Make WordPress Core


Ignore:
Timestamp:
11/30/2021 12:22:30 AM (3 years ago)
Author:
noisysocks
Message:

Update @wordpress packages

Update packages to include these bug fixes from Gutenberg:

  • Update Pattern block category and add documentation
  • Fix non existent menu handling in nav block
  • Make Reusable blocks available in the Site Editor
  • Add caching to WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_custom_post_type()
  • theme.json: add appearanceTools flag to opt-in into appearance UI controls
  • Update the block theme folders to templates and parts
  • Remove reference to gutenberg_, swap with wp_
  • Use table layout in templates list screen
  • Update featured image placeholder graphic.
  • [Inserter]: Adjust order of theme blocks and reorder inserter items
  • Implement suitable fallback for Nav block on front end of site when no menu selected
  • Toggle Group Control: add tooltip
  • Use first non-empty Nav post as primary fallback for Nav block
  • Change .nvmrc and documentation for Node.js version (LTS to 14.18.1)
  • Update: Migrate global styles user database data on the rest endpoint
  • Update global styles public API
  • Update: Rename user preset origin to custom
  • Try always generating navigation post title
  • Show all templates and template parts on the site editor list screens
  • Highlight "Site" in the navigation panel
  • Fix template part slug generation when creating through the block placeholder
  • [Block Library - Post Title]: Fix render error when setting Page to homepage
  • Add 'Clear customizations' button to template list page
  • Gallery v1: Allow clicks within replace media placeholder state
  • Site Editor: Set the <title> on the list page to be same as the CPT name
  • Gallery: Fix stuck image size options loader
  • Cover: Fix undo trap
  • Add success and error snackbars to the templates list page
  • Fix: theme colors cannot override defaults
  • Fix: Color palette is not being stored
  • Add elements support to the typography panel in global styles
  • Make links plural in global styles
  • Add: Gradient palette editor
  • Update some small style regressions in the template list
  • Add: Transparency support on global styles colors
  • Fix: apply by slug on all origins
  • Render empty Nav block if no fallback block can be utilised
  • Allow filtering of Nav block fallback
  • Fix Nav block fallback DB query to match on full block grammar start tag
  • Remove unstable max pages attribute from Nav block
  • DateTimePicker: set PM hours correctly
  • Update delete template button
  • Site Editor: Template list add rename action
  • Fix Nav block editing wrong entity on creation of new Menu
  • [REST] Restore the missing double slash in the ID received by /templates
  • Add icons to navigation sidebar items
  • Update function names for the public global styles API functions
  • Templates Controller: Add missing 'is_custom' prop
  • Rename gutenberg_ to wp_ for some functions that land in WordPress 5.9
  • [Block Library - Template Part]:Remove support for conversion to Reusable block
  • Global Styles: Call "palettes" and not "color palettes" on panel label
  • Add button text when no colors found
  • Update: Global Styes: Count all color palette origins on the palette counter
  • Rename navigationMenuId to ref
  • Offset the parent iframe when computing Popover position
  • Fix: Failing PHPUnit test
  • Show theme, plugin or author in Added By column with appropriate icon or avatar
  • Add origin and author to template rest api

See #54487.
Props talldanwp, mamaduka, oandregal.

File:
1 edited

