List table not rendering when $this->items is filled

I did same error first time I implemented WP_List_Table. The problem is that when you call WP_List_Table::display() WordPress in turn calls: WP_List_Table::display_rows_or_placeholder() WP_List_Table::display_rows() WP_List_Table::single_row() WP_List_Table::single_row_columns() Last function is called for every row. If you look at its code (see source), it has: if ( ‘cb’ == $column_name ) { // you don’t have ‘cb’ column, … Read more

Add visit site to your toolbar instead of being in the dropdown

Not complicated, but a little tricky to get timing right. Something like this should work, but you might need to experiment with priority to get the link to specific position on the bar: add_action( ‘admin_bar_menu’, function ( $wp_admin_bar ) { if ( ! is_admin() ) { return; } /** @var WP_Admin_Bar $wp_admin_bar */ $wp_admin_bar->remove_node( ‘view-site’ … Read more

remove_menu_page doesn’t work on custom plugin menus

Place this below temporary code in your functions.php or any where that can be executed. add_action( ‘admin_init’, ‘the_dramatist_debug_admin_menu’ ); function the_dramatist_debug_admin_menu() { echo ‘<pre>’ . print_r( $GLOBALS[ ‘menu’ ], TRUE) . ‘</pre>’; } Then search for the plugin-slug. In which array you find it copy the [2] value and put it in remove_menu_page(‘the [2] value’) … Read more

Add an admin page, but don’t show it on the admin menu

Use a submenu page as parent slug. The admin menu has just two levels, so the imaginary third level will be hidden. Sample code, tested: add_action( ‘admin_menu’, ‘wpse_73622_register_hidden_page’ ); function wpse_73622_register_hidden_page() { add_submenu_page( ‘options-writing.php’, ‘Hidden!’, ‘Hidden!’, ‘exists’, ‘wpse_73622’, ‘wpse_73622_render_hidden_page’ ); # /wp-admin/admin.php?page=wpse_73622 } function wpse_73622_render_hidden_page() { echo ‘<p>hello world</p>’; }

Plugin View Details Link

The ‘View details’ link in the installed plugins list table is only shown for plugins that are hosted in the WordPress.org plugin repository. If you take a look at the source for WP_Plugins_List_Table->single_row(), you’ll see that the details link is only generated if there’s API data present, e.g. the slug is set: // Details link … Read more

The Great WordPress Admin Menu Challenge of Jan 2011 (a.k.a. How to Resolve Some Challenges when Modifying the WordPress Admin Menu System?)

Mike, I’ve taken a look at the code and your ideal end use case … and some of them, frankly, aren’t possible with the current system. Again, your requirements: Get the “Microsite” submenu page to be highlighted when editing an Attorney Get the Attorney Menu Page link to link to /wp-admin/edit.php?post_type=attorney when editing an Attorney … Read more