8

In my Wordpress theme that I've currently been building I do not take advantage of the Wordpress Theme Customization API. As much as I would like too, I've invested far too much time into my own personal theme options framework for changing things.

This leads me to my question. How do I remove the blue, "Customize Your Site" button from the dashboard as well as link shown when viewing Appearance > Themes? I did some Googling, but my Google-Fu failed and couldn't find a solution that didn't use CSS or Javascript.

Ideally a hook to remove it would be best. But if there is no clean way to do so, a JS and or CSS solution would be fine.

2
  • If you don't hook your Theme's options into the Theme Customizer, why would you need to hide the Theme Customizer entirely? It is a convenient way to modify Header, Background, Front Page display settings, Site Title and Tagline, etc. and preview those changes in real-time. So: why the need to remove it? Also: there's no reason you couldn't hook your "own personal theme options framework" into the Theme Customizer (and would provide a great benefit to your Theme users in the process). Jan 21, 2013 at 1:39
  • 3
    I want to remove it because it is confusing. People assume they can change theme settings via this button but in my theme you can't. As good as the inbuilt theme customisation API is, it has limitations and is far from an out of the box solution. It can be extended of course, but I'm working off of a library that I built which supports things I'd have to code in support for via the new API of which would take considerable time to do so. Jan 21, 2013 at 1:48

5 Answers 5

5

With the lastest version of WordPress (4.3) you can now natively remove the customizer's theme switch setting without resorting to CSS hacks.

/**
 * Remove customizer options.
 *
 * @since 1.0.0
 * @param object $wp_customize
 */
function ja_remove_customizer_options( $wp_customize ) {
   //$wp_customize->remove_section( 'static_front_page' );
   //$wp_customize->remove_section( 'title_tagline'     );
   //$wp_customize->remove_section( 'nav'               );
   $wp_customize->remove_section( 'themes'              );
}
add_action( 'customize_register', 'ja_remove_customizer_options', 30 );
1
  • You are correct (and welcome). I have chosen your answer as the correct one as the original was always just a hack around the problem. A native solution is more bulletproof. Aug 27, 2015 at 23:03
4

In the latest version of WordPress, the themes section is a panel, so it must be removed as follows:

add_action( 'customize_register', 'prefix_remove_customizer_options', 30 );
/**
 * Remove customizer options.
 *
 * @since 1.0.0
 * @param object $wp_customize The current WordPress customizer object.
 */
function prefix_remove_customizer_options( $wp_customize ) {
    $wp_customize->remove_panel( 'themes' );
}
1

This will fully remove the menu option:

add_action('admin_menu', function () {
    global $submenu;

    foreach ($submenu as $name => $items) {
        if ($name === 'themes.php') {
            foreach ($items as $i => $data) {
                if (in_array('customize', $data, true)) {
                    unset($submenu[$name][$i]);

                    return;
                }
            }
        }
    }
});

Other answers don't remove it if you are on another subpage + you hover themes menu (you'll see it in submenus)

0

There are no hooks to that part of the Dashboard.

It has to be done with CSS (or jQuery if you want to convert it in another thing).

add_action( 'admin_head-index.php', 'hide_customize_button_wpse_82424' );

function hide_customize_button_wpse_82424(){
    ?>
    <style type="text/css">div.welcome-panel-column:first-child {display:none;} </style>
    <?php
}

[update]

As pointed by @helenhousandi in a comment:

the wp_welcome_panel() function is added on the welcome_panel hook, but no, there are (purposefully) no hooks inside that function.

So, another approach is to remove the action hook and recreate the wp_welcome_panel() function, like so:

add_action( 'load-index.php', 'remove_welcome_panel' );
function remove_welcome_panel()
{
    remove_action( 'welcome_panel', 'wp_welcome_panel' );
    add_action( 'welcome_panel', 'my_welcome_panel' );
}

And my_welcome_panel is a replica of wp_welcome_panel() adapted as one wishes.

Please, also note her observation: my emphasis

I would suggest against having a publicly distributed theme remove it, though, because a user may come to expect that it's there. We found in user testing that many new users returned to that welcome panel even after getting acquainted.

4
  • Oh, that's a shame. Thank you very much for posting your solution, it works well! Jan 21, 2013 at 4:30
  • Actually, the wp_welcome_panel() function is added on the welcome_panel hook, but no, there are (purposefully) no hooks inside that function. It's more a use it as is, replace it with what works better for you/client/whomever, or remove it kind of thing. I would suggest against having a publicly distributed theme remove it, though, because a user may come to expect that it's there. We found in user testing that many new users returned to that welcome panel even after getting acquainted. Jan 22, 2013 at 23:37
  • @helenhousandi, thanks for the feedback! I've updated the Answer accordingly (:hopefully:).
    – brasofilo
    Jan 23, 2013 at 14:07
  • sorry to dig this up, but where would one have to add the code you posted in your answer? In the admin.php file or in functions.php of my theme?
    – Octoshape
    Apr 8, 2014 at 13:22
0

You need to Pass the following code at function.php

function theme_option_remove( $wp_customize ) {
$wp_customize->remove_section("themes");
}
add_action( 'customize_register', 'theme_option_remove' ,20 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.