diff --git a/admin/partials/rt-transcoder-admin-display.php b/admin/partials/rt-transcoder-admin-display.php index 90cf0ac..d3c9d70 100755 --- a/admin/partials/rt-transcoder-admin-display.php +++ b/admin/partials/rt-transcoder-admin-display.php @@ -12,7 +12,11 @@ // Check if the user has access to the transcoding service. $usage_details = get_site_option( 'rt-transcoding-usage' ); -$has_access = isset( $usage_details[ $this->api_key ]->sub_status ) && $usage_details[ $this->api_key ]->sub_status; +$usage = $usage_details[ $this->api_key ] ?? null; +$has_access = ! empty( $this->api_key ) && + is_object( $usage ) && + ! empty( $usage->status ) && + ( ! isset( $usage->remaining ) || $usage->remaining > 0 ); // Temporarily allow access to all users. $has_access = true; ?> diff --git a/admin/rt-retranscode-admin.php b/admin/rt-retranscode-admin.php index 45fcccf..3629473 100644 --- a/admin/rt-retranscode-admin.php +++ b/admin/rt-retranscode-admin.php @@ -48,6 +48,8 @@ public function __construct() { $this->stored_api_key = get_site_option( 'rt-transcoding-api-key-stored' ); $this->usage_info = get_site_option( 'rt-transcoding-usage' ); + // Load Rest Endpoints. + $this->load_rest_endpoints(); // Do not activate re-transcoding without valid license key // Or usage are fully utilized. @@ -80,9 +82,6 @@ public function __construct() { // Allow people to change what capability is required to use this feature. $this->capability = apply_filters( 'retranscode_media_cap', 'manage_options' ); - - // Load Rest Endpoints. - $this->load_rest_endpoints(); } /** diff --git a/admin/rt-transcoder-admin.php b/admin/rt-transcoder-admin.php index 6fe67d0..42335c0 100755 --- a/admin/rt-transcoder-admin.php +++ b/admin/rt-transcoder-admin.php @@ -140,7 +140,13 @@ public function register_transcoder_settings() { // Check if the user has an active paid subscription. $usage_details = get_site_option( 'rt-transcoding-usage' ); - $has_access = isset( $usage_details[ $this->api_key ]->sub_status ) && $usage_details[ $this->api_key ]->sub_status; + $usage = $usage_details[ $this->api_key ] ?? null; + $has_access = ! empty( $this->api_key ) && + is_object( $usage ) && + ! empty( $usage->status ) && + ( ! isset( $usage->remaining ) || $usage->remaining > 0 ); + // Temporarily allow access to all users. + $has_access = true; // Register adaptive bitrate streaming setting with conditional default. register_setting( @@ -189,7 +195,11 @@ public function register_transcoder_settings() { */ public function sanitize_adaptive_bitrate( $value ) { $usage_details = get_site_option( 'rt-transcoding-usage' ); - $has_access = isset( $usage_details[ $this->api_key ]->sub_status ) && $usage_details[ $this->api_key ]->sub_status; + $usage = $usage_details[ $this->api_key ] ?? null; + $has_access = ! empty( $this->api_key ) && + is_object( $usage ) && + ! empty( $usage->status ) && + ( ! isset( $usage->remaining ) || $usage->remaining > 0 ); // Temporarily allow access to all users. $has_access = true; @@ -249,7 +259,7 @@ public function enqueue_scripts_styles() { $page = transcoder_filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); - if ( 'admin.php' !== $pagenow || 'rt-transcoder' !== $page ) { + if ( 'upload.php' !== $pagenow && ( 'admin.php' !== $pagenow && 'rt-transcoder' !== $page ) ) { return; } $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; diff --git a/admin/rt-transcoder-handler.php b/admin/rt-transcoder-handler.php index 469f43c..c0935a1 100755 --- a/admin/rt-transcoder-handler.php +++ b/admin/rt-transcoder-handler.php @@ -118,6 +118,9 @@ public function __construct( $no_init = false ) { $this->api_key = get_site_option( 'rt-transcoding-api-key' ); $this->stored_api_key = get_site_option( 'rt-transcoding-api-key-stored' ); + // Temporarily inclduing rt-retranscode-admin.php file here. + include_once RT_TRANSCODER_PATH . 'admin/rt-retranscode-admin.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant + /** * Allow other plugin and wp-config to overwrite API URL. */ @@ -136,6 +139,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.