PluginProbe
Polylang / 3.6.7
Polylang v3.6.7
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 +27 -22 3.03.6.7 View file →
@@ -73,14 +73,14 @@
73 73 add_action( 'mlang_action_string-translation', array( $this, 'save_translations' ) );
74 74 }
75 75
76 76 /**
77 - * Displays the item information in a column ( default case )
77 + * Displays the item information in a column (default case).
78 78 *
79 79 * @since 0.6
80 80 *
81 - * @param array $item
82 - * @param string $column_name
81 + * @param array $item Data related to the current string.
82 + * @param string $column_name The current column name.
83 83 * @return string
84 84 */
85 85 public function column_default( $item, $column_name ) {
86 86 return $item[ $column_name ];
@@ -86,13 +86,13 @@
86 86 return $item[ $column_name ];
87 87 }
88 88
89 89 /**
90 - * Displays the checkbox in first column
90 + * Displays the checkbox in first column.
91 91 *
92 92 * @since 1.1
93 93 *
94 - * @param array $item
94 + * @param array $item Data related to the current string.
95 95 * @return string
96 96 */
97 97 public function column_cb( $item ) {
98 98 return sprintf(
@@ -99,36 +99,40 @@
99 99 '<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label><input id="cb-select-%1$s" type="checkbox" name="strings[]" value="%1$s" %3$s />',
100 100 esc_attr( $item['row'] ),
101 101 /* translators: accessibility text, %s is a string potentially in any language */
102 102 sprintf( __( 'Select %s', 'polylang' ), format_to_edit( $item['string'] ) ),
103 - empty( $item['icl'] ) ? 'disabled' : '' // Only strings registered with WPML API can be removed
103 + empty( $item['icl'] ) ? 'disabled' : '' // Only strings registered with WPML API can be removed.
104 104 );
105 105 }
106 106
107 107 /**
108 - * Displays the string to translate
108 + * Displays the string to translate.
109 109 *
110 110 * @since 1.0
111 111 *
112 - * @param array $item
112 + * @param array $item Data related to the current string.
113 113 * @return string
114 114 */
115 115 public function column_string( $item ) {
116 - return format_to_edit( $item['string'] ); // Don't interpret special chars for the string column
116 + return format_to_edit( $item['string'] ); // Don't interpret special chars for the string column.
117 117 }
118 118
119 119 /**
120 - * Displays the translations to edit
120 + * Displays the translations to edit.
121 121 *
122 122 * @since 0.6
123 123 *
124 - * @param array $item
124 + * @param array $item Data related to the current string.
125 125 * @return string
126 126 */
127 127 public function column_translations( $item ) {
128 - $languages = array_combine( wp_list_pluck( $this->languages, 'slug' ), wp_list_pluck( $this->languages, 'name' ) );
129 - $out = '';
128 + $out = '';
129 + $languages = array();
130 130
131 + foreach ( $this->languages as $language ) {
132 + $languages[ $language->slug ] = $language->name;
133 + }
134 +
131 135 foreach ( $item['translations'] as $key => $translation ) {
132 136 $input_type = $item['multiline'] ?
133 137 '<textarea name="translation[%1$s][%2$s]" id="%1$s-%2$s">%4$s</textarea>' :
134 138 '<input type="text" name="translation[%1$s][%2$s]" id="%1$s-%2$s" value="%4$s" />';
@@ -136,9 +140,9 @@
136 140 '<div class="translation"><label for="%1$s-%2$s">%3$s</label>' . $input_type . '</div>' . "\n",
137 141 esc_attr( $key ),
138 142 esc_attr( $item['row'] ),
139 143 esc_html( $languages[ $key ] ),
140 - format_to_edit( $translation ) // Don't interpret special chars
144 + format_to_edit( $translation ) // Don't interpret special chars.
141 145 );
142 146 }
143 147
144 148 return $out;
@@ -210,14 +214,14 @@
210 214 return array_unique( $founds );
211 215 }
212 216
213 217 /**
214 - * Sort items
218 + * Sorts registered string items.
215 219 *
216 220 * @since 0.6
217 221 *
218 - * @param object $a The first object to compare
219 - * @param object $b The second object to compare
222 + * @param array $a The first item to compare.
223 + * @param array $b The second item to compare.
220 224 * @return int -1 or 1 if $a is considered to be respectively less than or greater than $b.
221 225 */
222 226 protected function usort_reorder( $a, $b ) {
223 227 if ( ! empty( $_GET['orderby'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
@@ -231,9 +235,9 @@
231 235 return 0;
232 236 }
233 237
234 238 /**
235 - * Prepares the list of items for displaying
239 + * Prepares the list of registered strings for display.
236 240 *
237 241 * @since 0.6
238 242 *
239 243 * @return void
@@ -287,9 +291,9 @@
287 291 $this->set_pagination_args(
288 292 array(
289 293 'total_items' => $total_items,
290 294 'per_page' => $per_page,
291 - 'total_pages' => ceil( $total_items / $per_page ),
295 + 'total_pages' => (int) ceil( $total_items / $per_page ),
292 296 )
293 297 );
294 298
295 299 // Translate strings
@@ -366,9 +370,9 @@
366 370 }
367 371
368 372 /**
369 373 * Saves the strings translations in DB
370 - * Optionaly clean the DB
374 + * Optionally clean the DB
371 375 *
372 376 * @since 1.9
373 377 *
374 378 * @return void
@@ -381,12 +385,13 @@
381 385 if ( empty( $_POST['translation'][ $language->slug ] ) || ! is_array( $_POST['translation'][ $language->slug ] ) ) { // In case the language filter is active ( thanks to John P. Bloch )
382 386 continue;
383 387 }
384 388
389 + $translations = array_map( 'trim', (array) wp_unslash( $_POST['translation'][ $language->slug ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
390 +
385 391 $mo = new PLL_MO();
386 392 $mo->import_from_db( $language );
387 393
388 - $translations = array_map( 'trim', wp_unslash( $_POST['translation'][ $language->slug ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
389 394 foreach ( $translations as $key => $translation ) {
390 395 /**
391 396 * Filter the string translation before it is saved in DB
392 397 * Allows to sanitize strings registered with pll_register_string
@@ -413,9 +418,9 @@
413 418
414 419 isset( $new_mo ) ? $new_mo->export_to_db( $language ) : $mo->export_to_db( $language );
415 420 }
416 421
417 - add_settings_error( 'general', 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'updated' );
422 + pll_add_notice( new WP_Error( 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'success' ) );
418 423
419 424 /**
420 425 * Fires after the strings translations are saved in DB
421 426 *