How to inject variables into public-facing JS using wp_enqueue_script
How to inject variables into public-facing JS using wp_enqueue_script
How to inject variables into public-facing JS using wp_enqueue_script
with is_singular() if (!is_singular(‘post’)) { function live_search() { wp_enqueue_script(‘live_search’, get_bloginfo(‘stylesheet_directory’) .’/assets/js/live.search.js’, array(‘jquery’), ‘1.0.1’, true ); wp_localize_script( ‘live_search’, ‘MovieWordpressSearch’, array( ‘api’ => moviewp_url_search(), ‘nonce’ => moviewp_create_nonce(‘moviewp-search-nonce’), ‘area’ => “.live-search”, ‘more’ => “Show all”, ) ); } add_action(‘wp_enqueue_scripts’, ‘live_search’); }
wp_editor() youtube link does not load video
Actually these types of task is for plugin not for widget. Based on the value of widget instance scripts can be enqueued to footer not in head or just after body tag. Reason behind this is the instance value can be checked inside the function widget of widget class. The function widget is called when … Read more
We can try to use has_block(), has_blocks() and parse_blocks() to find an embed with a given providerNameSlug attribute. Untested suggestion: function has_block_embed_by_provider_wpse( $provider, $post = null ) { if ( ! has_blocks( $post ) ) { return false; } if ( ! is_string( $post ) ) { $wp_post = get_post( $post ); if ( $wp_post … Read more
How to enqueue JavaScript file that depends on CSS stylesheet
How can I manually enqueue plugin scripts
Is there a way to check for an attribute of a script when using script_loader_tag?
Change script type and src of plugins in theme
Another option is to use the script_loader_tag filter to catch and remove the actual HTML tag before it is output, eg.: add_filter( ‘script_loader_tag’, ‘remove_social_login_frontend’, 10, 3 ); function remove_social_login_frontend( $tag, $handle, $src ) { if ( ‘wc-social-login-frontend’ === $handle ) {$tag = ”;} return $tag; } Note you could also do this via a string … Read more