Save and use the per page screen option value for API Keys

This commit is contained in:
Shiva Poudel 2018-02-06 01:30:12 +05:45
parent ccc10083fe
commit 018da951ce
4 changed files with 20 additions and 14 deletions

View File

@ -2,10 +2,8 @@
/**
* WooCommerce API Keys Table List
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.4.0
* @package WooCommerce\Admin
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -177,7 +175,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
public function prepare_items() {
global $wpdb;
$per_page = apply_filters( 'woocommerce_api_keys_settings_items_per_page', 10 );
$per_page = $this->get_items_per_page( 'wc_api_keys_per_page' );
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();

View File

@ -2,10 +2,8 @@
/**
* WooCommerce Admin API Keys Class
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.4.0
* @package WooCommerce\Admin
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -22,6 +20,7 @@ class WC_Admin_API_Keys {
*/
public function __construct() {
add_action( 'admin_init', array( $this, 'actions' ) );
add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
}
/**
@ -54,11 +53,22 @@ class WC_Admin_API_Keys {
}
}
/**
* Add screen option.
*/
public function screen_option() {
if ( ! isset( $_GET['create-key'], $_GET['edit-key'] ) && $this->is_api_keys_settings_page() ) {
add_screen_option( 'per_page', array(
'default' => 10,
'option' => 'wc_api_keys_per_page',
) );
}
}
/**
* Table list output.
*/
private static function table_list_output() {
global $wpdb;
echo '<h2>' . __( 'Keys/Apps', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=api&section=keys&create-key=1' ) ) . '" class="add-new-h2">' . __( 'Add key', 'woocommerce' ) . '</a></h2>';

View File

@ -229,7 +229,7 @@ class WC_Admin_Menus {
* @param int $value The number of rows to use.
*/
public function set_screen_option( $status, $option, $value ) {
if ( in_array( $option, array( 'wc_webhooks_per_page' ), true ) ) {
if ( in_array( $option, array( 'wc_webhooks_per_page', 'wc_api_keys_per_page' ), true ) ) {
return $value;
}

View File

@ -272,11 +272,9 @@ class WC_Admin_Webhooks {
* Add screen option.
*/
public function screen_option() {
global $webhooks_table_list;
if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
add_screen_option( 'per_page', array(
'default' => 20,
'default' => 10,
'option' => 'wc_webhooks_per_page',
) );
}