Order Admin sub-menu items?

The filter ‘custom_menu_order’ will not work on the menu order because apply_filters in wp-admin/includes/menu.php supplies false as the filtered content. You can try changing false to $menu and the filter works grand. Since we obviously can’t touch the core, here’s how I got it to work: function custom_menu_order(){ global $submenu; $find_page=”edit.php”; $find_sub = ‘Post Tags’; … Read more

Can I have Post Types under other Post Types in Admin menu?

Yes, this capability is available with register_post_type, via the show_in_menu argument, but whether or not the particular plugin you are using supports this I don’t know. add_action( ‘init’, ‘wpa70679_custom_types’ ); function wpa70679_custom_types() { register_post_type( ‘parent_type’, array( ‘public’ => true, ‘labels’ => array( ‘name’ => ‘Parent post type’ ) ) ); register_post_type( ‘child_type’, array( ‘public’ => … Read more

Edit specific nodes in WP_Admin_Bar

Yes I recently ran into the situation where I wanted to change the profile link in the user-info section of the admin bar. The problem is that you can only get all nodes, add and remove them. Not edit. And you also cannot modify the $wp_admin_bar->nodes property due it is private. When easily removing and … Read more

Removing an admin page added by a 3rd party plugin. Gravity forms in this example

Ok, Eugene’s Answer works in the case of a plugin that doesn’t deals with custom capabilities. http://codex.wordpress.org/Roles_and_Capabilities The WordPress Plugin API allows Roles and Capabilities to be added, removed and changed. Since Plugins might change Roles and Capabilities, just the default ones are addressed in this article. So, if his code works without checking for … Read more

Remove Customize Background and Header from Appearance admin menu without CSS or JS

As overcomplicated as it sounds, I always find the best way to handle admin menu modifications is to overlook the given wordpress remove_ functions and go straight to the $menu and $submenu globals. In the case you’ve specified here, you’d want to change your code to: add_action(‘admin_menu’, ‘remove_unnecessary_wordpress_menus’, 999); function remove_unnecessary_wordpress_menus(){ global $submenu; unset($submenu[‘themes.php’][20]); unset($submenu[‘themes.php’][22]); … Read more

Run functions only in the admin area?

There is very little overhead to assigning couple of filters on hooks that simply won’t fire on front end. In general it would be something like this: add_action(‘init’, ‘admin_only’); function admin_only() { if( !is_admin() ) return; // filter assignemnts and such go here } Also create_function() is not recommended for performance and some other reasons. … Read more

What is the recommended way to create plugin administration forms?

I personally just add a menu link and in the function for it handle the form. With $_SERVER[‘REQUEST_URI’] as the action. Example below. add_action(“admin_menu”, “menu” ); function menu(){ add_menu_page(‘Test form’, ‘Test form’, ‘manage_options’, ‘show_form’ ); } function show_form(){ if ( $_SERVER[“REQUEST_METHOD”] == “POST” ){ print “do stuff”; } else { ?><form method=”post” action=”<?php echo $_SERVER[‘REQUEST_URI’]; … Read more

Modify Admin Bar Link

I’ve not worked with the admin-bar before. However, I found your question interesting and decided to take a look. If you add a function to handle the action hook ‘admin_bar_menu’ and set the priority to be higher than 70, you will have access to the raw admin_bar_menu nodes where you can modify the properties you … Read more

Creating a WordPress admin page without a menu for a plugin

I am less convinced that I know what you are doing than I once was. // Add menu and pages to WordPress admin area add_action(‘admin_menu’, ‘myplugin_create_top_level_menu’); function myplugin_create_top_level_menu() { // This is the menu on the side add_menu_page( ‘MyPlugin’, ‘MyPlugin’, ‘manage_options’, ‘myplugin-top-level-page’ ); // This is the first page that is displayed when the menu … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)