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
|
<?php // phpcs:ignoreFile
namespace AutomateWoo\Fields;
use AutomateWoo\Clean;
if ( ! defined( 'ABSPATH' ) ) exit;
/** * @class Workflow */ class Workflow extends Select {
protected $name = 'workflow';
/** @var array */ public $query_args = [];
/** * @param bool $show_placeholder */ function __construct( $show_placeholder = true ) { parent::__construct( $show_placeholder ); $this->set_title( __( 'Workflow', 'automatewoo' ) ); }
/** * @return array */ function get_options() {
$args = array_merge([ 'post_type' => 'aw_workflow', 'post_status' => 'any', 'posts_per_page' => -1 ], $this->query_args );
$workflows = new \WP_Query($args);
$options = [];
if ( $workflows->have_posts() ) { foreach( $workflows->posts as $workflow ) { $options[$workflow->ID] = $workflow->post_title; } }
return $options; }
/** * @param $key * @param $value * @return $this */ function add_query_arg( $key, $value ) { $this->query_args[$key] = $value; return $this; }
/** * Sanitizes the value of the field. * * @since 4.4.0 * * @param array|string $value * * @return array|string */ function sanitize_value( $value ) { if ( $this->multiple ) { return Clean::ids( $value ); } else{ return Clean::id( $value ); } }
}
|