/** * Enqueue scripts and styles. * * @since 3.0.0 */ public function load() { $css_path = SIMPLE_CALENDAR_ASSETS . 'css/'; $css_path_vendor = $css_path . 'vendor/'; $js_path = SIMPLE_CALENDAR_ASSETS . 'js/'; $js_path_vendor = $js_path . 'vendor/'; /* ====================== * * Register Admin Scripts * * ====================== */ // TipTip uses ".minified.js" filename ending. wp_register_script('simcal-tiptip', $js_path_vendor . 'jquery.tipTip' . ($this->min !== '' ? '.minified' : '') . '.js', array('jquery'), SIMPLE_CALENDAR_VERSION, true); wp_register_script('simcal-select2', $js_path_vendor . 'select2' . $this->min . '.js', array(), SIMPLE_CALENDAR_VERSION, true); wp_register_script('simcal-admin', $js_path . 'admin' . $this->min . '.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-datepicker', 'wp-color-picker', 'simcal-tiptip', 'simcal-select2'), SIMPLE_CALENDAR_VERSION, true); wp_register_script('simcal-admin-add-calendar', $js_path . 'admin-add-calendar' . $this->min . '.js', array('simcal-select2'), SIMPLE_CALENDAR_VERSION, true); /* ===================== * * Register Admin Styles * * ===================== */ wp_register_style('simcal-select2', $css_path_vendor . 'select2' . $this->min . '.css', array(), SIMPLE_CALENDAR_VERSION); wp_register_style('simcal-admin', $css_path . 'admin' . $this->min . '.css', array('wp-color-picker', 'simcal-select2'), SIMPLE_CALENDAR_VERSION); wp_register_style('simcal-admin-add-calendar', $css_path . 'admin-add-calendar' . $this->min . '.css', array('simcal-select2'), SIMPLE_CALENDAR_VERSION); if (simcal_is_admin_screen() !== false) { wp_enqueue_script('simcal-admin'); wp_localize_script('simcal-admin', 'simcal_admin', simcal_common_scripts_variables()); wp_enqueue_style('simcal-admin'); } else { global $post_type; $screen = get_current_screen(); $post_types = array(); $settings = get_option('simple-calendar_settings_calendars'); if (isset($settings['general']['attach_calendars_posts'])) { $post_types = $settings['general']['attach_calendars_posts']; } $conditions = array(in_array($post_type, (array) $post_types), $screen->id == 'widgets'); if (in_array(true, $conditions)) { wp_enqueue_script('simcal-admin-add-calendar'); wp_localize_script('simcal-admin-add-calendar', 'simcal_admin', array('locale' => get_locale(), 'text_dir' => is_rtl() ? 'rtl' : 'ltr')); wp_enqueue_style('simcal-admin-add-calendar'); } } }
/** * Default calendar list scripts. * * Scripts to load when this view is displayed. * * @since 3.0.0 * * @param string $min * * @return array */ public function scripts($min = '') { return array('simcal-qtip' => array('src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', 'deps' => array('jquery'), 'ver' => '2.2.1', 'in_footer' => true), 'simcal-default-calendar' => array('src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', 'deps' => array('jquery', 'simcal-qtip'), 'var' => SIMPLE_CALENDAR_VERSION, 'in_footer' => true, 'localize' => array('simcal_default_calendar' => simcal_common_scripts_variables()))); }
/** * Default calendar grid scripts. * * Scripts to load when this view is displayed. * * @since 3.0.0 * * @param string $min * * @return array */ public function scripts($min = '') { return array('simcal-qtip' => array('src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/jquery.qtip' . $min . '.js', 'deps' => array('jquery'), 'in_footer' => true), 'simcal-fullcal-moment' => array('src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/moment' . $min . '.js', 'deps' => array('jquery'), 'in_footer' => true), 'simcal-moment-timezone' => array('src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/moment-timezone-with-data' . $min . '.js', 'deps' => array('jquery'), 'in_footer' => true), 'simcal-default-calendar' => array('src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', 'deps' => array('jquery', 'simcal-qtip', 'simcal-fullcal-moment', 'simcal-moment-timezone'), 'in_footer' => true, 'localize' => array('simcal_default_calendar' => simcal_common_scripts_variables()))); }