diff --git a/includes/api/class-wc-rest-settings-controller.php b/includes/api/class-wc-rest-settings-controller.php index 560bd125466..467912eb72a 100644 --- a/includes/api/class-wc-rest-settings-controller.php +++ b/includes/api/class-wc-rest-settings-controller.php @@ -29,6 +29,7 @@ class WC_Rest_Settings_Controller extends WC_REST_Controller { /** * Register routes. + * * @since 2.7.0 */ public function register_routes() { @@ -101,6 +102,7 @@ class WC_Rest_Settings_Controller extends WC_REST_Controller { /** * Prepare a report sales object for serialization. * + * @since 2.7.0 * @param array $item Group object. * @param WP_REST_Request $request Request object. * @return WP_REST_Response $response Response data. @@ -194,14 +196,14 @@ class WC_Rest_Settings_Controller extends WC_REST_Controller { ), ), 'label' => array( - 'description' => __( 'A human readable label. This is a translated string that can be used in interfaces.', 'woocommerce' ), + 'description' => __( 'A human readable translation wrapped label. Meant to be used in interfaces.', 'woocommerce' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ), 'description' => array( - 'description' => __( 'A human readable description. This is a translated string that can be used in interfaces.', 'woocommerce' ), + 'description' => __( 'A human readable translation wrapped description. Meant to be used in interfaces', 'woocommerce' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', diff --git a/includes/api/class-wc-rest-settings-options-controller.php b/includes/api/class-wc-rest-settings-options-controller.php index 5086d2107ae..1e3fe20d0b8 100644 --- a/includes/api/class-wc-rest-settings-options-controller.php +++ b/includes/api/class-wc-rest-settings-options-controller.php @@ -29,6 +29,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Register routes. + * * @since 2.7.0 */ public function register_routes() { @@ -69,6 +70,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Return a single setting. + * * @since 2.7.0 * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response @@ -87,6 +89,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Return all settings in a group. + * * @since 2.7.0 * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response @@ -112,19 +115,19 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Get all settings in a group. * + * @since 2.7.0 * @param string $group_id Group ID. - * * @return array|WP_Error */ public function get_group_settings( $group_id ) { if ( empty( $group_id ) ) { - return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); + return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) ); } $settings = apply_filters( 'woocommerce_settings-' . $group_id, array() ); if ( empty( $settings ) ) { - return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); + return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) ); } $filtered_settings = array(); @@ -143,9 +146,9 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Get setting data. * + * @since 2.7.0 * @param string $group_id Group ID. * @param string $setting_id Setting ID. - * * @return stdClass|WP_Error */ public function get_setting( $group_id, $setting_id ) { @@ -177,6 +180,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Bulk create, update and delete items. * + * @since 2.7.0 * @param WP_REST_Request $request Full details about the request. * @return array Of WP_Error or WP_REST_Response. */ @@ -202,6 +206,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Update a single setting in a group. + * @since 2.7.0 * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response @@ -226,6 +231,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Prepare a single setting object for response. * + * @since 2.7.0 * @param object $item Setting object. * @param WP_REST_Request $request Request object. * @return WP_REST_Response $response Response data. @@ -248,6 +254,7 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { /** * Prepare links for the request. * + * @since 2.7.0 * @param string $setting_id Setting ID. * @param string $group_id Group ID. * @return array Links for the given setting. @@ -366,14 +373,14 @@ class WC_Rest_Settings_Options_Controller extends WC_REST_Controller { ), ), 'label' => array( - 'description' => __( 'A human readable label. This is a translated string that can be used in interfaces.', 'woocommerce' ), + 'description' => __( 'A human readable translation wrapped label. Meant to be used in interfaces.', 'woocommerce' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ), 'description' => array( - 'description' => __( 'A human readable description. This is a translated string that can be used in interfaces.', 'woocommerce' ), + 'description' => __( 'A human readable translation wrapped description. Meant to be used in interfaces.', 'woocommerce' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', diff --git a/includes/class-wc-register-legacy-settings.php b/includes/class-wc-register-legacy-settings.php index eb32b02df35..a342c414947 100644 --- a/includes/class-wc-register-legacy-settings.php +++ b/includes/class-wc-register-legacy-settings.php @@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) { * * @version 2.7.0 * @since 2.7.0 - * @package WooCommerce/Classes + * @package WooCommerce/Classes * @category Class */ class WC_Register_Legacy_Settings { @@ -19,6 +19,7 @@ class WC_Register_Legacy_Settings { /** * Hooks into the settings API and starts registering our settings registered via legacy hooks/filters. + * * @since 2.7.0 */ public function __construct( $page ) { @@ -29,6 +30,7 @@ class WC_Register_Legacy_Settings { /** * Registers a setting group. + * * @since 2.7.0 * @param array $group * @return array @@ -43,6 +45,7 @@ class WC_Register_Legacy_Settings { /** * Registers the actual settings to the group they came from. + * * @since 2.7.0 * @param array $settings Existing registered settings * @return array @@ -67,10 +70,10 @@ class WC_Register_Legacy_Settings { /** * Convert a "legacy" setting (WC_Settings_Page::get_settings()) into the format expected - * for the REST API Settings Controller + * for the REST API Settings Controller. * + * @since 2.7.0 * @param $legacy_setting Settings array, as produced by a subclass of WC_Settings_Page. - * * @return array|bool Boolean false if legacy setting has no ID, Array of converted new setting otherwise. */ public function new_setting_from_legacy( $legacy_setting ) { diff --git a/tests/framework/helpers/class-wc-helper-settings.php b/tests/framework/helpers/class-wc-helper-settings.php index 2a042bc624b..93495166dee 100644 --- a/tests/framework/helpers/class-wc-helper-settings.php +++ b/tests/framework/helpers/class-wc-helper-settings.php @@ -9,6 +9,7 @@ class WC_Helper_Settings { /** * Hooks in some dummy data for testing the settings REST API. + * * @since 2.7.0 */ public static function register() { @@ -18,6 +19,7 @@ class WC_Helper_Settings { /** * Registers some example setting groups, including invalid ones that should not show up in JSON responses. + * * @since 2.7.0 * @param array $groups * @return array @@ -47,6 +49,7 @@ class WC_Helper_Settings { /** * Registers some example settings. + * * @since 2.7.0 * @param array $settings * @return array diff --git a/tests/unit-tests/api/settings.php b/tests/unit-tests/api/settings.php index f9cd9faaf95..0b64745685b 100644 --- a/tests/unit-tests/api/settings.php +++ b/tests/unit-tests/api/settings.php @@ -1,7 +1,8 @@ endpoint->get_setting( 'test', '' ); @@ -396,6 +411,8 @@ class Settings extends WC_Unit_Test_Case { /** * Tests the GET single setting route handler receiving an invalid setting ID. + * + * @since 2.7.0 */ public function test_get_setting_invalid_setting_id() { $result = $this->endpoint->get_setting( 'test', 'invalid' ); @@ -405,6 +422,8 @@ class Settings extends WC_Unit_Test_Case { /** * Tests the GET single setting route handler encountering an invalid setting type. + * + * @since 2.7.0 */ public function test_get_setting_invalid_setting_type() { $controller = $this->getMock( 'WC_Rest_Settings_Options_Controller', array( 'get_group_settings', 'is_setting_type_valid' ) ); @@ -426,6 +445,7 @@ class Settings extends WC_Unit_Test_Case { /** * Test updating a single setting without valid user permissions. + * * @since 2.7.0 */ public function test_update_setting_without_permission() { @@ -442,6 +462,7 @@ class Settings extends WC_Unit_Test_Case { /** * Test updating multiple settings without valid user permissions. + * * @since 2.7.0 */ public function test_update_settings_without_permission() { @@ -462,6 +483,7 @@ class Settings extends WC_Unit_Test_Case { /** * Test updating a bad setting ID. + * * @since 2.7.0 * @covers WC_Rest_Settings_Options_Controller::update_item */ @@ -478,6 +500,7 @@ class Settings extends WC_Unit_Test_Case { /** * Tests our classic setting registration to make sure settings added for WP-Admin are available over the API. + * * @since 2.7.0 */ public function test_classic_settings() { diff --git a/tests/unit-tests/settings/register-legacy-settings.php b/tests/unit-tests/settings/register-legacy-settings.php index 2fa41ce58c9..8f94342c174 100644 --- a/tests/unit-tests/settings/register-legacy-settings.php +++ b/tests/unit-tests/settings/register-legacy-settings.php @@ -2,6 +2,7 @@ /** * Settings API Tests + * * @package WooCommerce\Tests\Settings * @since 2.7.0 */ @@ -34,16 +35,18 @@ class WC_Tests_Register_Legacy_Settings extends WC_Unit_Test_Case { } /** + * @since 2.7.0 * @covers WC_Register_Legacy_Settings::__construct */ public function test_constructor() { $legacy_settings = new WC_Register_Legacy_Settings( $this->page ); - + $this->assertEquals( has_filter( 'woocommerce_settings_groups', array( $legacy_settings, 'register_legacy_group' ) ), 10 ); $this->assertEquals( has_filter( 'woocommerce_settings-' . $this->page->get_id(), array( $legacy_settings, 'register_legacy_settings' ) ), 10 ); } /** + * @since 2.7.0 * @covers WC_Register_Legacy_Settings::register_legacy_group */ public function test_register_legacy_group() { @@ -66,6 +69,9 @@ class WC_Tests_Register_Legacy_Settings extends WC_Unit_Test_Case { $this->assertEquals( $expected, $actual ); } + /** + * @since 2.7.0 + */ public function new_setting_from_legacy_provider() { return array( // No "id" case @@ -145,6 +151,7 @@ class WC_Tests_Register_Legacy_Settings extends WC_Unit_Test_Case { } /** + * @since 2.7.0 * @dataProvider new_setting_from_legacy_provider * @covers WC_Register_Legacy_Settings::new_setting_from_legacy */ @@ -157,6 +164,7 @@ class WC_Tests_Register_Legacy_Settings extends WC_Unit_Test_Case { } /** + * @since 2.7.0 * @covers WC_Register_Legacy_Settings::register_legacy_settings */ public function test_register_legacy_settings_one_section() { @@ -180,6 +188,7 @@ class WC_Tests_Register_Legacy_Settings extends WC_Unit_Test_Case { } /** + * @since 2.7.0 * @covers WC_Register_Legacy_Settings::register_legacy_settings */ public function test_register_legacy_settings() { @@ -227,4 +236,4 @@ class WC_Tests_Register_Legacy_Settings extends WC_Unit_Test_Case { $this->assertEquals( $expected, $actual ); } -} \ No newline at end of file +}