Legend:

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

    r52186 r52275  
    5454    }
    5555
    56 
    5756    public function test_register_routes() {
    5857        $routes = rest_get_server()->get_routes();
     
    9493                'slug'           => 'my_template',
    9594                'source'         => 'custom',
     95                'origin'         => null,
    9696                'type'           => 'wp_template',
    9797                'description'    => 'Description of my template.',
     
    103103                'wp_id'          => self::$post->ID,
    104104                'has_theme_file' => false,
     105                'is_custom'      => true,
     106                'author'         => 0,
    105107            ),
    106108            $this->find_and_normalize_template_by_id( $data, 'default//my_template' )
     
    135137                'slug'           => 'my_template',
    136138                'source'         => 'custom',
     139                'origin'         => null,
    137140                'type'           => 'wp_template',
    138141                'description'    => 'Description of my template.',
     
    144147                'wp_id'          => self::$post->ID,
    145148                'has_theme_file' => false,
     149                'is_custom'      => true,
     150                'author'         => 0,
    146151            ),
    147152            $data
     153        );
     154    }
     155
     156    /**
     157     * @ticket 54507
     158     * @dataProvider get_template_endpoint_urls
     159     */
     160    public function test_get_item_works_with_a_single_slash( $endpoint_url ) {
     161        wp_set_current_user( self::$admin_id );
     162        $request  = new WP_REST_Request( 'GET', $endpoint_url );
     163        $response = rest_get_server()->dispatch( $request );
     164
     165        $data = $response->get_data();
     166        unset( $data['content'] );
     167        unset( $data['_links'] );
     168
     169        $this->assertSame(
     170            array(
     171                'id'             => 'default//my_template',
     172                'theme'          => 'default',
     173                'slug'           => 'my_template',
     174                'source'         => 'custom',
     175                'origin'         => null,
     176                'type'           => 'wp_template',
     177                'description'    => 'Description of my template.',
     178                'title'          => array(
     179                    'raw'      => 'My Template',
     180                    'rendered' => 'My Template',
     181                ),
     182                'status'         => 'publish',
     183                'wp_id'          => self::$post->ID,
     184                'has_theme_file' => false,
     185                'is_custom'      => true,
     186                'author'         => 0,
     187            ),
     188            $data
     189        );
     190    }
     191
     192    public function get_template_endpoint_urls() {
     193        return array(
     194            array( '/wp/v2/templates/default/my_template' ),
     195            array( '/wp/v2/templates/default//my_template' ),
     196        );
     197    }
     198
     199    /**
     200     * @ticket 54507
     201     * @dataProvider get_template_ids_to_sanitize
     202     */
     203    public function test_sanitize_template_id( $input_id, $sanitized_id ) {
     204        $endpoint = new WP_REST_Templates_Controller( 'wp_template' );
     205        $this->assertEquals(
     206            $sanitized_id,
     207            $endpoint->_sanitize_template_id( $input_id )
     208        );
     209    }
     210
     211    public function get_template_ids_to_sanitize() {
     212        return array(
     213            array( 'tt1-blocks/index', 'tt1-blocks//index' ),
     214            array( 'tt1-blocks//index', 'tt1-blocks//index' ),
     215
     216            array( 'theme-experiments/tt1-blocks/index', 'theme-experiments/tt1-blocks//index' ),
     217            array( 'theme-experiments/tt1-blocks//index', 'theme-experiments/tt1-blocks//index' ),
    148218        );
    149219    }
     
    162232                'title'       => 'My Template',
    163233                'content'     => 'Content',
     234                'author'      => self::$admin_id,
    164235            )
    165236        );
     
    178249                'slug'           => 'my_custom_template',
    179250                'source'         => 'custom',
     251                'origin'         => null,
    180252                'type'           => 'wp_template',
    181253                'description'    => 'Just a description',
     
    186258                'status'         => 'publish',
    187259                'has_theme_file' => false,
     260                'is_custom'      => true,
     261                'author'         => self::$admin_id,
    188262            ),
    189263            $data
     
    208282                    'raw' => 'Content',
    209283                ),
     284                'author'      => self::$admin_id,
    210285            )
    211286        );
     
    224299                'slug'           => 'my_custom_template_raw',
    225300                'source'         => 'custom',
     301                'origin'         => null,
    226302                'type'           => 'wp_template',
    227303                'description'    => 'Just a description',
     
    232308                'status'         => 'publish',
    233309                'has_theme_file' => false,
     310                'is_custom'      => true,
     311                'author'         => self::$admin_id,
    234312            ),
    235313            $data
    236314        );
     315    }
     316
     317    public function test_create_item_invalid_author() {
     318        wp_set_current_user( self::$admin_id );
     319        $request = new WP_REST_Request( 'POST', '/wp/v2/templates' );
     320        $request->set_body_params(
     321            array(
     322                'slug'        => 'my_custom_template_invalid_author',
     323                'description' => 'Just a description',
     324                'title'       => 'My Template',
     325                'content'     => 'Content',
     326                'author'      => -1,
     327            )
     328        );
     329        $response = rest_get_server()->dispatch( $request );
     330        $this->assertErrorResponse( 'rest_invalid_author', $response, 400 );
    237331    }
    238332
     
    371465        $data       = $response->get_data();
    372466        $properties = $data['schema']['properties'];
    373         $this->assertCount( 11, $properties );
     467        $this->assertCount( 14, $properties );
    374468        $this->assertArrayHasKey( 'id', $properties );
    375469        $this->assertArrayHasKey( 'description', $properties );
     
    378472        $this->assertArrayHasKey( 'type', $properties );
    379473        $this->assertArrayHasKey( 'source', $properties );
     474        $this->assertArrayHasKey( 'origin', $properties );
    380475        $this->assertArrayHasKey( 'content', $properties );
    381476        $this->assertArrayHasKey( 'title', $properties );
     
    384479        $this->assertArrayHasKey( 'wp_id', $properties );
    385480        $this->assertArrayHasKey( 'has_theme_file', $properties );
     481        $this->assertArrayHasKey( 'is_custom', $properties );
     482        $this->assertArrayHasKey( 'author', $properties );
    386483    }
    387484
Note: See TracChangeset for help on using the changeset viewer.