I think you could or even should combine your filters to keep your code DRY.
add_filter('script_loader_tag', function( $tag, $handle ) {
if ( 'chargebee' == $handle ) :
return str_replace( ' src', ' data-cb-site="mydomain" src', $tag );
elseif( 'google-maps' == $handle ) :
return str_replace( ' src', ' async="async" defer src', $tag );
endif;
return $tag;
}, 10, 2);
Related Posts:
- Ajax call always returns 0
- plugins_url vs plugin_dir_url
- Get list of years when posts have been published
- Where and how to put inline js in pages
- Is it possible to remove the “standard” post format?
- Do WordPress’ cron’s clean up expired transients?
- How to add first name & last name to default registration form?
- Masking logout URL
- Hourly Routine Not Firing ( wp_schedule_event() )
- Warning/Notice about functions.php
- Is checking whether the blog is installed necessary?
- echo or print_r in an admin function
- Overriding methods in a child theme
- WP disobeys disabling of the posts revision feature
- How do I deactivate a plugin for some roles
- How to display more audio file ID3 tags in WordPress
- Searching for content post
- Running CRON on Server with WP Function
- Using separate .php file for functions – how to run on site?
- wp_trash_post function to only apply to posts, not pages!
- Adding widget to dashboard with wp_dashboard_setup not working
- Add Featured image column into wordpress admin on pages AND posts
- How can I change the do_action function in footer (copyright area)
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- functions.php How to add css/js depending on Template Name?
- wp_nav_menu, walker class, categories as classes of li
- Calling a Function in Functions.php from an external PHP script
- Why is my page feed returning empty content?
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- Including a specific Javascript Script in a template. Is my code correct?
- Custom shortcodes not inserting into visual composer columns
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Adding a colorbutton in tinymce dialog with current api
- Post meta not updating
- Accessing two databases wordpress
- Add a jQuery Function
- append to existing parent theme function
- Get category URL for current post
- How can I get the post id from within functions.php
- Check if Page Slug Exists, then display that Page’s Title
- Why doesn’t is_page(id) work in functions.php?
- I have problems with loading javascripts
- Enqueuing latest version of jQuery into a child theme returns a blank screen
- Function to alphabetically sort custom post types creating duplicates
- How do I change a parent theme’s function through the child theme?
- Enqueue script on every page except one
- Best way to handle lack of titles in microblogging
- Dropline menus — seperators between children only?
- Echoing function into WordPress NextGen gallery
- does wp function the_content(); accept another tag inside
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Redirect to other page if login
- Prevent loading of functions
- 404 when enqueue_script using plugin_url
- WP Customizer API loaded into functions.php
- Get term slug by term id and then explode it
- Shortcode question
- call_user_func_array() expects parameter 1 to be a valid callback, function
- How to use get_posts() function in functions.php
- the_widget() inside functions.php
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- Adding tables to the WordPress Editor
- Add Login and logout buttons to top menu bar
- implementing a centralized content “show-do-not-show” toggle?
- WordPress – using sessions?
- How to hide content on mobile in the functions.php file – woocommerce
- Load templates, pass arguments, and render output from functions.php
- How to load a css file depending on the current role
- WordPress Lite/Light
- How to add HTML into error message
- Add a word after the post url if it is within a specific category
- Selecting specific query for offset
- Is_Page doesnt detect my page
- Security when outputing wp_oembed_get code
- Show image after X para – center aligned
- Problems adding a new field to product in cart
- Function for Sticky Post on Categories causes issues with 404 behavior
- function replace_text for entire page
- Get value of pre-populated Gravity forms field as variable in my function
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- Graphic before title – Specific Category
- Edit meta fields from within template
- What to do to have access to WordPress functions
- Adding a meta box fields to child theme options page
- Changing the color of post title [closed]
- Create html from function
- wp_list_pages change of children and anchor of parent
- Admin Panel errors because of functions.php
- WordPress not performing direct update
- Using Output from one Function and calling it into another
- How to add a class and title attribute to the link generated by next/previous post
- “Headers already sent” while trying to add a CSS file to my login page?
- Remove theme, change theme button and WP version on “Right Now” admin dashboard?
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Load script only on selected Pages
- Using input_attrs() Multiple Times Within One Customizer Control
- Convert Image to Webp on upload without plugin
- How to automatically load Google Fonts on pages only as they’re used?