Disable default WordPress widgets in sidebar

This function will disable all widgets: add_filter( ‘sidebars_widgets’, ‘wpse134172_disable_all_widgets’ ); function wpse134172_disable_all_widgets( $sidebars_widgets ) { if (true == true) { $sidebars_widgets = array( false ); } return $sidebars_widgets; } Now the true=true conditional will disable them all the time, while you only want this to happen with a clean install. So you will have to … Read more

How can I whitelist only specific shortcodes for processing in text widgets?

add_filter( ‘widget_text’, ‘wpse_137725_shortcode_whitelist’ ); /** * Apply only whitelisted shortcode to content. * * @link http://wordpress.stackexchange.com/q/137725/1685 * * @param string $text * @return string */ function wpse_137725_shortcode_whitelist( $text ) { static $whitelist = array( ‘gallery’, ‘form’, ); global $shortcode_tags; // Store original copy of registered tags. $_shortcode_tags = $shortcode_tags; // Remove any tags not in … Read more

Remove rss widget title link

You are trying to modify a built-in widget. Unfortunately for you there is no easy solution to get the results you desire. As you figured out already, there is no filter hook to modify the whole title output. How to get the results? Create your own Widget extending WP_Widget_RSS where you overwrite the parents method … Read more

Remove […] from RSS feed?

Here’s a suggestion: First we target the RSS widgets that have summaries. Then we filter the output of wp_trim_words() within the wp_widget_rss_output() function, to remove the […] part. Then we clean up in two ways: First we remove our wp_trim_words() filter, if it’s running, before the current widget is displayed. We can do that by … Read more

How to use control_callback when creating a widget via functions.php or plugin?

Actually the from fields only should be in the control_callback function , both form and handling so try this: <?php /* Plugin Name: custom dashboard widget Plugin URI: http://en.bainternet.info Description: custom dashboard widget with control form Version: 0.1 Author: bainternet Author URI: http://en.bainternet.info */ //show widget function custom_dashboard_widget_coach() { //get saved data if ( !$widget_options … Read more

Add div class to only one widget

You have two possible solutions. 1. The widget_display_callback filter hook This filter hook parameters allows you to target easily the widget instance and override it’s arguments. A possible approach would be: Inside the filter callback, modify the arguments for that instance, display it and then return false to prevent it from being displayed again the … Read more

Widget Update Code Not Working

You’re using get_field_id() for the name attribute of the form elements, but you should use get_field_name(). The field names are of the form widget-{$id_base}[{$number}][{$field_name}], but id’s can’t use [], so they are like widget-{$id_base}-{$number}-{$field_name}.

Widget with random posts from a blog for external sites

To create a special output of random posts: Register an endpoint to the root of your blog. See A (Mostly) Complete Guide to the WordPress Rewrite API for details. Refresh the permalink settings. I would do this on (de)activation only. Hook into ‘template_redirect’ and return your output depending on the details of the requested endpoint. … Read more

Add New Footer Widget Area with Limited Options?

Widget areas are the wrong tools for what you need. They are built to offer a choice. Breaking that would be very difficult … and hard to understand for the user. Alternative: Use a custom setting, for example in wp-admin/options-general.php where the tagline and the site title is. There is even a hook for such … Read more

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