Skip to content

Commit 5db05ea

Browse files
committed
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develop into trac-43258-post-merge-feedback
2 parents 69ed332 + 330deca commit 5db05ea

File tree

12 files changed

+476
-27
lines changed

12 files changed

+476
-27
lines changed

src/wp-admin/options-general.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,20 @@ class="<?php echo esc_attr( $classes_for_button ); ?>"
479479

480480
foreach ( $date_formats as $format ) {
481481
echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
482+
482483
if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
483484
echo " checked='checked'";
484485
$custom = false;
485486
}
486-
echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
487+
488+
echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span>' .
489+
'<code>' . esc_html( $format ) . '</code>';
490+
491+
if ( __( 'F j, Y' ) === $format ) {
492+
echo ' ' . __( '(Site language default)' );
493+
}
494+
495+
echo "</label><br />\n";
487496
}
488497

489498
echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
@@ -524,11 +533,20 @@ class="<?php echo esc_attr( $classes_for_button ); ?>"
524533

525534
foreach ( $time_formats as $format ) {
526535
echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
536+
527537
if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===".
528538
echo " checked='checked'";
529539
$custom = false;
530540
}
531-
echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
541+
542+
echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span>' .
543+
'<code>' . esc_html( $format ) . '</code>';
544+
545+
if ( __( 'g:i a' ) === $format ) {
546+
echo ' ' . __( '(Site language default)' );
547+
}
548+
549+
echo "</label><br />\n";
532550
}
533551

534552
echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';

src/wp-admin/theme-editor.php

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,57 @@
212212
);
213213
}
214214

