page = $page; $this->tab = $tab; parent::__construct( array( 'singular' => 'convertkit-item', 'plural' => 'convertkit-items', 'ajax' => false, ) ); } /** * Set default column attributes * * @since 1.0.0 * * @param array $item A singular item (one full row's worth of data). * @param string $column_name The name/slug of the column to be processed. * @return string Text or HTML to be placed inside the column
'search-submit' ) ); ?>
page ) { ?> tab ) { ?> columns; } /** * Add a column to the table * * @param string $key Machine-readable column name. * @param string $title Title shown to the user. * @param boolean $sortable Whether or not this is sortable (defaults false). */ public function add_column( $key, $title, $sortable = false ) { $this->columns[ $key ] = $title; if ( $sortable ) { $this->sortable_columns[ $key ] = array( $key, false ); } } /** * Add an item (row) to the table * * @param array $item A row's worth of data. */ public function add_item( $item ) { array_push( $this->items, $item ); } /** * Add multiple items to the table * * @since 3.0.0 * * @param array $items Table rows. */ public function add_items( $items ) { $this->items = $items; } /** * Set the total number of items available, which may * be greater than the number of items displayed. * * @since 3.0.0 * * @param int $total_items Total number of items. */ public function set_total_items( $total_items ) { $this->total_items = $total_items; } /** * Set the key that stores the user's preference for the number of items per page * to display, defined in the Screen Options. * * @since 3.0.0 * * @param string $items_per_page_screen_options_key Key. */ public function set_items_per_page_screen_options_key( $items_per_page_screen_options_key ) { $this->items_per_page_screen_options_key = $items_per_page_screen_options_key; } /** * Get the total number of items available, which may * be greater than the number of items displayed. * * @since 3.0.0 * * @return int Total number of items. */ public function get_total_items() { if ( $this->total_items ) { return $this->total_items; } return count( $this->items ); } /** * Add a bulk action to the table * * @param string $key Machine-readable action name. * @param string $name Title shown to the user. */ public function add_bulk_action( $key, $name ) { $this->bulk_actions[ $key ] = $name; } /** * Add a filter to the table * * @since 3.0.1 * * @param string $key Filter name. * @param string $label Filter label. * @param array $options Filter options. */ public function add_filter( $key, $label, $options ) { $this->filters[ $key ] = array( 'label' => $label, 'options' => $options, ); } /** * Define table columns and pagination for this WP_List_Table. * * @since 3.0.0 */ public function prepare_items() { // Set column headers. // If this isn't done, the table will not display. $this->_column_headers = array( $this->columns, array(), $this->sortable_columns ); // If no items per page options key is set, return, as it means // this table won't paginate. if ( ! $this->items_per_page_screen_options_key ) { return; } // Set pagination args so WP_List_Table knows what to render. $total_items = $this->get_total_items(); $per_page = $this->get_items_per_page( $this->items_per_page_screen_options_key, 25 ); $total_pages = (int) ceil( $total_items / $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => $total_pages, ) ); } /** * Generate the table navigation above or below the table * * @since 3.0.0 * * @param string $which The location of the bulk actions: 'top' or 'bottom'. * This is designated as optional for backward compatibility. */ protected function display_tablenav( $which ) { // Define a nonce for search submissions. if ( 'top' === $which ) { wp_nonce_field( 'bulk-' . $this->_args['plural'] ); } ?>