1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221:
<?php
class Inbound_Mailer_Enqueues {
static $scripts_queue;
public function __construct() {
self::load_hooks();
}
public static function load_hooks() {
add_action('wp_enqueue_scripts', array( __CLASS__ , 'load_all_frontend_enqueues' ) );
add_action('admin_enqueue_scripts', array( __CLASS__ , 'load_all_backend_enqueues' ) );
}
public static function load_all_frontend_enqueues() {
global $post , $wp_query;
if (!isset($post)) {
return;
}
self::load_frontend_global_enqueue();
self::load_frontend_inbound_email_enqueue();
}
public static function load_frontend_global_enqueue() {
global $post;
wp_enqueue_script('jquery');
wp_enqueue_style('mailer-unsubsribe-css', INBOUND_EMAIL_URLPATH . 'assets/css/frontend/style-unsubscribe.css');
wp_enqueue_script('mailer-unsubsribe-js', INBOUND_EMAIL_URLPATH . 'assets/js/frontend/unsubscribe.js');
}
public static function load_frontend_inbound_email_enqueue() {
global $post;
if ( isset($post) && $post->post_type == 'inbound-email' ) {
return;
}
}
public static function load_all_backend_enqueues( $hook ) {
global $post;
self::load_inbound_email_post_type_enqueues( $hook );
self::load_frontend_editor_enqueus( $hook );
}
public static function load_inbound_email_post_type_enqueues( $hook ) {
global $post;
$Templates = Inbound_Mailer_Load_Templates();
$screen = get_current_screen();
if ( isset($screen) && ( $screen->post_type == 'post' || $screen->post_type == 'page' ) ){
wp_enqueue_script('sweet-alert-js', INBOUND_EMAIL_URLPATH . 'assets/libraries/SweetAlert/sweet-alert.js');
wp_enqueue_style('sweet-alert-css', INBOUND_EMAIL_URLPATH . 'assets/libraries/SweetAlert/sweet-alert.css');
}
if ( ( isset($screen) && $screen->post_type != 'inbound-email' ) ){
return;
}
wp_enqueue_script(array('jquery', 'jqueryui', 'editor', 'thickbox', 'media-upload'));
wp_enqueue_script('jpicker', INBOUND_EMAIL_URLPATH . 'assets/libraries/jpicker/jpicker-1.1.6.min.js');
wp_localize_script( 'jpicker', 'jpicker', array( 'thispath' => INBOUND_EMAIL_URLPATH.'assets/libraries/jpicker/images/' ));
wp_enqueue_style('jpicker-css', INBOUND_EMAIL_URLPATH . 'assets/libraries/jpicker/css/jPicker-1.1.6.min.css');
wp_enqueue_script('jquery-datepicker', INBOUND_EMAIL_URLPATH . 'assets/libraries/jquery-datepicker/jquery.timepicker.min.js');
wp_enqueue_script('jquery-datepicker-functions', INBOUND_EMAIL_URLPATH . 'assets/libraries/jquery-datepicker/picker_functions.js');
wp_enqueue_script('jquery-datepicker-base', INBOUND_EMAIL_URLPATH . 'assets/libraries/jquery-datepicker/lib/base.js');
wp_enqueue_script('jquery-datepicker-datepair', INBOUND_EMAIL_URLPATH . 'assets/libraries/jquery-datepicker/lib/datepair.js');
wp_localize_script( 'jquery-datepicker', 'jquery_datepicker', array( 'thispath' => INBOUND_EMAIL_URLPATH.'assets/libraries/lib/jquery-datepicker/' ));
wp_enqueue_style('jquery-timepicker-css', INBOUND_EMAIL_URLPATH . 'assets/libraries/jquery-datepicker/jquery.timepicker.css');
wp_enqueue_style('jquery-datepicker-base.css', INBOUND_EMAIL_URLPATH . 'assets/libraries/jquery-datepicker/lib/base.css');
wp_enqueue_script('select2', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/Select2/select2.min.js');
wp_enqueue_style('select2', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/Select2/select2.min.css');
wp_enqueue_style('select2-bootstrap', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/Select2/select2.css');
wp_enqueue_script('sweet-alert-js', INBOUND_EMAIL_URLPATH . 'assets/libraries/SweetAlert/sweet-alert.js');
wp_enqueue_style('sweet-alert-css', INBOUND_EMAIL_URLPATH . 'assets/libraries/SweetAlert/sweet-alert.css');
if (isset($_GET['page']) && $_GET['page'] === 'inbound_email_global_settings') {
wp_enqueue_script('cta-settings-js', INBOUND_EMAIL_URLPATH . 'assets/js/admin/admin.global-settings.js');
}
if ( isset($hook) && $hook == 'post-new.php' || $hook == 'post.php') {
add_filter( 'wp_default_editor', array( __CLASS__ , 'set_default_editor_mode' ) );
wp_dequeue_script( 'autosave' );
wp_enqueue_script('mailer-post-edit-ui', INBOUND_EMAIL_URLPATH . 'assets/js/admin/admin.post-edit.js');
wp_localize_script( 'mailer-post-edit-ui', 'inbound_email_post_edit_ui', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'post_id' => $post->ID , 'wp_call_to_action_meta_nonce' => wp_create_nonce('inbound-email-meta-nonce'), 'wp_call_to_action_template_nonce' => wp_create_nonce('mailer-nonce') ) );
wp_enqueue_script('mailer-js-metaboxes', INBOUND_EMAIL_URLPATH . 'assets/js/admin/admin.metaboxes.js');
$template_data = $Templates->definitions;
$template_data = json_encode($template_data);
$template = get_post_meta($post->ID, 'mailer-selected-template', true);
$template = apply_filters('inbound_email_selected_template',$template);
$template = strtolower($template);
$params = array('selected_template'=>$template, 'templates'=>$template_data);
wp_localize_script('mailer-js-metaboxes', 'data', $params);
wp_enqueue_style('admin-post-edit-css', INBOUND_EMAIL_URLPATH . 'assets/css/admin-post-edit.css');
}
if ( $hook == 'post-new.php'){
wp_enqueue_script('mailer-js-create-new', INBOUND_EMAIL_URLPATH . 'assets/js/admin/admin.post-new.js', array('jquery'), '1.0', true );
wp_enqueue_style('mailer-css-post-new', INBOUND_EMAIL_URLPATH . 'assets/css/admin-post-new.css');
}
if ( $hook == 'edit.php' ){
wp_enqueue_style('mailer-list', INBOUND_EMAIL_URLPATH . 'assets/css/admin-post-listing.css');
wp_enqueue_script('mailer-list', INBOUND_EMAIL_URLPATH . 'assets/js/admin/admin.list.js', array('jquery'), '1.0', true );
}
}
public static function load_frontend_editor_enqueus() {
if (!isset($_GET['page'])||$_GET['page']!='mailer-frontend-editor') {
return;
}
wp_deregister_script('heartbeat');
wp_dequeue_script( 'autosave' );
wp_enqueue_script(array('jquery', 'editor', 'thickbox', 'media-upload'));
wp_dequeue_script('jquery-cookie');
wp_enqueue_script('jquery-cookie', INBOUND_EMAIL_URLPATH . 'assets/js/jquery.cookie.js');
wp_enqueue_style( 'wp-admin' );
wp_admin_css('thickbox');
add_thickbox();
wp_enqueue_script('mailer-post-edit-ui', INBOUND_EMAIL_URLPATH . 'assets/js/admin/admin.post-edit.js');
wp_localize_script( 'mailer-post-edit-ui', 'inbound_email_post_edit_ui', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'wp_call_to_action_meta_nonce' => wp_create_nonce('inbound-email-meta-nonce') ) );
wp_enqueue_script('jpicker', INBOUND_EMAIL_URLPATH . 'assets/libraries/jpicker/jpicker-1.1.6.min.js');
wp_localize_script( 'jpicker', 'jpicker', array( 'thispath' => INBOUND_EMAIL_URLPATH.'assets/libraries/jpicker/images/' ));
wp_enqueue_style('jpicker-css', INBOUND_EMAIL_URLPATH . 'assets/libraries/jpicker/css/jPicker-1.1.6.min.css');
wp_enqueue_style('jpicker-css', INBOUND_EMAIL_URLPATH . 'assets/libraries/jpicker/css/jPicker.css');
wp_enqueue_style('mailer-customizer-frontend', INBOUND_EMAIL_URLPATH . 'assets/css/customizer.frontend.css');
wp_enqueue_script('jquery-easing', INBOUND_EMAIL_URLPATH . 'assets/js/jquery.easing.min.js');
}
public static function set_default_editor_mode() {
return 'html';
}
}
$Inbound_Mailer_Enqueues = new Inbound_Mailer_Enqueues();