get_columns(); $hidden = $this->get_hidden_columns(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); $query = $this->table_data(); if ( is_wp_error( $query ) ) { $this->error = $query->get_error_message(); $this->items = array(); return; } $this->set_pagination_args( array( 'total_items' => $query->pagination->count, 'per_page' => $this->get_items_per_page( 'affiliate-requests' ), ) ); $this->items = $query->data; } /** * Get views for the list table status links. * * @global int $post_id * @global string $comment_status * @global string $comment_type */ protected function get_views() { foreach ( $this->getStatuses() as $status => $label ) { $link = admin_url( 'admin.php?page=sc-affiliate-requests' ); $current_link_attributes = ''; if ( ! empty( $_GET['status'] ) ) { if ( $status === $_GET['status'] ) { $current_link_attributes = ' class="current" aria-current="page"'; } } elseif ( 'all' === $status ) { $current_link_attributes = ' class="current" aria-current="page"'; } $link = add_query_arg( 'status', $status, $link ); $link = esc_url( $link ); $status_links[ $status ] = "" . $label . ''; } /** * Filters the comment status links. * * @since 2.5.0 * @since 5.1.0 The 'Mine' link was added. * * @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine', * 'Pending', 'Approved', 'Spam', and 'Trash'. */ return apply_filters( 'comment_status_links', $status_links ); } /** * Override the parent columns method. Defines the columns to use in your listing table * * @return array */ public function get_columns() { return array_merge( [ 'name' => __( 'Name', 'surecart' ), 'email' => __( 'Email', 'surecart' ), 'payout_email' => __( 'Payout Email', 'surecart' ), 'status' => __( 'Status', 'surecart' ), 'date' => __( 'Date', 'surecart' ), ], parent::get_columns() ); } /** * Define which columns are hidden * * @return array */ public function get_hidden_columns() { return array(); } /** * Get the table data * * @return object|WP_Error */ private function table_data() { $affiliate_request_query = AffiliationRequest::where( array( 'status[]' => $this->getFilteredStatus(), 'query' => $this->get_search_query(), 'used' => false, ) ); return $affiliate_request_query->paginate( array( 'per_page' => $this->get_items_per_page( 'affiliate_requests' ), 'page' => $this->get_pagenum(), ) ); } /** * Nothing found. * * @return void */ public function no_items() { if ( $this->error ) { echo esc_html( $this->error ); return; } echo esc_html_e( 'No affiliate requests found.', 'surecart' ); } /** * Published column * * @param \SureCart\Models\AffiliationRequest $affiliate_request AffiliationRequest model. * * @return string */ public function column_status( $affiliate_request ) { ob_start(); ?> status_display_text ); ?> edit( 'affiliate-request', $affiliate_request->id ) ) . '">' . esc_html( $affiliate_request->first_name . ' ' . $affiliate_request->last_name ) . ''; } return esc_html( $affiliate_request->$column_name ?? '' ); } /** * Displays extra table navigation. * * @param string $which Top or bottom placement. */ protected function extra_tablenav( $which ) { ?> __( 'All', 'surecart' ), 'approved' => __( 'Approved', 'surecart' ), 'denied' => __( 'Denied', 'surecart' ), 'pending' => __( 'Pending', 'surecart' ), ); } }