id = 'email';
$this->label = __( 'Emails', 'propertyhive' );
add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'propertyhive_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) );
add_action( 'propertyhive_admin_field_email_queue', array( $this, 'email_queue_setting' ) );
}
/**
* Get sections.
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __( 'Email Options', 'propertyhive' ),
);
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
{
$sections['log'] = __( 'Email Queue', 'propertyhive' );
}
return apply_filters( 'propertyhive_get_sections_' . $this->id, $sections );
}
/**
* Get settings array.
*
* @return array
*/
public function get_settings() {
$settings = array(
array( 'title' => __( 'Email Sender Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'email_sender_options' ),
array(
'title' => __( '"From" Email Address', 'propertyhive' ),
'id' => 'propertyhive_email_from_address',
'type' => 'text',
'css' => 'min-width:300px;',
'default' => get_option('admin_email'),
'autoload' => false,
'desc_tip' => false,
),
array( 'type' => 'sectionend', 'id' => 'email_sender_options' ),
array( 'title' => __( 'Email Template Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'email_template_options' ),
array(
'title' => __( 'Header Image URL', 'propertyhive' ),
'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'propertyhive' ),
'id' => 'propertyhive_email_header_image',
'type' => 'text',
'css' => 'min-width:300px;',
'placeholder' => 'http://',
'default' => '',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Email Background Colour', 'propertyhive' ),
'desc' => __( 'The background colour for Property Hive email templates.', 'propertyhive' ),
'id' => 'propertyhive_email_background_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#f7f7f7',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Body Background Colour', 'propertyhive' ),
'desc' => __( 'The main body background colour.', 'propertyhive' ),
'id' => 'propertyhive_email_body_background_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#ffffff',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Body Text Colour', 'propertyhive' ),
'desc' => __( 'The main body text colour.', 'propertyhive' ),
'id' => 'propertyhive_email_text_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#333333',
'autoload' => false,
'desc_tip' => true,
),
array( 'type' => 'sectionend', 'id' => 'email_template_options' ),
array( 'title' => __( 'Enquiry Auto Responder Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'enquiry_auto_responder_email_options' ),
array(
'title' => __( 'Auto Responder Enabled', 'propertyhive' ),
'id' => 'propertyhive_enquiry_auto_responder',
'type' => 'checkbox',
'default' => '',
),
array(
'title' => __( 'Auto Responder Email Subject', 'propertyhive' ),
'id' => 'propertyhive_enquiry_auto_responder_email_subject',
'type' => 'text',
'css' => 'min-width:300px;',
),
array(
'title' => __( 'Auto Responder Email Body', 'propertyhive' ),
'id' => 'propertyhive_enquiry_auto_responder_email_body',
'type' => 'textarea',
'css' => 'min-width:300px; height:110px;',
),
array( 'type' => 'sectionend', 'id' => 'enquiry_auto_responder_email_options' )
);
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
{
$settings[] = array( 'title' => __( 'Property Match Email Settings', 'propertyhive' ), 'type' => 'title', 'id' => 'applicant_match_email_options' );
$settings[] = array(
'title' => __( 'Default Email Subject', 'propertyhive' ),
'id' => 'propertyhive_property_match_default_email_subject',
'type' => 'text',
'css' => 'min-width:300px;',
);
$settings[] = array(
'title' => __( 'Default Email Body', 'propertyhive' ),
'id' => 'propertyhive_property_match_default_email_body',
'type' => 'textarea',
'css' => 'min-width:300px; height:110px;',
);
$settings[] = array(
'title' => __( 'Automatically Send Matching Properties To Applicants', 'propertyhive' ),
'desc' => __( 'Enabling this setting will mean applicants will automatically get sent emailed properties as they\'re added.
- This will only apply to properties added from the moment this option is activated.
- When enabled, this can disabled on a per-applicant basis by going into their record
- When sending out lots of emails we recommend using a plugin to send them out using SMTP. Your web developer or hosting company should be able to advise on this.', 'propertyhive' ),
'id' => 'propertyhive_auto_property_match',
'type' => 'checkbox',
'default' => '',
);
$settings[] = array( 'type' => 'sectionend', 'id' => 'applicant_match_email_options' );
}
$settings = apply_filters( 'propertyhive_email_settings', $settings );
return apply_filters( 'propertyhive_get_settings_' . $this->id, $settings );
}
/**
* Get email queue settings array
*
* @return array
*/
public function get_email_queue_settings() {
return apply_filters( 'propertyhive_email_queue_settings', array(
array( 'title' => __( 'Email Queue', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'email_queue_options' ),
array(
'type' => 'email_queue'
),
array( 'type' => 'sectionend', 'id' => 'email_queue_options'),
) ); // End general map settings
}
/**
* Output email queue
*
* @access public
* @return void
*/
public function email_queue_setting()
{
global $wpdb, $post;
$additional_query = '';
$additional_query_string = '';
if ( isset($_GET['date_from']) && $_GET['date_from'] != '' )
{
$additional_query_string .= '&date_from=' . $_GET['date_from'];
if ( $_GET['date_from'] != 'all' )
{
$additional_query .= " AND send_at >= '" . $_GET['date_from'] . " 00:00:00' ";
}
}
else
{
// Default to 7 days
$additional_query .= " AND send_at >= '" . date("Y-m-d", strtotime('-7 days')) . " 00:00:00' ";
}
?>
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.
Using this screen you can see which emails have been sent, which have failed, and how many are queued to be sent.
| send_at)); ?> | contact_id) . '">' . get_the_title($email->contact_id) . ' ' . $email->to_email_address; ?> |
subject; ?> | status) { case "fail1": { echo 'First attempt failed. Will retry'; break; } case "fail2": { echo 'Failed after 2 attempts'; break; } case "sent": { echo 'Sent'; break; } default: { echo 'Queued'; } } ?> | View Email |