| 1 |
<?php |
| 2 |
namespace Elementor\Core\Debug; |
| 3 |
|
| 4 |
use Elementor\Core\Debug\Classes\Inspection_Base; |
| 5 |
use Elementor\Core\Debug\Classes\Shop_Page_Edit; |
| 6 |
use Elementor\Core\Debug\Classes\Theme_Missing; |
| 7 |
use Elementor\Core\Debug\Classes\Htaccess; |
| 8 |
use Elementor\Utils; |
| 9 |
|
| 10 |
class Loading_Inspection_Manager { |
| 11 |
|
| 12 |
public static $_instance = null; |
| 13 |
|
| 14 |
public static function instance() { |
| 15 |
if ( null === self::$_instance ) { |
| 16 |
self::$_instance = new Loading_Inspection_Manager(); |
| 17 |
} |
| 18 |
return self::$_instance; |
| 19 |
} |
| 20 |
|
| 21 |
/** @var Inspection_Base[] */ |
| 22 |
private $inspections = []; |
| 23 |
|
| 24 |
public function register_inspections() { |
| 25 |
$this->inspections['theme-missing'] = new Theme_Missing(); |
| 26 |
$this->inspections['htaccess'] = new Htaccess(); |
| 27 |
|
| 28 |
$is_editing_shop_page = Utils::get_super_global_value( $_GET, 'post' ) == get_option( 'woocommerce_shop_page_id' ); |
| 29 |
if ( $is_editing_shop_page ) { |
| 30 |
$this->inspections['shop-page-edit'] = new Shop_Page_Edit(); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @param Inspection_Base $inspection |
| 36 |
*/ |
| 37 |
public function register_inspection( $inspection ) { |
| 38 |
$this->inspections[ $inspection->get_name() ] = $inspection; |
| 39 |
} |
| 40 |
|
| 41 |
public function run_inspections() { |
| 42 |
$debug_data = [ |
| 43 |
'message' => esc_html__( "We’re sorry, but something went wrong. Click on 'Learn more' and follow each of the steps to quickly solve it.", 'elementor' ), |
| 44 |
'header' => esc_html__( 'The preview could not be loaded', 'elementor' ), |
| 45 |
'doc_url' => 'https://go.elementor.com/preview-not-loaded/', |
| 46 |
]; |
| 47 |
foreach ( $this->inspections as $inspection ) { |
| 48 |
if ( ! $inspection->run() ) { |
| 49 |
$debug_data = [ |
| 50 |
'message' => $inspection->get_message(), |
| 51 |
'header' => $inspection->get_header_message(), |
| 52 |
'doc_url' => $inspection->get_help_doc_url(), |
| 53 |
'error' => true, |
| 54 |
]; |
| 55 |
break; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
return $debug_data; |
| 60 |
} |
| 61 |
} |
| 62 |
|