/**
  * The asset loading function.
  *
  * @param string $name The name of the package reqested.
  * @param array $deps An array of dependencies (this should be the registered name that is registered to the wp_enqueue functions).
  * @return void
  * @author Timothy Wood
  * @since 3.0
  */
 public static function asset_package($name, $deps = array())
 {
     $tec_pro = TribeEventsPro::instance();
     $prefix = 'tribe-events-pro';
     // setup plugin resources & 3rd party vendor urls
     $resources_url = trailingslashit($tec_pro->pluginUrl) . 'resources/';
     $vendor_url = trailingslashit($tec_pro->pluginUrl) . 'vendor/';
     switch ($name) {
         case 'ajax-weekview':
             $ajax_data = array("ajaxurl" => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'post_type' => TribeEvents::POSTTYPE);
             $path1 = Tribe_Template_Factory::getMinFile($vendor_url . 'jquery-slimscroll/jquery.slimscroll.js', true);
             $path2 = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-week.js', true);
             wp_enqueue_script('tribe-events-pro-slimscroll', $path1, array('tribe-events-pro', 'jquery-ui-draggable'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_enqueue_script('tribe-events-pro-week', $path2, array('tribe-events-pro-slimscroll'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_localize_script('tribe-events-pro-week', 'TribeWeek', $ajax_data);
             break;
         case 'ajax-photoview':
             $tribe_paged = !empty($_REQUEST['tribe_paged']) ? $_REQUEST['tribe_paged'] : 0;
             $ajax_data = array("ajaxurl" => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'tribe_paged' => $tribe_paged);
             $path1 = Tribe_Template_Factory::getMinFile($vendor_url . 'isotope/jquery.isotope.js', true);
             $path2 = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-photo-view.js', true);
             wp_enqueue_script('tribe-events-pro-isotope', $path1, array('tribe-events-pro'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_enqueue_script('tribe-events-pro-photo', $path2, array('tribe-events-pro-isotope'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_localize_script('tribe-events-pro-photo', 'TribePhoto', $ajax_data);
             break;
         case 'ajax-dayview':
             $ajax_data = array("ajaxurl" => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'post_type' => TribeEvents::POSTTYPE);
             $path = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-ajax-day.js', true);
             wp_enqueue_script('tribe-events-pro-ajax-day', $path, array('tribe-events-pro'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_localize_script('tribe-events-pro-ajax-day', 'TribeCalendar', $ajax_data);
             break;
         case 'ajax-maps':
             $http = is_ssl() ? 'https' : 'http';
             wp_register_script('gmaps', $http . '://maps.google.com/maps/api/js?sensor=false', array('tribe-events-pro'));
             $path = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-ajax-maps.js', true);
             wp_register_script('tribe-events-pro-geoloc', $path, array('gmaps', parent::get_placeholder_handle()), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION));
             wp_enqueue_script('tribe-events-pro-geoloc');
             $geoloc = TribeEventsGeoLoc::instance();
             $data = array('ajaxurl' => admin_url('admin-ajax.php', $http), 'nonce' => wp_create_nonce('tribe_geosearch'), 'map_view' => TribeEvents::instance()->displaying == 'map' ? true : false);
             wp_localize_script('tribe-events-pro-geoloc', 'GeoLoc', $data);
             break;
     }
     parent::asset_package($name, $deps);
 }
 /**
  * Enqueue the proper PRO scripts as necessary.
  *
  * @return void
  * @author Paul Hughes
  * @since 3.0
  */
 public function enqueue_pro_scripts()
 {
     if (tribe_is_event_query()) {
         $resources_url = trailingslashit($this->pluginUrl) . 'resources/';
         $path = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-pro.js', true);
         wp_enqueue_script('tribe-events-pro', $path, array('jquery', 'tribe-events-calendar-script'), false, false);
         $geoloc = TribeEventsGeoLoc::instance();
         $data = array('geocenter' => $geoloc->estimate_center_point());
         wp_localize_script('tribe-events-pro', 'TribeEventsPro', $data);
     }
 }
Beispiel #3
0
 /**
  * Enqueue the proper PRO scripts as necessary.
  *
  * @return void
  */
 public function enqueue_pro_scripts()
 {
     if (tribe_is_event_query()) {
         // @TODO filter the tribe_events_resource_url() function
         $resources_url = trailingslashit($this->pluginUrl) . 'resources/';
         $path = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-pro.js', true);
         wp_enqueue_script('tribe-events-pro', $path, array('jquery', 'tribe-events-calendar-script'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), false);
         $geoloc = TribeEventsGeoLoc::instance();
         $data = array('geocenter' => $geoloc->estimate_center_point(), 'map_tooltip_event' => __('Event: ', 'tribe-events-calendar-pro'), 'map_tooltip_address' => __('Address: ', 'tribe-events-calendar-pro'));
         $data = apply_filters('tribe_events_pro_localize_script', $data, 'TribeEventsPro', 'tribe-events-pro');
         wp_localize_script('tribe-events-pro', 'TribeEventsPro', $data);
     }
 }
 /**
  * The asset loading function.
  *
  * @param string $name The name of the package reqested.
  * @param array  $deps An array of dependencies (this should be the registered name that is registered to the wp_enqueue functions).
  *
  * @return void
  */
 public static function asset_package($name, $deps = array())
 {
     $tec_pro = TribeEventsPro::instance();
     $prefix = 'tribe-events-pro';
     // setup plugin resources & 3rd party vendor urls
     $resources_url = trailingslashit($tec_pro->pluginUrl) . 'resources/';
     $vendor_url = trailingslashit($tec_pro->pluginUrl) . 'vendor/';
     switch ($name) {
         case 'ajax-weekview':
             $ajax_data = array("ajaxurl" => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'post_type' => TribeEvents::POSTTYPE);
             $path1 = Tribe_Template_Factory::getMinFile($vendor_url . 'jquery-slimscroll/jquery.slimscroll.js', true);
             $path2 = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-week.js', true);
             wp_enqueue_script('tribe-events-pro-slimscroll', $path1, array('tribe-events-pro', 'jquery-ui-draggable'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_enqueue_script('tribe-events-pro-week', $path2, array('tribe-events-pro-slimscroll'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_localize_script('tribe-events-pro-week', 'TribeWeek', $ajax_data);
             break;
         case 'ajax-photoview':
             $tribe_paged = !empty($_REQUEST['tribe_paged']) ? $_REQUEST['tribe_paged'] : 0;
             $ajax_data = array("ajaxurl" => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'tribe_paged' => $tribe_paged);
             $path1 = Tribe_Template_Factory::getMinFile($vendor_url . 'isotope/jquery.isotope.js', true);
             $path2 = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-photo-view.js', true);
             wp_enqueue_script('tribe-events-pro-isotope', $path1, array('tribe-events-pro'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_enqueue_script('tribe-events-pro-photo', $path2, array('tribe-events-pro-isotope'), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION), true);
             wp_localize_script('tribe-events-pro-photo', 'TribePhoto', $ajax_data);
             break;
         case 'ajax-maps':
             $http = is_ssl() ? 'https' : 'http';
             $url = apply_filters('tribe_events_pro_google_maps_api', $http . '://maps.google.com/maps/api/js?sensor=false');
             wp_register_script('tribe-gmaps', $url, array('tribe-events-pro'));
             $path = Tribe_Template_Factory::getMinFile($resources_url . 'tribe-events-ajax-maps.js', true);
             wp_register_script('tribe-events-pro-geoloc', $path, array('tribe-gmaps', parent::get_placeholder_handle()), apply_filters('tribe_events_pro_js_version', TribeEventsPro::VERSION));
             wp_enqueue_script('tribe-events-pro-geoloc');
             $geoloc = TribeEventsGeoLoc::instance();
             $data = array('ajaxurl' => admin_url('admin-ajax.php', $http), 'nonce' => wp_create_nonce('tribe_geosearch'), 'map_view' => TribeEvents::instance()->displaying == 'map' ? true : false);
             wp_localize_script('tribe-events-pro-geoloc', 'GeoLoc', $data);
             break;
         case 'events-pro-css':
             $stylesheets = array();
             $mobile_break = tribe_get_mobile_breakpoint();
             // Get the selected style option
             $style_option = tribe_get_option('stylesheetOption', 'tribe');
             // Determine the stylesheet files for the selected option
             switch ($style_option) {
                 case 'skeleton':
                     $stylesheets['tribe-events-calendar-pro-style'] = 'tribe-events-pro-skeleton.css';
                     break;
                 case 'full':
                     $stylesheets['tribe-events-calendar-pro-style'] = 'tribe-events-pro-full.css';
                     if ($mobile_break > 0) {
                         $stylesheets['tribe-events-calendar-pro-mobile-style'] = 'tribe-events-pro-full-mobile.css';
                     }
                     break;
                 default:
                     // tribe styles
                     $stylesheets['tribe-events-full-pro-calendar-style'] = 'tribe-events-pro-full.css';
                     $stylesheets['tribe-events-calendar-pro-style'] = 'tribe-events-pro-theme.css';
                     if ($mobile_break > 0) {
                         $stylesheets['tribe-events-calendar-full-pro-mobile-style'] = 'tribe-events-pro-full-mobile.css';
                         $stylesheets['tribe-events-calendar-pro-mobile-style'] = 'tribe-events-pro-theme-mobile.css';
                     }
                     break;
             }
             // put override css at the end of the array
             $stylesheets['tribe-events-calendar-pro-override-style'] = 'tribe-events/pro/tribe-events-pro.css';
             // do the enqueues
             foreach ($stylesheets as $name => $css_file) {
                 if ($name == 'tribe-events-calendar-pro-override-style') {
                     $user_stylesheet_url = TribeEventsTemplates::locate_stylesheet($css_file);
                     if ($user_stylesheet_url) {
                         wp_enqueue_style($name, $user_stylesheet_url);
                     }
                 } else {
                     // get full URL
                     $url = tribe_events_pro_resource_url($css_file);
                     // get the minified file
                     $url = self::getMinFile($url, true);
                     // apply filters
                     $url = apply_filters('tribe_events_pro_stylesheet_url', $url, $name);
                     // set the $media attribute
                     if ($name == 'tribe-events-calendar-pro-mobile-style' || $name == 'tribe-events-calendar-full-pro-mobile-style') {
                         $media = "only screen and (max-width: {$mobile_break}px)";
                         wp_enqueue_style($name, $url, array('tribe-events-calendar-pro-style'), TribeEventsPro::VERSION, $media);
                     } else {
                         wp_register_style($name, $url, array(), TribeEventsPro::VERSION);
                         wp_enqueue_style($name);
                     }
                 }
             }
             break;
     }
     parent::asset_package($name, $deps);
 }
 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
     $resources_url = trailingslashit(TribeEvents::instance()->pluginUrl) . 'resources/';
     $url = Tribe_Template_Factory::getMinFile($resources_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;
 }