Load Google Maps script only when needed
This commit is contained in:
@@ -40,13 +40,18 @@ class SP_Frontend_Scripts {
|
||||
* @return void
|
||||
*/
|
||||
public function load_scripts() {
|
||||
global $typenow;
|
||||
// Scripts
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
|
||||
wp_enqueue_script( 'jquery-datatables', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
|
||||
wp_enqueue_script( 'jquery-countdown', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
|
||||
wp_enqueue_script( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/sportspress.js', array( 'jquery' ), time(), true );
|
||||
|
||||
if ( is_singular( 'sp_event' ) || is_tax( 'sp_venue' ) ):
|
||||
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
|
||||
wp_enqueue_script( 'sp-maps', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/sp-maps.js', array( 'jquery', 'google-maps' ), time(), true );
|
||||
endif;
|
||||
|
||||
// Localize scripts.
|
||||
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ), 'previous' => __( 'Previous', 'sportspress' ), 'next' => __( 'Next', 'sportspress' ) ) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user