Skip to content

Commit ce6f48c

Browse files
authored
Merge pull request #280 from rtCamp/develop
Version update v1.3.5 (master)
2 parents 375868e + 65c2434 commit ce6f48c

9 files changed

+177
-148
lines changed

README.md

Lines changed: 8 additions & 1 deletion
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/), [vaishu.agola27](https://profiles.wordpress.org/vaishuagola27/), [ravatparmar](https://profiles.wordpress.org/ravatparmar/), [tremidkhar](https://profiles.wordpress.org/tremidkhar/)
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/), [tremidkhar](https://profiles.wordpress.org/tremidkhar/), [utsavladani](https://profiles.wordpress.org/utsavladani/), [vishalkakadiya](https://profiles.wordpress.org/vishalkakadiya/), [pavanpatil1](https://profiles.wordpress.org/pavanpatil1/)
1313

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

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

6767
## Changelog ##
68+
#### 1.3.5 [October 19, 2023] ####
69+
70+
* FIXED
71+
72+
* Compatible with PHP8.1
73+
* Enhance security checks and fixed deprecation errors.
74+
6875
#### 1.3.4 [August 17, 2021] ####
6976

7077
* FIXED

admin/js/build/rt-transcoder-block-editor-support.build.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/rt-retranscode-admin.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public function add_admin_menu() {
122122
'rt-retranscoder',
123123
array( $this, 'retranscode_interface' )
124124
);
125-
126125
}
127126

128127
/**
@@ -230,7 +229,7 @@ public function add_bulk_actions_via_javascript() {
230229
?>
231230
<script type="text/javascript">
232231
jQuery(document).ready(function($){
233-
$('select[name^="action"] option:last-child').before('<option value="bulk_retranscode_media"><?php echo esc_attr( __( 'Retranscode Media', 'transcoder' ) ); ?></option>');
232+
$('select[name^="action"] option:last-child').before('<option value="bulk_retranscode_media"><?php esc_html_e( 'Retranscode Media', 'transcoder' ); ?></option>');
234233
});
235234
</script>
236235
<?php
@@ -372,7 +371,7 @@ public function retranscode_interface() {
372371
<table border=0>
373372
?>
374373
<tr>
375-
<td><input type="submit" class="button button-primary button-small" value="<?php echo esc_html__( 'Proceed with retranscoding', 'transcoder' ); ?>"></td>
374+
<td><input type="submit" class="button button-primary button-small" value="<?php esc_attr_e( 'Proceed with retranscoding', 'transcoder' ); ?>"></td>
376375
<td></td>
377376
</tr>
378377
<?php
@@ -386,7 +385,7 @@ public function retranscode_interface() {
386385
}
387386
?>
388387
<tr>
389-
<td><input type="submit" class="button button-primary button-small" value="<?php esc_html_e( 'Proceed with retranscoding', 'transcoder' ); ?>" ></td>
388+
<td><input type="submit" class="button button-primary button-small" value="<?php esc_attr_e( 'Proceed with retranscoding', 'transcoder' ); ?>" ></td>
390389
<td></td>
391390
</tr>
392391
</table>
@@ -422,7 +421,7 @@ public function retranscode_interface() {
422421
<div id="retranscodemedia-bar-percent" style="position:absolute;left:50%;top:50%;width:300px;margin-left:-150px;height:25px;margin-top:-9px;font-weight:bold;text-align:center;"></div>
423422
</div>
424423

425-
<p><input type="button" class="button hide-if-no-js" name="retranscodemedia-stop" id="retranscodemedia-stop" value="<?php esc_html_e( 'Abort the Operation', 'transcoder' ); ?>" /></p>
424+
<p><input type="button" class="button hide-if-no-js" name="retranscodemedia-stop" id="retranscodemedia-stop" value="<?php esc_attr_e( 'Abort the Operation', 'transcoder' ); ?>" /></p>
426425

427426
<h3 class="title"><?php esc_html_e( 'Debugging Information', 'transcoder' ); ?></h3>
428427

@@ -594,7 +593,7 @@ function RetranscodeMedia( id ) {
594593

595594
<p><?php esc_html_e( 'To begin, just press the button below.', 'transcoder' ); ?></p>
596595

597-
<p><input type="submit" class="button hide-if-no-js button button-primary" name="rt-retranscoder" id="rt-retranscoder" value="<?php esc_html_e( 'Retranscode All Media', 'transcoder' ); ?>" /></p>
596+
<p><input type="submit" class="button hide-if-no-js button button-primary" name="rt-retranscoder" id="rt-retranscoder" value="<?php esc_attr_e( 'Retranscode All Media', 'transcoder' ); ?>" /></p>
598597

599598
<noscript><p><em><?php esc_html_e( 'You must enable Javascript in order to proceed!', 'transcoder' ); ?></em></p></noscript>
600599

@@ -717,10 +716,10 @@ public function die_json_error_msg( $id, $message ) {
717716
/**
718717
* Helper function to escape quotes in strings for use in Javascript
719718
*
720-
* @param string $string String to escape quotes from.
719+
* @param string $str String to escape quotes from.
721720
*/
722-
public function esc_quotes( $string ) {
723-
return str_replace( '"', '\"', $string );
721+
public function esc_quotes( $str ) {
722+
return str_replace( '"', '\"', $str );
724723
}
725724

726725
/**
@@ -744,7 +743,7 @@ private function retranscode_admin_error_notice() {
744743
* @param number $media_id Post ID of the media.
745744
* @param array $post_request Post request coming for the transcoder API.
746745
*/
747-
public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' ) {
746+
public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
748747
if ( empty( $media_id ) ) {
749748
return;
750749
}
@@ -767,7 +766,6 @@ public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' )
767766
rtt_delete_transcoded_files( $previous_thumbs );
768767
}
769768
delete_post_meta( $media_id, '_rt_media_thumbnails' );
770-
771769
}
772770

