0

My website WordPress backend is not loading with CSS….the frontend is working fine but once i try login to my wordpress admin the page load without any style .. I have reinstalled WordPress core file many time and i have try and added these (define( ‘CONCATENATE_SCRIPTS’, false ); define( ‘SCRIPT_DEBUG’, true ); in wp-config.php but problem still not fixed

enter image description here

the error in chrome consul is showing :

Refused to apply style from 'https://www.csm.school/wp-admin/load-styles.php?c=1&dir=ltr&load%5Bchunk_0%5D=dashicons,admin-bar,wp-pointer,site-health,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-m&load%5Bchunk_1%5D=enus,widgets,site-icon,l10n,buttons,wp-auth-check&ver=5.4.2' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Function.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();

Load-style.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>
8
  • Hi @Arnab88 could you please add the code to the question with which you're loading all of your stylesheets? Most likely it's in the functions.php file. Second, can you please check if your CSS file has a specific header or so?
    – ralphjsmit
    Jul 4, 2020 at 11:18
  • sure i will dd all the content of function.php and load-style.php in the question if that is what you mean
    – Arnab88
    Jul 4, 2020 at 11:51
  • Where do you load the load-style.php file? It seems to me that it's never included and so it doesn't do anything in the first place. Or am I wrong in this?
    – ralphjsmit
    Jul 4, 2020 at 12:09
  • 2
    Don't touch core files (load-style.php in this case) under any circumstances. Yours has been edited already and a header is missing in the line #83.
    – Max Yudin
    Jul 4, 2020 at 13:53
  • 1
    Max is right: load-styles should have a line header( 'Content-Type: text/css; charset=UTF-8' ); amongst the other header() lines at the bottom. Why did you delete that? Can you put it back?
    – Rup
    Jul 4, 2020 at 16:22

2 Answers 2

1

The load-style.php URL you provided above is redirecting to the login form and this is why the inspector is complaining about a HTML response.

I tested this on a fresh installation and WordPress returns the styles even if you are logged off so you much have some .htaccess or PHP code redirecting the load-style.php file to the login form.

You have also removed a line of the core which tells the browser the PHP script is a CSS file, though I suspect Chrome would still parse it so long as the response was actually CSS, you should never do this and as such I would also recommend re-installing WordPress via Dashboard => Updates to get the core back to its correct state.

2
  • load-style.php might be missing some the lines but i think the is not what is causing the problem (because i added all the missing lines but still not showing style) .. as you mentioned it would be something else i cant find it :( . ( I have added the .htaccess file in the main question )
    – Arnab88
    Jul 5, 2020 at 11:22
  • It is load-styles.php redirecting to the login form HTML that is the reason your CMS is unstyled. It looks like it may be your wp-admin folder .htaccess as the following redirecting is the reason the login form is unstyled: csm.school/wp-admin/css/login.css - you can see it too redirects to the login form instead of serving the CSS.
    – Will Craig
    Jul 8, 2020 at 13:02
0

Probably some (cache) plugin does this in your admin

Add this in config.

define( 'CONCATENATE_SCRIPTS', false );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.