-
Notifications
You must be signed in to change notification settings - Fork 3
/
uoa-helpers.php
85 lines (73 loc) · 2.05 KB
/
uoa-helpers.php
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
<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
namespace Uncanny_Automator;
use Uncanny_Automator_Pro\Uoa_Pro_Helpers;
use WP_Error;
/**
* Class Uoa_Helpers
*
* @package Uncanny_Automator
*/
class Uoa_Helpers {
/**
* @var Uoa_Helpers
*/
public $options;
/**
* @var Uoa_Pro_Helpers
*/
public $pro;
/**
* @var bool
*/
public $load_options = true;
/**
* Uoa_Helpers constructor.
*/
public function __construct() {
$this->load_options = Automator()->helpers->recipe->maybe_load_trigger_options( __CLASS__ );
}
/**
* @param Uoa_Helpers $options
*/
public function setOptions( Uoa_Helpers $options ) {
$this->options = $options;
}
/**
* @param Uoa_Pro_Helpers $pro
*/
public function setPro( Uoa_Pro_Helpers $pro ) {
$this->pro = $pro;
}
/**
* @param string $label
* @param string $option_code
*
* @return mixed
*/
public function get_recipes( $label = null, $option_code = 'UOARECIPE', $any_option = false ) {
if ( ! $label ) {
$label = esc_attr__( 'Recipe', 'uncanny-automator' );
}
// post query arguments.
global $wpdb;
$results = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_status FROM $wpdb->posts WHERE post_status IN ('publish', 'draft') AND post_type = %s ORDER BY post_title ASC", 'uo-recipe' ) );
$options = array();
$options['-1'] = esc_attr__( 'Any recipe', 'uncanny-automator' );
if ( $results ) {
foreach ( $results as $result ) {
$options[ $result->ID ] = sprintf( '%s (%s)', $result->post_title, $result->post_status );
}
}
//$options = Automator()->helpers->recipe->options->wp_query( $args, $any_option, esc_attr__( 'Any recipe', 'uncanny-automator' ) );
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $options,
'relevant_tokens' => array(),
//'custom_value_description' => esc_attr__( 'Recipe slug', 'uncanny-automator' ),
);
return apply_filters( 'uap_option_get_recipes', $option );
}
}