Skip to content

Commit 598138c

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 228190e + 7d826c0 commit 598138c

11 files changed

Lines changed: 133 additions & 39 deletions

File tree

src/wp-content/themes/twentysixteen/functions.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ function twentysixteen_setup() {
246246
* @since Twenty Sixteen 1.0
247247
*/
248248
function twentysixteen_content_width() {
249+
/**
250+
* Filters Twenty Sixteen content width of the theme.
251+
*
252+
* @since Twenty Sixteen 1.0
253+
*
254+
* @param int $content_width Content width in pixels.
255+
*/
249256
$GLOBALS['content_width'] = apply_filters( 'twentysixteen_content_width', 840 );
250257
}
251258
add_action( 'after_setup_theme', 'twentysixteen_content_width', 0 );

src/wp-content/themes/twentysixteen/inc/template-tags.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
*/
2020
function twentysixteen_entry_meta() {
2121
if ( 'post' === get_post_type() ) {
22+
/**
23+
* Filters the Twenty Sixteen entry meta avatar size.
24+
*
25+
* @since Twenty Sixteen 1.0
26+
*
27+
* @param int $size The avatar height and width size in pixels.
28+
*/
2229
$author_avatar_size = apply_filters( 'twentysixteen_author_avatar_size', 49 );
2330
printf(
2431
'<span class="byline">%1$s<span class="screen-reader-text">%2$s </span><span class="author vcard"><a class="url fn n" href="%3$s">%4$s</a></span></span>',

src/wp-includes/abilities-api/class-wp-abilities-registry.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public function register( string $name, array $args ): ?WP_Ability {
121121

122122
// Validate ability category exists if provided (will be validated as required in WP_Ability).
123123
if ( isset( $args['category'] ) ) {
124-
$category_registry = WP_Ability_Categories_Registry::get_instance();
125-
if ( ! $category_registry->is_registered( $args['category'] ) ) {
124+
if ( ! wp_has_ability_category( $args['category'] ) ) {
126125
_doing_it_wrong(
127126
__METHOD__,
128127
sprintf(

src/wp-includes/author-template.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,31 @@ function the_author( $deprecated = '', $deprecated_echo = true ) {
8686
* Retrieves the author who last edited the current post.
8787
*
8888
* @since 2.8.0
89+
* @since 6.9.0 Added the `$post` parameter. Unknown return value is now explicitly null instead of void.
8990
*
90-
* @return string|void The author's display name, empty string if unknown.
91+
* @param int|WP_Post|null $post Optional. Post ID or post object. Default is global `$post` object.
92+
* @return string|null The author's display name. Empty string if user is unavailable. Null if there was no last editor or the post is invalid.
9193
*/
92-
function get_the_modified_author() {
93-
$last_id = get_post_meta( get_post()->ID, '_edit_last', true );
94-
95-
if ( $last_id ) {
96-
$last_user = get_userdata( $last_id );
94+
function get_the_modified_author( $post = null ) {
95+
$post = get_post( $post );
96+
if ( ! $post ) {
97+
return null;
98+
}
9799

98-
/**
99-
* Filters the display name of the author who last edited the current post.
100-
*
101-
* @since 2.8.0
102-
*
103-
* @param string $display_name The author's display name, empty string if unknown.
104-
*/
105-
return apply_filters( 'the_modified_author', $last_user ? $last_user->display_name : '' );
100+
$last_id = get_post_meta( $post->ID, '_edit_last', true );
101+
if ( ! $last_id ) {
102+
return null;
106103
}
104+
$last_user = get_userdata( $last_id );
105+
106+
/**
107+
* Filters the display name of the author who last edited the current post.
108+
*
109+
* @since 2.8.0
110+
*
111+
* @param string $display_name The author's display name, empty string if user is unavailable.
112+
*/
113+
return apply_filters( 'the_modified_author', $last_user ? $last_user->display_name : '' );
107114
}
108115

109116
/**

src/wp-includes/formatting.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
446446
function wpautop( $text, $br = true ) {
447447
$pre_tags = array();
448448

449-
if ( trim( $text ) === '' ) {
449+
if ( '' === trim( $text ) ) {
450450
return '';
451451
}
452452

@@ -1181,7 +1181,7 @@ function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters =
11811181
$unicode .= $encoded_char;
11821182
$unicode_length += $encoded_char_length;
11831183
} else {
1184-
if ( count( $values ) === 0 ) {
1184+
if ( 0 === count( $values ) ) {
11851185
if ( $value < 224 ) {
11861186
$num_octets = 2;
11871187
} elseif ( $value < 240 ) {
@@ -2294,10 +2294,10 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa
22942294
$title = strtolower( $title );
22952295

22962296
if ( 'save' === $context ) {
2297-
// Convert &nbsp, &ndash, and &mdash to hyphens.
2298-
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
2299-
// Convert &nbsp, &ndash, and &mdash HTML entities to hyphens.
2300-
$title = str_replace( array( '&nbsp;', '&#160;', '&ndash;', '&#8211;', '&mdash;', '&#8212;' ), '-', $title );
2297+
// Convert &nbsp, non-breaking hyphen, &ndash, and &mdash to hyphens.
2298+
$title = str_replace( array( '%c2%a0', '%e2%80%91', '%e2%80%93', '%e2%80%94' ), '-', $title );
2299+
// Convert &nbsp, non-breaking hyphen, &ndash, and &mdash HTML entities to hyphens.
2300+
$title = str_replace( array( '&nbsp;', '&#8209;', '&#160;', '&ndash;', '&#8211;', '&mdash;', '&#8212;' ), '-', $title );
23012301
// Convert forward slash to hyphen.
23022302
$title = str_replace( '/', '-', $title );
23032303

@@ -2558,7 +2558,7 @@ function convert_invalid_entities( $content ) {
25582558
* @return string Balanced text.
25592559
*/
25602560
function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
2561-
if ( $force || (int) get_option( 'use_balanceTags' ) === 1 ) {
2561+
if ( $force || 1 === (int) get_option( 'use_balanceTags' ) ) {
25622562
return force_balance_tags( $text );
25632563
} else {
25642564
return $text;
@@ -2999,7 +2999,7 @@ function _make_web_ftp_clickable_cb( $matches ) {
29992999

30003000
// Removed trailing [.,;:)] from URL.
30013001
$last_char = substr( $dest, -1 );
3002-
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) {
3002+
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) ) {
30033003
$ret = $last_char;
30043004
$dest = substr( $dest, 0, strlen( $dest ) - 1 );
30053005
}
@@ -3326,7 +3326,7 @@ function wp_targeted_link_rel( $text ) {
33263326
_deprecated_function( __FUNCTION__, '6.7.0' );
33273327

33283328
// Don't run (more expensive) regex if no links with targets.
3329-
if ( stripos( $text, 'target' ) === false || stripos( $text, '<a ' ) === false || is_serialized( $text ) ) {
3329+
if ( false === stripos( $text, 'target' ) || false === stripos( $text, '<a ' ) || is_serialized( $text ) ) {
33303330
return $text;
33313331
}
33323332

@@ -3446,7 +3446,7 @@ function wp_remove_targeted_link_rel_filters() {
34463446
function translate_smiley( $matches ) {
34473447
global $wpsmiliestrans;
34483448

3449-
if ( count( $matches ) === 0 ) {
3449+
if ( 0 === count( $matches ) ) {
34503450
return '';
34513451
}
34523452

@@ -3572,7 +3572,7 @@ function is_email( $email, $deprecated = false ) {
35723572
}
35733573

35743574
// Test for an @ character after the first position.
3575-
if ( strpos( $email, '@', 1 ) === false ) {
3575+
if ( false === strpos( $email, '@', 1 ) ) {
35763576
/** This filter is documented in wp-includes/formatting.php */
35773577
return apply_filters( 'is_email', false, $email, 'email_no_at' );
35783578
}
@@ -3786,7 +3786,7 @@ function sanitize_email( $email ) {
37863786
}
37873787

37883788
// Test for an @ character after the first position.
3789-
if ( strpos( $email, '@', 1 ) === false ) {
3789+
if ( false === strpos( $email, '@', 1 ) ) {
37903790
/** This filter is documented in wp-includes/formatting.php */
37913791
return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
37923792
}
@@ -5362,7 +5362,7 @@ function wp_sprintf_l( $pattern, $args ) {
53625362

53635363
$args = (array) $args;
53645364
$result = array_shift( $args );
5365-
if ( count( $args ) === 1 ) {
5365+
if ( 1 === count( $args ) ) {
53665366
$result .= $l['between_only_two'] . array_shift( $args );
53675367
}
53685368

src/wp-includes/general-template.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,9 +3326,13 @@ function feed_links_extra( $args = array() ) {
33263326
*/
33273327
$args = apply_filters( 'feed_links_extra_args', $args );
33283328

3329-
if ( is_singular() ) {
3330-
$id = 0;
3331-
$post = get_post( $id );
3329+
/*
3330+
* The template conditionals are referring to the global query, so the queried object is used rather than
3331+
* depending on a global $post being set.
3332+
*/
3333+
$queried_object = get_queried_object();
3334+
if ( is_singular() && $queried_object instanceof WP_Post ) {
3335+
$post = $queried_object;
33323336

33333337
/** This filter is documented in wp-includes/general-template.php */
33343338
$show_comments_feed = apply_filters( 'feed_links_show_comments_feed', true );
@@ -3348,12 +3352,17 @@ function feed_links_extra( $args = array() ) {
33483352
*/
33493353
$show_post_comments_feed = apply_filters( 'feed_links_extra_show_post_comments_feed', $show_comments_feed );
33503354

3351-
if ( $show_post_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) {
3355+
if ( $show_post_comments_feed && ( comments_open( $post ) || pings_open( $post ) || (int) $post->comment_count > 0 ) ) {
33523356
$title = sprintf(
33533357
$args['singletitle'],
33543358
get_bloginfo( 'name' ),
33553359
$args['separator'],
3356-
the_title_attribute( array( 'echo' => false ) )
3360+
the_title_attribute(
3361+
array(
3362+
'echo' => false,
3363+
'post' => $post,
3364+
)
3365+
)
33573366
);
33583367

33593368
$feed_link = get_post_comments_feed_link( $post->ID );

src/wp-includes/script-loader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,7 +2869,7 @@ function wp_enqueue_editor_format_library_assets() {
28692869
* @return string String made of sanitized `<script>` tag attributes.
28702870
*/
28712871
function wp_sanitize_script_attributes( $attributes ) {
2872-
$html5_script_support = ! is_admin() && ! current_theme_supports( 'html5', 'script' );
2872+
$html5_script_support = is_admin() || current_theme_supports( 'html5', 'script' );
28732873
$attributes_string = '';
28742874

28752875
/*
@@ -2879,7 +2879,7 @@ function wp_sanitize_script_attributes( $attributes ) {
28792879
foreach ( $attributes as $attribute_name => $attribute_value ) {
28802880
if ( is_bool( $attribute_value ) ) {
28812881
if ( $attribute_value ) {
2882-
$attributes_string .= $html5_script_support ? sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_name ) ) : ' ' . esc_attr( $attribute_name );
2882+
$attributes_string .= $html5_script_support ? ' ' . esc_attr( $attribute_name ) : sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_name ) );
28832883
}
28842884
} else {
28852885
$attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) );

src/wp-includes/theme-templates.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_id
5050
}
5151

5252
// For wp_template, slugs no longer have to be unique within the same theme.
53-
if ( 'wp_template' !== $post_type ) {
54-
return $override_slug;
53+
if ( 'wp_template' === $post_type ) {
54+
return $slug;
5555
}
5656

5757
if ( ! $override_slug ) {

tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ public function test_replaces_ndash_mdash_entities() {
8585
$this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do &mdash; the &#8212; Dash', '', 'save' ) );
8686
}
8787

88+
/**
89+
* @ticket 64089
90+
*/
91+
public function test_replaces_non_breaking_hyphen() {
92+
$this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do‑the Dash', '', 'save' ) );
93+
}
94+
95+
/**
96+
* @ticket 64089
97+
*/
98+
public function test_replaces_non_breaking_hyphen_entity() {
99+
$this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do &#8209; the Dash', '', 'save' ) );
100+
}
101+
88102
public function test_replaces_iexcel_iquest() {
89103
$this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) );
90104
$this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) );

tests/phpunit/tests/general/feedLinksExtra.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,15 @@ public function data_feed_links_extra_should_output_nothing_when_filters_return_
634634
),
635635
);
636636
}
637+
638+
/**
639+
* @ticket 63263
640+
*/
641+
public function test_feed_links_extra_should_work_fail_if_global_post_empty() {
642+
$post_id = self::factory()->post->create();
643+
$this->go_to( get_permalink( $post_id ) );
644+
$GLOBALS['post'] = null;
645+
646+
$this->assertNotEmpty( get_echo( 'feed_links_extra' ) );
647+
}
637648
}

0 commit comments

Comments
 (0)