WordPress后端正在加载,没有样式

时间:2020-07-04 作者:Arnab88

我的网站WordPress后端未加载CSS…。前端工作正常,但一旦我尝试登录到我的wordpress管理员,页面加载将不带任何样式。。我多次重新安装WordPress核心文件,并尝试添加这些文件(define(\'CONCATENATE\\u SCRIPTS\',false);define(\'SCRIPT\\u DEBUG\',true);在wp配置中。php但问题仍未修复

enter image description here

chrome Consor中的错误显示:

拒绝应用来自“”的样式https://www.csm.school/wp-admin/load-styles.php?c=1&;dir=长期(&R);加载%5Bchunk\\u 0%5D=仪表盘图标、管理栏、wp指针、站点运行状况、公用、表单、管理菜单、仪表盘、列表表、编辑、修订、媒体、主题、关于、导航和维护;加载%5Bchunk\\u 1%5D=enus、widgets、站点图标、l10n、按钮、wp auth check&;ver=5.4.2”,因为其MIME类型(“文本/html”)不是受支持的样式表MIME类型,并且启用了严格的MIME检查。

作用php:

<?php

// simple error trapping on screen
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// full errors
//  error_reporting(E_ALL);


/**
 * Customify functions and definitions
 *
 * @link    https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package customify
 */

/**
 *  Same the hook `the_content`
 *
 * @TODO: do not effect content by plugins
 *
 * 8 WP_Embed:run_shortcode
 * 8 WP_Embed:autoembed
 * 10 wptexturize
 * 10 wpautop
 * 10 shortcode_unautop
 * 10 prepend_attachment
 * 10 wp_make_content_images_responsive
 * 11 capital_P_dangit
 * 11 do_shortcode
 * 20 convert_smilies
 */
global $wp_embed;
add_filter( \'customify_the_content\', array( $wp_embed, \'run_shortcode\' ), 8 );
add_filter( \'customify_the_content\', array( $wp_embed, \'autoembed\' ), 8 );
add_filter( \'customify_the_content\', \'wptexturize\' );
add_filter( \'customify_the_content\', \'wpautop\' );
add_filter( \'customify_the_content\', \'shortcode_unautop\' );
add_filter( \'customify_the_content\', \'wp_make_content_images_responsive\' );
add_filter( \'customify_the_content\', \'capital_P_dangit\' );
add_filter( \'customify_the_content\', \'do_shortcode\' );
add_filter( \'customify_the_content\', \'convert_smilies\' );


/**
 *  Same the hook `the_content` but not auto P
 *
 * @TODO: do not effect content by plugins
 *
 * 8 WP_Embed:run_shortcode
 * 8 WP_Embed:autoembed
 * 10 wptexturize
 * 10 shortcode_unautop
 * 10 prepend_attachment
 * 10 wp_make_content_images_responsive
 * 11 capital_P_dangit
 * 11 do_shortcode
 * 20 convert_smilies
 */
add_filter( \'customify_the_title\', array( $wp_embed, \'run_shortcode\' ), 8 );
add_filter( \'customify_the_title\', array( $wp_embed, \'autoembed\' ), 8 );
add_filter( \'customify_the_title\', \'wptexturize\' );
add_filter( \'customify_the_title\', \'shortcode_unautop\' );
add_filter( \'customify_the_title\', \'wp_make_content_images_responsive\' );
add_filter( \'customify_the_title\', \'capital_P_dangit\' );
add_filter( \'customify_the_title\', \'do_shortcode\' );
add_filter( \'customify_the_title\', \'convert_smilies\' );

// Include the main Customify class.
require_once get_template_directory() . \'/inc/class-customify.php\';

/**
 * Main instance of Customify.
 *
 * Returns the main instance of Customify.
 *
 * @return Customify
 */
function Customify() {
    // phpc:ignore WordPress.NamingConventions.ValidFunctionName.
    return Customify::get_instance();
}

Customify();
加载样式。php:

    <?php

/**
 * Disable error reporting
 *
 * Set this to error_reporting( -1 ) for debugging
 */
error_reporting( 0 );

/** Set ABSPATH for execution */
if ( ! defined( \'ABSPATH\' ) ) {
    define( \'ABSPATH\', dirname( __DIR__ ) . \'/\' );
}

define( \'WPINC\', \'wp-includes\' );

require ABSPATH . \'wp-admin/includes/noop.php\';
require ABSPATH . WPINC . \'/script-loader.php\';
require ABSPATH . WPINC . \'/version.php\';

$protocol = $_SERVER[\'SERVER_PROTOCOL\'];
if ( ! in_array( $protocol, array( \'HTTP/1.1\', \'HTTP/2\', \'HTTP/2.0\' ) ) ) {
    $protocol = \'HTTP/1.0\';
}

$load = $_GET[\'load\'];
if ( is_array( $load ) ) {
    ksort( $load );
    $load = implode( \'\', $load );
}

$load = preg_replace( \'/[^a-z0-9,_-]+/i\', \'\', $load );
$load = array_unique( explode( \',\', $load ) );

if ( empty( $load ) ) {
    header( "$protocol 400 Bad Request" );
    exit;
}

$rtl            = ( isset( $_GET[\'dir\'] ) && \'rtl\' == $_GET[\'dir\'] );
$expires_offset = 31536000; // 1 year.
$out            = \'\';

$wp_styles = new WP_Styles();
wp_default_styles( $wp_styles );

if ( isset( $_SERVER[\'HTTP_IF_NONE_MATCH\'] ) && stripslashes( $_SERVER[\'HTTP_IF_NONE_MATCH\'] ) === $wp_version ) {
    header( "$protocol 304 Not Modified" );
    exit();
}

foreach ( $load as $handle ) {
    if ( ! array_key_exists( $handle, $wp_styles->registered ) ) {
        continue;
    }

    $style = $wp_styles->registered[ $handle ];

    if ( empty( $style->src ) ) {
        continue;
    }

    $path = ABSPATH . $style->src;

    if ( $rtl && ! empty( $style->extra[\'rtl\'] ) ) {
        // All default styles have fully independent RTL files.
        $path = str_replace( \'.min.css\', \'-rtl.min.css\', $path );
    }

    $content = get_file( $path ) . "\\n";

    if ( strpos( $style->src, \'/\' . WPINC . \'/css/\' ) === 0 ) {
        $content = str_replace( \'../images/\', \'../\' . WPINC . \'/images/\', $content );
        $content = str_replace( \'../js/tinymce/\', \'../\' . WPINC . \'/js/tinymce/\', $content );
        $content = str_replace( \'../fonts/\', \'../\' . WPINC . \'/fonts/\', $content );
        $out    .= $content;
    } else {
        $out .= str_replace( \'../images/\', \'images/\', $content );
    }
}

header( "Etag: $wp_version" );
header( \'Expires: \' . gmdate( \'D, d M Y H:i:s\', time() + $expires_offset ) . \' GMT\' );
header( "Cache-Control: public, max-age=$expires_offset" );

echo $out;
exit;
。Htaccess:

<FilesMatch index.php>
Order Allow,Deny
Allow from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

1 个回复
SO网友:Will Craig

加载样式。上面提供的php URL正在重定向到登录表单,这就是为什么检查器抱怨HTML响应。

我在一个新的安装上测试了这个,WordPress会返回这些样式,即使你注销了,所以你有很多。htaccess或PHP代码重定向加载样式。登录表单的php文件。

您还删除了一行core,它告诉浏览器PHP脚本是一个CSS文件,尽管我怀疑Chrome仍然会解析它,只要响应实际上是CSS,您永远不应该这样做,因此我还建议通过Dashboard重新安装WordPress=>;更新以使core恢复到正确状态。

相关推荐

Style.css样式表不包含有效的主题标题

当我尝试上传一个我在免费主机上上传的主题时,这是我第一次在主机上上传主题,我得到了这个错误,因为风格。css样式表不包含有效的主题标头。然后我把这个放在我的风格上。css,但仍然会出现此错误,尽管主题在本地主机上运行得很好。请问我该怎么办?/* Theme Name: shah Author: shah Author URI: http://shah.gq Description: Wordpress Theme Versio