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