WP_CLI

Runner::set_wp_root()private staticWP-CLI 1.0

Set WordPress root as a given path.

Метод класса: Runner{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$result = Runner::set_wp_root( $path );
$path(строка) (обязательный)
-

Код Runner::set_wp_root() WP-CLI 2.8.0-alpha

private static function set_wp_root( $path ) {
	if ( ! defined( 'ABSPATH' ) ) {
		// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Declaring a WP native constant.
		define( 'ABSPATH', Utils\normalize_path( Utils\trailingslashit( $path ) ) );
	} elseif ( ! is_null( $path ) ) {
		WP_CLI::error_multi_line(
			[
				'The --path parameter cannot be used when ABSPATH is already defined elsewhere',
				'ABSPATH is defined as: "' . ABSPATH . '"',
			]
		);
	}
	WP_CLI::debug( 'ABSPATH defined: ' . ABSPATH, 'bootstrap' );

	$_SERVER['DOCUMENT_ROOT'] = realpath( $path );
}