Move site visibility settings to a new tab (#46140)

* Move site visibility settings to a new tab

* Add changefile(s) from automation for the following project(s): woocommerce

* Update tab id to site-visibility and link to it from the homescreen badge

* Fix tests

* Remove unused code

* Lower case tab title

* Remove general from the slotfill id

* Remove typo

* Lint fix

* Lint fix

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Moon 2024-04-04 14:28:58 -07:00 committed by GitHub
parent 674d7a01bf
commit def3ac920d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 87 additions and 36 deletions

View File

@ -205,7 +205,7 @@ const SiteVisibilitySlotFill = () => {
export const registerSiteVisibilitySlotFill = () => {
registerPlugin( 'woocommerce-admin-site-visibility-settings-slotfill', {
scope: 'woocommerce-settings',
scope: 'woocommerce-site-visibility-settings',
render: SiteVisibilitySlotFill,
} );
};

View File

@ -50,7 +50,7 @@ export const LaunchYourStoreStatus = ( { comingSoon, storePagesOnly } ) => {
<MenuGroup className="woocommerce-lys-status-popover">
<MenuItem
href={ getAdminLink(
'admin.php?page=wc-settings'
'admin.php?page=wc-settings&tab=site-visibility'
) }
>
<Icon icon={ cog } size={ 24 } />

View File

@ -19,8 +19,8 @@ export const possiblyRenderSettingsSlots = () => {
{ id: 'wc_tax_settings_slotfill', scope: 'woocommerce-tax-settings' },
{ id: 'wc_settings_slotfill', scope: 'woocommerce-settings' },
{
id: 'wc_settings_general_site_visibility_slotfill',
scope: 'woocommerce-settings',
id: 'wc_settings_site_visibility_slotfill',
scope: 'woocommerce-site-visibility-settings',
},
];

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Move site visibility settings to a new tab

View File

@ -57,6 +57,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
$settings[] = include __DIR__ . '/settings/class-wc-settings-accounts.php';
$settings[] = include __DIR__ . '/settings/class-wc-settings-emails.php';
$settings[] = include __DIR__ . '/settings/class-wc-settings-integrations.php';
$settings[] = include __DIR__ . '/settings/class-wc-settings-site-visibility.php';
$settings[] = include __DIR__ . '/settings/class-wc-settings-advanced.php';
self::$settings = apply_filters( 'woocommerce_get_settings_pages', $settings );

View File

@ -217,11 +217,6 @@ class WC_Settings_General extends WC_Settings_Page {
'id' => 'general_options',
),
array(
'id' => 'wc_settings_general_site_visibility_slotfill',
'type' => 'slotfill_placeholder',
),
array(
'title' => __( 'Currency options', 'woocommerce' ),
'type' => 'title',

View File

@ -0,0 +1,52 @@
<?php
/**
* WooCommerce site visibility settings
*
* @package WooCommerce\Admin
*/
defined( 'ABSPATH' ) || exit;
/**
* Settings for API.
*/
if ( class_exists( 'WC_Settings_Site_Visibility', false ) ) {
return new WC_Settings_Site_Visibility();
}
/**
* WC_Settings_Advanced.
*/
class WC_Settings_Site_Visibility extends WC_Settings_Page {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'site-visibility';
$this->label = __( 'Site visibility', 'woocommerce' );
parent::__construct();
}
/**
* Get settings for the default section.
*
* @return array
*/
protected function get_settings_for_default_section() {
$settings =
array(
array(
'id' => 'wc_settings_site_visibility_slotfill',
'type' => 'slotfill_placeholder',
),
);
return $settings;
}
}
return new WC_Settings_Site_Visibility();

View File

@ -12,7 +12,7 @@ class LaunchYourStore {
* Constructor.
*/
public function __construct() {
add_action( 'woocommerce_update_options_general', array( $this, 'save_site_visibility_options' ) );
add_action( 'woocommerce_update_options_site-visibility', array( $this, 'save_site_visibility_options' ) );
add_action( 'current_screen', array( $this, 'maybe_create_coming_soon_page' ) );
if ( is_admin() ) {
add_filter( 'woocommerce_admin_shared_settings', array( $this, 'preload_settings' ) );

View File

@ -22,7 +22,7 @@ class WC_Settings_General_Test extends WC_Settings_Unit_Test_Case {
add_filter(
'woocommerce_general_settings',
function( $settings ) use ( &$actual_settings_via_filter ) {
function ( $settings ) use ( &$actual_settings_via_filter ) {
$actual_settings_via_filter = $settings;
return $settings;
},
@ -48,29 +48,28 @@ class WC_Settings_General_Test extends WC_Settings_Unit_Test_Case {
$settings_ids_and_types = $this->get_ids_and_types( $settings );
$expected = array(
'woocommerce_store_address' => 'text',
'woocommerce_store_address_2' => 'text',
'woocommerce_store_city' => 'text',
'woocommerce_default_country' => 'single_select_country',
'woocommerce_store_postcode' => 'text',
'store_address' => array( 'title', 'sectionend' ),
'woocommerce_allowed_countries' => 'select',
'woocommerce_all_except_countries' => 'multi_select_countries',
'woocommerce_specific_allowed_countries' => 'multi_select_countries',
'woocommerce_ship_to_countries' => 'select',
'woocommerce_specific_ship_to_countries' => 'multi_select_countries',
'woocommerce_default_customer_address' => 'select',
'woocommerce_calc_taxes' => 'checkbox',
'woocommerce_enable_coupons' => 'checkbox',
'woocommerce_calc_discounts_sequentially' => 'checkbox',
'general_options' => array( 'title', 'sectionend' ),
'woocommerce_currency' => 'select',
'woocommerce_currency_pos' => 'select',
'woocommerce_price_thousand_sep' => 'text',
'woocommerce_price_decimal_sep' => 'text',
'woocommerce_price_num_decimals' => 'number',
'pricing_options' => array( 'title', 'sectionend' ),
'wc_settings_general_site_visibility_slotfill' => 'slotfill_placeholder',
'woocommerce_store_address' => 'text',
'woocommerce_store_address_2' => 'text',
'woocommerce_store_city' => 'text',
'woocommerce_default_country' => 'single_select_country',
'woocommerce_store_postcode' => 'text',
'store_address' => array( 'title', 'sectionend' ),
'woocommerce_allowed_countries' => 'select',
'woocommerce_all_except_countries' => 'multi_select_countries',
'woocommerce_specific_allowed_countries' => 'multi_select_countries',
'woocommerce_ship_to_countries' => 'select',
'woocommerce_specific_ship_to_countries' => 'multi_select_countries',
'woocommerce_default_customer_address' => 'select',
'woocommerce_calc_taxes' => 'checkbox',
'woocommerce_enable_coupons' => 'checkbox',
'woocommerce_calc_discounts_sequentially' => 'checkbox',
'general_options' => array( 'title', 'sectionend' ),
'woocommerce_currency' => 'select',
'woocommerce_currency_pos' => 'select',
'woocommerce_price_thousand_sep' => 'text',
'woocommerce_price_decimal_sep' => 'text',
'woocommerce_price_num_decimals' => 'number',
'pricing_options' => array( 'title', 'sectionend' ),
);
$this->assertEquals( $expected, $settings_ids_and_types );
@ -82,13 +81,13 @@ class WC_Settings_General_Test extends WC_Settings_Unit_Test_Case {
public function test_get_settings__currencies() {
FunctionsMockerHack::add_function_mocks(
array(
'get_woocommerce_currencies' => function() {
'get_woocommerce_currencies' => function () {
return array(
'c1' => 'Currency 1',
'c2' => 'Currency 2',
);
},
'get_woocommerce_currency_symbol' => function( $currency = '' ) {
'get_woocommerce_currency_symbol' => function ( $currency = '' ) {
return "symbol for $currency";
},
)