Code Monkey home page Code Monkey logo

Comments (2)

swissspidy avatar swissspidy commented on July 2, 2024

--skip-themes is a global argument in WP-CLI to skip loading the theme. However, the doctor check command deliberately forces WordPress to be loaded with a theme:

/**
* Runs through the entirety of the WP bootstrap process
*/
private function load_wordpress_with_template() {
global $wp_query;
WP_CLI::add_wp_hook(
'wp_redirect',
function ( $to ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
ob_start();
debug_print_backtrace();
$message = ob_get_clean();
throw new Exception( 'Incomplete check execution. Some code is trying to do a URL redirect. Backtrace:' . PHP_EOL . $message );
},
1
);
WP_CLI::get_runner()->load_wordpress();
// Set up the main WordPress query.
wp();
$interpreted = array();
foreach ( $wp_query as $key => $value ) {
if ( 0 === stripos( $key, 'is_' ) && $value ) {
$interpreted[] = $key;
}
}
WP_CLI::debug( 'Main WP_Query: ' . implode( ', ', $interpreted ), 'doctor' );
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- WordPress Core constant.
define( 'WP_USE_THEMES', true );
add_filter(
'template_include',
static function ( $template ) {
$display_template = str_replace( dirname( get_template_directory() ) . '/', '', $template );
WP_CLI::debug( "Theme template: {$display_template}", 'doctor' );
return $template;
},
999
);
// Template is normally loaded in global scope, so we need to replicate
foreach ( $GLOBALS as $key => $value ) {
global ${$key}; // phpcs:ignore PHPCompatibility.Variables.ForbiddenGlobalVariableVariable.NonBareVariableFound -- Syntax is updated to compatible with php 5 and 7.
}
// Load the theme template.
ob_start();
require_once ABSPATH . WPINC . '/template-loader.php';
ob_get_clean();
}

So the two are not really compatible.

While the command could be adapted to manually load the theme's functions.php in that case, it's probably much simpler to just document that it can't be used in combination with --skip-themes.

What's the reason you are using --skip-themes in this instance?

from doctor-command.

nostamp avatar nostamp commented on July 2, 2024

Thank you for the response. I was unaware of the compatibility issues. That --skip-themes flag ended up working its way into my notes as I run other commands with --skip-themes --skip-plugins when checking some core things.

Thank you kindly for the information. I will update my notes and discontinue the use.

from doctor-command.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.