Homepage js is conflicting with js of plugin of other page

Put it in an if clause to only load on front page: if (is_front_page()){ // you could also try is_home() //or is_page($the_id_of_home_page = 555) If you know the id of the home page wp_register_script(‘java1’, get_template_directory_uri() . ‘/js/cr-scroll.js’, array( ‘jquery’ )); wp_enqueue_script( ‘java1’ ); } or remove it on a specific page: function remove_scroll_js(){ if (is_page($the_id_of_that_page_lets_say … Read more

pass wordpress template directory into ajax url call

I suspect you don’t want to hardcode your URL to data.php, but using a standalone file to handle requests in a theme or plugin is a major security problem. Instead, using a REST API endpoint. For example, lets register a data endpoint: add_action( ‘rest_api_init’, function () { register_rest_route( ‘monacoder/v1’, ‘/data/’, array( ‘methods’ => ‘POST’, ‘callback’ … Read more

enqueing Javascript and CSS

If you care about pagespeed and those standards, you should make the resources local instead of off remote servers. Although they’re all off CDNs, nothing’s faster than local. With http/2 on the rise, its going to become less and less important to have fewer scripts- but having them locally will still matter. You can combine … Read more

How to organize my js files

Generally speaking, combining all of the global scripts will boost performance, but so will enqueueing JS selectively – meaning if a script is only used on one CPT or template, you should only enqueue it there. Look into conditionally enqueueing JS in your functions.php. You can target specific sites by blog_id and target specific post … Read more

Preventing double loading JS scripts (like React) when developing for Gutenberg

Any WordPress-packaged scripts enqueued properly via wp_enqueue_script won’t load multiple times. If two different plugins rely on the same dependencies, thanks to the enqueue logic, those dependencies will only be loaded once. create-guten-block only contains javascript relevant to the custom block itself, and sets wp-blocks, wp-i18n, and wp-element (the abstraction layer WP uses on top … Read more

How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?

You could use the gettext filter. See the examples here https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext. In your filter you will add code to check IF it’s the exact text you want to change then if the users meta value is what you are looking for the return the revised text. Else return the passed text unchanged.