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:
<?php
if ( !class_exists( 'Inbound_Automation_Trigger_Update_Lead' ) ) {
class Inbound_Automation_Trigger_Update_Lead {
static $trigger;
function __construct() {
self::$trigger = 'wplead_page_view';
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('inbound_automation_trigger_arguments-track-lead' , array(
'lead_data' => array(
'id' => 'lead_data',
'label' => 'Lead Data'
)
) );
$db_lookup_filters = apply_filters( 'inbound_automation_db_lookup_filters-update-lead' , array (
array(
'id' => 'lead_data',
'label' => __( 'Validate Lead Data', 'inbound-pro' ),
'class_name' => 'Inbound_Automation_Query_Lead'
)
));
$actions = apply_filters('inbound_automation_trigger_actions-update-lead' , array(
'send_email' , 'wait' , 'relay_data' , 'add_remove_lead_list', 'add_remove_lead_tag'
) );
$triggers[ self::$trigger ] = array (
'label' => 'On Lead Tracking Event',
'description' => 'This trigger fires whenever a tracked lead visits a new page.',
'action_hook' => self::$trigger ,
'arguments' => $arguments,
'db_lookup_filters' => $db_lookup_filters,
'actions' => $actions
);
return $triggers;
}
public static function create_dummy_event() {
$lead = array (
'lead_id' => 97351,
'nature' => 'non-conversion',
'json' => 0,
'wp_lead_uid' => 'mxb8EHq5H71LtVmOTyXINufHKwA3EaUxTpH',
'page_id' => 97188,
'current_url' => 'http://inboundsoon.dev/go/flat-ui/'
);
$inbound_arguments = Inbound_Options_API::get_option( 'inbound_automation' , 'arguments' );
$inbound_arguments = ( $inbound_arguments ) ? $inbound_arguments : array();
$inbound_arguments[self::$trigger]['lead_data'] = $lead;
Inbound_Options_API::update_option( 'inbound_automation' , 'arguments' , $inbound_arguments );
}
}
new Inbound_Automation_Trigger_Update_Lead;
}