| @@ -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 | } |
| @@ -18,15 +15,13 @@ | ||
| 18 | 15 | * Constructor |
| 19 | 16 | * |
| 20 | 17 | * @since 1.8 |
| 21 | 18 | */ |
| 22 | - public function __construct() { | |
| 23 | - parent::__construct( | |
| 24 | - array( | |
| 25 | - 'plural' => 'Settings', // Do not translate ( used for css class ) | |
| 26 | - 'ajax' => false, | |
| 27 | - ) | |
| 28 | - ); | |
| 19 | + function __construct() { | |
| 20 | + parent::__construct( array( | |
| 21 | + 'plural' => 'Settings', // Do not translate ( used for css class ) | |
| 22 | + 'ajax' => false, | |
| 23 | + ) ); | |
| 29 | 24 | } |
| 30 | 25 | |
| 31 | 26 | /** |
| 32 | 27 | * Get the table classes for styling |
| @@ -57,13 +52,18 @@ | ||
| 57 | 52 | echo '</tr>'; |
| 58 | 53 | |
| 59 | 54 | // Display an upgrade message if there is any, reusing css from the plugins updates |
| 60 | 55 | if ( $message = $item->get_upgrade_message() ) { |
| 61 | - printf( | |
| 62 | - '<tr class="plugin-update-tr"> | |
| 56 | + printf( ' | |
| 57 | + <tr class="plugin-update-tr"> | |
| 63 | 58 | <td colspan="3" class="plugin-update colspanchange">%s</td> |
| 64 | 59 | </tr>', |
| 65 | - sprintf( '<div class="update-message notice inline notice-warning notice-alt"><p>%s</p></div>', $message ) // phpcs:ignore WordPress.Security.EscapeOutput | |
| 60 | + sprintf( | |
| 61 | + version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ? | |
| 62 | + '<div class="update-message">%s</div>' : // backward compatibility with WP < 4.6 | |
| 63 | + '<div class="update-message notice inline notice-warning notice-alt"><p>%s</p></div>', | |
| 64 | + $message | |
| 65 | + ) | |
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // The settings if there are |
| @@ -68,10 +68,10 @@ | ||
| 68 | 68 | |
| 69 | 69 | // The settings if there are |
| 70 | 70 | // "inactive" class to reuse css from the plugins list table |
| 71 | 71 | if ( $form = $item->get_form() ) { |
| 72 | - printf( | |
| 73 | - '<tr id="pll-configure-%s" class="pll-configure inactive inline-edit-row" style="display: none;"> | |
| 72 | + printf( ' | |
| 73 | + <tr id="pll-configure-%s" class="pll-configure inactive inline-edit-row" style="display: none;"> | |
| 74 | 74 | <td colspan="3"> |
| 75 | 75 | <legend>%s</legend> |
| 76 | 76 | %s |
| 77 | 77 | <p class="submit inline-edit-save"> |
| @@ -78,12 +78,9 @@ | ||
| 78 | 78 | %s |
| 79 | 79 | </p> |
| 80 | 80 | </td> |
| 81 | 81 | </tr>', |
| 82 | - esc_attr( $item->module ), | |
| 83 | - esc_html( $item->title ), | |
| 84 | - $form, // phpcs:ignore | |
| 85 | - implode( $item->get_buttons() ) // phpcs:ignore | |
| 82 | + esc_attr( $item->module ), esc_html( $item->title ), $form, implode( $item->get_buttons() ) | |
| 86 | 83 | ); |
| 87 | 84 | } |
| 88 | 85 | } |
| 89 | 86 | |
| @@ -94,25 +91,28 @@ | ||
| 94 | 91 | * |
| 95 | 92 | * @param object $item The current item |
| 96 | 93 | */ |
| 97 | 94 | protected function single_row_columns( $item ) { |
| 98 | - $column_info = $this->get_column_info(); | |
| 99 | - $columns = $column_info[0]; | |
| 100 | - $primary = $column_info[3]; | |
| 95 | + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); | |
| 101 | 96 | |
| 102 | - foreach ( array_keys( $columns ) as $column_name ) { | |
| 97 | + foreach ( $columns as $column_name => $column_display_name ) { | |
| 103 | 98 | $classes = "$column_name column-$column_name"; |
| 104 | 99 | if ( $primary === $column_name ) { |
| 105 | 100 | $classes .= ' column-primary'; |
| 106 | 101 | } |
| 107 | 102 | |
| 103 | + if ( in_array( $column_name, $hidden ) ) { | |
| 104 | + $classes .= ' hidden'; | |
| 105 | + } | |
| 106 | + | |
| 108 | 107 | if ( 'cb' == $column_name ) { |
| 109 | 108 | echo '<th scope="row" class="check-column">'; |
| 110 | - echo $this->column_cb( $item ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 109 | + echo $this->column_cb( $item ); | |
| 111 | 110 | echo '</th>'; |
| 112 | - } else { | |
| 111 | + } | |
| 112 | + else { | |
| 113 | 113 | printf( '<td class="%s">', esc_attr( $classes ) ); |
| 114 | - echo $this->column_default( $item, $column_name ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 114 | + echo $this->column_default( $item, $column_name ); | |
| 115 | 115 | echo '</td>'; |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
| @@ -167,16 +167,8 @@ | ||
| 167 | 167 | * @param array $items |
| 168 | 168 | */ |
| 169 | 169 | public function prepare_items( $items = array() ) { |
| 170 | 170 | $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() ); |
| 171 | - | |
| 172 | - // Sort rows, lowest priority on top. | |
| 173 | - usort( | |
| 174 | - $items, | |
| 175 | - function( $a, $b ) { | |
| 176 | - return $a->priority > $b->priority ? 1 : -1; | |
| 177 | - } | |
| 178 | - ); | |
| 179 | 171 | $this->items = $items; |
| 180 | 172 | } |
| 181 | 173 | |
| 182 | 174 | /** |
| @@ -185,6 +177,6 @@ | ||
| 185 | 177 | * @since 2.1 |
| 186 | 178 | * |
| 187 | 179 | * @param string $which 'top' or 'bottom' |
| 188 | 180 | */ |
| 189 | - protected function display_tablenav( $which ) {} // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 181 | + protected function display_tablenav( $which ) {} | |
| 190 | 182 | } |