Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/wp-includes/view-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function wp_get_entity_view_config_hook_name( $kind, $name ) {
* returns `false`.
*
* @since 7.1.0
* @since 7.2.0 Shows a placeholder for an empty excerpt and a missing author.
* @since 7.2.0 Shows a placeholder for an empty excerpt and a missing author,
* and summarizes the `date` panel with the `publish_date` field.
*
* @return array The default form configuration.
*/
Expand Down Expand Up @@ -95,7 +96,13 @@ function _wp_get_default_posttype_form() {
'sticky',
),
),
'date',
array(
'id' => 'date',
'layout' => array(
'type' => 'panel',
'summary' => 'publish_date',
),
),
'slug',
array(
'id' => 'author',
Expand Down
53 changes: 53 additions & 0 deletions tests/phpunit/tests/view-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,59 @@ public static function data_default_form_post_types() {
);
}

/**
* The `date` panel of the default form is summarized by the
* `publish_date` field, which reads "Immediately" while the post has no
* date of its own.
*
* @ticket 65981
*
* @covers ::_wp_get_default_posttype_form
*
* @dataProvider data_default_form_post_types
*
* @param string $post_type The post type.
*/
public function test_date_panel_is_summarized_by_publish_date( $post_type ) {
if ( ! post_type_exists( $post_type ) ) {
register_post_type( $post_type );
}

$config = wp_get_entity_view_config( 'postType', $post_type );

$this->assertSame(
array(
'type' => 'panel',
'summary' => 'publish_date',
),
$this->get_form_field( $config, 'date' )['layout']
);

if ( 'page' !== $post_type && 'post' !== $post_type ) {
unregister_post_type( $post_type );
}
}

/**
* Post types with their own form keep their `date` member, if any, as it
* is.
*
* @ticket 65981
*
* @dataProvider data_post_types_with_own_form
*
* @param string $post_type The post type.
*/
public function test_own_form_post_types_do_not_get_date_summary( $post_type ) {
$config = wp_get_entity_view_config( 'postType', $post_type );
$date = $this->get_form_field( $config, 'date' );

$this->assertFalse(
isset( $date['layout']['summary'] ),
"The `date` member of the $post_type form should not have a summary."
);
}

/**
* Post types with their own form do not receive the default form groups.
*
Expand Down
Loading