Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0fba97c
Send transcoding request from localhost
sourovroy Dec 1, 2021
7013df8
Merge pull request #244 from rtCamp/feature/run-from-local
sourovroy Dec 27, 2021
0e8e381
Fix broken banner image
HrithikDalal May 11, 2022
2d396b3
fix: adds message when image attachment is added to rt_media shortcode
Pathan-Amaankhan Feb 2, 2023
1fd3569
Merge branch 'master' of github.com:rtCamp/transcoder into sync-dev-w…
Pathan-Amaankhan Feb 2, 2023
9e9b66e
fix: adds conditional check for api-key's status
Pathan-Amaankhan Feb 2, 2023
a00ada7
Merge pull request #261 from rtCamp/sync-dev-with-master
Pathan-Amaankhan Feb 2, 2023
3089c59
Merge pull request #259 from rtCamp/fix/shortcode-rt_media
Pathan-Amaankhan Feb 3, 2023
af373f5
Merge pull request #262 from rtCamp/fix/wrong-message-on-subscription…
Pathan-Amaankhan Feb 3, 2023
69dd88b
fix(app): 275 Fix PHP deprecation errors for php@8.1
Utsav-Ladani Oct 18, 2023
686feee
Merge pull request #276 from rtCamp/fix/PHP-deprecation-error
Utsav-Ladani Oct 18, 2023
21a5217
fix(app): 275 Fix PHP@8.1 deprecation errors and enhance security checks
Utsav-Ladani Oct 18, 2023
42680e9
fix(app): 275 Remove trailing php ending tag from end of the file
Utsav-Ladani Oct 18, 2023
ced3d8a
Merge pull request #277 from rtCamp/fix/PHP-deprecation-error
Utsav-Ladani Oct 18, 2023
a6d3576
fix(app): Add condition to enqueue script from transcoder
Utsav-Ladani Oct 19, 2023
5663304
Merge pull request #278 from rtCamp/fix/rtMedia-js-dependency
Utsav-Ladani Oct 19, 2023
cfc00fb
Version update v1.3.5
Utsav-Ladani Oct 19, 2023
84d0a04
Merge pull request #279 from rtCamp/version-update/v1.3.5
Utsav-Ladani Oct 19, 2023
65c2434
Merge branch 'master' into develop
Utsav-Ladani Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Transcoding services for ANY WordPress website. Convert audio/video files of any
<img src="https://rtmedia.io/wp-content/uploads/2016/08/trancoder-banner-01.png" alt="Transcoder Banner"/>
</p>

* **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/)
* **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/)

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

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

## Changelog ##
#### 1.3.5 [October 19, 2023] ####

* FIXED

* Compatible with PHP8.1
* Enhance security checks and fixed deprecation errors.

#### 1.3.4 [August 17, 2021] ####

* FIXED
Expand Down
2 changes: 1 addition & 1 deletion admin/js/build/rt-transcoder-block-editor-support.build.js

Large diffs are not rendered by default.

31 changes: 12 additions & 19 deletions admin/rt-retranscode-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public function add_admin_menu() {
'rt-retranscoder',
array( $this, 'retranscode_interface' )
);

}

/**
Expand Down Expand Up @@ -230,7 +229,7 @@ public function add_bulk_actions_via_javascript() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$('select[name^="action"] option:last-child').before('<option value="bulk_retranscode_media"><?php echo esc_attr( __( 'Retranscode Media', 'transcoder' ) ); ?></option>');
$('select[name^="action"] option:last-child').before('<option value="bulk_retranscode_media"><?php esc_html_e( 'Retranscode Media', 'transcoder' ); ?></option>');
});
</script>
<?php
Expand Down Expand Up @@ -372,7 +371,7 @@ public function retranscode_interface() {
<table border=0>
?>
<tr>
<td><input type="submit" class="button button-primary button-small" value="<?php echo esc_html__( 'Proceed with retranscoding', 'transcoder' ); ?>"></td>
<td><input type="submit" class="button button-primary button-small" value="<?php esc_attr_e( 'Proceed with retranscoding', 'transcoder' ); ?>"></td>
<td></td>
</tr>
<?php
Expand All @@ -386,7 +385,7 @@ public function retranscode_interface() {
}
?>
<tr>
<td><input type="submit" class="button button-primary button-small" value="<?php esc_html_e( 'Proceed with retranscoding', 'transcoder' ); ?>" ></td>
<td><input type="submit" class="button button-primary button-small" value="<?php esc_attr_e( 'Proceed with retranscoding', 'transcoder' ); ?>" ></td>
<td></td>
</tr>
</table>
Expand Down Expand Up @@ -422,7 +421,7 @@ public function retranscode_interface() {
<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>
</div>

<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>
<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>

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

Expand Down Expand Up @@ -594,7 +593,7 @@ function RetranscodeMedia( id ) {

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

<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>
<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>

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

Expand Down Expand Up @@ -717,10 +716,10 @@ public function die_json_error_msg( $id, $message ) {
/**
* Helper function to escape quotes in strings for use in Javascript
*
* @param string $string String to escape quotes from.
* @param string $str String to escape quotes from.
*/
public function esc_quotes( $string ) {
return str_replace( '"', '\"', $string );
public function esc_quotes( $str ) {
return str_replace( '"', '\"', $str );
}

/**
Expand All @@ -744,7 +743,7 @@ private function retranscode_admin_error_notice() {
* @param number $media_id Post ID of the media.
* @param array $post_request Post request coming for the transcoder API.
*/
public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' ) {
public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
if ( empty( $media_id ) ) {
return;
}
Expand All @@ -767,7 +766,6 @@ public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' )
rtt_delete_transcoded_files( $previous_thumbs );
}
delete_post_meta( $media_id, '_rt_media_thumbnails' );

}

