Don't show the notices if the dedicated extension is already active.
This commit is contained in:
parent
0533ad40af
commit
10d6366ff1
|
@ -130,7 +130,7 @@ class WC_Admin_Notices {
|
|||
* TODO: Change this method in WooCommerce 9.0 so that it checks if the Legacy REST API extension is installed, and if not, it points to the extension URL in the WordPress plugins directory.
|
||||
*/
|
||||
private static function maybe_add_legacy_api_removal_notice() {
|
||||
if ( 'yes' !== get_option( 'woocommerce_api_enabled' ) ) {
|
||||
if ( ! self::must_show_legacy_api_removal_notice() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,11 +158,22 @@ class WC_Admin_Notices {
|
|||
* TODO: Change this method in WooCommerce 9.0 so that the notice gets removed if the Legacy REST API extension is installed and active.
|
||||
*/
|
||||
private static function maybe_remove_legacy_api_removal_notice() {
|
||||
if ( 'yes' !== get_option( 'woocommerce_api_enabled' ) && self::has_notice( 'legacy_api_removed_in_woo_90' ) ) {
|
||||
if ( self::has_notice( 'legacy_api_removed_in_woo_90' ) && ! self::must_show_legacy_api_removal_notice() ) {
|
||||
self::remove_notice( 'legacy_api_removed_in_woo_90' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it needed to display the legacy API removal notice?
|
||||
*
|
||||
* TODO: Change or remove this method in WooCommerce 9.0 accordingly, depending on the changes to maybe_add/remove_legacy_api_removal_notice.
|
||||
*
|
||||
* @return bool True if the legacy API removal notice must be displayed.
|
||||
*/
|
||||
private static function must_show_legacy_api_removal_notice() {
|
||||
return 'yes' === get_option( 'woocommerce_api_enabled' ) && ! is_plugin_active( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' );
|
||||
}
|
||||
|
||||
// phpcs:enable Generic.Commenting.Todo.TaskFound
|
||||
|
||||
/**
|
||||
|
|
|
@ -383,6 +383,25 @@ class WC_Settings_Advanced extends WC_Settings_Page {
|
|||
* @return array
|
||||
*/
|
||||
protected function get_settings_for_legacy_api_section() {
|
||||
$enable_legacy_api_setting = array(
|
||||
'title' => __( 'Legacy API', 'woocommerce' ),
|
||||
'desc' => __( 'Enable the legacy REST API', 'woocommerce' ),
|
||||
'id' => 'woocommerce_api_enabled',
|
||||
'type' => 'checkbox',
|
||||
'default' => 'no',
|
||||
);
|
||||
|
||||
if ( ! is_plugin_active( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' ) ) {
|
||||
$enable_legacy_api_setting['desc_tip'] = sprintf(
|
||||
// translators: Placeholder is a URL.
|
||||
__(
|
||||
'⚠️ <b>️The Legacy REST API will be removed in WooCommerce 9.0.</b> A separate WooCommerce extension will soon be available to keep it enabled. <b><a target=”_blank” href="%s">Learn more about this change</a></b>',
|
||||
'woocommerce'
|
||||
),
|
||||
'https://developer.woocommerce.com/2023/10/03/the-legacy-rest-api-will-move-to-a-dedicated-extension-in-woocommerce-9-0/'
|
||||
);
|
||||
}
|
||||
|
||||
$settings =
|
||||
array(
|
||||
array(
|
||||
|
@ -391,21 +410,7 @@ class WC_Settings_Advanced extends WC_Settings_Page {
|
|||
'desc' => '',
|
||||
'id' => 'legacy_api_options',
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Legacy API', 'woocommerce' ),
|
||||
'desc' => __( 'Enable the legacy REST API', 'woocommerce' ),
|
||||
'id' => 'woocommerce_api_enabled',
|
||||
'type' => 'checkbox',
|
||||
'default' => 'no',
|
||||
'desc_tip' => sprintf(
|
||||
// translators: Placeholder is a URL.
|
||||
__(
|
||||
'⚠️ <b>️The Legacy REST API will be removed in WooCommerce 9.0.</b> A separate WooCommerce extension will soon be available to keep it enabled. <b><a target=”_blank” href="%s">Learn more about this change</a></b>',
|
||||
'woocommerce'
|
||||
),
|
||||
'https://developer.woocommerce.com/2023/10/03/the-legacy-rest-api-will-move-to-a-dedicated-extension-in-woocommerce-9-0/'
|
||||
),
|
||||
),
|
||||
$enable_legacy_api_setting,
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'legacy_api_options',
|
||||
|
|
Loading…
Reference in New Issue