Add maybe blank check for API keys & webhooks

For consistency purpose in the way we display empty data (like orders
or coupons), the maybe blank check replaces the default empty table by
a more friendly message explaining the purpose of API keys and webhooks.

Results:

![](http://cld.wthms.co/cEF9+)
This commit is contained in:
corsonr 2017-03-17 23:49:19 +01:00
parent 476041698f
commit c126ee9a99
2 changed files with 46 additions and 16 deletions

View File

@ -58,8 +58,15 @@ class WC_Admin_API_Keys {
* 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>';
// Get the API keys count
$count = $wpdb->get_var( "SELECT COUNT(key_id) FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1;" );
if ( absint( $count ) && $count > 0 ) {
$keys_table_list = new WC_Admin_API_Keys_Table_List();
$keys_table_list->prepare_items();
@ -70,6 +77,14 @@ class WC_Admin_API_Keys {
$keys_table_list->views();
$keys_table_list->search_box( __( 'Search key', 'woocommerce' ), 'key' );
$keys_table_list->display();
} else {
echo '<div class="woocommerce-BlankState">';
?>
<h2 class="woocommerce-BlankState-message"><?php _e( 'The WooCommerce REST API works on a key system to control access. These keys are linked to WordPress users on your website.', 'woocommerce' ); ?></h2>
<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=api&section=keys&create-key=1' ) ); ?>"><?php _e( 'Create your first key!', 'woocommerce' ); ?></a>
<?php echo '<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; } </style></div>';
}
}
/**

View File

@ -428,8 +428,15 @@ class WC_Admin_Webhooks {
* Table list output.
*/
private static function table_list_output() {
global $wpdb;
echo '<h2>' . __( 'Webhooks', 'woocommerce' ) . ' <a href="' . esc_url( wp_nonce_url( admin_url( 'admin.php?page=wc-settings&tab=api&section=webhooks&create-webhook=1' ), 'create-webhook' ) ) . '" class="add-new-h2">' . __( 'Add webhook', 'woocommerce' ) . '</a></h2>';
// Get the webhooks count
$count = array_sum( (array) wp_count_posts( 'shop_webhook', 'readable' ) );
if ( absint( $count ) && $count > 0 ) {
$webhooks_table_list = new WC_Admin_Webhooks_Table_List();
$webhooks_table_list->prepare_items();
@ -440,6 +447,14 @@ class WC_Admin_Webhooks {
$webhooks_table_list->views();
$webhooks_table_list->search_box( __( 'Search webhooks', 'woocommerce' ), 'webhook' );
$webhooks_table_list->display();
} else {
echo '<div class="woocommerce-BlankState">';
?>
<h2 class="woocommerce-BlankState-message"><?php _e( 'Webhooks are event notifications sent to a URL of your choice. They are useful for integrating with third-party services and other external API that support them.', 'woocommerce' ); ?></h2>
<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=api&section=webhooks&create-webhook=1' ) ); ?>"><?php _e( 'Create your first webhook!', 'woocommerce' ); ?></a>
<?php echo '<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; } </style></div>';
}
}
/**