You can use the style_loader_src
and script_loader_src
filters.
namespace WPSE;
\add_filter( 'style_loader_src' , __NAMESPACE__ . '\protocol_relative-url' );
\add_filter( 'script_loader_src', __NAMESPACE__ . '\protocol_relative-url' );
function protocol_relative_url( string $url ) : string {
return str_replace( [ 'http:', 'https:' ], '', $url );
}
/* Notes:
* Namespaces require PHP > 5.3
* [] array syntax requires PHP > 5.4
* String type declaration requires PHP > 7.0
*/
Related Posts:
- Difference Between Filter and Action Hooks?
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How do I Make a Theme “plugin-ready”?
- How to modify post content before writing to database?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- Hook for post permalink update
- Dynamically Override Fancy Title
- Define a function outside a class and call the function using action or filter hook
- Synchronize Custom post type tags to WordPress default posts tags
- Woocommerce – Hide a Column in Cart Table
- WordPress after content Hook & external template part
- Namespaced action and filter tags
- best practice for query string values – get_query_var always empty for my value supplied in query string
- get_current_screen() return null
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- WordPress custom taxonomy check box to dropdown
- How to get all queries’s results after they have executed?
- Remove an action by extending class and replacing it
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Update variable value via add_filter
- How to find list of all functions bind to a particular hook from my plugin?
- apply_filters() and call_user_func() to define and call a function outside a class
- Limit get_next_post to posts from the same author
- Any way, hook to add content right before the “read more” link?
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- Add_action not calling callback function
- How do I replace title with my plugin?
- Apply function on all action hooks?
- Ninja Forms: Front-End Forms, Post ID?
- How can I load a page template from a plugin?
- Add a new tab to WordPress Plugin install Listing
- Changing Plugin Load Order
- How should you hook a session_start() when authoring a plugin?
- Init action hook running late after PayPal’s return url?
- How to get Post ID with the Add Filter Function
- How Do I Load My Action Earlier Enough?
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Filter on the_content ignores shortcodes
- How to change wordpress post title?
- Failed to invoke other hook from the init hook
- How can I filter blog name?
- Changing bloginfo description from a plugin
- Create a plugin to change the action to which a function is hooked
- Adding Automatically To In WordPress Using Filter Referencing?
- comment_email hook doesn’t seem to work for comment editor field
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- Add tab to profile.php wordpress plugin development
- How to set a custom path, for ajax image upload folder in admin?
- How do I change the initial quantity of a product in woocommerce?
- Where and how does WordPress store and use its plugin and hook information?
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Which are the hooks run before/after when a category’s deletion?
- edit_{$taxonomy} | Hook
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Where to add hooks in a class
- How to use output buffering in WordPress hooked functions?
- Adding option to Gallery shortcode
- Adding rewrite rule dynamically
- do_action and add_action on two different installed plugins won’t work
- I have 2 plugins using the same wp_login action hook and one is not working
- Using ob_get_content to get_search_form puts into infinite loop
- Add a new confirmation page before saving
- WordPress class, using add_action to call member function does not work
- What happens when two or more plugins use the same hook?
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- flush rewrite rules after plugin update?
- When does save_post hook fire on post save/update
- Plugin does not add action
- Add child pages to submenu automatically
- After plugin activation hook
- How to replace default comments with custom HTML?
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- Run command “composer install” when activating wordpress plugin
- Hide one specific woocoomerce product
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- WP_NAV_MENU filter targets all menus
- Redirect returning users to a certain page?
- Set the payment processor callbacks to a plugin
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Woocommerce get_term_by() in transition_post_status hook doesn’t works
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- Add a custom submenu under submenu in a Custom WordPress Plugin
- How do I ensure I can loop through every enqueued script and CSS?
- Redirect theme directory to plugin theme directory
- replacing jquery google cdn with a new version dynamically
- Modify search form with plugin
- Single_template for a custom post type created from a plugin is returning an empty page
- Unable to show a message after plugin activation
- Apply Filters Causing a 500 Internal Server Error
- add_filter adds output in the head
- how to insert content into wp_head after loop_end
- Execute callback after REST API request completes + Response is sent