| 1 |
<?php |
| 2 |
/** |
| 3 |
* Selection Lite |
| 4 |
* Carefully selected Elementor addons bundle, for building the most awesome websites |
| 5 |
* |
| 6 |
* @encoding UTF-8 |
| 7 |
* @version 1.12 |
| 8 |
* @copyright (C) 2018-2024 Merkulove ( https://merkulov.design/ ). All rights reserved. |
| 9 |
* @license GPLv3 |
| 10 |
* @contributors merkulove, vladcherviakov, phoenixmkua, podolianochka, viktorialev01 |
| 11 |
* @support help@merkulov.design |
| 12 |
**/ |
| 13 |
|
| 14 |
namespace Merkulove\SelectionLite\Unity; |
| 15 |
|
| 16 |
/** Exit if accessed directly. */ |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
header( 'Status: 403 Forbidden' ); |
| 19 |
header( 'HTTP/1.1 403 Forbidden' ); |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Unity main class |
| 25 |
* |
| 26 |
* @since 1.0 |
| 27 |
*/ |
| 28 |
final class Unity { |
| 29 |
|
| 30 |
/** |
| 31 |
* The one true Unity. |
| 32 |
* |
| 33 |
* @since 1.0 |
| 34 |
* @var Unity |
| 35 |
**/ |
| 36 |
private static $instance; |
| 37 |
|
| 38 |
/** |
| 39 |
* Sets up a new plugin instance. |
| 40 |
* |
| 41 |
* @since 1.0 |
| 42 |
* @access public |
| 43 |
* |
| 44 |
* @return void |
| 45 |
**/ |
| 46 |
private function __construct() { |
| 47 |
|
| 48 |
/** Initialize main variables. */ |
| 49 |
Plugin::get_instance(); |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Do critical compatibility checks and stop work if fails. |
| 55 |
* |
| 56 |
* @param array $checks - List of critical initial checks to run. List of available checks: 'php56' |
| 57 |
* |
| 58 |
* @since 1.0 |
| 59 |
* @access public |
| 60 |
* |
| 61 |
* @return bool |
| 62 |
**/ |
| 63 |
public function initial_checks( $checks ) { |
| 64 |
|
| 65 |
/** Do critical initial checks. */ |
| 66 |
if ( ! CheckCompatibility::get_instance()->do_initial_checks( $checks, true ) ) { return false; } |
| 67 |
|
| 68 |
return true; |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Set up the Unity. |
| 74 |
* |
| 75 |
* @since 1.0 |
| 76 |
* @access public |
| 77 |
* |
| 78 |
* @return void |
| 79 |
**/ |
| 80 |
public function setup() { |
| 81 |
|
| 82 |
/** Define hooks that runs on both the front-end and the dashboard. */ |
| 83 |
$this->both_hooks(); |
| 84 |
|
| 85 |
/** Define admin hooks. */ |
| 86 |
$this->admin_hooks(); |
| 87 |
|
| 88 |
/** Extra setup for Elementor plugins. */ |
| 89 |
if ( 'elementor' === Plugin::get_type() ) { |
| 90 |
Elementor::get_instance()->setup(); |
| 91 |
} |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Define hooks that runs on both the front-end and the dashboard. |
| 97 |
* |
| 98 |
* @since 1.0 |
| 99 |
* @access private |
| 100 |
* |
| 101 |
* @return void |
| 102 |
**/ |
| 103 |
private function both_hooks() { |
| 104 |
|
| 105 |
/** Load the plugin text domain for translation. */ |
| 106 |
PluginHelper::load_textdomain(); |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Register all the hooks related to the admin area functionality. |
| 112 |
* |
| 113 |
* @since 1.0 |
| 114 |
* @access private |
| 115 |
* |
| 116 |
* @return void |
| 117 |
**/ |
| 118 |
private function admin_hooks() { |
| 119 |
|
| 120 |
if ( ! is_admin() ) { return; } |
| 121 |
|
| 122 |
/** Initialize plugin settings. */ |
| 123 |
Settings::get_instance(); |
| 124 |
|
| 125 |
/** Add admin CSS */ |
| 126 |
AdminStyles::get_instance(); |
| 127 |
|
| 128 |
/** Add admin JS */ |
| 129 |
AdminScripts::get_instance(); |
| 130 |
|
| 131 |
/** Initialize PluginHelper. */ |
| 132 |
PluginHelper::get_instance(); |
| 133 |
|
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Run when the plugin is activated. |
| 138 |
* |
| 139 |
* @static |
| 140 |
* @since 1.0 |
| 141 |
* @access public |
| 142 |
* |
| 143 |
* @return void |
| 144 |
**/ |
| 145 |
public static function on_activation() { |
| 146 |
|
| 147 |
/** Security checks. */ |
| 148 |
if ( ! current_user_can( 'activate_plugins' ) ) { return; } |
| 149 |
|
| 150 |
/** Do critical initial checks. */ |
| 151 |
if ( ! CheckCompatibility::get_instance()->do_initial_checks( ['php56'], false ) ) { return; } |
| 152 |
|
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Called when a plugin is deactivated. |
| 157 |
* |
| 158 |
* @static |
| 159 |
* @since 1.0 |
| 160 |
* @access public |
| 161 |
* |
| 162 |
* @return void |
| 163 |
**/ |
| 164 |
public static function on_deactivation() {} |
| 165 |
|
| 166 |
/** |
| 167 |
* Main Instance. |
| 168 |
* |
| 169 |
* Insures that only one instance of Unity exists in memory at any one time. |
| 170 |
* |
| 171 |
* @static |
| 172 |
* @since 1.0 |
| 173 |
* |
| 174 |
* @return Unity |
| 175 |
**/ |
| 176 |
public static function get_instance() { |
| 177 |
|
| 178 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { |
| 179 |
|
| 180 |
self::$instance = new self(); |
| 181 |
|
| 182 |
} |
| 183 |
|
| 184 |
return self::$instance; |
| 185 |
|
| 186 |
} |
| 187 |
|
| 188 |
} |
| 189 |
|