How to add a help tab to all admin pages – including plugin pages

This is how you can add help tabs to all admin pages—no matter if there already are any, or not: add_action(‘in_admin_header’, ‘wpse_124979_add_help_tabs’); function wpse_124979_add_help_tabs() { if ($screen = get_current_screen()) { $help_tabs = $screen->get_help_tabs(); $screen->remove_help_tabs(); $screen->add_help_tab(array( ‘id’ => ‘my_help_tab’, ‘title’ => ‘My Help’, ‘content’ => ‘<p>My help content…</p>’, )); if (count($help_tabs)) foreach ($help_tabs as $help_tab) $screen->add_help_tab($help_tab); … Read more

Remove post from new menu in top bar

The users can still create new posts if the URL is known, like; domain.com/wp-admin/post-new.php Here is the code you can use for that … added it to the file functions.php function hide_add_new() { global $submenu; // For Removing New Posts from Admin Menu unset($submenu[‘post-new.php?post_type=post’][10]); // For Removing New Pages unset($submenu[‘post-new.php?post_type=page’][10]); // For Removing CPTs unset($submenu[‘post-new.php?post_type=custom_post_type’][10]); … Read more

How to add menu to Dashboard that can be viewed by all users

You have to use the right capability for this. You chose manage_options, which by default only users with an Administrator user role have. So, change it to read or exist, for instance, and every user will be able to see and access the menu. add_dashboard_page( ‘custom menu title’, ‘Test’, ‘read’, ‘custompage’, ‘my_custom_menu_page’, plugins_url( ‘test/images/icon.png’ ), … Read more

Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress

If WordPress is loaded from outside of the main WordPress files using a separate PHP script that includes wp-load.php then the /template-loader.php file will not be loaded and therefore the template_redirect action will not be triggered. This is important because template_redirect is how the Toolbar is initialized on the front end. Taking a look at … Read more

How do I set up a webhook?

You are using self-hosted WordPress, which sometimes referred to as WordPress.org. Calling remote hook is still a possibility there, but unless your e-commerce solution supports it, you may need to add a custom code. Option – find a plugin There are some plugins which will post data to external URL when certain event happens, say, … Read more

Jquery no more loading, load-scripts.php not found (404)

I had this problem with a multisite setup. On my secondary site load-scripts.php returned a 404 error. the following line in wp-config.php fixed it for me: define( ‘CONCATENATE_SCRIPTS’, false ); # worked for me my .htaccess file: # BEGIN manual WordPress Multisite # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically … Read more

Make parent categories not selectable

I really doubt this is filterable, so jQuery comes to rescue 🙂 The Code add_action( ‘admin_footer-post.php’, ‘wpse_22836_remove_top_categories_checkbox’ ); add_action( ‘admin_footer-post-new.php’, ‘wpse_22836_remove_top_categories_checkbox’ ); function wpse_22836_remove_top_categories_checkbox() { global $post_type; if ( ‘post’ != $post_type ) return; ?> <script type=”text/javascript”> jQuery(“#categorychecklist>li>label input”).each(function(){ jQuery(this).remove(); }); </script> <?php } The Result Advanced There’s a caveat: whenever selecting a sub-category, it … Read more

How do I fix this error: Warning: invalid argument supplied for foreach()?

This usually happens when you are trying to do admin navigation stuff and you aren’t hooked into admin_menu. If you hook in before that, $menu hasn’t been created yet. add_action(‘admin_menu’, ‘my_plugin_add_menu’); function my_plugin_add_menu(){ $ptype=”my_post_type”; $ptype_obj = get_post_type_object( $ptype ); add_submenu_page( ‘my-menu-item’, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, “edit.php?post_type=$ptype” ); }