From 9ad669d1605fe8d96bdc0074f3c89d8c455e71cc Mon Sep 17 00:00:00 2001 From: Pranav Yeole Date: Wed, 13 Nov 2024 14:46:19 +0530 Subject: [PATCH] fix: phpcs comments --- admin/rt-transcoder-handler.php | 43 ++++++++++++++--------------- admin/rt-transcoder-progressbar.php | 1 - admin/rt-transcoder-rest-routes.php | 1 - inc/helpers/autoloader.php | 1 - inc/traits/trait-singleton.php | 2 -- phpcs.xml | 3 +- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/admin/rt-transcoder-handler.php b/admin/rt-transcoder-handler.php index f997489..e845055 100755 --- a/admin/rt-transcoder-handler.php +++ b/admin/rt-transcoder-handler.php @@ -136,7 +136,7 @@ public function __construct( $no_init = false ) { } add_action( 'admin_init', array( $this, 'save_api_key' ), 10, 1 ); - + // phpcs:disable if ( $this->api_key ) { // Store api key as different db key if user disable transcoding service. if ( ! $this->stored_api_key ) { @@ -148,22 +148,22 @@ public function __construct( $no_init = false ) { if ( isset( $usage_info ) && is_array( $usage_info ) && array_key_exists( $this->api_key, $usage_info ) ) { // if ( isset( $usage_info[ $this->api_key ]->plan->expires ) - // && strtotime( $usage_info[ $this->api_key ]->plan->expires ) < time() ) { - // $usage_info = $this->update_usage( $this->api_key ); + // && strtotime( $usage_info[ $this->api_key ]->plan->expires ) < time() ) { + // $usage_info = $this->update_usage( $this->api_key ); // } - if ( array_key_exists( $this->api_key, $usage_info ) && is_object( $usage_info[ $this->api_key ] ) && isset( $usage_info[ $this->api_key ]->status ) && $usage_info[ $this->api_key ]->status === 'Active' ) { + if ( array_key_exists( $this->api_key, $usage_info ) && is_object( $usage_info[ $this->api_key ] ) && isset( $usage_info[ $this->api_key ]->status ) && 'Active' === $usage_info[ $this->api_key ]->status ) { if ( isset( $usage_info[ $this->api_key ]->remaining ) && $usage_info[ $this->api_key ]->remaining > 0 ) { // Enable re-transcoding. include_once RT_TRANSCODER_PATH . 'admin/rt-retranscode-admin.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant // if ( $usage_info[ $this->api_key ]->remaining < 524288000 && ! get_site_option( 'rt-transcoding-usage-limit-mail' ) ) { - // $this->nearing_usage_limit( $usage_info ); + // $this->nearing_usage_limit( $usage_info ); // } elseif ( $usage_info[ $this->api_key ]->remaining > 524288000 && get_site_option( 'rt-transcoding-usage-limit-mail' ) ) { - // update_site_option( 'rt-transcoding-usage-limit-mail', 0 ); + // update_site_option( 'rt-transcoding-usage-limit-mail', 0 ); // } // if ( strtotime( $usage_info[ $this->api_key ]->plan->expires ) > time() ) { - // add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_media_transcoding' ), 21, 2 ); + // add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_media_transcoding' ), 21, 2 ); // } /* Do not let the user to upload non supported media types on localhost */ @@ -178,6 +178,7 @@ public function __construct( $no_init = false ) { } } } + // phpcs:enable add_action( 'init', array( $this, 'handle_callback' ), 20 ); add_action( 'wp_ajax_rt_disable_transcoding', array( $this, 'disable_transcoding' ), 1 ); @@ -265,14 +266,14 @@ public function wp_media_transcoding( $wp_metadata, $attachment_id, $autoformat 'sslverify' => false, 'timeout' => 60, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout 'body' => array( - 'api_token' => $this->api_key, - 'job_type' => $job_type, - 'job_for' => $job_for, + 'api_token' => $this->api_key, + 'job_type' => $job_type, + 'job_for' => $job_for, 'file_origin' => rawurlencode( $url ), - 'callback_url' => rawurlencode( trailingslashit( home_url() ) . 'index.php' ), - 'force' => 0, - 'formats' => ( true === $autoformat ) ? ( ( 'video' === $type_array[0] ) ? 'mp4' : 'mp3' ) : $autoformat, - 'thumbnail_count' => $options_video_thumb, + 'callback_url' => rawurlencode( trailingslashit( home_url() ) . 'index.php' ), + 'force' => 0, + 'formats' => ( true === $autoformat ) ? ( ( 'video' === $type_array[0] ) ? 'mp4' : 'mp3' ) : $autoformat, + 'thumbnail_count' => $options_video_thumb, ), ); @@ -286,7 +287,7 @@ public function wp_media_transcoding( $wp_metadata, $attachment_id, $autoformat ) ) { $upload_info = json_decode( $upload_page['body'] ); - error_log(json_encode($upload_info)); + error_log( json_encode( $upload_info ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.WP.AlternativeFunctions.json_encode_json_encode if ( isset( $upload_info->data ) && isset( $upload_info->data->name ) ) { $job_id = $upload_info->data->name; update_post_meta( $attachment_id, '_rt_transcoding_job_id', $job_id ); @@ -1156,10 +1157,9 @@ public function handle_callback() { } if ( ! empty( $post_array['files'] ) ) { - if ( ! empty($post_array['files']['mpd']) ) { - update_post_meta( $attachment_id, '_rt_transcoded_url', $post_array['download_url'] ); - } - else { + if ( ! empty( $post_array['files']['mpd'] ) ) { + update_post_meta( $attachment_id, '_rt_transcoded_url', $post_array['download_url'] ); + } else { $this->add_transcoded_files( $post_array['files'], $attachment_id, $job_for ); } } @@ -1642,8 +1642,7 @@ private function filter_transcoder_response() { $post_array['files']['mp4'][] = filter_var( $post_var['files']['mp4'][0], FILTER_SANITIZE_URL ); } elseif ( ! empty( $post_var['files']['mp3'][0] ) ) { $post_array['files']['mp3'][] = filter_var( $post_var['files']['mp3'][0], FILTER_SANITIZE_URL ); - } - elseif ( ! empty( $post_var['files']['mpd'][0] ) ) { + } elseif ( ! empty( $post_var['files']['mpd'][0] ) ) { $post_array['files']['mpd'][] = filter_var( $post_var['files']['mpd'][0], FILTER_SANITIZE_URL ); } @@ -1656,4 +1655,4 @@ private function filter_transcoder_response() { return $post_array; } -} \ No newline at end of file +} diff --git a/admin/rt-transcoder-progressbar.php b/admin/rt-transcoder-progressbar.php index 009292d..6113153 100644 --- a/admin/rt-transcoder-progressbar.php +++ b/admin/rt-transcoder-progressbar.php @@ -27,7 +27,6 @@ class RT_Progress { * @return void */ public function __construct() { - } /** diff --git a/admin/rt-transcoder-rest-routes.php b/admin/rt-transcoder-rest-routes.php index c3576d2..85df8a6 100644 --- a/admin/rt-transcoder-rest-routes.php +++ b/admin/rt-transcoder-rest-routes.php @@ -151,5 +151,4 @@ private function get_media_data_by_id( $media_id ) { 'transcodedMedia' => $final_file_url, ); } - } diff --git a/inc/helpers/autoloader.php b/inc/helpers/autoloader.php index b9e353e..ad3e638 100644 --- a/inc/helpers/autoloader.php +++ b/inc/helpers/autoloader.php @@ -79,7 +79,6 @@ function autoloader( $resource = '' ) { // We already making sure that file is exists and valid. require_once $resource_path; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable } - } spl_autoload_register( __NAMESPACE__ . '\autoloader' ); diff --git a/inc/traits/trait-singleton.php b/inc/traits/trait-singleton.php index c4d6f8b..e39d1d2 100644 --- a/inc/traits/trait-singleton.php +++ b/inc/traits/trait-singleton.php @@ -83,7 +83,5 @@ final public static function get_instance() { } return $instance[ $called_class ]; - } - } // End trait diff --git a/phpcs.xml b/phpcs.xml index 617e6d7..31cda1c 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -38,7 +38,7 @@ as set in the "Requires at least" tag in the readme.txt file. --> - + @@ -48,5 +48,6 @@ */vendor/* .github/ */index.php + */build/*