| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="<?php bloginfo( 'charset' ); ?>" /> |
| 5 |
<meta name="viewport" content="width=device-width, user-scalable=no"> |
| 6 |
<meta name="format-detection" content="telephone=no"/> |
| 7 |
</head> |
| 8 |
<body> |
| 9 |
<style> |
| 10 |
body { |
| 11 |
height: 600px !important; |
| 12 |
overflow: hidden !important; |
| 13 |
} |
| 14 |
#load_rich_editor { |
| 15 |
font-size: 13px !important; |
| 16 |
line-height: 2.15384615 !important; |
| 17 |
height: 600px !important; |
| 18 |
} |
| 19 |
#load_rich_editor iframe#sendmailmessage_ifr, #load_rich_editor textarea#sendmailmessage { |
| 20 |
height: 570px !important; |
| 21 |
} |
| 22 |
.wp-core-ui .quicktags-toolbar input.button.button-small { |
| 23 |
font-size: 12px; |
| 24 |
min-height: 26px; |
| 25 |
line-height: 2; |
| 26 |
} |
| 27 |
#wpfooter {display: none} |
| 28 |
</style> |
| 29 |
<div id="load_rich_editor"> |
| 30 |
<p id="email_content_response"></p> |
| 31 |
<?php |
| 32 |
/** |
| 33 |
* Set default tab use for rich editor |
| 34 |
* |
| 35 |
* @return string type of tab (text,html). |
| 36 |
*/ |
| 37 |
function usces_set_rich_editor_default_open_tab() { |
| 38 |
if ( usces_is_html_mail() ) { |
| 39 |
return 'tinymce'; |
| 40 |
} |
| 41 |
} |
| 42 |
// add function set rich editor default show tab. |
| 43 |
add_filter( 'wp_default_editor', 'usces_set_rich_editor_default_open_tab' ); |
| 44 |
|
| 45 |
$order_id = isset( $_GET['orderid'] ) ? stripslashes( $_GET['orderid'] ) : 0; |
| 46 |
$mode_str = isset( $_GET['mode'] ) ? stripslashes( $_GET['mode'] ) : ''; |
| 47 |
$content = ''; |
| 48 |
wp_editor( |
| 49 |
$content, |
| 50 |
'sendmailmessage', |
| 51 |
array( |
| 52 |
'dfw' => true, |
| 53 |
'tabindex' => 1, |
| 54 |
'textarea_rows' => 26, |
| 55 |
'textarea_name' => 'sendmailmessage', |
| 56 |
) |
| 57 |
); |
| 58 |
?> |
| 59 |
</div> |
| 60 |
<script> |
| 61 |
var settings ={ |
| 62 |
url: "<?php echo site_url(); ?>/wp-admin/admin-ajax.php", |
| 63 |
type: 'POST', |
| 64 |
cache: false |
| 65 |
}; |
| 66 |
window.onload = function() { |
| 67 |
jQuery("#email_content_response").html(''); |
| 68 |
var modeControl = '<?php echo esc_attr( $mode_str ); ?>'; |
| 69 |
var order_id = '<?php echo (int) $order_id; ?>'; |
| 70 |
var s = settings; |
| 71 |
s.data = "action=order_item_ajax&mode=" + modeControl + "&order_id=" + order_id+ '&wc_nonce=' + '<?php echo wp_create_nonce( 'order_edit' ); ?>'; |
| 72 |
var now_loading = "<?php esc_attr_e( 'now loading', 'usces' ); ?>"; |
| 73 |
if (typeof tinymce !== 'undefined') { |
| 74 |
tinymce.get("sendmailmessage").setContent(now_loading); |
| 75 |
} else { |
| 76 |
jQuery("#sendmailmessage").val(now_loading); |
| 77 |
} |
| 78 |
jQuery.ajax( s ).done(function( data ) { |
| 79 |
if (typeof tinymce !== 'undefined') { |
| 80 |
tinymce.get("sendmailmessage").setContent(data); |
| 81 |
} else { |
| 82 |
jQuery("#sendmailmessage").val(data); |
| 83 |
} |
| 84 |
}).fail(function( msg ) { |
| 85 |
jQuery("#email_content_response").html(msg); |
| 86 |
if (typeof tinymce !== 'undefined') { |
| 87 |
tinymce.get("sendmailmessage").setContent(''); |
| 88 |
} else { |
| 89 |
jQuery("#sendmailmessage").val(''); |
| 90 |
} |
| 91 |
}); |
| 92 |
}; |
| 93 |
function getContentEditor() { |
| 94 |
if (typeof tinymce !== 'undefined' && tinymce.get("sendmailmessage")) { |
| 95 |
if ( jQuery("#sendmailmessage").is(':visible') ) { |
| 96 |
// TEXT TAB active |
| 97 |
return jQuery("#sendmailmessage").val(); |
| 98 |
} else { |
| 99 |
// VISUAL TAB active |
| 100 |
return tinymce.get("sendmailmessage").getContent(); |
| 101 |
} |
| 102 |
} else { |
| 103 |
var sendmailmessageText = jQuery("#sendmailmessage").val(); |
| 104 |
return sendmailmessageText; |
| 105 |
} |
| 106 |
} |
| 107 |
</script> |
| 108 |
|