protected function update_js() { $path = tribe_events_pro_resource_url('events-additional-fields-update.js'); $spinner = '<img src="' . esc_url(get_admin_url(null, 'images/spinner.gif')) . '">'; wp_enqueue_script('tribe-events-pro-additional-fields-update', $path, array('jquery'), false, true); wp_localize_script('tribe-events-pro-additional-fields-update', 'tribe_additional_fields', array('update_check' => wp_create_nonce('custom_meta_tools:updater'), 'complete_msg' => '<strong>' . _x('All fields have been updated!', 'additional field update', 'tribe-events-calendar-pro') . '</strong>', 'failure_msg' => '<strong>' . _x('An unexpected error stopped the update from completing.', 'additional field update', 'tribe-events-calendar-pro') . '</strong>', 'in_progress_msg' => '<strong>' . _x('Working…', 'additional field update', 'tribe-events-calendar-pro') . "</strong> {$spinner}")); }
/** * Enqueue the appropriate CSS for the calendar/advanced list widgets, which share * the same basic appearance. */ public static function enqueue_calendar_widget_styles() { // CSS file $event_file = 'widget-calendar.css'; $event_file_option = 'widget-calendar-theme.css'; $stylesheet_option = tribe_get_option('stylesheetOption', 'tribe'); // Choose the appropriate stylesheet in light of the current styling options switch ($stylesheet_option) { case 'skeleton': case 'full': $event_file_option = "widget-calendar-{$stylesheet_option}.css"; break; } $style_url = tribe_events_pro_resource_url($event_file_option); $style_url = apply_filters('tribe_events_pro_widget_calendar_stylesheet_url', $style_url); $style_override_url = Tribe__Events__Templates::locate_stylesheet('tribe-events/pro/' . $event_file, $style_url); // Load up stylesheet from theme or plugin if ($style_url && 'tribe' === $stylesheet_option) { wp_enqueue_style('widget-calendar-pro-style', tribe_events_pro_resource_url('widget-calendar-full.css'), array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $style_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } else { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $style_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } if ($style_override_url) { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '--widget-calendar-pro-override-style', $style_override_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } }
public function widget($args, $instance) { $title = empty($instance['title']) ? null : $instance['title']; $event_date = empty($instance['event_date']) ? null : $instance['event_date']; $event_ID = empty($instance['event_ID']) ? null : $instance['event_ID']; $show_seconds = empty($instance['show_seconds']) ? null : $instance['show_seconds']; $complete = empty($instance['complete']) ? null : $instance['complete']; $event_countdown_date = null; $title = apply_filters('widget_title', $title); wp_enqueue_script('tribe-events-countdown-widget', tribe_events_pro_resource_url('widget-countdown.js'), array('jquery'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION), true); // Get the timer data. if ($complete) { $complete = '<h3 class="tribe-countdown-complete">' . $complete . '</h3>'; } if ($event_ID) { $event_countdown_date = $this->get_output($event_ID, $complete, $show_seconds, $event_date); } echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } if (!empty($event_countdown_date)) { echo $event_countdown_date; } echo $args['after_widget']; }
public function load_scripts($hook) { if ($hook != 'widgets.php') { return; } Tribe__Events__Template_Factory::asset_package('select2'); wp_enqueue_script('calendar-widget-admin', tribe_events_pro_resource_url('calendar-widget-admin.js'), array(), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION)); }
public function handle() { $ajax_data = array('ajaxurl' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'post_type' => Tribe__Events__Main::POSTTYPE); $path1 = Tribe__Events__Template_Factory::getMinFile($this->vendor_url . 'nanoscroller/jquery.nanoscroller.js', true); wp_enqueue_script('tribe-events-pro-slimscroll', $path1, array('tribe-events-pro', 'jquery-ui-draggable'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION), true); $path2 = Tribe__Events__Template_Factory::getMinFile(tribe_events_pro_resource_url('tribe-events-week.js'), true); wp_enqueue_script('tribe-events-pro-week', $path2, array('tribe-events-pro-slimscroll'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION), true); wp_localize_script('tribe-events-pro-week', 'TribeWeek', $ajax_data); }
public function handle() { $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__Events__Template_Factory::getMinFile($this->vendor_url . 'isotope/jquery.isotope.js', true); $path2 = Tribe__Events__Template_Factory::getMinFile(tribe_events_pro_resource_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', Tribe__Events__Pro__Main::VERSION), true); wp_enqueue_script('tribe-events-pro-photo', $path2, array('tribe-events-pro-isotope'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION), true); wp_localize_script('tribe-events-pro-photo', 'TribePhoto', $ajax_data); }
public function handle() { $http = is_ssl() ? 'https' : 'http'; $url = apply_filters('tribe_events_pro_google_maps_api', $http . '://maps.google.com/maps/api/js'); wp_register_script('tribe-gmaps', $url, array('tribe-events-pro')); $path = Tribe__Events__Template_Factory::getMinFile(tribe_events_pro_resource_url('tribe-events-ajax-maps.js'), true); wp_register_script('tribe-events-pro-geoloc', $path, array('tribe-gmaps', Tribe__Events__Template_Factory::get_placeholder_handle()), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION)); wp_enqueue_script('tribe-events-pro-geoloc'); $geoloc = Tribe__Events__Pro__Geo_Loc::instance(); $data = array('ajaxurl' => admin_url('admin-ajax.php', $http), 'nonce' => wp_create_nonce('tribe_geosearch'), 'map_view' => 'map' == Tribe__Events__Main::instance()->displaying ? true : false); wp_localize_script('tribe-events-pro-geoloc', 'GeoLoc', $data); }
/** * @param $hook */ public function load_scripts($hook) { if ('widgets.php' != $hook) { return; } //JS for Taxonomy Filter Select Tribe__Events__Template_Factory::asset_package('select2'); wp_enqueue_script('calendar-widget-admin', tribe_events_pro_resource_url('calendar-widget-admin.js'), array(), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION)); //Need for Customizer and to prevent errors in Widgets Section with Color Picker wp_enqueue_script('underscore'); //Colorpicker wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker'); }
public function handle() { $stylesheets = array(); $mobile_break = tribe_get_mobile_breakpoint(); // Get the selected style option $style_option = tribe_get_option('stylesheetOption', 'tribe'); // from `some-style-option` // to `Tribe__Events__Pro__Asset__Events_Css_Some_Style_Option` $child_class_name = $this->get_child_class_name($style_option); /** * @var Tribe__Events__Asset__Abstract_Events_Css */ $child_class_instance = new $child_class_name(); // `$stylesheets` passed by reference $child_class_instance->handle($stylesheets, $mobile_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 = Tribe__Events__Templates::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 = Tribe__Events__Template_Factory::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'), Tribe__Events__Pro__Main::VERSION, $media); } else { wp_register_style($name, $url, array(), Tribe__Events__Pro__Main::VERSION); wp_enqueue_style($name); } } } }
public function widget($args, $instance) { $defaults = array('title' => null, 'type' => 'single-event', 'event' => null, 'show_seconds' => true, 'complete' => esc_attr__('Hooray!', 'tribe-events-calendar-pro'), 'event_ID' => null, 'event_date' => null); $instance = wp_parse_args((array) $instance, $defaults); wp_enqueue_script('tribe-events-countdown-widget', tribe_events_pro_resource_url('widget-countdown.js'), array('jquery'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION), true); // Setup required variables if (empty($instance['event'])) { $instance['event'] = $instance['event_ID']; } $title = apply_filters('widget_title', $instance['title']); if ($instance['complete']) { $instance['complete'] = '<h3 class="tribe-countdown-complete">' . $instance['complete'] . '</h3>'; } echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } echo $this->get_output($instance); echo $args['after_widget']; }
/** * This Week Widget - Style and Scripts * */ public static function styles_and_scripts() { wp_enqueue_script('tribe-this-week', tribe_events_pro_resource_url('widget-this-week.min.js'), array('jquery'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION)); // Tribe Events CSS filename $event_file = 'widget-this-week.css'; $stylesheet_option = tribe_get_option('stylesheetOption', 'tribe'); // What Option was selected switch ($stylesheet_option) { case 'skeleton': $event_file_option = 'widget-this-week-' . $stylesheet_option . '.css'; break; case 'full': $event_file_option = 'widget-this-week-' . $stylesheet_option . '.css'; break; default: $event_file_option = 'widget-this-week-theme.css'; break; } $style_url = tribe_events_pro_resource_url($event_file_option); // get the minified file $style_url = Tribe__Events__Template_Factory::getMinFile($style_url, true); //filter stylesheet $style_url = apply_filters('tribe_events_pro_widget_calendar_stylesheet_url', $style_url); //Check for Override $style_override_url = Tribe__Events__Templates::locate_stylesheet('tribe-events/pro/' . $event_file, $style_url); // Load up stylesheet from theme or plugin if ($style_url && $stylesheet_option == 'tribe') { wp_enqueue_style('widget-this-week-pro-style', tribe_events_pro_resource_url('widget-this-week-full.css'), array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-this-week-pro-style', $style_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } else { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-this-week-pro-style', $style_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } if ($style_override_url && $style_override_url != $style_url) { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '--widget-this-week-pro-override-style', $style_override_url, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } $widget_data = array('ajaxurl' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http')); wp_localize_script('tribe-this-week', 'tribe_this_week', $widget_data); }
/** * 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 $path = Tribe__Events__Pro__Template_Factory::getMinFile(tribe_events_pro_resource_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', self::VERSION), false); $geoloc = Tribe__Events__Pro__Geo_Loc::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, 'Tribe__Events__Pro__Main', 'tribe-events-pro'); wp_localize_script('tribe-events-pro', 'TribeEventsPro', $data); } }
/** * @todo revise so that our stylesheet is enqueued in time for the link to be included within the head element */ protected function styles_and_scripts() { wp_enqueue_script('tribe-mini-calendar', tribe_events_pro_resource_url('widget-calendar.js'), array('jquery'), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION)); Tribe__Events__Pro__Widgets::enqueue_calendar_widget_styles(); // Tribe Events CSS filename $event_file = 'widget-calendar.css'; $stylesheet_option = tribe_get_option('stylesheetOption', 'tribe'); // What Option was selected switch ($stylesheet_option) { case 'skeleton': $event_file_option = 'widget-calendar-' . $stylesheet_option . '.css'; break; case 'full': $event_file_option = 'widget-calendar-' . $stylesheet_option . '.css'; break; default: $event_file_option = 'widget-calendar-theme.css'; break; } $styleUrl = tribe_events_pro_resource_url($event_file_option); $styleUrl = apply_filters('tribe_events_pro_widget_calendar_stylesheet_url', $styleUrl); $styleOverrideUrl = Tribe__Events__Templates::locate_stylesheet('tribe-events/pro/' . $event_file, $styleUrl); // Load up stylesheet from theme or plugin if ($styleUrl && $stylesheet_option == 'tribe') { wp_enqueue_style('widget-calendar-pro-style', tribe_events_pro_resource_url('widget-calendar-full.css'), array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $styleUrl, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } else { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-widget-calendar-pro-style', $styleUrl, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } if ($styleOverrideUrl) { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '--widget-calendar-pro-override-style', $styleOverrideUrl, array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); } $widget_data = array('ajaxurl' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http')); wp_localize_script('tribe-mini-calendar', 'TribeMiniCalendar', $widget_data); }
/** * Localizes recurrence JS data */ public static function enqueue_recurrence_data($post_id = null) { wp_enqueue_style(Tribe__Events__Main::POSTTYPE . '-recurrence', tribe_events_pro_resource_url('events-recurrence.css'), array(), apply_filters('tribe_events_pro_css_version', Tribe__Events__Pro__Main::VERSION)); if ($post_id) { // convert array to variables that can be used in the view $recurrence = self::getRecurrenceMeta($post_id); /** * Creates a way to filter the output of recurrence meta depending on the ID * @var $recurrence Meta Info * @var $post_id the post ID */ $recurrence = apply_filters('tribe_events_pro_output_recurrence_data', $recurrence, $post_id); wp_localize_script(Tribe__Events__Main::POSTTYPE . '-premium-admin', 'tribe_events_pro_recurrence_data', $recurrence); } wp_localize_script(Tribe__Events__Main::POSTTYPE . '-premium-admin', 'tribe_events_pro_recurrence_strings', array('date' => self::date_strings(), 'recurrence' => Tribe__Events__Pro__Recurrence__Strings::recurrence_strings(), 'exclusion' => array())); }
/** * 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); }