Add my own button next to “Screen options” and “Help” in the admin

The HTML echo ‘<div id=”screen-meta-links”>’; echo ‘ <div id=”contextual-help-link-wrap” class=”hide-if-no-js screen-meta-toggle”>’; echo ‘ <a href=”#” id=”your-own-button” class=”show-settings”>Text for your button</a>’; echo ‘ </div>’; echo ‘</div>’; echo ‘<br style=”clera:both” />’; echo ‘<div id=”your-button-content” class=”your-button-hide”>’; // your content goes here echo ‘</div>’; And you need some custom JavaScript jQuery(document).ready( function($){ $( ‘.your-button-hide’ ).each( function(e){ $( this ).hide(); … Read more

How to obtain the user ID of the current profile being edited in WP-Admin?

There is a global variable called … $user_id available on that page. Always. From user-edit.php: $user_id = (int) $user_id; $current_user = wp_get_current_user(); if ( ! defined( ‘IS_PROFILE_PAGE’ ) ) define( ‘IS_PROFILE_PAGE’, ( $user_id == $current_user->ID ) ); if ( ! $user_id && IS_PROFILE_PAGE ) $user_id = $current_user->ID; elseif ( ! $user_id && ! IS_PROFILE_PAGE ) … Read more

Plugin to remove Admin menu items based on user role?

Update: reading mike’s answer again got me thinking that you can add a new capability to a role and use that as you removal condition, so: // first add your role the capability like so // get the “author” role object $role = get_role( ‘administrator’ ); // add “see_all_menus” to this role object $role->add_cap( ‘see_all_menus’ … Read more

Load plugin scripts and styles only on plugin page

When you register a plugin option page you get a hook from the registration function: $hook = add_menu_page( ‘T5 Demo’, // page title ‘T5 Demo’, // menu title ‘manage_options’, // capability ‘t5-demo’, // menu slug ‘my_render_page’ // callback function ); Use this hook to enqueue the scripts and styles: add_action( “admin_print_styles-$hook”, “my_enqueue_style” ); add_action( “admin_print_scripts-$hook”, … Read more

How to remove list view from media library?

This is a little hacky, but doesn’t require you to edit core files, which you should never do, as you are aware. add_action(‘admin_init’, function() { $_GET[‘mode’] = ‘grid’; }, 100); This will always force the mode into grid view. What it does not do, it does not remove the List View icon it does not … Read more

Change admin bar to default:off

add_action(“user_register”, “set_user_admin_bar_false_by_default”, 10, 1); function set_user_admin_bar_false_by_default($user_id) { update_user_meta( $user_id, ‘show_admin_bar_front’, ‘false’ ); update_user_meta( $user_id, ‘show_admin_bar_admin’, ‘false’ ); } Place in theme functions file or you can make into a plugin. Once user registers it will go and set the users admin bar prefs to false. The user can then, once logged in, set this to … Read more

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