| @@ -9,8 +9,11 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | namespace Templately; |
| 12 | 12 | |
| 13 | +use Templately\Admin\API\Settings as APISettings; | |
| 14 | +use Templately\Admin\Settings; | |
| 15 | +use Templately\API\AIContent; | |
| 13 | 16 | use Templately\API\Conditions; |
| 14 | 17 | use Templately\API\ThemeBuilderApi; |
| 15 | 18 | use Templately\Builder\ThemeBuilder; |
| 16 | 19 | use Templately\Core\Importer\FullSiteImport; |
| @@ -37,11 +40,12 @@ | ||
| 37 | 40 | use Templately\Core\Platform\Gutenberg; |
| 38 | 41 | use Templately\Core\Platform\Elementor; |
| 39 | 42 | |
| 40 | 43 | final class Plugin extends Base { |
| 41 | - public $version = '3.0.4'; | |
| 44 | + public $version = '3.5.0'; | |
| 42 | 45 | |
| 43 | 46 | public $admin; |
| 47 | + public $settings; | |
| 44 | 48 | /** |
| 45 | 49 | * Enqueue class responsible for assets |
| 46 | 50 | * @var Enqueue |
| 47 | 51 | */ |
| @@ -52,8 +56,13 @@ | ||
| 52 | 56 | */ |
| 53 | 57 | public $theme_builder; |
| 54 | 58 | |
| 55 | 59 | /** |
| 60 | + * @var Developer | |
| 61 | + */ | |
| 62 | + public $developer; | |
| 63 | + | |
| 64 | + /** | |
| 56 | 65 | * Plugin constructor. |
| 57 | 66 | * Initializing Templately plugin. |
| 58 | 67 | * |
| 59 | 68 | * @access private |
| @@ -65,10 +74,14 @@ | ||
| 65 | 74 | Maintenance::init(); |
| 66 | 75 | |
| 67 | 76 | $this->assets = Enqueue::get_instance( TEMPLATELY_URL, TEMPLATELY_PATH, $this->version ); |
| 68 | 77 | $this->admin = Admin::get_instance(); |
| 78 | + $this->settings = Settings::get_instance(); | |
| 69 | 79 | $this->theme_builder = ThemeBuilder::get_instance(); |
| 70 | 80 | |
| 81 | + // Initialize developer functionality if available | |
| 82 | + $this->init_developer_functionality(); | |
| 83 | + | |
| 71 | 84 | add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); |
| 72 | 85 | add_action( 'rest_api_init', [ $this, 'register_routes' ] ); |
| 73 | 86 | /** |
| 74 | 87 | * Initialize. |
| @@ -73,8 +86,9 @@ | ||
| 73 | 86 | /** |
| 74 | 87 | * Initialize. |
| 75 | 88 | */ |
| 76 | 89 | do_action( 'templately_init' ); |
| 90 | + | |
| 77 | 91 | } |
| 78 | 92 | |
| 79 | 93 | /** |
| 80 | 94 | * Cloning is forbidden. |
| @@ -113,8 +127,38 @@ | ||
| 113 | 127 | FullSiteImport::get_instance(); |
| 114 | 128 | } |
| 115 | 129 | |
| 116 | 130 | /** |
| 131 | + * Initialize developer functionality if available | |
| 132 | + * | |
| 133 | + * This method safely loads developer functionality only if the developer | |
| 134 | + * directory and class exist, preventing fatal errors in production builds. | |
| 135 | + * | |
| 136 | + * @return void | |
| 137 | + */ | |
| 138 | + private function init_developer_functionality() { | |
| 139 | + $developer_file = TEMPLATELY_PATH . 'includes/Core/Developer/Developer.php'; | |
| 140 | + | |
| 141 | + // Check if developer file exists before attempting to load | |
| 142 | + if ( file_exists( $developer_file ) ) { | |
| 143 | + // Include the developer class file | |
| 144 | + require_once $developer_file; | |
| 145 | + | |
| 146 | + // Check if the class exists after including the file | |
| 147 | + if ( class_exists( '\\Templately\\Core\\Developer\\Developer' ) ) { | |
| 148 | + $this->developer = \Templately\Core\Developer\Developer::get_instance(); | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + // If developer functionality is not available, set to null | |
| 153 | + if ( ! isset( $this->developer ) ) { | |
| 154 | + $this->developer = null; | |
| 155 | + } | |
| 156 | + } | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + /** | |
| 117 | 161 | * Initialize all platforms |
| 118 | 162 | * @return void |
| 119 | 163 | */ |
| 120 | 164 | public function platforms() { |
| @@ -134,8 +178,9 @@ | ||
| 134 | 178 | Dependencies::get_instance(); |
| 135 | 179 | Tags::get_instance(); |
| 136 | 180 | ThemeBuilderApi::get_instance(); |
| 137 | 181 | |
| 182 | + AIContent::get_instance(); | |
| 138 | 183 | Items::get_instance(); |
| 139 | 184 | SavedTemplates::get_instance(); |
| 140 | 185 | |
| 141 | 186 | Login::get_instance(); |
| @@ -143,8 +188,11 @@ | ||
| 143 | 188 | Import::get_instance(); |
| 144 | 189 | Profile::get_instance(); |
| 145 | 190 | MyClouds::get_instance(); |
| 146 | 191 | WorkSpaces::get_instance(); |
| 192 | + | |
| 193 | + APISettings::get_instance(); | |
| 194 | + // Note: DeveloperSettings::get_instance() is called in Developer::init_modules() when developer functionality is available and enabled | |
| 147 | 195 | } |
| 148 | 196 | |
| 149 | 197 | /** |
| 150 | 198 | * Register all REST API endpoints |