Skip to content

Commit 8a468d2

Browse files
committed
Merge branch 'trunk' into trac-64238-script-modules
2 parents fe08d73 + 73dada3 commit 8a468d2

File tree

7 files changed

+53
-14
lines changed

7 files changed

+53
-14
lines changed

src/wp-admin/includes/class-wp-debug-data.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,11 @@ private static function get_wp_constants(): array {
15921592
'value' => $db_collate,
15931593
'debug' => $db_collate_debug,
15941594
),
1595+
'EMPTY_TRASH_DAYS' => array(
1596+
'label' => 'EMPTY_TRASH_DAYS',
1597+
'value' => EMPTY_TRASH_DAYS ? EMPTY_TRASH_DAYS : __( 'Empty value' ),
1598+
'debug' => EMPTY_TRASH_DAYS,
1599+
),
15951600
);
15961601

15971602
return array(

src/wp-admin/includes/post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
764764
if ( $create_in_db ) {
765765
$post_id = wp_insert_post(
766766
array(
767-
'post_title' => __( 'Auto Draft' ),
767+
'post_title' => post_type_supports( $post_type, 'title' ) ? __( 'Auto Draft' ) : '',
768768
'post_type' => $post_type,
769769
'post_status' => 'auto-draft',
770770
),

src/wp-includes/class-wp-dependencies.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ class WP_Dependencies {
5656
/**
5757
* An array of additional arguments passed when a handle is registered.
5858
*
59-
* Arguments are appended to the item query string.
59+
* The keys are dependency handles and the values are query strings which are appended to the item URL's query
60+
* string, after the `ver` if provided.
6061
*
6162
* @since 2.6.0
6263
*
63-
* @var array
64+
* @var array<string, string>
6465
*/
6566
public $args = array();
6667

@@ -100,7 +101,7 @@ class WP_Dependencies {
100101
*
101102
* @since 5.9.0
102103
*
103-
* @var array
104+
* @var array<string, string|null>
104105
*/
105106
private $queued_before_register = array();
106107

src/wp-includes/class-wp-dependency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _WP_Dependency {
6666
* Extra data to supply to the handle.
6767
*
6868
* @since 2.6.0
69-
* @var array
69+
* @var array<string, mixed>
7070
*/
7171
public $extra = array();
7272

@@ -82,7 +82,7 @@ class _WP_Dependency {
8282
* Translation path set for this dependency.
8383
*
8484
* @since 5.0.0
85-
* @var string
85+
* @var string|null
8686
*/
8787
public $translations_path;
8888

src/wp-includes/class-wp-scripts.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class WP_Scripts extends WP_Dependencies {
4646
* Holds handles of scripts which are enqueued in footer.
4747
*
4848
* @since 2.8.0
49-
* @var array
49+
* @var string[]
5050
*/
5151
public $in_footer = array();
5252

@@ -118,7 +118,7 @@ class WP_Scripts extends WP_Dependencies {
118118
* List of default directories.
119119
*
120120
* @since 2.8.0
121-
* @var array
121+
* @var string[]|null
122122
*/
123123
public $default_dirs;
124124

@@ -374,7 +374,8 @@ public function do_item( $handle, $group = false ) {
374374
$filtered_src = apply_filters( 'script_loader_src', $src, $handle );
375375

376376
if (
377-
$this->in_default_dir( $filtered_src )
377+
is_string( $filtered_src )
378+
&& $this->in_default_dir( $filtered_src )
378379
&& ( $before_script || $after_script || $translations_stop_concat || $this->is_delayed_strategy( $strategy ) )
379380
) {
380381
$this->do_concat = false;
@@ -589,9 +590,9 @@ public function get_inline_script_tag( $handle, $position = 'after' ) {
589590
*
590591
* @since 2.1.0
591592
*
592-
* @param string $handle Name of the script to attach data to.
593-
* @param string $object_name Name of the variable that will contain the data.
594-
* @param array $l10n Array of data to localize.
593+
* @param string $handle Name of the script to attach data to.
594+
* @param string $object_name Name of the variable that will contain the data.
595+
* @param array<string, mixed> $l10n Array of data to localize.
595596
* @return bool True on success, false on failure.
596597
*/
597598
public function localize( $handle, $object_name, $l10n ) {

src/wp-includes/class-wp-styles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class WP_Styles extends WP_Dependencies {
9696
* List of default directories.
9797
*
9898
* @since 2.8.0
99-
* @var array
99+
* @var string[]|null
100100
*/
101101
public $default_dirs;
102102

@@ -183,7 +183,7 @@ public function do_item( $handle, $group = false ) {
183183
}
184184

185185
if ( $this->do_concat ) {
186-
if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
186+
if ( is_string( $src ) && $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
187187
$this->concat .= "$handle,";
188188
$this->concat_version .= "$handle$ver";
189189

tests/phpunit/tests/admin/includesPost.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,38 @@ public function test_get_default_post_to_edit_with_wp_insert_post_error() {
548548
get_default_post_to_edit( 'post', true );
549549
}
550550

551+
/**
552+
* Tests that default post title is present when a CPT has title support, and is empty otherwise.
553+
*
554+
* @ticket 45516
555+
*
556+
* @covers ::get_default_post_to_edit
557+
*/
558+
public function test_get_default_post_to_edit_with_and_without_title_support() {
559+
register_post_type(
560+
'yes_title',
561+
array(
562+
'supports' => array( 'title', 'editor' ),
563+
)
564+
);
565+
register_post_type(
566+
'no_title',
567+
array(
568+
'supports' => array( 'editor' ),
569+
)
570+
);
571+
572+
/*
573+
* The ID is obtained because get_default_post_to_edit() will force the post_title
574+
* to be overridden on the returned WP_Post object.
575+
*/
576+
$default_yes_title_post_id = get_default_post_to_edit( 'yes_title', true )->ID;
577+
$default_no_title_post_id = get_default_post_to_edit( 'no_title', true )->ID;
578+
579+
$this->assertSame( __( 'Auto Draft' ), get_post( $default_yes_title_post_id )->post_title, 'Expected post_title to be the default title.' );
580+
$this->assertSame( '', get_post( $default_no_title_post_id )->post_title, 'Expected post_title to be an empty string.' );
581+
}
582+
551583
/**
552584
* @ticket 38293
553585
*/

0 commit comments

Comments
 (0)