Allow widget forms to work standalone, without being inside the customizer control context#26
Merged
Merged
Conversation
…to allow for Shortcake or frontend integrations * Remove the passing of the WidgetControl as a property when constructing a Form; instead pass the model (which can be a Setting or a Value) and id_base directly, the latter of which should already be located on the Form prototype along with the config. * Replace wp.customize.Widgets.formConstructor with wp.widgets.formConstructor.archives * Replace wp.customize.Widgets.Form with wp.widgets.Form * Eliminate exporting all form configs to CustomizeJSWidgets.data.form_configs and instead attach to From prototypes. * Fix initialization of Pages widget in how it amends the default config. * Add Form.notifications * Rename script handles to be more appropriate.
* Converts/renames WP_JS_Widget::form_template() into wrapper method WP_JS_Widget::render_form_template_scripts() which outputs the script tags. * Splits out form template contents into `WP_JS_Widget::render_form_template()`. * Eliminates extraneous `id_base` property for JS Form class, adding `template_id` form config which is then sourced from a new WP_JS_Widget::get_form_template_id(), which in turn is used by WP_JS_Widget::render_form_template_scripts() and is used in the JS Form#getTemplate() method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove forms dependency on customize-widgets; allow standalone forms to allow for Shortcake or frontend integrations
WidgetControlas a property when constructing a Form; instead pass the model(which can be a Setting or a Value) and id_base directly, the latter of which should already be located
on the Form prototype along with the config.
wp.customize.Widgets.formConstructorwithwp.widgets.formConstructorwp.customize.Widgets.Formwithwp.widgets.FormWP_JS_Widget::render_form_template_scripts()which outputs the script tags.WP_JS_Widget::render_form_template().id_baseproperty for JS Form class, addingtemplate_idform config which is then sourced from a newWP_JS_Widget::get_form_template_id(), which in turn is used byWP_JS_Widget::render_form_template_scripts()and is used in the JSForm#getTemplatemethod.Todo:
Allow JS widgets to work on the widgets admin screen.Restore ability forupdatemethod to be invoked. IfsanitizereturnsWP_Errorthen returnfalse.This is a dependency for #11, to integrate with Shortcake.