| @@ -22,9 +22,9 @@ | ||
| 22 | 22 | * Holds the supported bulk actions. |
| 23 | 23 | * |
| 24 | 24 | * @var array |
| 25 | 25 | */ |
| 26 | - private $bulk_actions = array(); | |
| 26 | + private $_bulk_actions = array(); // phpcs:ignore | |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Holds the table columns. |
| 30 | 30 | * |
| @@ -29,9 +29,9 @@ | ||
| 29 | 29 | * Holds the table columns. |
| 30 | 30 | * |
| 31 | 31 | * @var array |
| 32 | 32 | */ |
| 33 | - private $columns = array(); | |
| 33 | + private $_columns = array(); // phpcs:ignore | |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Holds the sortable table columns. |
| 37 | 37 | * |
| @@ -36,9 +36,9 @@ | ||
| 36 | 36 | * Holds the sortable table columns. |
| 37 | 37 | * |
| 38 | 38 | * @var array |
| 39 | 39 | */ |
| 40 | - private $sortable_columns = array(); | |
| 40 | + private $_sortable_columns = array(); // phpcs:ignore | |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Holds the table rows and their data. |
| 44 | 44 | * |
| @@ -43,9 +43,9 @@ | ||
| 43 | 43 | * Holds the table rows and their data. |
| 44 | 44 | * |
| 45 | 45 | * @var array |
| 46 | 46 | */ |
| 47 | - private $data = array(); | |
| 47 | + private $_data = array(); // phpcs:ignore | |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Constructor. |
| 51 | 51 | * |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | * @return array Bulk actions |
| 101 | 101 | */ |
| 102 | 102 | public function get_bulk_actions() { |
| 103 | 103 | |
| 104 | - return $this->bulk_actions; | |
| 104 | + return $this->_bulk_actions; | |
| 105 | 105 | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| @@ -111,9 +111,9 @@ | ||
| 111 | 111 | * @return array |
| 112 | 112 | */ |
| 113 | 113 | public function get_columns() { |
| 114 | 114 | |
| 115 | - return $this->columns; | |
| 115 | + return $this->_columns; | |
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| @@ -124,12 +124,12 @@ | ||
| 124 | 124 | * @param boolean $sortable Whether or not this is sortable (defaults false). |
| 125 | 125 | */ |
| 126 | 126 | public function add_column( $key, $title, $sortable = false ) { |
| 127 | 127 | |
| 128 | - $this->columns[ $key ] = $title; | |
| 128 | + $this->_columns[ $key ] = $title; | |
| 129 | 129 | |
| 130 | 130 | if ( $sortable ) { |
| 131 | - $this->sortable_columns[ $key ] = array( $key, false ); | |
| 131 | + $this->_sortable_columns[ $key ] = array( $key, false ); | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
| @@ -139,9 +139,9 @@ | ||
| 139 | 139 | * @param array $item A row's worth of data. |
| 140 | 140 | */ |
| 141 | 141 | public function add_item( $item ) { |
| 142 | 142 | |
| 143 | - array_push( $this->data, $item ); | |
| 143 | + array_push( $this->_data, $item ); | |
| 144 | 144 | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
| @@ -151,9 +151,9 @@ | ||
| 151 | 151 | * @param string $name Title shown to the user. |
| 152 | 152 | */ |
| 153 | 153 | public function add_bulk_action( $key, $name ) { |
| 154 | 154 | |
| 155 | - $this->bulk_actions[ $key ] = $name; | |
| 155 | + $this->_bulk_actions[ $key ] = $name; | |
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
| @@ -160,20 +160,20 @@ | ||
| 160 | 160 | * Prepares the items (rows) to be rendered |
| 161 | 161 | */ |
| 162 | 162 | public function prepare_items() { |
| 163 | 163 | |
| 164 | - $total_items = count( $this->data ); | |
| 164 | + $total_items = count( $this->_data ); | |
| 165 | 165 | $per_page = 25; |
| 166 | 166 | |
| 167 | - $columns = $this->columns; | |
| 167 | + $columns = $this->_columns; | |
| 168 | 168 | $hidden = array(); |
| 169 | - $sortable = $this->sortable_columns; | |
| 169 | + $sortable = $this->_sortable_columns; | |
| 170 | 170 | |
| 171 | 171 | $this->_column_headers = array( $columns, $hidden, $sortable ); |
| 172 | 172 | |
| 173 | 173 | $current_page = $this->get_pagenum(); |
| 174 | 174 | |
| 175 | - $sorted_data = $this->reorder( $this->data ); | |
| 175 | + $sorted_data = $this->reorder( $this->_data ); | |
| 176 | 176 | |
| 177 | 177 | $data = array_slice( $sorted_data, ( ( $current_page - 1 ) * $per_page ), $per_page ); |
| 178 | 178 | |
| 179 | 179 | $this->items = $data; |
| @@ -181,9 +181,9 @@ | ||
| 181 | 181 | $this->set_pagination_args( |
| 182 | 182 | array( |
| 183 | 183 | 'total_items' => $total_items, |
| 184 | 184 | 'per_page' => $per_page, |
| 185 | - 'total_pages' => (int) ceil( $total_items / $per_page ), | |
| 185 | + 'total_pages' => ceil( $total_items / $per_page ), | |
| 186 | 186 | ) |
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | 189 | } |
| @@ -199,18 +199,18 @@ | ||
| 199 | 199 | usort( |
| 200 | 200 | $data, |
| 201 | 201 | function( $a, $b ) { |
| 202 | 202 | |
| 203 | - if ( empty( $_REQUEST['orderby'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 203 | + if ( empty( $_REQUEST['orderby'] ) ) { // phpcs:ignore | |
| 204 | 204 | $orderby = 'title'; |
| 205 | 205 | } else { |
| 206 | - $orderby = sanitize_sql_orderby( wp_unslash( $_REQUEST['orderby'] ) ); // phpcs:ignore WordPress.Security.NonceVerification | |
| 206 | + $orderby = sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ); // phpcs:ignore | |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if ( empty( $_REQUEST['order'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 209 | + if ( empty( $_REQUEST['order'] ) ) { // phpcs:ignore | |
| 210 | 210 | $order = 'asc'; |
| 211 | 211 | } else { |
| 212 | - $order = sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ); // phpcs:ignore WordPress.Security.NonceVerification | |
| 212 | + $order = sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ); // phpcs:ignore | |
| 213 | 213 | } |
| 214 | 214 | $result = strcmp( $a[ $orderby ], $b[ $orderby ] ); // Determine sort order. |
| 215 | 215 | return ( 'asc' === $order ) ? $result : -$result; // Send final sort direction to usort. |
| 216 | 216 | |