Save and use the per page screen option value for API Keys
This commit is contained in:
parent
ccc10083fe
commit
018da951ce
|
@ -2,10 +2,8 @@
|
||||||
/**
|
/**
|
||||||
* WooCommerce API Keys Table List
|
* WooCommerce API Keys Table List
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @package WooCommerce\Admin
|
||||||
* @category Admin
|
* @version 2.4.0
|
||||||
* @package WooCommerce/Admin
|
|
||||||
* @version 2.4.0
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
@ -177,7 +175,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
||||||
public function prepare_items() {
|
public function prepare_items() {
|
||||||
global $wpdb;
|
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();
|
$columns = $this->get_columns();
|
||||||
$hidden = array();
|
$hidden = array();
|
||||||
$sortable = $this->get_sortable_columns();
|
$sortable = $this->get_sortable_columns();
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
/**
|
/**
|
||||||
* WooCommerce Admin API Keys Class
|
* WooCommerce Admin API Keys Class
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @package WooCommerce\Admin
|
||||||
* @category Admin
|
* @version 2.4.0
|
||||||
* @package WooCommerce/Admin
|
|
||||||
* @version 2.4.0
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
@ -22,6 +20,7 @@ class WC_Admin_API_Keys {
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
add_action( 'admin_init', array( $this, 'actions' ) );
|
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.
|
* Table list output.
|
||||||
*/
|
*/
|
||||||
private static function table_list_output() {
|
private static function table_list_output() {
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
echo '<h2>' . __( 'Keys/Apps', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&create-key=1' ) ) . '" class="add-new-h2">' . __( 'Add key', 'woocommerce' ) . '</a></h2>';
|
echo '<h2>' . __( 'Keys/Apps', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&create-key=1' ) ) . '" class="add-new-h2">' . __( 'Add key', 'woocommerce' ) . '</a></h2>';
|
||||||
|
|
|
@ -229,7 +229,7 @@ class WC_Admin_Menus {
|
||||||
* @param int $value The number of rows to use.
|
* @param int $value The number of rows to use.
|
||||||
*/
|
*/
|
||||||
public function set_screen_option( $status, $option, $value ) {
|
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;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,11 +272,9 @@ class WC_Admin_Webhooks {
|
||||||
* Add screen option.
|
* Add screen option.
|
||||||
*/
|
*/
|
||||||
public function screen_option() {
|
public function screen_option() {
|
||||||
global $webhooks_table_list;
|
|
||||||
|
|
||||||
if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
|
if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
|
||||||
add_screen_option( 'per_page', array(
|
add_screen_option( 'per_page', array(
|
||||||
'default' => 20,
|
'default' => 10,
|
||||||
'option' => 'wc_webhooks_per_page',
|
'option' => 'wc_webhooks_per_page',
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue