コード例 #1
0
 function enqueue_scripts()
 {
     global $wp_query;
     $obj_id = is_home() ? '-1' : $wp_query->get_queried_object_id();
     $wpfc_scripts_limit = get_option('wpfc_scripts_limit');
     if (empty($wpfc_scripts_limit) || in_array($obj_id, explode(',', $wpfc_scripts_limit))) {
         //Scripts
         wp_enqueue_script('wp-fullcalendar', plugins_url('includes/js/main.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'));
         //jQuery will load as dependency
         WP_FullCalendar::localize_script();
         //Styles
         wp_enqueue_style('wp-fullcalendar', plugins_url('includes/css/main.css', __FILE__));
     }
 }
コード例 #2
0
 public static function enqueue_scripts()
 {
     global $wp_query;
     $min = defined('WP_DEBUG') && WP_DEBUG ? '' : '.min';
     $obj_id = is_home() ? '-1' : $wp_query->get_queried_object_id();
     $wpfc_scripts_limit = get_option('wpfc_scripts_limit');
     if (empty($wpfc_scripts_limit) || in_array($obj_id, explode(',', $wpfc_scripts_limit))) {
         //Scripts
         wp_enqueue_script('wp-fullcalendar', plugins_url('includes/js/main.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-selectmenu'), WPFC_VERSION);
         //jQuery will load as dependency
         WP_FullCalendar::localize_script();
         //Styles
         wp_enqueue_style('wp-fullcalendar', plugins_url('includes/css/main.css', __FILE__), array(), WPFC_VERSION);
         //Load custom style or jQuery UI Theme
         $wpfc_theme = get_option('wpfc_theme_css');
         if (preg_match('/\\.css$/', $wpfc_theme)) {
             //user-defined style within the themes/themename/plugins/wp-fullcalendar/ folder
             //if you're using jQuery UI Theme-Roller, you need to include the jquery-ui-css framework file too, you could do this using the @import CSS rule or include it all in your CSS file
             if (file_exists(get_stylesheet_directory() . "/plugins/wp-fullcalendar/" . $wpfc_theme)) {
                 $wpfc_theme_css = get_stylesheet_directory_uri() . "/plugins/wp-fullcalendar/" . $wpfc_theme;
                 wp_deregister_style('jquery-ui');
                 wp_enqueue_style('jquery-ui', $wpfc_theme_css, array('wp-fullcalendar'), WPFC_VERSION);
             }
         } elseif (!empty($wpfc_theme)) {
             //We'll find the current jQuery UI version and attempt to load the right version of jQuery UI, otherwise we'll load the default. This allows backwards compatability from 3.6 onwards.
             global $wp_scripts;
             $jquery_ui_version = preg_replace('/\\.[0-9]+$/', '', $wp_scripts->registered['jquery-ui-core']->ver);
             if ($jquery_ui_version != WPFC_UI_VERSION) {
                 $jquery_ui_css_versions = glob($plugin_path = plugin_dir_path(__FILE__) . "/includes/css/jquery-ui-" . $jquery_ui_version . '*', GLOB_ONLYDIR);
                 if (!empty($jquery_ui_css_versions)) {
                     //use backwards compatible theme
                     $jquery_ui_css_folder = str_replace(plugin_dir_path(__FILE__), '', array_pop($jquery_ui_css_versions));
                     $jquery_ui_css_uri = plugins_url(trailingslashit($jquery_ui_css_folder) . $wpfc_theme . "/jquery-ui{$min}.css", __FILE__);
                     $wpfc_theme_css = plugins_url(trailingslashit($jquery_ui_css_folder) . $wpfc_theme . '/theme.css', __FILE__);
                 }
             }
             if (empty($wpfc_theme_css)) {
                 //use default theme
                 $jquery_ui_css_uri = plugins_url('/includes/css/jquery-ui/' . $wpfc_theme . "/jquery-ui{$min}.css", __FILE__);
                 $wpfc_theme_css = plugins_url('/includes/css/jquery-ui/' . $wpfc_theme . '/theme.css', __FILE__);
             }
             if (!empty($wpfc_theme_css)) {
                 wp_deregister_style('jquery-ui');
                 wp_enqueue_style('jquery-ui', $jquery_ui_css_uri, array('wp-fullcalendar'), WPFC_VERSION);
                 wp_enqueue_style('jquery-ui-theme', $wpfc_theme_css, array('wp-fullcalendar'), WPFC_VERSION);
             }
         }
     }
 }