Ejemplo n.º 1
0
 public function handle()
 {
     // check if responsive should be killed
     if (apply_filters('tribe_events_kill_responsive', false)) {
         add_filter('tribe_events_mobile_breakpoint', '__return_zero');
     }
     $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__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-override-style'] = 'tribe-events/tribe-events.css';
     // do the enqueues
     foreach ($stylesheets as $name => $css_file) {
         if ($name == 'tribe-events-calendar-override-style') {
             $user_stylesheet_url = Tribe__Events__Templates::locate_stylesheet('tribe-events/tribe-events.css');
             if ($user_stylesheet_url) {
                 wp_enqueue_style($name, $user_stylesheet_url);
             }
         } else {
             // get full URL
             $url = tribe_events_resource_url($css_file);
             // get the minified file
             $url = Tribe__Events__Template_Factory::getMinFile($url, true);
             // apply filters
             $url = apply_filters('tribe_events_stylesheet_url', $url, $name);
             // set the $media attribute
             if ($name == 'tribe-events-calendar-mobile-style' || $name == 'tribe-events-calendar-full-mobile-style') {
                 $media = "only screen and (max-width: {$mobile_break}px)";
                 wp_enqueue_style($name, $url, array('tribe-events-calendar-style'), Tribe__Events__Main::VERSION, $media);
             } else {
                 wp_register_style($name, $url, array(), Tribe__Events__Main::VERSION);
                 wp_enqueue_style($name);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Prints out data attributes used in the template header tags
  *
  * @category Events
  * @param string|null $current_view
  *
  * @return void
  * @todo move to template classes
  **/
 function tribe_events_the_header_attributes($current_view = null)
 {
     $attrs = array();
     $current_view = !empty($current_view) ? $current_view : basename(tribe_get_current_template());
     $attrs['data-title'] = wp_title('|', false, 'right');
     switch ($current_view) {
         case 'month.php':
             $attrs['data-view'] = 'month';
             $attrs['data-date'] = date('Y-m', strtotime(tribe_get_month_view_date()));
             $attrs['data-baseurl'] = tribe_get_gridview_link(false);
             break;
         case 'day.php':
             $attrs['data-startofweek'] = get_option('start_of_week');
             break;
         case 'list.php':
             $attrs['data-startofweek'] = get_option('start_of_week');
             $attrs['data-view'] = 'list';
             if (tribe_is_upcoming()) {
                 $attrs['data-baseurl'] = tribe_get_listview_link(false);
             } elseif (tribe_is_past()) {
                 $attrs['data-view'] = 'past';
                 $attrs['data-baseurl'] = tribe_get_listview_past_link(false);
             }
             break;
     }
     if (has_filter('tribe_events_mobile_breakpoint')) {
         $attrs['data-mobilebreak'] = tribe_get_mobile_breakpoint();
     }
     $attrs = apply_filters('tribe_events_header_attributes', $attrs, $current_view);
     foreach ($attrs as $attr => $value) {
         echo " {$attr}=" . '"' . esc_attr($value) . '"';
     }
 }
<?php

namespace Fragen\Category_Colors;

/*
 * Setup variables for CSS generation.
 */
$teccc = Main::instance();
$options = Admin::fetch_options($teccc);
if (function_exists('tribe_get_mobile_breakpoint')) {
    $breakpoint = tribe_get_mobile_breakpoint();
}
?>

/* The Events Calendar Category Colors <?php 
echo Main::$version;
?>
 generated CSS */
.teccc-legend a, .tribe-events-calendar a, #tribe-events-content .tribe-events-tooltip h4
{
	font-weight: <?php 
esc_attr_e($options['font_weight']);
?>
;
}

.tribe-events-list .vevent.hentry h2 { padding-left: 5px; }

@media only screen and (max-width: <?php 
esc_attr_e($breakpoint);
?>
 /**
  * Asset calls for vendor packages
  *
  * @param string $name
  * @param array $deps Dependents
  */
 public static function asset_package($name, $deps = array())
 {
     $tec = TribeEvents::instance();
     $prefix = 'tribe-events';
     // TribeEvents::POSTTYPE;
     // setup plugin resources & 3rd party vendor urls
     $resources_url = trailingslashit($tec->pluginUrl) . 'resources/';
     $vendor_url = trailingslashit($tec->pluginUrl) . 'vendor/';
     switch ($name) {
         case 'jquery-resize':
             $path = self::getMinFile($vendor_url . 'jquery-resize/jquery.ba-resize.js', true);
             $deps = array_merge($deps, array('jquery'));
             wp_enqueue_script($prefix . '-jquery-resize', $path, $deps, '1.1', false);
             self::$vendor_scripts[] = $prefix . '-jquery-resize';
             break;
         case 'chosen':
             // Vendor: jQuery Chosen
             $deps = array_merge($deps, array('jquery'));
             $css_path = self::getMinFile($vendor_url . 'chosen/public/chosen.css', true);
             $path = self::getMinFile($vendor_url . 'chosen/public/chosen.jquery.js', true);
             wp_enqueue_style($prefix . '-chosen-style', $css_path);
             wp_enqueue_script($prefix . '-chosen-jquery', $path, $deps, '0.9.5', false);
             self::$vendor_scripts[] = $prefix . '-chosen-jquery';
             break;
         case 'smoothness':
             // Vendor: jQuery Custom Styles
             $path = self::getMinFile($vendor_url . 'jquery/smoothness/jquery-ui-1.8.23.custom.css', true);
             wp_enqueue_style($prefix . '-custom-jquery-styles', $path);
             break;
         case 'select2':
             // Vendor: Select2
             $css_path = self::getMinFile($vendor_url . 'select2/select2.css', true);
             $path = self::getMinFile($vendor_url . 'select2/select2.js', true);
             wp_enqueue_style($prefix . '-select2-css', $css_path);
             wp_enqueue_script($prefix . '-select2', $path, 'jquery', '3.2');
             self::$vendor_scripts[] = $prefix . '-select2';
             break;
         case 'calendar-script':
             // Tribe Events JS
             $deps = array_merge($deps, array('jquery'), self::$vendor_scripts);
             $path = self::getMinFile($resources_url . 'tribe-events.js', true);
             wp_enqueue_script($prefix . '-calendar-script', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION));
             break;
         case 'datepicker':
             // Vendor: jQuery Datepicker
             wp_enqueue_script('jquery-ui-datepicker');
             wp_enqueue_style('jquery-ui-datepicker');
             self::$vendor_scripts[] = 'jquery-ui-datepicker';
             break;
         case 'bootstrap-datepicker':
             // Vendor: Bootstrap Datepicker
             $css_path = self::getMinFile($vendor_url . 'bootstrap-datepicker/css/datepicker.css', true);
             $path = self::getMinFile($vendor_url . 'bootstrap-datepicker/js/bootstrap-datepicker.js', true);
             wp_enqueue_style($prefix . '-bootstrap-datepicker-css', $css_path);
             wp_enqueue_script($prefix . '-bootstrap-datepicker', $path, 'jquery', '3.2');
             self::$vendor_scripts[] = $prefix . '-bootstrap-datepicker';
             $localized_datepicker_array = array('days' => array_merge($tec->daysOfWeek, array($tec->daysOfWeek[0])), 'daysShort' => array_merge($tec->daysOfWeekShort, array($tec->daysOfWeekShort[0])), 'daysMin' => array_merge($tec->daysOfWeekMin, array($tec->daysOfWeekMin[0])), 'months' => array_values($tec->monthsFull), 'monthsShort' => array_values($tec->monthsShort), 'clear' => 'Clear', 'today' => 'Today');
             wp_localize_script($prefix . '-bootstrap-datepicker', 'tribe_bootstrap_datepicker_strings', array('dates' => $localized_datepicker_array));
             break;
         case 'dialog':
             // Vendor: jQuery Dialog
             wp_enqueue_script('jquery-ui-dialog');
             self::$vendor_scripts[] = 'jquery-ui-dialog';
             break;
         case 'admin-ui':
             // Tribe Events
             $path = self::getMinFile($resources_url . 'events-admin.css', true);
             wp_enqueue_style($prefix . '-admin-ui', $path, array(), TribeEvents::VERSION);
             break;
         case 'admin':
             $deps = array_merge($deps, array('jquery', 'jquery-ui-datepicker'));
             $path = self::getMinFile($resources_url . 'events-admin.js', true);
             wp_enqueue_script($prefix . '-admin', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION), true);
             break;
         case 'settings':
             $deps = array_merge($deps, array('jquery'));
             $path = self::getMinFile($resources_url . 'tribe-settings.js', true);
             wp_enqueue_script($prefix . '-settings', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION), true);
             break;
         case 'ecp-plugins':
             $deps = array_merge($deps, array('jquery'));
             $path = self::getMinFile($resources_url . 'jquery-ecp-plugins.js', true);
             wp_enqueue_script($prefix . '-ecp-plugins', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION));
             break;
         case 'tribe-events-bar':
             $deps = array_merge($deps, array('jquery', $prefix . '-calendar-script', $prefix . '-bootstrap-datepicker', $prefix . '-jquery-resize', self::get_placeholder_handle()));
             $path = self::getMinFile($resources_url . 'tribe-events-bar.js', true);
             wp_enqueue_script($prefix . '-bar', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION));
             break;
         case 'jquery-placeholder':
             // Vendor: jQuery Placeholder
             $deps = array_merge($deps, array('jquery'));
             $path = self::getMinFile($vendor_url . 'jquery-placeholder/jquery.placeholder.js', true);
             $placeholder_handle = self::get_placeholder_handle();
             wp_enqueue_script($placeholder_handle, $path, $deps, '2.0.7', false);
             self::$vendor_scripts[] = $placeholder_handle;
             break;
         case 'ajax-calendar':
             $deps = array_merge($deps, array('jquery', $prefix . '-bootstrap-datepicker', $prefix . '-calendar-script'));
             $ajax_data = array("ajaxurl" => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'));
             $path = self::getMinFile($resources_url . 'tribe-events-ajax-calendar.js', true);
             wp_enqueue_script('tribe-events-calendar', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION), true);
             wp_localize_script('tribe-events-calendar', 'TribeCalendar', $ajax_data);
             break;
         case 'ajax-list':
             $deps = array_merge($deps, array('jquery', $prefix . '-calendar-script'));
             $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);
             $path = self::getMinFile($resources_url . 'tribe-events-ajax-list.js', true);
             wp_enqueue_script('tribe-events-list', $path, $deps, apply_filters('tribe_events_js_version', TribeEvents::VERSION), true);
             wp_localize_script('tribe-events-list', 'TribeList', $ajax_data);
             break;
         case 'events-css':
             // check if responsive should be killed
             if (apply_filters('tribe_events_kill_responsive', false)) {
                 add_filter('tribe_events_mobile_breakpoint', '__return_zero');
             }
             $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-style'] = 'tribe-events-skeleton.css';
                     break;
                 case 'full':
                     $stylesheets['tribe-events-calendar-style'] = 'tribe-events-full.css';
                     if ($mobile_break > 0) {
                         $stylesheets['tribe-events-calendar-mobile-style'] = 'tribe-events-full-mobile.css';
                     }
                     break;
                 default:
                     // tribe styles
                     $stylesheets['tribe-events-full-calendar-style'] = 'tribe-events-full.css';
                     $stylesheets['tribe-events-calendar-style'] = 'tribe-events-theme.css';
                     if ($mobile_break > 0) {
                         $stylesheets['tribe-events-calendar-full-mobile-style'] = 'tribe-events-full-mobile.css';
                         $stylesheets['tribe-events-calendar-mobile-style'] = 'tribe-events-theme-mobile.css';
                     }
                     break;
             }
             // put override css at the end of the array
             $stylesheets['tribe-events-calendar-override-style'] = 'tribe-events/tribe-events.css';
             // do the enqueues
             foreach ($stylesheets as $name => $css_file) {
                 if ($name == 'tribe-events-calendar-override-style') {
                     $user_stylesheet_url = TribeEventsTemplates::locate_stylesheet('tribe-events/tribe-events.css');
                     if ($user_stylesheet_url) {
                         wp_enqueue_style($name, $user_stylesheet_url);
                     }
                 } else {
                     // get full URL
                     $url = tribe_events_resource_url($css_file);
                     // get the minified file
                     $url = self::getMinFile($url, true);
                     // apply filters
                     $url = apply_filters('tribe_events_stylesheet_url', $url, $name);
                     // set the $media attribute
                     if ($name == 'tribe-events-calendar-mobile-style' || $name == 'tribe-events-calendar-full-mobile-style') {
                         $media = "(max-width: {$mobile_break}px)";
                         wp_enqueue_style($name, $url, array('tribe-events-calendar-style'), TribeEvents::VERSION, $media);
                     } else {
                         wp_register_style($name, $url, array(), TribeEvents::VERSION);
                         wp_enqueue_style($name);
                     }
                 }
             }
             break;
         default:
             do_action($prefix . '-' . $name);
             break;
     }
 }
 /**
  * Create CSS for stylesheet
  * Minify CSS when WP_DEBUG is false
  * @link https://gist.github.com/manastungare/2625128
  *
  * @return mixed|string
  */
 protected function generate_css()
 {
     // Look out for fresh_css requests
     $refresh_css = array_key_exists('refresh_css', $_GET) ? true : false;
     $debug_css = array_key_exists('debug_css', $_GET) ? true : false;
     // Return cached CSS if available and if fresh CSS hasn't been requested
     $cache_key = 'teccc_' . $this->options_hash();
     $css = get_transient($cache_key);
     if (!empty($css) && (!$refresh_css && !$debug_css)) {
         return $css;
     }
     // Else generate the CSS afresh
     ob_start();
     $this->teccc->view('category.css', array('options' => $this->options, 'teccc' => $this->teccc, 'breakpoint' => tribe_get_mobile_breakpoint()));
     $css = ob_get_clean();
     if ((!defined('WP_DEBUG') || !WP_DEBUG) && !$debug_css) {
         $css = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $css);
         // Remove comments
         $css = str_replace(': ', ':', $css);
         // Remove space after colons
         $css = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '   ', '    '), '', $css);
         // Remove whitespace
     }
     // Store in transient
     set_transient($cache_key, $css, 4 * WEEK_IN_SECONDS);
     return $css;
 }
 /**
  * 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);
 }