/**
Expand All @@ -776,7 +774,7 @@ public function rtt_before_thumbnail_store( $media_id = '', $post_request = '' )
* @param number $media_id Post ID of the media.
* @param array $transcoded_files Post request coming for the transcoder API.
*/
public function rtt_before_transcoded_media_store( $media_id = '', $transcoded_files = '' ) {
public function rtt_before_transcoded_media_store( $media_id = '', $transcoded_files = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
if ( empty( $media_id ) ) {
return;
}
Expand All @@ -791,7 +789,6 @@ public function rtt_before_transcoded_media_store( $media_id = '', $transcoded_f
}
}
delete_post_meta( $media_id, '_rt_media_transcoded_files' );

}

/**
Expand Down Expand Up @@ -872,7 +869,7 @@ public function transcoded_thumbnails_added( $media_id = '' ) {
* @param number $attachment_id Post ID of the media.
* @param string $job_id Unique job ID of the transcoding request.
*/
public function rtt_handle_callback_finished( $attachment_id = '', $job_id = '' ) {
public function rtt_handle_callback_finished( $attachment_id = '', $job_id = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
if ( empty( $attachment_id ) ) {
return;
}
Expand All @@ -884,7 +881,6 @@ public function rtt_handle_callback_finished( $attachment_id = '', $job_id = ''
delete_post_meta( $attachment_id, '_rt_retranscoding_sent' );

}

}

/**
Expand Down Expand Up @@ -1015,7 +1011,6 @@ public function add_search_mime_types( $where ) {
$where .= " AND post_mime_type LIKE 'audio/%' OR post_mime_type LIKE 'video/%'";
return $where;
}

}

// Start up this plugin.
Expand All @@ -1024,11 +1019,9 @@ public function add_search_mime_types( $where ) {
/**
* Execute RetranscodeMedia constructor.
*/
function retranscode_media() {
function retranscode_media() { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed

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

$RetranscodeMedia = new RetranscodeMedia(); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
}

?>
36 changes: 25 additions & 11 deletions admin/rt-transcoder-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function rt_media_shortcode( $attrs, $content = '' ) {
}

$mime_type = explode( '/', $type );
$media_url = '';

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

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

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

} elseif ( 'image' === $mime_type[0] ) {

$content = '<p>' . esc_html__( 'Image attachments are not handled by Transcoder plugin.', 'transcoder' ) . '</p>';

}

if ( is_file_being_transcoded( $attachment_id ) ) {
Expand Down Expand Up @@ -160,7 +165,6 @@ function rt_media_get_video_thumbnail( $attachment_id ) {
}

return false;

}

/**
Expand Down Expand Up @@ -199,7 +203,6 @@ function rtt_get_media_url( $attachment_id, $media_type = 'mp4' ) {
}

return $final_file_url;

}

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

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

Expand Down Expand Up @@ -701,7 +704,6 @@ function rtt_add_status_columns_head( $defaults ) {

$defaults['convert_status'] = __( 'Transcode Status', 'transcoder' );
return $defaults;

}

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

$columns['convert_status'] = 'convert_status';
return $columns;

}

add_filter( 'manage_upload_sortable_columns', 'rtt_status_column_register_sortable' );
Expand All @@ -773,11 +774,11 @@ function rtt_status_column_register_sortable( $columns ) {
*/
function rtt_enqueue_scripts() {

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

$translation_array = array(
'load_flag' => current_user_can( 'administrator' ),
'load_flag' => true,
'security_nonce' => esc_js( wp_create_nonce( 'check-transcoding-status-ajax-nonce' ) ),
);

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

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

$rest_url_prefix = get_site_url() . '/' . rest_get_url_prefix();
Expand Down Expand Up @@ -854,7 +855,6 @@ function rtt_ajax_process_check_status_request() {
}

wp_die();

}

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

if ( is_file_being_transcoded( $post_id ) ) {

if ( current_user_can( 'administrator' ) && '1' === get_option( 'rtt_client_check_status_button', false ) ) {
if ( current_user_can( 'manage_options' ) && '1' === get_option( 'rtt_client_check_status_button', false ) ) {
$message = sprintf(
'<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>',
esc_attr( $post_id ),
Expand Down Expand Up @@ -983,7 +983,7 @@ function rtt_filter_single_media_page_video_markup( $html, $rtmedia_media ) {
* @param int $attachment_id ID of attachment.
* @param string $autoformat If true then generating thumbs only else trancode video.
*/
function rtt_media_update_usage( $wp_metadata, $attachment_id, $autoformat = true ) {
function rtt_media_update_usage( $wp_metadata, $attachment_id, $autoformat = true ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed

$stored_key = get_site_option( 'rt-transcoding-api-key' );
$transient_flag = get_transient( 'rtt_usage_update_flag' );
Expand Down Expand Up @@ -1022,3 +1022,17 @@ function get_server_var( $server_key, $filter_type = FILTER_SANITIZE_FULL_SPECIA
}
return $server_val;
}

/**
* Get local ip addresses for block.
*
* @return array
*/
function rtt_get_blacklist_ip_addresses() {
// If custom API URL added then don't block local ips.
if ( defined( 'TRANSCODER_API_URL' ) ) {
return array();
}

return array( '127.0.0.1', '::1' );
}
30 changes: 16 additions & 14 deletions admin/rt-transcoder-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function __construct( $no_init = false ) {
}

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

return $thumb_count > 10 ? 10 : $thumb_count;

}

/**
Expand Down Expand Up @@ -489,12 +488,14 @@ public function save_api_key() {
add_action( 'admin_notices', array( $this, 'public_host_needed_notice' ) );
}

$apikey = trim( transcoder_filter_input( INPUT_GET, 'apikey', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) );
$page = transcoder_filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$filtered_apikey = transcoder_filter_input( INPUT_GET, 'apikey', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$apikey = ! empty( $filtered_apikey ) ? trim( $filtered_apikey ) : '';

$page = transcoder_filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

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

if ( ! empty( $api_key ) ) {
if ( $usage_details && isset( $usage_details[ $api_key ]->status ) && $usage_details[ $api_key ]->status ) {
if ( $usage_details && isset( $usage_details[ $api_key ]->status ) && $usage_details[ $api_key ]->status && 'error' !== $usage_details[ $api_key ]->status ) {

if ( isset( $usage_details[ $api_key ]->plan->name ) ) {
$plan_name = strtolower( $usage_details[ $api_key ]->plan->name );
Expand Down Expand Up @@ -1332,14 +1333,12 @@ public function upload_dir( $upload_dir ) {
$rtmedia_upload_prefix = 'groups/';
$id = $this->uploaded['context_id'];
}
} else {
if ( 'group' !== $rtmedia_interaction->context->type ) {
} elseif ( 'group' !== $rtmedia_interaction->context->type ) {
$rtmedia_upload_prefix = 'users/';
$id = $this->uploaded['media_author'];
} else {
$rtmedia_upload_prefix = 'groups/';
$id = $rtmedia_interaction->context->id;
}
} else {
$rtmedia_upload_prefix = 'groups/';
$id = $rtmedia_interaction->context->id;
}

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

if ( ! is_array( $email_ids ) ) {
$email_ids = array();
}

if ( empty( $subject ) || empty( $message ) ) {
return true;
}
Expand Down Expand Up @@ -1629,7 +1632,6 @@ class_exists( 'ImagickPixel', false ) &&
}

$this->wp_media_transcoding( array( 'mime_type' => 'application/pdf' ), $post_id );

}

/**
Expand Down
3 changes: 1 addition & 2 deletions inc/helpers/custom-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @return mixed Value of the requested variable on success, FALSE if the filter fails, or NULL if the
* variable_name variable is not set.
*/
function transcoder_filter_input( $type, $variable_name, $filter = FILTER_DEFAULT, $options = null ) {
function transcoder_filter_input( $type, $variable_name, $filter = FILTER_DEFAULT, $options = 0 ) {

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

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

return filter_var( $input, $filter );

}
Loading