Skip to content

Commit aeb06b2

Browse files
Merge branch 'WordPress:trunk' into trunk
2 parents ad80afc + f6cf8fa commit aeb06b2

File tree

26 files changed

+416
-261
lines changed

26 files changed

+416
-261
lines changed

src/wp-admin/css/forms.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@ p.search-box {
727727
clear: left;
728728
}
729729

730-
.search-box input[name="s"],
731730
.tablenav .search-plugins input[name="s"],
732731
.tagsdiv .newtag {
733732
float: left;
@@ -1653,11 +1652,15 @@ table.form-table td .updated p {
16531652
}
16541653

16551654
p.search-box input[name="s"] {
1656-
float: none;
16571655
width: 100%;
1656+
float: none;
16581657
margin-bottom: 10px;
16591658
vertical-align: middle;
16601659
}
1660+
.js.plugins-php .search-box .wp-filter-search {
1661+
width: 100%;
1662+
margin-bottom: 0;
1663+
}
16611664

16621665
p.search-box input[type="submit"] {
16631666
margin-bottom: 10px;

src/wp-admin/css/themes.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,7 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap {
961961
}
962962

963963
.themes-php .wp-filter-search {
964-
float: none;
965-
clear: both;
966-
left: 0;
967-
right: 0;
968964
width: 100%;
969-
max-width: 280px;
970965
}
971966

972967
.theme-install-php .wp-filter p.search-box {

src/wp-admin/includes/class-custom-image-header.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,8 +1547,8 @@ public function get_default_header_images() {
15471547

15481548
$already_has_default = false;
15491549

1550-
foreach ( $this->default_headers as $k => $h ) {
1551-
if ( $h['url'] === $default ) {
1550+
foreach ( $this->default_headers as $k => $header ) {
1551+
if ( $header['url'] === $default ) {
15521552
$already_has_default = true;
15531553
break;
15541554
}

src/wp-admin/includes/nav-menu.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
495495
}
496496
}
497497

498-
// @todo Transient caching of these results with proper invalidation on updating of a post of this type.
499498
$get_posts = new WP_Query();
500499
$posts = $get_posts->query( $args );
501500

src/wp-admin/network/site-users.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,37 @@
139139

140140
case 'promote':
141141
check_admin_referer( 'bulk-users' );
142+
143+
if ( ! current_user_can( 'promote_users' ) ) {
144+
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
145+
}
146+
142147
$editable_roles = get_editable_roles();
143148
$role = $_REQUEST['new_role'];
144149

150+
// Mock `none` as editable role.
151+
$editable_roles['none'] = array(
152+
'name' => __( '— No role for this site —' ),
153+
);
154+
145155
if ( empty( $editable_roles[ $role ] ) ) {
146156
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
147157
}
148158

159+
if ( 'none' === $role ) {
160+
$role = '';
161+
}
162+
149163
if ( isset( $_REQUEST['users'] ) ) {
150164
$userids = $_REQUEST['users'];
151165
$update = 'promote';
152166
foreach ( $userids as $user_id ) {
153167
$user_id = (int) $user_id;
154168

169+
if ( ! current_user_can( 'promote_user', $user_id ) ) {
170+
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
171+
}
172+
155173
// If the user doesn't already belong to the blog, bail.
156174
if ( ! is_user_member_of_blog( $user_id ) ) {
157175
wp_die(
@@ -162,6 +180,8 @@
162180
}
163181

164182
$user = get_userdata( $user_id );
183+
184+
// If $role is empty, none will be set.
165185
$user->set_role( $role );
166186
}
167187
} else {

src/wp-admin/user-edit.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,15 +471,11 @@
471471
</tr>
472472
<?php endif; // End if ! IS_PROFILE_PAGE. ?>
473473

474-
<?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?>
474+
<?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && ! isset( $super_admins ) ) : ?>
475475
<tr class="user-super-admin-wrap">
476476
<th><?php _e( 'Super Admin' ); ?></th>
477477
<td>
478-
<?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?>
479-
<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
480-
<?php else : ?>
481-
<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
482-
<?php endif; ?>
478+
<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
483479
</td>
484480
</tr>
485481
<?php endif; ?>

src/wp-admin/users.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
$editable_roles = get_editable_roles();
123123
$role = $_REQUEST['new_role'];
124124

125-
// Mocking the `none` role so we are able to save it to the database
125+
// Mock `none` as editable role.
126126
$editable_roles['none'] = array(
127127
'name' => __( '&mdash; No role for this site &mdash;' ),
128128
);
@@ -162,6 +162,8 @@
162162
}
163163

164164
$user = get_userdata( $id );
165+
166+
// If $role is empty, none will be set.
165167
$user->set_role( $role );
166168
}
167169

src/wp-includes/block-bindings.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ function get_block_bindings_source( string $source_name ) {
140140
*/
141141
function get_block_bindings_supported_attributes( $block_type ) {
142142
$block_bindings_supported_attributes = array(
143-
'core/paragraph' => array( 'content' ),
144-
'core/heading' => array( 'content' ),
145-
'core/image' => array( 'id', 'url', 'title', 'alt', 'caption' ),
146-
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
147-
'core/post-date' => array( 'datetime' ),
143+
'core/paragraph' => array( 'content' ),
144+
'core/heading' => array( 'content' ),
145+
'core/image' => array( 'id', 'url', 'title', 'alt', 'caption' ),
146+
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
147+
'core/post-date' => array( 'datetime' ),
148+
'core/navigation-link' => array( 'url' ),
149+
'core/navigation-submenu' => array( 'url' ),
148150
);
149151

150152
$supported_block_attributes =

src/wp-includes/block-supports/layout.php

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,50 +1074,53 @@ static function ( $matches ) {
10741074
* @return string Filtered block content.
10751075
*/
10761076
function wp_restore_image_outer_container( $block_content, $block ) {
1077-
$image_with_align = "
1078-
/# 1) everything up to the class attribute contents
1079-
(
1080-
^\s*
1081-
<figure\b
1082-
[^>]*
1083-
\bclass=
1084-
[\"']
1085-
)
1086-
# 2) the class attribute contents
1087-
(
1088-
[^\"']*
1089-
\bwp-block-image\b
1090-
[^\"']*
1091-
\b(?:alignleft|alignright|aligncenter)\b
1092-
[^\"']*
1093-
)
1094-
# 3) everything after the class attribute contents
1095-
(
1096-
[\"']
1097-
[^>]*
1098-
>
1099-
.*
1100-
<\/figure>
1101-
)/iUx";
1077+
if ( wp_theme_has_theme_json() ) {
1078+
return $block_content;
1079+
}
11021080

1081+
$figure_processor = new WP_HTML_Tag_Processor( $block_content );
11031082
if (
1104-
wp_theme_has_theme_json() ||
1105-
0 === preg_match( $image_with_align, $block_content, $matches )
1083+
! $figure_processor->next_tag( 'FIGURE' ) ||
1084+
! $figure_processor->has_class( 'wp-block-image' ) ||
1085+
! (
1086+
$figure_processor->has_class( 'alignleft' ) ||
1087+
$figure_processor->has_class( 'aligncenter' ) ||
1088+
$figure_processor->has_class( 'alignright' )
1089+
)
11061090
) {
11071091
return $block_content;
11081092
}
11091093

1110-
$wrapper_classnames = array( 'wp-block-image' );
1094+
/*
1095+
* The next section of code wraps the existing figure in a new DIV element.
1096+
* While doing it, it needs to transfer the layout and the additional CSS
1097+
* class names from the original figure upward to the wrapper.
1098+
*
1099+
* Example:
1100+
*
1101+
* // From this…
1102+
* <!-- wp:image {"className":"hires"} -->
1103+
* <figure class="wp-block-image wide hires">…
1104+
*
1105+
* // To this…
1106+
* <div class="wp-block-image hires"><figure class="wide">…
1107+
*/
1108+
$wrapper_processor = new WP_HTML_Tag_Processor( '<div>' );
1109+
$wrapper_processor->next_token();
1110+
$wrapper_processor->set_attribute(
1111+
'class',
1112+
is_string( $block['attrs']['className'] ?? null )
1113+
? "wp-block-image {$block['attrs']['className']}"
1114+
: 'wp-block-image'
1115+
);
11111116

1112-
// If the block has a classNames attribute these classnames need to be removed from the content and added back
1113-
// to the new wrapper div also.
1114-
if ( ! empty( $block['attrs']['className'] ) ) {
1115-
$wrapper_classnames = array_merge( $wrapper_classnames, explode( ' ', $block['attrs']['className'] ) );
1117+
// And remove them from the existing content; it has been transferred upward.
1118+
$figure_processor->remove_class( 'wp-block-image' );
1119+
foreach ( $wrapper_processor->class_list() as $class_name ) {
1120+
$figure_processor->remove_class( $class_name );
11161121
}
1117-
$content_classnames = explode( ' ', $matches[2] );
1118-
$filtered_content_classnames = array_diff( $content_classnames, $wrapper_classnames );
11191122

1120-
return '<div class="' . implode( ' ', $wrapper_classnames ) . '">' . $matches[1] . implode( ' ', $filtered_content_classnames ) . $matches[3] . '</div>';
1123+
return "{$wrapper_processor->get_updated_html()}{$figure_processor->get_updated_html()}</div>";
11211124
}
11221125

11231126
add_filter( 'render_block_core/image', 'wp_restore_image_outer_container', 10, 2 );

src/wp-includes/capabilities.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ function grant_super_admin( $user_id ) {
12521252
* Revokes Super Admin privileges.
12531253
*
12541254
* @since 3.0.0
1255+
* @since 6.9.0 Super admin privileges can be revoked regardless of email address.
12551256
*
12561257
* @global array $super_admins
12571258
*
@@ -1278,7 +1279,7 @@ function revoke_super_admin( $user_id ) {
12781279
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
12791280

12801281
$user = get_userdata( $user_id );
1281-
if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
1282+
if ( $user ) {
12821283
$key = array_search( $user->user_login, $super_admins, true );
12831284
if ( false !== $key ) {
12841285
unset( $super_admins[ $key ] );

0 commit comments

Comments
 (0)