PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.0-beta2
Secure Custom Fields v6.4.0-beta2
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / locations / abstract-acf-location.php
secure-custom-fields / includes / locations Last commit date
abstract-acf-legacy-location.php 1 year ago abstract-acf-location.php 1 year ago class-acf-location-attachment.php 1 year ago class-acf-location-comment.php 1 year ago class-acf-location-current-user-role.php 1 year ago class-acf-location-current-user.php 1 year ago class-acf-location-nav-menu-item.php 1 year ago class-acf-location-nav-menu.php 1 year ago class-acf-location-page-parent.php 1 year ago class-acf-location-page-template.php 1 year ago class-acf-location-page-type.php 1 year ago class-acf-location-page.php 1 year ago class-acf-location-post-category.php 1 year ago class-acf-location-post-format.php 1 year ago class-acf-location-post-status.php 1 year ago class-acf-location-post-taxonomy.php 1 year ago class-acf-location-post-template.php 1 year ago class-acf-location-post-type.php 1 year ago class-acf-location-post.php 1 year ago class-acf-location-taxonomy.php 1 year ago class-acf-location-user-form.php 1 year ago class-acf-location-user-role.php 1 year ago class-acf-location-widget.php 1 year ago index.php 1 year ago
abstract-acf-location.php
190 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Location' ) ) :
8 abstract class ACF_Location extends ACF_Legacy_Location {
9
10 /**
11 * The location rule name.
12 *
13 * @since 5.9.0
14 * @var string
15 */
16 public $name = '';
17
18 /**
19 * The location rule label.
20 *
21 * @since 5.9.0
22 * @var string
23 */
24 public $label = '';
25
26 /**
27 * The location rule category.
28 *
29 * Accepts "post", "page", "user", "forms" or a custom label.
30 *
31 * @since 5.9.0
32 * @var string
33 */
34 public $category = 'post';
35
36 /**
37 * Whether or not the location rule is publicly accessible.
38 *
39 * @since 5.0.0
40 * @var boolean
41 */
42 public $public = true;
43
44 /**
45 * The object type related to this location rule.
46 *
47 * Accepts an object type discoverable by `acf_get_object_type()`.
48 *
49 * @since 5.9.0
50 * @var string
51 */
52 public $object_type = '';
53
54 /**
55 * The object subtype related to this location rule.
56 *
57 * Accepts a custom post type or custom taxonomy.
58 *
59 * @since 5.9.0
60 * @var string
61 */
62 public $object_subtype = '';
63
64 /**
65 * Constructor.
66 *
67 * @date 8/4/20
68 * @since 5.9.0
69 *
70 * @param void
71 * @return void
72 */
73 public function __construct() {
74 $this->initialize();
75
76 // Call legacy constructor.
77 parent::__construct();
78 }
79
80 /**
81 * Initializes props.
82 *
83 * @date 5/03/2014
84 * @since 5.0.0
85 *
86 * @param void
87 * @return void
88 */
89 public function initialize() {
90 // Set props here.
91 }
92
93 /**
94 * Returns an array of operators for this location.
95 *
96 * @date 9/4/20
97 * @since 5.9.0
98 *
99 * @param array $rule A location rule.
100 * @return array
101 */
102 public static function get_operators( $rule ) {
103 return array(
104 '==' => __( 'is equal to', 'acf' ),
105 '!=' => __( 'is not equal to', 'acf' ),
106 );
107 }
108
109 /**
110 * Returns an array of possible values for this location.
111 *
112 * @date 9/4/20
113 * @since 5.9.0
114 *
115 * @param array $rule A location rule.
116 * @return array
117 */
118 public function get_values( $rule ) {
119 return array();
120 }
121
122 /**
123 * Returns the object_type connected to this location.
124 *
125 * @date 1/4/20
126 * @since 5.9.0
127 *
128 * @param array $rule A location rule.
129 * @return string
130 */
131 public function get_object_type( $rule ) {
132 return $this->object_type;
133 }
134
135 /**
136 * Returns the object_subtype connected to this location.
137 *
138 * @date 1/4/20
139 * @since 5.9.0
140 *
141 * @param array $rule A location rule.
142 * @return string|array
143 */
144 public function get_object_subtype( $rule ) {
145 return $this->object_subtype;
146 }
147
148 /**
149 * Matches the provided rule against the screen args returning a bool result.
150 *
151 * @date 9/4/20
152 * @since 5.9.0
153 *
154 * @param array $rule The location rule.
155 * @param array $screen The screen args.
156 * @param array $field_group The field group settings.
157 * @return boolean
158 */
159 public function match( $rule, $screen, $field_group ) {
160 return false;
161 }
162
163 /**
164 * Compares the given value and rule params returning true when they match.
165 *
166 * @date 17/9/19
167 * @since 5.8.1
168 *
169 * @param array $rule The location rule data.
170 * @param mixed $value The value to compare against.
171 * @return boolean
172 */
173 public function compare_to_rule( $value, $rule ) {
174 $result = ( $value == $rule['value'] );
175
176 // Allow "all" to match any value.
177 if ( $rule['value'] === 'all' ) {
178 $result = true;
179 }
180
181 // Reverse result for "!=" operator.
182 if ( $rule['operator'] === '!=' ) {
183 return ! $result;
184 }
185 return $result;
186 }
187 }
188
189 endif; // class_exists check
190