From 859b6408b2475e93eee7d07e5a23ebf907772054 Mon Sep 17 00:00:00 2001 From: Dan Burzynski Date: Thu, 24 Oct 2024 15:02:47 +0100 Subject: [PATCH] Possible fix for issue #1261 This is backwards compatible with 7.x and forwards compatible with 8.x --- core/Widget/Widget.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/Widget/Widget.php b/core/Widget/Widget.php index 3533e3f6..67ec00c9 100644 --- a/core/Widget/Widget.php +++ b/core/Widget/Widget.php @@ -12,6 +12,7 @@ */ abstract class Widget extends \WP_Widget { public static $registered_widget_ids = array(); + private $registered_field_names = array(); /** * Widget Datastore @@ -223,14 +224,12 @@ public function add_fields( $fields ) { * @return boolean */ public function register_field_name( $name ) { - static $registered_field_names = array(); - - if ( in_array( $name, $registered_field_names ) ) { + if ( in_array( $name, $this->registered_field_names ) ) { Incorrect_Syntax_Exception::raise( 'Field name "' . $name . '" already registered' ); return false; } - $registered_field_names[] = $name; + $this->registered_field_names[] = $name; return true; }