HEX
Server: Apache
System: Linux www 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64
User: root (0)
PHP: 8.2.1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals
Upload Files
File: /mnt/drbd/www/edenhouse/wp-content/plugins/templately/includes/Core/Importer/Import.php
<?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 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 Customizer( $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;
	}
}