2015-05-16 02:03:24 +00:00
< ? php
if ( ! defined ( 'ABSPATH' ) ) {
exit ;
}
?>
2015-05-16 03:09:29 +00:00
< div id = " key-fields " class = " settings-panel " >
2016-10-12 10:16:30 +00:00
< h2 >< ? php _e ( 'Key details' , 'woocommerce' ); ?> </h2>
2015-06-08 22:41:35 +00:00
< input type = " hidden " id = " key_id " value = " <?php echo esc_attr( $key_id ); ?> " />
2015-06-08 23:22:49 +00:00
< table id = " api-keys-options " class = " form-table " >
2015-05-16 03:09:29 +00:00
< tbody >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
< label for = " key_description " >< ? php _e ( 'Description' , 'woocommerce' ); ?> </label>
2015-10-23 15:09:08 +00:00
< ? php echo wc_help_tip ( __ ( 'Friendly name for identifying this key.' , 'woocommerce' ) ); ?>
2015-05-16 03:09:29 +00:00
</ th >
< td class = " forminp " >
2015-06-08 22:41:35 +00:00
< input id = " key_description " type = " text " class = " input-text regular-input " value = " <?php echo esc_attr( $key_data['description'] ); ?> " />
2015-05-16 03:09:29 +00:00
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
< label for = " key_user " >< ? php _e ( 'User' , 'woocommerce' ); ?> </label>
2015-10-23 15:09:08 +00:00
< ? php echo wc_help_tip ( __ ( 'Owner of these keys.' , 'woocommerce' ) ); ?>
2015-05-16 03:09:29 +00:00
</ th >
< td class = " forminp " >
< ? php
2015-05-18 18:23:05 +00:00
$curent_user_id = get_current_user_id ();
$user_id = ! empty ( $key_data [ 'user_id' ] ) ? absint ( $key_data [ 'user_id' ] ) : $curent_user_id ;
$user = get_user_by ( 'id' , $user_id );
2016-10-29 10:16:03 +00:00
/* translators: 1: user display name 2: user ID 3: user email */
2016-10-13 16:34:48 +00:00
$user_string = sprintf (
esc_html__ ( '%1$s (#%2$s – %3$s)' , 'woocommerce' ),
$user -> display_name ,
absint ( $user -> ID ),
$user -> user_email
);
2015-05-18 18:23:05 +00:00
?>
2016-12-21 14:18:33 +00:00
< select class = " wc-customer-search " id = " key_user " data - placeholder = " <?php esc_attr_e( 'Search for a user…', 'woocommerce' ); ?> " data - allow_clear = " true " >
< option value = " <?php echo esc_attr( $user_id ); ?> " selected = " selected " >< ? php echo $user_string ; ?> <option>
</ select >
2015-05-16 03:09:29 +00:00
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
2015-08-01 17:42:10 +00:00
< label for = " key_permissions " >< ? php _e ( 'Permissions' , 'woocommerce' ); ?> </label>
2015-10-23 15:09:08 +00:00
< ? php echo wc_help_tip ( __ ( 'Select the access type of these keys.' , 'woocommerce' ) ); ?>
2015-05-16 03:09:29 +00:00
</ th >
< td class = " forminp " >
2015-06-08 22:41:35 +00:00
< select id = " key_permissions " class = " wc-enhanced-select " >
2015-05-16 03:09:29 +00:00
< ? php
$permissions = array (
'read' => __ ( 'Read' , 'woocommerce' ),
'write' => __ ( 'Write' , 'woocommerce' ),
'read_write' => __ ( 'Read/Write' , 'woocommerce' ),
);
foreach ( $permissions as $permission_id => $permission_name ) : ?>
< option value = " <?php echo esc_attr( $permission_id ); ?> " < ? php selected ( $key_data [ 'permissions' ], $permission_id , true ); ?> ><?php echo esc_html( $permission_name ); ?></option>
< ? php endforeach ; ?>
</ select >
</ td >
</ tr >
2015-07-16 18:42:00 +00:00
< ? php if ( 0 !== $key_id ) : ?>
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
2016-10-12 10:16:30 +00:00
< ? php _e ( 'Consumer key ending in' , 'woocommerce' ); ?>
2015-07-16 18:42:00 +00:00
</ th >
< td class = " forminp " >
< code >& hellip ; < ? php echo esc_html ( $key_data [ 'truncated_key' ] ); ?> </code>
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
2016-10-12 10:16:30 +00:00
< ? php _e ( 'Last access' , 'woocommerce' ); ?>
2015-07-16 18:42:00 +00:00
</ th >
< td class = " forminp " >
< span >< ? php
if ( ! empty ( $key_data [ 'last_access' ] ) ) {
2016-10-24 07:31:07 +00:00
/* translators: 1: last access date 2: last access time */
$date = sprintf ( __ ( '%1$s at %2$s' , 'woocommerce' ), date_i18n ( wc_date_format (), strtotime ( $key_data [ 'last_access' ] ) ), date_i18n ( wc_time_format (), strtotime ( $key_data [ 'last_access' ] ) ) );
2015-07-16 18:42:00 +00:00
echo apply_filters ( 'woocommerce_api_key_last_access_datetime' , $date , $key_data [ 'last_access' ] );
} else {
_e ( 'Unknown' , 'woocommerce' );
}
?> </span>
</ td >
</ tr >
< ? php endif ?>
2015-05-16 03:09:29 +00:00
</ tbody >
</ table >
< ? php do_action ( 'woocommerce_admin_key_fields' , $key_data ); ?>
< ? php
2015-05-18 18:23:05 +00:00
if ( 0 == $key_id ) {
2016-10-12 10:16:30 +00:00
submit_button ( __ ( 'Generate API key' , 'woocommerce' ), 'primary' , 'update_api_key' );
2015-05-16 03:09:29 +00:00
} else {
2015-05-18 18:23:05 +00:00
?>
< p class = " submit " >
2016-03-24 17:26:40 +00:00
< ? php submit_button ( __ ( 'Save changes' , 'woocommerce' ), 'primary' , 'update_api_key' , false ); ?>
2016-10-12 10:16:30 +00:00
< a style = " color: #a00; text-decoration: none; margin-left: 10px; " href = " <?php echo esc_url( wp_nonce_url( add_query_arg( array( 'revoke-key' => $key_id ), admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys' ) ), 'revoke' ) ); ?> " >< ? php _e ( 'Revoke key' , 'woocommerce' ); ?> </a>
2015-05-18 18:23:05 +00:00
</ p >
< ? php
2015-05-16 03:09:29 +00:00
}
?>
</ div >
2015-06-08 22:41:35 +00:00
2015-08-05 18:02:55 +00:00
< script type = " text/template " id = " tmpl-api-keys-template " >
2016-03-02 18:13:17 +00:00
< p id = " copy-error " ></ p >
2015-06-08 22:41:35 +00:00
< table class = " form-table " >
< tbody >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
2016-10-12 10:16:30 +00:00
< ? php _e ( 'Consumer key' , 'woocommerce' ); ?>
2015-06-08 22:41:35 +00:00
</ th >
< td class = " forminp " >
2016-03-10 17:39:52 +00:00
< input id = " key_consumer_key " type = " text " value = " { { data.consumer_key }} " size = " 55 " readonly = " readonly " > < button type = " button " class = " button-secondary copy-key " data - tip = " <?php esc_attr_e( 'Copied!', 'woocommerce' ); ?> " >< ? php _e ( 'Copy' , 'woocommerce' ); ?> </button>
2015-06-08 22:41:35 +00:00
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
2016-10-12 10:16:30 +00:00
< ? php _e ( 'Consumer secret' , 'woocommerce' ); ?>
2015-06-08 22:41:35 +00:00
</ th >
< td class = " forminp " >
2016-03-10 17:39:52 +00:00
< input id = " key_consumer_secret " type = " text " value = " { { data.consumer_secret }} " size = " 55 " readonly = " readonly " > < button type = " button " class = " button-secondary copy-secret " data - tip = " <?php esc_attr_e( 'Copied!', 'woocommerce' ); ?> " >< ? php _e ( 'Copy' , 'woocommerce' ); ?> </button>
2015-06-08 22:41:35 +00:00
</ td >
</ tr >
< tr valign = " top " >
< th scope = " row " class = " titledesc " >
< ? php _e ( 'QRCode' , 'woocommerce' ); ?>
</ th >
< td class = " forminp " >
< div id = " keys-qrcode " ></ div >
</ td >
</ tr >
</ tbody >
</ table >
</ script >