From 16e405fb72bf2416a7b4d83389746e7a5aa916af Mon Sep 17 00:00:00 2001
From: Sys-Admin <sys@rtcamp.com>
Date: Tue, 10 Jan 2017 11:50:16 +0000
Subject: [PATCH 1/2] Update version v1.1.1

---
 README.md | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 2db5f582..e577f69e 100644
--- a/README.md
+++ b/README.md
@@ -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
 
@@ -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.

From 4513e98ff89e56ffe81b0c1848a939bff2c5ea3c Mon Sep 17 00:00:00 2001
From: deepak <ddeeppaakk.d@gmail.com>
Date: Mon, 6 Feb 2017 12:55:22 +0530
Subject: [PATCH 2/2] Fix Transcoder activation check

Check for transcoder activation or renew in every after 30 mints
---
 admin/rt-transcoder-actions.php | 49 +++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/admin/rt-transcoder-actions.php b/admin/rt-transcoder-actions.php
index 9873101a..daf38466 100644
--- a/admin/rt-transcoder-actions.php
+++ b/admin/rt-transcoder-actions.php
@@ -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' ) ) {
 
 	/**
@@ -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 );