Make WordPress Core

Changeset 61108


Ignore:
Timestamp:
10/31/2025 11:21:37 PM (6 weeks ago)
Author:
joedolson
Message:

Themes: Prevent PHP notice thrown in wp_title_parts.

The value passed to the wp_title_parts filter is run through explode(), but can be empty. This throws a PHP notice.

If value of $title is empty, return an empty array without exploding.

Props nexbridge, dhruvang21, tussendoor, michaelreetz, o-o, beee, sabernhardt, sirlouen, nimeshatxecurify, westonruter, sirlouen.
Fixes #61352.

File:
1 edited

Legend:

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

    r61058 r61108  
    14371437     * @param string[] $title_array Array of parts of the page title.
    14381438     */
    1439     $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
     1439    $title_array = apply_filters( 'wp_title_parts', ! empty( $title ) ? explode( $t_sep, $title ) : array() );
    14401440
    14411441    // Determines position of the separator and direction of the breadcrumb.
Note: See TracChangeset for help on using the changeset viewer.