PluginProbe
Polylang / 3.7.7
Polylang v3.7.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-languages.php +34 -32 2.93.7.7 View file →
@@ -29,13 +29,14 @@
29 29 );
30 30 }
31 31
32 32 /**
33 - * Generates content for a single row of the table
33 + * Generates content for a single row of the table.
34 34 *
35 35 * @since 1.8
36 36 *
37 - * @param object $item The current item
37 + * @param PLL_Language $item The language item.
38 + * @return void
38 39 */
39 40 public function single_row( $item ) {
40 41 /**
41 42 * Filter the list of classes assigned a row in the languages list table
@@ -41,10 +42,10 @@
41 42 * Filter the list of classes assigned a row in the languages list table
42 43 *
43 44 * @since 1.8
44 45 *
45 - * @param array $classes list of class names
46 - * @param object $item the current item
46 + * @param array $classes The list of class names.
47 + * @param PLL_Language $item The language item.
47 48 */
48 49 $classes = apply_filters( 'pll_languages_row_classes', array(), $item );
49 50 echo '<tr' . ( empty( $classes ) ? '>' : ' class="' . esc_attr( implode( ' ', $classes ) ) . '">' );
50 51 $this->single_row_columns( $item );
@@ -51,15 +52,15 @@
51 52 echo '</tr>';
52 53 }
53 54
54 55 /**
55 - * Displays the item information in a column ( default case )
56 + * Displays the item information in a column ( default case ).
56 57 *
57 58 * @since 0.1
58 59 *
59 - * @param object $item
60 - * @param string $column_name
61 - * @return string
60 + * @param PLL_Language $item The language item.
61 + * @param string $column_name The column name.
62 + * @return string|int
62 63 */
63 64 public function column_default( $item, $column_name ) {
64 65 switch ( $column_name ) {
65 66 case 'locale':
@@ -66,13 +67,15 @@
66 67 case 'slug':
67 68 return esc_html( $item->$column_name );
68 69
69 70 case 'term_group':
71 + return (int) $item->$column_name;
72 +
70 73 case 'count':
71 - return (int) $item->$column_name;
74 + return $item->get_tax_prop( 'language', $column_name );
72 75
73 76 default:
74 - return $item->$column_name; // flag
77 + return $item->$column_name; // Flag.
75 78 }
76 79 }
77 80
78 81 /**
@@ -80,9 +83,9 @@
80 83 * Displays the edit and delete action links
81 84 *
82 85 * @since 0.1
83 86 *
84 - * @param object $item
87 + * @param PLL_Language $item The language item.
85 88 * @return string
86 89 */
87 90 public function column_name( $item ) {
88 91 return sprintf(
@@ -98,15 +101,13 @@
98 101 * Displays the 'make default' action link
99 102 *
100 103 * @since 1.8
101 104 *
102 - * @param object $item
105 + * @param PLL_Language $item The language item.
103 106 * @return string
104 107 */
105 108 public function column_default_lang( $item ) {
106 - $options = get_option( 'polylang' );
107 -
108 - if ( $options['default_lang'] != $item->slug ) {
109 + if ( ! $item->is_default ) {
109 110 $s = sprintf(
110 111 '<div class="row-actions"><span class="default-lang">
111 112 <a class="icon-default-lang" title="%1$s" href="%2$s"><span class="screen-reader-text">%3$s</span></a>
112 113 </span></div>',
@@ -116,14 +117,14 @@
116 117 esc_html( sprintf( __( 'Choose %s as default language', 'polylang' ), $item->name ) )
117 118 );
118 119
119 120 /**
120 - * Filter the default language row action in the languages list table
121 + * Filters the default language row action in the languages list table.
121 122 *
122 123 * @since 1.8
123 124 *
124 - * @param string $s html markup of the action
125 - * @param object $item
125 + * @param string $s The html markup of the action.
126 + * @param PLL_Language $item The language item.
126 127 */
127 128 $s = apply_filters( 'pll_default_lang_row_action', $s, $item );
128 129 } else {
129 130 $s = sprintf(
@@ -140,9 +141,9 @@
140 141 * Gets the list of columns
141 142 *
142 143 * @since 0.1
143 144 *
144 - * @return array the list of column titles
145 + * @return string[] The list of column titles.
145 146 */
146 147 public function get_columns() {
147 148 return array(
148 149 'name' => esc_html__( 'Full name', 'polylang' ),
@@ -187,11 +188,11 @@
187 188 * Generates and display row actions links for the list table.
188 189 *
189 190 * @since 1.8
190 191 *
191 - * @param object $item The item being acted upon.
192 - * @param string $column_name Current column name.
193 - * @param string $primary Primary column name.
192 + * @param PLL_Language $item The language item being acted upon.
193 + * @param string $column_name Current column name.
194 + * @param string $primary Primary column name.
194 195 * @return string The row actions output.
195 196 */
196 197 protected function handle_row_actions( $item, $column_name, $primary ) {
197 198 if ( $primary !== $column_name ) {
@@ -214,14 +215,14 @@
214 215 ),
215 216 );
216 217
217 218 /**
218 - * Filter the list of row actions in the languages list table
219 + * Filters the list of row actions in the languages list table.
219 220 *
220 221 * @since 1.8
221 222 *
222 - * @param array $actions list of html markup actions
223 - * @param object $item
223 + * @param array $actions A list of html markup actions.
224 + * @param PLL_Language $item The language item.
224 225 */
225 226 $actions = apply_filters( 'pll_languages_row_actions', $actions, $item );
226 227
227 228 return $this->row_actions( $actions );
@@ -227,14 +228,14 @@
227 228 return $this->row_actions( $actions );
228 229 }
229 230
230 231 /**
231 - * Sort items
232 + * Sorts language items.
232 233 *
233 234 * @since 0.1
234 235 *
235 - * @param object $a The first object to compare
236 - * @param object $b The second object to compare
236 + * @param PLL_Language $a The first language to compare.
237 + * @param PLL_Language $b The second language to compare.
237 238 * @return int -1 or 1 if $a is considered to be respectively less than or greater than $b.
238 239 */
239 240 protected function usort_reorder( $a, $b ) {
240 241 $orderby = ! empty( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'name'; // phpcs:ignore WordPress.Security.NonceVerification
@@ -243,18 +244,19 @@
243 244 $result = $a->$orderby > $b->$orderby ? 1 : -1;
244 245 } else {
245 246 $result = strcmp( $a->$orderby, $b->$orderby );
246 247 }
247 - // Send final sort direction to usort
248 + // Send final sort direction to usort.
248 249 return ( empty( $_GET['order'] ) || 'asc' === $_GET['order'] ) ? $result : -$result; // phpcs:ignore WordPress.Security.NonceVerification
249 250 }
250 251
251 252 /**
252 - * Prepares the list of items for displaying
253 + * Prepares the list of languages for display.
253 254 *
254 255 * @since 0.1
255 256 *
256 - * @param array $data
257 + * @param PLL_Language[] $data The list of languages.
258 + * @return void
257 259 */
258 260 public function prepare_items( $data = array() ) {
259 261 $per_page = $this->get_items_per_page( 'pll_lang_per_page' );
260 262 $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
@@ -267,9 +269,9 @@
267 269 $this->set_pagination_args(
268 270 array(
269 271 'total_items' => $total_items,
270 272 'per_page' => $per_page,
271 - 'total_pages' => ceil( $total_items / $per_page ),
273 + 'total_pages' => (int) ceil( $total_items / $per_page ),
272 274 )
273 275 );
274 276 }
275 277 }