Make WordPress Core

Ticket #47704: 47704-add_theme_support.patch

File 47704-add_theme_support.patch, 2.4 KB (added by jrf, 6 years ago)

PHP 7.4/array-access: Fix add_theme_support() - fixes 15 errors

  • src/wp-includes/theme.php

    From b33b29293b8df8e8d9234669b6485e9eadbaa4cc Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Mon, 15 Jul 2019 00:11:34 +0200
    Subject: [PATCH] PHP 7.4/array-access: Fix add_theme_support()
    
    ---
     src/wp-includes/theme.php | 12 ++++++------
     1 file changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
    index f7f061d351..eddd76684a 100644
    a b function add_theme_support( $feature, ...$args ) { 
    23712371                         * Merge post types with any that already declared their support
    23722372                         * for post thumbnails.
    23732373                         */
    2374                         if ( is_array( $args[0] ) && isset( $_wp_theme_features['post-thumbnails'] ) ) {
     2374                        if ( isset( $args[0] ) && is_array( $args[0] ) && isset( $_wp_theme_features['post-thumbnails'] ) ) {
    23752375                                $args[0] = array_unique( array_merge( $_wp_theme_features['post-thumbnails'][0], $args[0] ) );
    23762376                        }
    23772377
    23782378                        break;
    23792379
    23802380                case 'post-formats':
    2381                         if ( is_array( $args[0] ) ) {
     2381                        if ( isset( $args[0] ) && is_array( $args[0] ) ) {
    23822382                                $post_formats = get_post_format_slugs();
    23832383                                unset( $post_formats['standard'] );
    23842384
    function add_theme_support( $feature, ...$args ) { 
    23912391                        if ( empty( $args[0] ) ) {
    23922392                                // Build an array of types for back-compat.
    23932393                                $args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) );
    2394                         } elseif ( ! is_array( $args[0] ) ) {
     2394                        } elseif ( ! isset( $args[0] ) || ! is_array( $args[0] ) ) {
    23952395                                _doing_it_wrong( "add_theme_support( 'html5' )", __( 'You need to pass an array of types.' ), '3.6.1' );
    23962396                                return false;
    23972397                        }
    function add_theme_support( $feature, ...$args ) { 
    24032403                        break;
    24042404
    24052405                case 'custom-logo':
    2406                         if ( ! is_array( $args ) ) {
     2406                        if ( true === $args ) {
    24072407                                $args = array( 0 => array() );
    24082408                        }
    24092409                        $defaults = array(
    function add_theme_support( $feature, ...$args ) { 
    24262426                        return add_theme_support( 'custom-header', array( 'uploads' => true ) );
    24272427
    24282428                case 'custom-header':
    2429                         if ( ! is_array( $args ) ) {
     2429                        if ( true === $args ) {
    24302430                                $args = array( 0 => array() );
    24312431                        }
    24322432
    function add_theme_support( $feature, ...$args ) { 
    25162516                        break;
    25172517
    25182518                case 'custom-background':
    2519                         if ( ! is_array( $args ) ) {
     2519                        if ( true === $args ) {
    25202520                                $args = array( 0 => array() );
    25212521                        }
    25222522