Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (51 sloc) 2.14 KB
<?php
if(is_file('wp-login.php') && is_file('wp-admin/load-scripts.php') && is_file('wp-admin/load-styles.php') && is_file('wp-admin/includes/noop.php')) {
$wp_login_lines = explode("\n",file_get_contents('wp-login.php'));
$wp_login_is_ok = ($wp_login_lines[1] == "define('CONCATENATE_SCRIPTS', false);");
$load_styles_is_ok = strpos(file_get_contents('wp-admin/load-styles.php'),"require( ABSPATH . 'wp-admin/admin.php' );") !== false;
$load_scripts_is_ok = strpos(file_get_contents('wp-admin/load-scripts.php'),"require( ABSPATH . 'wp-admin/admin.php' );") !== false;
$noop_content = "<?php
/**
* Noop functions for load-scripts.php and load-styles.php.
*
* @package WordPress
* @subpackage Administration
* @since 4.4.0
*/
function get_file( \$path ) {
if ( function_exists('realpath') ) {
\$path = realpath( \$path );
}
if ( ! \$path || ! @is_file( \$path ) ) {
return '';
}
return @file_get_contents( \$path );
}
";
$noop_is_ok = file_get_contents('wp-admin/includes/noop.php') == $noop_content;
if($wp_login_is_ok) {
echo "wp-login.php ok\n<br>";
} else {
$wp_login_lines[0] = "<?php\ndefine('CONCATENATE_SCRIPTS', false);";
file_put_contents('wp-login.php',implode(PHP_EOL,$wp_login_lines));
echo "wp-login.php patched\n<br>";
}
if($load_styles_is_ok) {
echo "wp-admin/load-styles.php ok\n<br>";
} else {
file_put_contents('wp-admin/load-styles.php',str_replace("require( ABSPATH . WPINC . '/script-loader.php' );","require( ABSPATH . 'wp-admin/admin.php' );",file_get_contents('wp-admin/load-styles.php')));
echo "wp-admin/load-styles.php patched\n<br>";
}
if($load_scripts_is_ok) {
echo "wp-admin/load-scripts.php ok\n<br>";
} else {
file_put_contents('wp-admin/load-scripts.php',str_replace("require( ABSPATH . WPINC . '/script-loader.php' );","require( ABSPATH . 'wp-admin/admin.php' );",file_get_contents('wp-admin/load-scripts.php')));
echo "wp-admin/load-scripts.php patched\n<br>";
}
if($noop_is_ok) {
echo "wp-admin/includes/noop.php ok\n<br>";
} else {
file_put_contents('wp-admin/includes/noop.php',$noop_content);
echo "wp-admin/includes/noop.php patched\n<br>";
}
}