How to minimize WP dashboard menu programmatically?

Add a javascript to all admin pages: add_action( ‘admin_print_scripts’, ‘auto_collapse_menu’ ); function auto_collapse_menu(){ wp_enqueue_script( ‘autocollapsemenu’, plugins_url( ‘autocollapsemenu.js’, __FILE__ ), array( ‘jquery’ ), false, true ); } The javascript: jQuery(document).ready( function($){ // catch every click inside element with ID ‘adminmenu’ $( ‘#adminmenu’ ).click( function(e){ // true if the menu is folded, false if not var bodyFolded … Read more

I changed “Howdy” in the admin bar in the dashboard, but when I’m viewing the site it still says Howdy!

I see a couple of problems here. This line if (!is_admin() || ‘default’ != $domain) return $translated; returns the Howdy right back unchanged if is_admin is false – which it is if you’re not in the dashboard. Also, you’re running your filter callback on gettext. This means it will be run every time some internationalized … Read more

Get all posts by post_author

The shortest possible answer would be to correct ‘post_author’ to ‘author’, since that is the key WP is looking for. If a key is incorrect or misspelled it will be ignored, as was the case with ‘post_author’.

Adding help information to custom post edit page

Try this: function options_instructions_example() { global $my_admin_page; $screen = get_current_screen(); if ( is_admin() && ($screen->id == ‘custom_post_type_name’) ) { function add_content_after_editor() { global $post; $id = $post->ID; echo ‘<div class=”postbox” style=”background:#0074a2;color:#fff;margin-top:20px;”><div class=”inside”>’; echo ‘Instructions go here.’; echo ‘</div></div>’; } add_action( ‘edit_form_after_title’, ‘add_content_after_editor’ ); } } add_action( ‘admin_notices’, ‘options_instructions_example’ ); It will result in something that … Read more

How do I pass arguments to dashboard widget callback functions?

The args are stored in the 2nd variable passed to your callback function. add_action( ‘wp_dashboard_setup’, ‘sample_widget_setup’ ); function sample_widget_setup() { wp_add_dashboard_widget( ‘sample_dashboard_widget’, ‘Sample Widget’, ‘sample_dashboard_widget_callback’, null, ‘sample_string’ ); } function sample_dashboard_widget_callback( $var, $args ) { var_dump( $args ); } Output from above: array ‘id’ => string ‘sample_dashboard_widget’ (length=23) ‘title’ => string ‘Sample Widget’ (length=13) ‘callback’ … Read more

How To Remove Dashboard Menu Items for Multisite Users?

1) Install & network activate User Role Editor plugin from http://example.com/wp-admin/network/plugins.php 2) Then go to Settings > User Role Editor menu on network and make sure you have the settings as shown in following screenshot. 3) Go to “User Role Editor” settings page on your main site http://example.com/wp-admin/users.php?page=users-user-role-editor.php and select the “Administrator” role. Then remove … Read more

Give editors access to particular plugin – turn “admin.php” into “edit.php”

As I mentioned, it’s not the best practice to edit the plugin’s source codes because this will be overwritten if you were to get the latest update from the author. Nonetheless, to allow the Business Opening Hours plugin to show for your Editors open /business-opening-hours/bizo-hours.php and tweak the following lines. At the time of this … Read more

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