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 = []; return; } $this->set_pagination_args( [ 'total_items' => $query->pagination->count, 'per_page' => $this->get_items_per_page( 'bumps' ), ] ); $this->items = $query->data; } /** * @global int $post_id * @global string $comment_status * @global string $comment_type */ protected function get_views() { $stati = [ 'active' => __( 'Active', 'surecart' ), 'archived' => __( 'Archived', 'surecart' ), 'all' => __( 'All', 'surecart' ), ]; foreach ( $stati as $status => $label ) { $link = admin_url( 'admin.php?page=sc-bumps' ); $current_link_attributes = ''; if ( ! empty( $_GET['status'] ) ) { if ( $status === $_GET['status'] ) { $current_link_attributes = ' class="current" aria-current="page"'; } } elseif ( 'active' === $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( [ // 'cb' => '', 'name' => __( 'Name', 'surecart' ), // 'description' => __( 'Description', 'surecart' ), 'price' => __( 'Price', 'surecart' ), // 'type' => __( 'Type', 'surecart' ), // 'integrations' => __( 'Integrations', 'surecart' ), 'date' => __( 'Date', 'surecart' ), ], parent::get_columns() ); } /** * Displays the checkbox column. * * @param Bump $bump The bump model. */ public function column_cb( $bump ) { ?> bumpIntegrationsList( $bump->id ); return $list ? $list : '-'; } /** * Define which columns are hidden * * @return Array */ public function get_hidden_columns() { return array(); } /** * Define the sortable columns * * @return Array */ public function get_sortable_columns() { return array( 'title' => array( 'title', false ) ); } /** * Get the table data * * @return Array */ private function table_data() { return Bump::where( [ 'archived' => $this->getArchiveStatus(), 'query' => $this->get_search_query(), ] ) ->with( [ 'price', 'price.product' ] ) ->paginate( [ 'per_page' => $this->get_items_per_page( 'bumps' ), '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 order bumps found.', 'surecart' ); } /** * Handle the type column output. * * @param \SureCart\Models\Price $bump Bump model. * * @return string */ public function column_type( $bump ) { if ( $bump->recurring ) { return '
' . esc_html__( 'Subscription', 'surecart' ) . '
'; } return '
' . esc_html__( 'One-Time', 'surecart' ) . '
'; } /** * Price * * @param \SureCart\Models\Bump $bump Bump model. * * @return string */ public function column_price( $bump ) { if ( empty( $bump->price->id ) ) { return; } $price = $bump->price ?? null; ob_start(); ?> product->name ); ?>
display_amount ); ?> short_interval_text ); ?> short_interval_count_text ); ?>
name ? $bump->name : $bump->price->product->name ); ?> row_actions( [ 'edit' => ' ' . __( 'Edit', 'surecart' ) . '', ], ); ?>
$column_name ?? '' ); } } }