| 1 |
<?php |
| 2 |
namespace Swatchly; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 5 |
|
| 6 |
class Helper{ |
| 7 |
|
| 8 |
private static $_instance = null; |
| 9 |
|
| 10 |
/** |
| 11 |
* Instance |
| 12 |
*/ |
| 13 |
public static function instance(){ |
| 14 |
if( is_null( self::$_instance ) ){ |
| 15 |
self::$_instance = new self(); |
| 16 |
} |
| 17 |
return self::$_instance; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Constructor |
| 22 |
*/ |
| 23 |
public function __construct(){ |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* If the request is an AJAX request and the action is elementor, then it's an Elementor preview |
| 29 |
*/ |
| 30 |
public static function doing_ajax_is_elementor_preview(){ |
| 31 |
$server = wp_unslash( $_SERVER ); |
| 32 |
|
| 33 |
$referer = !empty($server['referer']) ? $server['referer'] : ''; |
| 34 |
$request_uri = !empty($server['REQUEST_URI']) ? $server['REQUEST_URI'] : ''; |
| 35 |
|
| 36 |
parse_str($referer, $query_str_arr); |
| 37 |
parse_str($request_uri, $request_uri_arr); |
| 38 |
|
| 39 |
if( !empty($query_str_arr['action']) && $query_str_arr['action'] == 'elementor' || |
| 40 |
!empty($request_uri_arr['action']) && $request_uri_arr['action'] == 'elementor' |
| 41 |
){ |
| 42 |
return true; |
| 43 |
} |
| 44 |
|
| 45 |
return false; |
| 46 |
} |
| 47 |
|
| 48 |
} |