0

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.

10
  • Looks like you've a typo in 'concatemojoi', try 'concatemoji'. Why do you need to modify the wp-embed.js file?
    – birgire
    Jan 10, 2017 at 19:28
  • Hi, thank you for this, well spotted! Unfortunately, the conventional ways for re-directing old domain to new domain did not seem to work for the js libraries, which still have the old domain. I was looking for a workaround.
    – panza
    Jan 11, 2017 at 8:54
  • So you're migrating a site and the js libraries still point to the old domain? Didn't you change the home and siteurl accordingly like explained here ?
    – birgire
    Jan 11, 2017 at 9:40
  • Yes I did, I am afraid.
    – panza
    Jan 11, 2017 at 9:41
  • That sounds strange, I've migrated many sites but never experienced that. Make sure you changed the correct settings, check e.g. if you have it overriden in wp-config.php. Double check the values in the database. Make sure it's not plugin/theme related. Cache related? Always take a backup of db before modifying during migration..
    – birgire
    Jan 11, 2017 at 9:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.