Skip to content

Commit 5d7ccb0

Browse files
committedFeb 14, 2017
Ensure that id_base is defined on widget form prototypes
1 parent 067c045 commit 5d7ccb0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

‎js/widget-form.js

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ wp.widgets.Form = (function( api, $, _ ) {
4040
initialize: function initialize( properties ) {
4141
var form = this;
4242

43+
if ( ! form.id_base ) {
44+
throw new Error( 'Missing id_base' );
45+
}
46+
4347
_.extend( form, getValidatedFormProperties( form.config, properties ) );
4448

4549
form.setting = form.model; // @todo Deprecate 'setting' name in favor of 'model'?

‎php/class-wp-adapter-js-widget.php

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public function enqueue_control_scripts() {
8787
wp_json_encode( $this->id_base ),
8888
wp_json_encode( $this->get_form_config() )
8989
) );
90+
wp_add_inline_script( $handle, sprintf(
91+
'wp.widgets.formConstructor[ %s ].prototype.id_base = %s;',
92+
wp_json_encode( $this->id_base ),
93+
wp_json_encode( $this->id_base )
94+
) );
9095
}
9196

9297
/**

0 commit comments

Comments
 (0)