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’]; } ?>

Wp Customizer event for when a new widget has been added

In order to interact with the event “widget-added” , you should enqueue your JavaScript file using “customize_controls_enqueue_scripts” to avoid it being part of the repetitively loading preview iframe ( where $(document) is different from the parent page document). I was able of interacting with the “widget-added” event using this example : in theme’s functions.php function … Read more

Image Upload Widget Issue

Updated Actually, you have to trigger change event to activate the Save button. WordPress widget handler listens to only changes. When you update the input field value with JS, DOM doesn’t trigger any change. That’s why we have to trigger manually. Please check the following code – $(‘.deo-‘ + type + ‘-hidden-input’).val(attachment.url).trigger(‘change’);

Widget html code error

Changes were made to the Text Widget in WordPress 4.8. The editing experiencing was enhanced in some ways but this also caused issues with certain HTML tags and formatting. Fortunately, a new Custom HTML Widget was added in WordPress version 4.8.1. The Custom HTML Widget allows <script> tags, and will not remove certain formatting unlike … Read more