773771
/**
@@ -776,7 +774,7 @@ public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' )
776774
* @param number $media_id Post ID of the media.
777775
* @param array $transcoded_files Post request coming for the transcoder API.
778776
*/
779-
public function rtt_before_transcoded_media_store( $media_id = '', $transcoded_files = '' ) {
777+
public function rtt_before_transcoded_media_store( $media_id = '', $transcoded_files = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
780778
if ( empty( $media_id ) ) {
781779
return;
782780
}
@@ -791,7 +789,6 @@ public function rtt_before_transcoded_media_store( $media_id = '', $transcoded_f
791789
}
792790
}
793791
delete_post_meta( $media_id, '_rt_media_transcoded_files' );
794-
795792
}
796793

797794
/**
@@ -872,7 +869,7 @@ public function transcoded_thumbnails_added( $media_id = '' ) {
872869
* @param number $attachment_id Post ID of the media.
873870
* @param string $job_id Unique job ID of the transcoding request.
874871
*/
875-
public function rtt_handle_callback_finished( $attachment_id = '', $job_id = '' ) {
872+
public function rtt_handle_callback_finished( $attachment_id = '', $job_id = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
876873
if ( empty( $attachment_id ) ) {
877874
return;
878875
}
@@ -884,7 +881,6 @@ public function rtt_handle_callback_finished( $attachment_id = '', $job_id = ''
884881
delete_post_meta( $attachment_id, '_rt_retranscoding_sent' );
885882

886883
}
887-
888884
}
889885

890886
/**
@@ -1015,7 +1011,6 @@ public function add_search_mime_types( $where ) {
10151011
$where .= " AND post_mime_type LIKE 'audio/%' OR post_mime_type LIKE 'video/%'";
10161012
return $where;
10171013
}
1018-
10191014
}
10201015

10211016
// Start up this plugin.
@@ -1024,11 +1019,9 @@ public function add_search_mime_types( $where ) {
10241019
/**
10251020
* Execute RetranscodeMedia constructor.
10261021
*/
1027-
function retranscode_media() {
1022+
function retranscode_media() { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
10281023

10291024
global $RetranscodeMedia; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
10301025

10311026
$RetranscodeMedia = new RetranscodeMedia(); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
10321027
}
1033-
1034-
?>

admin/rt-transcoder-functions.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function rt_media_shortcode( $attrs, $content = '' ) {
5252
}
5353

5454
$mime_type = explode( '/', $type );
55+
$media_url = '';
5556

5657
if ( 'video' === $mime_type[0] ) {
5758

@@ -81,6 +82,10 @@ function rt_media_shortcode( $attrs, $content = '' ) {
8182

8283
$content = do_shortcode( "[audio {$audio_shortcode_attributes}]" );
8384

85+
} elseif ( 'image' === $mime_type[0] ) {
86+
87+
$content = '<p>' . esc_html__( 'Image attachments are not handled by Transcoder plugin.', 'transcoder' ) . '</p>';
88+
8489
}
8590

8691
if ( is_file_being_transcoded( $attachment_id ) ) {
@@ -160,7 +165,6 @@ function rt_media_get_video_thumbnail( $attachment_id ) {
160165
}
161166

162167
return false;
163-
164168
}
165169

166170
/**
@@ -199,7 +203,6 @@ function rtt_get_media_url( $attachment_id, $media_type = 'mp4' ) {
199203
}
200204

201205
return $final_file_url;
202-
203206
}
204207

205208
if ( ! function_exists( 'rtt_update_activity_after_thumb_set' ) ) {
@@ -455,7 +458,7 @@ function rtt_bp_get_activity_content( $content, $activity = null ) {
455458
}
456459
// If media is sent to the transcoder then show the message.
457460
if ( is_file_being_transcoded( $media->media_id ) ) {
458-
if ( current_user_can( 'administrator' ) && '1' === get_option( 'rtt_client_check_status_button', false ) ) {
461+
if ( current_user_can( 'manage_options' ) && '1' === get_option( 'rtt_client_check_status_button', false ) ) {
459462

460463
$check_button_text = __( 'Check Status', 'transcoder' );
461464

@@ -701,7 +704,6 @@ function rtt_add_status_columns_head( $defaults ) {
701704

702705
$defaults['convert_status'] = __( 'Transcode Status', 'transcoder' );
703706
return $defaults;
704-
705707
}
706708

707709
add_filter( 'manage_media_columns', 'rtt_add_status_columns_head' );
@@ -760,7 +762,6 @@ function rtt_status_column_register_sortable( $columns ) {
760762

761763
$columns['convert_status'] = 'convert_status';
762764
return $columns;
763-
764765
}
765766

766767
add_filter( 'manage_upload_sortable_columns', 'rtt_status_column_register_sortable' );
@@ -773,11 +774,11 @@ function rtt_status_column_register_sortable( $columns ) {
773774
*/
774775
function rtt_enqueue_scripts() {
775776

776-
if ( current_user_can( 'administrator' ) ) {
777+
if ( current_user_can( 'manage_options' ) ) {
777778
wp_register_script( 'rt_transcoder_js', plugins_url( 'js/rt-transcoder.min.js', __FILE__ ), array(), RT_TRANSCODER_VERSION, false );
778779

779780
$translation_array = array(
780-
'load_flag' => current_user_can( 'administrator' ),
781+
'load_flag' => true,
781782
'security_nonce' => esc_js( wp_create_nonce( 'check-transcoding-status-ajax-nonce' ) ),
782783
);
783784

@@ -806,7 +807,7 @@ function rtt_enqueue_frontend_scripts() {
806807
$file_to_use = 'public-assets/js/build/transcoder.min.js';
807808

808809
$file = path_join( RT_TRANSCODER_PATH, $file_to_use );
809-
if ( file_exists( $file ) ) {
810+
if ( file_exists( $file ) && class_exists( 'RTMedia' ) ) {
810811
wp_enqueue_script( 'rt-transcoder-front-js', RT_TRANSCODER_URL . $file_to_use, array( 'jquery', 'rtmedia-backbone' ), filemtime( $file ), true );
811812

812813
$rest_url_prefix = get_site_url() . '/' . rest_get_url_prefix();
@@ -854,7 +855,6 @@ function rtt_ajax_process_check_status_request() {
854855
}
855856

856857
wp_die();
857-
858858
}
859859

860860
// Action added to handle check_status onclick request.
@@ -911,7 +911,7 @@ function rtt_add_transcoding_process_status_button_single_media_page( $rtmedia_i
911911

912912
if ( is_file_being_transcoded( $post_id ) ) {
913913

914-
if ( current_user_can( 'administrator' ) && '1' === get_option( 'rtt_client_check_status_button', false ) ) {
914+
if ( current_user_can( 'manage_options' ) && '1' === get_option( 'rtt_client_check_status_button', false ) ) {
915915
$message = sprintf(
916916
'<div class="transcoding-in-progress"><button id="btn_check_status%1$s" class="btn_check_transcode_status" name="check_status_btn" data-value="%1$s">%2$s</button> <div class="transcode_status_box" id="span_status%1$s">%3$s</div></div>',
917917
esc_attr( $post_id ),
@@ -983,7 +983,7 @@ function rtt_filter_single_media_page_video_markup( $html, $rtmedia_media ) {
983983
* @param int $attachment_id ID of attachment.
984984
* @param string $autoformat If true then generating thumbs only else trancode video.
985985
*/
986-
function rtt_media_update_usage( $wp_metadata, $attachment_id, $autoformat = true ) {
986+
function rtt_media_update_usage( $wp_metadata, $attachment_id, $autoformat = true ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
987987

988988
$stored_key = get_site_option( 'rt-transcoding-api-key' );
989989
$transient_flag = get_transient( 'rtt_usage_update_flag' );
@@ -1022,3 +1022,17 @@ function get_server_var( $server_key, $filter_type = FILTER_SANITIZE_FULL_SPECIA
10221022
}
10231023
return $server_val;
10241024
}
1025+
1026+
/**
1027+
* Get local ip addresses for block.
1028+
*
1029+
* @return array
1030+
*/
1031+
function rtt_get_blacklist_ip_addresses() {
1032+
// If custom API URL added then don't block local ips.
1033+
if ( defined( 'TRANSCODER_API_URL' ) ) {
1034+
return array();
1035+
}
1036+
1037+
return array( '127.0.0.1', '::1' );
1038+
}

admin/rt-transcoder-handler.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function __construct( $no_init = false ) {
167167
}
168168

169169
/* Do not let the user to upload non supported media types on localhost */
170-
$blacklist = array( '127.0.0.1', '::1' );
170+
$blacklist = rtt_get_blacklist_ip_addresses();
171171
$remote_addr = rtt_get_remote_ip_address();
172172
if ( ! in_array( wp_unslash( $remote_addr ), $blacklist, true ) ) {
173173
add_filter( 'rtmedia_plupload_files_filter', array( $this, 'allowed_types' ), 10, 1 );
@@ -319,7 +319,6 @@ public function get_thumbnails_required( $attachment_id = '' ) {
319319
$thumb_count = apply_filters( 'rt_media_total_video_thumbnails', $thumb_count, $attachment_id );
320320

321321
return $thumb_count > 10 ? 10 : $thumb_count;
322-
323322
}
324323

325324
/**
@@ -489,12 +488,14 @@ public function save_api_key() {
489488
add_action( 'admin_notices', array( $this, 'public_host_needed_notice' ) );
490489
}
491490

492-
$apikey = trim( transcoder_filter_input( INPUT_GET, 'apikey', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) );
493-
$page = transcoder_filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
491+
$filtered_apikey = transcoder_filter_input( INPUT_GET, 'apikey', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
492+
$apikey = ! empty( $filtered_apikey ) ? trim( $filtered_apikey ) : '';
493+
494+
$page = transcoder_filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
494495

495496
if ( ! empty( $apikey ) && is_admin() && ! empty( $page ) && ( 'rt-transcoder' === $page ) ) {
496497
/* Do not activate transcoding service on localhost */
497-
$blacklist = array( '127.0.0.1', '::1' );
498+
$blacklist = rtt_get_blacklist_ip_addresses();
498499
$remote_addr = rtt_get_remote_ip_address();
499500
if ( in_array( wp_unslash( $remote_addr ), $blacklist, true ) ) {
500501
$return_page = add_query_arg(
@@ -650,7 +651,7 @@ public function usage_widget() {
650651
}
651652

652653
if ( ! empty( $api_key ) ) {
653-
if ( $usage_details && isset( $usage_details[ $api_key ]->status ) && $usage_details[ $api_key ]->status ) {
654+
if ( $usage_details && isset( $usage_details[ $api_key ]->status ) && $usage_details[ $api_key ]->status && 'error' !== $usage_details[ $api_key ]->status ) {
654655

655656
if ( isset( $usage_details[ $api_key ]->plan->name ) ) {
656657
$plan_name = strtolower( $usage_details[ $api_key ]->plan->name );
@@ -1332,14 +1333,12 @@ public function upload_dir( $upload_dir ) {
13321333
$rtmedia_upload_prefix = 'groups/';
13331334
$id = $this->uploaded['context_id'];
13341335
}
1335-
} else {
1336-
if ( 'group' !== $rtmedia_interaction->context->type ) {
1336+
} elseif ( 'group' !== $rtmedia_interaction->context->type ) {
13371337
$rtmedia_upload_prefix = 'users/';
13381338
$id = $this->uploaded['media_author'];
1339-
} else {
1340-
$rtmedia_upload_prefix = 'groups/';
1341-
$id = $rtmedia_interaction->context->id;
1342-
}
1339+
} else {
1340+
$rtmedia_upload_prefix = 'groups/';
1341+
$id = $rtmedia_interaction->context->id;
13431342
}
13441343

13451344
if ( ! $id ) {
@@ -1366,11 +1365,15 @@ public function upload_dir( $upload_dir ) {
13661365
* @param string $message Email message.
13671366
* @param boolean $include_admin If true then send an email to admin also else not.
13681367
*/
1369-
public function send_notification( $email_ids = array(), $subject, $message, $include_admin = true ) {
1368+
public function send_notification( $email_ids, $subject, $message, $include_admin = true ) {
13701369
if ( defined( 'RT_TRANSCODER_NO_MAIL' ) ) {
13711370
return;
13721371
}
13731372

1373+
if ( ! is_array( $email_ids ) ) {
1374+
$email_ids = array();
1375+
}
1376+
13741377
if ( empty( $subject ) || empty( $message ) ) {
13751378
return true;
13761379
}
@@ -1629,7 +1632,6 @@ class_exists( 'ImagickPixel', false ) &&
16291632
}
16301633

16311634
$this->wp_media_transcoding( array( 'mime_type' => 'application/pdf' ), $post_id );
1632-
16331635
}
16341636

16351637
/**

inc/helpers/custom-functions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @return mixed Value of the requested variable on success, FALSE if the filter fails, or NULL if the
2222
* variable_name variable is not set.
2323
*/
24-
function transcoder_filter_input( $type, $variable_name, $filter = FILTER_DEFAULT, $options = null ) {
24+
function transcoder_filter_input( $type, $variable_name, $filter = FILTER_DEFAULT, $options = 0 ) {
2525

2626
if ( php_sapi_name() !== 'cli' ) {
2727

@@ -118,5 +118,4 @@ function transcoder_filter_input( $type, $variable_name, $filter = FILTER_DEFAUL
118118
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE
119119

120120
return filter_var( $input, $filter );
121-
122121
}

0 commit comments

Comments
 (0)