__( 'API Key', 'easy-digital-downloads' ), 'plural' => __( 'API Keys', 'easy-digital-downloads' ), 'ajax' => false ) ); $this->query(); } /** * Gets the name of the primary column. * * @since 2.5 * @access protected * * @return string Name of the primary column. */ protected function get_primary_column_name() { return 'user'; } /** * This function renders most of the columns in the list table. * * @since 2.0 * * @param array $item Contains all the data of the keys * @param string $column_name The name of the column * * @return string Column Name */ public function column_default( $item, $column_name ) { return $item[ $column_name ]; } /** * Displays the public key rows * * @since 2.4 * * @param array $item Contains all the data of the keys * @param string $column_name The name of the column * * @return string Column Name */ public function column_key( $item ) { return ''; } /** * Displays the token rows * * @since 2.4 * * @param array $item Contains all the data of the keys * @param string $column_name The name of the column * * @return string Column Name */ public function column_token( $item ) { return ''; } /** * Displays the secret key rows * * @since 2.4 * * @param array $item Contains all the data of the keys * @param string $column_name The name of the column * * @return string Column Name */ public function column_secret( $item ) { return ''; } /** * Renders the column for the user field * * @since 2.0 * @return void */ public function column_user( $item ) { $actions = array(); if ( apply_filters( 'edd_api_log_requests', true ) ) { $actions['view'] = sprintf( '%s', esc_url( edd_get_admin_url( array( 'view' => 'api_requests', 'page' => 'edd-tools', 'tab' => 'logs', 's' => rawurlencode( $item['email'] ) ) ) ), __( 'View Log', 'easy-digital-downloads' ) ); } $actions['reissue'] = sprintf( '%s', esc_url( wp_nonce_url( add_query_arg( array( 'user_id' => absint( $item['id'] ), 'edd_action' => 'process_api_key', 'edd_api_process' => 'regenerate' ) ), 'edd-api-nonce' ) ), __( 'Reissue', 'easy-digital-downloads' ) ); $actions['revoke'] = sprintf( '%s', esc_url( wp_nonce_url( add_query_arg( array( 'user_id' => absint( $item['id'] ), 'edd_action' => 'process_api_key', 'edd_api_process' => 'revoke' ) ), 'edd-api-nonce' ) ), __( 'Revoke', 'easy-digital-downloads' ) ); $actions = apply_filters( 'edd_api_row_actions', array_filter( $actions ) ); return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); } /** * Retrieve the table columns * * @since 2.0 * @return array $columns Array of all the list table columns */ public function get_columns() { return array( 'user' => __( 'Username', 'easy-digital-downloads' ), 'key' => __( 'Public Key', 'easy-digital-downloads' ), 'token' => __( 'Token', 'easy-digital-downloads' ), 'secret' => __( 'Secret Key', 'easy-digital-downloads' ) ); } /** * Display the key generation form * * @since 1.5 * @return void */ public function bulk_actions( $which = '' ) { static $edd_api_is_bottom = false; if ( true === $edd_api_is_bottom ) { return; } if ( 'top' !== $which ) { return; } $edd_api_is_bottom = true; ?>
html->ajax_user_search(); ?>
_args['plural'] ); } ?>
bulk_actions( $which ); ?>
extra_tablenav( $which ); $this->pagination( $which ); ?>
'edd_user_secret_key', 'number' => $this->per_page, 'offset' => $this->per_page * ( $this->get_paged() - 1 ) ) ); $keys = array(); foreach( $users as $user ) { $keys[$user->ID]['id'] = $user->ID; $keys[$user->ID]['email'] = $user->user_email; $keys[$user->ID]['user'] = '' . esc_html( $user->user_login ) . ''; $keys[$user->ID]['key'] = EDD()->api->get_user_public_key( $user->ID ); $keys[$user->ID]['secret'] = EDD()->api->get_user_secret_key( $user->ID ); $keys[$user->ID]['token'] = EDD()->api->get_token( $user->ID ); } return $keys; } /** * Retrieve count of total users with keys * * @since 2.0 * @return int */ public function total_items() { global $wpdb; if ( ! get_transient( 'edd_total_api_keys' ) ) { $total_items = $wpdb->get_var( "SELECT count(user_id) FROM {$wpdb->usermeta} WHERE meta_value='edd_user_secret_key'" ); set_transient( 'edd_total_api_keys', $total_items, 60 * 60 ); } return get_transient( 'edd_total_api_keys' ); } /** * Setup the final data for the table * * @since 2.0 * @return void */ public function prepare_items() { $this->_column_headers = array( $this->get_columns(), array(), array(), 'user' ); $total_items = $this->total_items(); $this->items = $this->query(); $per_page = ! empty( $this->per_page ) ? $this->per_page : 30; $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => $total_items > 0 ? ceil( $total_items / $per_page ) : 0 ) ); } }