make `wccom` commands text translatable, add application-password section URL (#34363)
* make text translatable, add application-password section url * fix URL * add missing `translators:` comments, fix wront params order
This commit is contained in:
parent
4dcff8ccf1
commit
0654c4a7c6
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Make connect text translatable, add application-password section URL
|
|
@ -16,6 +16,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
* @package WooCommerce
|
* @package WooCommerce
|
||||||
*/
|
*/
|
||||||
class WC_CLI_COM_Command {
|
class WC_CLI_COM_Command {
|
||||||
|
const APPLICATION_PASSWORD_SECTION_URL = 'https://woocommerce.com/my-account/#application-passwords';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a commands for managing WooCommerce.com extensions.
|
* Registers a commands for managing WooCommerce.com extensions.
|
||||||
*/
|
*/
|
||||||
|
@ -110,12 +112,12 @@ class WC_CLI_COM_Command {
|
||||||
*/
|
*/
|
||||||
public static function disconnect( array $args, array $assoc_args ) {
|
public static function disconnect( array $args, array $assoc_args ) {
|
||||||
if ( ! WC_Helper::is_site_connected() ) {
|
if ( ! WC_Helper::is_site_connected() ) {
|
||||||
WP_CLI::error( 'Your store is not connected to WooCommerce.com. Run `wp wc com connect` command.' );
|
WP_CLI::error( __( 'Your store is not connected to WooCommerce.com. Run `wp wc com connect` command.', 'woocommerce' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
WP_CLI::confirm( 'Are you sure you want to disconnect your store from WooCommerce.com?', $assoc_args );
|
WP_CLI::confirm( __( 'Are you sure you want to disconnect your store from WooCommerce.com?', 'woocommerce' ), $assoc_args );
|
||||||
WC_Helper::disconnect();
|
WC_Helper::disconnect();
|
||||||
WP_CLI::success( 'You have successfully disconnected your store from WooCommerce.com' );
|
WP_CLI::success( __( 'You have successfully disconnected your store from WooCommerce.com', 'woocommerce' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,20 +154,21 @@ class WC_CLI_COM_Command {
|
||||||
if ( $force ) {
|
if ( $force ) {
|
||||||
WC_Helper::disconnect();
|
WC_Helper::disconnect();
|
||||||
} else {
|
} else {
|
||||||
WP_CLI::error( 'Your store is already connected.' );
|
WP_CLI::error( __( 'Your store is already connected.', 'woocommerce' ) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:ignore
|
|
||||||
// @todo add URL to application password section
|
|
||||||
if ( empty( $password ) ) {
|
if ( empty( $password ) ) {
|
||||||
$password = self::ask( 'Connection password:' );
|
// translators: %s is the URL for the application-password section in WooCommerce.com.
|
||||||
|
WP_CLI::log( sprintf( __( 'If you don\'t have an application password (not your account password), generate a password from %s', 'woocommerce' ), esc_url( self::APPLICATION_PASSWORD_SECTION_URL ) ) );
|
||||||
|
$password = self::ask( __( 'Connection password:', 'woocommerce' ) );
|
||||||
}
|
}
|
||||||
$password = sanitize_text_field( $password );
|
$password = sanitize_text_field( $password );
|
||||||
if ( empty( $password ) ) {
|
if ( empty( $password ) ) {
|
||||||
WP_CLI::error( 'Invalid password.' );
|
// translators: %s is the URL for the application-password section in WooCommerce.com.
|
||||||
|
WP_CLI::error( sprintf( __( 'Invalid password. Generate a new one from %s.', 'woocommerce' ), esc_url( self::APPLICATION_PASSWORD_SECTION_URL ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$auth = WC_Helper::connect_with_password( $password );
|
$auth = WC_Helper::connect_with_password( $password );
|
||||||
|
@ -174,7 +177,7 @@ class WC_CLI_COM_Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( WC_Helper::is_site_connected() ) {
|
if ( WC_Helper::is_site_connected() ) {
|
||||||
WP_CLI::success( 'Store connected successfully.' );
|
WP_CLI::success( __( 'Store connected successfully.', 'woocommerce' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue