From 2be5005607d6bc3609ce09b68d7009945520c83f Mon Sep 17 00:00:00 2001 From: Kurt Zenisek Date: Wed, 1 Dec 2021 15:02:17 -0600 Subject: [PATCH] Prevent fatal error with newer PHP versions Simply using count() throws an error if that variable is empty since something that's empty isn't seen as countable (TypeError). Check if it's not empty first to avoid the error. --- admin-bar-color.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin-bar-color.php b/admin-bar-color.php index 2ce083d..1ecff2c 100644 --- a/admin-bar-color.php +++ b/admin-bar-color.php @@ -3,7 +3,7 @@ Plugin Name: Admin Bar Color Plugin URI: http://github.com/eduardozulian/admin-bar-color Description: Use your favorite Dashboard color scheme on the front end admin bar. -Version: 1.2 +Version: 1.2.0.1 Author: Eduardo Zulian Author URI: http://zulian.org License: GNU General Public License v2 or later @@ -28,7 +28,7 @@ function __construct() { function save_wp_admin_color_schemes_list() { global $_wp_admin_css_colors; - if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) { + if ( !empty( $_wp_admin_css_colors ) && count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) { update_option( 'wp_admin_color_schemes', $_wp_admin_css_colors ); } }