Skip to content

Commit 2111d68

Browse files
committed
2 parents 3b9179e + 56ac994 commit 2111d68

File tree

10 files changed

+139
-84
lines changed

10 files changed

+139
-84
lines changed

src/wp-admin/includes/schema.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ function populate_options( array $options = array() ) {
563563

564564
// 6.9.0
565565
'wp_notes_notify' => 1,
566-
567566
);
568567

569568
// 3.3.0

src/wp-admin/menu.php

Lines changed: 77 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@
4040

4141
if ( ! is_multisite() ) {
4242
if ( current_user_can( 'update_core' ) ) {
43-
$cap = 'update_core';
43+
$capability = 'update_core';
4444
} elseif ( current_user_can( 'update_plugins' ) ) {
45-
$cap = 'update_plugins';
45+
$capability = 'update_plugins';
4646
} elseif ( current_user_can( 'update_themes' ) ) {
47-
$cap = 'update_themes';
47+
$capability = 'update_themes';
4848
} else {
49-
$cap = 'update_languages';
49+
$capability = 'update_languages';
5050
}
51+
5152
$submenu['index.php'][10] = array(
5253
sprintf(
5354
/* translators: %s: Number of pending updates. */
@@ -58,30 +59,35 @@
5859
number_format_i18n( $update_data['counts']['total'] )
5960
)
6061
),
61-
$cap,
62+
$capability,
6263
'update-core.php',
6364
);
64-
unset( $cap );
65+
66+
unset( $capability );
6567
}
6668

6769
$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
6870

6971
// $menu[5] = Posts.
7072

71-
$menu[10] = array( __( 'Media' ), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' );
73+
$menu[10] = array( __( 'Media' ), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' );
74+
7275
$submenu['upload.php'][5] = array( __( 'Library' ), 'upload_files', 'upload.php' );
7376
$submenu['upload.php'][10] = array( __( 'Add Media File' ), 'upload_files', 'media-new.php' );
74-
$i = 15;
75-
foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) {
76-
if ( ! $tax->show_ui || ! $tax->show_in_menu ) {
77-
continue;
77+
$submenu_index = 15;
78+
79+
foreach ( get_taxonomies_for_attachments( 'objects' ) as $taxonomy ) {
80+
if ( ! $taxonomy->show_ui || ! $taxonomy->show_in_menu ) {
81+
continue;
7882
}
7983

80-
$submenu['upload.php'][ $i++ ] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' );
84+
$submenu['upload.php'][ $submenu_index++ ] = array( esc_attr( $taxonomy->labels->menu_name ), $taxonomy->cap->manage_terms, 'edit-tags.php?taxonomy=' . $taxonomy->name . '&post_type=attachment' );
8185
}
82-
unset( $tax, $i );
8386

84-
$menu[15] = array( __( 'Links' ), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' );
87+
unset( $taxonomy, $submenu_index );
88+
89+
$menu[15] = array( __( 'Links' ), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' );
90+
8591
$submenu['link-manager.php'][5] = array( _x( 'All Links', 'admin menu' ), 'manage_links', 'link-manager.php' );
8692
$submenu['link-manager.php'][10] = array( __( 'Add Link' ), 'manage_links', 'link-add.php' );
8793
$submenu['link-manager.php'][15] = array( __( 'Link Categories' ), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );
@@ -90,114 +96,124 @@
9096

9197
// Avoid the comment count query for users who cannot edit_posts.
9298
if ( current_user_can( 'edit_posts' ) ) {
93-
$awaiting_mod = wp_count_comments();
94-
$awaiting_mod = $awaiting_mod->moderated;
95-
$awaiting_mod_i18n = number_format_i18n( $awaiting_mod );
99+
$awaiting_moderation = wp_count_comments();
100+
$awaiting_moderation = $awaiting_moderation->moderated;
101+
$awaiting_moderation_i18n = number_format_i18n( $awaiting_moderation );
96102
/* translators: %s: Number of comments. */
97-
$awaiting_mod_text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ), $awaiting_mod_i18n );
103+
$awaiting_moderation_text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_moderation ), $awaiting_moderation_i18n );
98104

99105
$menu[25] = array(
100106
/* translators: %s: Number of comments. */
101-
sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count" aria-hidden="true">' . $awaiting_mod_i18n . '</span><span class="comments-in-moderation-text screen-reader-text">' . $awaiting_mod_text . '</span></span>' ),
107+
sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_moderation ) . '"><span class="pending-count" aria-hidden="true">' . $awaiting_moderation_i18n . '</span><span class="comments-in-moderation-text screen-reader-text">' . $awaiting_moderation_text . '</span></span>' ),
102108
'edit_posts',
103109
'edit-comments.php',
104110
'',
105111
'menu-top menu-icon-comments',
106112
'menu-comments',
107113
'dashicons-admin-comments',
108114
);
109-
unset( $awaiting_mod );
115+
116+
unset( $awaiting_moderation );
110117
}
111118

