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:
<?php
class Inbound_Automation_Trigger_inbound_track_link {
static $trigger;
function __construct() {
self::$trigger = 'inbound_track_link';
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(
'link_data' => array(
'id' => 'link_data',
'label' => __( 'Clicked link data' , 'inbound-pro' ),
'callback' => array(
get_class() , 'enrich_data'
)
)
) );
$db_lookup_filters = apply_filters( 'trigger/'.self::$trigger.'/db_filters' , array (
array(
'id' => 'lead_data',
'label' => __( 'Lead lookup' , '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 tracked link click' , 'inbound-pro' ),
'description' => __( 'This trigger fires whenever a link tracked by Inbound Pro is clicked.' , 'inbound-pro' ),
'action_hook' => self::$trigger,
'arguments' => $arguments,
'db_lookup_filters' => $db_lookup_filters,
'actions' => $actions
);
return $triggers;
}
public static function enrich_data( $args ) {
$args['cta_id'] = isset($args['cta_id']) ? $args['cta_id'] : 0;
$args['page_id'] = isset($args['page_id']) ? $args['page_id'] : 0;
$args['vid'] = isset($args['vid']) ? $args['vid'] : 0;
$args['url'] = isset($args['url']) ? $args['url'] : '';
$args['lead_id'] = isset($args['lead_id']) ? $args['lead_id'] : 0;
$args['id'] = isset($args['id']) ? $args['id'] : 0;
$args['lead_id'] = ($args['lead_id']) ? $args['lead_id'] : $args['id'] ;
return $args;
}
public static function create_dummy_event() {
$lead = array (
'id' => 54321,
'lead_id' => 54321,
'email_id' => 321,
'page_id' => 123,
'cta_id' => 132,
'vid' => 0,
'url' => 'https://www.inboundnow.com/',
'tracking_id' => __('Special Tracking ID' , 'inbound-pro' )
);
$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 );
}
}
new Inbound_Automation_Trigger_inbound_track_link;