Skip to content

Commit 0de8a8d

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents f23d38a + 1a1ac10 commit 0de8a8d

6 files changed

Lines changed: 301 additions & 32 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ final class WP_Comment {
2222
*
2323
* @since 4.4.0
2424
* @var string
25+
* @phpstan-var numeric-string
2526
*/
2627
public $comment_ID;
2728

@@ -32,6 +33,7 @@ final class WP_Comment {
3233
*
3334
* @since 4.4.0
3435
* @var string
36+
* @phpstan-var numeric-string
3537
*/
3638
public $comment_post_ID = '0';
3739

@@ -98,6 +100,7 @@ final class WP_Comment {
98100
*
99101
* @since 4.4.0
100102
* @var string
103+
* @phpstan-var numeric-string
101104
*/
102105
public $comment_karma = '0';
103106

@@ -133,6 +136,7 @@ final class WP_Comment {
133136
*
134137
* @since 4.4.0
135138
* @var string
139+
* @phpstan-var numeric-string
136140
*/
137141
public $comment_parent = '0';
138142

@@ -143,6 +147,7 @@ final class WP_Comment {
143147
*
144148
* @since 4.4.0
145149
* @var string
150+
* @phpstan-var numeric-string
146151
*/
147152
public $user_id = '0';
148153

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*
1919
* @since 4.4.0
2020
*
21-
* @property int $id
22-
* @property int $site_id
21+
* @property int $id
22+
* @property string $blog_id
23+
* @property int $site_id
24+
*
25+
* @phpstan-property numeric-string $blog_id
2326
*/
2427
#[AllowDynamicProperties]
2528
class WP_Network {
@@ -61,6 +64,7 @@ class WP_Network {
6164
*
6265
* @since 4.4.0
6366
* @var string
67+
* @phpstan-var numeric-string
6468
*/
6569
private $blog_id = '0';
6670

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
*
1616
* @since 4.5.0
1717
*
18-
* @property int $id
19-
* @property int $network_id
20-
* @property string $blogname
21-
* @property string $siteurl
22-
* @property int $post_count
23-
* @property string $home
18+
* @property int $id
19+
* @property int $network_id
20+
* @property string $blogname
21+
* @property string $siteurl
22+
* @property int|string|false $post_count
23+
* @property string $home
24+
*
25+
* @phpstan-property int|numeric-string|false $post_count
2426
*/
2527
#[AllowDynamicProperties]
2628
final class WP_Site {
@@ -34,6 +36,7 @@ final class WP_Site {
3436
*
3537
* @since 4.5.0
3638
* @var string
39+
* @phpstan-var numeric-string
3740
*/
3841
public $blog_id;
3942

@@ -63,6 +66,7 @@ final class WP_Site {
6366
*
6467
* @since 4.5.0
6568
* @var string
69+
* @phpstan-var numeric-string
6670
*/
6771
public $site_id = '0';
6872

@@ -89,6 +93,7 @@ final class WP_Site {
8993
*
9094
* @since 4.5.0
9195
* @var string
96+
* @phpstan-var numeric-string
9297
*/
9398
public $public = '1';
9499

@@ -99,6 +104,7 @@ final class WP_Site {
99104
*
100105
* @since 4.5.0
101106
* @var string
107+
* @phpstan-var numeric-string
102108
*/
103109
public $archived = '0';
104110

@@ -112,6 +118,7 @@ final class WP_Site {
112118
*
113119
* @since 4.5.0
114120
* @var string
121+
* @phpstan-var numeric-string
115122
*/
116123
public $mature = '0';
117124

@@ -122,6 +129,7 @@ final class WP_Site {
122129
*
123130
* @since 4.5.0
124131
* @var string
132+
* @phpstan-var numeric-string
125133
*/
126134
public $spam = '0';
127135

@@ -132,6 +140,7 @@ final class WP_Site {
132140
*
133141
* @since 4.5.0
134142
* @var string
143+
* @phpstan-var numeric-string
135144
*/
136145
public $deleted = '0';
137146

@@ -142,6 +151,7 @@ final class WP_Site {
142151
*
143152
* @since 4.5.0
144153
* @var string
154+
* @phpstan-var numeric-string
145155
*/
146156
public $lang_id = '0';
147157

src/wp-includes/class-wp-theme-json.php

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,30 @@ class WP_Theme_JSON {
641641
* @var array
642642
*/
643643
const VALID_BLOCK_PSEUDO_SELECTORS = array(
644-
'core/button' => array( ':hover', ':focus', ':focus-visible', ':active' ),
644+
'core/button' => array( ':hover', ':focus', ':focus-visible', ':active' ),
645+
'core/navigation-link' => array( ':hover', ':focus', ':focus-visible', ':active' ),
646+
);
647+
648+
/**
649+
* Custom states for blocks that map to CSS class selectors rather than
650+
* CSS pseudo-selectors. Values use the '-' prefix (e.g. '-current') to
651+
* distinguish them from real CSS pseudo-selectors and breakpoint states.
652+
*
653+
* The CSS selector for each state is defined in the block's block.json
654+
* under `selectors.states`, e.g.:
655+
*
656+
* "selectors": { "states": { "-current": ".some-css-selector" } }
657+
*
658+
* This constant controls which states are valid in theme.json for a given
659+
* block. Blocks listed here also inherit their VALID_BLOCK_PSEUDO_SELECTORS
660+
* as valid sub-states, producing compound selectors such as
661+
* `.wp-block-navigation-item.current-menu-item:hover`.
662+
*
663+
* @since 7.1.0
664+
* @var array
665+
*/
666+
const VALID_BLOCK_CUSTOM_STATES = array(
667+
'core/navigation-link' => array( '-current' ),
645668
);
646669

647670
/**
@@ -1157,6 +1180,23 @@ protected static function sanitize( $input, $valid_block_names, $valid_element_n
11571180
$schema_styles_blocks[ $block ][ $pseudo_selector ] = $styles_non_top_level;
11581181
}
11591182
}
1183+
1184+
// Add custom states for blocks that support them (e.g. '-current' for navigation).
1185+
if ( isset( static::VALID_BLOCK_CUSTOM_STATES[ $block ] ) ) {
1186+
foreach ( static::VALID_BLOCK_CUSTOM_STATES[ $block ] as $custom_state ) {
1187+
$custom_state_schema = $styles_non_top_level;
1188+
/*
1189+
* The same pseudo-selectors valid for the block at the top level
1190+
* are also valid within each custom state.
1191+
*/
1192+
if ( isset( static::VALID_BLOCK_PSEUDO_SELECTORS[ $block ] ) ) {
1193+
foreach ( static::VALID_BLOCK_PSEUDO_SELECTORS[ $block ] as $pseudo ) {
1194+
$custom_state_schema[ $pseudo ] = $styles_non_top_level;
1195+
}
1196+
}
1197+
$schema_styles_blocks[ $block ][ $custom_state ] = $custom_state_schema;
1198+
}
1199+
}
11601200
}
11611201

11621202
$block_style_variation_styles = static::VALID_STYLES;
@@ -1556,6 +1596,11 @@ protected static function get_blocks_metadata() {
15561596
if ( ! empty( $style_selectors ) ) {
15571597
static::$blocks_metadata[ $block_name ]['styleVariations'] = $style_selectors;
15581598
}
1599+
1600+
// If the block has custom states defined in block.json, store their selectors.
1601+
if ( ! empty( $block_type->selectors['states'] ) && is_array( $block_type->selectors['states'] ) ) {
1602+
static::$blocks_metadata[ $block_name ]['states'] = $block_type->selectors['states'];
1603+
}
15591604
}
15601605

15611606
return static::$blocks_metadata;
@@ -3218,6 +3263,47 @@ private static function get_block_nodes( $theme_json, $selectors = array(), $opt
32183263
}
32193264
}
32203265
}
3266+
3267+
// Handle custom states (e.g. '-current' for navigation).
3268+
if ( isset( static::VALID_BLOCK_CUSTOM_STATES[ $name ] ) ) {
3269+
foreach ( static::VALID_BLOCK_CUSTOM_STATES[ $name ] as $custom_state ) {
3270+
if (
3271+
isset( $theme_json['styles']['blocks'][ $name ][ $custom_state ] ) &&
3272+
isset( $selectors[ $name ]['states'][ $custom_state ] )
3273+
) {
3274+
$custom_css_selector = $selectors[ $name ]['states'][ $custom_state ];
3275+
$nodes[] = array(
3276+
'name' => $name,
3277+
'path' => array( 'styles', 'blocks', $name, $custom_state ),
3278+
'selector' => $custom_css_selector,
3279+
'selectors' => $feature_selectors,
3280+
'elements' => $selectors[ $name ]['elements'] ?? array(),
3281+
'duotone' => $duotone_selector,
3282+
'variations' => $variation_selectors,
3283+
'css' => $custom_css_selector,
3284+
);
3285+
3286+
// Sub-pseudo-selectors within the custom state.
3287+
if ( isset( static::VALID_BLOCK_PSEUDO_SELECTORS[ $name ] ) ) {
3288+
foreach ( static::VALID_BLOCK_PSEUDO_SELECTORS[ $name ] as $pseudo ) {
3289+
if ( isset( $theme_json['styles']['blocks'][ $name ][ $custom_state ][ $pseudo ] ) ) {
3290+
$compound_css_selector = static::append_to_selector( $custom_css_selector, $pseudo );
3291+
$nodes[] = array(
3292+
'name' => $name,
3293+
'path' => array( 'styles', 'blocks', $name, $custom_state, $pseudo ),
3294+
'selector' => $compound_css_selector,
3295+
'selectors' => $feature_selectors,
3296+
'elements' => $selectors[ $name ]['elements'] ?? array(),
3297+
'duotone' => $duotone_selector,
3298+
'variations' => $variation_selectors,
3299+
'css' => $compound_css_selector,
3300+
);
3301+
}
3302+
}
3303+
}
3304+
}
3305+
}
3306+
}
32213307
}
32223308
if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'] ) ) {
32233309
foreach ( $theme_json['styles']['blocks'][ $name ]['elements'] as $element => $node ) {

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

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,32 @@
1414
* @since 6.8.0 The `user_pass` property is now hashed using bcrypt by default instead of phpass.
1515
* Existing passwords may still be hashed using phpass.
1616
*
17-
* @property string $nickname
18-
* @property string $description
19-
* @property string $user_description
20-
* @property string $first_name
21-
* @property string $user_firstname
22-
* @property string $last_name
23-
* @property string $user_lastname
24-
* @property string $user_login
25-
* @property string $user_pass
26-
* @property string $user_nicename
27-
* @property string $user_email
28-
* @property string $user_url
29-
* @property string $user_registered
30-
* @property string $user_activation_key
31-
* @property string $user_status
32-
* @property int $user_level
33-
* @property string $display_name
34-
* @property string $spam
35-
* @property string $deleted
36-
* @property string $locale
37-
* @property string $rich_editing
38-
* @property string $syntax_highlighting
39-
* @property string $use_ssl
17+
* @property string $nickname
18+
* @property string $description
19+
* @property string $user_description
20+
* @property string $first_name
21+
* @property string $user_firstname
22+
* @property string $last_name
23+
* @property string $user_lastname
24+
* @property string $user_login
25+
* @property string $user_pass
26+
* @property string $user_nicename
27+
* @property string $user_email
28+
* @property string $user_url
29+
* @property string $user_registered
30+
* @property string $user_activation_key
31+
* @property string $user_status
32+
* @property int|string $user_level
33+
* @property string $display_name
34+
* @property string $spam
35+
* @property string $deleted
36+
* @property string $locale
37+
* @property string $rich_editing
38+
* @property string $syntax_highlighting
39+
* @property string $use_ssl
40+
*
41+
* @phpstan-property numeric-string $user_status
42+
* @phpstan-property int|numeric-string|'' $user_level
4043
*/
4144
#[AllowDynamicProperties]
4245
class WP_User {

0 commit comments

Comments
 (0)