示例#1
0
function mc_register_styles()
{
    global $wp_query;
    $stylesheet = mc_get_style_path(get_option('mc_css_file'), 'url');
    wp_register_style('my-calendar-style', $stylesheet);
    $admin_stylesheet = plugins_url('css/mc-admin.css', __FILE__);
    wp_register_style('my-calendar-admin-style', $admin_stylesheet);
    if (current_user_can('mc_manage_events')) {
        wp_enqueue_style('my-calendar-admin-style');
    }
    $this_post = $wp_query->get_queried_object();
    $id = is_object($this_post) && isset($this_post->ID) ? $this_post->ID : false;
    $js_array = get_option('mc_show_js') != '' ? explode(",", get_option('mc_show_js')) : array();
    $css_array = get_option('mc_show_css') != '' ? explode(",", get_option('mc_show_css')) : array();
    // check whether any scripts are actually enabled.
    if (get_option('mc_calendar_javascript') != 1 || get_option('mc_list_javascript') != 1 || get_option('mc_mini_javascript') != 1 || get_option('mc_ajax_javascript') != 1) {
        if (@in_array($id, $js_array) || get_option('mc_show_js') == '') {
            wp_enqueue_script('jquery');
            if (get_option('mc_gmap') == 'true') {
                wp_register_script('gmaps', "//maps.google.com/maps/api/js?sensor=true");
                wp_register_script('gmap3', plugins_url('js/gmap3.min.js', __FILE__), array('jquery'));
                wp_enqueue_script('gmaps');
                wp_enqueue_script('gmap3');
            }
        }
    }
    if (get_option('mc_use_styles') != 'true') {
        if (@in_array($id, $css_array) || get_option('mc_show_css') == '') {
            wp_enqueue_style('my-calendar-style');
        }
    }
    if (mc_is_tablet() && mc_file_exists('mc-tablet.css')) {
        $tablet = mc_get_file('mc-tablet.css');
        wp_register_style('my-calendar-tablet-style', $tablet);
        wp_enqueue_style('my-calendar-tablet-style');
    }
    if (mc_is_mobile() && mc_file_exists('mc-mobile.css')) {
        $mobile = mc_get_file('mc-mobile.css');
        wp_register_style('my-calendar-mobile-style', $mobile);
        wp_enqueue_style('my-calendar-mobile-style');
    }
    if (function_exists('mcs_submissions')) {
        $mcs = plugins_url('/my-calendar-submissions/mcs-styles.css');
        $mcs_ui = plugins_url('/my-calendar-submissions/css/smoothness/jquery-ui-1.8.23.custom.css');
        wp_register_style('my-calendar-submissions-ui-style', $mcs_ui);
        wp_enqueue_style('my-calendar-submissions-ui-style');
        wp_register_style('my-calendar-submissions-style', $mcs);
        wp_enqueue_style('my-calendar-submissions-style');
    }
}
function mc_register_styles()
{
    global $wp_query;
    $stylesheet = apply_filters('mc_registered_stylesheet', mc_get_style_path(get_option('mc_css_file'), 'url'));
    wp_register_style('my-calendar-reset', plugins_url('css/reset.css', __FILE__));
    wp_register_style('my-calendar-style', $stylesheet, array('dashicons', 'my-calendar-reset'));
    $admin_stylesheet = plugins_url('css/mc-admin.css', __FILE__);
    wp_register_style('my-calendar-admin-style', $admin_stylesheet);
    if (current_user_can('mc_manage_events')) {
        wp_enqueue_style('my-calendar-admin-style');
    }
    $this_post = $wp_query->get_queried_object();
    $id = is_object($this_post) && isset($this_post->ID) ? $this_post->ID : false;
    $js_array = get_option('mc_show_js') != '' ? explode(",", get_option('mc_show_js')) : array();
    $css_array = get_option('mc_show_css') != '' ? explode(",", get_option('mc_show_css')) : array();
    // check whether any scripts are actually enabled.
    if (get_option('mc_calendar_javascript') != 1 || get_option('mc_list_javascript') != 1 || get_option('mc_mini_javascript') != 1 || get_option('mc_ajax_javascript') != 1) {
        if (@in_array($id, $js_array) || get_option('mc_show_js') == '' || is_singular('mc-events')) {
            wp_enqueue_script('jquery');
            if (get_option('mc_gmap') == 'true') {
                $api_key = get_option('mc_gmap_api_key');
                if ($api_key) {
                    wp_enqueue_script('gmaps', "https://maps.googleapis.com/maps/api/js?key={$api_key}");
                    wp_enqueue_script('gmap3', plugins_url('js/gmap3.min.js', __FILE__), array('jquery'));
                }
            }
        }
    }
    if (get_option('mc_use_styles') != 'true') {
        if (@in_array($id, $css_array) || get_option('mc_show_css') == '') {
            wp_enqueue_style('my-calendar-style');
        }
    }
    if (mc_is_tablet() && mc_file_exists('mc-tablet.css')) {
        $tablet = mc_get_file('mc-tablet.css');
        wp_register_style('my-calendar-tablet-style', $tablet);
        wp_enqueue_style('my-calendar-tablet-style');
    }
    if (mc_is_mobile() && mc_file_exists('mc-mobile.css')) {
        $mobile = mc_get_file('mc-mobile.css');
        wp_register_style('my-calendar-mobile-style', $mobile);
        wp_enqueue_style('my-calendar-mobile-style');
    }
}