common = $common; } /** * Initialize box with 'Enable Amazon Polly' checkbox under the new post form. * * @param string $post New post. * * @since 0.1 */ public function display_box_content( $post) { $this->display_polly_gui( $post ); } private function render_voice_options( $language_code, $selected_voice_id ) { $neural_requested = $this->common->is_polly_neural_requested(); $voice_groups = $this->common->get_grouped_polly_voices( $language_code ); $has_voices = false; foreach ( $voice_groups as $group_key => $group ) { if ( empty( $group['voices'] ) ) { continue; } $has_voices = true; echo ''; } return $has_voices; } /** * Display Polly GUI on page for saving new post. * * @param string $post New post. * * @since 0.1 */ public function display_polly_gui( $post) { $nonce = wp_create_nonce( 'itron-polly-tts' ); echo ''; if ($this->common->is_polly_enabled()) { echo ''; $is_polly_enabled_for_post = get_post_meta( $post->ID, 'itron_polly_tts_enable', true ); if ('1' === $is_polly_enabled_for_post) { $polly_checked = 'checked'; } elseif ('0' === $is_polly_enabled_for_post) { $polly_checked = ''; } else { if ($this->common->is_polly_enabled_for_new_posts()) { $polly_checked = 'checked'; } else { $polly_checked = ''; } } $post_options_visibility = ''; echo '
'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- The constant contains the itron_polly_tts_ prefixed consent hook. do_action( AudioConsent::META_BOX_HOOK, $post ); echo '
No supported voices are currently available for this language in the selected AWS region.
'; } elseif ( $is_post_voice_override_disabled ) { echo 'Voice name: ' . esc_html( $voice_id ) . '
'; echo 'Custom per-post voice selection is disabled in plugin settings. This post will use the global voice.
'; } else { echo 'Voice name:
'; echo 'No supported voices are currently available for this language in the selected AWS region.
'; echo 'Neural-only voices require the global Neural setting to stay enabled.
'; } } catch ( \Exception $e ) { echo 'Unable to load supported Amazon Polly voices right now.
'; } echo ''; } elseif ( $this->common->has_post_audio( (int) $post->ID ) ) { echo '' . esc_html__( 'Text-to-speech is off. If this update changes the speech content or synthesis settings, the existing audio will be removed without generating a replacement. An unchanged save will keep it.', 'ai-text-to-speech-using-aws-polly' ) . '
'; } echo '' . esc_html__( 'AWS charges may apply.', 'ai-text-to-speech-using-aws-polly' ) . ' ' . esc_html__( 'View official Amazon Polly pricing.', 'ai-text-to-speech-using-aws-polly' ) . '
'; } }