From 3ea38b0fb2dd8f79fd32cb653b44ede4bd25687e Mon Sep 17 00:00:00 2001 From: "Stephen A. Bernhardt" Date: Sat, 8 Nov 2025 23:16:49 -0600 Subject: [PATCH 1/2] Check `is_string()` and then use empty string for comparison --- src/wp-includes/general-template.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index acc3d611a6ef0..2a739b594436c 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -1424,8 +1424,12 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { $title = __( 'Page not found' ); } + if ( ! is_string( $title ) ) { + $title = ''; + } + $prefix = ''; - if ( ! empty( $title ) ) { + if ( '' !== $title ) { $prefix = " $sep "; } @@ -1436,7 +1440,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { * * @param string[] $title_array Array of parts of the page title. */ - $title_array = apply_filters( 'wp_title_parts', ! empty( $title ) ? explode( $t_sep, $title ) : array() ); + $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); // Determines position of the separator and direction of the breadcrumb. if ( 'right' === $seplocation ) { // Separator on right, so reverse the order. From da236b17f60a2741cf906e7a39e895b2358aa893 Mon Sep 17 00:00:00 2001 From: "Stephen A. Bernhardt" Date: Mon, 10 Nov 2025 15:46:04 -0600 Subject: [PATCH 2/2] Assign `$title_array` variable before filter for better readabilty --- src/wp-includes/general-template.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 2a739b594436c..640bc54c8e754 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -1428,9 +1428,11 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { $title = ''; } - $prefix = ''; + $prefix = ''; + $title_array = array(); if ( '' !== $title ) { - $prefix = " $sep "; + $prefix = " $sep "; + $title_array = explode( $t_sep, $title ); } /** @@ -1440,7 +1442,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { * * @param string[] $title_array Array of parts of the page title. */ - $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); + $title_array = apply_filters( 'wp_title_parts', $title_array ); // Determines position of the separator and direction of the breadcrumb. if ( 'right' === $seplocation ) { // Separator on right, so reverse the order.