Make WordPress Core


Ignore:
Timestamp:
05/29/2024 08:51:04 AM (6 months ago)
Author:
ellatrix
Message:

Options: Add 'label' argument to register_setting.

The 'label' will displayed to users when editing core or custom settings via block editors. It avoids hardcoding Settings labels and improves extensibility.

Backports https://github.com/WordPress/gutenberg/pull/59243.

Props mamaduka, timothyblynjacobs, ellatrix.

Fixes #61023.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php

    r55457 r58230  
    782782        $this->assertSame( 3, $response->data['mycustomsetting']['test3'] );
    783783    }
     784
     785    /**
     786     * @ticket 61023
     787     */
     788    public function test_provides_setting_metadata_in_schema() {
     789        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/settings' );
     790        $response = rest_get_server()->dispatch( $request );
     791        $data     = $response->get_data();
     792        $title    = $data['schema']['properties']['title'];
     793
     794        $this->assertSame( 'string', $title['type'] );
     795        $this->assertSame( 'Title', $title['title'] );
     796        $this->assertSame( 'Site title.', $title['description'] );
     797        $this->assertSame( null, $title['default'] );
     798    }
    784799}
Note: See TracChangeset for help on using the changeset viewer.