Too many widgets

WordPress admin is not designed to scale. If you are managing some resource which is 100x more than the average site, you need to be prepared to either develop your own solution to admin it or learn to live with it. In the case of widgets you should try the customizer or the accessibility mode … Read more

How to determine the number of widgets contained in a sidebar via customizer JS

While you can look at the WidgetControl instances contained inside of a SidebarSection, it is better to instead to look at the underlying setting that lists out the widgets contained inside of the sidebar. So do something like this: wp.customize( ‘sidebars_widgets[sidebar-1]’, function( sidebarSetting ) { console.info( sidebarSetting.get().length ); } ); Alternatively, with a reusable function: … Read more

Include chat (HTML, js, css) in all pages of WordPress

Try to include your inline script at the bottom of your snipper.js file, and then enqueue it using wp_enqueue_scripts(): function my_chat_script() { wp_enqueue_script( ‘chat-js’, ‘URL OF SNIPPER HERE’, false ); } add_action( ‘wp_enqueue_scripts’, ‘my_chat_script’ ); This is the proper way to include scripts in your WordPress using functions.php file. However, if you insist on adding … Read more

Customizer: widget-synced triggers twice

The reason for this is that the widget will run its update logic on keydown and also on change for a given input element. See https://github.com/WordPress/wordpress-develop/blob/4.7.2/src/wp-admin/js/customize-widgets.js#L891-L907 There are some tradeoffs made when widgets were added to the customizer to bring these PHP-driven interfaces into a JS-driven context. It wasn’t perfect and so this is part … Read more

How to give custom classes to the WordPress Menu widget

(Updated based on comments below.) <div class=”menu-menu-1-container”> is coming from WP’s default menu container. You can customize what tag is used (div, ul, etc.) or tell WP not to use a container at all, as well as set the ID and/or class (menu-menu-1-container, etc.) by using the container, container_class and container_id arguments when you call … Read more

Get widget Title from widget id

You can get the widget name from the widget id with this: <?php global $wp_registered_widgets; $id = ‘recent-comments-1’; // example if ( isset($wp_registered_widgets[$id][‘name’]) ) { echo $wp_registered_widgets[$id][‘name’]; } ?>