215-
if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) {
216-
$message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf(
217-
/* translators: %s: Link to Custom CSS section in the Customizer. */
218-
__( 'There is no need to change your CSS here &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
219-
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
220-
) . '</p>';
221-
wp_admin_notice(
222-
$message,
223-
array(
224-
'type' => 'info',
225-
'id' => 'message',
226-
)
227-
);
215+
if ( preg_match( '/\.css$/', $file ) ) {
216+
if ( ! wp_is_block_theme() && current_user_can( 'customize' ) ) {
217+
$message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf(
218+
/* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */
219+
__( 'There is no need to change your CSS here &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
220+
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
221+
) . '</p>';
222+
wp_admin_notice(
223+
$message,
224+
array(
225+
'type' => 'info',
226+
'id' => 'message',
227+
)
228+
);
229+
} elseif ( wp_is_block_theme() && current_user_can( 'edit_theme_options' ) ) {
230+
$site_editor_url = admin_url(
231+
add_query_arg(
232+
urlencode_deep(
233+
array(
234+
'p' => '/styles',
235+
'section' => '/css',
236+
)
237+
),
238+
'site-editor.php'
239+
)
240+
);
241+
242+
$message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf(
243+
/* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */
244+
__( 'There is no need to change your CSS here &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
245+
esc_url( $site_editor_url )
246+
) . '</p>';
247+
wp_admin_notice(
248+
$message,
249+
array(
250+
'type' => 'info',
251+
'id' => 'message',
252+
)
253+
);
254+
}
255+
if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) {
256+
$message = '<p><strong>' . __( 'There is a minified version of this stylesheet.' ) . '</strong></p><p>' .
257+
__( 'It is likely that this unminified stylesheet will not be served to visitors.' ) . '</p>';
258+
wp_admin_notice(
259+
$message,
260+
array(
261+
'type' => 'warning',
262+
'id' => 'wp-css-min-warning',
263+
)
264+
);
265+
}
228266
}
229267
?>
230268

src/wp-includes/SimplePie/src/IRI.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function __get(string $name)
170170
$return = null;
171171
}
172172

173-
if ($return === null && isset($this->normalization[$this->scheme][$name])) {
173+
if ($return === null && isset($this->scheme, $this->normalization[$this->scheme][$name])) {
174174
return $this->normalization[$this->scheme][$name];
175175
}
176176

@@ -623,6 +623,10 @@ protected function remove_iunreserved_percent_encoded(array $match)
623623
*/
624624
protected function scheme_normalization()
625625
{
626+
if ($this->scheme === null) {
627+
return;
628+
}
629+
626630
if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) {
627631
$this->iuserinfo = null;
628632
}

src/wp-includes/block-bindings/post-data.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,29 @@ function _block_bindings_post_data_get_value( array $source_args, $block_instanc
2323
return null;
2424
}
2525

26-
if ( empty( $block_instance->context['postId'] ) ) {
26+
/*
27+
* BACKWARDS COMPATIBILITY: Hardcoded exception for navigation blocks.
28+
* Required for WordPress 6.9+ navigation blocks. DO NOT REMOVE.
29+
*/
30+
$block_name = $block_instance->name ?? '';
31+
$is_navigation_block = in_array(
32+
$block_name,
33+
array( 'core/navigation-link', 'core/navigation-submenu' ),
34+
true
35+
);
36+
37+
if ( $is_navigation_block ) {
38+
// Navigation blocks: read from block attributes.
39+
$post_id = $block_instance->attributes['id'] ?? null;
40+
} else {
41+
// All other blocks: use context.
42+
$post_id = $block_instance->context['postId'] ?? null;
43+
}
44+
45+
// If we don't have an entity ID, bail early.
46+
if ( empty( $post_id ) ) {
2747
return null;
2848
}
29-
$post_id = $block_instance->context['postId'];
3049

3150
// If a post isn't public, we need to prevent unauthorized users from accessing the post data.
3251
$post = get_post( $post_id );
@@ -46,6 +65,11 @@ function _block_bindings_post_data_get_value( array $source_args, $block_instanc
4665
return '';
4766
}
4867
}
68+
69+
if ( 'link' === $source_args['key'] ) {
70+
$permalink = get_permalink( $post_id );
71+
return false === $permalink ? null : esc_url( $permalink );
72+
}
4973
}
5074

5175
/**
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/**
3+
* Term Data source for Block Bindings.
4+
*
5+
* @since 6.9.0
6+
* @package WordPress
7+
* @subpackage Block Bindings
8+
*/
9+
10+
/**
11+
* Gets value for Term Data source.
12+
*
13+
* @since 6.9.0
14+
* @access private
15+
*
16+
* @param array $source_args Array containing source arguments used to look up the override value.
17+
* Example: array( "key" => "name" ).
18+
* @param WP_Block $block_instance The block instance.
19+
* @return mixed The value computed for the source.
20+
*/
21+
function _block_bindings_term_data_get_value( array $source_args, $block_instance ) {
22+
if ( empty( $source_args['key'] ) ) {
23+
return null;
24+
}
25+
26+
/*
27+
* BACKWARDS COMPATIBILITY: Hardcoded exception for navigation blocks.
28+
* Required for WordPress 6.9+ navigation blocks. DO NOT REMOVE.
29+
*/
30+
$block_name = $block_instance->name ?? '';
31+
$is_navigation_block = in_array(
32+
$block_name,
33+
array( 'core/navigation-link', 'core/navigation-submenu' ),
34+
true
35+
);
36+
37+
if ( $is_navigation_block ) {
38+
// Navigation blocks: read from block attributes.
39+
$term_id = $block_instance->attributes['id'] ?? null;
40+
$type = $block_instance->attributes['type'] ?? '';
41+
// Map UI shorthand to taxonomy slug when using attributes.
42+
$taxonomy = ( 'tag' === $type ) ? 'post_tag' : $type;
43+
} else {
44+
// All other blocks: use context
45+
$term_id = $block_instance->context['termId'] ?? null;
46+
$taxonomy = $block_instance->context['taxonomy'] ?? '';
47+
}
48+
49+
// If we don't have required identifiers, bail early.
50+
if ( empty( $term_id ) || empty( $taxonomy ) ) {
51+
return null;
52+
}
53+
54+
// Get the term data.
55+
$term = get_term( $term_id, $taxonomy );
56+
if ( is_wp_error( $term ) || ! $term ) {
57+
return null;
58+
}
59+
60+
// Check if taxonomy exists and is publicly queryable.
61+
$taxonomy_object = get_taxonomy( $taxonomy );
62+
if ( ! $taxonomy_object || ! $taxonomy_object->publicly_queryable ) {
63+
if ( ! current_user_can( 'read' ) ) {
64+
return null;
65+
}
66+
}
67+
68+
switch ( $source_args['key'] ) {
69+
case 'id':
70+
return esc_html( (string) $term_id );
71+
72+
case 'name':
73+
return esc_html( $term->name );
74+
75+
case 'link':
76+
// Only taxonomy entities are supported by Term Data.
77+
$term_link = get_term_link( $term );
78+
return is_wp_error( $term_link ) ? null : esc_url( $term_link );
79+
80+
case 'slug':
81+
return esc_html( $term->slug );
82+
83+
case 'description':
84+
return wp_kses_post( $term->description );
85+
86+
case 'parent':
87+
return esc_html( (string) $term->parent );
88+
89+
case 'count':
90+
return esc_html( (string) $term->count );
91+
92+
default:
93+
return null;
94+
}
95+
}
96+
97+
/**
98+
* Registers Term Data source in the block bindings registry.
99+
*
100+
* @since 6.9.0
101+
* @access private
102+
*/
103+
function _register_block_bindings_term_data_source() {
104+
if ( get_block_bindings_source( 'core/term-data' ) ) {
105+
// The source is already registered.
106+
return;
107+
}
108+
109+
register_block_bindings_source(
110+
'core/term-data',
111+
array(
112+
'label' => _x( 'Term Data', 'block bindings source' ),
113+
'get_value_callback' => '_block_bindings_term_data_get_value',
114+
'uses_context' => array( 'termId', 'taxonomy' ),
115+
)
116+
);
117+
}
118+
119+
add_action( 'init', '_register_block_bindings_term_data_source' );

src/wp-includes/template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ function load_template( $_template_file, $load_once = true, $args = array() ) {
828828
* Checks whether the template should be output buffered for enhancement.
829829
*
830830
* By default, an output buffer is only started if a {@see 'wp_template_enhancement_output_buffer'} filter has been
831-
* added be the time a template is included at the {@see 'wp_before_include_template'} action. This allows template
831+
* added by the time a template is included at the {@see 'wp_before_include_template'} action. This allows template
832832
* responses to be streamed as much as possible when no template enhancements are registered to apply.
833833
*
834834
* @since 6.9.0

src/wp-includes/user.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,14 @@ function count_user_posts( $userid, $post_type = 'post', $public_only = false )
649649
* Gets the number of posts written by a list of users.
650650
*
651651
* @since 3.0.0
652+
* @since 6.9.0 The results are now cached.
652653
*
653654
* @global wpdb $wpdb WordPress database abstraction object.
654655
*
655656
* @param int[] $users Array of user IDs.
656657
* @param string|string[] $post_type Optional. Single post type or array of post types to check. Defaults to 'post'.
657658
* @param bool $public_only Optional. Only return counts for public posts. Defaults to false.
658-
* @return string[] Amount of posts each user has written, as strings, keyed by user ID.
659+
* @return array<int, string> Amount of posts each user has written, as strings, keyed by user ID.
659660
*/
660661
function count_many_users_posts( $users, $post_type = 'post', $public_only = false ) {
661662
global $wpdb;
@@ -682,14 +683,31 @@ function count_many_users_posts( $users, $post_type = 'post', $public_only = fal
682683
return $pre;
683684
}
684685

685-
$userlist = implode( ',', array_map( 'absint', $users ) );
686-
$where = get_posts_by_author_sql( $post_type, true, null, $public_only );
686+
// Cleanup the users array. Remove duplicates and sort for consistent ordering.
687+
$users = array_unique( array_filter( array_map( 'intval', $users ) ) );
688+
sort( $users );
687689

688-
$result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
690+
// Cleanup the post type argument. Remove duplicates and sort for consistent ordering.
691+
$post_type = array_unique( (array) $post_type );
692+
sort( $post_type );
693+
694+
$userlist = implode( ',', $users );
695+
$where = get_posts_by_author_sql( $post_type, true, null, $public_only );
696+
$query = "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author";
697+
$cache_key = 'count_many_users_posts:' . md5( $query );
698+
$cache_salts = array( wp_cache_get_last_changed( 'posts' ), wp_cache_get_last_changed( 'users' ) );
699+
$count = wp_cache_get_salted( $cache_key, 'post-queries', $cache_salts );
700+
701+
if ( false === $count ) {
702+
$where = get_posts_by_author_sql( $post_type, true, null, $public_only );
703+
$result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
704+
705+
$count = array_fill_keys( $users, 0 );
706+
foreach ( $result as $row ) {
707+
$count[ $row[0] ] = $row[1];
708+
}
689709

690-
$count = array_fill_keys( $users, 0 );
691-
foreach ( $result as $row ) {
692-
$count[ $row[0] ] = $row[1];
710+
wp_cache_set_salted( $cache_key, $count, 'post-queries', $cache_salts, HOUR_IN_SECONDS );
693711
}
694712

695713
return $count;

src/wp-settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
require ABSPATH . WPINC . '/block-bindings/pattern-overrides.php';
370370
require ABSPATH . WPINC . '/block-bindings/post-data.php';
371371
require ABSPATH . WPINC . '/block-bindings/post-meta.php';
372+
require ABSPATH . WPINC . '/block-bindings/term-data.php';
372373
require ABSPATH . WPINC . '/blocks.php';
373374
require ABSPATH . WPINC . '/blocks/index.php';
374375
require ABSPATH . WPINC . '/block-editor.php';

tests/phpunit/includes/functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ function _unhook_block_registration() {
350350
remove_action( 'init', '_register_block_bindings_pattern_overrides_source' );
351351
remove_action( 'init', '_register_block_bindings_post_data_source' );
352352
remove_action( 'init', '_register_block_bindings_post_meta_source' );
353+
remove_action( 'init', '_register_block_bindings_term_data_source' );
353354
}
354355
tests_add_filter( 'init', '_unhook_block_registration', 1000 );
355356

tests/phpunit/tests/block-bindings/register.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function test_get_all_registered() {
7575
'core/post-data' => get_block_bindings_source( 'core/post-data' ),
7676
'core/post-meta' => get_block_bindings_source( 'core/post-meta' ),
7777
'core/pattern-overrides' => get_block_bindings_source( 'core/pattern-overrides' ),
78+
'core/term-data' => get_block_bindings_source( 'core/term-data' ),
7879
);
7980

8081
$registered = get_all_registered_block_bindings_sources();

0 commit comments

Comments
 (0)