| 1 |
<?php |
| 2 |
namespace EmailKit\Admin\EmailKitEditor; |
| 3 |
|
| 4 |
use EmailKit\Admin\MetaField\StyleLoad; |
| 5 |
|
| 6 |
defined('ABSPATH') || exit('No direct script access allowed!'); |
| 7 |
|
| 8 |
/** |
| 9 |
* EmailKitEditorInit |
| 10 |
* |
| 11 |
* @since 1.0.0 |
| 12 |
*/ |
| 13 |
|
| 14 |
class EmailKitEditorInit |
| 15 |
{ |
| 16 |
|
| 17 |
public function __construct() |
| 18 |
{ |
| 19 |
if(!current_user_can( 'manage_options' )){ |
| 20 |
return; |
| 21 |
} |
| 22 |
$post_id = isset($_GET['post']) ? sanitize_text_field(wp_unslash($_GET['post'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification -- Nonce can't be added in CPT edit page URL |
| 23 |
$action = isset($_GET['action']) ? sanitize_text_field(wp_unslash($_GET['action'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification -- Nonce can't be added in CPT edit page URL |
| 24 |
$post_type = get_post_type($post_id); |
| 25 |
|
| 26 |
if (empty($post_id) || $action != 'emailkit-builder' || $post_type != 'emailkit') { |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
$dep = \EmailKit\Admin\Dependency::check(get_post_meta($post_id,'emailkit_email_type', true)); |
| 31 |
|
| 32 |
if(true !== $dep){ |
| 33 |
wp_die("Need to " . esc_html($dep['label']) . "<a href='" . esc_url($dep['url']) . "'> Check here </a>", 'Need to activate plugin'); |
| 34 |
} |
| 35 |
|
| 36 |
new StyleLoad(); |
| 37 |
add_action('wp_loaded', [$this, 'add_editor_template']); |
| 38 |
} |
| 39 |
|
| 40 |
public function add_editor_template() |
| 41 |
{ |
| 42 |
?> |
| 43 |
<!DOCTYPE html> |
| 44 |
<html> |
| 45 |
<head> |
| 46 |
<?php wp_head(); ?> |
| 47 |
<meta charSet="utf-8" /> |
| 48 |
<meta name="viewport" content="width=device-width" /> |
| 49 |
<meta name="next-head-count" content="2" /> |
| 50 |
</head> |
| 51 |
|
| 52 |
<body class="<?php body_class(['post-'.get_the_ID()]); ?>"> |
| 53 |
|
| 54 |
<?php |
| 55 |
require_once EMAILKIT_PATH . '/dist/editor.php'; |
| 56 |
wp_footer(); |
| 57 |
?> |
| 58 |
|
| 59 |
</body> |
| 60 |
</html> |
| 61 |
<?php |
| 62 |
exit(); |
| 63 |
} |
| 64 |
} |
| 65 |
|