PluginProbe
Polylang / 2.5
Polylang v2.5
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-filters.php +19 -47 2.7.22.5 View file →
@@ -41,11 +41,8 @@
41 41 add_filter( 'sanitize_user', array( $this, 'sanitize_user' ), 10, 3 );
42 42 }
43 43
44 44 add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
45 -
46 - // Add post state for translations of the privacy policy page
47 - add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 );
48 45 }
49 46
50 47 /**
51 48 * Modifies the widgets forms to add our language dropdown list
@@ -59,30 +56,26 @@
59 56 public function in_widget_form( $widget, $return, $instance ) {
60 57 $screen = get_current_screen();
61 58
62 59 // Test the Widgets screen and the Customizer to avoid displaying the option in page builders
63 - // Saving the widget reloads the form. And curiously the action is in $_REQUEST but neither in $_POST, nor in $_GET.
64 - if ( ( isset( $screen ) && 'widgets' === $screen->base ) || ( isset( $_REQUEST['action'] ) && 'save-widget' === $_REQUEST['action'] ) || isset( $GLOBALS['wp_customize'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
60 + // Saving the widget reloads the form. And curiously the action is in $_REQUEST but neither in $_POST, not in $_GET.
61 + if ( ( isset( $screen ) && 'widgets' === $screen->base ) || ( isset( $_REQUEST['action'] ) && 'save-widget' === $_REQUEST['action'] ) || isset( $GLOBALS['wp_customize'] ) ) {
65 62 $dropdown = new PLL_Walker_Dropdown();
66 -
67 - $dropdown_html = $dropdown->walk(
68 - array_merge(
69 - array( (object) array( 'slug' => 0, 'name' => __( 'All languages', 'polylang' ) ) ),
70 - $this->model->get_languages_list()
71 - ),
72 - -1,
73 - array(
74 - 'name' => $widget->id . '_lang_choice',
75 - 'class' => 'tags-input pll-lang-choice',
76 - 'selected' => empty( $instance['pll_lang'] ) ? '' : $instance['pll_lang'],
77 - )
78 - );
79 -
80 63 printf(
81 64 '<p><label for="%1$s">%2$s %3$s</label></p>',
82 65 esc_attr( $widget->id . '_lang_choice' ),
83 66 esc_html__( 'The widget is displayed for:', 'polylang' ),
84 - $dropdown_html // phpcs:ignore WordPress.Security.EscapeOutput
67 + $dropdown->walk(
68 + array_merge(
69 + array( (object) array( 'slug' => 0, 'name' => __( 'All languages', 'polylang' ) ) ),
70 + $this->model->get_languages_list()
71 + ),
72 + array(
73 + 'name' => $widget->id . '_lang_choice',
74 + 'class' => 'tags-input pll-lang-choice',
75 + 'selected' => empty( $instance['pll_lang'] ) ? '' : $instance['pll_lang'],
76 + )
77 + )
85 78 );
86 79 }
87 80 }
88 81
@@ -98,12 +91,10 @@
98 91 * @param object $widget WP_Widget object
99 92 * @return array Widget options
100 93 */
101 94 public function widget_update_callback( $instance, $new_instance, $old_instance, $widget ) {
102 - $key = $widget->id . '_lang_choice';
103 -
104 - if ( ! empty( $_POST[ $key ] ) && $lang = $this->model->get_language( sanitize_key( $_POST[ $key ] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
105 - $instance['pll_lang'] = $lang->slug;
95 + if ( ! empty( $_POST[ $key = $widget->id . '_lang_choice' ] ) && in_array( $_POST[ $key ], $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) ) {
96 + $instance['pll_lang'] = $_POST[ $key ];
106 97 } else {
107 98 unset( $instance['pll_lang'] );
108 99 }
109 100
@@ -120,9 +111,9 @@
120 111 public function personal_options_update( $user_id ) {
121 112 // Biography translations
122 113 foreach ( $this->model->get_languages_list() as $lang ) {
123 114 $meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
124 - $description = empty( $_POST[ 'description_' . $lang->slug ] ) ? '' : trim( $_POST[ 'description_' . $lang->slug ] ); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput
115 + $description = empty( $_POST[ 'description_' . $lang->slug ] ) ? '' : trim( $_POST[ 'description_' . $lang->slug ] );
125 116
126 117 /** This filter is documented in wp-includes/user.php */
127 118 $description = apply_filters( 'pre_user_description', $description ); // Applies WP default filter wp_filter_kses
128 119 update_user_meta( $user_id, $meta, $description );
@@ -191,13 +182,13 @@
191 182 * @param string $locale
192 183 * @return string
193 184 */
194 185 public function get_locale( $locale ) {
195 - if ( isset( $_POST['post_lang_choice'] ) && $lang = $this->model->get_language( sanitize_key( $_POST['post_lang_choice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
186 + if ( isset( $_POST['post_lang_choice'] ) && $lang = $this->model->get_language( $_POST['post_lang_choice'] ) ) {
196 187 $locale = $lang->locale;
197 - } elseif ( isset( $_POST['term_lang_choice'] ) && $lang = $this->model->get_language( sanitize_key( $_POST['term_lang_choice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
188 + } elseif ( isset( $_POST['term_lang_choice'] ) && $lang = $this->model->get_language( $_POST['term_lang_choice'] ) ) {
198 189 $locale = $lang->locale;
199 - } elseif ( isset( $_POST['inline_lang_choice'] ) && $lang = $this->model->get_language( sanitize_key( $_POST['inline_lang_choice'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
190 + } elseif ( isset( $_POST['inline_lang_choice'] ) && $lang = $this->model->get_language( $_POST['inline_lang_choice'] ) ) {
200 191 $locale = $lang->locale;
201 192 } elseif ( ! empty( $this->curlang ) ) {
202 193 $locale = $this->curlang->locale;
203 194 }
@@ -266,25 +257,6 @@
266 257 if ( ! empty( $this->curlang ) ) {
267 258 $classes .= ' pll-dir-' . ( $this->curlang->is_rtl ? 'rtl' : 'ltr' );
268 259 }
269 260 return $classes;
270 - }
271 -
272 - /**
273 - * Add post state for translations of the privacy policy page
274 - *
275 - * @since 2.7
276 - *
277 - * @param array $post_states An array of post display states.
278 - * @param object $post The current post object.
279 - * @return array
280 - */
281 - public function display_post_states( $post_states, $post ) {
282 - $page_for_privacy_policy = get_option( 'wp_page_for_privacy_policy' );
283 -
284 - if ( $page_for_privacy_policy && in_array( $post->ID, $this->model->post->get_translations( $page_for_privacy_policy ) ) ) {
285 - $post_states['page_for_privacy_policy'] = __( 'Privacy Policy Page', 'polylang' );
286 - }
287 -
288 - return $post_states;
289 261 }
290 262 }