| @@ -1,0 +1,57 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace ABlocksThemeBuilder; | |
| 4 | + | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; // Exit if accessed directly. | |
| 7 | +} | |
| 8 | + | |
| 9 | +use ABlocks\Interfaces\AddonInterface; | |
| 10 | + | |
| 11 | +final class ThemeBuilder implements AddonInterface { | |
| 12 | + private $addon_name = 'theme-builder'; | |
| 13 | + private function __construct() { | |
| 14 | + $this->define_constants(); | |
| 15 | + $this->init_addon(); | |
| 16 | + } | |
| 17 | + | |
| 18 | + public function define_constants() { | |
| 19 | + /** | |
| 20 | + * Defines CONSTANTS for Whole Addon. | |
| 21 | + */ | |
| 22 | + define( 'ABLOCKS_THEME_BUILDER_VERSION', '1.0' ); | |
| 23 | + define( 'ABLOCKS_THEME_BUILDER_ADDON_NAME', $this->addon_name ); | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function init_addon() { | |
| 27 | + // fire addon activation hook | |
| 28 | + add_action( "ablocks/addons/activated_{$this->addon_name}", array( $this, 'addon_activation_hook' ) ); | |
| 29 | + // if disable then stop running addon | |
| 30 | + if ( ! \ABlocks\Helper::get_addon_active_status( $this->addon_name ) ) { | |
| 31 | + return; | |
| 32 | + } | |
| 33 | + | |
| 34 | + database::init(); | |
| 35 | + CompatibilityManager::init(); | |
| 36 | + Assets::init(); | |
| 37 | + ( new Ajax\Posts() )->dispatch_actions(); | |
| 38 | + Shortcode::init(); | |
| 39 | + if ( ! is_admin() ) { | |
| 40 | + Frontend::init(); | |
| 41 | + } | |
| 42 | + } | |
| 43 | + | |
| 44 | + public static function init() { | |
| 45 | + static $instance = false; | |
| 46 | + | |
| 47 | + if ( ! $instance ) { | |
| 48 | + $instance = new self(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + return $instance; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public function addon_activation_hook() { | |
| 55 | + | |
| 56 | + } | |
| 57 | +} | |