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

Different widgets on different page templates?

You will need to create more sidebars in your functions.php file and then edit the page templates to call the sidebar you want. Adding sidebars Go in to your functions.php file. You should see some sidebars already being registered. The code will look something like this: //Adds default sidebar if ( function_exists(‘register_sidebar’) ) register_sidebar(); To … Read more

How to add image uploader to a custom widget?

Firstly, it is not recommended to use WP_PLUGIN_URL constant, instead use plugins_url() function. Second thing, it will not work when you put your files in the theme. You must put the necessary folder and file in the plugin if have to use this constant or function. Make sure, you have put correct path and you … Read more

How to refresh Theme Customizer after change color inside wpColorPicker?

Try using the existing WordPress function to modify color palette like: function my_mce4_options( $init ) { $default_colours=” “000000”, “Black”, “993300”, “Burnt orange”, “333300”, “Dark olive”, “003300”, “Dark green”, “003366”, “Dark azure”, “000080”, “Navy Blue”, “333399”, “Indigo”, “333333”, “Very dark gray”, “800000”, “Maroon”, “FF6600”, “Orange”, “808000”, “Olive”, “008000”, “Green”, “008080”, “Teal”, “0000FF”, “Blue”, “666699”, “Grayish blue”, … Read more

How can I add links to widget titles?

Making the title click-able WordPress won’t let you pass HTML code in the title of the widget, but it does have the handy parameters $before_title and $after_title that you can use to manipulate things. In your widget, just add the first part of the link (<a href=”…”>) to the end of $before_title and the last … Read more

Prevent second widget activation

You can create a one-time-use widget with the following example found here: wp_register_sidebar_widget The following code will create a widget called “Your Widget” which will become available in the WordPress Administrative Panels. The widget can then be dragged to an available sidebar for display. Note that this widget can only be used once in exactly … Read more

Get sidebar parameters (before_widget, before_title, etc.) from within a widget

The parameters are given (as an array) as the first argument provided to the widget method. The second argument, $instance, holds the options for that particular instance of the widget. My usual set up is: function widget($args, $instance){ //Extract the widget-sidebar parameters from array extract($args, EXTR_SKIP); echo $before_widget; echo $before_title; //Display title as stored in … 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

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