WC_Admin_Webhooks_Table_List::prepare_items() – Prepare table list items.

You appear to be a bot. Output may be restricted

Description

Prepare table list items.

Usage

WC_Admin_Webhooks_Table_List::prepare_items();

Parameters

Returns

void

Source

File name: woocommerce/includes/admin/class-wc-admin-webhooks-table-list.php
Lines:

1 to 35 of 35
  public function prepare_items() {
    $per_page     = $this->get_items_per_page( 'woocommerce_webhooks_per_page' );
    $current_page = $this->get_pagenum();

    // Query args.
    $args = array(
      'limit'  => $per_page,
      'offset' => $per_page * ( $current_page - 1 ),
    );

    // Handle the status query.
    if ( ! empty( $_REQUEST['status'] ) ) { // WPCS: input var okay, CSRF ok.
      $args['status'] = sanitize_key( wp_unslash( $_REQUEST['status'] ) ); // WPCS: input var okay, CSRF ok.
    }

    if ( ! empty( $_REQUEST['s'] ) ) { // WPCS: input var okay, CSRF ok.
      $args['search'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // WPCS: input var okay, CSRF ok.
    }

    $args['paginate'] = true;

    // Get the webhooks.
    $data_store  = WC_Data_Store::load( 'webhook' );
    $webhooks    = $data_store->search_webhooks( $args );
    $this->items = array_map( 'wc_get_webhook', $webhooks->webhooks );

    // Set the pagination.
    $this->set_pagination_args(
      array(
        'total_items' => $webhooks->total,
        'per_page'    => $per_page,
        'total_pages' => $webhooks->max_num_pages,
      )
    );
  }
 

 View on GitHub View on Trac