Changeset 55992
- Timestamp:
- 06/23/2023 06:27:45 AM (15 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template-utils.php
r55881 r55992 543 543 * 544 544 * @since 5.9.0 545 * @since 6.3.0 Added `modified` property to template objects. 545 546 * @access private 546 547 * … … 565 566 $template->has_theme_file = true; 566 567 $template->is_custom = true; 568 $template->modified = null; 567 569 568 570 if ( 'wp_template' === $template_type && isset( $default_template_types[ $template_file['slug'] ] ) ) { … … 744 746 * 745 747 * @since 5.9.0 748 * @since 6.3.0 Added `modified` property to template objects. 746 749 * @access private 747 750 * … … 783 786 $template->is_custom = empty( $is_wp_suggestion ); 784 787 $template->author = $post->post_author; 788 $template->modified = $post->post_modified; 785 789 786 790 if ( 'wp_template' === $post->post_type && $has_theme_file && isset( $template_file['postTypes'] ) ) { -
trunk/src/wp-includes/class-wp-block-template.php
r55693 r55992 147 147 */ 148 148 public $area; 149 150 /** 151 * Modified. 152 * 153 * @since 6.3.0 154 * @var string|null 155 */ 156 public $modified; 149 157 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
r55294 r55992 615 615 * @since 5.8.0 616 616 * @since 5.9.0 Renamed `$template` to `$item` to match parent class for PHP 8 named parameter support. 617 * @since 6.3.0 Added `modified` property to the response. 617 618 * 618 619 * @param WP_Block_Template $item Template instance. … … 707 708 if ( rest_is_field_included( 'area', $fields ) && 'wp_template_part' === $template->type ) { 708 709 $data['area'] = $template->area; 710 } 711 712 if ( rest_is_field_included( 'modified', $fields ) ) { 713 $data['modified'] = mysql_to_rfc3339( $template->modified ); 709 714 } 710 715 … … 927 932 'context' => array( 'view', 'edit', 'embed' ), 928 933 ), 934 'modified' => array( 935 'description' => __( "The date the template was last modified, in the site's timezone." ), 936 'type' => 'string', 937 'format' => 'date-time', 938 'context' => array( 'view', 'edit' ), 939 'readonly' => true, 940 ), 929 941 ), 930 942 ); -
trunk/tests/phpunit/tests/block-template-utils.php
r55500 r55992 102 102 $this->assertSame( 'Description of my template', $template->description ); 103 103 $this->assertSame( 'wp_template', $template->type ); 104 $this->assertSame( self::$template_post->post_modified, $template->modified ); 104 105 105 106 // Test template parts. … … 118 119 $this->assertSame( 'wp_template_part', $template_part->type ); 119 120 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 121 $this->assertSame( self::$template_part_post->post_modified, $template->modified ); 120 122 } 121 123 … … 137 139 $this->assertSame( 'Displays single posts on your website unless a custom template has been applied to that post or a dedicated template exists.', $template->description ); 138 140 $this->assertSame( 'wp_template', $template->type ); 141 $this->assertEmpty( $template->modified ); 139 142 140 143 // Test template parts. … … 156 159 $this->assertSame( 'wp_template_part', $template_part->type ); 157 160 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 161 $this->assertEmpty( $template_part->modified ); 158 162 } 159 163 -
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r55562 r55992 119 119 'is_custom' => true, 120 120 'author' => 0, 121 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 121 122 ), 122 123 $this->find_and_normalize_template_by_id( $data, 'default//my_template' ) … … 163 164 'is_custom' => true, 164 165 'author' => 0, 166 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 165 167 ), 166 168 $data … … 199 201 'is_custom' => true, 200 202 'author' => 0, 203 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 201 204 ), 202 205 $data … … 258 261 'is_custom' => true, 259 262 'author' => self::$admin_id, 263 'modified' => mysql_to_rfc3339( $post->post_modified ), 260 264 ), 261 265 $data … … 414 418 $response = rest_get_server()->dispatch( $request ); 415 419 $data = $response->get_data(); 420 $modified = get_post( $data['wp_id'] )->post_modified; 416 421 unset( $data['_links'] ); 417 422 unset( $data['wp_id'] ); … … 437 442 'is_custom' => true, 438 443 'author' => self::$admin_id, 444 'modified' => mysql_to_rfc3339( $modified ), 439 445 ), 440 446 $data … … 460 466 $response = rest_get_server()->dispatch( $request ); 461 467 $data = $response->get_data(); 468 $modified = get_post( $data['wp_id'] )->post_modified; 462 469 unset( $data['_links'] ); 463 470 unset( $data['wp_id'] ); … … 483 490 'is_custom' => false, 484 491 'author' => self::$admin_id, 492 'modified' => mysql_to_rfc3339( $modified ), 485 493 ), 486 494 $data … … 510 518 $response = rest_get_server()->dispatch( $request ); 511 519 $data = $response->get_data(); 520 $modified = get_post( $data['wp_id'] )->post_modified; 512 521 unset( $data['_links'] ); 513 522 unset( $data['wp_id'] ); … … 533 542 'is_custom' => true, 534 543 'author' => self::$admin_id, 544 'modified' => mysql_to_rfc3339( $modified ), 535 545 ), 536 546 $data … … 691 701 $data = $response->get_data(); 692 702 $properties = $data['schema']['properties']; 693 $this->assertCount( 1 4, $properties );703 $this->assertCount( 15, $properties ); 694 704 $this->assertArrayHasKey( 'id', $properties ); 695 705 $this->assertArrayHasKey( 'description', $properties ); … … 707 717 $this->assertArrayHasKey( 'is_custom', $properties ); 708 718 $this->assertArrayHasKey( 'author', $properties ); 719 $this->assertArrayHasKey( 'modified', $properties ); 709 720 } 710 721 … … 737 748 $request = new WP_REST_Request( 'POST', '/wp/v2/templates' ); 738 749 $request->set_body_params( $body_params ); 739 $response = rest_get_server()->dispatch( $request ); 740 $data = $response->get_data(); 750 $response = rest_get_server()->dispatch( $request ); 751 $data = $response->get_data(); 752 $modified = get_post( $data['wp_id'] )->post_modified; 753 $expected['modified'] = mysql_to_rfc3339( $modified ); 741 754 unset( $data['_links'] ); 742 755 unset( $data['wp_id'] );
Note: See TracChangeset
for help on using the changeset viewer.