Getting the different post statuses + count like in edit.php, in a custom submenu page

The class used in edit.php is an extension of the WP_List_Table: WP_Posts_List_Table. See wp-admin/includes/class-wp-posts-list-table.php. And here you find a call to wp_count_posts( $type=”post”, $perm = ” ). The first parameter is for the post type, the second can be empty or readable. If it is readable and the current user has no permission to see … Read more

remove_action with profile_personal_options

Sometimes you need to get a little creative when customizing the WordPress admin area. It’s often possible to do it without CSS, but it isn’t always straightforward: understanding what’s happening on the source files and digging through the many functions called in the ifs and elses is a must. Here’s something slightly hacky I came … Read more

wp-admin does not redirect to dashboard

The problem was in .htaccess. There was an old global .htaccess file (from the old website) besides the wordpress one which was hidden on the sever (by admins of the hosting company) which rewrite rules harmed the ones in wordpress. I actually had to contact the admins and ask them to remove those rewrite rules.

Redirect users away from Admin breaks ajax

You can and a check for the DOING_AJAX constant which is defined on an Ajax in your conditional check: function no_admin_access() { if ( // Don’t do this for AJAX calls ! defined( ‘DOING_AJAX’ ) // Capability check && ! current_user_can( ‘delete_posts’ ) ) { // Redirect to home/front page wp_redirect( site_url( “https://wordpress.stackexchange.com/” ) ); … Read more

How do I allow users to follow a post and then allow admins to email all users who have followed that post?

I don’t think its polite to send email to all users who Favorited your post. Because some people favorite your post to bookmark it. So don’t combine favorite with follow. So here is my suggestion: For bookmarking, use WP favorite posts plugin. As for the follow there is no plugin exists for normal wordpress installation. … Read more

How to set Active plugins as the default screen?

There are two options, modify the menu link href attribute or redirect the main screen. Modify menu Alter the global variable $submenu. This method works for Single and Multisite. Problem: the submenu item Installed Plugins doesn’t show in bold. add_action( ‘admin_head’, ‘b5f_plugins_redirect_to_active’ ); function b5f_plugins_redirect_to_active() { global $submenu; $submenu[‘plugins.php’][5][2] .= “?plugin_status=active”; return; } Redirect page … Read more

Add tabbed menu to admin page

if you don’t like this method. maybe you would like the follow code: you can try to put the follow code in your functions.php file- // Theme options /* get options & set default options */ if( !function_exists(‘share3h_theme_get_options’) ) : function share3h_theme_get_options($option){ $share3h_theme_options = get_option(‘share3h_theme_options’); if( !$share3h_theme_options || array_key_exists($option, $share3h_theme_options) ) : $share3h_theme_default_options = array( … Read more

Remove “Get Shortlink” button in admin of custom post type

If you filter pre_get_shortlink and return anything but false WordPress will not create a shortlink with its own logic. If your return value is empty, the shortlink UI will not be printed. Combining both leads us to: add_filter( ‘pre_get_shortlink’, ‘__return_empty_string’ ); If you want to restrict the filter to a specific post type, check the … Read more