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:
<?php
class Inbound_Mailer_Common_Settings {
private static $instance;
public $settings;
public static function instance()
{
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Inbound_Mailer_Common_Settings ) )
{
self::$instance = new Inbound_Mailer_Common_Settings;
self::$instance->add_common_settings();
self::$instance->load_settings();
}
return self::$instance;
}
function add_common_settings() {
self::add_addressing_settings();
self::add_batch_send_settings();
}
function add_addressing_settings(){
self::$instance->settings['email-settings']['subject'] = array(
'description' => __( 'Subject line of the email. This field is variation dependant!' , 'inbound-pro' ) ,
'label' => __( 'Subject Line' , 'inbound-pro' ),
'id' => 'subject',
'type' => 'text',
'default' => '',
'class' => '',
'disable_variants' => false
);
self::$instance->settings['email-settings']['from_name'] = array(
'label' => __( 'From Name' , 'inbound-pro' ),
'description' => __( 'The name of the sender. This field is variation dependant!' , 'inbound-pro' ) ,
'id' => 'from_name',
'type' => 'text',
'default' => '',
'class' => '',
'disable_variants' => false
);
self::$instance->settings['email-settings']['from_email'] = array(
'label' => __( 'From Email' , 'inbound-pro' ),
'description' => __( 'The email address of the sender. This field is variation dependant!' , 'inbound-pro' ) ,
'id' => 'from_email',
'type' => 'text',
'default' => '',
'class' => '',
'disable_variants' => false
);
self::$instance->settings['email-settings']['reply_email'] = array(
'label' => __( 'Reply Email' , 'inbound-pro' ),
'description' => __( 'The email address recipients can reply to. This field is variation dependant!' , 'inbound-pro' ) ,
'id' => 'reply_email',
'type' => 'text',
'default' => '',
'class' => '',
'disable_variants' => false
);
}
function add_batch_send_settings() {
$lead_lists = self::get_lead_lists_as_array();
self::$instance->settings['batch-send-settings']['recipients'] = array(
'id' => 'recipients',
'label' => __( 'Recipient Lists' , 'inbound-pro' ),
'description' => __( 'Add the lists you would like to target with this email.' , 'inbound-pro' ),
'type' => 'select2',
'default' => '',
'placeholder' => __( 'Select lists to send mail to.' , 'inbound-pro' ),
'options' => $lead_lists,
'disable_variants' => true
);
$tz = Inbound_Mailer_Scheduling::get_current_timezone();
self::$instance->settings['batch-send-settings']['send_datetime'] = array(
'id' => 'send_datetime',
'label' => __( 'Send Date/Time' , 'inbound-pro' ),
'description' => __( 'Select the date and time you would like this message to send.' , 'inbound-pro' ),
'type' => 'datepicker',
'default' => '',
'default_timezone_abbr' => $tz['abbr'] . '-UTC' . $tz['offset'] ,
'placeholder' => __( 'Select lists to send mail to.' , 'inbound-pro' ),
'options' => $lead_lists,
'disable_variants' => true
);
}
function load_settings() {
self::$instance->settings = apply_filters( 'inbound_email_common_settings' , self::$instance->settings );
}
public static function get_lead_lists_as_array() {
$array = array();
$args = array(
'hide_empty' => false,
);
$terms = get_terms('wplead_list_category', $args);
foreach ( $terms as $term ) {
$array[$term->term_id] = $term->name . " (".$term->count.")";
}
return $array;
}
}
function Inbound_Mailer_Common_Settings() {
return Inbound_Mailer_Common_Settings::instance();
}