112119
$submenu['edit-comments.php'][0] = array( __( 'All Comments' ), 'edit_posts', 'edit-comments.php' );
113120

114121
$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group.
115122

116-
$types = (array) get_post_types(
123+
$post_types = (array) get_post_types(
117124
array(
118125
'show_ui' => true,
119126
'_builtin' => false,
120127
'show_in_menu' => true,
121128
)
122129
);
123-
$builtin = array( 'post', 'page' );
124-
foreach ( array_merge( $builtin, $types ) as $ptype ) {
125-
$ptype_obj = get_post_type_object( $ptype );
130+
$builtin = array( 'post', 'page' );
131+
132+
foreach ( array_merge( $builtin, $post_types ) as $post_type ) {
133+
$post_type_obj = get_post_type_object( $post_type );
134+
126135
// Check if it should be a submenu.
127-
if ( true !== $ptype_obj->show_in_menu ) {
136+
if ( true !== $post_type_obj->show_in_menu ) {
128137
continue;
129138
}
130-
$ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first.
131-
$ptype_for_id = sanitize_html_class( $ptype );
139+
140+
$post_type_menu_position = is_int( $post_type_obj->menu_position )
141+
? $post_type_obj->menu_position
142+
: ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first.
143+
$post_type_for_id = sanitize_html_class( $post_type );
132144

133145
$menu_icon = 'dashicons-admin-post';
134-
if ( is_string( $ptype_obj->menu_icon ) ) {
146+
if ( is_string( $post_type_obj->menu_icon ) ) {
135147
// Special handling for an empty div.wp-menu-image, data:image/svg+xml, and Dashicons.
136-
if ( 'none' === $ptype_obj->menu_icon || 'div' === $ptype_obj->menu_icon
137-
|| str_starts_with( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' )
138-
|| str_starts_with( $ptype_obj->menu_icon, 'dashicons-' )
148+
if ( 'none' === $post_type_obj->menu_icon || 'div' === $post_type_obj->menu_icon
149+
|| str_starts_with( $post_type_obj->menu_icon, 'data:image/svg+xml;base64,' )
150+
|| str_starts_with( $post_type_obj->menu_icon, 'dashicons-' )
139151
) {
140-
$menu_icon = $ptype_obj->menu_icon;
152+
$menu_icon = $post_type_obj->menu_icon;
141153
} else {
142-
$menu_icon = esc_url( $ptype_obj->menu_icon );
154+
$menu_icon = esc_url( $post_type_obj->menu_icon );
143155
}
144-
} elseif ( in_array( $ptype, $builtin, true ) ) {
145-
$menu_icon = 'dashicons-admin-' . $ptype;
156+
} elseif ( in_array( $post_type, $builtin, true ) ) {
157+
$menu_icon = 'dashicons-admin-' . $post_type;
146158
}
147159

148-
$menu_class = 'menu-top menu-icon-' . $ptype_for_id;
160+
$menu_class = 'menu-top menu-icon-' . $post_type_for_id;
149161
// 'post' special case.
150-
if ( 'post' === $ptype ) {
162+
if ( 'post' === $post_type ) {
151163
$menu_class .= ' open-if-no-js';
152-
$ptype_file = 'edit.php';
164+
$post_type_file = 'edit.php';
153165
$post_new_file = 'post-new.php';
154166
$edit_tags_file = 'edit-tags.php?taxonomy=%s';
155167
} else {
156-
$ptype_file = "edit.php?post_type=$ptype";
157-
$post_new_file = "post-new.php?post_type=$ptype";
158-
$edit_tags_file = "edit-tags.php?taxonomy=%s&amp;post_type=$ptype";
168+
$post_type_file = "edit.php?post_type=$post_type";
169+
$post_new_file = "post-new.php?post_type=$post_type";
170+
$edit_tags_file = "edit-tags.php?taxonomy=%s&amp;post_type=$post_type";
159171
}
160172

161-
if ( in_array( $ptype, $builtin, true ) ) {
162-
$ptype_menu_id = 'menu-' . $ptype_for_id . 's';
173+
if ( in_array( $post_type, $builtin, true ) ) {
174+
$post_type_menu_id = 'menu-' . $post_type_for_id . 's';
163175
} else {
164-
$ptype_menu_id = 'menu-posts-' . $ptype_for_id;
176+
$post_type_menu_id = 'menu-posts-' . $post_type_for_id;
165177
}
178+
166179
/*
167-
* If $ptype_menu_position is already populated or will be populated
180+
* If $post_type_menu_position is already populated or will be populated
168181
* by a hard-coded value below, increment the position.
169182
*/
170183
$core_menu_positions = array( 59, 60, 65, 70, 75, 80, 85, 99 );
171-
while ( isset( $menu[ $ptype_menu_position ] ) || in_array( $ptype_menu_position, $core_menu_positions, true ) ) {
172-
++$ptype_menu_position;
184+
while ( isset( $menu[ $post_type_menu_position ] ) || in_array( $post_type_menu_position, $core_menu_positions, true ) ) {
185+
++$post_type_menu_position;
173186
}
174187

175-
$menu[ $ptype_menu_position ] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, $ptype_file, '', $menu_class, $ptype_menu_id, $menu_icon );
176-
$submenu[ $ptype_file ][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, $ptype_file );
177-
$submenu[ $ptype_file ][10] = array( $ptype_obj->labels->add_new_item, $ptype_obj->cap->create_posts, $post_new_file );
188+
$menu[ $post_type_menu_position ] = array( esc_attr( $post_type_obj->labels->menu_name ), $post_type_obj->cap->edit_posts, $post_type_file, '', $menu_class, $post_type_menu_id, $menu_icon );
189+
$submenu[ $post_type_file ][5] = array( $post_type_obj->labels->all_items, $post_type_obj->cap->edit_posts, $post_type_file );
190+
$submenu[ $post_type_file ][10] = array( $post_type_obj->labels->add_new_item, $post_type_obj->cap->create_posts, $post_new_file );
178191

179-
$i = 15;
180-
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
181-
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array( $ptype, (array) $tax->object_type, true ) ) {
192+
$submenu_index = 15;
193+
194+
foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
195+
if ( ! $taxonomy->show_ui || ! $taxonomy->show_in_menu || ! in_array( $post_type, (array) $taxonomy->object_type, true ) ) {
182196
continue;
183197
}
184198

185-
$submenu[ $ptype_file ][ $i++ ] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, sprintf( $edit_tags_file, $tax->name ) );
199+
$submenu[ $post_type_file ][ $submenu_index++ ] = array( esc_attr( $taxonomy->labels->menu_name ), $taxonomy->cap->manage_terms, sprintf( $edit_tags_file, $taxonomy->name ) );
186200
}
187201
}
188-
unset( $ptype, $ptype_obj, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax, $post_new_file );
202+
203+
unset( $post_type, $post_type_obj, $post_type_for_id, $post_type_menu_position, $menu_icon, $submenu_index, $taxonomy, $post_new_file );
189204

190205
$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
191206

192-
$appearance_cap = current_user_can( 'switch_themes' ) ? 'switch_themes' : 'edit_theme_options';
207+
$appearance_capability = current_user_can( 'switch_themes' ) ? 'switch_themes' : 'edit_theme_options';
193208

194-
$menu[60] = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
209+
$menu[60] = array( __( 'Appearance' ), $appearance_capability, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
195210

196211
$count = '';
197212
if ( ! is_multisite() && current_user_can( 'update_themes' ) ) {
198213
if ( ! isset( $update_data ) ) {
199214
$update_data = wp_get_update_data();
200215
}
216+
201217
$count = sprintf(
202218
'<span class="update-plugins count-%s"><span class="theme-count">%s</span></span>',
203219
$update_data['counts']['themes'],
@@ -206,7 +222,7 @@
206222
}
207223

208224
/* translators: %s: Number of available theme updates. */
209-
$submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' );
225+
$submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_capability, 'themes.php' );
210226

211227
if ( wp_is_block_theme() ) {
212228
$submenu['themes.php'][6] = array( _x( 'Editor', 'site editor menu item' ), 'edit_theme_options', 'site-editor.php' );
@@ -234,17 +250,15 @@
234250

235251
if ( current_theme_supports( 'custom-header' ) && current_user_can( 'customize' ) ) {
236252
$customize_header_url = add_query_arg( array( 'autofocus' => array( 'control' => 'header_image' ) ), $customize_url );
237-
$submenu['themes.php'][15] = array( _x( 'Header', 'custom image header' ), $appearance_cap, esc_url( $customize_header_url ), '', 'hide-if-no-customize' );
253+
$submenu['themes.php'][15] = array( _x( 'Header', 'custom image header' ), $appearance_capability, esc_url( $customize_header_url ), '', 'hide-if-no-customize' );
238254
}
239255

240256
if ( current_theme_supports( 'custom-background' ) && current_user_can( 'customize' ) ) {
241257
$customize_background_url = add_query_arg( array( 'autofocus' => array( 'control' => 'background_image' ) ), $customize_url );
242-
$submenu['themes.php'][20] = array( _x( 'Background', 'custom background' ), $appearance_cap, esc_url( $customize_background_url ), '', 'hide-if-no-customize' );
258+
$submenu['themes.php'][20] = array( _x( 'Background', 'custom background' ), $appearance_capability, esc_url( $customize_background_url ), '', 'hide-if-no-customize' );
243259
}
244260

245-
unset( $customize_url );
246-
247-
unset( $appearance_cap );
261+
unset( $customize_url, $appearance_capability );
248262

249263
// Add 'Theme File Editor' to the bottom of the Appearance (non-block themes) or Tools (block themes) menu.
250264
if ( ! is_multisite() ) {

src/wp-admin/options-discussion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<?php _e( 'A comment is held for moderation' ); ?> </label>
163163
<br />
164164
<label for="wp_notes_notify">
165-
<input name="wp_notes_notify" type="checkbox" id="wp_notes_notify" value="1" <?php checked( '1', get_option( 'wp_notes_notify' ) ); ?> />
165+
<input name="wp_notes_notify" type="checkbox" id="wp_notes_notify" value="1" <?php checked( '1', get_option( 'wp_notes_notify', 1 ) ); ?> />
166166
<?php _e( 'Anyone posts a note' ); ?> </label>
167167

168168
</fieldset></td>

src/wp-includes/comment.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ function wp_new_comment_notify_postauthor( $comment_id ) {
24272427
$comment = get_comment( $comment_id );
24282428
$is_note = ( $comment && 'note' === $comment->comment_type );
24292429

2430-
$maybe_notify = $is_note ? get_option( 'wp_notes_notify' ) : get_option( 'comments_notify' );
2430+
$maybe_notify = $is_note ? get_option( 'wp_notes_notify', 1 ) : get_option( 'comments_notify' );
24312431

24322432
/**
24332433
* Filters whether to send the post author new comment notification emails,
@@ -2458,6 +2458,19 @@ function wp_new_comment_notify_postauthor( $comment_id ) {
24582458
return wp_notify_postauthor( $comment_id );
24592459
}
24602460

2461+
/**
2462+
* Send a notification to the post author when a new note is added via the REST API.
2463+
*
2464+
* @since 6.9.0
2465+
*
2466+
* @param WP_Comment $comment The comment object.
2467+
*/
2468+
function wp_new_comment_via_rest_notify_postauthor( $comment ) {
2469+
if ( $comment instanceof WP_Comment && 'note' === $comment->comment_type ) {
2470+
wp_new_comment_notify_postauthor( (int) $comment->comment_ID );
2471+
}
2472+
}
2473+
24612474
/**
24622475
* Sets the status of a comment.
24632476
*

src/wp-includes/default-filters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
// Email notifications.
523523
add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
524524
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
525-
add_action( 'rest_insert_comment', array( 'WP_REST_Comments_Controller', 'wp_new_comment_via_rest_notify_postauthor' ) );
525+
add_action( 'rest_insert_comment', 'wp_new_comment_via_rest_notify_postauthor' );
526526
add_action( 'after_password_reset', 'wp_password_change_notification' );
527527
add_action( 'register_new_user', 'wp_send_new_user_notifications' );
528528
add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );

src/wp-includes/general-template.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,9 +1424,15 @@ function wp_title( $sep = '&raquo;', $display = true, $seplocation = '' ) {
14241424
$title = __( 'Page not found' );
14251425
}
14261426

1427-
$prefix = '';
1428-
if ( ! empty( $title ) ) {
1429-
$prefix = " $sep ";
1427+
if ( ! is_string( $title ) ) {
1428+
$title = '';
1429+
}
1430+
1431+
$prefix = '';
1432+
$title_array = array();
1433+
if ( '' !== $title ) {
1434+
$prefix = " $sep ";
1435+
$title_array = explode( $t_sep, $title );
14301436
}
14311437

14321438
/**
@@ -1436,7 +1442,7 @@ function wp_title( $sep = '&raquo;', $display = true, $seplocation = '' ) {
14361442
*
14371443
* @param string[] $title_array Array of parts of the page title.
14381444
*/
1439-
$title_array = apply_filters( 'wp_title_parts', ! empty( $title ) ? explode( $t_sep, $title ) : array() );
1445+
$title_array = apply_filters( 'wp_title_parts', $title_array );
14401446

14411447
// Determines position of the separator and direction of the breadcrumb.
14421448
if ( 'right' === $seplocation ) { // Separator on right, so reverse the order.

src/wp-includes/interactivity-api/class-wp-interactivity-api.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,12 @@ private function _process_directives( string $html ) {
520520
array_pop( $tag_stack );
521521
}
522522
} else {
523-
if ( 0 !== count( $p->get_attribute_names_with_prefix( 'data-wp-each-child' ) ) ) {
523+
$each_child_attrs = $p->get_attribute_names_with_prefix( 'data-wp-each-child' );
524+
if ( null === $each_child_attrs ) {
525+
continue;
526+
}
527+
528+
if ( 0 !== count( $each_child_attrs ) ) {
524529
/*
525530
* If the tag has a `data-wp-each-child` directive, jump to its closer
526531
* tag because those tags have already been processed.

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ public function __construct() {
3636
$this->meta = new WP_REST_Comment_Meta_Fields();
3737
}
3838

39-
/**
40-
* Send a notification to the post author when a new note is added via the REST API.
41-
*
42-
* @since 6.9.0
43-
*
44-
* @param WP_Comment $comment The comment object.
45-
*/
46-
public static function wp_new_comment_via_rest_notify_postauthor( $comment ) {
47-
if ( 'note' === $comment->comment_type ) {
48-
wp_new_comment_notify_postauthor( $comment->comment_ID );
49-
}
50-
}
5139
/**
5240
* Registers the routes for comments.
5341
*

0 commit comments

Comments
 (0)