WC_Admin_Webhooks_Table_List::prepare_items()

Prepare table list items.


Description Description


Source Source

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

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
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,
        )
    );
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.