| @@ -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 | } |
| @@ -37,14 +34,13 @@ | ||
| 37 | 34 | return array( 'wp-list-table', 'widefat', 'plugins', 'pll-settings' ); // get the style of the plugins list table + one specific class |
| 38 | 35 | } |
| 39 | 36 | |
| 40 | 37 | /** |
| 41 | - * Displays a single row. | |
| 38 | + * Displays a single row | |
| 42 | 39 | * |
| 43 | 40 | * @since 1.8 |
| 44 | 41 | * |
| 45 | - * @param PLL_Settings_Module $item Settings module item. | |
| 46 | - * @return void | |
| 42 | + * @param object $item PLL_Settings_Module object | |
| 47 | 43 | */ |
| 48 | 44 | public function single_row( $item ) { |
| 49 | 45 | // Classes to reuse css from the plugins list table |
| 50 | 46 | $classes = $item->is_active() ? 'active' : 'inactive'; |
| @@ -62,9 +58,9 @@ | ||
| 62 | 58 | printf( |
| 63 | 59 | '<tr class="plugin-update-tr"> |
| 64 | 60 | <td colspan="3" class="plugin-update colspanchange">%s</td> |
| 65 | 61 | </tr>', |
| 66 | - sprintf( '<div class="update-message notice inline notice-warning notice-alt"><p>%s</p></div>', $message ) // phpcs:ignore WordPress.Security.EscapeOutput | |
| 62 | + sprintf( '<div class="update-message notice inline notice-warning notice-alt"><p>%s</p></div>', $message ) | |
| 67 | 63 | ); |
| 68 | 64 | } |
| 69 | 65 | |
| 70 | 66 | // The settings if there are |
| @@ -81,40 +77,42 @@ | ||
| 81 | 77 | </td> |
| 82 | 78 | </tr>', |
| 83 | 79 | esc_attr( $item->module ), |
| 84 | 80 | esc_html( $item->title ), |
| 85 | - $form, // phpcs:ignore | |
| 86 | - implode( $item->get_buttons() ) // phpcs:ignore | |
| 81 | + $form, | |
| 82 | + implode( $item->get_buttons() ) | |
| 87 | 83 | ); |
| 88 | 84 | } |
| 89 | 85 | } |
| 90 | 86 | |
| 91 | 87 | /** |
| 92 | - * Generates the columns for a single row of the table. | |
| 88 | + * Generates the columns for a single row of the table | |
| 93 | 89 | * |
| 94 | 90 | * @since 1.8 |
| 95 | 91 | * |
| 96 | - * @param PLL_Settings_Module $item Settings module item. | |
| 97 | - * @return void | |
| 92 | + * @param object $item The current item | |
| 98 | 93 | */ |
| 99 | 94 | protected function single_row_columns( $item ) { |
| 100 | - $column_info = $this->get_column_info(); | |
| 101 | - $columns = $column_info[0]; | |
| 102 | - $primary = $column_info[3]; | |
| 95 | + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); | |
| 103 | 96 | |
| 104 | - foreach ( array_keys( $columns ) as $column_name ) { | |
| 97 | + foreach ( $columns as $column_name => $column_display_name ) { | |
| 105 | 98 | $classes = "$column_name column-$column_name"; |
| 106 | 99 | if ( $primary === $column_name ) { |
| 107 | 100 | $classes .= ' column-primary'; |
| 108 | 101 | } |
| 109 | 102 | |
| 103 | + if ( in_array( $column_name, $hidden ) ) { | |
| 104 | + $classes .= ' hidden'; | |
| 105 | + } | |
| 106 | + | |
| 110 | 107 | if ( 'cb' == $column_name ) { |
| 111 | 108 | echo '<th scope="row" class="check-column">'; |
| 112 | - echo $this->column_cb( $item ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 109 | + echo $this->column_cb( $item ); | |
| 113 | 110 | echo '</th>'; |
| 114 | - } else { | |
| 111 | + } | |
| 112 | + else { | |
| 115 | 113 | printf( '<td class="%s">', esc_attr( $classes ) ); |
| 116 | - echo $this->column_default( $item, $column_name ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 114 | + echo $this->column_default( $item, $column_name ); | |
| 117 | 115 | echo '</td>'; |
| 118 | 116 | } |
| 119 | 117 | } |
| 120 | 118 | } |
| @@ -119,15 +117,15 @@ | ||
| 119 | 117 | } |
| 120 | 118 | } |
| 121 | 119 | |
| 122 | 120 | /** |
| 123 | - * Displays the item information in a column (default case). | |
| 121 | + * Displays the item information in a column ( default case ) | |
| 124 | 122 | * |
| 125 | 123 | * @since 1.8 |
| 126 | 124 | * |
| 127 | - * @param PLL_Settings_Module $item Settings module item. | |
| 128 | - * @param string $column_name Column name. | |
| 129 | - * @return string The column name. | |
| 125 | + * @param object $item | |
| 126 | + * @param string $column_name | |
| 127 | + * @return string | |
| 130 | 128 | */ |
| 131 | 129 | protected function column_default( $item, $column_name ) { |
| 132 | 130 | if ( 'plugin-title' == $column_name ) { |
| 133 | 131 | return sprintf( '<strong>%s</strong>', esc_html( $item->title ) ) . $this->row_actions( $item->get_action_links(), true /*always visible*/ ); |
| @@ -135,13 +133,13 @@ | ||
| 135 | 133 | return $item->$column_name; |
| 136 | 134 | } |
| 137 | 135 | |
| 138 | 136 | /** |
| 139 | - * Gets the list of columns. | |
| 137 | + * Gets the list of columns | |
| 140 | 138 | * |
| 141 | 139 | * @since 1.8 |
| 142 | 140 | * |
| 143 | - * @return string[] The list of column titles. | |
| 141 | + * @return array the list of column titles | |
| 144 | 142 | */ |
| 145 | 143 | public function get_columns() { |
| 146 | 144 | return array( |
| 147 | 145 | 'cb' => '', // For the 4px border inherited from plugins when the module is activated |
| @@ -165,21 +163,12 @@ | ||
| 165 | 163 | * Prepares the list of items for displaying |
| 166 | 164 | * |
| 167 | 165 | * @since 1.8 |
| 168 | 166 | * |
| 169 | - * @param PLL_Settings_Module[] $items Array of settings module items. | |
| 170 | - * @return void | |
| 167 | + * @param array $items | |
| 171 | 168 | */ |
| 172 | 169 | public function prepare_items( $items = array() ) { |
| 173 | 170 | $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() ); |
| 174 | - | |
| 175 | - // Sort rows, lowest priority on top. | |
| 176 | - usort( | |
| 177 | - $items, | |
| 178 | - function( $a, $b ) { | |
| 179 | - return $a->priority > $b->priority ? 1 : -1; | |
| 180 | - } | |
| 181 | - ); | |
| 182 | 171 | $this->items = $items; |
| 183 | 172 | } |
| 184 | 173 | |
| 185 | 174 | /** |
| @@ -187,8 +176,7 @@ | ||
| 187 | 176 | * |
| 188 | 177 | * @since 2.1 |
| 189 | 178 | * |
| 190 | 179 | * @param string $which 'top' or 'bottom' |
| 191 | - * @return void | |
| 192 | 180 | */ |
| 193 | - protected function display_tablenav( $which ) {} // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 181 | + protected function display_tablenav( $which ) {} | |
| 194 | 182 | } |