WordPress.org

Ready to get started?Download WordPress

Forums

Pronamic Google Maps
[resolved] Modify plugin properly site.js (4 posts)

  1. jcuenin
    Member
    Posted 1 year ago #

    Hi everyone,

    i would like to find a way to modify the plugin and most precisely the site.js file.

    I could change directly the site.js file but then at every update i will have to modify the code again.

    So is there a way for me to unregister the base site.js and load m custom one instead and that the plugin can be updated without troubles?

    I saw i can use hooks and such but i am not so much confident with that.

    Thanks in advance,

    regards

    http://wordpress.org/extend/plugins/pronamic-google-maps/

  2. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    I think this is possible, we register the script in the following file:
    https://github.com/pronamic/wp-pronamic-google-maps/blob/2.2.4/classes/Pronamic/Google/Maps/Site.php#L39

    Maybe you can deregister this script and register your own script.

  3. jcuenin
    Member
    Posted 1 year ago #

    Thank you for your answer, yes i did try this, my script was loading but i got that error in the console : Uncaught ReferenceError: google is not defined.

    I just copied the old script and did my modifications.

    When i did my modifications inside site.js it was working though.

  4. jcuenin
    Member
    Posted 1 year ago #

    Alright it's working my bad!

    I forgot to add array('jquery', 'google-jsapi') when i was registering my plugin.

    So basicly what i did was :

    Create a new plugin named my google maps and a modified site.js to deregister the base script and then register mine.

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

    function my_deregister_javascript() {
    wp_deregister_script( 'pronamic-google-maps-site' );
    wp_register_script(
    'pronamic-google-maps-site' ,
    plugins_url('my-google-maps/site.js') ,
    array('jquery', 'google-jsapi')
    );
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags