Skip to content

Commit

Permalink
fix: phpcs comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pranvinit committed Nov 13, 2024
1 parent 0b7ded9 commit 9ad669d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
43 changes: 21 additions & 22 deletions admin/rt-transcoder-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 */
Expand All @@ -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 );
Expand Down Expand Up @@ -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,
),
);

Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
}
}
Expand Down Expand Up @@ -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 );
}

Expand All @@ -1656,4 +1655,4 @@ private function filter_transcoder_response() {

return $post_array;
}
}
}
1 change: 0 additions & 1 deletion admin/rt-transcoder-progressbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class RT_Progress {
* @return void
*/
public function __construct() {

}

/**
Expand Down
1 change: 0 additions & 1 deletion admin/rt-transcoder-rest-routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,4 @@ private function get_media_data_by_id( $media_id ) {
'transcodedMedia' => $final_file_url,
);
}

}
1 change: 0 additions & 1 deletion inc/helpers/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
2 changes: 0 additions & 2 deletions inc/traits/trait-singleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,5 @@ final public static function get_instance() {
}

return $instance[ $called_class ];

}

} // End trait
3 changes: 2 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
as set in the "Requires at least" tag in the readme.txt file. -->
<rule ref="WordPress.WP.DeprecatedFunctions">
<properties>
<property name="minimum_supported_version" value="4.1" />
<!-- <property name="minimum_supported_version" value="4.1" /> -->
</properties>
</rule>

Expand All @@ -48,5 +48,6 @@
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>.github/</exclude-pattern>
<exclude-pattern>*/index.php</exclude-pattern>
<exclude-pattern>*/build/*</exclude-pattern>

</ruleset>

0 comments on commit 9ad669d

Please sign in to comment.