Make WordPress Core

Changeset 56160


Ignore:
Timestamp:
07/07/2023 07:27:53 AM (19 months ago)
Author:
isabel_brison
Message:

Editor: rename sync_status and move it to top level.

Renames sync_status to wp_pattern_sync_status and moves it to top level field of wp_block post type.

Props glendaviesnz, aaronrobertshaw, mukesh27, peterwilsoncc.
Fixes 58677.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r56120 r56160  
    80428042 * Registers any additional post meta fields.
    80438043 *
    8044  * @since 6.3.0 Adds sync_status meta field to the wp_block post type so an unsynced option can be added.
     8044 * @since 6.3.0 Adds `wp_pattern_sync_status` meta field to the wp_block post type so an unsynced option can be added.
    80458045 *
    80468046 * @link https://github.com/WordPress/gutenberg/pull/51144
     
    80498049    register_post_meta(
    80508050        'wp_block',
    8051         'sync_status',
     8051        'wp_pattern_sync_status',
    80528052        array(
    80538053            'sanitize_callback' => 'sanitize_text_field',
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php

    r56093 r56160  
    4141     *
    4242     * @since 5.0.0
     43     * @since 6.3 Adds the `wp_pattern_sync_status` postmeta property to the top level of response.
    4344     *
    4445     * @param array  $data    Response data to filter.
     
    5758        unset( $data['content']['rendered'] );
    5859
     60        // Add the core wp_pattern_sync_status meta as top level property to the response.
     61        $data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : '';
     62        unset( $data['meta']['wp_pattern_sync_status'] );
    5963        return $data;
    6064    }
  • trunk/tests/phpunit/tests/rest-api/rest-blocks-controller.php

    r55457 r56160  
    221221        );
    222222    }
     223
     224    /**
     225     * Check that the `wp_pattern_sync_status` postmeta is moved from meta array to top
     226     * level of response.
     227     *
     228     * @ticket 58677
     229     */
     230    public function test_wp_patterns_sync_status_post_meta() {
     231        register_post_meta(
     232            'wp_block',
     233            'wp_pattern_sync_status',
     234            array(
     235                'single'       => true,
     236                'type'         => 'string',
     237                'show_in_rest' => array(
     238                    'schema' => array(
     239                        'type'       => 'string',
     240                        'properties' => array(
     241                            'sync_status' => array(
     242                                'type' => 'string',
     243                            ),
     244                        ),
     245                    ),
     246                ),
     247            )
     248        );
     249        wp_set_current_user( self::$user_ids['author'] );
     250
     251        $request  = new WP_REST_Request( 'GET', '/wp/v2/blocks/' . self::$post_id );
     252        $response = rest_get_server()->dispatch( $request );
     253        $data     = $response->get_data();
     254
     255        $this->assertArrayHasKey( 'wp_pattern_sync_status', $data );
     256        $this->assertArrayNotHasKey( 'wp_pattern_sync_status', $data['meta'] );
     257    }
    223258}
Note: See TracChangeset for help on using the changeset viewer.