Skip to content

Commit

Permalink
#540 - Add filter docblocks for intial and subsequent audio generatio…
Browse files Browse the repository at this point in the history
…n toggle states. Keep the TTS voice selected value intact incase the service is reconnected.
  • Loading branch information
joshuaabenazer committed Aug 3, 2023
1 parent ca275e3 commit 5ae0a6a
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions includes/Classifai/Providers/Azure/TextToSpeech.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function sanitize_settings( $settings ) {
if ( ! empty( $current_settings['voices'] ) ) {
$current_settings['authenticated'] = true;
} else {
$current_settings['voices'] = [];
$current_settings['voices'] = [];
$current_settings['authenticated'] = false;
}
}
Expand Down Expand Up @@ -268,8 +268,6 @@ public function sanitize_settings( $settings ) {

if ( isset( $settings['voice'] ) && ! empty( $settings['voice'] ) ) {
$current_settings['voice'] = sanitize_text_field( $settings['voice'] );
} else {
$current_settings['voice'] = '';
}

return $current_settings;
Expand Down Expand Up @@ -452,6 +450,17 @@ public function get_default_settings() {
* @return {bool} The initial state of audio generation. Default true.
*/
public function get_audio_generation_initial_state( $post = null ) {
/**
* Initial state of the audio generation toggle when no audio already exists for the post.
*
* @since 2.3.0
* @hook classifai_audio_generation_initial_state
*
* @param {bool} $state Initial state of audio generation toggle on a post. Default true.
* @param {WP_Post} $post The current Post object.
*
* @return {bool} Initial state the audio generation toggle should be set to when no audio exists.
*/
return apply_filters( 'classifai_audio_generation_initial_state', true, get_post( $post ) );
}

Expand All @@ -466,6 +475,17 @@ public function get_audio_generation_initial_state( $post = null ) {
* @return {bool} The subsequenet state of audio generation. Default false.
*/
public function get_audio_generation_subsequent_state( $post = null ) {
/**
* Subsequent state of the audio generation toggle when audio exists for the post.
*
* @since 2.3.0
* @hook classifai_audio_generation_subsequent_state
*
* @param {bool} $state Subsequent state of audio generation toggle on a post. Default false.
* @param {WP_Post} $post The current Post object.
*
* @return {bool} Subsequent state the audio generation toggle should be set to when audio exists.
*/
return apply_filters( 'classifai_audio_generation_subsequent_state', false, get_post( $post ) );
}

Expand Down

0 comments on commit 5ae0a6a

Please sign in to comment.