Server IP : 104.21.14.48 / Your IP : 3.145.85.151 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/plugins/templately/includes/Core/Importer/ |
Upload File : |
<?php namespace Templately\Core\Importer; use Exception; use Templately\Core\Importer\Runners\BaseRunner; use Templately\Core\Importer\Runners\Customizer; use Templately\Core\Importer\Runners\ElementorContent; use Templately\Core\Importer\Runners\ExtraContent; use Templately\Core\Importer\Runners\Finalizer; use Templately\Core\Importer\Runners\GutenbergContent; use Templately\Core\Importer\Runners\Templates; use Templately\Core\Importer\Runners\WPContent; class Import { use LogHelper; /** * @var FullSiteImport */ public $full_site_import; /** * @var array */ private $manifest; private $runners; private $imported_data = []; /** * @throws Exception */ public function __construct( $full_site_import ) { $this->full_site_import = $full_site_import; $this->manifest = $full_site_import->manifest; $this->register_runners(); } /** * @throws Exception */ private function register_runners() { $this->runners = [ // TODO: Site Settings Import Runner new Customizer( $this->full_site_import ), new ExtraContent( $this->full_site_import ), new Templates( $this->full_site_import ), new GutenbergContent( $this->full_site_import ), new ElementorContent( $this->full_site_import ), new WPContent( $this->full_site_import ), new Finalizer( $this->full_site_import ) ]; } public function run( $callable = null ): array { $data = $this->full_site_import->get_request_params(); /** * @var BaseRunner $runner */ foreach ( $this->runners as $runner ) { try{ if ( $runner->should_run( $data, $this->imported_data ) ) { if( $runner->get_name() != 'finalize' ) { $runner->log(); } $import = $runner->import( $data, $this->imported_data ); $this->imported_data = array_merge_recursive( $this->imported_data, $import ); if( $runner->get_name() != 'finalize' ) { $runner->log( 100 ); } else { $runner->log( 100, $runner->log_message() ); } } }catch (Exception $e){ error_log($e->getMessage()); } } return $this->imported_data; } public function get_runners() { return $this->runners; } }