Skip to content

Additional hook on 'editor_get_wp_widget_form' success #1886

@MjHead

Description

@MjHead

Hi guys, thanks for great and clean-coded plugin first of all! At second - can you please research ability to add one tine feature, that can be very helpful for developers, who uses Elementor. Detailed:

1. The Problem

If theme or plugin has own widgets, them automatically added to WordPress section in editor. When user inserts this widget into page, widget's controls form renders on back-end on elementor_editor_get_wp_widget_form. If widget uses simple controls - all fine, but if widget use some complex controls, like Media Upload button for example - not always has possibility to initialize JS events for this controls. In last release you have added fix for the same problem for new WP core widgets - media and rich-editable text. But would be great if would be universal solution for such widgets.

2. Possible solution

Specific hook on AJAX success callback could be such solution, for example after this code - https://github.com/pojome/elementor/blob/master/assets/js/editor.js#L9020-L9024. I tried to add such hook. I added following code after https://github.com/pojome/elementor/blob/master/assets/js/editor.js#L9024:

elementor.hooks.doAction( 'panel/open_editor/wp_widget_form/' + this.model.get( 'widget' ), this );

Than I could add callback for this hook into my script (example):

elementor.hooks.addAction( 'panel/open_editor/wp_widget_form/wp-widget-my_widget_about', function( panel ) {

	if ( panel.ui.form.length ) {
		$( 'body' ).trigger( {
			type: 'my-ui-elements-init-trigger',
			_target: panel.ui.form
		} );
	}

} );

Existing hooks panel/open_editor/{elementType} and panel/open_editor/{elementType}/{elementName} are triggering after AJAX send, but before AJAX success, so developers can't perform any operations with widgets forms content on this hooks. So additional hook on AJAX success make this part of editor more flexible for developers.

Thanks, Andrew.

Metadata

Metadata

Assignees

Labels

type/developer-apiIndicates when a topic is related to the Developer API and Documentation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions