¿Cómo elimino la capacidad de cambiar el ‘Icono del sitio’ en WordPress?

1 minuto de lectura

Avatar de usuario de Alberto93
alberto93

Estoy tratando de eliminar la capacidad de cambiar el ‘icono del sitio’ en un sitio de WordPress a menos que el usuario sea un ‘superadministrador’.

Eliminar lo que está en el cuadro rojo

Mi primer pensamiento fue tratar de modificar este fragmento de código aquí que se encuentra en **/wp-includes/class-wp-customize-manager.php

        $this->add_setting( 'site_icon', array(
        'type'       => 'option',
        'capability' => 'manage_options',
        'transport'  => 'postMessage', // Previewed with JS in the Customizer controls window.
    ) );

    $this->add_control( new WP_Customize_Site_Icon_Control( $this, 'site_icon', array(
        'label'       => __( 'Site Icon' ),
        'description' => sprintf(
            /* translators: %s: site icon size in pixels */
            __( 'The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least %s pixels wide and tall.' ),
            '<strong>512</strong>'
        ),
        'section'     => 'title_tagline',
        'priority'    => 60,
        'height'      => 512,
        'width'       => 512,
    ) ) );

Pero no quiero cambiar ningún archivo central/entregado. ¿Hay alguna otra manera de lograr esto? ¿Tal vez en el archivo functions.php del tema?

Además, actualmente estoy usando WordPress 4.5.2 y el tema veinte doce.

function remove_styles_sections($wp_customize) {
    $wp_customize->remove_control('site_icon');
}
add_action( 'customize_register', 'remove_styles_sections', 20, 1 );  

Esto es lo que hice para eliminar la funcionalidad del icono del sitio.

if( !is_super_admin( get_current_user_id()) ){
function remove_styles_sections(){
    global $wp_customize;
    $wp_customize->remove_control('site_icon');

}

// Priority 20 so that we remove options only once they've been added
add_action( 'customize_register', 'remove_styles_sections', 20 );}

¿Ha sido útil esta solución?