PluginProbe
Polylang / 2.0.12
Polylang v2.0.12
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 +31 -48 2.92.0.12 View file →
@@ -1,11 +1,8 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 if ( ! class_exists( 'WP_List_Table' ) ) {
7 - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
4 + require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
8 5 }
9 6
10 7 /**
11 8 * A class to create the languages table in Polylang settings
@@ -19,15 +16,13 @@
19 16 * Constructor
20 17 *
21 18 * @since 0.1
22 19 */
23 - public function __construct() {
24 - parent::__construct(
25 - array(
26 - 'plural' => 'Languages', // Do not translate ( used for css class )
27 - 'ajax' => false,
28 - )
29 - );
20 + function __construct() {
21 + parent::__construct( array(
22 + 'plural' => 'Languages', // Do not translate ( used for css class )
23 + 'ajax' => false,
24 + ) );
30 25 }
31 26
32 27 /**
33 28 * Generates content for a single row of the table
@@ -59,9 +54,9 @@
59 54 * @param object $item
60 55 * @param string $column_name
61 56 * @return string
62 57 */
63 - public function column_default( $item, $column_name ) {
58 + function column_default( $item, $column_name ) {
64 59 switch ( $column_name ) {
65 60 case 'locale':
66 61 case 'slug':
67 62 return esc_html( $item->$column_name );
@@ -83,13 +78,13 @@
83 78 *
84 79 * @param object $item
85 80 * @return string
86 81 */
87 - public function column_name( $item ) {
82 + function column_name( $item ) {
88 83 return sprintf(
89 84 '<a title="%s" href="%s">%s</a>',
90 85 esc_attr__( 'Edit this language', 'polylang' ),
91 - esc_url( admin_url( 'admin.php?page=mlang&amp;pll_action=edit&amp;lang=' . $item->term_id ) ),
86 + esc_url( admin_url( 'options-general.php?page=mlang&amp;pll_action=edit&amp;lang=' . $item->term_id ) ),
92 87 esc_html( $item->name )
93 88 );
94 89 }
95 90
@@ -101,14 +96,14 @@
101 96 *
102 97 * @param object $item
103 98 * @return string
104 99 */
105 - public function column_default_lang( $item ) {
100 + function column_default_lang( $item ) {
106 101 $options = get_option( 'polylang' );
107 102
108 103 if ( $options['default_lang'] != $item->slug ) {
109 - $s = sprintf(
110 - '<div class="row-actions"><span class="default-lang">
104 + $s = sprintf('
105 + <div class="row-actions"><span class="default-lang">
111 106 <a class="icon-default-lang" title="%1$s" href="%2$s"><span class="screen-reader-text">%3$s</span></a>
112 107 </span></div>',
113 108 esc_attr__( 'Select as default language', 'polylang' ),
114 109 wp_nonce_url( '?page=mlang&amp;pll_action=default-lang&amp;noheader=true&amp;lang=' . $item->term_id, 'default-lang' ),
@@ -130,8 +125,9 @@
130 125 '<span class="icon-default-lang"><span class="screen-reader-text">%1$s</span></span>',
131 126 /* translators: accessibility text */
132 127 esc_html__( 'Default language', 'polylang' )
133 128 );
129 + $actions = array();
134 130 }
135 131
136 132 return $s;
137 133 }
@@ -142,9 +138,9 @@
142 138 * @since 0.1
143 139 *
144 140 * @return array the list of column titles
145 141 */
146 - public function get_columns() {
142 + function get_columns() {
147 143 return array(
148 144 'name' => esc_html__( 'Full name', 'polylang' ),
149 145 'locale' => esc_html__( 'Locale', 'polylang' ),
150 146 'slug' => esc_html__( 'Code', 'polylang' ),
@@ -161,30 +157,19 @@
161 157 * @since 0.1
162 158 *
163 159 * @return array
164 160 */
165 - public function get_sortable_columns() {
161 + function get_sortable_columns() {
166 162 return array(
167 - 'name' => array( 'name', true ), // sorted by name by default
168 - 'locale' => array( 'locale', false ),
169 - 'slug' => array( 'slug', false ),
170 - 'term_group' => array( 'term_group', false ),
171 - 'count' => array( 'count', false ),
163 + 'name' => array( 'name', true ), // sorted by name by default
164 + 'locale' => array( 'locale', false ),
165 + 'slug' => array( 'slug', false ),
166 + 'term_group' => array( 'term_group', false ),
167 + 'count' => array( 'count', false ),
172 168 );
173 169 }
174 170
175 171 /**
176 - * Gets the name of the default primary column.
177 - *
178 - * @since 2.1
179 - *
180 - * @return string Name of the default primary column, in this case, 'name'.
181 - */
182 - protected function get_default_primary_column_name() {
183 - return 'name';
184 - }
185 -
186 - /**
187 172 * Generates and display row actions links for the list table.
188 173 *
189 174 * @since 1.8
190 175 *
@@ -201,10 +186,10 @@
201 186 $actions = array(
202 187 'edit' => sprintf(
203 188 '<a title="%s" href="%s">%s</a>',
204 189 esc_attr__( 'Edit this language', 'polylang' ),
205 - esc_url( admin_url( 'admin.php?page=mlang&amp;pll_action=edit&amp;lang=' . $item->term_id ) ),
206 - esc_html__( 'Edit', 'polylang' )
190 + esc_url( admin_url( 'options-general.php?page=mlang&amp;pll_action=edit&amp;lang=' . $item->term_id ) ),
191 + esc_html__( 'Edit','polylang' )
207 192 ),
208 193 'delete' => sprintf(
209 194 '<a title="%s" href="%s" onclick = "return confirm( \'%s\' );">%s</a>',
210 195 esc_attr__( 'Delete this language and all its associated data', 'polylang' ),
@@ -209,9 +194,9 @@
209 194 '<a title="%s" href="%s" onclick = "return confirm( \'%s\' );">%s</a>',
210 195 esc_attr__( 'Delete this language and all its associated data', 'polylang' ),
211 196 wp_nonce_url( '?page=mlang&amp;pll_action=delete&amp;noheader=true&amp;lang=' . $item->term_id, 'delete-lang' ),
212 197 esc_js( __( 'You are about to permanently delete this language. Are you sure?', 'polylang' ) ),
213 - esc_html__( 'Delete', 'polylang' )
198 + esc_html__( 'Delete','polylang' )
214 199 ),
215 200 );
216 201
217 202 /**
@@ -236,9 +221,9 @@
236 221 * @param object $b The second object to compare
237 222 * @return int -1 or 1 if $a is considered to be respectively less than or greater than $b.
238 223 */
239 224 protected function usort_reorder( $a, $b ) {
240 - $orderby = ! empty( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'name'; // phpcs:ignore WordPress.Security.NonceVerification
225 + $orderby = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'name';
241 226 // Determine sort order
242 227 if ( is_numeric( $a->$orderby ) ) {
243 228 $result = $a->$orderby > $b->$orderby ? 1 : -1;
244 229 } else {
@@ -244,9 +229,9 @@
244 229 } else {
245 230 $result = strcmp( $a->$orderby, $b->$orderby );
246 231 }
247 232 // Send final sort direction to usort
248 - return ( empty( $_GET['order'] ) || 'asc' === $_GET['order'] ) ? $result : -$result; // phpcs:ignore WordPress.Security.NonceVerification
233 + return ( empty( $_GET['order'] ) || 'asc' == $_GET['order'] ) ? $result : -$result;
249 234 }
250 235
251 236 /**
252 237 * Prepares the list of items for displaying
@@ -254,9 +239,9 @@
254 239 * @since 0.1
255 240 *
256 241 * @param array $data
257 242 */
258 - public function prepare_items( $data = array() ) {
243 + function prepare_items( $data = array() ) {
259 244 $per_page = $this->get_items_per_page( 'pll_lang_per_page' );
260 245 $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
261 246
262 247 usort( $data, array( $this, 'usort_reorder' ) );
@@ -263,13 +248,11 @@
263 248
264 249 $total_items = count( $data );
265 250 $this->items = array_slice( $data, ( $this->get_pagenum() - 1 ) * $per_page, $per_page );
266 251
267 - $this->set_pagination_args(
268 - array(
269 - 'total_items' => $total_items,
270 - 'per_page' => $per_page,
271 - 'total_pages' => ceil( $total_items / $per_page ),
272 - )
273 - );
252 + $this->set_pagination_args( array(
253 + 'total_items' => $total_items,
254 + 'per_page' => $per_page,
255 + 'total_pages' => ceil( $total_items / $per_page ),
256 + ) );
274 257 }
275 258 }