PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.10.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.10.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / vendor / codeinwp / themeisle-sdk / src / Loader.php

Loader.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.10.8, at vendor/codeinwp/themeisle-sdk/src/Loader.php

152 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The main loader class for ThemeIsle SDK
4 *
5 * @package ThemeIsleSDK
6 * @subpackage Loader
7 * @copyright Copyright (c) 2017, Marius Cristea
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.0.0
10 */
11
12 namespace ThemeisleSDK;
13
14 use ThemeisleSDK\Common\Module_Factory;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20
21 /**
22 * Singleton loader for ThemeIsle SDK.
23 */
24 final class Loader {
25 /**
26 * Singleton instance.
27 *
28 * @var Loader instance The singleton instance
29 */
30 private static $instance;
31 /**
32 * Current loader version.
33 *
34 * @var string $version The class version.
35 */
36 private static $version = '2.0.0';
37 /**
38 * Holds registered products.
39 *
40 * @var array The products which use the SDK.
41 */
42 private static $products = [];
43 /**
44 * Holds available modules to load.
45 *
46 * @var array The modules which SDK will be using.
47 */
48 private static $available_modules = [
49 'script_loader',
50 'dashboard_widget',
51 'rollback',
52 'uninstall_feedback',
53 'licenser',
54 'logger',
55 'translate',
56 'review',
57 'recommendation',
58 'notification',
59 'promotions',
60 'welcome',
61 'compatibilities',
62 'about_us',
63 'announcements',
64 ];
65
66 /**
67 * Initialize the sdk logic.
68 */
69 public static function init() {
70 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
71 self::$instance = new Loader();
72 $modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) );
73 foreach ( $modules as $key => $module ) {
74 if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) {
75 unset( $modules[ $key ] );
76 }
77 }
78 self::$available_modules = $modules;
79 }
80 }
81
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 /**
105 * Register product into SDK.
106 *
107 * @param string $base_file The product base file.
108 *
109 * @return Loader The singleton object.
110 */
111 public static function add_product( $base_file ) {
112
113 if ( ! is_file( $base_file ) ) {
114 return self::$instance;
115 }
116 $product = new Product( $base_file );
117
118 Module_Factory::attach( $product, self::get_modules() );
119
120 self::$products[ $product->get_slug() ] = $product;
121
122 return self::$instance;
123 }
124
125 /**
126 * Get all registered modules by the SDK.
127 *
128 * @return array Modules available.
129 */
130 public static function get_modules() {
131 return self::$available_modules;
132 }
133
134 /**
135 * Get all products using the SDK.
136 *
137 * @return array Products available.
138 */
139 public static function get_products() {
140 return self::$products;
141 }
142
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 }
151 }
152