| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* Class PLL_Widgets_Filters |
| 8 |
* |
| 9 |
* @since 3.0 |
| 10 |
* |
| 11 |
* Adds new options to {@see https://developer.wordpress.org/reference/classes/wp_widget/ WP_Widget} and saves them. |
| 12 |
*/ |
| 13 |
class PLL_Admin_Filters_Widgets_Options extends PLL_Filters_Widgets_Options { |
| 14 |
/** |
| 15 |
* Modifies the widgets forms to add our language dropdown list. |
| 16 |
* |
| 17 |
* @since 0.3 |
| 18 |
* @since 3.0 Moved from PLL_Admin_Filters |
| 19 |
* |
| 20 |
* @param WP_Widget $widget Widget instance. |
| 21 |
* @param null $return Not used. |
| 22 |
* @param array $instance Widget settings. |
| 23 |
* @return void |
| 24 |
* |
| 25 |
* @phpstan-param WP_Widget<array<string, mixed>> $widget |
| 26 |
*/ |
| 27 |
public function in_widget_form( $widget, $return, $instance ) { |
| 28 |
$screen = get_current_screen(); |
| 29 |
|
| 30 |
// Test the Widgets screen and the Customizer to avoid displaying the option in page builders |
| 31 |
// Saving the widget reloads the form. And curiously the action is in $_REQUEST but neither in $_POST, nor in $_GET. |
| 32 |
if ( ( isset( $screen ) && 'widgets' === $screen->base ) || ( isset( $_REQUEST['action'] ) && 'save-widget' === $_REQUEST['action'] ) || isset( $GLOBALS['wp_customize'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 33 |
parent::in_widget_form( $widget, $return, $instance ); |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|