Multilple single-use widgets with the same output callback

It appears that wp_register_sidebar_widget is a very outdated function from early implementations of widgets. Apparently back then widgets could only be used once each and the output callback name seems to be what made a widget unique, despite the existence of an ID. The single-use nature of these widgets doesn’t appear to be an intentional … Read more

How to add just one specific page to widget without plugin?

Follow this step for Only one page add custom sidebar Step 1: Put this code in your theme function.php file. Register custom sidebar and your custom add_action. function wpdocs_theme_slug_widgets_init() { register_sidebar( array( ‘name’ => __( ‘Custom Sidebar’, ‘textdomain’ ), ‘id’ => ‘sidebar-10’, ‘description’ => __( ‘Widgets in this area will be shown on all posts … Read more

How to check if you are on widget.php page?

You may use the global variable $pagenow to figure out if you are on a particular admin page, in your case this would be checking if you are on the widgets.php admin page: <?php global $pagenow; if( $pagenow === ‘widgets.php’ ) { ?> <script> // JavaScript goes here </script> <?php }   Furthermore, it will … Read more

How to save widget fields generated from an array?

OK, so I’ve done some debugging and I know where your problem lies… First of all in update function: public function update( $new_instance, $old_instance ) { $instance = $old_instance; if ( empty( $this->fields ) ) { return $instance; } $instance = $this->save_fields( $new_instance, $old_instance ); return $instance; } You shouldn’t use $old_instance as starting point. … Read more

How to allow your custom widget as block in gutemberg editor

I found the solution here and here. My OOP Code : Block_Type abstract Class Block_Type { public $handle; public $handle_editor; public $handle_block; private $editor_js_file; public $editor_js_file_path; private $editor_css_file; public $editor_css_file_path; private $css_file; public $css_file_path; public function __construct( $handle, $editor_js_file_path = null, $editor_css_file_path = null, $css_file_path = null ) { $this->handle = “h4a-” . $handle; $this->handle_editor … Read more

Prev / Next menu item

I wrote this short-code plugin. To use it add the following shortcode to any page or inside a shortcode widget. [menu_navigator menu=’The name of your menu’] menu will default to “Table of contents” if not specified. To install, just save to a file named shortcode-blazoruniversity-menu-navigator.php, zip it up, and then upload it as a plugin. … Read more