@@ -29,7 +29,7 @@ class RT_Transcoder_Handler {
2929 * @access protected
3030 * @var string $transcoding_api_url The URL of the api.
3131 */
32- protected $ transcoding_api_url = 'http://test. api.rtmedia.io/api/v1/ ' ;
32+ protected $ transcoding_api_url = 'http://api.rtmedia.io/api/v1/ ' ;
3333
3434 /**
3535 * The URL of the EDD store.
@@ -84,6 +84,7 @@ class RT_Transcoder_Handler {
8484 * @var string $audio_extensions Audio extensions with comma separated.
8585 */
8686 public $ audio_extensions = ',wma,ogg,wav,m4a ' ;
87+
8788 /**
8889 * Other extensions with comma separated.
8990 *
@@ -92,6 +93,7 @@ class RT_Transcoder_Handler {
9293 * @var string $other_extensions Other extensions with comma separated.
9394 */
9495 public $ other_extensions = ',pdf ' ;
96+
9597 /**
9698 * Allowed mimetypes.
9799 *
@@ -103,6 +105,7 @@ class RT_Transcoder_Handler {
103105 'application/ogg ' ,
104106 'application/pdf ' ,
105107 );
108+
106109 /**
107110 * Initialize the class and set its properties.
108111 *
@@ -112,15 +115,18 @@ class RT_Transcoder_Handler {
112115 */
113116 public function __construct ( $ no_init = false ) {
114117
115- $ this ->api_key = get_site_option ( 'rt-transcoding-api-key ' );
116- $ this ->stored_api_key = get_site_option ( 'rt-transcoding-api-key-stored ' );
118+ $ this ->api_key = get_site_option ( 'rt-transcoding-api-key ' );
119+ $ this ->stored_api_key = get_site_option ( 'rt-transcoding-api-key-stored ' );
120+ $ this ->transcoding_api_url = apply_filters ( 'transcoding_api_url ' , $ this ->transcoding_api_url );
117121
118122 if ( $ no_init ) {
119123 return ;
120124 }
125+
121126 if ( is_admin () ) {
122127 add_action ( 'rt_transcoder_before_widgets ' , array ( $ this , 'usage_widget ' ) );
123128 }
129+
124130 add_action ( 'admin_init ' , array ( $ this , 'save_api_key ' ), 10 , 1 );
125131
126132 if ( $ this ->api_key ) {
@@ -1449,6 +1455,7 @@ public function get_transcoding_status( $post_id ) {
14491455
14501456 return wp_json_encode ( $ response );
14511457 }
1458+
14521459 /**
14531460 * Send transcoding request to the server for PDF files.
14541461 *
@@ -1459,35 +1466,20 @@ public function get_transcoding_status( $post_id ) {
14591466 */
14601467 public function after_upload_pdf ( $ post_id ) {
14611468
1462- /**
1463- * Allow users to disable PDF thumbnail generation using transcoder.
1464- */
1465- if ( ! apply_filters ( 'transcoder_enable_pdf_thumbnail ' , true ) ) {
1466- return ;
1467- }
1468-
1469- // Check if the Ghostscript is enabled.
1470- $ is_gs_enabled = false ;
1471- if ( ! defined ( 'VIP_GO_APP_ENVIRONMENT ' ) && function_exists ( 'exec ' ) ) {
1472- $ gs = exec ( 'gs --version ' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec
1473- if ( empty ( $ gs ) ) {
1474- $ is_gs_enabled = false ;
1475- } else {
1476- $ is_gs_enabled = true ;
1477- }
1478- }
1479-
14801469 // If it have native support, skip the use of transcoder server.
1481- if ( extension_loaded ( 'imagick ' ) && class_exists ( 'Imagick ' , false ) &&
1470+ if ( extension_loaded ( 'imagick ' ) &&
1471+ class_exists ( 'Imagick ' , false ) &&
14821472 class_exists ( 'ImagickPixel ' , false ) &&
1483- version_compare ( phpversion ( 'imagick ' ), '2.2.0 ' , '>= ' ) &&
1484- $ is_gs_enabled
1473+ version_compare ( phpversion ( 'imagick ' ), '2.2.0 ' , '>= ' )
14851474 ) {
14861475 return ;
14871476 }
14881477
14891478 $ file_url = wp_get_attachment_url ( $ post_id );
14901479 $ filetype = wp_check_filetype ( $ file_url );
1480+
1481+ $ filetype ['ext ' ] = strtolower ( $ filetype ['ext ' ] );
1482+
14911483 if ( 'pdf ' === $ filetype ['ext ' ] ) {
14921484 $ this ->wp_media_transcoding ( array ( 'mime_type ' => 'application/pdf ' ), $ post_id );
14931485 }
0 commit comments