'', 'time_two' => '', 'date_one' => '', 'date_two' => '', 'weekly_days' => [], )); } /** * Date related condition filters * * @since 1.0.0 * @return boolean */ public function filters($matched, $condition) { $operator = $condition['operator']; if ('date:weekly_days' === $condition['type']) { $weekly_days = isset($condition['weekly_days']) && is_array($condition['weekly_days']) ? $condition['weekly_days'] : array(); $current_day = strtolower(current_time('l')); if ('any_in_list' == $operator && in_array($current_day, $weekly_days)) { return true; } if ('not_in_list' == $operator && !in_array($current_day, $weekly_days)) { return true; } } if ('date:time' === $condition['type']) { $time_one = strtotime($condition['time_one']); if (false === $time_one) { return $matched; } if ('before' === $operator) { return current_time('timestamp') < $time_one; } if ('after' === $operator) { return current_time('timestamp') > $time_one; } if ('between' === $operator) { $time_two = strtotime($condition['time_two']); if (false === $time_two) { return $matched; } $current_time = current_time('timestamp'); return ($current_time >= $time_one && $current_time <= $time_two); } } if ('date:date' === $condition['type']) { $date_one = strtotime($condition['date_one']); if (false === $date_one) { return $matched; } if ('before' === $operator) { return current_time('timestamp') < $date_one; } if ('after' === $operator) { return current_time('timestamp') > $date_one; } if ('between' === $operator) { $date_two = strtotime($condition['date_two']); if (false === $date_two) { return $matched; } $current_time = current_time('timestamp'); return ($current_time >= $date_one && $current_time <= $date_two); } } return $matched; } /** * Add weekly days template of condition * * @since 1.0.3 * @return void */ public function time_template() { ?>