| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
class WPCargo_Email_Settings{ |
| 6 |
private $text_domain = 'wpcargo'; |
| 7 |
function __construct(){ |
| 8 |
add_action('admin_menu', array( $this, 'add_email_settings_menu' ), 15 ); |
| 9 |
//call register settings function |
| 10 |
add_action( 'admin_init', array( $this, 'register_wpcargo_mail_settings') ); |
| 11 |
} |
| 12 |
public function add_email_settings_menu(){ |
| 13 |
add_submenu_page( |
| 14 |
'wpcargo-settings', |
| 15 |
wpcargo_client_email_settings_label(), |
| 16 |
wpcargo_client_email_settings_label(), |
| 17 |
'manage_options', |
| 18 |
'wpcargo-email-settings', |
| 19 |
array( $this, 'client_email_settings_menu_callback' ) |
| 20 |
); |
| 21 |
add_submenu_page( |
| 22 |
'wpcargo-settings', |
| 23 |
wpcargo_admin_email_settings_label(), |
| 24 |
wpcargo_admin_email_settings_label(), |
| 25 |
'manage_options', |
| 26 |
'wpcargo-admin-email-settings', |
| 27 |
array( $this, 'admin_email_settings_menu_callback' ) |
| 28 |
); |
| 29 |
} |
| 30 |
public function admin_email_settings_menu_callback(){ |
| 31 |
global $wpcargo; |
| 32 |
$wpcargo_admin_mail_active = get_option('wpcargo_admin_mail_active'); |
| 33 |
$wpcargo_admin_mail_status = $wpcargo->admin_mail_status; |
| 34 |
$wpcargo_admin_mail_domain = get_option('wpcargo_admin_mail_domain'); |
| 35 |
$wpcargo_admin_mail_to = get_option('wpcargo_admin_mail_to'); |
| 36 |
$wpcargo_admin_mail_subject = get_option('wpcargo_admin_mail_subject'); |
| 37 |
$wpcargo_admin_mail_body = get_option('wpcargo_admin_mail_body'); |
| 38 |
$wpcargo_admin_mail_footer = get_option('wpcargo_admin_mail_footer'); |
| 39 |
$mail_status = $wpcargo->mail_status; |
| 40 |
$email_meta_tags = wpcargo_email_shortcodes_list(); |
| 41 |
$wpcargo_admin_mail_body = !empty( $wpcargo_admin_mail_body ) ? $wpcargo_admin_mail_body : '<p>Dear Admin,</p> |
| 42 |
<p>Shipment number {'.wpcargo_track_meta().'} has been updated to {status}.</p> |
| 43 |
<br /> |
| 44 |
<p>Yours sincerely</p> |
| 45 |
<p><a href="{site_url}">{site_name}</a></p>'; |
| 46 |
$wpcargo_admin_mail_footer = !empty( $wpcargo_admin_mail_footer ) ? $wpcargo_admin_mail_footer : '<div class="wpc-contact-info" style="margin-top: 10px;"> |
| 47 |
<p>Your Address Here...</p> |
| 48 |
<p>Email: <a href="mailto:{admin_email}">{admin_email}</a> - Web: <a href="{site_url}">{site_name}</a></p> |
| 49 |
<p>Phone: <a href="tel:">Your Phone Number Here</a>, <a href="tel:">Your Phone Number Here</a></p> |
| 50 |
</div> |
| 51 |
<div class="wpc-contact-bottom" style="margin-top: 20px; padding: 5px; border-top: 1px solid #000;"> |
| 52 |
<p>This message is intended solely for the use of the individual or organisation to whom it is addressed. It may contain privileged or confidential information. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you should not use, copy, alter or disclose the contents of this message. All information or opinions expressed in this message and/or any attachments are those of the author and are not necessarily those of {site_name} or its affiliates. {site_name} accepts no responsibility for loss or damage arising from its use, including damage from virus.</p> |
| 53 |
</div>'; |
| 54 |
?> |
| 55 |
<div class="wrap"> |
| 56 |
<h1><?php echo esc_html(wpcargo_admin_email_settings_label()); ?></h1> |
| 57 |
<style type="text/css"> |
| 58 |
table#email_meta_tags{ |
| 59 |
width: 100%; |
| 60 |
} |
| 61 |
table#email_meta_tags, table#email_meta_tags tr td,table#email_meta_tags tr th{ |
| 62 |
border:1px solid #000; |
| 63 |
border-collapse: collapse; |
| 64 |
} |
| 65 |
</style> |
| 66 |
<?php |
| 67 |
require_once( WPCARGO_PLUGIN_PATH.'admin/templates/admin-navigation.tpl.php' ); |
| 68 |
require_once( WPCARGO_PLUGIN_PATH.'admin/templates/admin-email-settings-option.tpl.php' ); |
| 69 |
?> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
} |
| 73 |
public function client_email_settings_menu_callback(){ |
| 74 |
global $wpcargo; |
| 75 |
$options = get_option('wpcargo_mail_settings'); |
| 76 |
$page_options = get_option('wpcargo_email_page_settings'); |
| 77 |
$wpcargo_mail_admin = get_option('wpcargo_mail_admin'); |
| 78 |
$wpcargo_mail_domain = get_option('wpcargo_mail_domain'); |
| 79 |
$mail_status = $wpcargo->mail_status; |
| 80 |
$email_meta_tags = wpcargo_email_shortcodes_list(); |
| 81 |
$mail_message = !empty($options['wpcargo_mail_message']) ? $options['wpcargo_mail_message'] : '<p>Dear {shipper_name},</p> |
| 82 |
<p>We are pleased to inform you that your shipment has now cleared customs and is now {status}.</p> |
| 83 |
<br /> |
| 84 |
<h4 style="font-size: 25px; color: #00a924;">Tracking Information</h4> |
| 85 |
<p>Tracking Number - {'. esc_html( wpcargo_track_meta() ).'}</p> |
| 86 |
<p>Latest International Scan: Customs status updated</p> |
| 87 |
<p>We hope this meets with your approval. Please do not hesitate to get in touch if we can be of any further assistance.</p> |
| 88 |
<br /> |
| 89 |
<p>Yours sincerely</p> |
| 90 |
<p><a href="{site_url}">{site_name}</a></p>'; |
| 91 |
$mail_footer = !empty($options['wpcargo_mail_footer']) ? esc_html( $options['wpcargo_mail_footer'] ) : '<div class="wpc-contact-info" style="margin-top: 10px;"> |
| 92 |
<p>Your Address Here...</p> |
| 93 |
<p>Email: <a href="mailto:{admin_email}">{admin_email}</a> - Web: <a href="{site_url}">{site_name}</a></p> |
| 94 |
<p>Phone: <a href="tel:">Your Phone Number Here</a>, <a href="tel:">Your Phone Number Here</a></p> |
| 95 |
</div> |
| 96 |
<div class="wpc-contact-bottom" style="margin-top: 20px; padding: 5px; border-top: 1px solid #000;"> |
| 97 |
<p>This message is intended solely for the use of the individual or organisation to whom it is addressed. It may contain privileged or confidential information. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you should not use, copy, alter or disclose the contents of this message. All information or opinions expressed in this message and/or any attachments are those of the author and are not necessarily those of {site_name} or its affiliates. {site_name} accepts no responsibility for loss or damage arising from its use, including damage from virus.</p> |
| 98 |
</div>'; |
| 99 |
|
| 100 |
?> |
| 101 |
<div class="wrap"> |
| 102 |
<h1><?php echo esc_html(wpcargo_client_email_settings_label()); ?></h1> |
| 103 |
<style type="text/css"> |
| 104 |
table#email_meta_tags{ |
| 105 |
width: 100%; |
| 106 |
} |
| 107 |
table#email_meta_tags, table#email_meta_tags tr td,table#email_meta_tags tr th{ |
| 108 |
border:1px solid #000; |
| 109 |
border-collapse: collapse; |
| 110 |
} |
| 111 |
</style> |
| 112 |
<?php |
| 113 |
require_once( WPCARGO_PLUGIN_PATH.'admin/templates/admin-navigation.tpl.php' ); |
| 114 |
require_once( WPCARGO_PLUGIN_PATH.'admin/templates/email-settings-option.tpl.php' ); |
| 115 |
?> |
| 116 |
</div> |
| 117 |
<?php |
| 118 |
} |
| 119 |
function register_wpcargo_mail_settings() { |
| 120 |
//Register Client Email Settings |
| 121 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_mail_settings' ); |
| 122 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_mail_domain' ); |
| 123 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_mail_admin' ); |
| 124 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_mail_status' ); |
| 125 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_email_page_settings' ); |
| 126 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_email_cc' ); |
| 127 |
register_setting( 'wpcargo_mail_settings', 'wpcargo_email_bcc' ); |
| 128 |
//Register Admin Email Settings |
| 129 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_active' ); |
| 130 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_status' ); |
| 131 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_domain' ); |
| 132 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_to' ); |
| 133 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_subject' ); |
| 134 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_body' ); |
| 135 |
register_setting( 'wpcargo_admin_mail_settings', 'wpcargo_admin_mail_footer' ); |
| 136 |
} |
| 137 |
} |
| 138 |
new WPCargo_Email_Settings; |