| 1 |
<?php |
| 2 |
/** |
| 3 |
* PropertyHive Email Settings |
| 4 |
* |
| 5 |
* @author PropertyHive |
| 6 |
* @category Admin |
| 7 |
* @package PropertyHive/Admin |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! class_exists( 'PH_Settings_Emails' ) ) : |
| 16 |
|
| 17 |
/** |
| 18 |
* PH_Settings_Emails. |
| 19 |
*/ |
| 20 |
class PH_Settings_Emails extends PH_Settings_Page { |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
$this->id = 'email'; |
| 27 |
$this->label = __( 'Emails', 'propertyhive' ); |
| 28 |
|
| 29 |
add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
| 30 |
add_action( 'propertyhive_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 31 |
add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) ); |
| 32 |
add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) ); |
| 33 |
|
| 34 |
add_action( 'propertyhive_admin_field_email_queue', array( $this, 'email_queue_setting' ) ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Get sections. |
| 39 |
* |
| 40 |
* @return array |
| 41 |
*/ |
| 42 |
public function get_sections() { |
| 43 |
$sections = array( |
| 44 |
'' => __( 'Email Options', 'propertyhive' ), |
| 45 |
); |
| 46 |
|
| 47 |
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' ) |
| 48 |
{ |
| 49 |
$sections['log'] = __( 'Email Queue', 'propertyhive' ); |
| 50 |
} |
| 51 |
|
| 52 |
return apply_filters( 'propertyhive_get_sections_' . $this->id, $sections ); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get settings array. |
| 57 |
* |
| 58 |
* @return array |
| 59 |
*/ |
| 60 |
public function get_settings() { |
| 61 |
$settings = array( |
| 62 |
|
| 63 |
array( 'title' => __( 'Email Sender Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'email_sender_options' ), |
| 64 |
|
| 65 |
array( |
| 66 |
'title' => __( '"From" Email Address', 'propertyhive' ), |
| 67 |
'id' => 'propertyhive_email_from_address', |
| 68 |
'type' => 'text', |
| 69 |
'css' => 'min-width:300px;', |
| 70 |
'default' => get_option('admin_email'), |
| 71 |
'autoload' => false, |
| 72 |
'desc_tip' => false, |
| 73 |
), |
| 74 |
|
| 75 |
array( 'type' => 'sectionend', 'id' => 'email_sender_options' ), |
| 76 |
|
| 77 |
array( 'title' => __( 'Email Template Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'email_template_options' ), |
| 78 |
|
| 79 |
array( |
| 80 |
'title' => __( 'Header Image URL', 'propertyhive' ), |
| 81 |
'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'propertyhive' ), |
| 82 |
'id' => 'propertyhive_email_header_image', |
| 83 |
'type' => 'text', |
| 84 |
'css' => 'min-width:300px;', |
| 85 |
'placeholder' => 'http://', |
| 86 |
'default' => '', |
| 87 |
'autoload' => false, |
| 88 |
'desc_tip' => true, |
| 89 |
), |
| 90 |
|
| 91 |
array( |
| 92 |
'title' => __( 'Email Background Colour', 'propertyhive' ), |
| 93 |
'desc' => __( 'The background colour for Property Hive email templates.', 'propertyhive' ), |
| 94 |
'id' => 'propertyhive_email_background_color', |
| 95 |
'type' => 'color', |
| 96 |
'css' => 'width:6em;', |
| 97 |
'default' => '#f7f7f7', |
| 98 |
'autoload' => false, |
| 99 |
'desc_tip' => true, |
| 100 |
), |
| 101 |
|
| 102 |
array( |
| 103 |
'title' => __( 'Body Background Colour', 'propertyhive' ), |
| 104 |
'desc' => __( 'The main body background colour.', 'propertyhive' ), |
| 105 |
'id' => 'propertyhive_email_body_background_color', |
| 106 |
'type' => 'color', |
| 107 |
'css' => 'width:6em;', |
| 108 |
'default' => '#ffffff', |
| 109 |
'autoload' => false, |
| 110 |
'desc_tip' => true, |
| 111 |
), |
| 112 |
|
| 113 |
array( |
| 114 |
'title' => __( 'Body Text Colour', 'propertyhive' ), |
| 115 |
'desc' => __( 'The main body text colour.', 'propertyhive' ), |
| 116 |
'id' => 'propertyhive_email_text_color', |
| 117 |
'type' => 'color', |
| 118 |
'css' => 'width:6em;', |
| 119 |
'default' => '#333333', |
| 120 |
'autoload' => false, |
| 121 |
'desc_tip' => true, |
| 122 |
), |
| 123 |
|
| 124 |
array( 'type' => 'sectionend', 'id' => 'email_template_options' ), |
| 125 |
|
| 126 |
array( 'title' => __( 'Enquiry Auto Responder Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'enquiry_auto_responder_email_options' ), |
| 127 |
|
| 128 |
array( |
| 129 |
'title' => __( 'Auto Responder Enabled', 'propertyhive' ), |
| 130 |
'id' => 'propertyhive_enquiry_auto_responder', |
| 131 |
'type' => 'checkbox', |
| 132 |
'default' => '', |
| 133 |
), |
| 134 |
|
| 135 |
array( |
| 136 |
'title' => __( 'Auto Responder Email Subject', 'propertyhive' ), |
| 137 |
'id' => 'propertyhive_enquiry_auto_responder_email_subject', |
| 138 |
'type' => 'text', |
| 139 |
'css' => 'min-width:300px;', |
| 140 |
), |
| 141 |
|
| 142 |
array( |
| 143 |
'title' => __( 'Auto Responder Email Body', 'propertyhive' ), |
| 144 |
'id' => 'propertyhive_enquiry_auto_responder_email_body', |
| 145 |
'type' => 'textarea', |
| 146 |
'css' => 'min-width:300px; height:110px;', |
| 147 |
), |
| 148 |
|
| 149 |
array( 'type' => 'sectionend', 'id' => 'enquiry_auto_responder_email_options' ) |
| 150 |
|
| 151 |
); |
| 152 |
|
| 153 |
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' ) |
| 154 |
{ |
| 155 |
$settings[] = array( 'title' => __( 'Property Match Email Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'applicant_match_email_options' ); |
| 156 |
|
| 157 |
$settings[] = array( |
| 158 |
'title' => __( 'Default Email Subject', 'propertyhive' ), |
| 159 |
'id' => 'propertyhive_property_match_default_email_subject', |
| 160 |
'type' => 'text', |
| 161 |
'css' => 'min-width:300px;', |
| 162 |
); |
| 163 |
|
| 164 |
$settings[] = array( |
| 165 |
'title' => __( 'Default Email Body', 'propertyhive' ), |
| 166 |
'id' => 'propertyhive_property_match_default_email_body', |
| 167 |
'type' => 'textarea', |
| 168 |
'css' => 'min-width:300px; height:110px;', |
| 169 |
); |
| 170 |
|
| 171 |
$options = array(); |
| 172 |
$args = array( |
| 173 |
'hide_empty' => false, |
| 174 |
'parent' => 0 |
| 175 |
); |
| 176 |
$terms = get_terms( 'availability', $args ); |
| 177 |
|
| 178 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 179 |
{ |
| 180 |
foreach ($terms as $term) |
| 181 |
{ |
| 182 |
$options[$term->term_id] = $term->name; |
| 183 |
} |
| 184 |
} |
| 185 |
$settings[] = array( |
| 186 |
'title' => __( 'Only Include Properties With Statuses', 'propertyhive' ), |
| 187 |
'id' => 'propertyhive_property_match_statuses', |
| 188 |
'type' => 'multiselect', |
| 189 |
'css' => 'min-width:300px; height:110px;', |
| 190 |
'options' => $options, |
| 191 |
'desc' => '<p>' . __( 'By default, all on market properties will come back in matches when sending properties to applicants. If you wish to only send properties with a certain status you can choose this here. For example, maybe you don\'t want Sold STC properties to be sent. Hold ctrl/cmd whilst clicking to select multiple.', 'propertyhive' ) . '</p>', |
| 192 |
); |
| 193 |
|
| 194 |
$settings[] = array( |
| 195 |
'title' => __( 'Automatically Send Matching Properties To Applicants', 'propertyhive' ), |
| 196 |
'desc' => __( 'Enabling this setting will mean applicants will automatically get sent emailed properties as they\'re added.<br><br> |
| 197 |
- This will only apply to properties added from the moment this option is activated.<br> |
| 198 |
- When enabled, this can disabled on a per-applicant basis by going into their record<br> |
| 199 |
- When sending out lots of emails we recommend using <a href="https://en-gb.wordpress.org/plugins/tags/smtp" target="_blank">a plugin</a> to send them out using SMTP. Your web developer or hosting company should be able to advise on this.', 'propertyhive' ), |
| 200 |
'id' => 'propertyhive_auto_property_match', |
| 201 |
'type' => 'checkbox', |
| 202 |
'default' => '', |
| 203 |
); |
| 204 |
|
| 205 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'applicant_match_email_options' ); |
| 206 |
} |
| 207 |
|
| 208 |
if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' ) |
| 209 |
{ |
| 210 |
//Applicant |
| 211 |
$settings[] = array( 'title' => __( 'Applicant Viewing Booking Confirmations', 'propertyhive' ), 'type' => 'title', 'id' => 'applicant_viewing_booking_confirmation_email_options' ); |
| 212 |
|
| 213 |
$settings[] = array( |
| 214 |
'title' => __( 'Default Email Subject', 'propertyhive' ), |
| 215 |
'id' => 'propertyhive_viewing_applicant_booking_confirmation_email_subject', |
| 216 |
'type' => 'text', |
| 217 |
'css' => 'min-width:300px;', |
| 218 |
); |
| 219 |
|
| 220 |
$settings[] = array( |
| 221 |
'title' => __( 'Default Email Body', 'propertyhive' ), |
| 222 |
'id' => 'propertyhive_viewing_applicant_booking_confirmation_email_body', |
| 223 |
'type' => 'textarea', |
| 224 |
'css' => 'min-width:300px; height:110px;', |
| 225 |
); |
| 226 |
|
| 227 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'viewing_booking_confirmation_email_options' ); |
| 228 |
|
| 229 |
// Owner |
| 230 |
$settings[] = array( 'title' => __( 'Owner/Landlord Booking Confirmations', 'propertyhive' ), 'type' => 'title', 'id' => 'applicant_viewing_booking_confirmation_email_options' ); |
| 231 |
|
| 232 |
$settings[] = array( |
| 233 |
'title' => __( 'Default Email Subject', 'propertyhive' ), |
| 234 |
'id' => 'propertyhive_viewing_owner_booking_confirmation_email_subject', |
| 235 |
'type' => 'text', |
| 236 |
'css' => 'min-width:300px;', |
| 237 |
); |
| 238 |
|
| 239 |
$settings[] = array( |
| 240 |
'title' => __( 'Default Email Body', 'propertyhive' ), |
| 241 |
'id' => 'propertyhive_viewing_owner_booking_confirmation_email_body', |
| 242 |
'type' => 'textarea', |
| 243 |
'css' => 'min-width:300px; height:110px;', |
| 244 |
); |
| 245 |
|
| 246 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'viewing_booking_confirmation_email_options' ); |
| 247 |
} |
| 248 |
|
| 249 |
$settings = apply_filters( 'propertyhive_email_settings', $settings ); |
| 250 |
|
| 251 |
return apply_filters( 'propertyhive_get_settings_' . $this->id, $settings ); |
| 252 |
} |
| 253 |
|
| 254 |
/** |
| 255 |
* Get email queue settings array |
| 256 |
* |
| 257 |
* @return array |
| 258 |
*/ |
| 259 |
public function get_email_queue_settings() { |
| 260 |
|
| 261 |
return apply_filters( 'propertyhive_email_queue_settings', array( |
| 262 |
|
| 263 |
array( 'title' => __( 'Email Queue', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'email_queue_options' ), |
| 264 |
|
| 265 |
array( |
| 266 |
'type' => 'email_queue' |
| 267 |
), |
| 268 |
|
| 269 |
array( 'type' => 'sectionend', 'id' => 'email_queue_options'), |
| 270 |
|
| 271 |
) ); // End general map settings |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* Output email queue |
| 276 |
* |
| 277 |
* @access public |
| 278 |
* @return void |
| 279 |
*/ |
| 280 |
public function email_queue_setting() |
| 281 |
{ |
| 282 |
global $wpdb, $post; |
| 283 |
|
| 284 |
$additional_query = ''; |
| 285 |
$additional_query_string = ''; |
| 286 |
if ( isset($_GET['date_from']) && sanitize_text_field($_GET['date_from']) != '' ) |
| 287 |
{ |
| 288 |
$additional_query_string .= '&date_from=' . sanitize_text_field($_GET['date_from']); |
| 289 |
if ( sanitize_text_field($_GET['date_from']) != 'all' ) |
| 290 |
{ |
| 291 |
$additional_query .= " AND send_at >= '" . sanitize_text_field($_GET['date_from']) . " 00:00:00' "; |
| 292 |
} |
| 293 |
} |
| 294 |
else |
| 295 |
{ |
| 296 |
// Default to 30 days |
| 297 |
$additional_query .= " AND send_at >= '" . date("Y-m-d", strtotime('-30 days')) . " 00:00:00' "; |
| 298 |
} |
| 299 |
?> |
| 300 |
<tr valign="top"> |
| 301 |
<td style="padding:0"> |
| 302 |
|
| 303 |
<p>Some processes, such as property matching, can result in a lot of emails being sent at once. To cater for this we queue emails and send them out in batches at regular intervals.</p> |
| 304 |
|
| 305 |
<p>Using this screen you can see which emails have been sent, which have failed, and how many are queued to be sent.</p> |
| 306 |
|
| 307 |
<br> |
| 308 |
|
| 309 |
<p><strong><?php |
| 310 |
$next_due = wp_next_scheduled( 'propertyhive_process_email_log' ); |
| 311 |
|
| 312 |
if ( $next_due == FALSE ) |
| 313 |
{ |
| 314 |
echo 'Whoops. WordPress doesn\'t have the emails automated task scheduled. A quick fix for this is to deactivate, then re-activate the plugin.'; |
| 315 |
} |
| 316 |
else |
| 317 |
{ |
| 318 |
echo __( 'Next scheduled to run at', 'propertyhive' ) . ' ' . date("H:i jS F Y", $next_due); |
| 319 |
} |
| 320 |
?></strong> <a href="<?php echo admin_url('admin.php?page=ph-settings&tab=email§ion=log&custom_email_log_cron=propertyhive_process_email_log' ); ?>" class="button">Run Now</a></p> |
| 321 |
|
| 322 |
<br> |
| 323 |
|
| 324 |
<ul class="subsubsub"> |
| 325 |
<?php |
| 326 |
$emails = $wpdb->get_var(" |
| 327 |
SELECT COUNT(*) |
| 328 |
FROM " . $wpdb->prefix . "ph_email_log |
| 329 |
"); |
| 330 |
?> |
| 331 |
<li class="all"><a href="<?php echo admin_url('admin.php?page=ph-settings&tab=email§ion=log' . $additional_query_string); ?>"<?php if ( !isset($_GET['status']) || (isset($_GET['status']) && $_GET['status'] == '') ) { echo ' class="current"'; } ?>>All <span class="count">(<?php echo number_format($emails); ?>)</span></a> |</li> |
| 332 |
<?php |
| 333 |
$emails = $wpdb->get_var(" |
| 334 |
SELECT COUNT(*) |
| 335 |
FROM " . $wpdb->prefix . "ph_email_log |
| 336 |
WHERE |
| 337 |
status = '' |
| 338 |
"); |
| 339 |
?> |
| 340 |
<li class="queued"><a href="<?php echo admin_url('admin.php?page=ph-settings&tab=email§ion=log&status=queued' . $additional_query_string); ?>"<?php if ( isset($_GET['status']) && $_GET['status'] == 'queued' ) { echo ' class="current"'; } ?>>Queued <span class="count">(<?php echo number_format($emails); ?>)</span></a> |</li> |
| 341 |
<?php |
| 342 |
$emails = $wpdb->get_var(" |
| 343 |
SELECT COUNT(*) |
| 344 |
FROM " . $wpdb->prefix . "ph_email_log |
| 345 |
WHERE |
| 346 |
status IN ('fail1', 'fail2') |
| 347 |
"); |
| 348 |
?> |
| 349 |
<li class="failed"><a href="<?php echo admin_url('admin.php?page=ph-settings&tab=email§ion=log&status=failed' . $additional_query_string); ?>"<?php if ( isset($_GET['status']) && $_GET['status'] == 'failed' ) { echo ' class="current"'; } ?>>Failed <span class="count">(<?php echo number_format($emails); ?>)</span></a> |</li> |
| 350 |
<?php |
| 351 |
$emails = $wpdb->get_var(" |
| 352 |
SELECT COUNT(*) |
| 353 |
FROM " . $wpdb->prefix . "ph_email_log |
| 354 |
WHERE |
| 355 |
status = 'sent' |
| 356 |
"); |
| 357 |
?> |
| 358 |
<li class="sent"><a href="<?php echo admin_url('admin.php?page=ph-settings&tab=email§ion=log&status=sent' . $additional_query_string); ?>"<?php if ( isset($_GET['status']) && $_GET['status'] == 'sent' ) { echo ' class="current"'; } ?>>Sent <span class="count">(<?php echo number_format($emails); ?>)</span></a></li> |
| 359 |
</ul> |
| 360 |
|
| 361 |
<div class="tablenav top"> |
| 362 |
<div class="alignleft actions bulkactions"> |
| 363 |
<div class="alignleft actions"> |
| 364 |
<input type="hidden" name="page" value="ph-settings"> |
| 365 |
<input type="hidden" name="tab" value="email"> |
| 366 |
<input type="hidden" name="section" value="log"> |
| 367 |
<input type="hidden" name="status" value="<?php echo ( ( isset($_GET['status']) ) ? $_GET['status'] : '' ); ?>"> |
| 368 |
<select name="date_from" id="dropdown_date_from"> |
| 369 |
<option value="<?php echo date("Y-m-d", strtotime("-7 days")); ?>"<?php if ( isset($_GET['date_from']) && $_GET['date_from'] == date("Y-m-d", strtotime("-7 days")) ) { echo ' selected'; } ?>>Last 7 Days</option> |
| 370 |
<option value="<?php echo date("Y-m-d", strtotime("-14 days")); ?>"<?php if ( isset($_GET['date_from']) && $_GET['date_from'] == date("Y-m-d", strtotime("-14 days")) ) { echo ' selected'; } ?>>Last 14 Days</option> |
| 371 |
<option value="<?php echo date("Y-m-d", strtotime("-30 days")); ?>"<?php if ( !isset($_GET['date_from']) || ( isset($_GET['date_from']) && $_GET['date_from'] == date("Y-m-d", strtotime("-30 days")) ) ) { echo ' selected'; } ?>>Last 30 Days</option> |
| 372 |
<option value="all"<?php if ( isset($_GET['date_from']) && $_GET['date_from'] == 'all' ) { echo ' selected'; } ?>>All Time</option> |
| 373 |
</select> |
| 374 |
<input type="submit" name="filter_action" id="post-query-submit" class="button" value="Filter"> |
| 375 |
|
| 376 |
<script> |
| 377 |
jQuery(document).ready(function() |
| 378 |
{ |
| 379 |
jQuery('#_wpnonce').remove(); |
| 380 |
jQuery('input[name=\'_wp_http_referer\']').remove(); |
| 381 |
jQuery('#mainform').attr('method', 'get'); |
| 382 |
jQuery('#mainform').attr('action', '<?php echo admin_url('admin.php'); ?>'); |
| 383 |
}); |
| 384 |
</script> |
| 385 |
</div> |
| 386 |
</div> |
| 387 |
</div> |
| 388 |
|
| 389 |
<table class="ph_email_queue widefat" cellspacing="0"> |
| 390 |
<thead> |
| 391 |
<tr> |
| 392 |
<th class="date-time"><?php _e( 'Date/Time', 'propertyhive' ); ?></th> |
| 393 |
<th class="recipient"><?php _e( 'Recipient', 'propertyhive' ); ?></th> |
| 394 |
<th class="subject"><?php _e( 'Subject', 'propertyhive' ); ?></th> |
| 395 |
<th class="status"><?php _e( 'Status', 'propertyhive' ); ?></th> |
| 396 |
<th class="actions"> </th> |
| 397 |
</tr> |
| 398 |
</thead> |
| 399 |
<tbody> |
| 400 |
<?php |
| 401 |
$query = " |
| 402 |
SELECT |
| 403 |
email_id, |
| 404 |
contact_id, |
| 405 |
to_email_address, |
| 406 |
subject, |
| 407 |
status, |
| 408 |
send_at |
| 409 |
FROM " . $wpdb->prefix . "ph_email_log |
| 410 |
WHERE |
| 411 |
1=1 "; |
| 412 |
if ( isset($_GET['status']) ) |
| 413 |
{ |
| 414 |
switch ( $_GET['status'] ) |
| 415 |
{ |
| 416 |
case "queued": { $query .= " AND status = '' "; break; } |
| 417 |
case "failed": { $query .= " AND status IN ('fail1', 'fail2') "; break; } |
| 418 |
case "sent": { $query .= " AND status = 'sent' "; break; } |
| 419 |
} |
| 420 |
} |
| 421 |
$query .= $additional_query; |
| 422 |
|
| 423 |
$query .= " ORDER BY send_at DESC |
| 424 |
LIMIT 250 |
| 425 |
"; |
| 426 |
$emails = $wpdb->get_results( $query ); |
| 427 |
|
| 428 |
if ( is_array($emails) && !empty($emails) ) |
| 429 |
{ |
| 430 |
foreach ( $emails as $email ) |
| 431 |
{ |
| 432 |
?> |
| 433 |
<tr> |
| 434 |
<td class="date-time"><?php echo date("jS M Y H:i", strtotime($email->send_at)); ?></td> |
| 435 |
<td class="recipient"><?php echo '<a href="' . get_edit_post_link($email->contact_id) . '">' . get_the_title($email->contact_id) . '</a><br>' . $email->to_email_address; ?></td> |
| 436 |
<td class="subject"><?php echo $email->subject; ?></td> |
| 437 |
<td class="status"><?php |
| 438 |
switch ($email->status) |
| 439 |
{ |
| 440 |
case "fail1": { echo 'First attempt failed. Will retry'; break; } |
| 441 |
case "fail2": { echo 'Failed after 2 attempts'; break; } |
| 442 |
case "sent": { echo 'Sent'; break; } |
| 443 |
default: { echo 'Queued'; } |
| 444 |
} |
| 445 |
?></td> |
| 446 |
<td class="actions"> |
| 447 |
<a href="<?php echo wp_nonce_url( admin_url('?view_propertyhive_email=' . $email->email_id . '&email_id=' . $email->email_id ), 'view-email' ) ?>" target="_blank" class="button">View Email</a> |
| 448 |
</td> |
| 449 |
</tr> |
| 450 |
<?php |
| 451 |
} |
| 452 |
} |
| 453 |
else |
| 454 |
{ |
| 455 |
?> |
| 456 |
<tr> |
| 457 |
<td colspan="5">No emails found</td> |
| 458 |
</tr> |
| 459 |
<?php |
| 460 |
} |
| 461 |
?> |
| 462 |
</tbody> |
| 463 |
</table> |
| 464 |
</td> |
| 465 |
</tr> |
| 466 |
<?php |
| 467 |
} |
| 468 |
|
| 469 |
/** |
| 470 |
* Output the settings. |
| 471 |
*/ |
| 472 |
public function output() { |
| 473 |
global $current_section, $hide_save_button; |
| 474 |
|
| 475 |
if ( $current_section ) |
| 476 |
{ |
| 477 |
switch ($current_section) |
| 478 |
{ |
| 479 |
case "log": { $settings = $this->get_email_queue_settings(); $hide_save_button = true; break; } |
| 480 |
default: { die("Unknown setting section"); } |
| 481 |
} |
| 482 |
} |
| 483 |
else |
| 484 |
{ |
| 485 |
$settings = $this->get_settings(); |
| 486 |
} |
| 487 |
|
| 488 |
PH_Admin_Settings::output_fields( $settings ); |
| 489 |
} |
| 490 |
|
| 491 |
/** |
| 492 |
* Save settings. |
| 493 |
*/ |
| 494 |
public function save() { |
| 495 |
PH_Admin_Settings::save_fields( $this->get_settings() ); |
| 496 |
|
| 497 |
if ( isset($_POST['propertyhive_auto_property_match']) && $_POST['propertyhive_auto_property_match'] == '1' ) |
| 498 |
{ |
| 499 |
update_option( 'propertyhive_auto_property_match_enabled_date', date("Y-m-d H:i:s"), FALSE); |
| 500 |
|
| 501 |
wp_schedule_event( time(), 'hourly', 'propertyhive_auto_email_match' ); // Skew it by 30 minutes to reduce conflict with email log processing |
| 502 |
} |
| 503 |
else |
| 504 |
{ |
| 505 |
wp_clear_scheduled_hook( 'propertyhive_auto_email_match' ); |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
endif; |
| 511 |
|
| 512 |
return new PH_Settings_Emails(); |