Change embedded-map.js URL to theme folder

Home Forums Calendar Products Events Calendar PRO Change embedded-map.js URL to theme folder

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #973043
    darrienw93
    Participant

    Hi, I’m trying to change the js file on the single events page that appears when tribe_get_embedded_map(); is echoed.

    <script src=”/app/plugins/the-events-calendar/resources/embedded-map.js”></script>

    I would like to change the url to one that is inside of my theme folder.
    <script src=”/app/themes/mywebsite/assets/scripts/embedded-map.js”></script>

    I found this inside of the Embedded_Maps.php in the src/Tribe folder.

    	protected function enqueue_map_scripts() {
    		// Setup Google Maps API
    		$url = apply_filters( 'tribe_events_google_maps_api', '//maps.googleapis.com/maps/api/js' );
    		wp_enqueue_script( 'tribe_events_google_maps_api', $url, array(), false, true );
    
    		// Setup our own script used to initialize each map
    		$url = Tribe__Events__Template_Factory::getMinFile( tribe_events_resource_url( 'embedded-map.js' ), true );
    		wp_enqueue_script( self::MAP_HANDLE, $url, array( 'tribe_events_google_maps_api' ), false, true );
    
    		$this->map_script_enqueued = true;
    	}

    I have creaeted this function, but it adds a ‘/wp/’ before my link

    add_action( 'wp_enqueue_scripts', 'replace_embedded_maps_js' );
    function replace_embedded_maps_js(){
      $url = apply_filters( 'tribe_events_google_maps_api', '/app/themes/mysite/assets/scripts/embedded-map.js' );
      wp_enqueue_script( 'tribe_events_embedded_map', $url, array('tribe_events_google_maps_api'), [], null, true ); 
    }
    
    #973153
    Barry
    Member

    Hi @darrienw93,

    Looks like a great start 🙂

    Is the only problem with your solution the leading wp/ segment in the URL – and have you installed WordPress in such a way that it resides in a wp/ directory?

    What if, when forming your custom script URL, you provide an absolute URL – including the domain – based on the site URL, instead of your current approach?

    #986054
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Change embedded-map.js URL to theme folder’ is closed to new replies.