How to create a widgetized sidebar for every category dynamically?

Not a good thing if you have a lot of categories, so be careful! First, add the following function in functions.php: add_action( ‘widgets_init’, ‘generate_widget_areas’ ); function generate_widget_areas() { //Do not create for uncategorized category $terms = get_categories(‘exclude=1&hide_empty=0’); foreach ($terms as $term) { register_sidebar( array( ‘name’ => ‘Category ‘.$term->name, ‘id’ => $term->slug.’-widget-area’, ‘description’ => ‘Widget area … Read more

Add class to before_widget for all widgets with a dropdown and a counter

The CSS classes are applied in the function dynamic_sidebar(). There is no specific filter for that: // Substitute HTML id and class attributes into before_widget $classname_ = ”; foreach ( (array) $wp_registered_widgets[$id][‘classname’] as $cn ) { if ( is_string($cn) ) $classname_ .= ‘_’ . $cn; elseif ( is_object($cn) ) $classname_ .= ‘_’ . get_class($cn); } … Read more

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

How to get the registered sidebar’s name by its id?

Sidebars are stored in global variable $wp_registered_sidebars. You can get the sidebar properties using this variable. global $wp_registered_sidebars; if ( isset( $wp_registered_sidebars[‘sidebar-2’] ) ) { echo $wp_registered_sidebars[‘sidebar-2’][‘name’]; } Note that do not use it too early, either on/after widgets_init hook or in a template file.

Anyway to edit the titlebar of WordPress Widgets in the Admin area?

I believe you are looking for $params = apply_filters( ‘dynamic_sidebar_params’, $params ); (look here: https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets.php#L706). Now this filter will evaluate both in front end and back end. so to answer your question, you could wrap your filter in a if( is_admin() ){ // Do icons } check. Better yet, you could define this at registration … Read more