Redirect Css files to https

时间:2021-08-04 作者:Norman

在哪里可以找到负责调用Css文件的文件,并测试它们的链接是http还是https?

我想测试请求是否为https,如果是,那么很好,如果不是,请将其更改为https

在函数中。php我找到了负责调用主题Css的函数,下面是它的代码:

if (!function_exists(\'jobcareer_front_scripts\')) {

    function jobcareer_front_scripts() {
        global $jobcareer_options;
        if (!is_admin()) {
            /*
             * Css Files
             */
            wp_enqueue_style(\'jobcareer_iconmoon_css\', trailingslashit(get_template_directory_uri()) . \'assets/css/iconmoon.css\');
            wp_enqueue_style(\'cs_bootstrap_css\', trailingslashit(get_template_directory_uri()) . \'assets/css/bootstrap.css\');
            wp_enqueue_style(\'jobcareer_style_css\', get_stylesheet_directory_uri() . \'/style.css\');
            wp_enqueue_style(\'jobcareer_nav-icon\', trailingslashit(get_template_directory_uri()) . \'assets/css/nav-icon.css\');
            wp_enqueue_style(\'jobcareer_top-menu\', trailingslashit(get_template_directory_uri()) . \'assets/css/top-menu.css\');
            wp_enqueue_style(\'cs_slicknav_css\', trailingslashit(get_template_directory_uri()) . \'assets/css/slicknav.css\');
            wp_enqueue_style(\'jobcareer_widgets_css\', trailingslashit(get_template_directory_uri()) . \'assets/css/widget.css\');
            wp_enqueue_style(\'jobcareer_prettyPhoto\', trailingslashit(get_template_directory_uri()) . \'assets/css/prettyPhoto.css\');
            if (class_exists(\'WooCommerce\')) {
                wp_enqueue_style(\'cs-woocommerce\', trailingslashit(get_template_directory_uri()) . \'assets/css/cs-woocommerce.css\');
            }

            // color style 
            $custom_style_ver = (isset($jobcareer_options[\'jobcareer_theme_option_save_flag\'])) ? $jobcareer_options[\'jobcareer_theme_option_save_flag\'] : \'\';
            wp_enqueue_style(\'jobcareer_custom_style_css\', trailingslashit(get_template_directory_uri()) . \'assets/css/custom-style.css\', \'\', $custom_style_ver);

            /*
             * Js Files
             * 
             */

            if (isset($jobcareer_options[\'cs_maintenance_page_switch\']) and $jobcareer_options[\'cs_maintenance_page_switch\'] == \'on\') {
                wp_enqueue_script(\'jobcareer_addthis_widget_js\', \'\' . cs_server_protocol() . \'s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e4412d954dccc64\', \'\', \'\', true);
            }
            wp_enqueue_script(\'cs_bootstrap_min_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/bootstrap.min.js\', array(\'jquery\'), \'\', true);
            wp_enqueue_script(\'jobcareer_modernizr_min_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/modernizr.min.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_browser_detect_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/browser-detect.js\', \'\', \'\', true);
            wp_enqueue_script(\'cs_slick_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/slick.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_jquery_sticky_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.sticky.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_map_styles\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/cs_map_styles.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_functions_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/functions.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_menu_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/menu.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_prettyPhoto_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.prettyPhoto.js\', \'\', \'\', true);
            wp_enqueue_script(\'jobcareer_lightbox_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/lightbox.js\', \'\', \'\', true);

            if (is_singular() && get_option(\'thread_comments\') && get_comments_number()) {
                wp_enqueue_script(\'comment-reply\');
            }

            /*
             * Include scroll js enqueue files functions 
             */
            if (!function_exists(\'jobcareer_scrolltofix\')) {

                function jobcareer_scrolltofix() {
                    wp_enqueue_script(\'jobcareer_sticky_header_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/sticky_header.js\', \'\', \'\', true);
                }

            }

            /*
             * Include scroll js enqueue files functions 
             */
            if (!function_exists(\'jobcareer_jquery_easing_js\')) {

                function jobcareer_jquery_easing_js() {
                    wp_enqueue_script(\'jobcareer_jquery_easing_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.easing.1.3.js\', \'\', \'\', true);
                }

            }

            // Start Include  Counter Script enqueue files functions 
            if (!function_exists(\'jobcareer_counter_script\')) {

                function jobcareer_counter_script() {
                    wp_enqueue_script(\'jobcareer_counter_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/counter.js\', \'\', \'\', true);
                }

            }

            /*
             *  Include slick Script enqueue files functions 
             */
            if (!function_exists(\'jobcareer_enqueue_slick_script\')) {

                function jobcareer_enqueue_slick_script() {
                    wp_enqueue_script(\'cs_slick_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/slick.js\', \'\', \'\', true);
                }

            }

            /*
             * Start Include Count Script enqueue files functions 
             */
            if (!function_exists(\'jobcareer_enqueue_count_nos\')) {

                function jobcareer_enqueue_count_nos() {
                    wp_enqueue_script(\'jobcareer_countTo_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.countTo.js\', \'\', \'\', true);
                    wp_enqueue_script(\'jobcareer_inview_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.inview.min.js\', \'\', \'\', true);
                }

            }

            /*
             * Start Include Ticker enqueue files functions 
             */
            if (!function_exists(\'jobcareer_news_ticker_script\')) {

                function jobcareer_news_ticker_script() {
                    wp_enqueue_script(\'jobcareer_news_ticker_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/ticker.js\', \'\', \'\', true);
                }

            }
            /*
             *  End Include Ticker enqueue files functions 
             */

            if (!function_exists(\'jobcareer_google_map_script\')) {

                function jobcareer_google_map_script() {
                    global $jobcareer_options;
                    $google_api_key = \'?libraries=places\';
                    if (isset($jobcareer_options[\'cs_googleapi_key\']) && $jobcareer_options[\'cs_googleapi_key\'] != \'\') {
                        $google_api_key = \'?key=\' . $jobcareer_options[\'cs_googleapi_key\'] . \'&libraries=places\';
                    }
                    wp_enqueue_script(\'cs_google_autocomplete_script\', \'https://maps.googleapis.com/maps/api/js\' . $google_api_key);
                }

            }

            // Start Include Slide Menu enqueue files functions
            if (!function_exists(\'jobcareer_sliiide_menu\')) {

                function jobcareer_sliiide_menu() {
                    wp_enqueue_script(\'jobcareer_sliiide_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/sliiide.js\', \'\', \'\', true);
                    wp_enqueue_script(\'jobcareer_nav-icon_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/nav-icon.js\', \'\', \'\', true);
                    wp_enqueue_script(\'jobcareer_jquery.slicknav_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.slicknav.js\', \'\', \'\', true);
                }

            }

            /*
             * Start Add this soocial sharing enqueue Script
             */
            if (!function_exists(\'jobcareer_addthis_script_init_method\')) {

                function jobcareer_addthis_script_init_method() {
                    wp_enqueue_script(\'jobcareer_addthis_widget_js\', \'\' . cs_server_protocol() . \'s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e4412d954dccc64\');
                }

            }

            if (!function_exists(\'jobcareer_dynamic_scripts\')) {

                function jobcareer_dynamic_scripts($cs_js_key, $cs_arr_key, $cs_js_code) {
                    // Register the script
                    wp_register_script(\'jobcareer_dynamic_scripts\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/cs_inline_scripts_functions.js\', \'\', \'\', true);


                    // Localize the script
                    $cs_code_array = array(
                        $cs_arr_key => $cs_js_code
                    );
                    wp_localize_script(\'jobcareer_dynamic_scripts\', $cs_js_key, $cs_code_array);
                    wp_enqueue_script(\'jobcareer_dynamic_scripts\');

                    wp_enqueue_style(\'jobcareer_dynamic_scripts\');
                }

            }

            if (!function_exists(\'jobcareer_gallery_masonry\')) {

                function jobcareer_gallery_masonry() {
                    wp_enqueue_script(\'jobcareer_init_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/init.js\', \'\', \'\', true);
                    wp_enqueue_script(\'jobcareer_freetile_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/jquery.freetile.js\', \'\', \'\', true);
                    wp_enqueue_script(\'jobcareer_masonry_pkgd_min_js\', trailingslashit(get_template_directory_uri()) . \'assets/scripts/masonry.pkgd.min.js\', \'\', \'\', true);
                }

            }
        }
        jobcareer_inline_styles_method();
    }

}
非常感谢。

1 个回复
SO网友:Shashikant

您只需更改httphttps在您的site_urlhome_url 中的字段wp_options 桌子

希望它能起作用。

相关推荐

未应用自定义CSS导航菜单样式

我创建了一个插件和自定义CSS页面,在WordPress网站的一个页面上显示自定义导航菜单。我试图在感兴趣的页面上使用自定义HTML块显示导航菜单。使用查询监视器,我可以看到样式正在应用于页面,但自定义HTML从未将样式应用于页面。有人能看出我做错了什么吗?下面是让我的CSS排队的PHP:function additional_stylesheets() { // wp_register_style( \'bt-wp-styles\', get_template_director