0

Does the Wordpress theme browser have a name? I looked in its code and don't see something spesific and when I search Google I get other topics.

To disable the theme browser and keep upload theme button active, I would like to add some code like:

add_filter('theme_browser', '__return_false');

Actually I want to disable both the theme browser and the plugin browser. Is there a way to do this but keep the upload theme button active and upload plugin button active?

2 Answers 2

0

You can block the API.

add_action('themes_api', 'se_block_api');
add_action('plugins_api', 'se_block_api');
function se_block_api(){
    exit;
}
1
  • Good idea. That works partly, but then displays an error and also the javascript would still be running I think; slowing the page. I think a filter would be better, if there was one, then that would stop the javascript from trying to load the theme/plugin browsers, at php level. -- But might use your method for a while. Thanks.
    – Angel Hess
    Commented Feb 24, 2022 at 22:17
0

Use action to block themes API, and filter to block plugins API.

add_action('themes_api', function() { exit; });
add_filter('plugins_api', function() { return new stdClass(); });

If you don't like seeing the spinner, you can just hide it using CSS:

add_action('admin_head', function() {
    echo '<style>body.theme-install-php .spinner, body.plugin-install-php .spinner { display: none !important; }</style>';
});

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.