Changeset 2268197
- Timestamp:
- 03/26/2020 01:24:22 PM (6 years ago)
- Location:
- amazon-polly/trunk
- Files:
-
- 1 added
- 21 edited
-
README.md (modified) (2 diffs)
-
README.txt (modified) (2 diffs)
-
admin/AmazonAI-AlexaConfiguration.php (modified) (2 diffs)
-
admin/AmazonAI-CloudFrontConfiguration.php (modified) (1 diff)
-
admin/AmazonAI-Cloudformation.php (modified) (1 diff)
-
admin/AmazonAI-Common.php (modified) (12 diffs)
-
admin/AmazonAI-GeneralConfiguration.php (modified) (4 diffs)
-
admin/AmazonAI-LocalFileHandler.php (modified) (2 diffs)
-
admin/AmazonAI-Logger.php (modified) (1 diff)
-
admin/AmazonAI-PodcastConfiguration.php (modified) (2 diffs)
-
admin/AmazonAI-PollyConfiguration.php (modified) (2 diffs)
-
admin/AmazonAI-PollyService.php (modified) (8 diffs)
-
admin/AmazonAI-PostMetaBox.php (added)
-
admin/AmazonAI-S3FileHandler.php (modified) (3 diffs)
-
admin/AmazonAI-TranslateConfiguration.php (modified) (2 diffs)
-
admin/AmazonAI-Translator.php (modified) (2 diffs)
-
amazonpolly.php (modified) (1 diff)
-
includes/class-amazonpolly-activator.php (modified) (1 diff)
-
includes/class-amazonpolly-pollycast.php (modified) (4 diffs)
-
includes/class-amazonpolly.php (modified) (10 diffs)
-
includes/template-amazon-pollycast.php (modified) (5 diffs)
-
public/class-amazonpolly-public.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amazon-polly/trunk/README.md
r2219187 r2268197 7 7 | Requires PHP | 5.6 | 8 8 | Tested up to | 5.3 | 9 | Stable tag | 4. 0.3|9 | Stable tag | 4.2.0 | 10 10 | License | GPLv3 ONLY | 11 11 | License URI | https://www.gnu.org/licenses/gpl-3.0.html | … … 136 136 #### Changelog 137 137 138 = 4.2.0 = 139 * Code Refactoring 140 138 141 = 4.0.3 = 139 * Bug Fixing. 140 * 142 * Bug Fixing 143 144 * 141 145 = 4.0.2 = 142 146 * Added translate support for multiple new languages -
amazon-polly/trunk/README.txt
r2219187 r2268197 5 5 Requires PHP: 5.6 6 6 Tested up to: 5.3 7 Stable tag: 4. 0.37 Stable tag: 4.2.0 8 8 License: GPLv3 ONLY 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 134 134 135 135 == Changelog == 136 137 = 4.2.0 = 138 * Code Refactoring 136 139 137 140 = 4.0.3 = -
amazon-polly/trunk/admin/AmazonAI-AlexaConfiguration.php
r2031081 r2268197 11 11 class AmazonAI_AlexaConfiguration 12 12 { 13 /** 14 * @var AmazonAI_Common 15 */ 16 private $common; 17 18 /** 19 * AmazonAI_PodcastConfiguration constructor. 20 * 21 * @param AmazonAI_Common $common 22 */ 23 public function __construct(AmazonAI_Common $common) { 24 $this->common = $common; 25 } 13 26 14 27 public function amazon_ai_add_menu() … … 29 42 </div> 30 43 <?php 31 32 $this->common = new AmazonAI_Common();33 $this->common->init();34 44 if ( $this->common->is_podcast_enabled() ) { 35 45 echo '<p class="description">You can extend WordPress websites and blogs through Alexa devices. This opens new possibilities for the creators and authors of websites to reach an even broader audience. It also makes it easier for people to listen to their favorite blogs by just asking Alexa to read them! </p>'; -
amazon-polly/trunk/admin/AmazonAI-CloudFrontConfiguration.php
r2188605 r2268197 15 15 private $cloudformation; //Required to retrieve Cloudformation service 16 16 17 public function __construct() { 18 $this->common = new AmazonAI_Common(); 19 $this->common->init(); 20 $this->cloudformation = new AmazonAI_Cloudformation(); 17 public function __construct(AmazonAI_Common $common, AmazonAI_Cloudformation $cloudformation) { 18 $this->common = $common; 19 $this->cloudformation = $cloudformation; 21 20 } 22 21 -
amazon-polly/trunk/admin/AmazonAI-Cloudformation.php
r2188605 r2268197 20 20 private $stack_resources; 21 21 22 public function __construct() { 23 $this->common = new AmazonAI_Common(); 24 $this->common->init(); 22 public function __construct(AmazonAI_Common $common) { 23 $this->common = $common; 25 24 $this->cloudformation_client = $this->common->get_cloudformation_client(); 26 25 $this->acm_client = $this->common->get_acm_client(); -
amazon-polly/trunk/admin/AmazonAI-Common.php
r2219187 r2268197 71 71 ]; 72 72 73 private $sdk; 74 private $sdk_use1; // SDK with region fixed as us-east-1 75 private $polly_client; 76 private $translate_client; 77 private $s3_handler; 78 private $local_file_handler; 79 private $translate; 80 private $logger; 81 private $cloudformation_client; 82 private $cloudfront_client; 83 private $acm_client; 84 85 /** 86 * Creates SDK objects for the plugin. 87 * 88 * @since 2.5.0 89 */ 90 public function __construct() { 91 $this->logger = new AmazonAI_Logger(); 92 } 93 73 94 public function prepare_paragraphs($post_id) { 74 95 … … 259 280 } 260 281 261 private $sdk;262 private $sdk_use1; // SDK with region fixed as us-east-1263 private $polly_client;264 private $translate_client;265 private $s3_handler;266 private $local_file_handler;267 private $translate;268 private $logger;269 private $cloudformation_client;270 private $cloudfront_client;271 private $acm_client;272 273 /**274 * Creates SDK objects for the plugin.275 *276 * @since 2.5.0277 */278 public function __construct() {279 $this->logger = new AmazonAI_Logger();280 }281 282 282 public function init() { 283 283 $aws_sdk_config = $this->get_aws_sdk_config(); … … 286 286 $this->translate_client = $this->sdk->createTranslate(); 287 287 288 $this->s3_handler = new AmazonAI_S3FileHandler( );289 $this->local_file_handler = new AmazonAI_LocalFileHandler( );288 $this->s3_handler = new AmazonAI_S3FileHandler($this); 289 $this->local_file_handler = new AmazonAI_LocalFileHandler($this); 290 290 291 291 $this->s3_handler->set_s3_client($this->sdk->createS3()); 292 $this->translate = new AmazonAI_Translator( );292 $this->translate = new AmazonAI_Translator($this); 293 293 294 294 $aws_sdk_config_use1 = $this->get_aws_sdk_config_use1(); … … 625 625 $file_name = 'amazon_polly_' . $post_id . $language . '.mp3'; 626 626 $s3BucketName = $this->get_s3_bucket_name(); 627 $cloudfront_domain_name = get_option( 'amazon_polly_cloudfront');627 $cloudfront_domain_name = apply_filters('amazon_polly_cloudfront_domain', get_option( 'amazon_polly_cloudfront' )); 628 628 629 629 if ( get_option('uploads_use_yearmonth_folders') ) { … … 768 768 public function get_aws_region() 769 769 { 770 $region = get_option('amazon_polly_region');770 $region = apply_filters('amazon_polly_aws_region', get_option('amazon_polly_region')); 771 771 if (empty($region)) { 772 772 update_option('amazon_polly_region', 'us-east-1'); … … 1212 1212 * @since 2.5.0 1213 1213 */ 1214 private function get_aws_sdk_config() 1215 { 1214 private function get_aws_sdk_config($region = null) 1215 { 1216 $aws_sdk_config = [ 1217 'region' => $this->get_aws_region(), 1218 'version' => 'latest', 1219 ]; 1220 $credentials = false; 1216 1221 $aws_access_key = get_option('amazon_polly_access_key'); 1217 1222 $aws_secret_key = get_option('amazon_polly_secret_key'); 1218 if (empty($aws_access_key)) { 1219 $aws_sdk_config = array( 1220 'region' => $this->get_aws_region() , 1221 'version' => 'latest', 1222 ); 1223 } 1224 else { 1225 $aws_sdk_config = array( 1226 'region' => $this->get_aws_region() , 1227 'version' => 'latest', 1228 'credentials' => array( 1229 'key' => $aws_access_key, 1230 'secret' => $aws_secret_key, 1231 ) , 1232 ); 1223 1224 if ($aws_access_key && $aws_secret_key) { 1225 $credentials = [ 1226 'key' => $aws_access_key, 1227 'secret' => $aws_secret_key, 1228 ]; 1229 } 1230 1231 if ($credentials = apply_filters('amazon_polly_aws_sdk_credentials', $credentials)) { 1232 $aws_sdk_config['credentials'] = $credentials; 1233 } 1234 1235 if ($region) { 1236 $aws_sdk_config['region'] = $region; 1233 1237 } 1234 1238 … … 1236 1240 } 1237 1241 1238 /**1242 /** 1239 1243 * Returns AWS SDK configuration to allow connection with AWS account and region us-east-1. 1240 1244 * … … 1242 1246 */ 1243 1247 private function get_aws_sdk_config_use1() 1244 { 1245 $aws_access_key = get_option('amazon_polly_access_key'); 1246 $aws_secret_key = get_option('amazon_polly_secret_key'); 1247 if (empty($aws_access_key)) { 1248 $aws_sdk_config = array( 1249 'region' => 'us-east-1' , 1250 'version' => 'latest', 1251 ); 1252 } 1253 else { 1254 $aws_sdk_config = array( 1255 'region' => 'us-east-1' , 1256 'version' => 'latest', 1257 'credentials' => array( 1258 'key' => $aws_access_key, 1259 'secret' => $aws_secret_key, 1260 ) , 1261 ); 1262 } 1263 1264 return $aws_sdk_config; 1265 } 1248 { 1249 return $this->get_aws_sdk_config('us-east-1'); 1250 } 1266 1251 1267 1252 … … 1676 1661 */ 1677 1662 public function add_quicktags() { 1678 1679 $common = new AmazonAI_Common(); 1680 $is_ssml_enabled = $common->is_ssml_enabled(); 1663 $is_ssml_enabled = $this->is_ssml_enabled(); 1681 1664 1682 1665 if ( $is_ssml_enabled ) { … … 1848 1831 $post_types_supported = $this->get_posttypes_array(); 1849 1832 1833 $meta_box = new AmazonAI_PostMetaBox($this); 1834 1850 1835 add_meta_box( 1851 1836 'amazon_polly_box_id', … … 1853 1838 'Amazon Polly', 1854 1839 // Title of the box. 1855 'amazon_polly_box_content',1840 [ $meta_box, 'display_box_content'], 1856 1841 // Function to be called to display the checkboxes, see the function below. 1857 1842 $post_types_supported, … … 1904 1889 } 1905 1890 1906 1907 1891 public function aws_configuration_update($new_value, $old_value) { 1892 1893 $default_value = '********************'; 1894 1895 if ( !isset($new_value) ) { 1896 $new_value = $default_value; 1897 } 1898 1899 if ($new_value != $default_value) { 1900 update_option('amazon_polly_secret_key', $new_value); 1901 } 1902 1903 return $default_value; 1904 } 1908 1905 1909 1906 } -
amazon-polly/trunk/admin/AmazonAI-GeneralConfiguration.php
r2183170 r2268197 12 12 class AmazonAI_GeneralConfiguration 13 13 { 14 /** 15 * @var AmazonAI_Common 16 */ 17 private $common; 14 18 15 private $common; 16 19 /** 20 * AmazonAI_GeneralConfiguration constructor. 21 * 22 * @param AmazonAI_Common $common 23 */ 24 public function __construct(AmazonAI_Common $common) { 25 $this->common = $common; 26 } 17 27 18 28 public function amazon_ai_add_menu() … … 58 68 { 59 69 60 $this->common = new AmazonAI_Common();61 $this->common->init();62 63 70 // ************************************************* * 64 71 // ************** GENERAL SECTION ************** * … … 73 80 'label_for' => 'amazon_polly_access_key' 74 81 )); 75 add_settings_field('amazon_polly_secret_key ', __('AWS secret key:', 'amazonpolly'), array(82 add_settings_field('amazon_polly_secret_key_fake', __('AWS secret key:', 'amazonpolly'), array( 76 83 $this, 77 84 'secret_key_gui' 78 85 ), 'amazon_ai', 'amazon_ai_general', array( 79 'label_for' => 'amazon_polly_secret_key '86 'label_for' => 'amazon_polly_secret_key_fake' 80 87 )); 81 88 82 89 83 90 register_setting('amazon_ai', 'amazon_polly_access_key'); 84 register_setting('amazon_ai', 'amazon_polly_secret_key ');91 register_setting('amazon_ai', 'amazon_polly_secret_key_fake'); 85 92 86 93 add_settings_field('amazon_polly_region', __('AWS Region:', 'amazonpolly'), array( … … 116 123 */ 117 124 function secret_key_gui() { 118 $secret_key = get_option('amazon_polly_secret_key ');119 echo '<input type="password" class="regular-text" name="amazon_polly_secret_key " id="amazon_polly_secret_key" value="' . esc_attr($secret_key) . '" autocomplete="off"> ';125 $secret_key = get_option('amazon_polly_secret_key_fake','********************'); 126 echo '<input type="password" class="regular-text" name="amazon_polly_secret_key_fake" id="amazon_polly_secret_key_fake" value="' . esc_attr($secret_key) . '" autocomplete="off"> '; 120 127 echo '<p class="description" id="amazon_polly_access_key">Required only if you aren\'t using IAM roles</p>'; 121 128 } -
amazon-polly/trunk/admin/AmazonAI-LocalFileHandler.php
r1967308 r2268197 11 11 12 12 class AmazonAI_LocalFileHandler extends AmazonAI_FileHandler { 13 /** 14 * @var AmazonAI_Common 15 */ 16 private $common; 13 17 18 /** 19 * AmazonAI_LocalFileHandler constructor. 20 * 21 * @param AmazonAI_Common $common 22 */ 23 public function __construct(AmazonAI_Common $common) { 24 $this->common = $common; 25 } 14 26 15 27 /** … … 73 85 74 86 // Adding audio info to media library (If Media Library was selected) 75 $common = new AmazonAI_Common();87 $common = $this->common; 76 88 if ($common->is_medialibrary_enabled()) { 77 89 -
amazon-polly/trunk/admin/AmazonAI-Logger.php
r1991560 r2268197 13 13 public function log($log) { 14 14 15 if (true === WP_DEBUG) { 16 17 $common = new AmazonAI_Common(); 18 if ( $common->is_logging_enabled() ) { 19 error_log($log); 20 } 21 15 if (true === WP_DEBUG && apply_filters('amazon_polly_logging_enabled', false)) { 16 error_log($log); 22 17 } 23 18 } -
amazon-polly/trunk/admin/AmazonAI-PodcastConfiguration.php
r2188605 r2268197 11 11 12 12 class AmazonAI_PodcastConfiguration { 13 /** 14 * @var AmazonAI_Common 15 */ 16 private $common; 17 18 /** 19 * AmazonAI_PodcastConfiguration constructor. 20 * 21 * @param AmazonAI_Common $common 22 */ 23 public function __construct(AmazonAI_Common $common) { 24 $this->common = $common; 25 } 13 26 14 27 public function amazon_ai_add_menu() { … … 40 53 function display_options() 41 54 { 42 43 $this->common = new AmazonAI_Common();44 $this->common->init();45 46 55 add_settings_section('amazon_ai_podcast', "Amazon Pollycast configuration", array($this,'podcast_gui'), 'amazon_ai_podcast'); 47 56 add_settings_field( 'amazon_polly_podcast_enabled', __( 'Pollycast enabled:', 'amazonpolly' ), array( $this, 'podcast_enabled_gui' ), 'amazon_ai_podcast', 'amazon_ai_podcast', array( 'label_for' => 'amazon_polly_podcast_enabled' ) ); -
amazon-polly/trunk/admin/AmazonAI-PollyConfiguration.php
r2218638 r2268197 11 11 12 12 class AmazonAI_PollyConfiguration { 13 14 private $common; 13 /** 14 * @var AmazonAI_Common 15 */ 16 private $common; 17 18 /** 19 * AmazonAI_PollyConfiguration constructor. 20 * 21 * @param AmazonAI_Common $common 22 */ 23 public function __construct(AmazonAI_Common $common) { 24 $this->common = $common; 25 } 15 26 16 27 public function amazon_ai_add_menu() { … … 42 53 function display_options() 43 54 { 44 45 $this->common = new AmazonAI_Common();46 $this->common->init();47 48 55 register_setting('amazon_ai_polly', 'amazon_ai_polly_enable'); 49 56 add_settings_section('amazon_ai_polly', "Amazon Polly configuration", array($this,'polly_gui'), 'amazon_ai_polly'); -
amazon-polly/trunk/admin/AmazonAI-PollyService.php
r2218638 r2268197 15 15 const NONCE_NAME = 'amazon-polly-post-nonce'; 16 16 17 /** 18 * @var AmazonAI_Common 19 */ 20 private $common; 21 22 /** 23 * AmazonAI_PollyService constructor. 24 * 25 * @param AmazonAI_Common $common 26 */ 27 public function __construct(AmazonAI_Common $common) { 28 $this->common = $common; 29 } 17 30 18 31 /** … … 22 35 */ 23 36 public function save_post( $post_id, $post, $updated ) { 24 25 // Creating new standard common object for interacting with other methods of the plugin. 26 $common = new AmazonAI_Common(); 27 $common->init(); 28 37 $common = $this->common; 29 38 $logger = new AmazonAI_Logger(); 30 39 $logger->log(sprintf('%s Saving post ( id=%s )', __METHOD__, $post_id)); … … 77 86 */ 78 87 public function generate_audio( $post_id ) { 79 80 88 $logger = new AmazonAI_Logger(); 81 89 $logger->log(sprintf('%s Generating audio for post ( id=%s )', __METHOD__, $post_id)); … … 89 97 90 98 // Creating new standard common object for interacting with other methods of the plugin. 91 $common = new AmazonAI_Common(); 92 $common->init(); 93 99 $common = $this->common; 94 100 $is_polly_enabled = (bool) get_post_meta($post_id, 'amazon_polly_enable', true); 95 101 $is_key_valid = (bool) get_option('amazon_polly_valid_keys'); … … 258 264 259 265 // Creating new standard common object for interacting with other methods of the plugin. 260 $common = new AmazonAI_Common(); 261 $common->init(); 266 $common = $this->common; 262 267 263 268 // This part will be called only in case of translate opration and converting … … 539 544 540 545 $batch_size = 1; 541 $common = new AmazonAI_Common(); 542 $common->init(); 546 $common = $this->common; 543 547 $post_types_supported = $common->get_posttypes_array(); 544 548 $amazon_polly_voice_id = $common->get_voice_id(); … … 607 611 private function get_percentage_complete() { 608 612 $total_posts = 0; 609 $common = new AmazonAI_Common(); 610 $common->init(); 613 $common = $this->common; 611 614 $post_types_supported = $common->get_posttypes_array(); 612 615 $posts_needing_translation = $this->get_num_posts_needing_transcription(); … … 634 637 public function get_num_posts_needing_transcription() { 635 638 636 $common = new AmazonAI_Common(); 637 $common->init(); 639 $common = $this->common; 638 640 $post_types_supported = $common->get_posttypes_array(); 639 641 $amazon_polly_voice_id = get_option( 'amazon_polly_voice_id' ); -
amazon-polly/trunk/admin/AmazonAI-S3FileHandler.php
r1991560 r2268197 11 11 12 12 class AmazonAI_S3FileHandler extends AmazonAI_FileHandler { 13 14 private $s3_client; 13 private $s3_client; 14 15 /** 16 * @var AmazonAI_Common 17 */ 18 private $common; 19 20 /** 21 * AmazonAI_S3FileHandler constructor. 22 * 23 * @param AmazonAI_Common $common 24 */ 25 public function __construct(AmazonAI_Common $common) { 26 $this->common = $common; 27 } 15 28 16 29 /** … … 37 50 public function delete($wp_filesystem, $file, $post_id) { 38 51 39 $common = new AmazonAI_Common();52 $common = $this->common; 40 53 41 54 // Retrieve the name of the bucket where audio files are stored. … … 96 109 97 110 $s3BucketName = $this->get_bucket_name(); 98 $cloudfront_domain_name = get_option( 'amazon_polly_cloudfront');111 $cloudfront_domain_name = apply_filters('amazon_polly_cloudfront_domain', get_option( 'amazon_polly_cloudfront' )); 99 112 $key = $this->get_prefix($post_id) . $file_name; 100 113 101 114 if ( empty( $cloudfront_domain_name ) ) { 102 115 103 $common = new AmazonAI_Common();116 $common = $this->common; 104 117 $selected_region = $common->get_aws_region(); 105 118 -
amazon-polly/trunk/admin/AmazonAI-TranslateConfiguration.php
r2218638 r2268197 11 11 class AmazonAI_TranslateConfiguration 12 12 { 13 private $common; 14 private $aws_ok; 15 private $s3_ok; 16 13 private $aws_ok; 14 private $s3_ok; 15 16 /** 17 * @var AmazonAI_Common 18 */ 19 private $common; 20 21 /** 22 * AmazonAI_TranslateConfiguration constructor. 23 * 24 * @param AmazonAI_Common $common 25 */ 26 public function __construct(AmazonAI_Common $common) { 27 $this->common = $common; 28 } 17 29 18 30 public function amazon_ai_add_menu() … … 45 57 function display_options() 46 58 { 47 $this->common = new AmazonAI_Common();48 $this->common->init();49 50 59 add_settings_section('amazon_ai_translate', "Amazon Translate configuration", array( 51 60 $this, -
amazon-polly/trunk/admin/AmazonAI-Translator.php
r2183170 r2268197 12 12 13 13 class AmazonAI_Translator { 14 /** 15 * @var AmazonAI_Common 16 */ 17 private $common; 18 19 /** 20 * AmazonAI_Translator constructor. 21 * 22 * @param AmazonAI_Common $common 23 */ 24 public function __construct(AmazonAI_Common $common) { 25 $this->common = $common; 26 } 14 27 15 28 /** … … 235 248 check_ajax_referer( 'pollyajaxnonce', 'nonce' ); 236 249 237 $polly = new AmazonAI_PollyService(); 238 $common = new AmazonAI_Common(); 239 $common->init(); 250 $common = $this->common; 251 $polly = new AmazonAI_PollyService($common); 240 252 241 253 $logger = new AmazonAI_Logger(); -
amazon-polly/trunk/amazonpolly.php
r2219190 r2268197 17 17 * Plugin URI: https://wordpress.org/plugins/amazon-polly/ 18 18 * Description: Create audio versions of your posts, translate them into other languages, and create podcasts. Integrate with Amazon Alexa to listen to your posts on Alexa-enabled devices. Use Amazon CloudFront to accelerate your website and provide a faster, more reliable viewing experience. 19 * Version: 4. 0.319 * Version: 4.2.0 20 20 * Author: AWS Labs, WP Engine 21 21 * Author URI: https://aws.amazon.com/ -
amazon-polly/trunk/includes/class-amazonpolly-activator.php
r1942322 r2268197 30 30 31 31 // Flush the permalinks to enable the "amazon-pollycast" route. 32 $amazon_pollycast = new Amazonpolly_PollyCast( );32 $amazon_pollycast = new Amazonpolly_PollyCast(new AmazonAI_Common()); 33 33 $amazon_pollycast->create_podcast(); 34 34 flush_rewrite_rules(); -
amazon-polly/trunk/includes/class-amazonpolly-pollycast.php
r2183170 r2268197 18 18 */ 19 19 class Amazonpolly_PollyCast { 20 /** 21 * @var AmazonAI_Common 22 */ 23 private $common; 24 25 /** 26 * AmazonAI_PodcastConfiguration constructor. 27 * 28 * @param AmazonAI_Common $common 29 */ 30 public function __construct(AmazonAI_Common $common) { 31 $this->common = $common; 32 } 20 33 21 34 /** … … 46 59 */ 47 60 public function render_rss() { 61 // Used by template 62 $amazonai_common = $this->common; 63 48 64 require_once dirname( __FILE__ ) . '/template-amazon-pollycast.php'; 49 65 } … … 81 97 } 82 98 83 $common = new AmazonAI_Common(); 84 $feed_size = $common->get_feed_size(); 99 $feed_size = $this->common->get_feed_size(); 85 100 86 101 // How many items to show in the Amazon PollyCast feed. … … 96 111 */ 97 112 public function get_posttypes_array() { 98 $this->common = new AmazonAI_Common();99 113 $posttypes_array = $this->common->get_posttypes(); 100 114 $posttypes_array = explode( ' ', $posttypes_array ); -
amazon-polly/trunk/includes/class-amazonpolly.php
r2183170 r2268197 71 71 $this->plugin_name = 'amazonpolly'; 72 72 $this->version = '1.0.0'; 73 74 73 $this->load_dependencies(); 74 75 $this->common = new AmazonAI_Common(); 76 $this->common->init(); 77 78 $this->define_global_hooks(); 75 79 $this->set_locale(); 76 80 $this->define_admin_hooks(); … … 94 98 * @access private 95 99 */ 96 private function load_dependencies() {97 100 private function load_dependencies() 101 { 98 102 /** 99 103 * The class responsible for orchestrating the actions and filters of the 100 104 * core plugin. 101 105 */ 102 require_once plugin_dir_path( dirname( __FILE__ )) . 'includes/class-amazonpolly-loader.php';106 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-amazonpolly-loader.php'; 103 107 104 108 /** … … 106 110 * of the plugin. 107 111 */ 108 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-amazonpolly-i18n.php'; 109 110 /** 111 * The class responsible for defining all actions that occur in the admin area. 112 */ 113 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/amazonpolly-metabox.php'; 114 115 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-BackgroundTask.php'; 116 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Exceptions.php'; 117 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Translator.php'; 118 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-FileHandler.php'; 119 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-LocalFileHandler.php'; 120 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-S3FileHandler.php'; 121 122 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Logger.php'; 123 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-Common.php'; 124 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-PollyService.php'; 125 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-GeneralConfiguration.php'; 126 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-PollyConfiguration.php'; 127 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-TranslateConfiguration.php'; 128 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-PodcastConfiguration.php'; 129 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/AmazonAI-AlexaConfiguration.php'; 130 //Class responsible for GUI for the CloudFront Menu 131 require_once plugin_dir_path( dirname( __FILE__)) . 'admin/AmazonAI-CloudFrontConfiguration.php'; 132 133 /** 134 * The class responsible for defining all actions that occur in the public-facing 135 * side of the site. 136 */ 137 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-amazonpolly-public.php'; 138 139 //Class responsible for CloudFormation and associated resources 140 require_once plugin_dir_path( dirname( __FILE__)) . 'admin/AmazonAI-Cloudformation.php'; 141 //This class is responsible for rewriting uURLs 142 require_once plugin_dir_path( dirname( __FILE__)) . 'admin/class-url-rewriter.php'; 143 144 145 require_once plugin_dir_path( dirname( __FILE__)) . 'admin/class-custom-settings.php'; 146 147 /** 148 * The class responsible for defining all actions that occur in the public-facing 149 * side of the site. 150 */ 151 require_once plugin_dir_path( dirname( __FILE__)) . 'public/class-amazonpolly-public.php'; 112 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-amazonpolly-i18n.php'; 113 114 /** 115 * Misc. classes responsible for helping with admin requests 116 */ 117 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-PostMetaBox.php'; 118 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-BackgroundTask.php'; 119 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-Exceptions.php'; 120 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-Translator.php'; 121 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-FileHandler.php'; 122 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-LocalFileHandler.php'; 123 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-S3FileHandler.php'; 124 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-Logger.php'; 125 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-Common.php'; 126 127 /** 128 * Classes responsible for admin setting pages 129 */ 130 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-AlexaConfiguration.php'; 131 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-CloudFrontConfiguration.php'; 132 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-GeneralConfiguration.php'; 133 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-PollyService.php'; 134 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-PodcastConfiguration.php'; 135 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-PollyConfiguration.php'; 136 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-TranslateConfiguration.php'; 137 138 /** 139 * The class responsible for defining all actions that occur in the public-facing 140 * side of the site. 141 */ 142 require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-amazonpolly-public.php'; 143 144 /** 145 * Class responsible for CloudFormation and associated resources 146 */ 147 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/AmazonAI-Cloudformation.php'; 148 149 /** 150 * This class is responsible for rewriting URLs 151 */ 152 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-url-rewriter.php'; 152 153 153 154 /** 154 155 * The class responsible for creating the podcast feature. 155 156 */ 156 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-amazonpolly-pollycast.php'; 157 158 /** 159 * Load AWS PHP SDK 160 */ 161 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'vendor/autoload.php'; 162 163 /** 164 * The class responsible for custom helper functions 165 */ 166 require_once plugin_dir_path( dirname( __FILE__)) . 'includes/class-helper.php'; 167 /** 168 * Load AWS PHP SDK 169 */ 170 require_once plugin_dir_path( dirname( __FILE__)) . 'vendor/autoload.php'; 171 172 $this->loader = new Amazonpolly_Loader(); 173 157 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-amazonpolly-pollycast.php'; 158 159 /** 160 * Load AWS PHP SDK 161 */ 162 require_once plugin_dir_path(dirname(__FILE__)) . 'vendor/autoload.php'; 163 164 /** 165 * The class responsible for custom helper functions 166 */ 167 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-helper.php'; 168 169 $this->loader = new Amazonpolly_Loader(); 174 170 } 175 171 … … 191 187 } 192 188 189 /** 190 * @return mixed 191 */ 192 private function define_global_hooks() 193 { 194 add_filter('amazon_polly_logging_enabled', [ $this->common, 'is_logging_enabled' ]); 195 } 193 196 194 197 /** … … 202 205 203 206 $background_task = new AmazonAI_BackgroundTask(); 204 $general_configuration = new AmazonAI_GeneralConfiguration(); 205 $polly_configuration = new AmazonAI_PollyConfiguration(); 206 $translate_configuration = new AmazonAI_TranslateConfiguration(); 207 $podcast_configuration = new AmazonAI_PodcastConfiguration(); 208 $alexa_configuration = new AmazonAI_AlexaConfiguration(); 209 $cloudfront_configuration = new AmazonAI_CloudFrontConfiguration(); 210 211 $cloudformation_service = new AmazonAI_Cloudformation(); 212 $polly_service = new AmazonAI_PollyService(); 213 $common = new AmazonAI_Common(); 214 $translate_service = new AmazonAI_Translator(); 207 $cloudformation_service = new AmazonAI_Cloudformation($this->common); 208 $general_configuration = new AmazonAI_GeneralConfiguration($this->common); 209 $polly_configuration = new AmazonAI_PollyConfiguration($this->common); 210 $translate_configuration = new AmazonAI_TranslateConfiguration($this->common); 211 $podcast_configuration = new AmazonAI_PodcastConfiguration($this->common); 212 $alexa_configuration = new AmazonAI_AlexaConfiguration($this->common); 213 $cloudfront_configuration = new AmazonAI_CloudFrontConfiguration($this->common, $cloudformation_service); 214 $polly_service = new AmazonAI_PollyService($this->common); 215 $translate_service = new AmazonAI_Translator($this->common); 215 216 216 217 $plugin_name = get_option('amazon_plugin_name'); 217 $this->loader->add_filter( "plugin_action_links_$plugin_name", $common, 'add_settings_link'); 218 218 $this->loader->add_filter( "plugin_action_links_$plugin_name", $this->common, 'add_settings_link'); 219 219 220 220 $this->loader->add_action( sprintf('admin_post_%s', AmazonAI_BackgroundTask::ADMIN_POST_ACTION), $background_task, 'run'); 221 221 222 $this->loader->add_action( 'admin_print_footer_scripts', $ common, 'add_quicktags');223 $this->loader->add_action( 'admin_enqueue_scripts', $ common, 'enqueue_styles');224 $this->loader->add_action( 'admin_enqueue_scripts', $ common, 'enqueue_scripts');225 $this->loader->add_action( 'admin_enqueue_scripts', $ common, 'enqueue_custom_scripts');226 $this->loader->add_action( 'add_meta_boxes', $ common, 'field_checkbox');222 $this->loader->add_action( 'admin_print_footer_scripts', $this->common, 'add_quicktags'); 223 $this->loader->add_action( 'admin_enqueue_scripts', $this->common, 'enqueue_styles'); 224 $this->loader->add_action( 'admin_enqueue_scripts', $this->common, 'enqueue_scripts'); 225 $this->loader->add_action( 'admin_enqueue_scripts', $this->common, 'enqueue_custom_scripts'); 226 $this->loader->add_action( 'add_meta_boxes', $this->common, 'field_checkbox'); 227 227 $this->loader->add_action( 'save_post', $polly_service, 'save_post', 10, 3); 228 228 $this->loader->add_action( 'amazon_polly_background_task_generate_post_audio', $polly_service, 'generate_audio', 10, 3); 229 229 230 230 231 $this->loader->add_action( 'before_delete_post', $ common, 'delete_post' );231 $this->loader->add_action( 'before_delete_post', $this->common, 'delete_post' ); 232 232 $this->loader->add_action( 'wp_ajax_polly_transcribe', $polly_service, 'ajax_bulk_synthesize' ); 233 233 $this->loader->add_action( 'wp_ajax_polly_translate', $translate_service, 'ajax_translate' ); … … 251 251 $plugin = plugin_basename( plugin_dir_path( dirname( __FILE__)) . 'amazonpolly.php'); 252 252 253 $this->loader->add_filter( 'wp_kses_allowed_html', $common, 'allowed_tags_kses'); 254 $this->loader->add_filter( 'tiny_mce_before_init', $common, 'allowed_tags_tinymce'); 253 $this->loader->add_filter( 'wp_kses_allowed_html', $this->common, 'allowed_tags_kses'); 254 $this->loader->add_filter( 'tiny_mce_before_init', $this->common, 'allowed_tags_tinymce'); 255 $this->loader->add_filter( "pre_update_option_amazon_polly_secret_key_fake", $this->common, 'aws_configuration_update', 10, 2 ); 256 257 255 258 256 259 $this->loader->add_action('wp_ajax_display_stack_details_creation', $cloudfront_configuration, 'display_stack_details_creation'); … … 270 273 $this->loader->add_action('wp_ajax_get_stack_state', $cloudformation_service, 'get_stack_state'); 271 274 $this->loader->add_action('wp_ajax_complete_setup', $cloudformation_service, 'complete_setup'); 275 276 272 277 } 278 279 280 private function update_aws_configuration() { 281 error_log("SAVING"); 282 } 273 283 274 284 /** … … 281 291 private function define_public_hooks() { 282 292 // Front-end 283 $plugin_public = new Amazonpolly_Public( $this->get_plugin_name(), $this->get_version() );293 $plugin_public = new Amazonpolly_Public( $this->get_plugin_name(), $this->get_version(), $this->common); 284 294 285 295 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); … … 290 300 291 301 // Podcast 292 $amazon_pollycast = new Amazonpolly_PollyCast( );302 $amazon_pollycast = new Amazonpolly_PollyCast($this->common); 293 303 $this->loader->add_filter( 'pre_get_posts', $amazon_pollycast, 'filter_pre_get_posts' ); 294 304 $this->loader->add_filter( 'the_excerpt_rss', $amazon_pollycast, 'filter_force_html_decode', 99999 ); 295 305 296 $common = new AmazonAI_Common(); 297 if ( $common->is_podcast_enabled()) { 306 if ( $this->common->is_podcast_enabled()) { 298 307 $this->loader->add_action( 'init', $amazon_pollycast, 'create_podcast'); 299 308 } … … 301 310 //Rewrite URLs if site acceleration is enabled and a CloudFront distribution has been deployed 302 311 $url_rewriter = new AmazonAI_UrlRewriter(); 303 if ( $ common->is_cloudfront_enabled() and $common->is_cloudfront_deployed()) {312 if ( $this->common->is_cloudfront_enabled() and $this->common->is_cloudfront_deployed()) { 304 313 $this->loader->add_action( 'init', $url_rewriter, 'define_url_rewrite_hooks'); 305 314 } -
amazon-polly/trunk/includes/template-amazon-pollycast.php
r2163519 r2268197 4 4 * 5 5 * @package WordPress 6 * 7 * @var AmazonAI_Common $amazonai_common 6 8 */ 7 9 … … 11 13 echo '<?xml version="1.0" encoding="' . esc_attr( get_option( 'blog_charset' ) ) . '"?' . '>'; 12 14 13 $amazon_pollycast = new Amazonpolly_PollyCast( );15 $amazon_pollycast = new Amazonpolly_PollyCast($amazonai_common); 14 16 15 17 /** … … 33 35 $itunes_description = $amazon_pollycast->get_itunes_description(); 34 36 35 $common = new AmazonAI_Common(); 36 $itunes_author = $common->get_podcast_author(); 37 $itunes_author = $amazonai_common->get_podcast_author(); 37 38 $amazon_pollycast->start_podcast_rss(); 38 39 … … 55 56 * @since 2.0.0 56 57 */ 57 $rss2namespace = $ common->is_rss2namespace_enabled();58 $rss2namespace = $amazonai_common->is_rss2namespace_enabled(); 58 59 if ($rss2namespace) { 59 60 do_action( 'rss2_ns' ); … … 145 146 <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description><?php 146 147 $fileSize = 0; 147 if ($ common->is_medialibrary_enabled() && !$common->is_s3_enabled()) {148 if ($amazonai_common->is_medialibrary_enabled() && !$amazonai_common->is_s3_enabled()) { 148 149 $fileSize = filesize(getcwd() . str_replace(get_home_url(), "", preg_replace('/\?.*/', '', $audio_file))); 149 150 } -
amazon-polly/trunk/public/class-amazonpolly-public.php
r2183170 r2268197 50 50 51 51 /** 52 * @var AmazonAI_Common 53 */ 54 private $common; 55 56 /** 52 57 * Initialize the class and set its properties. 53 58 * 54 * @since 1.0.0 55 * @param string $plugin_name The name of the plugin. 56 * @param string $version The version of this plugin. 57 */ 58 public function __construct( $plugin_name, $version ) { 59 * @param string $plugin_name The name of the plugin. 60 * @param string $version The version of this plugin. 61 * @param AmazonAI_Common $common 62 * 63 * @since 1.0.0 64 */ 65 public function __construct( $plugin_name, $version, AmazonAI_Common $common ) { 59 66 60 67 $this->plugin_name = $plugin_name; 61 68 $this->version = $version; 62 69 $this->common = $common; 63 70 } 64 71 65 72 public function title_filter( $title, $id = null ) { 66 67 $common = new AmazonAI_Common(); 73 $common = $this->common; 68 74 69 75 if ( is_singular() ) { … … 105 111 106 112 $post_id = $GLOBALS['post']->ID; 107 $common = new AmazonAI_Common();113 $common = $this->common; 108 114 109 115 $source_language = $common->get_post_source_language($post_id); … … 289 295 } 290 296 291 $common = new AmazonAI_Common();297 $common = $this->common; 292 298 $controlsList = ''; 293 299 if ( !$common->is_audio_download_enabled() ) { … … 308 314 $part = ''; 309 315 310 $common = new AmazonAI_Common();316 $common = $this->common; 311 317 $is_subscribe_button_enabled = $common->is_subscribe_button_enabled(); 312 318 if ($is_subscribe_button_enabled) {
Note: See TracChangeset
for help on using the changeset viewer.