theme-template-library
3 weeks ago
class-advanced-import-activator.php
4 years ago
class-advanced-import-cron.php
4 years ago
class-advanced-import-deactivator.php
3 weeks ago
class-advanced-import-i18n.php
3 weeks ago
class-advanced-import-loader.php
5 years ago
class-advanced-import.php
3 months ago
class-theme-template-library-base.php
3 weeks ago
functions-advanced-import.php
3 weeks ago
index.php
5 years ago
class-advanced-import.php
339 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The file that defines the core plugin class |
| 5 | * |
| 6 | * A class definition that includes attributes and functions used across both the |
| 7 | * public-facing side of the site and the admin area. |
| 8 | * |
| 9 | * @link https://addonspress.com/ |
| 10 | * @since 1.0.0 |
| 11 | * |
| 12 | * @package Advanced_Import |
| 13 | * @subpackage Advanced_Import/includes |
| 14 | */ |
| 15 | |
| 16 | /** |
| 17 | * The core plugin class. |
| 18 | * |
| 19 | * This is used to define internationalization, admin-specific hooks, and |
| 20 | * public-facing site hooks. |
| 21 | * |
| 22 | * Also maintains the unique identifier of this plugin as well as the current |
| 23 | * version of the plugin. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | * @package Advanced_Import |
| 27 | * @subpackage Advanced_Import/includes |
| 28 | * @author Addons Press <addonspress.com> |
| 29 | */ |
| 30 | class Advanced_Import { |
| 31 | |
| 32 | /** |
| 33 | * The loader that's responsible for maintaining and registering all hooks that power |
| 34 | * the plugin. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | * @access protected |
| 38 | * @var Advanced_Import_Loader $loader Maintains and registers all hooks for the plugin. |
| 39 | */ |
| 40 | protected $loader; |
| 41 | |
| 42 | /** |
| 43 | * The unique identifier of this plugin. |
| 44 | * |
| 45 | * @since 1.0.0 |
| 46 | * @access protected |
| 47 | * @var string $plugin_name The string used to uniquely identify this plugin. |
| 48 | */ |
| 49 | protected $plugin_name; |
| 50 | |
| 51 | /** |
| 52 | * The current version of the plugin. |
| 53 | * |
| 54 | * @since 1.0.0 |
| 55 | * @access protected |
| 56 | * @var string $version The current version of the plugin. |
| 57 | */ |
| 58 | protected $version; |
| 59 | |
| 60 | /** |
| 61 | * The admin class object of the plugin. |
| 62 | * |
| 63 | * @since 1.0.0 |
| 64 | * @access public |
| 65 | * @var object Advanced_Import_Admin $admin |
| 66 | */ |
| 67 | public $admin; |
| 68 | |
| 69 | /** |
| 70 | * The language object of the plugin. |
| 71 | * |
| 72 | * @since 1.0.0 |
| 73 | * @access public |
| 74 | * @var object Advanced_Import_i18n $plugin_i18n |
| 75 | */ |
| 76 | public $plugin_i18n; |
| 77 | |
| 78 | /** |
| 79 | * The admin class object of the plugin. |
| 80 | * |
| 81 | * @since 1.4.1 |
| 82 | * @access public |
| 83 | * @var object Advanced_Import_Admin $actions |
| 84 | */ |
| 85 | public $actions; |
| 86 | |
| 87 | /** |
| 88 | * The admin class object of the plugin. |
| 89 | * |
| 90 | * @since 1.4.1 |
| 91 | * @access public |
| 92 | * @var object Advanced_Import_Admin $filters |
| 93 | */ |
| 94 | public $filters; |
| 95 | |
| 96 | /** |
| 97 | * The admin class object of the plugin. |
| 98 | * |
| 99 | * @since 1.4.1 |
| 100 | * @access public |
| 101 | * @var object Advanced_Import_Admin $domain |
| 102 | */ |
| 103 | public $domain; |
| 104 | |
| 105 | /** |
| 106 | * The admin class object of the plugin. |
| 107 | * |
| 108 | * @since 1.4.1 |
| 109 | * @access public |
| 110 | * @var object Advanced_Import_Admin $errors |
| 111 | */ |
| 112 | public $errors; |
| 113 | |
| 114 | /** |
| 115 | * Main Advanced_Import Instance |
| 116 | * |
| 117 | * Insures that only one instance of Advanced_Import exists in memory at any one |
| 118 | * time. Also prevents needing to define globals all over the place. |
| 119 | * |
| 120 | * @since 1.0.0 |
| 121 | * @access public |
| 122 | * |
| 123 | * @uses Advanced_Import::setup_globals() Setup the globals needed |
| 124 | * @uses Advanced_Import::load_dependencies() Include the required files |
| 125 | * @uses Advanced_Import::set_locale() Setup language |
| 126 | * @uses Advanced_Import::define_admin_hooks() Setup admin hooks and actions |
| 127 | * @uses Advanced_Import::run() run |
| 128 | * @return object |
| 129 | */ |
| 130 | public static function instance() { |
| 131 | |
| 132 | // Store the instance locally to avoid private static replication |
| 133 | static $instance = null; |
| 134 | |
| 135 | // Only run these methods if they haven't been ran previously |
| 136 | if ( null === $instance ) { |
| 137 | $instance = new Advanced_Import(); |
| 138 | |
| 139 | $instance->setup_globals(); |
| 140 | $instance->load_dependencies(); |
| 141 | $instance->set_locale(); |
| 142 | $instance->define_admin_hooks(); |
| 143 | $instance->run(); |
| 144 | } |
| 145 | |
| 146 | // Always return the instance |
| 147 | return $instance; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Empty construct |
| 152 | * |
| 153 | * @since 1.0.0 |
| 154 | */ |
| 155 | public function __construct() { } |
| 156 | /** |
| 157 | * Define the locale for this plugin for internationalization. |
| 158 | * |
| 159 | * Uses the Advanced_Import_i18n class in order to set the domain and to register the hook |
| 160 | * with WordPress. |
| 161 | * |
| 162 | * @since 1.0.0 |
| 163 | * @access private |
| 164 | */ |
| 165 | private function setup_globals() { |
| 166 | |
| 167 | $this->version = defined( 'ADVANCED_IMPORT_VERSION' ) ? ADVANCED_IMPORT_VERSION : '1.0.0'; |
| 168 | $this->plugin_name = ADVANCED_IMPORT_PLUGIN_NAME; |
| 169 | |
| 170 | // The array of actions and filters registered with this plugins. |
| 171 | $this->actions = array(); |
| 172 | $this->filters = array(); |
| 173 | |
| 174 | // Misc |
| 175 | $this->domain = 'advanced-import'; // Unique identifier for retrieving translated strings |
| 176 | $this->errors = new WP_Error(); // errors |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Load the required dependencies for this plugin. |
| 181 | * |
| 182 | * Include the following files that make up the plugin: |
| 183 | * |
| 184 | * - Advanced_Import_Loader. Orchestrates the hooks of the plugin. |
| 185 | * - Advanced_Import_i18n. Defines internationalization functionality. |
| 186 | * - Advanced_Import_Admin. Defines all hooks for the admin area. |
| 187 | * - Advanced_Import_Public. Defines all hooks for the public side of the site. |
| 188 | * |
| 189 | * Create an instance of the loader which will be used to register the hooks |
| 190 | * with WordPress. |
| 191 | * |
| 192 | * @since 1.0.0 |
| 193 | * @access private |
| 194 | */ |
| 195 | private function load_dependencies() { |
| 196 | |
| 197 | /** |
| 198 | * The class responsible for orchestrating the actions and filters of the |
| 199 | * core plugin. |
| 200 | */ |
| 201 | require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-loader.php'; |
| 202 | |
| 203 | /** |
| 204 | * The class responsible for defining internationalization functionality |
| 205 | * of the plugin. |
| 206 | */ |
| 207 | require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-i18n.php'; |
| 208 | |
| 209 | /** |
| 210 | * The class responsible for defining common functions |
| 211 | * of the plugin. |
| 212 | */ |
| 213 | require_once ADVANCED_IMPORT_PATH . 'includes/functions-advanced-import.php'; |
| 214 | require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-cron.php'; |
| 215 | |
| 216 | /** |
| 217 | * The class responsible for defining all actions that occur in the admin area. |
| 218 | */ |
| 219 | require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-tracking.php'; |
| 220 | require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-admin.php'; |
| 221 | require_once ADVANCED_IMPORT_PATH . 'admin/class-elementor-import.php'; |
| 222 | |
| 223 | /** |
| 224 | * Template import |
| 225 | */ |
| 226 | require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-template.php'; |
| 227 | |
| 228 | /** |
| 229 | * The class responsible for WordPress rset |
| 230 | */ |
| 231 | require_once ADVANCED_IMPORT_PATH . 'admin/class-reset.php'; |
| 232 | |
| 233 | /*Theme Specific Setting*/ |
| 234 | require_once ADVANCED_IMPORT_PATH . 'includes/class-theme-template-library-base.php'; |
| 235 | |
| 236 | require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/cosmoswp.php'; /*cosmoswp*/ |
| 237 | require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/acmethemes.php'; /*acmethemes*/ |
| 238 | require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/patternswp.php'; /*patternswp*/ |
| 239 | |
| 240 | $this->loader = new Advanced_Import_Loader(); |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Define the locale for this plugin for internationalization. |
| 245 | * |
| 246 | * Uses the Advanced_Import_i18n class in order to set the domain and to register the hook |
| 247 | * with WordPress. |
| 248 | * |
| 249 | * @since 1.0.0 |
| 250 | * @access private |
| 251 | */ |
| 252 | private function set_locale() { |
| 253 | |
| 254 | $this->plugin_i18n = new Advanced_Import_i18n(); |
| 255 | |
| 256 | $this->loader->add_action( 'plugins_loaded', $this->plugin_i18n, 'load_plugin_textdomain' ); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Register all of the hooks related to the admin area functionality |
| 261 | * of the plugin. |
| 262 | * |
| 263 | * @since 1.0.0 |
| 264 | * @access private |
| 265 | */ |
| 266 | private function define_admin_hooks() { |
| 267 | |
| 268 | $this->admin = advanced_import_admin(); |
| 269 | |
| 270 | $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_styles' ); |
| 271 | $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' ); |
| 272 | |
| 273 | /*add mime types*/ |
| 274 | $this->loader->add_action( 'mime_types', $this->admin, 'mime_types' ); |
| 275 | |
| 276 | /*add menu*/ |
| 277 | $this->loader->add_action( 'admin_menu', $this->admin, 'import_menu' ); |
| 278 | $this->loader->add_filter( 'plugin_action_links_advanced-import/advanced-import.php', $this->admin, 'add_plugin_links', 10, 4 ); |
| 279 | $this->loader->add_action( 'current_screen', $this->admin, 'help_tabs' ); |
| 280 | |
| 281 | /*ajax process*/ |
| 282 | $this->loader->add_action( 'wp_ajax_advanced_import_ajax_setup', $this->admin, 'upload_zip' ); |
| 283 | $this->loader->add_action( 'wp_ajax_demo_download_and_unzip', $this->admin, 'demo_download_and_unzip' ); |
| 284 | $this->loader->add_action( 'wp_ajax_theme_screen', $this->admin, 'theme_screen' ); |
| 285 | $this->loader->add_action( 'wp_ajax_install_theme', $this->admin, 'install_theme' ); |
| 286 | $this->loader->add_action( 'wp_ajax_plugin_screen', $this->admin, 'plugin_screen' ); |
| 287 | $this->loader->add_action( 'wp_ajax_install_plugin', $this->admin, 'install_plugin' ); |
| 288 | $this->loader->add_action( 'wp_ajax_content_screen', $this->admin, 'content_screen' ); |
| 289 | $this->loader->add_action( 'wp_ajax_import_content', $this->admin, 'import_content' ); |
| 290 | $this->loader->add_action( 'wp_ajax_complete_screen', $this->admin, 'complete_screen' ); |
| 291 | |
| 292 | /*Reset Process*/ |
| 293 | $this->loader->add_action( 'wp_loaded', advanced_import_reset_wordpress(), 'hide_reset_notice', -1 ); |
| 294 | $this->loader->add_action( 'admin_init', advanced_import_reset_wordpress(), 'reset_wizard_actions', -1 ); |
| 295 | $this->loader->add_action( 'admin_notices', advanced_import_reset_wordpress(), 'reset_wizard_notice', -1 ); |
| 296 | $this->loader->add_action( 'wp_ajax_advanced_import_before_reset', advanced_import_reset_wordpress(), 'before_reset' ); |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Run the loader to execute all of the hooks with WordPress. |
| 301 | * |
| 302 | * @since 1.0.0 |
| 303 | */ |
| 304 | public function run() { |
| 305 | $this->loader->run(); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * The name of the plugin used to uniquely identify it within the context of |
| 310 | * WordPress and to define internationalization functionality. |
| 311 | * |
| 312 | * @since 1.0.0 |
| 313 | * @return string The name of the plugin. |
| 314 | */ |
| 315 | public function get_plugin_name() { |
| 316 | return $this->plugin_name; |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * The reference to the class that orchestrates the hooks with the plugin. |
| 321 | * |
| 322 | * @since 1.0.0 |
| 323 | * @return Advanced_Import_Loader Orchestrates the hooks of the plugin. |
| 324 | */ |
| 325 | public function get_loader() { |
| 326 | return $this->loader; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Retrieve the version number of the plugin. |
| 331 | * |
| 332 | * @since 1.0.0 |
| 333 | * @return string The version number of the plugin. |
| 334 | */ |
| 335 | public function get_version() { |
| 336 | return $this->version; |
| 337 | } |
| 338 | } |
| 339 |