wc_prevent_dangerous_auto_updates()
Prevent auto-updating the WooCommerce plugin on major releases if there are untested extensions active.
Хуков нет.
Возвращает
true|false.
Использование
wc_prevent_dangerous_auto_updates( $should_update, $plugin );
- $should_update(true|false) (обязательный)
- If should update.
- $plugin(объект) (обязательный)
- Plugin data.
Список изменений
| С версии 3.2.0 | Введена. |
Код wc_prevent_dangerous_auto_updates() wc prevent dangerous auto updates WC 10.7.0
function wc_prevent_dangerous_auto_updates( $should_update, $plugin ) {
if ( ! isset( $plugin->plugin, $plugin->new_version ) ) {
return $should_update;
}
if ( 'woocommerce/woocommerce.php' !== $plugin->plugin ) {
return $should_update;
}
if ( ! class_exists( 'WC_Plugin_Updates' ) ) {
include_once __DIR__ . '/admin/plugin-updates/class-wc-plugin-updates.php';
}
$new_version = wc_clean( $plugin->new_version );
$plugin_updates = new WC_Plugin_Updates();
$version_type = Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' );
if ( ! is_string( $version_type ) ) {
$version_type = 'none';
}
$untested_plugins = $plugin_updates->get_untested_plugins( $new_version, $version_type );
if ( ! empty( $untested_plugins ) ) {
return false;
}
return $should_update;
}