GRAYBYTE WORDPRESS FILE MANAGER3697

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/chahida.co.in/wp-content/plugins/envato-elements/inc/backend/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/chahida.co.in/wp-content/plugins/envato-elements/inc/backend//class-subscription.php
<?php
/**
 * Envato Elements: Subscription
 *
 * Subscription management
 *
 * @package Envato/Envato_Elements
 * @since 0.0.2
 */

namespace Envato_Elements\Backend;

use Envato_Elements\Utils\Base;
use Envato_Elements\Utils\Extensions_API;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}


/**
 * Subscription management.
 *
 * @since 0.0.2
 */
class Subscription extends Base {

	const SUBSCRIPTION_TOKEN_OPTION = 'elements_token';
	const SUBSCRIPTION_API_CACHE = 3600; // Cache results locally this long.
	const SUBSCRIPTION_INACTIVE = 'inactive';
	const SUBSCRIPTION_FREE = 'free';
	const SUBSCRIPTION_PAID = 'paid';


	/**
	 * Calls the Extensions API to verify if the provided token is correct.
	 * Caches the users subscription_status so our plugin can know what to do for different cases.
	 *
	 * @return array
	 */
	public function verify_token_and_cache_user_info( $token = false ) {

		if ( $token ) {
			// If we've been given an Extensions token value, we pass that through to our API library:
			Extensions_API::get_instance()->set_token( $token );
		}

		// Call the user_into endpoint, this returns the users subscription_status
		$result = Extensions_API::get_instance()->api_call( '/extensions/user_info' );
		if ( ! is_wp_error( $result ) && is_array( $result ) && ! empty( $result['subscription_status'] ) ) {
			// We've got a successful result from the Extensions API, cache the result locally so we don't have to hit this endpoint over and over again.
			$cached_auth_information = [
				'valid'  => true,
				'token'  => Extensions_API::get_instance()->get_token(),
				'time'   => time(),
				'status' => $result['subscription_status'],
			];
		} else {
			// We got a failure back from the Extensions API, this could be a number of reasons:
			// - invalid token
			// - api connectivity issue
			// - upstream connectivity issue
			$cached_auth_information = [
				'valid'  => false,
				'token'  => '',
				'time'   => time(),
				'status' => 'error',
			];

			// We check if our response was a "wp_error" so we can sniff more details about the issue out of the response:
			if ( is_wp_error( $result ) && is_array( $result->errors ) && is_array( $result->error_data ) ) {
				$error_status  = key( $result->errors );
				$error_data    = $result->error_data[ $error_status ];

				$cached_auth_information['error'] = [
					'message' => ! empty( $error_data['message'] ) ? $error_data['message'] : current( $result->errors[ $error_status ] ),
					'code'    => ! empty( $error_data['code'] ) ? $error_data['code'] : false,
				];
			}
		}

		Options::get_instance()->set( self::SUBSCRIPTION_TOKEN_OPTION, $cached_auth_information );

		return $cached_auth_information;
	}

	public function get_subscription_status(){
		$cached_auth_information = Options::get_instance()->get( self::SUBSCRIPTION_TOKEN_OPTION );
		if( $cached_auth_information && !empty($cached_auth_information['status'])){
			return $cached_auth_information['status'];
		}
		return 'unknown';
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:29
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:29
giriqfky / giriqfky
0644
class-downloaded-items.php
2.351 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-elementor-modal.php
1.565 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-options.php
3.385 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-photos-embed.php
1.612 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-rest.php
3.174 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-subscription.php
2.949 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-template-kits.php
8.546 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644
class-welcome.php
4.516 KB
March 07 2025 11:33:34
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF