Recurring.php
1.21 KB
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
<?php
namespace ACA\EC\Search\Event;
use AC;
use ACP\Search\Comparison;
use ACP\Search\Operators;
use ACP\Search\Query\Bindings;
use ACP\Search\Value;
class Recurring extends Comparison implements Comparison\Values {
public function __construct() {
$operators = new Operators( [
Operators::EQ,
] );
parent::__construct( $operators, Value::INT );
}
protected function create_query_bindings( $operator, Value $value ) {
global $wpdb;
$not_recur = 's:5:"rules";a:0:{}s:10:"exclusions";a:0:{}';
$bindings = new Bindings();
$alias = $bindings->get_unique_alias( 'ecrec' );
$bindings->join( " JOIN {$wpdb->postmeta} as {$alias} ON {$wpdb->posts}.ID = {$alias}.post_id AND {$alias}.meta_key = '_EventRecurrence'" );
$join_type = 'yes' === $value->get_value()
? 'NOT LIKE'
: 'LIKE';
$where = "{$alias}.meta_value {$join_type} '%$not_recur%'";
if ( 'yes' !== $value->get_value() ) {
$where .= " OR ${alias}.meta_value = ''";
}
$bindings->where( '(' . $where . ')' );
return $bindings;
}
public function get_values() {
return AC\Helper\Select\Options::create_from_array( [
-1 => __( 'True', 'codepress-admin-columns' ),
0 => __( 'False', 'codepress-admin-columns' ),
] );
}
}