PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
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 | settings/table-string.php +17 -54 3.0.22.6.2 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 if ( ! class_exists( 'WP_List_Table' ) ) {
7 4 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
8 5 }
@@ -13,42 +10,16 @@
13 10 *
14 11 * @since 0.6
15 12 */
16 13 class PLL_Table_String extends WP_List_Table {
17 - /**
18 - * The list of languages.
19 - *
20 - * @var PLL_Language[]
21 - */
22 - protected $languages;
14 + protected $languages, $strings, $groups, $selected_group;
23 15
24 16 /**
25 - * Registered strings.
17 + * Constructor
26 18 *
27 - * @var array
28 - */
29 - protected $strings;
30 -
31 - /**
32 - * The string groups.
33 - *
34 - * @var string[]
35 - */
36 - protected $groups;
37 -
38 - /**
39 - * The selected string group or -1 if none is selected.
40 - *
41 - * @var string|int
42 - */
43 - protected $selected_group;
44 -
45 - /**
46 - * Constructor.
47 - *
48 19 * @since 0.6
49 20 *
50 - * @param PLL_Language[] $languages List of languages.
21 + * @param array $languages list of languages
51 22 */
52 23 public function __construct( $languages ) {
53 24 parent::__construct(
54 25 array(
@@ -144,17 +115,17 @@
144 115 return $out;
145 116 }
146 117
147 118 /**
148 - * Gets the list of columns.
119 + * Gets the list of columns
149 120 *
150 121 * @since 0.6
151 122 *
152 - * @return string[] The list of column titles.
123 + * @return array the list of column titles
153 124 */
154 125 public function get_columns() {
155 126 return array(
156 - 'cb' => '<input type="checkbox" />', // Checkbox.
127 + 'cb' => '<input type="checkbox" />', // Checkbox
157 128 'string' => esc_html__( 'String', 'polylang' ),
158 129 'name' => esc_html__( 'Name', 'polylang' ),
159 130 'context' => esc_html__( 'Group', 'polylang' ),
160 131 'translations' => esc_html__( 'Translations', 'polylang' ),
@@ -191,11 +162,11 @@
191 162 * Search for a string in translations. Case insensitive.
192 163 *
193 164 * @since 2.6
194 165 *
195 - * @param PLL_MO[] $mos An array of PLL_MO objects.
196 - * @param string $s Searched string.
197 - * @return string[] Found strings.
166 + * @param array $mos An array of PLL_MO objects
167 + * @param string $s Searched string
168 + * @return array Found strings
198 169 */
199 170 protected function search_in_translations( $mos, $s ) {
200 171 $founds = array();
201 172
@@ -234,10 +205,8 @@
234 205 /**
235 206 * Prepares the list of items for displaying
236 207 *
237 208 * @since 0.6
238 - *
239 - * @return void
240 209 */
241 210 public function prepare_items() {
242 211 // Is admin language filter active?
243 212 if ( $lg = get_user_meta( get_current_user_id(), 'pll_filter_content', true ) ) {
@@ -246,9 +215,8 @@
246 215 $languages = $this->languages;
247 216 }
248 217
249 218 // Load translations
250 - $mo = array();
251 219 foreach ( $languages as $language ) {
252 220 $mo[ $language->slug ] = new PLL_MO();
253 221 $mo[ $language->slug ]->import_from_db( $language );
254 222 }
@@ -302,13 +270,13 @@
302 270 }
303 271 }
304 272
305 273 /**
306 - * Get the list of possible bulk actions.
274 + * Get the list of possible bulk actions
307 275 *
308 276 * @since 1.1
309 277 *
310 - * @return string[] Array of bulk actions.
278 + * @return array
311 279 */
312 280 public function get_bulk_actions() {
313 281 return array( 'delete' => __( 'Delete', 'polylang' ) );
314 282 }
@@ -330,9 +298,8 @@
330 298 *
331 299 * @since 1.1
332 300 *
333 301 * @param string $which only 'top' is supported
334 - * @return void
335 302 */
336 303 public function extra_tablenav( $which ) {
337 304 if ( 'top' !== $which ) {
338 305 return;
@@ -346,9 +313,9 @@
346 313 );
347 314 echo '<select id="select-group" name="group">' . "\n";
348 315 printf(
349 316 '<option value="-1"%s>%s</option>' . "\n",
350 - selected( $this->selected_group, -1, false ),
317 + selected( $this->group_selected, -1, false ),
351 318 esc_html__( 'View all groups', 'polylang' )
352 319 );
353 320
354 321 foreach ( $this->groups as $group ) {
@@ -369,10 +336,8 @@
369 336 * Saves the strings translations in DB
370 337 * Optionaly clean the DB
371 338 *
372 339 * @since 1.9
373 - *
374 - * @return void
375 340 */
376 341 public function save_translations() {
377 342 check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
378 343
@@ -377,9 +342,9 @@
377 342 check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
378 343
379 344 if ( ! empty( $_POST['submit'] ) ) {
380 345 foreach ( $this->languages as $language ) {
381 - if ( empty( $_POST['translation'][ $language->slug ] ) || ! is_array( $_POST['translation'][ $language->slug ] ) ) { // In case the language filter is active ( thanks to John P. Bloch )
346 + if ( empty( $_POST['translation'][ $language->slug ] ) ) { // In case the language filter is active ( thanks to John P. Bloch )
382 347 continue;
383 348 }
384 349
385 350 $mo = new PLL_MO();
@@ -384,20 +349,18 @@
384 349
385 350 $mo = new PLL_MO();
386 351 $mo->import_from_db( $language );
387 352
388 - $translations = array_map( 'trim', wp_unslash( $_POST['translation'][ $language->slug ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
389 - foreach ( $translations as $key => $translation ) {
353 + foreach ( $_POST['translation'][ $language->slug ] as $key => $translation ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
390 354 /**
391 355 * Filter the string translation before it is saved in DB
392 356 * Allows to sanitize strings registered with pll_register_string
393 357 *
394 358 * @since 1.6
395 - * @since 2.7 The translation passed to the filter is unslashed.
396 359 *
397 - * @param string $translation The string translation.
398 - * @param string $name The name as defined in pll_register_string.
399 - * @param string $context The context as defined in pll_register_string.
360 + * @param string $translation the string translation
361 + * @param string $name the name as defined in pll_register_string
362 + * @param string $context the context as defined in pll_register_string
400 363 */
401 364 $translation = apply_filters( 'pll_sanitize_string_translation', $translation, $this->strings[ $key ]['name'], $this->strings[ $key ]['context'] );
402 365 $mo->add_entry( $mo->make_entry( $this->strings[ $key ]['string'], $translation ) );
403 366 }