Skip to content

Commit 94f1175

Browse files
Merge pull request #227 from rtCamp/develop
Version update v1.3.2
2 parents 1e9b821 + a7c780f commit 94f1175

File tree

6 files changed

+134
-53
lines changed

6 files changed

+134
-53
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Transcoding services for ANY WordPress website. Convert audio/video files of any
99
<img src="https://rtmedia.io/wp-content/uploads/2016/08/trancoder-banner-01.png" alt="Transcoder Banner"/>
1010
</p>
1111

12-
* **Contributors:** [rtcamp] (http://profiles.wordpress.org/rtcamp), [mangeshp] (http://profiles.wordpress.org/mangeshp), [chandrapatel] (http://profiles.wordpress.org/chandrapatel), [manishsongirkar36] (http://profiles.wordpress.org/manishsongirkar36), [bhargavbhandari90] (http://profiles.wordpress.org/bhargavbhandari90), [kiranpotphode] (http://profiles.wordpress.org/kiranpotphode), [thrijith] (http://profiles.wordpress.org/thrijith), [devikvekariya] (http://profiles.wordpress.org/devikvekariya), [sagarnasit] (http://profiles.wordpress.org/sagarnasit), [sudhiryadav] (http://profiles.wordpress.org/sudhiryadav), [sid177] (https://profiles.wordpress.org/sid177/), [pooja1210] (https://profiles.wordpress.org/pooja1210/)
12+
* **Contributors:** [rtcamp] (http://profiles.wordpress.org/rtcamp), [mangeshp] (http://profiles.wordpress.org/mangeshp), [chandrapatel] (http://profiles.wordpress.org/chandrapatel), [manishsongirkar36] (http://profiles.wordpress.org/manishsongirkar36), [bhargavbhandari90] (http://profiles.wordpress.org/bhargavbhandari90), [kiranpotphode] (http://profiles.wordpress.org/kiranpotphode), [thrijith] (http://profiles.wordpress.org/thrijith), [devikvekariya] (http://profiles.wordpress.org/devikvekariya), [sagarnasit] (http://profiles.wordpress.org/sagarnasit), [sudhiryadav] (http://profiles.wordpress.org/sudhiryadav), [sid177] (https://profiles.wordpress.org/sid177/), [pooja1210] (https://profiles.wordpress.org/pooja1210/), [vaishu.agola27] (https://profiles.wordpress.org/vaishuagola27/), [ravatparmar] (https://profiles.wordpress.org/ravatparmar/)
1313

1414
* **License:** [GPL v2 or later] ( http://www.gnu.org/licenses/gpl-2.0.html)
1515

@@ -65,6 +65,15 @@ Read [Documentation](https://rtmedia.io/docs/transcoder/?utm_source=readme&utm_m
6565
1. Transcoder Settings
6666

6767
## Changelog ##
68+
#### 1.3.2 [January 12, 2021] ####
69+
70+
* FIXED
71+
72+
* The conflict with temp_filename filter and modified the filter
73+
* Compatibility issues with WordPress 5.6
74+
* Conflicts with WP Job Manager plugin
75+
* PHP Notices and Warnings
76+
6877
#### 1.3.1 [August 14, 2020] ####
6978

7079
* ENHANCEMENTS
@@ -190,4 +199,4 @@ Read [Documentation](https://rtmedia.io/docs/transcoder/?utm_source=readme&utm_m
190199
#### 1.0.0 ####
191200
Initial release
192201

193-
Transcoder 1.3.1, with WordPress 5.5 compatibility and media thumbnails auto update feature after transcoding is completed on rtMedia pages.
202+
Transcoder 1.3.2, with WordPress 5.6 compatibility and some minor fixes and modification of transcoded_temp_filename filter.

admin/rt-transcoder-handler.php

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function is_valid_key( $key ) {
357357
if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
358358
$validation_page = vip_safe_wp_remote_get( $validate_url, '', 3, 3 );
359359
} else {
360-
$validation_page = wp_remote_get( $validate_url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
360+
$validation_page = wp_safe_remote_get( $validate_url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
361361
}
362362
if ( ! is_wp_error( $validation_page ) ) {
363363
$validation_info = json_decode( $validation_page['body'] );
@@ -385,7 +385,7 @@ public function update_usage( $key ) {
385385
if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
386386
$usage_page = vip_safe_wp_remote_get( $usage_url, '', 3, 3 );
387387
} else {
388-
$usage_page = wp_remote_get( $usage_url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
388+
$usage_page = wp_safe_remote_get( $usage_url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
389389
}
390390
if ( ! is_wp_error( $usage_page ) ) {
391391
$usage_info = json_decode( $usage_page['body'] );
@@ -775,15 +775,36 @@ public function add_media_thumbnails( $post_array ) {
775775
$largest_thumb = false;
776776
$largest_thumb_url = false;
777777
$upload_thumbnail_array = array();
778+
$failed_thumbnails = false;
778779

779780
foreach ( $post_thumbs_array['thumbnail'] as $thumbnail ) {
780-
$thumbresource = function_exists( 'vip_safe_wp_remote_get' ) ? vip_safe_wp_remote_get( $thumbnail ) : wp_remote_get( $thumbnail ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
781+
$thumbresource = function_exists( 'vip_safe_wp_remote_get' ) ? vip_safe_wp_remote_get( $thumbnail, '', 3, 3 ) : wp_remote_get( $thumbnail, array( 'timeout' => 120 ) ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
781782
$thumbinfo = pathinfo( $thumbnail );
782783
$temp_name = $thumbinfo['basename'];
783784
$temp_name = urldecode( $temp_name );
784785
$temp_name_array = explode( '/', $temp_name );
785-
$temp_name = $temp_name_array[ count( $temp_name_array ) - 1 ];
786-
$thumbinfo['basename'] = apply_filters( 'transcoded_temp_filename', $temp_name );
786+
$thumbinfo['basename'] = $temp_name_array[ count( $temp_name_array ) - 1 ];
787+
788+
/**
789+
* Filter: 'transcoded_temp_filename' - Allows changes for the thumbnail name.
790+
*
791+
* @deprecated 1.3.2. Use the {@see 'transcoded_thumb_filename'} filter instead.
792+
*/
793+
$thumbinfo['basename'] = apply_filters_deprecated( 'transcoded_temp_filename', array( $thumbinfo['basename'] ), '1.3.2', 'transcoded_thumb_filename', __( 'Use transcoded_thumb_filename filter to modify video thumbnail name and transcoded_video_filename filter to modify video file name.', 'transcoder' ) );
794+
795+
/**
796+
* Allows users/plugins to filter the thumbnail Name
797+
*
798+
* @since 1.3.2
799+
*
800+
* @param string $temp_name Contains the thumbnail public name
801+
*/
802+
$thumbinfo['basename'] = apply_filters( 'transcoded_thumb_filename', $thumbinfo['basename'] );
803+
804+
// Verify Extension.
805+
if ( empty( pathinfo( $thumbinfo['basename'], PATHINFO_EXTENSION ) ) ) {
806+
$thumbinfo['basename'] .= '.' . $thumbinfo['extension'];
807+
}
787808

788809
if ( 'wp-media' !== $post_thumbs_array['job_for'] ) {
789810
add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
@@ -792,6 +813,11 @@ public function add_media_thumbnails( $post_array ) {
792813
// Create a file in the upload folder with given content.
793814
$thumb_upload_info = wp_upload_bits( $thumbinfo['basename'], null, $thumbresource['body'] );
794815

816+
// Check error.
817+
if ( ! empty( $thumb_upload_info['error'] ) ) {
818+
$failed_thumbnails = $thumb_upload_info;
819+
}
820+
795821
/**
796822
* Allow users to filter/perform action on uploaded transcoded file.
797823
*
@@ -802,7 +828,6 @@ public function add_media_thumbnails( $post_array ) {
802828
* and $thumb_upload_info['file'] contains the file physical path
803829
* @param int $post_id Contains the attachment ID for which transcoded file is uploaded
804830
*/
805-
806831
$thumb_upload_info = apply_filters( 'transcoded_file_stored', $thumb_upload_info, $post_id );
807832

808833
if ( 'wp-media' !== $post_thumbs_array['job_for'] ) {
@@ -834,6 +859,10 @@ public function add_media_thumbnails( $post_array ) {
834859
}
835860
}
836861

862+
if ( false !== $failed_thumbnails && ! empty( $failed_thumbnails['error'] ) ) {
863+
$this->nofity_transcoding_failed( $post_array['job_id'], sprintf( 'Failed saving of Thumbnail for %1$s.', $post_array['file_name'] ) );
864+
}
865+
837866
update_post_meta( $post_id, '_rt_media_source', $post_thumbs_array['job_for'] );
838867
update_post_meta( $post_id, '_rt_media_thumbnails', $upload_thumbnail_array );
839868

@@ -906,8 +935,15 @@ public function add_transcoded_files( $file_post_array, $attachment_id, $job_for
906935
$new_wp_attached_file_pathinfo = pathinfo( $download_url );
907936
$post_mime_type = 'mp4' === $new_wp_attached_file_pathinfo['extension'] ? 'video/mp4' : 'audio/mp3';
908937
$attachemnt_url = wp_get_attachment_url( $attachment_id );
938+
939+
$timeout = 5;
940+
941+
if ( 'video/mp4' === $post_mime_type ) {
942+
$timeout = 120;
943+
}
944+
909945
try {
910-
$response = function_exists( 'vip_safe_wp_remote_get' ) ? vip_safe_wp_remote_get( $download_url, '', 3, 3 ) : wp_remote_get( $download_url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
946+
$response = function_exists( 'vip_safe_wp_remote_get' ) ? vip_safe_wp_remote_get( $download_url, '', 3, 3 ) : wp_remote_get( $download_url, array( 'timeout' => $timeout ) ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
911947
} catch ( Exception $e ) {
912948
$flag = $e->getMessage();
913949
}
@@ -920,7 +956,21 @@ public function add_transcoded_files( $file_post_array, $attachment_id, $job_for
920956
add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
921957
}
922958

923-
$upload_info = wp_upload_bits( $new_wp_attached_file_pathinfo['basename'], null, $file_content );
959+
/**
960+
* Allows users/plugins to filter the transcoded file Name
961+
*
962+
* @since 1.3.2
963+
*
964+
* @param string $new_wp_attached_file_pathinfo['basename'] Contains the file public name
965+
*/
966+
$file_name = apply_filters( 'transcoded_video_filename', $new_wp_attached_file_pathinfo['basename'] );
967+
968+
// Verify Extension.
969+
if ( empty( pathinfo( $file_name, PATHINFO_EXTENSION ) ) ) {
970+
$file_name .= '.' . $new_wp_attached_file_pathinfo['extension'];
971+
}
972+
973+
$upload_info = wp_upload_bits( $file_name, null, $file_content );
924974

925975
/**
926976
* Allow users to filter/perform action on uploaded transcoded file.
@@ -991,6 +1041,7 @@ public function add_transcoded_files( $file_post_array, $attachment_id, $job_for
9911041
} else {
9921042
$uploads = wp_upload_dir();
9931043
}
1044+
9941045
if ( 'video/mp4' === $post_mime_type ) {
9951046
$media_type = 'mp4';
9961047
} elseif ( 'audio/mp3' === $post_mime_type ) {
@@ -1129,7 +1180,11 @@ public function handle_callback() {
11291180
die();
11301181
}
11311182
} else {
1132-
if ( isset( $job_id ) && class_exists( 'RTDBModel' ) ) {
1183+
1184+
// To check if request is sumitted from the WP Job Manager plugin ( https://wordpress.org/plugins/wp-job-manager/ ).
1185+
$job_manager_form = transcoder_filter_input( INPUT_POST, 'job_manager_form', FILTER_SANITIZE_STRING );
1186+
1187+
if ( isset( $job_id ) && ! empty( $job_id ) && class_exists( 'RTDBModel' ) && empty( $job_manager_form ) ) {
11331188

11341189
$has_thumbs = isset( $thumbnail ) ? true : false;
11351190
$flag = false;
@@ -1451,7 +1506,7 @@ public function get_transcoding_status( $post_id ) {
14511506
if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
14521507
$status_page = vip_safe_wp_remote_get( $status_url, '', 3, 3 );
14531508
} else {
1454-
$status_page = wp_remote_get( $status_url, array( 'timeout' => 120 ) ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
1509+
$status_page = wp_safe_remote_get( $status_url, array( 'timeout' => 120 ) ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
14551510
}
14561511

14571512
if ( ! is_wp_error( $status_page ) ) {

admin/rt-transcoder-rest-routes.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ public function register_routes() {
3434
$this->namespace_prefix . $this->version,
3535
'/amp-media/(?P<id>\d+)',
3636
array(
37-
'methods' => WP_REST_Server::READABLE,
38-
'callback' => array( $this, 'get_media_data' ),
37+
'methods' => WP_REST_Server::READABLE,
38+
'callback' => array( $this, 'get_media_data' ),
39+
'permission_callback' => '__return_true',
3940
)
4041
);
4142

@@ -44,8 +45,9 @@ public function register_routes() {
4445
$this->namespace_prefix . $this->version,
4546
'/amp-rtmedia',
4647
array(
47-
'methods' => WP_REST_Server::READABLE,
48-
'callback' => array( $this, 'get_rtmedia_data' ),
48+
'methods' => WP_REST_Server::READABLE,
49+
'callback' => array( $this, 'get_rtmedia_data' ),
50+
'permission_callback' => '__return_true',
4951
)
5052
);
5153
}

languages/transcoder.pot

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Copyright (C) 2020
1+
# Copyright (C) 2021
22
# This file is distributed under the same license as the package.
33
msgid ""
44
msgstr ""
55
"Project-Id-Version: \n"
66
"Report-Msgid-Bugs-To: http://community.rtcamp.com/\n"
7-
"POT-Creation-Date: 2020-08-14 11:39:04+00:00\n"
7+
"POT-Creation-Date: 2021-01-12 10:42:24+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
11-
"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
11+
"PO-Revision-Date: 2021-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: Transcoder <support@rtcamp.com>\n"
1313
"Language-Team: Transcoder <support@rtcamp.com>\n"
1414
"Language: en\n"
@@ -416,7 +416,7 @@ msgstr ""
416416
msgid " page."
417417
msgstr ""
418418

419-
#: admin/rt-transcoder-admin.php:204 admin/rt-transcoder-handler.php:1232
419+
#: admin/rt-transcoder-admin.php:204 admin/rt-transcoder-handler.php:1287
420420
msgid "Please enter the license key."
421421
msgstr ""
422422

@@ -556,99 +556,105 @@ msgstr ""
556556
msgid "Transcoding usage this month"
557557
msgstr ""
558558

559-
#: admin/rt-transcoder-handler.php:947
559+
#: admin/rt-transcoder-handler.php:793
560+
msgid ""
561+
"Use transcoded_thumb_filename filter to modify video thumbnail name and "
562+
"transcoded_video_filename filter to modify video file name."
563+
msgstr ""
564+
565+
#: admin/rt-transcoder-handler.php:997
560566
msgid "Could not read file."
561567
msgstr ""
562568

563-
#: admin/rt-transcoder-handler.php:960 admin/rt-transcoder-handler.php:1113
564-
#: admin/rt-transcoder-handler.php:1178
569+
#: admin/rt-transcoder-handler.php:1010 admin/rt-transcoder-handler.php:1164
570+
#: admin/rt-transcoder-handler.php:1233
565571
msgid "Transcoding: Download Failed"
566572
msgstr ""
567573

568-
#: admin/rt-transcoder-handler.php:961 admin/rt-transcoder-handler.php:1114
569-
#: admin/rt-transcoder-handler.php:1179 admin/rt-transcoder-handler.php:1376
570-
#: admin/rt-transcoder-handler.php:1379
574+
#: admin/rt-transcoder-handler.php:1011 admin/rt-transcoder-handler.php:1165
575+
#: admin/rt-transcoder-handler.php:1234 admin/rt-transcoder-handler.php:1431
576+
#: admin/rt-transcoder-handler.php:1434
571577
msgid "Media"
572578
msgstr ""
573579

574-
#: admin/rt-transcoder-handler.php:961 admin/rt-transcoder-handler.php:1114
580+
#: admin/rt-transcoder-handler.php:1011 admin/rt-transcoder-handler.php:1165
575581
msgid " was successfully encoded but there was an error while downloading:"
576582
msgstr ""
577583

578-
#: admin/rt-transcoder-handler.php:961
584+
#: admin/rt-transcoder-handler.php:1011
579585
msgid "You can "
580586
msgstr ""
581587

582-
#: admin/rt-transcoder-handler.php:961
588+
#: admin/rt-transcoder-handler.php:1011
583589
msgid "retry the download"
584590
msgstr ""
585591

586-
#: admin/rt-transcoder-handler.php:974 admin/rt-transcoder-handler.php:1127
587-
#: admin/rt-transcoder-handler.php:1192
592+
#: admin/rt-transcoder-handler.php:1024 admin/rt-transcoder-handler.php:1178
593+
#: admin/rt-transcoder-handler.php:1247
588594
msgid "Done"
589595
msgstr ""
590596

591-
#: admin/rt-transcoder-handler.php:1075
597+
#: admin/rt-transcoder-handler.php:1126
592598
msgid "Something went wrong. Invalid post request."
593599
msgstr ""
594600

595-
#: admin/rt-transcoder-handler.php:1107 admin/rt-transcoder-handler.php:1172
601+
#: admin/rt-transcoder-handler.php:1158 admin/rt-transcoder-handler.php:1227
596602
msgid ""
597603
"Something went wrong. The required attachment id does not exists. It must "
598604
"have been deleted."
599605
msgstr ""
600606

601-
#: admin/rt-transcoder-handler.php:1179
607+
#: admin/rt-transcoder-handler.php:1234
602608
msgid " was successfully transcoded but there was an error while downloading:"
603609
msgstr ""
604610

605-
#: admin/rt-transcoder-handler.php:1244
611+
#: admin/rt-transcoder-handler.php:1299
606612
msgid "Transcoding disabled successfully."
607613
msgstr ""
608614

609-
#: admin/rt-transcoder-handler.php:1255
615+
#: admin/rt-transcoder-handler.php:1310
610616
msgid "Transcoding enabled successfully."
611617
msgstr ""
612618

613-
#: admin/rt-transcoder-handler.php:1372
619+
#: admin/rt-transcoder-handler.php:1427
614620
msgid "Transcoding: Something went wrong."
615621
msgstr ""
616622

617-
#: admin/rt-transcoder-handler.php:1375
623+
#: admin/rt-transcoder-handler.php:1430
618624
msgid " There was unexpected error occurred while transcoding this following media."
619625
msgstr ""
620626

621-
#: admin/rt-transcoder-handler.php:1380
627+
#: admin/rt-transcoder-handler.php:1435
622628
msgid " there was unexpected error occurred while transcoding this media."
623629
msgstr ""
624630

625-
#: admin/rt-transcoder-handler.php:1415
631+
#: admin/rt-transcoder-handler.php:1470
626632
msgid "Something went wrong. Please try again!"
627633
msgstr ""
628634

629-
#: admin/rt-transcoder-handler.php:1433 admin/rt-transcoder-handler.php:1469
635+
#: admin/rt-transcoder-handler.php:1488 admin/rt-transcoder-handler.php:1524
630636
msgid "Your file is transcoded successfully. Please refresh the page."
631637
msgstr ""
632638

633-
#: admin/rt-transcoder-handler.php:1464
639+
#: admin/rt-transcoder-handler.php:1519
634640
msgid ""
635641
"Looks like the server is taking too long to respond, Please try again in "
636642
"sometime."
637643
msgstr ""
638644

639-
#: admin/rt-transcoder-handler.php:1465
645+
#: admin/rt-transcoder-handler.php:1520
640646
msgid "Unfortunately, Transcoder failed to transcode this file."
641647
msgstr ""
642648

643-
#: admin/rt-transcoder-handler.php:1466
649+
#: admin/rt-transcoder-handler.php:1521
644650
msgid "Your file is getting transcoded. Please refresh after some time."
645651
msgstr ""
646652

647-
#: admin/rt-transcoder-handler.php:1467
653+
#: admin/rt-transcoder-handler.php:1522
648654
msgid "This file is still in the queue. Please refresh after some time."
649655
msgstr ""
650656

651-
#: admin/rt-transcoder-handler.php:1468
657+
#: admin/rt-transcoder-handler.php:1523
652658
msgid "Your server should be ready to receive the transcoded file."
653659
msgstr ""
654660

0 commit comments

Comments
 (0)