| @@ -45,18 +45,23 @@ | ||
| 45 | 45 | * |
| 46 | 46 | * @var array The modules which SDK will be using. |
| 47 | 47 | */ |
| 48 | 48 | private static $available_modules = [ |
| 49 | + 'script_loader', | |
| 49 | 50 | 'dashboard_widget', |
| 50 | 51 | 'rollback', |
| 51 | 52 | 'uninstall_feedback', |
| 52 | 53 | 'licenser', |
| 53 | - 'endpoint', | |
| 54 | - 'notification', | |
| 55 | 54 | 'logger', |
| 56 | 55 | 'translate', |
| 57 | 56 | 'review', |
| 58 | - | |
| 57 | + 'recommendation', | |
| 58 | + 'notification', | |
| 59 | + 'promotions', | |
| 60 | + 'welcome', | |
| 61 | + 'compatibilities', | |
| 62 | + 'about_us', | |
| 63 | + 'announcements', | |
| 59 | 64 | ]; |
| 60 | 65 | |
| 61 | 66 | /** |
| 62 | 67 | * Initialize the sdk logic. |
| @@ -74,8 +79,30 @@ | ||
| 74 | 79 | } |
| 75 | 80 | } |
| 76 | 81 | |
| 77 | 82 | /** |
| 83 | + * Get cache token used in API requests. | |
| 84 | + * | |
| 85 | + * @return string Cache token. | |
| 86 | + */ | |
| 87 | + public static function get_cache_token() { | |
| 88 | + $cache_token = get_transient( 'themeisle_sdk_cache_token' ); | |
| 89 | + if ( false === $cache_token ) { | |
| 90 | + $cache_token = wp_generate_password( 6, false ); | |
| 91 | + set_transient( $cache_token, WEEK_IN_SECONDS ); | |
| 92 | + } | |
| 93 | + | |
| 94 | + return $cache_token; | |
| 95 | + } | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Clear cache token. | |
| 99 | + */ | |
| 100 | + public static function clear_cache_token() { | |
| 101 | + delete_transient( 'themeisle_sdk_cache_token' ); | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 78 | 105 | * Register product into SDK. |
| 79 | 106 | * |
| 80 | 107 | * @param string $base_file The product base file. |
| 81 | 108 | * |
| @@ -82,9 +109,9 @@ | ||
| 82 | 109 | * @return Loader The singleton object. |
| 83 | 110 | */ |
| 84 | 111 | public static function add_product( $base_file ) { |
| 85 | 112 | |
| 86 | - if ( ! is_readable( $base_file ) ) { | |
| 113 | + if ( ! is_file( $base_file ) ) { | |
| 87 | 114 | return self::$instance; |
| 88 | 115 | } |
| 89 | 116 | $product = new Product( $base_file ); |
| 90 | 117 | |
| @@ -112,6 +139,13 @@ | ||
| 112 | 139 | public static function get_products() { |
| 113 | 140 | return self::$products; |
| 114 | 141 | } |
| 115 | 142 | |
| 116 | - | |
| 143 | + /** | |
| 144 | + * Get the version of the SDK. | |
| 145 | + * | |
| 146 | + * @return string The version. | |
| 147 | + */ | |
| 148 | + public static function get_version() { | |
| 149 | + return self::$version; | |
| 150 | + } | |
| 117 | 151 | } |