| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* | |
| 3 | +* | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| @@ -6,75 +6,97 @@ | ||
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | -* | |
| 10 | +* | |
| 11 | 11 | */ |
| 12 | 12 | class CJTMainAccessPoint extends CJTAccessPoint { |
| 13 | - | |
| 14 | - /** | |
| 15 | - * put your comment there... | |
| 16 | - * | |
| 17 | - * @var mixed | |
| 18 | - */ | |
| 19 | - protected static $instance; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * put your comment there... | |
| 23 | - * | |
| 24 | - */ | |
| 25 | - public function __construct() { | |
| 26 | - // Initialize Access Point base! | |
| 27 | - parent::__construct(); | |
| 28 | - // Set access point name! | |
| 29 | - $this->name = 'main'; | |
| 30 | - // Needed for calling from nuinstall static method! | |
| 31 | - self::$instance = $this; | |
| 32 | - } | |
| 33 | 13 | |
| 34 | - /** | |
| 35 | - * put your comment there... | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - protected function doListen() { | |
| 39 | - // Register uninstall hook! | |
| 40 | - if (CJTPlugin::getInstance()->isInstalled()) { | |
| 41 | - // Wordpress need STATIC method! | |
| 42 | - register_uninstall_hook(CJTOOLBOX_PLUGIN_FILE, array(__CLASS__, 'uninstall')); | |
| 43 | - } | |
| 44 | - // If not in uninstall state then plugins_loaded hook | |
| 45 | - // used to run the plugin! | |
| 46 | - add_action('plugins_loaded', array(&$this, 'main')); | |
| 47 | - } | |
| 48 | - | |
| 49 | - /** | |
| 50 | - * put your comment there... | |
| 51 | - * | |
| 52 | - */ | |
| 53 | - public function main() { | |
| 54 | - // Run the coupling! | |
| 55 | - $this->controllerName = 'blocks-coupling'; | |
| 56 | - $this->route(); | |
| 57 | - // Run all the aother access points! | |
| 58 | - CJTPlugin::getInstance()->listen(); | |
| 59 | - } | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * put your comment there... | |
| 63 | - * | |
| 64 | - */ | |
| 65 | - public static function uninstall() { | |
| 66 | - // Get the only instance we've for the main access point! | |
| 67 | - $mainAccessPointObject = self::$instance; | |
| 68 | - // Load default controller! | |
| 69 | - $mainAccessPointObject->controllerName = 'default'; | |
| 70 | - $controller = $mainAccessPointObject->route() | |
| 71 | - // Fire uninstall action! | |
| 72 | - ->setAction('uninstall') | |
| 73 | - ->_doAction(); | |
| 74 | - return $controller; | |
| 75 | - } | |
| 76 | - | |
| 14 | + /** | |
| 15 | + * put your comment there... | |
| 16 | + * | |
| 17 | + * @var mixed | |
| 18 | + */ | |
| 19 | + protected static $instance; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * put your comment there... | |
| 23 | + * | |
| 24 | + */ | |
| 25 | + public function __construct() { | |
| 26 | + // Initialize Access Point base! | |
| 27 | + parent::__construct(); | |
| 28 | + // Set access point name! | |
| 29 | + $this->name = 'main'; | |
| 30 | + // Needed for calling from nuinstall static method! | |
| 31 | + self::$instance = $this; | |
| 32 | + } | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * put your comment there... | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + protected function doListen() | |
| 39 | + { | |
| 40 | + | |
| 41 | + // Register uninstall hook! | |
| 42 | + if (CJTPlugin::getInstance()->isInstalled()) | |
| 43 | + { | |
| 44 | + // Wordpress need STATIC method! | |
| 45 | + register_uninstall_hook(CJTOOLBOX_PLUGIN_FILE, array(__CLASS__, 'uninstall')); | |
| 46 | + } | |
| 47 | + | |
| 48 | + // If not in uninstall state then plugins_loaded hook | |
| 49 | + // used to run the plugin! | |
| 50 | + add_action('plugins_loaded', array(&$this, 'main')); | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * put your comment there... | |
| 55 | + * | |
| 56 | + */ | |
| 57 | + public function main() | |
| 58 | + { | |
| 59 | + | |
| 60 | + // Run the coupling only if installed! | |
| 61 | + if (CJTPlugin::getInstance()->isInstalled()) | |
| 62 | + { | |
| 63 | + $this->controllerName = 'blocks-coupling'; | |
| 64 | + $this->route(false); | |
| 65 | + } | |
| 66 | + | |
| 67 | + // Run all the aother access points! | |
| 68 | + CJTPlugin::getInstance()->listen(); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * put your comment there... | |
| 73 | + * | |
| 74 | + */ | |
| 75 | + public static function uninstall() { | |
| 76 | + // For the uninstaller to be run eraseData setting must be enabled. | |
| 77 | + cssJSToolbox::import('models:settings:uninstall.php'); | |
| 78 | + cssJSToolbox::import('models:installer.php'); | |
| 79 | + | |
| 80 | + delete_option( CJTPlugin::DB_VERSION_OPTION_NAME ); | |
| 81 | + delete_option( CJTInstallerModel::INSTALLATION_STATE ); | |
| 82 | + delete_option( 'cjtplusinstaller' ); | |
| 83 | + | |
| 84 | + $settings = new CJTSettingsUninstallPage(); | |
| 85 | + if ($settings->eraseData) { | |
| 86 | + // Get the only instance we've for the main access point! | |
| 87 | + $mainAccessPointObject = self::$instance; | |
| 88 | + // Load default controller! | |
| 89 | + $mainAccessPointObject->controllerName = 'default'; | |
| 90 | + $controller = $mainAccessPointObject->route(false) | |
| 91 | + // Fire uninstall action! | |
| 92 | + ->setAction('uninstall') | |
| 93 | + ->_doAction(); | |
| 94 | + | |
| 95 | + | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 77 | 99 | } // End class. |
| 78 | 100 | |
| 79 | 101 | // Hookable! |
| 80 | 102 | CJTMainAccessPoint::define('CJTMainAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |