2016-06-21 39 views
1

我試圖刪除在Wordpress網站中更改「網站圖標」的能力,除非用戶是「超級管理員」。如何刪除在WordPress中更改「網站圖標」的功能?

Remove whats in the red box

我的第一個念頭就是想在這裏修改該代碼段位於** /可溼性粉劑包含/類WP-定製-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, 
    ))); 

但我不想更改任何核心/交付的文件。有沒有其他方法可以實現這一點?也許在主題的functions.php文件中?

另外,我目前使用WordPress 4.5.2和第二十二個主題。

回答

0

這是我爲了去除網站圖標功能而做的。

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);} 
1
function remove_styles_sections($wp_customize) { 
    $wp_customize->remove_control('site_icon'); 
} 
add_action('customize_register', 'remove_styles_sections', 20, 1);