Skip to content

Commit

Permalink
Possible fix for issue htmlburger#1261
Browse files Browse the repository at this point in the history
This is backwards compatible with 7.x and forwards compatible with 8.x
  • Loading branch information
c0ntax committed Oct 24, 2024
1 parent 932ec6e commit 859b640
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/Widget/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
abstract class Widget extends \WP_Widget {
public static $registered_widget_ids = array();
private $registered_field_names = array();

/**
* Widget Datastore
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 859b640

Please sign in to comment.