Dashboard like meta boxes in my plugin – how to save their position and open/closed state?

When ordering or closing metaboxes, those actions require nonces, add the following to your code and see if that resolves the problem. <?php wp_nonce_field(‘closedpostboxes’, ‘closedpostboxesnonce’, false ); ?> <?php wp_nonce_field(‘meta-box-order’, ‘meta-box-order-nonce’, false ); ?> Additional: You should add metaboxes to your page using add_meta_box and output them using do_meta_boxes passing in the hook for your … Read more

How to display the user that published a pending post?

The reason that get_the_modified_author() is not working is that it relies on being used within the WordPress loop. wp_get_recent_posts() does not set up a global post object. Here is a complete example based on your original code that replaces get_the_modified_author() with some simple code to get the name of the last person who edited the … Read more

How to Make an admin_notices Message That Disappears Once the User Leaves That Particular Page?

The short answer is: Use Query Strings. If you notice in the address bar immediately after you publish a Post… You will see something similar to this: domain.com/wp-admin/post.php?post=4935&action=edit&message=6 There’s a few different Query Variables: post contains the ID of the Post being edited. action is saying we’re currently “editing” the Post. message refers to what … Read more

How to Remove All Widgets from Dashboard?

From this Q&A, I’ve learned about the global variable $wp_meta_boxes. And over there is also the code to remove the default meta boxes. After examining the variable, this is the code I wrote to remove all Dashboard Widgets, including the ones added by plugins: add_action(‘wp_dashboard_setup’, ‘wpse_73561_remove_all_dashboard_meta_boxes’, 9999 ); function wpse_73561_remove_all_dashboard_meta_boxes() { global $wp_meta_boxes; $wp_meta_boxes[‘dashboard’][‘normal’][‘core’] = … Read more

Disable “Blogroll” or “WordPress Dashboard News” section in WordPress v.4.1?

If you want to remove metaboxes from the dashboard page you can add this to functions.php function remove_dashboard_widgets () { remove_meta_box(‘dashboard_quick_press’,’dashboard’,’side’); //Quick Press widget remove_meta_box(‘dashboard_recent_drafts’,’dashboard’,’side’); //Recent Drafts remove_meta_box(‘dashboard_primary’,’dashboard’,’side’); //WordPress.com Blog remove_meta_box(‘dashboard_secondary’,’dashboard’,’side’); //Other WordPress News remove_meta_box(‘dashboard_incoming_links’,’dashboard’,’normal’); //Incoming Links remove_meta_box(‘dashboard_plugins’,’dashboard’,’normal’); //Plugins remove_meta_box(‘dashboard_right_now’,’dashboard’, ‘normal’); //Right Now remove_meta_box(‘rg_forms_dashboard’,’dashboard’,’normal’); //Gravity Forms remove_meta_box(‘dashboard_recent_comments’,’dashboard’,’normal’); //Recent Comments remove_meta_box(‘icl_dashboard_widget’,’dashboard’,’normal’); //Multi Language Plugin remove_meta_box(‘dashboard_activity’,’dashboard’, ‘normal’); … Read more

Storing custom dashboard widget options in wordpress

Solution pulled from OP. Ok fixed. In widget-config.php there is no check if the form has been submitted, so every time you load configuration it updates with empty values or keeps default ones. Add this check if (!empty($_POST)) before updating options values and display stored value of number-input: <input type=”text” name=”number” value=”<?php echo self::get_dashboard_widget_option(self::wid, ‘example_number’); … Read more

Enqueue script in specific page

Inside admin-header.php, there’s the following set of hooks: do_action(‘admin_enqueue_scripts’, $hook_suffix); do_action(“admin_print_styles-$hook_suffix”); do_action(‘admin_print_styles’); do_action(“admin_print_scripts-$hook_suffix”); do_action(‘admin_print_scripts’); do_action(“admin_head-$hook_suffix”); do_action(‘admin_head’); The one to always use it admin_enqueue_scripts, both for stylesheet and scripts. More info in this answer. It has one additional argument, the $hook_suffix. This argument is exactly the same as the return value that you get from add_submenu_page() … Read more