Make WordPress Core

Changeset 61198


Ignore:
Timestamp:
11/10/2025 10:29:26 PM (5 weeks ago)
Author:
joedolson
Message:

Themes: Improve type checking in wp_title.

Follow up to [61108].

Change type handling to ensure that falsey string values like 0 are correctly handled. Improves readability of underlying code by consolidating type checks and passing resulting array to the wp_title_parts filter.

Props tobiasbg, sabernhardt, sirlouen, wildworks, joedolson, mukesh27.
Fixes #61352.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r61108 r61198  
    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
     
    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.
Note: See TracChangeset for help on using the changeset viewer.