Customising widget titles/headings in WP 5.8

You’re right. I didn’t notice it before ! If you look at the code, you can see that Widgets are now showed from /wp-includes/widgets/class-wp-widget-block.php which extends /wp-includes/class-wp-widget.php The first file is a new one introduced in WP 5.8. In there you can see that the widget is now displayed through widget_block_content filter which use the … Read more

Display sidebar that created in functions.php

Here’s the way i would code it. Tested Add to functions file add_action( ‘widgets_init’, ‘wpsites_add_widget’ ); function wpsites_add_widget() { register_sidebar(array( ‘name’=>’Sidebar-Aries’, ‘id’ => ‘sidebar-aries’, ‘description’ =>’Display all the contents of sidebar at Aries page.’, ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ => ”, ‘after_title’ => ”, )); } Or you could use this code in … Read more

register child class in another plugin

I question the wisdom of extending a class from another plugin. You have no idea what will happen next time that other plugin gets updated. However, generally speaking you can control when in a hook “queue” a function runs by passing a third parameter– a priority. So pass a priority high enough and your function … Read more

Best way to allow manageable social media URLS?

The best way is on the user profile page using the contact methods extension: add_filter( ‘user_contactmethods’, ‘more_contactmethods’ ); function more_contactmethods( $contactmethods ) { $contactmethods[‘twitter’] = ‘Twitter username’; $contactmethods[‘facebook’] = ‘Facebook URL’; return $contactmethods; } This adds fields to the user profile page for those social networks. You can have as many as you like, then … Read more

Remove Widgets in Dashboard

I think the best way to go about this is to create a new plugin (or put in the theme function.php but a plugin will always work independent of theme) that disables the widgets you don’t need. Something like this. function wpse_47707_disable_admin_meta() { remove_meta_box( ‘dashboard_browser_nag’, ‘dashboard’, ‘normal’ ); remove_meta_box( ‘dashboard_right_now’, ‘dashboard’, ‘normal’ ); remove_meta_box( ‘dashboard_recent_comments’, … Read more

Count widgets in position and set class

I found an answer on this very site that didn’t come up before in search before @ Get number of widgets in sidebar function cosmos_bottom_sidebar_params($params) { $sidebar_id = $params[0][‘id’]; if ( $sidebar_id == ‘sidebar-bottom’ ) { $total_widgets = wp_get_sidebars_widgets(); $sidebar_widgets = count($total_widgets[$sidebar_id]); $params[0][‘before_widget’] = str_replace(‘class=”‘, ‘class=”span’ . floor(12 / $sidebar_widgets) . ‘ ‘, $params[0][‘before_widget’]); } … Read more

how to extend a WP_widget twice

You have to make sure that all of your parameters are passed all the way through to the WP_Widget class. Your code is very truncated but I am pretty sure that is what you are doing wrong. The widget code below works– it doesn’t do much of anything, but it works. See if you can … Read more

Multiple entries in get_option results? or why is _multiwidget set to 1?

I found the answer. Multiwidget is a nice new feature within wordpress’ new widget API. Yet there is sparse documentation on how to use it. $options = get_option( ‘your_option_id’ ); if( isset($options) && isset($options[$this->number])) { //$this->number returns the unique widget id that corresponds to the database index $instance_options = $options[$this->number]; } //now use $instance_options[‘setting’]