How to add a column to the Trash page?

You can check the value of the post_status query variable and make sure that it’s set to trash: function wpse239286_trash_column( $columns ) { // Bail if we’re not looking at trash. $status = get_query_var( ‘post_status’ ); if ( ‘trash’ !== $status ) { return $columns; } return array_merge( $columns, array( ‘trash_column’ => __( ‘Trash Column’, … Read more

Activate a new WordPress Theme Only for Admins

At first, you should active the WordPress Debug mode to get the error after implement your code. The code should work, also tested on my environment. I use it on a client installation and works really well. See my source below. It is important that you use the right string for the theme slug, like … Read more

How get Themes list via REST api?

You can write your own endpoint and use wp_get_themes to get a list of themes via that. Here is a simple one: add_action( ‘rest_api_init’, function () { //Path to rest endpoint register_rest_route( ‘theme_API/v1’, ‘/get_theme_list/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘theme_list_function’ ) ); }); // Our function to get the themes function theme_list_function(){ // Get … Read more

When is is_admin() available?

When is is_admin() available? Pretty much everywhere. The only example I can think of where it wouldn’t be available, is super early in files such as wp-config.php, and some drop-ins. But by the time an mu-plugin, a theme, or a plugin is loaded it’s present. Now, it would work to wrap the inner workings of … Read more