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:
<?php
if ( !class_exists( 'Inbound_Automation_Trigger_Set_Object_Terms' ) ) {
class Inbound_Automation_Trigger_Set_Object_Terms {
static $trigger;
function __construct() {
self::$trigger = 'set_object_terms';
add_filter( 'inbound_automation_triggers' , array( __CLASS__ , 'define_trigger' ) , 1 , 1);
}
public static function define_trigger( $triggers ) {
$arguments = apply_filters('trigger/added_term_relationship/trigger_arguments/' , array(
'object_id' => array(
'id' => 'object_id',
'label' => __( 'Post ID' , 'inbound-pro')
),
'terms' => array(
'id' => 'terms',
'label' => __( 'Terms' , 'inbound-pro'),
),
'tt_ids' => array(
'id' => 'tt_ids',
'label' => __( 'Terms Taxonomy IDs' , 'inbound-pro'),
),
'taxonomy' => array(
'id' => 'taxonomy',
'label' => __( 'Taxonomy slug' , 'inbound-pro'),
),
'append' => array(
'id' => 'append',
'label' => __( 'Append modifier.' , 'inbound-pro'),
),
'old_tt_ids' => array(
'id' => 'old_tt_ids',
'label' => __( 'Old array of term taxonomy IDs.' , 'inbound-pro'),
)
) );
$db_lookup_filters = apply_filters( 'trigger/added_term_relationship/db_arguments' , array (
));
$actions = apply_filters('trigger/added_term_relationship/actions' , array(
'send_email' , 'wait' , 'relay_data'
) );
$triggers[ self::$trigger ] = array (
'label' => __('On tag or categorize event' , 'inbound-pro'),
'description' => __('This trigger fires whenever a tag or category is added to a post object.' , 'inbound-pro'),
'action_hook' => self::$trigger ,
'arguments' => $arguments,
'db_lookup_filters' => $db_lookup_filters,
'actions' => $actions
);
return $triggers;
}
public static function create_dummy_event() {
$event = array (
'user_id' => 1
);
$inbound_arguments = Inbound_Options_API::get_option( 'inbound_automation' , 'arguments' );
$inbound_arguments = ( $inbound_arguments ) ? $inbound_arguments : array();
$inbound_arguments[self::$trigger] = $event;
Inbound_Options_API::update_option( 'inbound_automation' , 'arguments' , $inbound_arguments );
}
public static function get_taxonomy_data( $ttid ) {
return get_term_by( 'term_taxonomy_id', $ttid, 'category', $output, $filter );
}
}
new Inbound_Automation_Trigger_Set_Object_Terms;
}