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:
<?php
if ( !class_exists( 'Inbound_Automation_Action_Wait' ) ) {
class Inbound_Automation_Action_Wait {
function __construct() {
add_filter( 'inbound_automation_actions' , array( __CLASS__ , 'define_filter' ) , 1 , 1);
}
public static function define_filter( $actions ) {
$actions['wait'] = array (
'class_name' => get_class(),
'id' => 'wait',
'label' => 'Wait',
'description' => __('Wait an amount of time before firing the next event.','inbound-pro'),
'settings' => array (
array (
'id' => 'wait_time_hours',
'label' => 'Wait Time Hours:',
'description' => __('Here you can set wait time in hours.','inbound-pro'),
'type' => 'text',
'default' => '72',
),
array (
'id' => 'wait_time_minutes',
'label' => 'Wait Time Minutes:',
'description' => __('Here you can set wait time in minute.','inbound-pro'),
'type' => 'text',
'default' => '0',
)
)
);
return $actions;
}
public static function run_action( $action , $arguments ) {
$current_time = current_time('Y-m-d H:i:s');
$currentDate = strtotime($current_time);
$futureDate = $currentDate + ( 60 * $action['wait_time_minutes'] );
$futureDate = $futureDate + ( 60 * 60 * $action['wait_time_hours'] );
$action['run_date'] = date("Y-m-d H:i:s", $futureDate);
inbound_record_log(
__( 'Wait' , 'inbound-pro') ,
__( 'Scheduling Next Action to Run at:' , 'inbound-pro' ) . $action['run_date'] .
'<h2>'.__( 'Action Settings' , 'inbound-pro' ) .'</h2> <pre>' . print_r( $action , true ).'</pre>' , $action['rule_id'] , $action['job_id'] , 'action_event'
);
return $action;
}
}
new Inbound_Automation_Action_Wait();
}