Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Transcoder activation check #30

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Read [Documentation](https://rtmedia.io/docs/transcoder/?utm_source####readme&ut
1. Transcoder Settings

## Changelog ##
#### 1.1.1 [Jan 10, 2017] ####
* FIXED

* False positive result of localhost checking

#### 1.1 [Dec 27, 2016] ####
* NEW FEATURES

Expand Down Expand Up @@ -121,4 +126,4 @@ Read [Documentation](https://rtmedia.io/docs/transcoder/?utm_source####readme&ut
#### 1.0.0 ####
Initial release

Introduced retranscoding service to retranscode the media and the regeneration of the video thumbnails
Fix the false positive localhost checking bug.
49 changes: 47 additions & 2 deletions admin/rt-transcoder-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ class="alignleft">
}

add_action( 'rtmedia_add_edit_tab_content', 'rtt_rtmedia_vedio_editor_content', 1000 );

if ( ! function_exists( 'rtt_set_video_thumbnail' ) ) {

/**
Expand Down Expand Up @@ -235,8 +234,54 @@ function rtt_update_wp_media_thumbnail( $thumb_url, $attachment_id ) {
$model->update( array( 'cover_art' => $thumb_url ), array( 'media_id' => $attachment_id ) );
}
}

}
}

add_action( 'transcoded_thumb_added', 'rtt_update_wp_media_thumbnail', 10, 2 );



/**
* Check the transcoder media usage if it has being expired.
*
* @since 1.1.2
*/
function rtt_init_callback() {

if ( is_multisite() ) {
$transcoder_usage_check = get_site_transient( 'rtt_transcoder_usage_check' );
} else {
$transcoder_usage_check = get_transient( 'rtt_transcoder_usage_check' );
}

// check if transcoder usage check transient is expired or not.
if ( empty( $transcoder_usage_check ) || false === $transcoder_usage_check ) {

// will expired after every half an hour.
if ( is_multisite() ) {
set_site_transient( 'rtt_transcoder_usage_check', true, 30 * MINUTE_IN_SECONDS );
} else {
set_transient( 'rtt_transcoder_usage_check', true, 30 * MINUTE_IN_SECONDS );
}

$api_key = get_site_option( 'rt-transcoding-api-key' );
$usage_info = get_site_option( 'rt-transcoding-usage' );

if ( isset( $usage_info ) && is_array( $usage_info ) && array_key_exists( $api_key , $usage_info ) ) {
if ( is_object( $usage_info[ $api_key ] ) && isset( $usage_info[ $api_key ]->status ) && $usage_info[ $api_key ]->status ) {
if ( ( ! isset( $usage_info[ $api_key ]->remaining ) || isset( $usage_info[ $api_key ]->remaining ) && $usage_info[ $api_key ]->remaining <= 0 ) && class_exists( 'RT_Transcoder_Handler' ) ) {
$transcoder_handler = new RT_Transcoder_Handler();

// check is api key is valid or not.
if ( $transcoder_handler->is_valid_key( $api_key ) ) {

// set the data usage limit of the api key.
$transcoder_handler->update_usage( $api_key );
}
}
}
}
}

}
add_action( 'init', 'rtt_init_callback', 101 );