'US East (N. Virginia)', 'us-east-2' => 'US East (Ohio)', 'us-west-1' => 'US West (N. California)', 'us-west-2' => 'US West (Oregon)', 'af-south-1' => 'Africa (Cape Town)', 'ap-east-1' => 'Asia Pacific (Hong Kong)', 'ap-southeast-5' => 'Asia Pacific (Malaysia)', 'ap-south-1' => 'Asia Pacific (Mumbai)', 'ap-northeast-3' => 'Asia Pacific (Osaka)', 'ap-northeast-2' => 'Asia Pacific (Seoul)', 'ap-southeast-1' => 'Asia Pacific (Singapore)', 'ap-southeast-2' => 'Asia Pacific (Sydney)', 'ap-southeast-7' => 'Asia Pacific (Thailand)', 'ap-northeast-1' => 'Asia Pacific (Tokyo)', 'ca-central-1' => 'Canada (Central)', 'eu-central-1' => 'Europe (Frankfurt)', 'eu-west-1' => 'Europe (Ireland)', 'eu-west-2' => 'Europe (London)', 'eu-west-3' => 'Europe (Paris)', 'eu-south-2' => 'Europe (Spain)', 'eu-north-1' => 'Europe (Stockholm)', 'eu-central-2' => 'Europe (Zurich)', 'me-south-1' => 'Middle East (Bahrain)', 'sa-east-1' => 'South America (Sao Paulo)', 'us-gov-west-1' => 'AWS GovCloud (US-West)', ); /** * GeneralConfiguration constructor. * * @param Common $common */ public function __construct( Common $common) { $this->common = $common; } public function itron_polly_tts_add_menu() { $this->plugin_screen_hook_suffix = add_menu_page( __( 'AI Text-to-Speech', 'ai-text-to-speech-using-aws-polly' ), __( 'AI TTS', 'ai-text-to-speech-using-aws-polly' ), 'manage_options', 'itron_polly_tts', array( $this, 'render_settings_page', ), 'dashicons-controls-volumeon' ); $this->plugin_screen_hook_suffix = add_submenu_page( 'itron_polly_tts', 'General', 'General', 'manage_options', 'itron_polly_tts', array( $this, 'render_settings_page', ) ); } public function render_settings_page() { ?>
Defined as php constant
'; } } /** * Render the Secret Key input for this plugin * * @since 0.1 */ function secret_key_gui() { $name = 's3_secret_key'; $option = self::OPTION_PREFIX . $name; $is_disabled = self::is_overloaded( $name ); echo ' '; if ( $is_disabled ) { echo 'Defined as php constant
'; } } function s3_bucket_gui() { $name = 's3_bucket_name'; $option = self::OPTION_PREFIX . $name; $is_disabled = self::is_overloaded( $name ); echo ' '; if ( $is_disabled ) { echo 'Defined as php constant
'; } } /** * Render the region input. * * @since 0.1 */ function region_gui() { $name = 's3_region'; $option = self::OPTION_PREFIX . $name; $selected_region = $this->get_option( $name ); $regions = $this->get_regions(); if ( empty( $selected_region ) ) { $selected_region = array_key_first( $regions ); } $is_disabled = self::is_overloaded( $name ); echo ''; if ( $is_disabled ) { echo 'Defined as php constant
'; } } function general_gui() { printf( '', esc_url( 'https://github.com/hokoo/aws-polly/blob/master/plugin-dir/readme.txt' ), esc_html__( 'View the plugin setup and AWS credentials guide.', 'ai-text-to-speech-using-aws-polly' ) ); } function storage_gui() { //Empty } private static function is_overloaded( $option_slug ): bool { return defined( self::CONST_PREFIX . strtoupper( $option_slug ) ); } private static function get_overloaded( $option_slug ) { return constant( self::CONST_PREFIX . strtoupper( $option_slug ) ); } public static function get_option( $option_name ) { if ( self::is_overloaded( $option_name ) ) { return self::get_overloaded( $option_name ); } return (string) get_option( self::OPTION_PREFIX . $option_name ); } /** * Get S3 bucket name. The method uses filter 'itron_polly_tts_s3_bucket_name, * which allows to use customer S3 bucket name instead of default one. * * @since 0.1 */ public static function get_bucket_name() { return self::get_option( 's3_bucket_name' ); } public static function get_aws_access_key() { return self::get_option( 's3_access_key' ); } public static function get_aws_secret_key() { return self::get_option( 's3_secret_key' ); } public static function get_aws_region() { $region = self::get_option( 's3_region' ); return '' === $region ? self::DEFAULT_REGION : $region; } }