Modify Default URL for /wp-includes/js/wp-emoji.js?ver=4.6.1

I need to modify the URL for /wp-includes/js/wp-embed.min.js?ver=4.6.1 and I have found the following entry that employs the notion of filters:

https://wordpress.org/support/topic/how-to-change-default-url-for-new-script-wp-emoji-releaseminjs/

I have included the following code in my functions.php:

function filter_my_script_location( $script_url, $script_name ) {
    if ( 'concatemojoi' == $script_name ) {
        $script_url = 'http://mynewdomain/wp-emoji-release.min.js';
    }

    return $script_url;
}
add_filter( 'script_loader_src', 'filter_my_script_location', 10, 2 );

This does not change the Default URL to the one I wanted, is that the correct way to use filters in this case?

Thank you,

P.

EDIT:

Also noticed that this caused intermittent 500 errors and only on refresh the page is correctly rendered/loaded.

EDIT2:

I must apologise as I have realised that I was actually asking a slightly incorrect thing. I need to modify the URL for /wp-includes/js/wp-emoji.js?ver=4.6.1 The function above was slightly off as kindly pointed out by @birgire, I have amended it as follows:

function filter_emojii_location( $script_url, $script_name ) {
    if ( 'concatemoji' == $script_name ) {
        $script_url = 'http://mynewdomain/wp-emoji-release.min.js';
    }

    return $script_url;
}
    add_filter( 'script_loader_src', 'filter_emojii_location', 10, 2 );

Still it has no effect.

Topic emoji filters Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.