'py_otkaz', 'plural' => 'py_otkazi', 'ajax' => false, ) ); } /** * Filters from the request (shared with CSV export). * * @return array */ public static function filters_from_request() { // phpcs:disable WordPress.Security.NonceVerification.Recommended $get = static function ( $key ) { return isset( $_GET[ $key ] ) ? sanitize_text_field( wp_unslash( $_GET[ $key ] ) ) : ''; }; $args = array( 'search' => $get( 's' ), 'deadline' => $get( 'deadline' ), 'email_status' => $get( 'email_status' ), 'refund' => $get( 'refund' ), 'date_from' => $get( 'date_from' ), 'date_to' => $get( 'date_to' ), 'orderby' => $get( 'orderby' ) ? $get( 'orderby' ) : 'created_gmt', 'order' => $get( 'order' ) ? $get( 'order' ) : 'DESC', ); // phpcs:enable return $args; } /** * Columns. * * @return array */ public function get_columns() { return array( 'number' => __( 'Number', 'otkazpro' ), 'date' => __( 'Date', 'otkazpro' ), 'order' => __( 'Order', 'otkazpro' ), 'customer' => __( 'Customer', 'otkazpro' ), 'items' => __( 'Products', 'otkazpro' ), 'deadline' => __( 'Deadline', 'otkazpro' ), 'refund' => __( 'Refund', 'otkazpro' ), 'email' => __( 'Confirmation', 'otkazpro' ), ); } /** * Sortable columns. * * @return array */ protected function get_sortable_columns() { return array( 'number' => array( 'number', false ), 'date' => array( 'created_gmt', true ), 'order' => array( 'order_id', false ), 'customer' => array( 'name', false ), ); } /** * Prepare items. */ public function prepare_items() { $per_page = $this->get_items_per_page( 'py_otkaz_per_page', 20 ); $args = self::filters_from_request(); $args['per_page'] = $per_page; $args['page'] = $this->get_pagenum(); $result = Submission::query( $args ); $this->items = $result['items']; $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), 'number' ); $this->set_pagination_args( array( 'total_items' => $result['total'], 'per_page' => $per_page, 'total_pages' => (int) ceil( $result['total'] / max( 1, $per_page ) ), ) ); } /** * Empty state. */ public function no_items() { esc_html_e( 'No withdrawals yet.', 'otkazpro' ); } /** * Filters + export. * * @param string $which top|bottom. */ protected function extra_tablenav( $which ) { if ( 'top' !== $which ) { return; } $f = self::filters_from_request(); ?>