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/src/wp-includes/theme.php
+++ b/src/wp-includes/theme.php
@@ -2371,14 +2371,14 @@ function add_theme_support( $feature, ...$args ) {
 			 * Merge post types with any that already declared their support
 			 * for post thumbnails.
 			 */
-			if ( is_array( $args[0] ) && isset( $_wp_theme_features['post-thumbnails'] ) ) {
+			if ( isset( $args[0] ) && is_array( $args[0] ) && isset( $_wp_theme_features['post-thumbnails'] ) ) {
 				$args[0] = array_unique( array_merge( $_wp_theme_features['post-thumbnails'][0], $args[0] ) );
 			}
 
 			break;
 
 		case 'post-formats':
-			if ( is_array( $args[0] ) ) {
+			if ( isset( $args[0] ) && is_array( $args[0] ) ) {
 				$post_formats = get_post_format_slugs();
 				unset( $post_formats['standard'] );
 
@@ -2391,7 +2391,7 @@ function add_theme_support( $feature, ...$args ) {
 			if ( empty( $args[0] ) ) {
 				// Build an array of types for back-compat.
 				$args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) );
-			} elseif ( ! is_array( $args[0] ) ) {
+			} elseif ( ! isset( $args[0] ) || ! is_array( $args[0] ) ) {
 				_doing_it_wrong( "add_theme_support( 'html5' )", __( 'You need to pass an array of types.' ), '3.6.1' );
 				return false;
 			}
@@ -2403,7 +2403,7 @@ function add_theme_support( $feature, ...$args ) {
 			break;
 
 		case 'custom-logo':
-			if ( ! is_array( $args ) ) {
+			if ( true === $args ) {
 				$args = array( 0 => array() );
 			}
 			$defaults = array(
@@ -2426,7 +2426,7 @@ function add_theme_support( $feature, ...$args ) {
 			return add_theme_support( 'custom-header', array( 'uploads' => true ) );
 
 		case 'custom-header':
-			if ( ! is_array( $args ) ) {
+			if ( true === $args ) {
 				$args = array( 0 => array() );
 			}
 
@@ -2516,7 +2516,7 @@ function add_theme_support( $feature, ...$args ) {
 			break;
 
 		case 'custom-background':
-			if ( ! is_array( $args ) ) {
+			if ( true === $args ) {
 				$args = array( 0 => array() );
 			}
 
-- 
2.21.0.windows.1

