jetpack_cli_are_you_sure

Standard "ask for permission to continue" function.

Description

jetpack_cli_are_you_sure( (constant) $flagged = false, (bool) $error_msg = false ); 

If action cancelled, ask if they need help.

Written outside of the class so it's not listed as an executable command w/ wp jetpack

Parameters (2)

0. $flagged — Optional. (constant) => false
Bool false = normal option | true = flagged by get_jetpack_options_for_reset()
1. $error_msg — Optional. (bool) => false
String (optional)

Usage

  1. if ( !function_exists( 'jetpack_cli_are_you_sure' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/class.jetpack-cli.php'; 
  3.  
  4. // bool false = normal option | true = flagged by get_jetpack_options_for_reset() 
  5. $flagged = false; 
  6.  
  7. // string (optional) 
  8. $error_msg = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = jetpack_cli_are_you_sure($flagged, $error_msg); 
  12.  

Defined (1)

The function is defined in the following location(s).

/class.jetpack-cli.php  
  1. function jetpack_cli_are_you_sure( $flagged = false, $error_msg = false ) { 
  2. $cli = new Jetpack_CLI(); 
  3.  
  4. // Default cancellation message 
  5. if ( ! $error_msg ) { 
  6. $error_msg = 
  7. __( 'Action cancelled. Have a question?', jetpack ) 
  8. . ' ' 
  9. . $cli->green_open 
  10. . 'jetpack.me/support' 
  11. . $cli->color_close; 
  12.  
  13. if ( ! $flagged ) { 
  14. $prompt_message = __( 'Are you sure? This cannot be undone. Type "yes" to continue:', '"yes" is a command. Do not translate that.', jetpack ); 
  15. } else { 
  16. /** translators: Don't translate the word yes here. */ 
  17. $prompt_message = __( 'Are you sure? Modifying this option may disrupt your Jetpack connection. Type "yes" to continue.', jetpack ); 
  18.  
  19. WP_CLI::line( $prompt_message ); 
  20. $handle = fopen( "php://stdin", "r" ); 
  21. $line = fgets( $handle ); 
  22. if ( 'yes' != trim( $line ) ) { 
  23. WP_CLI::error( $error_msg );