Plugin Directory

Changeset 1991560


Ignore:
Timestamp:
12/11/2018 09:00:32 AM (7 years ago)
Author:
awslabs
Message:

trunk 2.6.1

Location:
amazon-polly/trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • amazon-polly/trunk/README.md

    r1967308 r1991560  
    77| Requires PHP | 5.6 |
    88| Tested up to | 4.9 |
    9 | Stable tag | 2.6.0 |
     9| Stable tag | 2.6.1 |
    1010| License | GPLv3 ONLY |
    1111| License URI | https://www.gnu.org/licenses/gpl-3.0.html |
     
    259259#### Changelog
    260260
     261= 2.6.1 =
     262* Added support for 8 new languages for translate functionality.
     263* Changed the way how audio is being generate (background process).
     264* Added a way of enabling plugin logging.
     265
    261266= 2.6.0 =
    262267* Fix problem with media library.
  • amazon-polly/trunk/README.txt

    r1967308 r1991560  
    55Requires PHP: 5.6
    66Tested up to: 4.9
    7 Stable tag: 2.6.0
     7Stable tag: 2.6.1
    88License: GPLv3 ONLY
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    252252== Changelog ==
    253253
     254= 2.6.1 =
     255* Added support for 8 new languages for translate functionality.
     256* Changed the way how audio is being generate (background process).
     257* Added a way of enabling plugin logging.
     258
    254259= 2.6.0 =
    255260* Fix problem with media library.
  • amazon-polly/trunk/admin/AmazonAI-Common.php

    r1967308 r1991560  
    1313    // Information about languages supported by the Amazon AI plugin
    1414    private $languages = [
    15         ['code' => 'da', 'name' => 'Danish', 'transable' => '', 'polly' => '1'],
    16         ['code' => 'nl', 'name' => 'Dutch', 'transable' => '', 'polly' => '1'],
     15        ['code' => 'da', 'name' => 'Danish', 'transable' => '1', 'polly' => '1'],
     16        ['code' => 'nl', 'name' => 'Dutch', 'transable' => '1', 'polly' => '1'],
    1717        ['code' => 'zh', 'name' => 'Chinese', 'transable' => '1', 'polly' => '1'],
    1818        ['code' => 'cs', 'name' => 'Czech', 'transable' => '1', 'polly' => ''],
    1919        ['code' => 'en', 'name' => 'English', 'transable' => '1', 'polly' => '1'],
     20        ['code' => 'fi', 'name' => 'Finish', 'transable' => '1', 'polly' => ''],
    2021        ['code' => 'fr', 'name' => 'French', 'transable' => '1', 'polly' => '1'],
    2122        ['code' => 'de', 'name' => 'German', 'transable' => '1', 'polly' => '1'],
     23        ['code' => 'he', 'name' => 'Hebraw', 'transable' => '1', 'polly' => ''],
    2224        ['code' => 'it', 'name' => 'Italian', 'transable' => '1', 'polly' => '1'],
     25        ['code' => 'id', 'name' => 'Indonesian', 'transable' => '1', 'polly' => ''],
    2326        ['code' => 'ja', 'name' => 'Japanese', 'transable' => '1', 'polly' => '1'],
    24         ['code' => 'ko', 'name' => 'Korean', 'transable' => '', 'polly' => '1'],
     27        ['code' => 'ko', 'name' => 'Korean', 'transable' => '1', 'polly' => '1'],
    2528        ['code' => 'nb', 'name' => 'Norwegian', 'transable' => '', 'polly' => '1'],
    26         ['code' => 'pl', 'name' => 'Polish', 'transable' => '', 'polly' => '1'],
     29        ['code' => 'pl', 'name' => 'Polish', 'transable' => '1', 'polly' => '1'],
    2730        ['code' => 'pt', 'name' => 'Portuguese', 'transable' => '1', 'polly' => '1'],
    2831        ['code' => 'ro', 'name' => 'Romanian', 'transable' => '', 'polly' => '1'],
    2932        ['code' => 'ru', 'name' => 'Russian', 'transable' => '1', 'polly' => '1'],
    3033        ['code' => 'es', 'name' => 'Spanish', 'transable' => '1', 'polly' => '1'],
    31         ['code' => 'sv', 'name' => 'Swedish', 'transable' => '', 'polly' => '1'],
     34        ['code' => 'sv', 'name' => 'Swedish', 'transable' => '1', 'polly' => '1'],
    3235        ['code' => 'tr', 'name' => 'Turkish', 'transable' => '1', 'polly' => '1'],
    3336        ['code' => 'cy', 'name' => 'Welsh', 'transable' => '', 'polly' => '1']
     
    214217    private $local_file_handler;
    215218    private $translate;
     219    private $logger;
     220
    216221    /**
    217222     * Creates SDK objects for the plugin.
     
    220225     */
    221226    public function __construct() {
    222         //Empty
     227        $this->logger = new AmazonAI_Logger();
    223228    }
    224229
     
    386391    }
    387392
     393    /**
     394     * Validates if logging is enabled.
     395     *
     396     * @since  2.6.1
     397     */
     398    public function is_logging_enabled() {
     399            $value = $this->checked_validator('amazon_ai_logging');
     400            if ('checked' == trim($value)) {
     401                return true;
     402            } else {
     403                return false;
     404            }
     405    }
    388406
    389407    /**
     
    582600        }
    583601
     602        $this->logger->log(sprintf('%s Sample rate: %s ', __METHOD__, $sample_rate));
     603
    584604        return $sample_rate;
    585605    }
     
    612632
    613633    public function if_translable_enabled_for_language($language_code) {
    614         $option = 'amazon_polly_trans_langs_' . $language_code;
    615         $value = $this->check_if_language_is_checked($option);
     634        $source_language_code = $this->get_source_language();
     635        $value = $this->check_if_language_is_checked($language_code, $source_language_code);
    616636        if (empty($value)) {
    617637            return false;
     
    626646     * @since  2.0.0
    627647     */
    628     public function check_if_language_is_checked($lang_code)
    629     {
    630         $value = get_option($lang_code, '');
    631         if ('amazon_polly_trans_langs_en' == $lang_code) {
    632             return ' checked ';
    633         }
     648    public function check_if_language_is_checked($language_code, $source_language_code)
     649    {
     650        #Some translations between languages are not supported by the service.
     651        #Details: https://docs.aws.amazon.com/translate/latest/dg/pairs.html
     652        if (!$this->is_translation_supported($source_language_code, $language_code)) {
     653            return '';
     654        }
     655
     656        $option = 'amazon_polly_trans_langs_' . $language_code;
     657
     658        $value = get_option($option, '');
    634659
    635660        if (empty($value)) {
     
    667692    {
    668693        $posttypes = get_option('amazon_polly_posttypes', 'post');
     694        $posttypes = str_replace(",", " ", $posttypes);
     695        $posttypes = preg_replace('!\s+!', ' ', $posttypes);
     696        update_option('amazon_polly_posttypes', $posttypes);
     697
    669698        return $posttypes;
    670699    }
     
    732761    {
    733762        $poweredby = get_option('amazon_polly_poweredby', 'on');
    734        
     763
    735764        if (empty($poweredby)) {
    736765            $result = false;
     
    10781107    public function clean_text($post_id, $with_title, $only_title)
    10791108    {
     1109
     1110        #$this->logger->log(sprintf('%s Cleaning text (%s, %s) ', __METHOD__, $with_title, $only_title));
     1111
    10801112        $clean_text = '';
    10811113
     
    13521384    }
    13531385
     1386    public function is_translation_supported($source_language, $target_language) {
     1387
     1388        if (( 'ko'== $source_language ) && ( 'he' == $target_language )) {
     1389            return false;
     1390        }
     1391
     1392        return true;
     1393    }
     1394
    13541395    /**
    13551396     * Register meta box for 'Enable Amazon Polly' on post creation form.
  • amazon-polly/trunk/admin/AmazonAI-GeneralConfiguration.php

    r1967308 r1991560  
    135135              'label_for' => 'amazon_polly_poweredby'
    136136          ));
     137          add_settings_field('amazon_ai_logging', __('Enable logging:', 'amazonpolly'), array(
     138              $this,
     139              'logging_gui'
     140          ), 'amazon_ai', 'amazon_ai_other', array(
     141              'label_for' => 'amazon_ai_logging'
     142          ));
    137143
    138144          register_setting('amazon_ai', 'amazon_ai_source_language');
     
    142148          register_setting('amazon_ai', 'amazon_polly_posttypes');
    143149          register_setting('amazon_ai', 'amazon_polly_poweredby');
     150          register_setting('amazon_ai', 'amazon_ai_logging');
    144151
    145152        }
     
    313320    }
    314321
     322    /**
     323     * Render the 'Enable Logging' input.
     324     *
     325     * @since  2.6.2
     326     */
     327    function logging_gui()
     328    {
     329      $checked = $this->common->checked_validator("amazon_ai_logging");
     330      echo '<input type="checkbox" name="amazon_ai_logging" id="amazon_ai_logging" ' . esc_attr($checked) . ' > <p class="description"></p>';
     331    }
     332
    315333    function other_gui()
    316334    {
  • amazon-polly/trunk/admin/AmazonAI-PodcastConfiguration.php

    r1941297 r1991560  
    5656                add_settings_field( 'amazon_polly_podcast_post_cat', __( 'Post categories:', 'amazonpolly' ), array( $this, 'podcast_post_cat_gui' ), 'amazon_ai_podcast', 'amazon_ai_podcast', array( 'label_for' => 'amazon_polly_podcast_post_cat' ) );
    5757                add_settings_field( 'amazon_polly_podcast_author', __( 'Author:', 'amazonpolly' ), array( $this, 'podcast_author_gui' ), 'amazon_ai_podcast', 'amazon_ai_podcast', array( 'label_for' => 'amazon_polly_podcast_author' ) );
     58                add_settings_field( 'amazon_polly_podcast_https', __( 'Use HTTPS for audio files:', 'amazonpolly' ), array( $this, 'podcast_https_gui' ), 'amazon_ai_podcast', 'amazon_ai_podcast', array( 'label_for' => 'amazon_polly_podcast_https' ) );
    5859
    5960                register_setting('amazon_ai_podcast', 'amazon_polly_podcast_email');
     
    6465                register_setting('amazon_ai_podcast', 'amazon_polly_podcast_post_cat');
    6566                register_setting('amazon_ai_podcast', 'amazon_polly_podcast_author');
    66             }
     67                register_setting('amazon_ai_podcast', 'amazon_polly_podcast_https');
     68            }
     69        }
     70
     71
     72        /**
     73         * Render the HTTPS podcast input.
     74         *
     75         * @since  4.0.5
     76         */
     77        public function podcast_https_gui() {
     78
     79            echo '<input type="checkbox" name="amazon_polly_podcast_https" id="amazon_polly_podcast_https" ' . $this->common->checked_validator( 'amazon_polly_podcast_https' ) . '> ';
     80
    6781        }
    6882
  • amazon-polly/trunk/admin/AmazonAI-PollyService.php

    r1967308 r1991560  
    1212
    1313class AmazonAI_PollyService {
     14    const GENERATE_POST_AUDIO_TASK = 'generate_post_audio';
     15    const NONCE_NAME = 'amazon-polly-post-nonce';
    1416
    1517    /**
    16      * Important. Run whenever new post is being created (or updated). The method executes Amazon Polly API to create audio file.
     18     * Important. Run whenever new post is being created (or updated). The method generates a background task to generate the audio file.
    1719     *
    1820     * @since    1.0.0
     
    2426        $common->init();
    2527
     28        $logger = new AmazonAI_Logger();
     29        $logger->log(sprintf('%s Saving post ( id=%s )', __METHOD__, $post_id));
     30
    2631        // Check if this isn't an auto save.
    2732        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     
    3742        $post_types_supported = $common->get_posttypes_array();
    3843        $post_type = get_post_type($post_id);
    39         if (!in_array($post_type, $post_types_supported )) {
     44        if ( !in_array($post_type, $post_types_supported) ) {
    4045            return;
    4146        }
    4247
    43         $is_quick_edit = isset($_POST['_inline_edit']) && wp_verify_nonce($_POST['_inline_edit'], 'inlineeditnonce');
    44         $is_polly_nonce_ok = isset( $_POST['amazon-polly-post-nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['amazon-polly-post-nonce'] ), 'amazon-polly' );
    45 
    46         // Check if this post is saved in 'regular' way.
    47         if (  $is_polly_nonce_ok || $is_quick_edit ) {
    48 
    49             $is_polly_enabled = isset( $_POST['amazon_polly_enable'] );
    50 
    51             // Check if translation deactivation flag is enabled. If yes, disable
    52             // and delete all files.
    53             $is_translate_deactivation_enabled = isset( $_POST['amazon_ai_deactive_translation'] );
    54             if ( !empty($is_translate_deactivation_enabled) ) {
     48        // If nonce is valid then update post meta
     49        // If it's not valid then this is probably a quick or bulk edit request in which case we won't update the polly post meta
     50        if ( isset($_POST[self::NONCE_NAME]) && wp_verify_nonce($_POST[self::NONCE_NAME], 'amazon-polly') ) {
     51            update_post_meta( $post_id, 'amazon_polly_enable', (int) isset($_POST['amazon_polly_enable']));
     52
     53            // If disabling post translation
     54            if ( isset($_POST['amazon_ai_deactive_translation']) ) {
    5555                $common->deactive_translation_for_post($post_id);
    5656            }
    5757
    58             $is_post_id_available = isset( $post_id );
    59             $is_key_valid = ( get_option( 'amazon_polly_valid_keys' ) === '1' );
    60 
    61             // If this is quick edit, we need to check other place to see if polly was already enabled for this post.
    62             if ( $is_post_id_available && $is_quick_edit ) {
    63                 if ( 1 == get_post_meta( $post_id, 'amazon_polly_enable', true)) {
    64                     $is_polly_enabled = true;
    65                 }
    66             }
    67 
    68             // Input var okay.
    69             $is_amazon_polly_voice_id_available = isset( $_POST['amazon_polly_voice_id'] );
    70 
    71             if ( $is_post_id_available && $is_polly_enabled && $is_key_valid && $is_amazon_polly_voice_id_available ) {
    72 
    73                 // Getting voice and sample rate which should be used for converting post to audio.
    74                 $voice_id = sanitize_text_field( wp_unslash( $_POST['amazon_polly_voice_id'] ) );
    75                 $sample_rate   = $common->get_sample_rate();
    76 
    77                 // Cleaning text. Includes for example removing not supported characters etc.
    78                 $clean_text    = $common->clean_text( $post_id, true, false);
    79 
    80                 // Breaking text into smaller parts, which will be then send to Amazon Polly for conversion.
    81                 $sentences     = $common->break_text( $clean_text );
    82 
    83                 // We will be operating on local file system for stiching files together.
    84                 $wp_filesystem = $common->prepare_wp_filesystem();
    85 
    86                 // Actual invocation of method which will call Amazon Polly API and create audio file.
    87                 $this->convert_to_audio( $post_id, $sample_rate, $voice_id, $sentences, $wp_filesystem, '' );
    88 
    89                 // Checking what was the source language of text and updating options for translate operations.
    90                 $source_language = $common->get_source_language();
    91                 update_post_meta( $post_id, 'amazon_polly_transcript_' . $source_language, $clean_text );
    92                 update_post_meta( $post_id, 'amazon_polly_transcript_source_lan', $source_language );
    93 
    94             }
    95 
    96             // It's possible that Amazon Polly was not enabled, then we make sure that the audio file
    97             // for the post is deleted (if existing) and options are removed.
    98             if ( $is_post_id_available && ! $is_polly_enabled ) {
    99                 $common->delete_post_audio( $post_id );
    100                 update_post_meta( $post_id, 'amazon_polly_enable', 0 );
    101                 update_post_meta( $post_id, 'amazon_polly_audio_location', '' );
    102             }
    103         }
     58            // Update post voice ID
     59            if ( isset( $_POST['amazon_polly_voice_id']) ) {
     60                $voice_id = sanitize_text_field(wp_unslash($_POST['amazon_polly_voice_id']));
     61                update_post_meta( $post_id, 'amazon_polly_voice_id', $voice_id);
     62            }
     63        }
     64
     65    $background_task = new AmazonAI_BackgroundTask();
     66    $background_task->trigger(self::GENERATE_POST_AUDIO_TASK, [ $post_id ]);
     67    }
     68
     69    /**
     70     * Important. Executes the Amazon Polly API to create audio file and save to the configured storage location
     71     *
     72     * @since    1.0.0
     73     */
     74    public function generate_audio( $post_id ) {
     75
     76        $logger = new AmazonAI_Logger();
     77        $logger->log(sprintf('%s Generating audio for post ( id=%s )', __METHOD__, $post_id));
     78
     79        /**
     80         * Fires before attempting to generate and save the Amazon Polly audio files
     81         *
     82         * @param int $post_id The post id to generate audio files for
     83         */
     84        do_action('amazon_polly_pre_generate_audio', $post_id);
     85
     86        // Creating new standard common object for interacting with other methods of the plugin.
     87        $common = new AmazonAI_Common();
     88        $common->init();
     89
     90        $is_polly_enabled = (bool) get_post_meta($post_id, 'amazon_polly_enable', true);
     91        $is_key_valid = (bool) get_option('amazon_polly_valid_keys');
     92        $voice_id = get_post_meta($post_id, 'amazon_polly_voice_id', true);
     93
     94        if ( $is_polly_enabled && $is_key_valid ) {
     95
     96            $logger->log(sprintf('%s Basic validation OK', __METHOD__));
     97
     98            // Sammple Rate
     99            $sample_rate   = $common->get_sample_rate();
     100
     101            // Cleaning text. Includes for example removing not supported characters etc.
     102            $clean_text    = $common->clean_text( $post_id, true, false);
     103
     104            // Breaking text into smaller parts, which will be then send to Amazon Polly for conversion.
     105            $sentences     = $common->break_text( $clean_text );
     106
     107            // We will be operating on local file system for stiching files together.
     108            $wp_filesystem = $common->prepare_wp_filesystem();
     109
     110            // Actual invocation of method which will call Amazon Polly API and create audio file.
     111            $this->convert_to_audio( $post_id, $sample_rate, $voice_id, $sentences, $wp_filesystem, '' );
     112
     113            // Checking what was the source language of text and updating options for translate operations.
     114            $source_language = $common->get_source_language();
     115            update_post_meta( $post_id, 'amazon_polly_transcript_' . $source_language, $clean_text );
     116            update_post_meta( $post_id, 'amazon_polly_transcript_source_lan', $source_language );
     117        }
     118
     119        // Remove audio files and post meta (if existing) if Polly is not enabled
     120        else if ( ! $is_polly_enabled ) {
     121            $common->delete_post_audio( $post_id );
     122            update_post_meta( $post_id, 'amazon_polly_audio_location', '' );
     123        }
     124
     125        /**
     126         * Fires after attempting to generate and save the Amazon Polly audio files
     127         *
     128         * @param int $post_id The post id to generate audio files for
     129         */
     130        do_action('amazon_polly_post_generate_audio', $post_id, $is_polly_enabled);
    104131    }
    105132
  • amazon-polly/trunk/admin/AmazonAI-S3FileHandler.php

    r1967308 r1991560  
    136136    public function create_s3_bucket() {
    137137
     138      $logger = new AmazonAI_Logger();
     139      $logger->log(sprintf('%s Creating new S3 Bucket', __METHOD__));
     140
    138141      $createNewBucket = true;
    139142
     
    153156                    $createNewBucket = false;
    154157
     158            $logger->log(sprintf('%s New S3 Bucket created ( name=%s )', __METHOD__, $name));
     159
    155160                } catch ( Aws\S3\Exception\S3Exception $e ) {
     161            $logger->log(sprintf('%s Failed to Create new S3 Bucket! ( error=%s )', __METHOD__, $e));
    156162            error_log($e);
    157163                    update_option( 'amazon_polly_s3_bucket', '' );
  • amazon-polly/trunk/admin/AmazonAI-TranslateConfiguration.php

    r1942322 r1991560  
    119119        $lan_display = 'amazon_polly_trans_langs_' . $lanuage . '_display';
    120120        $disabled         = '';
    121         if (($src_lang == $lanuage) or ('en' == $lanuage)) {
     121        if ( $src_lang == $lanuage ) {
    122122            $disabled = 'disabled';
    123123        }
    124124
     125        #Some translations between languages are not supported by the service.
     126        #Details: https://docs.aws.amazon.com/translate/latest/dg/pairs.html
     127        if (!$this->common->is_translation_supported($src_lang, $lanuage)) {
     128          $disabled = 'disabled';
     129        }
     130
    125131        echo '<tr>';
    126         echo '<td><input type="checkbox" name="' . $lan_option . '" id="' . $lan_option . '" ' . $this->common->check_if_language_is_checked($lan_option, $src_lang) . ' ' . $disabled . '>' . $language_name . ' </td><td>';
     132        echo '<td><input type="checkbox" name="' . $lan_option . '" id="' . $lan_option . '" ' . $this->common->check_if_language_is_checked($lanuage, $src_lang) . ' ' . $disabled . '>' . $language_name . ' </td><td>';
    127133        $voice_id = get_option($lan_voice_option);
    128134
  • amazon-polly/trunk/admin/AmazonAI-Translator.php

    r1935214 r1991560  
    107107  public function translate( $translate_client, $source_text, $source_language, $target_language) {
    108108
     109        $logger = new AmazonAI_Logger();
     110        $logger->log(sprintf('%s Traslating', __METHOD__));
     111
    109112        // Translate functionality doesn't support SSML, ONLYAUDIO, ONLYWORDS tags
    110113    $source_text = preg_replace( '/(\*\*AMAZONPOLLY\*SSML\*BREAK\*)(.*?)(\*\*\*)(.*?)(\*\*\*SSML\*\*)/', '', $source_text );
     
    140143
    141144    }
     145
     146        $logger->log(sprintf('%s Translated text:', __METHOD__));
     147        $logger->log(sprintf('%s', $translated_text));
    142148
    143149    return $translated_text;
     
    207213        $common->init();
    208214
     215        $logger = new AmazonAI_Logger();
     216        $logger->log(sprintf('%s Ajax Translate', __METHOD__));
     217
    209218        $post_id = $_POST['post_id'];
    210219        $phase   = $_POST['phase'];
    211220        $langs   = $_POST['langs'];
     221
     222        $logger->log(sprintf('%s Phase ( %s )', __METHOD__, $phase));
    212223
    213224        $step       = '';
     
    225236            $step       = 'done';
    226237            $percentage = 100;
     238
     239            $logger->log(sprintf('%s Transalte functionality is not enabled )', __METHOD__));
    227240
    228241        } else {
     
    240253
    241254                $langs = $all_langs;
    242 
    243                 if ( 'en' == $source_language ) {
    244                     $english_content = get_post_field('post_content', $post_id);
    245                     update_post_meta( $post_id, 'amazon_polly_transcript_en', $english_content );
    246                 }
    247 
    248255                update_post_meta( $post_id, 'amazon_ai_source_language', $source_language );
    249 
     256               
    250257            } else {
    251258
    252 
    253                 if ( ( $key = array_search( 'en', $langs ) ) !== false ) {
    254                     $language_code = 'en';
    255                     unset( $langs[ $key ] );
    256                 } else {
    257                     $language_code = array_shift( $langs );
    258                 }
    259 
    260                 if ( 'en' == $language_code ) {
    261                     $clean_text = $common->clean_text( $post_id, false, false );
    262                 } else {
    263                     $english_content = get_post_meta( $post_id, 'amazon_polly_transcript_en', true );
    264                     $source_language   = 'en';
    265                 }
     259                $logger->log(sprintf('%s Languages ( %s )', __METHOD__, implode(" ", $langs)));
     260
     261                # Check what language
     262                $language_code = array_shift( $langs );
     263
     264                #Retrieve original text
     265                $content = get_post_field('post_content', $post_id);
     266                $clean_text = $common->clean_text( $post_id, false, false );
     267
     268                $logger->log(sprintf('%s Translating from ( %s ) to ( %s )', __METHOD__, $source_language, $language_code));
    266269
    267270                $wp_filesystem = $common->prepare_wp_filesystem();
     
    272275                        $clean_title = $common->clean_text( $post_id, false, true );
    273276                        $translated_title = $this->translate( $translate_client, $clean_title, $source_language,  $language_code);
    274                         $translated_text = $this->translate_post( $common, $translate_client, $english_content, $source_language,  $language_code);
     277                        $translated_text = $this->translate_post( $common, $translate_client, $content, $source_language,  $language_code);
    275278                        update_post_meta( $post_id, 'amazon_polly_transcript_' . $language_code, $translated_text );
    276279                        update_post_meta( $post_id, 'amazon_polly_transcript_title_' . $language_code, $translated_title );
     
    295298        }//end if
    296299
    297         $next_langs = $langs;
    298         if ( ( 'en' != $source_language ) && ( $key = array_search( 'en', $next_langs ) ) !== false ) {
    299             $next_lang = 'en';
    300         } else {
    301             $next_lang = array_shift( $next_langs );
    302         }
     300        $temp_langs = $langs;
     301        $next_lang = array_shift( $temp_langs );
    303302
    304303        if ( ! empty( $next_lang ) ) {
     304            $logger->log(sprintf('%s Next language ( %s ))', __METHOD__, $next_lang));
    305305            $message = 'Translating from ' . $common->get_language_name( $source_language ) . ' to ' . $common->get_language_name( $next_lang );
    306306        } else {
  • amazon-polly/trunk/amazonpolly.php

    r1967308 r1991560  
    1717 * Plugin URI:        https://wordpress.org/plugins/amazon-polly/
    1818 * Description:       Create audio version of your posts, translate them into other languages and create podcasts! Amazon Polly is a service that turns text into lifelike speech. With dozens of voices across a variety of languages, you can select the ideal voice and build engaging speech-enabled applications that work in many different countries. The Amazon Polly plugin for WordPress is a sample application that shows how WordPress creators can easily add Text-to-Speech capabilities to written content with Amazon Polly. You can generate an audio feed for text-based content and insert it into an embedded player to increase the accessibility of your WordPress site. The sample code also enables you to publish podcasts directly from your site and make them available for listeners in the form of podcasts. In addition, the plugin allows to translate your text from one language to another using Amazon Translate– which is a neural machine translation service that delivers fast, high-quality, and affordable language translation. Amazon Translate allows you to localize content - such as websites and applications - for international users, and to easily translate large volumes of text efficiently.
    19  * Version:           2.6.0
     19 * Version:           2.6.1
    2020 * Author:            AWS Labs, WP Engine
    2121 * Author URI:        https://aws.amazon.com/
  • amazon-polly/trunk/includes/class-amazonpolly-pollycast.php

    r1935214 r1991560  
    9595     */
    9696    public function get_posttypes_array() {
    97         $posttypes_array = get_option( 'amazon_polly_posttypes', 'post' );
     97        $this->common = new AmazonAI_Common();
     98        $posttypes_array = $this->common->get_posttypes();
    9899        $posttypes_array = explode( ' ', $posttypes_array );
    99100        $posttypes_array = apply_filters( 'amazon_polly_post_types', $posttypes_array );
     
    113114    public function get_audio_file_location( $post_id ) {
    114115        $audio_file_location = get_post_meta( $post_id, 'amazon_polly_audio_link_location', true );
    115         $audio_file_location = str_replace( 'https://', 'http://', $audio_file_location );
     116
     117        $https_enabled = get_option( 'amazon_polly_podcast_https' );
     118        if ( empty( $https_enabled ) ) {
     119          $audio_file_location = str_replace( 'https://', 'http://', $audio_file_location );
     120        }
    116121
    117122        return $audio_file_location;
  • amazon-polly/trunk/includes/class-amazonpolly.php

    r1967308 r1991560  
    113113        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/amazonpolly-metabox.php';
    114114
     115        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-BackgroundTask.php';
    115116        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Exceptions.php';
    116117        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Translator.php';
     
    119120        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-S3FileHandler.php';
    120121
     122        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Logger.php';
    121123        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Common.php';
    122124        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-PollyService.php';
     
    176178    private function define_admin_hooks() {
    177179
     180        $background_task = new AmazonAI_BackgroundTask();
    178181        $general_configuration = new AmazonAI_GeneralConfiguration();
    179182        $polly_configuration = new AmazonAI_PollyConfiguration();
     
    185188        $translate_service = new AmazonAI_Translator();
    186189
     190        $this->loader->add_action( sprintf('admin_post_%s', AmazonAI_BackgroundTask::ADMIN_POST_ACTION), $background_task, 'run' );
     191
    187192        $this->loader->add_action( 'admin_print_footer_scripts', $common, 'add_quicktags' );
    188193        $this->loader->add_action( 'admin_enqueue_scripts', $common, 'enqueue_styles' );
     
    190195        $this->loader->add_action( 'add_meta_boxes', $common, 'field_checkbox' );
    191196        $this->loader->add_action( 'save_post', $polly_service, 'save_post', 10, 3 );
     197        $this->loader->add_action( 'amazon_polly_background_task_generate_post_audio', $polly_service, 'generate_audio', 10, 3 );
    192198
    193199
  • amazon-polly/trunk/uninstall.php

    r1898887 r1991560  
    99 */
    1010
    11 
    12 error_log("DDD");
    1311 // If uninstall not called from WordPress, then exit.
    1412 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    15 
    16      error_log("Usuwam");
    1713     exit;
    1814 }
Note: See TracChangeset for help on using the changeset viewer.