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:
<?php
class Inbound_Automation_Trigger_inbound_double_optin_confirm {
static $trigger;
function __construct() {
self::$trigger = 'inbound_double_optin_confirm';
add_filter( 'inbound_automation_triggers' , array( __CLASS__ , 'define_trigger' ) , 1 , 1);
add_action( 'activate/automation' , array( __CLASS__ , 'create_dummy_event' ) );
}
public static function define_trigger( $triggers ) {
$arguments = apply_filters('trigger/'.self::$trigger.'/args' , array(
'lead_data' => array(
'id' => 'lead_data',
'label' => __( 'Lead Data' , 'inbound-pro' ),
'callback' => array(
get_class() , 'enrich_lead_data'
)
)
) );
$db_lookup_filters = apply_filters( 'trigger/'.self::$trigger.'/db_filters' , array (
array(
'id' => 'lead_data',
'label' => __( 'Query Lead Data' , 'inbound-pro' ),
'class_name' => 'Inbound_Automation_Query_Lead'
)
));
$actions = apply_filters('trigger/'.self::$trigger.'/actions' , array(
'send_email' ,
'wait' ,
'relay_data' ,
'add_remove_lead_list',
'add_remove_lead_tag',
'kill_lead_tasks',
) );
$triggers[self::$trigger] = array (
'label' => __( 'On double-optin confirmation' , 'inbound-pro' ),
'description' => __( 'This trigger fires whenever a lead confirms their email address using our double optin feature' , 'inbound-pro' ),
'action_hook' => self::$trigger,
'arguments' => $arguments,
'db_lookup_filters' => $db_lookup_filters,
'actions' => $actions
);
return $triggers;
}
public static function enrich_lead_data( $args ) {
$new_args = array();
$args['wp_lead_status'] = isset($args['wp_lead_status']) ? $args['wp_lead_status'] : '';
$args['wpleads_raw_post_data'] = '';
foreach ($args as $arg_key => $arg_value) {
if (is_array($arg_value) || is_numeric($arg_key)) {
$arg_value = json_encode($arg_value);
}
$new_args[$arg_key] = $arg_value;
}
return $new_args;
}
public static function create_dummy_event() {
$lead = array (
'lead_id' => 47,
'list_ids' => array(
'0'=>208,
'1'=>210
),
'email_id' => 'test@inboundnow.com',
'variation_id' => '0',
'wp_lead_status' => '',
'wpleads_inbound_form_lists' => '208,210',
'wpleads_ip_address' => '127.0.0.1'
);
$inbound_arguments = Inbound_Options_API::get_option( 'inbound_automation' , 'arguments' );
$inbound_arguments = ( is_array($inbound_arguments) ) ? $inbound_arguments : array();
$inbound_arguments[self::$trigger]['lead_data'] = $lead;
Inbound_Options_API::update_option( 'inbound_automation' , 'arguments' , $inbound_arguments );
}
public static function is_json($string) {
$array = array('{','[');
foreach ($array as $v) {
if (substr($string, 0, 1) === $v) {
return true;
}
}
return false;
}
}
new Inbound_Automation_Trigger_inbound_double_optin_confirm;