From c4d4a623b5627315cc5cc8bddad620a5c578e0be Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 18 May 2015 15:33:36 -0300 Subject: [PATCH] Improved the API Keys table list, added actions and fixed the links --- .../class-wc-admin-api-keys-table-list.php | 52 +++++++------------ .../class-wc-admin-webhooks-table-list.php | 6 +-- .../admin/settings/views/html-keys-edit.php | 2 +- 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/includes/admin/class-wc-admin-api-keys-table-list.php b/includes/admin/class-wc-admin-api-keys-table-list.php index 34a74b78df1..c46eea3eb54 100644 --- a/includes/admin/class-wc-admin-api-keys-table-list.php +++ b/includes/admin/class-wc-admin-api-keys-table-list.php @@ -39,8 +39,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table { 'cb' => '', 'description' => __( 'Description', 'woocommerce' ), 'user' => __( 'User', 'woocommerce' ), - 'permissions' => __( 'Permissions', 'woocommerce' ), - 'actions' => __( 'Actions', 'woocommerce' ), + 'permissions' => __( 'Permissions', 'woocommerce' ) ); } @@ -61,14 +60,33 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table { * @return string */ public function column_description( $key ) { + $url = admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&edit-key=' . $key['key_id'] ); + $output = ''; + $output .= ''; if ( empty( $key['description'] ) ) { $output .= esc_html__( 'API Key', 'woocommerce' ); } else { $output .= esc_html( $key['description'] ); } + $output .= ''; $output .= ''; + // Get actions + $actions = array( + 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $key['key_id'] ), + 'edit' => '' . __( 'View/Edit', 'woocommerce' ) . '', + 'trash' => '' . __( 'Revoke', 'woocommerce' ) . '' + ); + + $row_actions = array(); + + foreach ( $actions as $action => $link ) { + $row_actions[] = '' . $link . ''; + } + + $output .= '
' . implode( ' | ', $row_actions ) . '
'; + return $output; } @@ -115,36 +133,6 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table { } } - /** - * Return actions column - * - * @param array $key - * @return string - */ - public function column_actions( $key ) { - $actions = array(); - - $actions['revoke'] = array( - 'url' => wp_nonce_url( add_query_arg( 'revoke', $key['key_id'] ), 'revoke' ), - 'name' => __( 'Revoke API Key', 'woocommerce' ), - 'action' => 'revoke' - ); - - $actions['edit'] = array( - 'url' => admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&edit-key=' . $key['key_id'] ), - 'name' => __( 'View/Edit', 'woocommerce' ), - 'action' => 'edit' - ); - - $output = ''; - - foreach ( $actions as $action ) { - $output .= sprintf( '%3$s', esc_attr( $action['action'] ), esc_url( $action['url'] ), esc_attr( $action['name'] ) ); - } - - return $output; - } - /** * Get bulk actions * diff --git a/includes/admin/class-wc-admin-webhooks-table-list.php b/includes/admin/class-wc-admin-webhooks-table-list.php index 15518563ba1..6834ea6f9f6 100644 --- a/includes/admin/class-wc-admin-webhooks-table-list.php +++ b/includes/admin/class-wc-admin-webhooks-table-list.php @@ -86,7 +86,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table { if ( 'trash' == $post_status ) { $output .= esc_html( $title ); } else { - $output .= '' . esc_html( $title ) . ''; + $output .= '' . esc_html( $title ) . ''; } $output .= ''; @@ -96,12 +96,12 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table { ); if ( current_user_can( $post_type_object->cap->edit_post, $the_webhook->id ) && 'trash' !== $post_status ) { - $actions['edit'] = '' . __( 'Edit', 'woocommerce' ) . ''; + $actions['edit'] = '' . __( 'Edit', 'woocommerce' ) . ''; } if ( current_user_can( $post_type_object->cap->delete_post, $the_webhook->id ) ) { if ( 'trash' == $post_status ) { - $actions['untrash'] = '' . __( 'Restore', 'woocommerce' ) . ''; + $actions['untrash'] = '' . __( 'Restore', 'woocommerce' ) . ''; } elseif ( EMPTY_TRASH_DAYS ) { $actions['trash'] = '' . __( 'Trash', 'woocommerce' ) . ''; } diff --git a/includes/admin/settings/views/html-keys-edit.php b/includes/admin/settings/views/html-keys-edit.php index bcd5977289e..675bbf1a92d 100644 --- a/includes/admin/settings/views/html-keys-edit.php +++ b/includes/admin/settings/views/html-keys-edit.php @@ -119,7 +119,7 @@ if ( ! defined( 'ABSPATH' ) ) { ?>

- +