Automattic\WooCommerce\Database\Migrations\CustomOrderTable
CLIRunner::toggle_compat_mode
Toggles compatibility mode on or off.
Метод класса: CLIRunner{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->toggle_compat_mode( $enabled ): void;
- $enabled(true|false) (обязательный)
- TRUE to enable compatibility mode, FALSE to disable.
Список изменений
| С версии 9.1.0 | Введена. |
Код CLIRunner::toggle_compat_mode() CLIRunner::toggle compat mode WC 10.5.2
private function toggle_compat_mode( bool $enabled ): void {
if ( ! $this->synchronizer->check_orders_table_exists() ) {
if ( $enabled ) {
$this->synchronizer->create_database_tables();
} else {
WP_CLI::error( __( 'HPOS tables do not exist.', 'woocommerce' ) );
}
}
$currently_enabled = $this->synchronizer->data_sync_is_enabled();
if ( $currently_enabled === $enabled ) {
if ( $enabled ) {
WP_CLI::warning( __( 'Compatibility mode is already enabled.', 'woocommerce' ) );
} else {
WP_CLI::warning( __( 'Compatibility mode is already disabled.', 'woocommerce' ) );
}
return;
}
update_option( $this->synchronizer::ORDERS_DATA_SYNC_ENABLED_OPTION, wc_bool_to_string( $enabled ) );
if ( $enabled ) {
WP_CLI::success( __( 'Compatibility mode enabled.', 'woocommerce' ) );
} else {
WP_CLI::success( __( 'Compatibility mode disabled.', 'woocommerce' ) );
}
}