#27603 closed defect (bug) (invalid)
fields added with action 'in_widget_form' disappear after update in customizer
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9 |
Component: | Widgets | Keywords: | |
Focuses: | Cc: |
Description
I just started testing the new widget preview in customizer. I add a field to all widgets forms using the action 'in_widget_form'. In customizer, the field is correctly displayed at first but disappears after the widget has been updated.
Change History (5)
#2
@
9 years ago
For comparison, the Jetpack Widget Visibility module uses the in_widget_form
to inject new fields, but they are not lost upon updating the widget.
#3
@
9 years ago
There is nothing private. the plugin is Polylang.
In a class PLL_Admin_Filters, I have the method:
public function in_widget_form($widget) { $dropdown = new PLL_Walker_Dropdown(); printf('<p><label for="%1$s">%2$s %3$s</label></p>', esc_attr( $widget->id.'_lang_choice'), __('The widget is displayed for:', 'polylang'), $dropdown->walk( array_merge( array((object) array('slug' => 0, 'name' => __('All languages', 'polylang'))), $this->model->get_languages_list() ), array( 'name' => $widget->id.'_lang_choice', 'class' => 'tags-input', 'selected' => empty($this->options['widgets'][$widget->id]) ? '' : $this->options['widgets'][$widget->id] ) ) ); }
The method is hooked to the action in the class constructor
add_action('in_widget_form', array(&$this, 'in_widget_form'));
However, looking back at my code I see that the object itself is created in a method hooked to 'wp_loaded'. Could it be too late?
I will look at jetpack to compare.
#4
@
9 years ago
- Resolution set to invalid
- Status changed from new to closed
I confirm that it works with Jetpack. Making further tests show that replacing 'wp_loaded' by 'init' as done in Jetpack does not change anything for Polylang. I now believe that this is a Polylang bug which does not load correctly on ajax request made by the customizer. Sorry for bothering you with this. I propose to close the ticket as invalid.
@Chouby Can you share the full code you're using, including the
in_widget_form
action usage? If private, please send to weston at x-team.com