| @@ -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 | } |
| @@ -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,9 +78,9 @@ | ||
| 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 | 86 | esc_url( admin_url( 'admin.php?page=mlang&pll_action=edit&lang=' . $item->term_id ) ), |
| @@ -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&pll_action=default-lang&noheader=true&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,9 +157,9 @@ | ||
| 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 | 163 | 'name' => array( 'name', true ), // sorted by name by default |
| 168 | 164 | 'locale' => array( 'locale', false ), |
| 169 | 165 | 'slug' => array( 'slug', false ), |
| @@ -236,9 +232,9 @@ | ||
| 236 | 232 | * @param object $b The second object to compare |
| 237 | 233 | * @return int -1 or 1 if $a is considered to be respectively less than or greater than $b. |
| 238 | 234 | */ |
| 239 | 235 | protected function usort_reorder( $a, $b ) { |
| 240 | - $orderby = ! empty( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'name'; // phpcs:ignore WordPress.Security.NonceVerification | |
| 236 | + $orderby = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'name'; | |
| 241 | 237 | // Determine sort order |
| 242 | 238 | if ( is_numeric( $a->$orderby ) ) { |
| 243 | 239 | $result = $a->$orderby > $b->$orderby ? 1 : -1; |
| 244 | 240 | } else { |
| @@ -244,9 +240,9 @@ | ||
| 244 | 240 | } else { |
| 245 | 241 | $result = strcmp( $a->$orderby, $b->$orderby ); |
| 246 | 242 | } |
| 247 | 243 | // Send final sort direction to usort |
| 248 | - return ( empty( $_GET['order'] ) || 'asc' === $_GET['order'] ) ? $result : -$result; // phpcs:ignore WordPress.Security.NonceVerification | |
| 244 | + return ( empty( $_GET['order'] ) || 'asc' == $_GET['order'] ) ? $result : -$result; | |
| 249 | 245 | } |
| 250 | 246 | |
| 251 | 247 | /** |
| 252 | 248 | * Prepares the list of items for displaying |
| @@ -254,9 +250,9 @@ | ||
| 254 | 250 | * @since 0.1 |
| 255 | 251 | * |
| 256 | 252 | * @param array $data |
| 257 | 253 | */ |
| 258 | - public function prepare_items( $data = array() ) { | |
| 254 | + function prepare_items( $data = array() ) { | |
| 259 | 255 | $per_page = $this->get_items_per_page( 'pll_lang_per_page' ); |
| 260 | 256 | $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() ); |
| 261 | 257 | |
| 262 | 258 | usort( $data, array( $this, 'usort_reorder' ) ); |
| @@ -263,13 +259,11 @@ | ||
| 263 | 259 | |
| 264 | 260 | $total_items = count( $data ); |
| 265 | 261 | $this->items = array_slice( $data, ( $this->get_pagenum() - 1 ) * $per_page, $per_page ); |
| 266 | 262 | |
| 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 | - ); | |
| 263 | + $this->set_pagination_args( array( | |
| 264 | + 'total_items' => $total_items, | |
| 265 | + 'per_page' => $per_page, | |
| 266 | + 'total_pages' => ceil( $total_items / $per_page ), | |
| 267 | + ) ); | |
| 274 | 268 | } |
| 275 | 269 | } |