CorePress后台主题设置显示空白修复教程

前言

今天在写文章的时候发现在使用CorePress编辑器增强功能时图标错位,如下图所示

本以为是主题设置有问题,于是保存草稿后,准备进入主题设置查看原因,点开主题设置页面发现,主题页面加载不出来,如下图所示

使用F12检查发现,有一个css和两个js文件加载不出来,进一步查看发现是原来使用的字节跳动CDN链接失效了,于是在网上找到了其他的CDN链接来替换掉失效的链接

教程

找到原因后,使用grep -rni 命令定位到需要修改的文件路径:根目录/wp-content/themes/CorePress/geekframe/loadfiles.php

下列两个CDN任选其一,将loadfiles.php 中以下代码替换掉即可

1.jsDelivr CDN(推荐):

function corepress_load_style_filse_onadmin($hook)
{
    wp_enqueue_style('corepressicon', THEME_LIB_PATH . '/corepressicon/iconfont.css', array(), THEME_VERSION);
    if ($hook == 'post.php' || $hook == 'post-new.php') {
        wp_enqueue_script('tools', THEME_JS_PATH . '/tools.js', array(), THEME_VERSION, false);
        wp_enqueue_script('layer', THEME_LIB_PATH . '/layer/layer.js', array(), THEME_VERSION, false);
        wp_enqueue_script('vue', 'https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js', array(), THEME_VERSION, false);
        wp_localize_script('tools', 'tools', array('index' => is_home(), 'page' => is_page(), 'post' => is_single()));
        wp_enqueue_script('corepress_element_js', 'https://cdn.jsdelivr.net/npm/element-ui@2.15.7/lib/index.min.js', array(), THEME_VERSION, false);
        wp_enqueue_style('corepress_element_css', 'https://cdn.jsdelivr.net/npm/element-ui@2.15.7/lib/theme-chalk/index.min.css', array(), THEME_VERSION);
        wp_enqueue_style('corepress_admin_css', THEME_CSS_PATH . '/admin.css', array(), THEME_VERSION);
        wp_enqueue_style('editor_window', THEME_CSS_PATH . '/editor-window.css', array(), THEME_VERSION);
    }
    if ($hook=='toplevel_page_geekpress_setting') {

        wp_enqueue_script('vue', 'https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js', array(), THEME_VERSION, false);

        wp_enqueue_script('corepress_element_js', 'https://cdn.jsdelivr.net/npm/element-ui@2.15.7/lib/index.min.js', array(), THEME_VERSION, false);
        wp_enqueue_style('corepress_element_css', 'https://cdn.jsdelivr.net/npm/element-ui@2.15.7/lib/theme-chalk/index.min.css', array(), THEME_VERSION);

    }

}

2.unpkg备用链接:

function corepress_load_style_filse_onadmin($hook)
{
    wp_enqueue_style('corepressicon', THEME_LIB_PATH . '/corepressicon/iconfont.css', array(), THEME_VERSION);
    if ($hook == 'post.php' || $hook == 'post-new.php') {
        wp_enqueue_script('tools', THEME_JS_PATH . '/tools.js', array(), THEME_VERSION, false);
        wp_enqueue_script('layer', THEME_LIB_PATH . '/layer/layer.js', array(), THEME_VERSION, false);
        wp_enqueue_script('vue', 'https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js', array(), THEME_VERSION, false);
        wp_localize_script('tools', 'tools', array('index' => is_home(), 'page' => is_page(), 'post' => is_single()));
        wp_enqueue_script('corepress_element_js', 'https://unpkg.com/element-ui@2.15.7/lib/index.js', array(), THEME_VERSION, false);
        wp_enqueue_style('corepress_element_css', 'https://unpkg.com/element-ui@2.15.7/lib/theme-chalk/index.css', array(), THEME_VERSION);
        wp_enqueue_style('corepress_admin_css', THEME_CSS_PATH . '/admin.css', array(), THEME_VERSION);
        wp_enqueue_style('editor_window', THEME_CSS_PATH . '/editor-window.css', array(), THEME_VERSION);
    }
    if ($hook=='toplevel_page_geekpress_setting') {

        wp_enqueue_script('vue', 'https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js', array(), THEME_VERSION, false);

        wp_enqueue_script('corepress_element_js', 'https://unpkg.com/element-ui@2.15.7/lib/index.js', array(), THEME_VERSION, false);
        wp_enqueue_style('corepress_element_css', 'https://unpkg.com/element-ui@2.15.7/lib/theme-chalk/index.css', array(), THEME_VERSION);

    }

}

替换掉失效的链接后,再次打开主题设置页面即可正常访问。

 

 

版权声明:
作者:蓝逸轩
链接:https://www.12xf.cn/1227.html
来源:星锋网
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>