| @@ -49,13 +49,13 @@ | ||
| 49 | 49 | 'dashboard_widget', |
| 50 | 50 | 'rollback', |
| 51 | 51 | 'uninstall_feedback', |
| 52 | 52 | 'licenser', |
| 53 | - 'endpoint', | |
| 54 | - 'notification', | |
| 55 | 53 | 'logger', |
| 56 | 54 | 'translate', |
| 57 | 55 | 'review', |
| 56 | + 'recommendation', | |
| 57 | + 'notification', | |
| 58 | 58 | |
| 59 | 59 | ]; |
| 60 | 60 | |
| 61 | 61 | /** |
| @@ -74,8 +74,30 @@ | ||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | + * Get cache token used in API requests. | |
| 79 | + * | |
| 80 | + * @return string Cache token. | |
| 81 | + */ | |
| 82 | + public static function get_cache_token() { | |
| 83 | + $cache_token = get_transient( 'themeisle_sdk_cache_token' ); | |
| 84 | + if ( false === $cache_token ) { | |
| 85 | + $cache_token = wp_generate_password( 6, false ); | |
| 86 | + set_transient( $cache_token, WEEK_IN_SECONDS ); | |
| 87 | + } | |
| 88 | + | |
| 89 | + return $cache_token; | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Clear cache token. | |
| 94 | + */ | |
| 95 | + public static function clear_cache_token() { | |
| 96 | + delete_transient( 'themeisle_sdk_cache_token' ); | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 78 | 100 | * Register product into SDK. |
| 79 | 101 | * |
| 80 | 102 | * @param string $base_file The product base file. |
| 81 | 103 | * |
| @@ -82,9 +104,9 @@ | ||
| 82 | 104 | * @return Loader The singleton object. |
| 83 | 105 | */ |
| 84 | 106 | public static function add_product( $base_file ) { |
| 85 | 107 | |
| 86 | - if ( ! is_readable( $base_file ) ) { | |
| 108 | + if ( ! is_file( $base_file ) ) { | |
| 87 | 109 | return self::$instance; |
| 88 | 110 | } |
| 89 | 111 | $product = new Product( $base_file ); |
| 90 | 112 | |
| @@ -112,6 +134,14 @@ | ||
| 112 | 134 | public static function get_products() { |
| 113 | 135 | return self::$products; |
| 114 | 136 | } |
| 115 | 137 | |
| 138 | + /** | |
| 139 | + * Get the version of the SDK. | |
| 140 | + * | |
| 141 | + * @return string The version. | |
| 142 | + */ | |
| 143 | + public static function get_version() { | |
| 144 | + return self::$version; | |
| 145 | + } | |
| 116 | 146 | |
| 117 | 147 | } |