@@ -44,27 +44,27 @@ |
||
44 | 44 | $args['PRC_name'] = sanitize_text_field($input['name']); |
45 | 45 | } |
46 | 46 | |
47 | - if (! empty($input['order'])) { |
|
47 | + if ( ! empty($input['order'])) { |
|
48 | 48 | $args['PRC_order'] = (int) $input['order']; |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($input['overrides'])) { |
|
51 | + if ( ! empty($input['overrides'])) { |
|
52 | 52 | $args['PRC_overrides'] = (int) $input['overrides']; |
53 | 53 | } |
54 | 54 | |
55 | - if (! empty($input['parent'])) { |
|
55 | + if ( ! empty($input['parent'])) { |
|
56 | 56 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
57 | 57 | $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($input['priceType'])) { |
|
60 | + if ( ! empty($input['priceType'])) { |
|
61 | 61 | $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
62 | 62 | $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
63 | 63 | } |
64 | 64 | |
65 | - if (! empty($input['wpUser'])) { |
|
65 | + if ( ! empty($input['wpUser'])) { |
|
66 | 66 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
67 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | + $args['PRC_wp_user'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return apply_filters( |
@@ -13,64 +13,64 @@ |
||
13 | 13 | class PriceMutation |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Maps the GraphQL input to a format that the model functions can use |
|
18 | - * |
|
19 | - * @param array $input Data coming from the GraphQL mutation query input |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public static function prepareFields(array $input): array |
|
23 | - { |
|
24 | - $args = []; |
|
16 | + /** |
|
17 | + * Maps the GraphQL input to a format that the model functions can use |
|
18 | + * |
|
19 | + * @param array $input Data coming from the GraphQL mutation query input |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public static function prepareFields(array $input): array |
|
23 | + { |
|
24 | + $args = []; |
|
25 | 25 | |
26 | - // amount can be 0 |
|
27 | - if (array_key_exists('amount', $input)) { |
|
28 | - $args['PRC_amount'] = (float) $input['amount']; |
|
29 | - } |
|
26 | + // amount can be 0 |
|
27 | + if (array_key_exists('amount', $input)) { |
|
28 | + $args['PRC_amount'] = (float) $input['amount']; |
|
29 | + } |
|
30 | 30 | |
31 | - if (isset($input['description'])) { |
|
32 | - $args['PRC_desc'] = wp_kses_post($input['description']); |
|
33 | - } |
|
31 | + if (isset($input['description'])) { |
|
32 | + $args['PRC_desc'] = wp_kses_post($input['description']); |
|
33 | + } |
|
34 | 34 | |
35 | - if (array_key_exists('isDefault', $input)) { |
|
36 | - $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
37 | - } |
|
35 | + if (array_key_exists('isDefault', $input)) { |
|
36 | + $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
37 | + } |
|
38 | 38 | |
39 | - if (array_key_exists('isTrashed', $input)) { |
|
40 | - $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
41 | - } |
|
39 | + if (array_key_exists('isTrashed', $input)) { |
|
40 | + $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
41 | + } |
|
42 | 42 | |
43 | - if (isset($input['name'])) { |
|
44 | - $args['PRC_name'] = sanitize_text_field($input['name']); |
|
45 | - } |
|
43 | + if (isset($input['name'])) { |
|
44 | + $args['PRC_name'] = sanitize_text_field($input['name']); |
|
45 | + } |
|
46 | 46 | |
47 | - if (! empty($input['order'])) { |
|
48 | - $args['PRC_order'] = (int) $input['order']; |
|
49 | - } |
|
47 | + if (! empty($input['order'])) { |
|
48 | + $args['PRC_order'] = (int) $input['order']; |
|
49 | + } |
|
50 | 50 | |
51 | - if (! empty($input['overrides'])) { |
|
52 | - $args['PRC_overrides'] = (int) $input['overrides']; |
|
53 | - } |
|
51 | + if (! empty($input['overrides'])) { |
|
52 | + $args['PRC_overrides'] = (int) $input['overrides']; |
|
53 | + } |
|
54 | 54 | |
55 | - if (! empty($input['parent'])) { |
|
56 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
57 | - $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
58 | - } |
|
55 | + if (! empty($input['parent'])) { |
|
56 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
57 | + $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
58 | + } |
|
59 | 59 | |
60 | - if (! empty($input['priceType'])) { |
|
61 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
62 | - $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
63 | - } |
|
60 | + if (! empty($input['priceType'])) { |
|
61 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
62 | + $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
63 | + } |
|
64 | 64 | |
65 | - if (! empty($input['wpUser'])) { |
|
66 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
67 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
68 | - } |
|
65 | + if (! empty($input['wpUser'])) { |
|
66 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
67 | + $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
68 | + } |
|
69 | 69 | |
70 | - return apply_filters( |
|
71 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
72 | - $args, |
|
73 | - $input |
|
74 | - ); |
|
75 | - } |
|
70 | + return apply_filters( |
|
71 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
72 | + $args, |
|
73 | + $input |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | } |
@@ -16,26 +16,26 @@ |
||
16 | 16 | class SiteUrls extends JsonDataNode |
17 | 17 | { |
18 | 18 | |
19 | - const NODE_NAME = 'siteUrls'; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * @param JsonDataNodeValidator $validator |
|
24 | - */ |
|
25 | - public function __construct(JsonDataNodeValidator $validator) |
|
26 | - { |
|
27 | - parent::__construct($validator); |
|
28 | - $this->setNodeName(SiteUrls::NODE_NAME); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @since $VID:$ |
|
34 | - */ |
|
35 | - public function initialize() |
|
36 | - { |
|
37 | - $this->addData('admin', admin_url('/')); |
|
38 | - $this->addData('home', site_url('/')); |
|
39 | - $this->setInitialized(true); |
|
40 | - } |
|
19 | + const NODE_NAME = 'siteUrls'; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * @param JsonDataNodeValidator $validator |
|
24 | + */ |
|
25 | + public function __construct(JsonDataNodeValidator $validator) |
|
26 | + { |
|
27 | + parent::__construct($validator); |
|
28 | + $this->setNodeName(SiteUrls::NODE_NAME); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @since $VID:$ |
|
34 | + */ |
|
35 | + public function initialize() |
|
36 | + { |
|
37 | + $this->addData('admin', admin_url('/')); |
|
38 | + $this->addData('home', site_url('/')); |
|
39 | + $this->setInitialized(true); |
|
40 | + } |
|
41 | 41 | } |
@@ -17,30 +17,30 @@ |
||
17 | 17 | class Locale extends JsonDataNode |
18 | 18 | { |
19 | 19 | |
20 | - const NODE_NAME = 'locale'; |
|
20 | + const NODE_NAME = 'locale'; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param JsonDataNodeValidator $validator |
|
25 | - */ |
|
26 | - public function __construct(JsonDataNodeValidator $validator) |
|
27 | - { |
|
28 | - parent::__construct($validator); |
|
29 | - $this->setNodeName(Locale::NODE_NAME); |
|
30 | - } |
|
23 | + /** |
|
24 | + * @param JsonDataNodeValidator $validator |
|
25 | + */ |
|
26 | + public function __construct(JsonDataNodeValidator $validator) |
|
27 | + { |
|
28 | + parent::__construct($validator); |
|
29 | + $this->setNodeName(Locale::NODE_NAME); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @inheritDoc |
|
34 | - */ |
|
35 | - public function initialize() |
|
36 | - { |
|
37 | - $this->addData('user', get_user_locale()); |
|
38 | - $this->addData('site', get_locale()); |
|
39 | - $this->addData('siteTimezone', [ |
|
40 | - 'city' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
41 | - 'name' => get_option('timezone_string'), |
|
42 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
43 | - ]); |
|
44 | - $this->setInitialized(true); |
|
45 | - } |
|
32 | + /** |
|
33 | + * @inheritDoc |
|
34 | + */ |
|
35 | + public function initialize() |
|
36 | + { |
|
37 | + $this->addData('user', get_user_locale()); |
|
38 | + $this->addData('site', get_locale()); |
|
39 | + $this->addData('siteTimezone', [ |
|
40 | + 'city' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
41 | + 'name' => get_option('timezone_string'), |
|
42 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
43 | + ]); |
|
44 | + $this->setInitialized(true); |
|
45 | + } |
|
46 | 46 | } |
@@ -16,238 +16,238 @@ |
||
16 | 16 | class RequestTypeContextChecker extends ContextChecker implements RequestTypeContextCheckerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var RequestTypeContext $request_type |
|
21 | - */ |
|
22 | - private $request_type; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * RequestTypeContextChecker constructor. |
|
27 | - * |
|
28 | - * @param RequestTypeContext $request_type |
|
29 | - */ |
|
30 | - public function __construct(RequestTypeContext $request_type) |
|
31 | - { |
|
32 | - $this->request_type = $request_type; |
|
33 | - parent::__construct( |
|
34 | - 'RequestTypeContextChecker', |
|
35 | - $this->request_type->validRequestTypes() |
|
36 | - ); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * true if the current request involves some form of activation |
|
42 | - * |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function isActivation() |
|
46 | - { |
|
47 | - return $this->request_type->isActivation() && ! $this->request_type->isUnitTesting(); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @param $is_activation |
|
53 | - */ |
|
54 | - public function setIsActivation($is_activation) |
|
55 | - { |
|
56 | - $this->request_type->setIsActivation($is_activation); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * true if the current request is for the admin and is not being made via AJAX |
|
62 | - * |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function isAdmin() |
|
66 | - { |
|
67 | - return $this->request_type->slug() === RequestTypeContext::ADMIN && ! $this->isActivation(); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * true if the current request is for the admin AND is being made via AJAX |
|
73 | - * |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function isAdminAjax() |
|
77 | - { |
|
78 | - return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN && ! $this->isActivation(); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * true if the current request is being made via AJAX... any AJAX |
|
84 | - * |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function isAjax() |
|
88 | - { |
|
89 | - return $this->isEeAjax() || $this->isOtherAjax(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX |
|
95 | - * |
|
96 | - * @return bool |
|
97 | - */ |
|
98 | - public function isEeAjax() |
|
99 | - { |
|
100 | - return $this->isAdminAjax() || $this->isFrontAjax(); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * true if the current request is being made via AJAX but is NOT for EE related logic |
|
106 | - * |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - public function isOtherAjax() |
|
110 | - { |
|
111 | - return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER && ! $this->isActivation(); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * true if the current request is for the EE REST API |
|
116 | - * |
|
117 | - * @return bool |
|
118 | - */ |
|
119 | - public function isApi() |
|
120 | - { |
|
121 | - return $this->request_type->slug() === RequestTypeContext::API && ! $this->isActivation(); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * true if the current request is from the command line |
|
127 | - * |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public function isCli() |
|
131 | - { |
|
132 | - return $this->request_type->slug() === RequestTypeContext::CLI && ! $this->isActivation(); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * true if the current request is for a WP_Cron |
|
138 | - * |
|
139 | - * @return bool |
|
140 | - */ |
|
141 | - public function isCron() |
|
142 | - { |
|
143 | - return $this->request_type->slug() === RequestTypeContext::CRON && ! $this->isActivation(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * true if the current request is for a feed (ie: RSS) |
|
149 | - * |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - public function isFeed() |
|
153 | - { |
|
154 | - return $this->request_type->slug() === RequestTypeContext::FEED && ! $this->isActivation(); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * true if the current request is for the frontend and is not being made via AJAX |
|
160 | - * |
|
161 | - * @return bool |
|
162 | - */ |
|
163 | - public function isFrontend() |
|
164 | - { |
|
165 | - return $this->request_type->slug() === RequestTypeContext::FRONTEND && ! $this->isActivation(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * true if the current request is for the frontend AND is being made via AJAX |
|
171 | - * |
|
172 | - * @return bool |
|
173 | - */ |
|
174 | - public function isFrontAjax() |
|
175 | - { |
|
176 | - return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT && ! $this->isActivation(); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * true if the current request is for the EE GraphQL manager |
|
182 | - * |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - public function isGQL() |
|
186 | - { |
|
187 | - return $this->request_type->slug() === RequestTypeContext::GQL && ! $this->isActivation(); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * true if the current request is for content that is to be displayed within an iframe |
|
193 | - * |
|
194 | - * @return bool |
|
195 | - */ |
|
196 | - public function isIframe() |
|
197 | - { |
|
198 | - return $this->request_type->slug() === RequestTypeContext::IFRAME && ! $this->isActivation(); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * true if the current request is occurring while unit testing |
|
204 | - * |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function isUnitTesting() |
|
208 | - { |
|
209 | - return $this->request_type->isUnitTesting() && ! $this->request_type->isActivation(); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * true if the current request is for the WP REST API |
|
215 | - * |
|
216 | - * @return bool |
|
217 | - */ |
|
218 | - public function isWordPressApi() |
|
219 | - { |
|
220 | - return $this->request_type->slug() === RequestTypeContext::WP_API && ! $this->isActivation(); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * true if the current request is being made via AJAX for the WP Heartbeat |
|
226 | - * |
|
227 | - * @return bool |
|
228 | - */ |
|
229 | - public function isWordPressHeartbeat() |
|
230 | - { |
|
231 | - return $this->request_type->slug() === RequestTypeContext::AJAX_HEARTBEAT && ! $this->isActivation(); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * true if the current request is a loopback sent from WP core to test for errors |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
240 | - public function isWordPressScrape() |
|
241 | - { |
|
242 | - return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function slug() |
|
250 | - { |
|
251 | - return $this->request_type->slug(); |
|
252 | - } |
|
19 | + /** |
|
20 | + * @var RequestTypeContext $request_type |
|
21 | + */ |
|
22 | + private $request_type; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * RequestTypeContextChecker constructor. |
|
27 | + * |
|
28 | + * @param RequestTypeContext $request_type |
|
29 | + */ |
|
30 | + public function __construct(RequestTypeContext $request_type) |
|
31 | + { |
|
32 | + $this->request_type = $request_type; |
|
33 | + parent::__construct( |
|
34 | + 'RequestTypeContextChecker', |
|
35 | + $this->request_type->validRequestTypes() |
|
36 | + ); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * true if the current request involves some form of activation |
|
42 | + * |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function isActivation() |
|
46 | + { |
|
47 | + return $this->request_type->isActivation() && ! $this->request_type->isUnitTesting(); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @param $is_activation |
|
53 | + */ |
|
54 | + public function setIsActivation($is_activation) |
|
55 | + { |
|
56 | + $this->request_type->setIsActivation($is_activation); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * true if the current request is for the admin and is not being made via AJAX |
|
62 | + * |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function isAdmin() |
|
66 | + { |
|
67 | + return $this->request_type->slug() === RequestTypeContext::ADMIN && ! $this->isActivation(); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * true if the current request is for the admin AND is being made via AJAX |
|
73 | + * |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function isAdminAjax() |
|
77 | + { |
|
78 | + return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN && ! $this->isActivation(); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * true if the current request is being made via AJAX... any AJAX |
|
84 | + * |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function isAjax() |
|
88 | + { |
|
89 | + return $this->isEeAjax() || $this->isOtherAjax(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX |
|
95 | + * |
|
96 | + * @return bool |
|
97 | + */ |
|
98 | + public function isEeAjax() |
|
99 | + { |
|
100 | + return $this->isAdminAjax() || $this->isFrontAjax(); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * true if the current request is being made via AJAX but is NOT for EE related logic |
|
106 | + * |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + public function isOtherAjax() |
|
110 | + { |
|
111 | + return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER && ! $this->isActivation(); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * true if the current request is for the EE REST API |
|
116 | + * |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | + public function isApi() |
|
120 | + { |
|
121 | + return $this->request_type->slug() === RequestTypeContext::API && ! $this->isActivation(); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * true if the current request is from the command line |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public function isCli() |
|
131 | + { |
|
132 | + return $this->request_type->slug() === RequestTypeContext::CLI && ! $this->isActivation(); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * true if the current request is for a WP_Cron |
|
138 | + * |
|
139 | + * @return bool |
|
140 | + */ |
|
141 | + public function isCron() |
|
142 | + { |
|
143 | + return $this->request_type->slug() === RequestTypeContext::CRON && ! $this->isActivation(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * true if the current request is for a feed (ie: RSS) |
|
149 | + * |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + public function isFeed() |
|
153 | + { |
|
154 | + return $this->request_type->slug() === RequestTypeContext::FEED && ! $this->isActivation(); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * true if the current request is for the frontend and is not being made via AJAX |
|
160 | + * |
|
161 | + * @return bool |
|
162 | + */ |
|
163 | + public function isFrontend() |
|
164 | + { |
|
165 | + return $this->request_type->slug() === RequestTypeContext::FRONTEND && ! $this->isActivation(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * true if the current request is for the frontend AND is being made via AJAX |
|
171 | + * |
|
172 | + * @return bool |
|
173 | + */ |
|
174 | + public function isFrontAjax() |
|
175 | + { |
|
176 | + return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT && ! $this->isActivation(); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * true if the current request is for the EE GraphQL manager |
|
182 | + * |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + public function isGQL() |
|
186 | + { |
|
187 | + return $this->request_type->slug() === RequestTypeContext::GQL && ! $this->isActivation(); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * true if the current request is for content that is to be displayed within an iframe |
|
193 | + * |
|
194 | + * @return bool |
|
195 | + */ |
|
196 | + public function isIframe() |
|
197 | + { |
|
198 | + return $this->request_type->slug() === RequestTypeContext::IFRAME && ! $this->isActivation(); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * true if the current request is occurring while unit testing |
|
204 | + * |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function isUnitTesting() |
|
208 | + { |
|
209 | + return $this->request_type->isUnitTesting() && ! $this->request_type->isActivation(); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * true if the current request is for the WP REST API |
|
215 | + * |
|
216 | + * @return bool |
|
217 | + */ |
|
218 | + public function isWordPressApi() |
|
219 | + { |
|
220 | + return $this->request_type->slug() === RequestTypeContext::WP_API && ! $this->isActivation(); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * true if the current request is being made via AJAX for the WP Heartbeat |
|
226 | + * |
|
227 | + * @return bool |
|
228 | + */ |
|
229 | + public function isWordPressHeartbeat() |
|
230 | + { |
|
231 | + return $this->request_type->slug() === RequestTypeContext::AJAX_HEARTBEAT && ! $this->isActivation(); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * true if the current request is a loopback sent from WP core to test for errors |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | + public function isWordPressScrape() |
|
241 | + { |
|
242 | + return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function slug() |
|
250 | + { |
|
251 | + return $this->request_type->slug(); |
|
252 | + } |
|
253 | 253 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public static function instance(LoaderInterface $loader = null, RequestInterface $request = null) |
52 | 52 | { |
53 | 53 | // check if class object is instantiated |
54 | - if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
54 | + if ( ! EE_Admin::$_instance instanceof EE_Admin) { |
|
55 | 55 | EE_Admin::$_instance = new EE_Admin($loader, $request); |
56 | 56 | } |
57 | 57 | return EE_Admin::$_instance; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
98 | 98 | add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
99 | 99 | add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
100 | - if (! $this->request->isAjax()) { |
|
100 | + if ( ! $this->request->isAjax()) { |
|
101 | 101 | // admin hooks |
102 | 102 | add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
103 | 103 | add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function _define_all_constants() |
119 | 119 | { |
120 | - if (! defined('EE_ADMIN_URL')) { |
|
121 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
122 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
123 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
124 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
120 | + if ( ! defined('EE_ADMIN_URL')) { |
|
121 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
122 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
123 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates/'); |
|
124 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
125 | 125 | define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
126 | 126 | } |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // set $main_file in stone |
140 | 140 | static $main_file; |
141 | 141 | // if $main_file is not set yet |
142 | - if (! $main_file) { |
|
142 | + if ( ! $main_file) { |
|
143 | 143 | $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
144 | 144 | } |
145 | 145 | if ($plugin === $main_file) { |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
175 | 175 | { |
176 | 176 | return array( |
177 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
178 | - 'about' => EE_ADMIN_PAGES . 'about/', |
|
179 | - 'support' => EE_ADMIN_PAGES . 'support/', |
|
177 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance/', |
|
178 | + 'about' => EE_ADMIN_PAGES.'about/', |
|
179 | + 'support' => EE_ADMIN_PAGES.'support/', |
|
180 | 180 | ); |
181 | 181 | } |
182 | 182 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->initModelsReady(); |
201 | 201 | } |
202 | 202 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
203 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
203 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
204 | 204 | try { |
205 | 205 | // this loads the controller for the admin pages which will setup routing etc |
206 | 206 | $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader'); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | } |
212 | 212 | add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
213 | - if (! $this->request->isAjax()) { |
|
213 | + if ( ! $this->request->isAjax()) { |
|
214 | 214 | // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
215 | 215 | add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10); |
216 | 216 | add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function getLoader() |
231 | 231 | { |
232 | - if (! $this->loader instanceof LoaderInterface) { |
|
232 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
233 | 233 | $this->loader = LoaderFactory::getLoader(); |
234 | 234 | } |
235 | 235 | return $this->loader; |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | '</strong>', |
300 | 300 | '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
301 | 301 | '</a>', |
302 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
302 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
303 | 303 | array( |
304 | 304 | 'page' => 'espresso_maintenance_settings', |
305 | 305 | 'action' => 'datetime_tools', |
306 | 306 | ), |
307 | 307 | admin_url('admin.php') |
308 | - ) . '">' |
|
308 | + ).'">' |
|
309 | 309 | ), |
310 | 310 | false, |
311 | 311 | 'manage_options', |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | public function enable_hidden_ee_nav_menu_metaboxes() |
352 | 352 | { |
353 | 353 | global $wp_meta_boxes, $pagenow; |
354 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
354 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | $user = wp_get_current_user(); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | if (is_array($hidden_meta_boxes)) { |
381 | 381 | foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
382 | 382 | if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
383 | - unset($hidden_meta_boxes[ $key ]); |
|
383 | + unset($hidden_meta_boxes[$key]); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function modify_edit_post_link($link, $id) |
422 | 422 | { |
423 | - if (! $post = get_post($id)) { |
|
423 | + if ( ! $post = get_post($id)) { |
|
424 | 424 | return $link; |
425 | 425 | } |
426 | 426 | if ($post->post_type === 'espresso_attendees') { |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | ); |
568 | 568 | |
569 | 569 | foreach ($keys as $key => $value) { |
570 | - $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; |
|
570 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
571 | 571 | } |
572 | 572 | return $menu_item; |
573 | 573 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
599 | 599 | } |
600 | 600 | |
601 | - if (! $this->request->isAjax()) { |
|
601 | + if ( ! $this->request->isAjax()) { |
|
602 | 602 | /** |
603 | 603 | * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
604 | 604 | * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
@@ -643,10 +643,10 @@ discard block |
||
643 | 643 | |
644 | 644 | // loop through to remove any critical pages from the array. |
645 | 645 | foreach ($critical_pages as $page_id) { |
646 | - $needle = 'value="' . $page_id . '"'; |
|
646 | + $needle = 'value="'.$page_id.'"'; |
|
647 | 647 | foreach ($split_output as $key => $haystack) { |
648 | 648 | if (strpos($haystack, $needle) !== false) { |
649 | - unset($split_output[ $key ]); |
|
649 | + unset($split_output[$key]); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | |
713 | 713 | foreach ($items as $type => $item_properties) { |
714 | 714 | $elements[] = sprintf( |
715 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
715 | + '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', |
|
716 | 716 | $item_properties['url'], |
717 | 717 | $item_properties['title'], |
718 | 718 | $item_properties['text'] |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | // check for date_format or time_format |
737 | 737 | switch ($option) { |
738 | 738 | case 'date_format': |
739 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
739 | + $date_time_format = $value.' '.get_option('time_format'); |
|
740 | 740 | break; |
741 | 741 | case 'time_format': |
742 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
742 | + $date_time_format = get_option('date_format').' '.$value; |
|
743 | 743 | break; |
744 | 744 | default: |
745 | 745 | $date_time_format = false; |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | |
763 | 763 | |
764 | 764 | foreach ($error_msg as $error) { |
765 | - $msg .= '<li>' . $error . '</li>'; |
|
765 | + $msg .= '<li>'.$error.'</li>'; |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | $msg .= '</ul></p><p>' |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | public function displayStateForCriticalPages($post_states, $post) |
835 | 835 | { |
836 | 836 | $post_states = (array) $post_states; |
837 | - if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
837 | + if ( ! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
838 | 838 | return $post_states; |
839 | 839 | } |
840 | 840 | /** @var EE_Core_Config $config */ |
@@ -20,491 +20,491 @@ discard block |
||
20 | 20 | final class EE_Admin implements InterminableInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EE_Admin $_instance |
|
25 | - */ |
|
26 | - private static $_instance; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
30 | - */ |
|
31 | - private $persistent_admin_notice_manager; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var LoaderInterface $loader |
|
35 | - */ |
|
36 | - protected $loader; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var RequestInterface $request |
|
40 | - */ |
|
41 | - protected $request; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @singleton method used to instantiate class object |
|
46 | - * @param LoaderInterface $loader |
|
47 | - * @param RequestInterface $request |
|
48 | - * @return EE_Admin |
|
49 | - * @throws EE_Error |
|
50 | - */ |
|
51 | - public static function instance(LoaderInterface $loader = null, RequestInterface $request = null) |
|
52 | - { |
|
53 | - // check if class object is instantiated |
|
54 | - if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
55 | - EE_Admin::$_instance = new EE_Admin($loader, $request); |
|
56 | - } |
|
57 | - return EE_Admin::$_instance; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @return EE_Admin |
|
63 | - * @throws EE_Error |
|
64 | - */ |
|
65 | - public static function reset() |
|
66 | - { |
|
67 | - EE_Admin::$_instance = null; |
|
68 | - $loader = LoaderFactory::getLoader(); |
|
69 | - $request = $loader->getShared('EventEspresso\core\services\request\Request'); |
|
70 | - return EE_Admin::instance($loader, $request); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * class constructor |
|
76 | - * |
|
77 | - * @param LoaderInterface $loader |
|
78 | - * @param RequestInterface $request |
|
79 | - * @throws EE_Error |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - * @throws InvalidInterfaceException |
|
82 | - * @throws InvalidArgumentException |
|
83 | - */ |
|
84 | - protected function __construct(LoaderInterface $loader, RequestInterface $request) |
|
85 | - { |
|
86 | - $this->loader = $loader; |
|
87 | - $this->request = $request; |
|
88 | - // define global EE_Admin constants |
|
89 | - $this->_define_all_constants(); |
|
90 | - // set autoloaders for our admin page classes based on included path information |
|
91 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
92 | - // reset Environment config (we only do this on admin page loads); |
|
93 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
94 | - // load EE_Request_Handler early |
|
95 | - add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
96 | - add_action('admin_init', array($this, 'admin_init'), 100); |
|
97 | - add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
98 | - add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
99 | - add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
100 | - if (! $this->request->isAjax()) { |
|
101 | - // admin hooks |
|
102 | - add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
|
103 | - add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
|
104 | - add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']); |
|
105 | - add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2); |
|
106 | - add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2); |
|
107 | - } |
|
108 | - do_action('AHEE__EE_Admin__loaded'); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * _define_all_constants |
|
114 | - * define constants that are set globally for all admin pages |
|
115 | - * |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - private function _define_all_constants() |
|
119 | - { |
|
120 | - if (! defined('EE_ADMIN_URL')) { |
|
121 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
122 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
123 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
124 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
125 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
132 | - * |
|
133 | - * @param array $links |
|
134 | - * @param string $plugin |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public function filter_plugin_actions($links, $plugin) |
|
138 | - { |
|
139 | - // set $main_file in stone |
|
140 | - static $main_file; |
|
141 | - // if $main_file is not set yet |
|
142 | - if (! $main_file) { |
|
143 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
144 | - } |
|
145 | - if ($plugin === $main_file) { |
|
146 | - // compare current plugin to this one |
|
147 | - if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
148 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
149 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
150 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
151 | - . '</a>'; |
|
152 | - array_unshift($links, $maintenance_link); |
|
153 | - } else { |
|
154 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
155 | - . esc_html__('Settings', 'event_espresso') |
|
156 | - . '</a>'; |
|
157 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
158 | - . esc_html__('Events', 'event_espresso') |
|
159 | - . '</a>'; |
|
160 | - // add before other links |
|
161 | - array_unshift($links, $org_settings_link, $events_link); |
|
162 | - } |
|
163 | - } |
|
164 | - return $links; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * hide_admin_pages_except_maintenance_mode |
|
170 | - * |
|
171 | - * @param array $admin_page_folder_names |
|
172 | - * @return array |
|
173 | - */ |
|
174 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
175 | - { |
|
176 | - return array( |
|
177 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
178 | - 'about' => EE_ADMIN_PAGES . 'about/', |
|
179 | - 'support' => EE_ADMIN_PAGES . 'support/', |
|
180 | - ); |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
186 | - * EE_Front_Controller's init phases have run |
|
187 | - * |
|
188 | - * @return void |
|
189 | - * @throws EE_Error |
|
190 | - * @throws InvalidArgumentException |
|
191 | - * @throws InvalidDataTypeException |
|
192 | - * @throws InvalidInterfaceException |
|
193 | - * @throws ReflectionException |
|
194 | - * @throws ServiceNotFoundException |
|
195 | - */ |
|
196 | - public function init() |
|
197 | - { |
|
198 | - // only enable most of the EE_Admin IF we're not in full maintenance mode |
|
199 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
200 | - $this->initModelsReady(); |
|
201 | - } |
|
202 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
203 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
204 | - try { |
|
205 | - // this loads the controller for the admin pages which will setup routing etc |
|
206 | - $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader'); |
|
207 | - $admin_page_loader->init(); |
|
208 | - } catch (EE_Error $e) { |
|
209 | - $e->get_error(); |
|
210 | - } |
|
211 | - } |
|
212 | - add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
213 | - if (! $this->request->isAjax()) { |
|
214 | - // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
215 | - add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10); |
|
216 | - add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10); |
|
217 | - // exclude EE critical pages from all nav menus and wp_list_pages |
|
218 | - add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10); |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * Gets the loader (and if it wasn't previously set, sets it) |
|
225 | - * @return LoaderInterface |
|
226 | - * @throws InvalidArgumentException |
|
227 | - * @throws InvalidDataTypeException |
|
228 | - * @throws InvalidInterfaceException |
|
229 | - */ |
|
230 | - protected function getLoader() |
|
231 | - { |
|
232 | - if (! $this->loader instanceof LoaderInterface) { |
|
233 | - $this->loader = LoaderFactory::getLoader(); |
|
234 | - } |
|
235 | - return $this->loader; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * Method that's fired on admin requests (including admin ajax) but only when the models are usable |
|
241 | - * (ie, the site isn't in maintenance mode) |
|
242 | - * |
|
243 | - * @return void |
|
244 | - * @throws EE_Error |
|
245 | - * @throws EE_Error |
|
246 | - * @since 4.9.63.p |
|
247 | - */ |
|
248 | - protected function initModelsReady() |
|
249 | - { |
|
250 | - // ok so we want to enable the entire admin |
|
251 | - $this->persistent_admin_notice_manager = $this->loader->getShared( |
|
252 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
253 | - ); |
|
254 | - $this->persistent_admin_notice_manager->setReturnUrl( |
|
255 | - EE_Admin_Page::add_query_args_and_nonce( |
|
256 | - array( |
|
257 | - 'page' => $this->request->getRequestParam('page', ''), |
|
258 | - 'action' => $this->request->getRequestParam('action', ''), |
|
259 | - ), |
|
260 | - EE_ADMIN_URL |
|
261 | - ) |
|
262 | - ); |
|
263 | - $this->maybeSetDatetimeWarningNotice(); |
|
264 | - // at a glance dashboard widget |
|
265 | - add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
266 | - // filter for get_edit_post_link used on comments for custom post types |
|
267 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * get_persistent_admin_notices |
|
273 | - * |
|
274 | - * @access public |
|
275 | - * @return void |
|
276 | - * @throws EE_Error |
|
277 | - * @throws InvalidArgumentException |
|
278 | - * @throws InvalidDataTypeException |
|
279 | - * @throws InvalidInterfaceException |
|
280 | - */ |
|
281 | - public function maybeSetDatetimeWarningNotice() |
|
282 | - { |
|
283 | - // add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
284 | - // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
285 | - // with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
286 | - // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
287 | - if ( |
|
288 | - apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
289 | - && ! get_option('timezone_string') |
|
290 | - && EEM_Event::instance()->count() > 0 |
|
291 | - ) { |
|
292 | - new PersistentAdminNotice( |
|
293 | - 'datetime_fix_notice', |
|
294 | - sprintf( |
|
295 | - esc_html__( |
|
296 | - '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
297 | - 'event_espresso' |
|
298 | - ), |
|
299 | - '<strong>', |
|
300 | - '</strong>', |
|
301 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
302 | - '</a>', |
|
303 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
304 | - array( |
|
305 | - 'page' => 'espresso_maintenance_settings', |
|
306 | - 'action' => 'datetime_tools', |
|
307 | - ), |
|
308 | - admin_url('admin.php') |
|
309 | - ) . '">' |
|
310 | - ), |
|
311 | - false, |
|
312 | - 'manage_options', |
|
313 | - 'datetime_fix_persistent_notice' |
|
314 | - ); |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
321 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
322 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
323 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
324 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
325 | - * |
|
326 | - * @param WP_Post $post_type WP post type object |
|
327 | - * @return WP_Post |
|
328 | - * @throws InvalidArgumentException |
|
329 | - * @throws InvalidDataTypeException |
|
330 | - * @throws InvalidInterfaceException |
|
331 | - */ |
|
332 | - public function remove_pages_from_nav_menu($post_type) |
|
333 | - { |
|
334 | - // if this isn't the "pages" post type let's get out |
|
335 | - if ($post_type->name !== 'page') { |
|
336 | - return $post_type; |
|
337 | - } |
|
338 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
339 | - $post_type->_default_query = array( |
|
340 | - 'post__not_in' => $critical_pages, |
|
341 | - ); |
|
342 | - return $post_type; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
348 | - * metaboxes get shown as well |
|
349 | - * |
|
350 | - * @return void |
|
351 | - */ |
|
352 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
353 | - { |
|
354 | - global $wp_meta_boxes, $pagenow; |
|
355 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
356 | - return; |
|
357 | - } |
|
358 | - $user = wp_get_current_user(); |
|
359 | - // has this been done yet? |
|
360 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
361 | - return; |
|
362 | - } |
|
363 | - |
|
364 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
365 | - $initial_meta_boxes = apply_filters( |
|
366 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
367 | - array( |
|
368 | - 'nav-menu-theme-locations', |
|
369 | - 'add-page', |
|
370 | - 'add-custom-links', |
|
371 | - 'add-category', |
|
372 | - 'add-espresso_events', |
|
373 | - 'add-espresso_venues', |
|
374 | - 'add-espresso_event_categories', |
|
375 | - 'add-espresso_venue_categories', |
|
376 | - 'add-post-type-post', |
|
377 | - 'add-post-type-page', |
|
378 | - ) |
|
379 | - ); |
|
380 | - |
|
381 | - if (is_array($hidden_meta_boxes)) { |
|
382 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
383 | - if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
384 | - unset($hidden_meta_boxes[ $key ]); |
|
385 | - } |
|
386 | - } |
|
387 | - } |
|
388 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
389 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
395 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
396 | - * |
|
397 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
398 | - * addons etc. |
|
399 | - * @return void |
|
400 | - */ |
|
401 | - public function register_custom_nav_menu_boxes() |
|
402 | - { |
|
403 | - add_meta_box( |
|
404 | - 'add-extra-nav-menu-pages', |
|
405 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
406 | - array($this, 'ee_cpt_archive_pages'), |
|
407 | - 'nav-menus', |
|
408 | - 'side', |
|
409 | - 'core' |
|
410 | - ); |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
416 | - * |
|
417 | - * @since 4.3.0 |
|
418 | - * @param string $link the original link generated by wp |
|
419 | - * @param int $id post id |
|
420 | - * @return string the (maybe) modified link |
|
421 | - */ |
|
422 | - public function modify_edit_post_link($link, $id) |
|
423 | - { |
|
424 | - if (! $post = get_post($id)) { |
|
425 | - return $link; |
|
426 | - } |
|
427 | - if ($post->post_type === 'espresso_attendees') { |
|
428 | - $query_args = array( |
|
429 | - 'action' => 'edit_attendee', |
|
430 | - 'post' => $id, |
|
431 | - ); |
|
432 | - return EEH_URL::add_query_args_and_nonce( |
|
433 | - $query_args, |
|
434 | - admin_url('admin.php?page=espresso_registrations') |
|
435 | - ); |
|
436 | - } |
|
437 | - return $link; |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - public function ee_cpt_archive_pages() |
|
442 | - { |
|
443 | - global $nav_menu_selected_id; |
|
444 | - $db_fields = false; |
|
445 | - $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
446 | - $current_tab = 'event-archives'; |
|
447 | - $removed_args = array( |
|
448 | - 'action', |
|
449 | - 'customlink-tab', |
|
450 | - 'edit-menu-item', |
|
451 | - 'menu-item', |
|
452 | - 'page-tab', |
|
453 | - '_wpnonce', |
|
454 | - ); |
|
455 | - ?> |
|
23 | + /** |
|
24 | + * @var EE_Admin $_instance |
|
25 | + */ |
|
26 | + private static $_instance; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
30 | + */ |
|
31 | + private $persistent_admin_notice_manager; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var LoaderInterface $loader |
|
35 | + */ |
|
36 | + protected $loader; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var RequestInterface $request |
|
40 | + */ |
|
41 | + protected $request; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @singleton method used to instantiate class object |
|
46 | + * @param LoaderInterface $loader |
|
47 | + * @param RequestInterface $request |
|
48 | + * @return EE_Admin |
|
49 | + * @throws EE_Error |
|
50 | + */ |
|
51 | + public static function instance(LoaderInterface $loader = null, RequestInterface $request = null) |
|
52 | + { |
|
53 | + // check if class object is instantiated |
|
54 | + if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
55 | + EE_Admin::$_instance = new EE_Admin($loader, $request); |
|
56 | + } |
|
57 | + return EE_Admin::$_instance; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @return EE_Admin |
|
63 | + * @throws EE_Error |
|
64 | + */ |
|
65 | + public static function reset() |
|
66 | + { |
|
67 | + EE_Admin::$_instance = null; |
|
68 | + $loader = LoaderFactory::getLoader(); |
|
69 | + $request = $loader->getShared('EventEspresso\core\services\request\Request'); |
|
70 | + return EE_Admin::instance($loader, $request); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * class constructor |
|
76 | + * |
|
77 | + * @param LoaderInterface $loader |
|
78 | + * @param RequestInterface $request |
|
79 | + * @throws EE_Error |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + * @throws InvalidInterfaceException |
|
82 | + * @throws InvalidArgumentException |
|
83 | + */ |
|
84 | + protected function __construct(LoaderInterface $loader, RequestInterface $request) |
|
85 | + { |
|
86 | + $this->loader = $loader; |
|
87 | + $this->request = $request; |
|
88 | + // define global EE_Admin constants |
|
89 | + $this->_define_all_constants(); |
|
90 | + // set autoloaders for our admin page classes based on included path information |
|
91 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
92 | + // reset Environment config (we only do this on admin page loads); |
|
93 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
94 | + // load EE_Request_Handler early |
|
95 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
96 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
97 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
98 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
99 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
100 | + if (! $this->request->isAjax()) { |
|
101 | + // admin hooks |
|
102 | + add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
|
103 | + add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
|
104 | + add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']); |
|
105 | + add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2); |
|
106 | + add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2); |
|
107 | + } |
|
108 | + do_action('AHEE__EE_Admin__loaded'); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * _define_all_constants |
|
114 | + * define constants that are set globally for all admin pages |
|
115 | + * |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + private function _define_all_constants() |
|
119 | + { |
|
120 | + if (! defined('EE_ADMIN_URL')) { |
|
121 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
122 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
123 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
124 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
125 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
132 | + * |
|
133 | + * @param array $links |
|
134 | + * @param string $plugin |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public function filter_plugin_actions($links, $plugin) |
|
138 | + { |
|
139 | + // set $main_file in stone |
|
140 | + static $main_file; |
|
141 | + // if $main_file is not set yet |
|
142 | + if (! $main_file) { |
|
143 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
144 | + } |
|
145 | + if ($plugin === $main_file) { |
|
146 | + // compare current plugin to this one |
|
147 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
148 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
149 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
150 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
151 | + . '</a>'; |
|
152 | + array_unshift($links, $maintenance_link); |
|
153 | + } else { |
|
154 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
155 | + . esc_html__('Settings', 'event_espresso') |
|
156 | + . '</a>'; |
|
157 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
158 | + . esc_html__('Events', 'event_espresso') |
|
159 | + . '</a>'; |
|
160 | + // add before other links |
|
161 | + array_unshift($links, $org_settings_link, $events_link); |
|
162 | + } |
|
163 | + } |
|
164 | + return $links; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * hide_admin_pages_except_maintenance_mode |
|
170 | + * |
|
171 | + * @param array $admin_page_folder_names |
|
172 | + * @return array |
|
173 | + */ |
|
174 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
175 | + { |
|
176 | + return array( |
|
177 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
178 | + 'about' => EE_ADMIN_PAGES . 'about/', |
|
179 | + 'support' => EE_ADMIN_PAGES . 'support/', |
|
180 | + ); |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
186 | + * EE_Front_Controller's init phases have run |
|
187 | + * |
|
188 | + * @return void |
|
189 | + * @throws EE_Error |
|
190 | + * @throws InvalidArgumentException |
|
191 | + * @throws InvalidDataTypeException |
|
192 | + * @throws InvalidInterfaceException |
|
193 | + * @throws ReflectionException |
|
194 | + * @throws ServiceNotFoundException |
|
195 | + */ |
|
196 | + public function init() |
|
197 | + { |
|
198 | + // only enable most of the EE_Admin IF we're not in full maintenance mode |
|
199 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
200 | + $this->initModelsReady(); |
|
201 | + } |
|
202 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
203 | + if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
204 | + try { |
|
205 | + // this loads the controller for the admin pages which will setup routing etc |
|
206 | + $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader'); |
|
207 | + $admin_page_loader->init(); |
|
208 | + } catch (EE_Error $e) { |
|
209 | + $e->get_error(); |
|
210 | + } |
|
211 | + } |
|
212 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
213 | + if (! $this->request->isAjax()) { |
|
214 | + // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
215 | + add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10); |
|
216 | + add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10); |
|
217 | + // exclude EE critical pages from all nav menus and wp_list_pages |
|
218 | + add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10); |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * Gets the loader (and if it wasn't previously set, sets it) |
|
225 | + * @return LoaderInterface |
|
226 | + * @throws InvalidArgumentException |
|
227 | + * @throws InvalidDataTypeException |
|
228 | + * @throws InvalidInterfaceException |
|
229 | + */ |
|
230 | + protected function getLoader() |
|
231 | + { |
|
232 | + if (! $this->loader instanceof LoaderInterface) { |
|
233 | + $this->loader = LoaderFactory::getLoader(); |
|
234 | + } |
|
235 | + return $this->loader; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * Method that's fired on admin requests (including admin ajax) but only when the models are usable |
|
241 | + * (ie, the site isn't in maintenance mode) |
|
242 | + * |
|
243 | + * @return void |
|
244 | + * @throws EE_Error |
|
245 | + * @throws EE_Error |
|
246 | + * @since 4.9.63.p |
|
247 | + */ |
|
248 | + protected function initModelsReady() |
|
249 | + { |
|
250 | + // ok so we want to enable the entire admin |
|
251 | + $this->persistent_admin_notice_manager = $this->loader->getShared( |
|
252 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
253 | + ); |
|
254 | + $this->persistent_admin_notice_manager->setReturnUrl( |
|
255 | + EE_Admin_Page::add_query_args_and_nonce( |
|
256 | + array( |
|
257 | + 'page' => $this->request->getRequestParam('page', ''), |
|
258 | + 'action' => $this->request->getRequestParam('action', ''), |
|
259 | + ), |
|
260 | + EE_ADMIN_URL |
|
261 | + ) |
|
262 | + ); |
|
263 | + $this->maybeSetDatetimeWarningNotice(); |
|
264 | + // at a glance dashboard widget |
|
265 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
266 | + // filter for get_edit_post_link used on comments for custom post types |
|
267 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * get_persistent_admin_notices |
|
273 | + * |
|
274 | + * @access public |
|
275 | + * @return void |
|
276 | + * @throws EE_Error |
|
277 | + * @throws InvalidArgumentException |
|
278 | + * @throws InvalidDataTypeException |
|
279 | + * @throws InvalidInterfaceException |
|
280 | + */ |
|
281 | + public function maybeSetDatetimeWarningNotice() |
|
282 | + { |
|
283 | + // add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
284 | + // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
285 | + // with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
286 | + // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
287 | + if ( |
|
288 | + apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
289 | + && ! get_option('timezone_string') |
|
290 | + && EEM_Event::instance()->count() > 0 |
|
291 | + ) { |
|
292 | + new PersistentAdminNotice( |
|
293 | + 'datetime_fix_notice', |
|
294 | + sprintf( |
|
295 | + esc_html__( |
|
296 | + '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
297 | + 'event_espresso' |
|
298 | + ), |
|
299 | + '<strong>', |
|
300 | + '</strong>', |
|
301 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
302 | + '</a>', |
|
303 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
304 | + array( |
|
305 | + 'page' => 'espresso_maintenance_settings', |
|
306 | + 'action' => 'datetime_tools', |
|
307 | + ), |
|
308 | + admin_url('admin.php') |
|
309 | + ) . '">' |
|
310 | + ), |
|
311 | + false, |
|
312 | + 'manage_options', |
|
313 | + 'datetime_fix_persistent_notice' |
|
314 | + ); |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
321 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
322 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
323 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
324 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
325 | + * |
|
326 | + * @param WP_Post $post_type WP post type object |
|
327 | + * @return WP_Post |
|
328 | + * @throws InvalidArgumentException |
|
329 | + * @throws InvalidDataTypeException |
|
330 | + * @throws InvalidInterfaceException |
|
331 | + */ |
|
332 | + public function remove_pages_from_nav_menu($post_type) |
|
333 | + { |
|
334 | + // if this isn't the "pages" post type let's get out |
|
335 | + if ($post_type->name !== 'page') { |
|
336 | + return $post_type; |
|
337 | + } |
|
338 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
339 | + $post_type->_default_query = array( |
|
340 | + 'post__not_in' => $critical_pages, |
|
341 | + ); |
|
342 | + return $post_type; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
348 | + * metaboxes get shown as well |
|
349 | + * |
|
350 | + * @return void |
|
351 | + */ |
|
352 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
353 | + { |
|
354 | + global $wp_meta_boxes, $pagenow; |
|
355 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
356 | + return; |
|
357 | + } |
|
358 | + $user = wp_get_current_user(); |
|
359 | + // has this been done yet? |
|
360 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
361 | + return; |
|
362 | + } |
|
363 | + |
|
364 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
365 | + $initial_meta_boxes = apply_filters( |
|
366 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
367 | + array( |
|
368 | + 'nav-menu-theme-locations', |
|
369 | + 'add-page', |
|
370 | + 'add-custom-links', |
|
371 | + 'add-category', |
|
372 | + 'add-espresso_events', |
|
373 | + 'add-espresso_venues', |
|
374 | + 'add-espresso_event_categories', |
|
375 | + 'add-espresso_venue_categories', |
|
376 | + 'add-post-type-post', |
|
377 | + 'add-post-type-page', |
|
378 | + ) |
|
379 | + ); |
|
380 | + |
|
381 | + if (is_array($hidden_meta_boxes)) { |
|
382 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
383 | + if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
384 | + unset($hidden_meta_boxes[ $key ]); |
|
385 | + } |
|
386 | + } |
|
387 | + } |
|
388 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
389 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
395 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
396 | + * |
|
397 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
398 | + * addons etc. |
|
399 | + * @return void |
|
400 | + */ |
|
401 | + public function register_custom_nav_menu_boxes() |
|
402 | + { |
|
403 | + add_meta_box( |
|
404 | + 'add-extra-nav-menu-pages', |
|
405 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
406 | + array($this, 'ee_cpt_archive_pages'), |
|
407 | + 'nav-menus', |
|
408 | + 'side', |
|
409 | + 'core' |
|
410 | + ); |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
416 | + * |
|
417 | + * @since 4.3.0 |
|
418 | + * @param string $link the original link generated by wp |
|
419 | + * @param int $id post id |
|
420 | + * @return string the (maybe) modified link |
|
421 | + */ |
|
422 | + public function modify_edit_post_link($link, $id) |
|
423 | + { |
|
424 | + if (! $post = get_post($id)) { |
|
425 | + return $link; |
|
426 | + } |
|
427 | + if ($post->post_type === 'espresso_attendees') { |
|
428 | + $query_args = array( |
|
429 | + 'action' => 'edit_attendee', |
|
430 | + 'post' => $id, |
|
431 | + ); |
|
432 | + return EEH_URL::add_query_args_and_nonce( |
|
433 | + $query_args, |
|
434 | + admin_url('admin.php?page=espresso_registrations') |
|
435 | + ); |
|
436 | + } |
|
437 | + return $link; |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + public function ee_cpt_archive_pages() |
|
442 | + { |
|
443 | + global $nav_menu_selected_id; |
|
444 | + $db_fields = false; |
|
445 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
446 | + $current_tab = 'event-archives'; |
|
447 | + $removed_args = array( |
|
448 | + 'action', |
|
449 | + 'customlink-tab', |
|
450 | + 'edit-menu-item', |
|
451 | + 'menu-item', |
|
452 | + 'page-tab', |
|
453 | + '_wpnonce', |
|
454 | + ); |
|
455 | + ?> |
|
456 | 456 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
457 | 457 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
458 | 458 | <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
459 | 459 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" |
460 | 460 | href="<?php |
461 | - if ($nav_menu_selected_id) { |
|
462 | - echo esc_url( |
|
463 | - add_query_arg( |
|
464 | - 'extra-nav-menu-pages-tab', |
|
465 | - 'event-archives', |
|
466 | - remove_query_arg($removed_args) |
|
467 | - ) |
|
468 | - ); |
|
469 | - } |
|
470 | - ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
461 | + if ($nav_menu_selected_id) { |
|
462 | + echo esc_url( |
|
463 | + add_query_arg( |
|
464 | + 'extra-nav-menu-pages-tab', |
|
465 | + 'event-archives', |
|
466 | + remove_query_arg($removed_args) |
|
467 | + ) |
|
468 | + ); |
|
469 | + } |
|
470 | + ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
471 | 471 | <?php esc_html_e('Event Archive Pages', 'event_espresso'); ?> |
472 | 472 | </a> |
473 | 473 | </li> |
474 | 474 | </ul><!-- .posttype-tabs --> |
475 | 475 | |
476 | 476 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
477 | - echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
478 | - ?>"> |
|
477 | + echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
478 | + ?>"> |
|
479 | 479 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
480 | 480 | <?php |
481 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
482 | - $args['walker'] = $walker; |
|
483 | - echo walk_nav_menu_tree( |
|
484 | - array_map( |
|
485 | - array($this, '_setup_extra_nav_menu_pages_items'), |
|
486 | - $pages |
|
487 | - ), |
|
488 | - 0, |
|
489 | - (object) $args |
|
490 | - ); |
|
491 | - ?> |
|
481 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
482 | + $args['walker'] = $walker; |
|
483 | + echo walk_nav_menu_tree( |
|
484 | + array_map( |
|
485 | + array($this, '_setup_extra_nav_menu_pages_items'), |
|
486 | + $pages |
|
487 | + ), |
|
488 | + 0, |
|
489 | + (object) $args |
|
490 | + ); |
|
491 | + ?> |
|
492 | 492 | </ul> |
493 | 493 | </div><!-- /.tabs-panel --> |
494 | 494 | |
495 | 495 | <p class="button-controls"> |
496 | 496 | <span class="list-controls"> |
497 | 497 | <a href="<?php |
498 | - echo esc_url( |
|
499 | - add_query_arg( |
|
500 | - array( |
|
501 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
502 | - 'selectall' => 1, |
|
503 | - ), |
|
504 | - remove_query_arg($removed_args) |
|
505 | - ) |
|
506 | - ); |
|
507 | - ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a> |
|
498 | + echo esc_url( |
|
499 | + add_query_arg( |
|
500 | + array( |
|
501 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
502 | + 'selectall' => 1, |
|
503 | + ), |
|
504 | + remove_query_arg($removed_args) |
|
505 | + ) |
|
506 | + ); |
|
507 | + ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a> |
|
508 | 508 | </span> |
509 | 509 | <span class="add-to-menu"> |
510 | 510 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> |
@@ -517,529 +517,529 @@ discard block |
||
517 | 517 | |
518 | 518 | </div><!-- /.posttypediv --> |
519 | 519 | <?php |
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * Returns an array of event archive nav items. |
|
525 | - * |
|
526 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
527 | - * method we use for getting the extra nav menu items |
|
528 | - * @return array |
|
529 | - */ |
|
530 | - private function _get_extra_nav_menu_pages_items() |
|
531 | - { |
|
532 | - $menuitems[] = array( |
|
533 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
534 | - 'url' => get_post_type_archive_link('espresso_events'), |
|
535 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
536 | - ); |
|
537 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
538 | - } |
|
539 | - |
|
540 | - |
|
541 | - /** |
|
542 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
543 | - * the properties and converts it to the menu item object. |
|
544 | - * |
|
545 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
546 | - * @param $menu_item_values |
|
547 | - * @return stdClass |
|
548 | - */ |
|
549 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
550 | - { |
|
551 | - $menu_item = new stdClass(); |
|
552 | - $keys = array( |
|
553 | - 'ID' => 0, |
|
554 | - 'db_id' => 0, |
|
555 | - 'menu_item_parent' => 0, |
|
556 | - 'object_id' => -1, |
|
557 | - 'post_parent' => 0, |
|
558 | - 'type' => 'custom', |
|
559 | - 'object' => '', |
|
560 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
561 | - 'title' => '', |
|
562 | - 'url' => '', |
|
563 | - 'target' => '', |
|
564 | - 'attr_title' => '', |
|
565 | - 'description' => '', |
|
566 | - 'classes' => array(), |
|
567 | - 'xfn' => '', |
|
568 | - ); |
|
569 | - |
|
570 | - foreach ($keys as $key => $value) { |
|
571 | - $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; |
|
572 | - } |
|
573 | - return $menu_item; |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * admin_init |
|
579 | - * |
|
580 | - * @return void |
|
581 | - * @throws InvalidArgumentException |
|
582 | - * @throws InvalidDataTypeException |
|
583 | - * @throws InvalidInterfaceException |
|
584 | - */ |
|
585 | - public function admin_init() |
|
586 | - { |
|
587 | - /** |
|
588 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
589 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
590 | - * - check if doing post processing. |
|
591 | - * - check if doing post processing of one of EE CPTs |
|
592 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
593 | - */ |
|
594 | - if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
595 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
596 | - $custom_post_types = $this->loader->getShared( |
|
597 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
598 | - ); |
|
599 | - $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
|
600 | - } |
|
601 | - |
|
602 | - if (! $this->request->isAjax()) { |
|
603 | - /** |
|
604 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
605 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
606 | - * Pages" tab in the EE General Settings Admin page. |
|
607 | - * This is for user-proofing. |
|
608 | - */ |
|
609 | - add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
610 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
611 | - $this->adminInitModelsReady(); |
|
612 | - } |
|
613 | - } |
|
614 | - } |
|
615 | - |
|
616 | - |
|
617 | - /** |
|
618 | - * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode) |
|
619 | - */ |
|
620 | - protected function adminInitModelsReady() |
|
621 | - { |
|
622 | - if (function_exists('wp_add_privacy_policy_content')) { |
|
623 | - $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); |
|
624 | - } |
|
625 | - } |
|
626 | - |
|
627 | - |
|
628 | - /** |
|
629 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
630 | - * |
|
631 | - * @param string $output Current output. |
|
632 | - * @return string |
|
633 | - * @throws InvalidArgumentException |
|
634 | - * @throws InvalidDataTypeException |
|
635 | - * @throws InvalidInterfaceException |
|
636 | - */ |
|
637 | - public function modify_dropdown_pages($output) |
|
638 | - { |
|
639 | - // get critical pages |
|
640 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
641 | - |
|
642 | - // split current output by line break for easier parsing. |
|
643 | - $split_output = explode("\n", $output); |
|
644 | - |
|
645 | - // loop through to remove any critical pages from the array. |
|
646 | - foreach ($critical_pages as $page_id) { |
|
647 | - $needle = 'value="' . $page_id . '"'; |
|
648 | - foreach ($split_output as $key => $haystack) { |
|
649 | - if (strpos($haystack, $needle) !== false) { |
|
650 | - unset($split_output[ $key ]); |
|
651 | - } |
|
652 | - } |
|
653 | - } |
|
654 | - // replace output with the new contents |
|
655 | - return implode("\n", $split_output); |
|
656 | - } |
|
657 | - |
|
658 | - |
|
659 | - /** |
|
660 | - * display_admin_notices |
|
661 | - * |
|
662 | - * @return void |
|
663 | - */ |
|
664 | - public function display_admin_notices() |
|
665 | - { |
|
666 | - echo EE_Error::get_notices(); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * @param array $elements |
|
672 | - * @return array |
|
673 | - * @throws EE_Error |
|
674 | - * @throws InvalidArgumentException |
|
675 | - * @throws InvalidDataTypeException |
|
676 | - * @throws InvalidInterfaceException |
|
677 | - */ |
|
678 | - public function dashboard_glance_items($elements) |
|
679 | - { |
|
680 | - $elements = is_array($elements) ? $elements : array($elements); |
|
681 | - $events = EEM_Event::instance()->count(); |
|
682 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
683 | - array('page' => 'espresso_events'), |
|
684 | - admin_url('admin.php') |
|
685 | - ); |
|
686 | - $items['events']['text'] = sprintf( |
|
687 | - esc_html( |
|
688 | - _n('%s Event', '%s Events', $events, 'event_espresso') |
|
689 | - ), |
|
690 | - number_format_i18n($events) |
|
691 | - ); |
|
692 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
693 | - $registrations = EEM_Registration::instance()->count( |
|
694 | - array( |
|
695 | - array( |
|
696 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
697 | - ), |
|
698 | - ) |
|
699 | - ); |
|
700 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
701 | - array('page' => 'espresso_registrations'), |
|
702 | - admin_url('admin.php') |
|
703 | - ); |
|
704 | - $items['registrations']['text'] = sprintf( |
|
705 | - esc_html( |
|
706 | - _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
|
707 | - ), |
|
708 | - number_format_i18n($registrations) |
|
709 | - ); |
|
710 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
711 | - |
|
712 | - $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
713 | - |
|
714 | - foreach ($items as $type => $item_properties) { |
|
715 | - $elements[] = sprintf( |
|
716 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
717 | - $item_properties['url'], |
|
718 | - $item_properties['title'], |
|
719 | - $item_properties['text'] |
|
720 | - ); |
|
721 | - } |
|
722 | - return $elements; |
|
723 | - } |
|
724 | - |
|
725 | - |
|
726 | - /** |
|
727 | - * check_for_invalid_datetime_formats |
|
728 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
729 | - * their selected format can be parsed by PHP |
|
730 | - * |
|
731 | - * @param $value |
|
732 | - * @param $option |
|
733 | - * @return string |
|
734 | - */ |
|
735 | - public function check_for_invalid_datetime_formats($value, $option) |
|
736 | - { |
|
737 | - // check for date_format or time_format |
|
738 | - switch ($option) { |
|
739 | - case 'date_format': |
|
740 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
741 | - break; |
|
742 | - case 'time_format': |
|
743 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
744 | - break; |
|
745 | - default: |
|
746 | - $date_time_format = false; |
|
747 | - } |
|
748 | - // do we have a date_time format to check ? |
|
749 | - if ($date_time_format) { |
|
750 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
751 | - |
|
752 | - if (is_array($error_msg)) { |
|
753 | - $msg = '<p>' |
|
754 | - . sprintf( |
|
755 | - esc_html__( |
|
756 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
757 | - 'event_espresso' |
|
758 | - ), |
|
759 | - date($date_time_format), |
|
760 | - $date_time_format |
|
761 | - ) |
|
762 | - . '</p><p><ul>'; |
|
763 | - |
|
764 | - |
|
765 | - foreach ($error_msg as $error) { |
|
766 | - $msg .= '<li>' . $error . '</li>'; |
|
767 | - } |
|
768 | - |
|
769 | - $msg .= '</ul></p><p>' |
|
770 | - . sprintf( |
|
771 | - esc_html__( |
|
772 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
773 | - 'event_espresso' |
|
774 | - ), |
|
775 | - '<span style="color:#D54E21;">', |
|
776 | - '</span>' |
|
777 | - ) |
|
778 | - . '</p>'; |
|
779 | - |
|
780 | - // trigger WP settings error |
|
781 | - add_settings_error( |
|
782 | - 'date_format', |
|
783 | - 'date_format', |
|
784 | - $msg |
|
785 | - ); |
|
786 | - |
|
787 | - // set format to something valid |
|
788 | - switch ($option) { |
|
789 | - case 'date_format': |
|
790 | - $value = 'F j, Y'; |
|
791 | - break; |
|
792 | - case 'time_format': |
|
793 | - $value = 'g:i a'; |
|
794 | - break; |
|
795 | - } |
|
796 | - } |
|
797 | - } |
|
798 | - return $value; |
|
799 | - } |
|
800 | - |
|
801 | - |
|
802 | - /** |
|
803 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
804 | - * |
|
805 | - * @param $content |
|
806 | - * @return string |
|
807 | - */ |
|
808 | - public function its_eSpresso($content) |
|
809 | - { |
|
810 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
811 | - } |
|
812 | - |
|
813 | - |
|
814 | - /** |
|
815 | - * espresso_admin_footer |
|
816 | - * |
|
817 | - * @return string |
|
818 | - */ |
|
819 | - public function espresso_admin_footer() |
|
820 | - { |
|
821 | - return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - /** |
|
826 | - * Hooks into the "post states" filter in a wp post type list table. |
|
827 | - * |
|
828 | - * @param array $post_states |
|
829 | - * @param WP_Post $post |
|
830 | - * @return array |
|
831 | - * @throws InvalidArgumentException |
|
832 | - * @throws InvalidDataTypeException |
|
833 | - * @throws InvalidInterfaceException |
|
834 | - */ |
|
835 | - public function displayStateForCriticalPages($post_states, $post) |
|
836 | - { |
|
837 | - $post_states = (array) $post_states; |
|
838 | - if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
839 | - return $post_states; |
|
840 | - } |
|
841 | - /** @var EE_Core_Config $config */ |
|
842 | - $config = $this->loader->getShared('EE_Config')->core; |
|
843 | - if (in_array($post->ID, $config->get_critical_pages_array(), true)) { |
|
844 | - $post_states[] = sprintf( |
|
845 | - /* Translators: Using company name - Event Espresso Critical Page */ |
|
846 | - esc_html__('%s Critical Page', 'event_espresso'), |
|
847 | - 'Event Espresso' |
|
848 | - ); |
|
849 | - } |
|
850 | - return $post_states; |
|
851 | - } |
|
852 | - |
|
853 | - |
|
854 | - /** |
|
855 | - * Show documentation links on the plugins page |
|
856 | - * |
|
857 | - * @param mixed $meta Plugin Row Meta |
|
858 | - * @param mixed $file Plugin Base file |
|
859 | - * @return array |
|
860 | - */ |
|
861 | - public function addLinksToPluginRowMeta($meta, $file) |
|
862 | - { |
|
863 | - if (EE_PLUGIN_BASENAME === $file) { |
|
864 | - $row_meta = array( |
|
865 | - 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"' |
|
866 | - . ' aria-label="' |
|
867 | - . esc_attr__('View Event Espresso documentation', 'event_espresso') |
|
868 | - . '">' |
|
869 | - . esc_html__('Docs', 'event_espresso') |
|
870 | - . '</a>', |
|
871 | - 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"' |
|
872 | - . ' aria-label="' |
|
873 | - . esc_attr__('View Event Espresso API docs', 'event_espresso') |
|
874 | - . '">' |
|
875 | - . esc_html__('API docs', 'event_espresso') |
|
876 | - . '</a>', |
|
877 | - ); |
|
878 | - return array_merge($meta, $row_meta); |
|
879 | - } |
|
880 | - return (array) $meta; |
|
881 | - } |
|
882 | - |
|
883 | - /**************************************************************************************/ |
|
884 | - /************************************* DEPRECATED *************************************/ |
|
885 | - /**************************************************************************************/ |
|
886 | - |
|
887 | - |
|
888 | - /** |
|
889 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
890 | - * EE_Admin_Page route is called. |
|
891 | - * |
|
892 | - * @return void |
|
893 | - */ |
|
894 | - public function route_admin_request() |
|
895 | - { |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
901 | - * |
|
902 | - * @return void |
|
903 | - */ |
|
904 | - public function wp_loaded() |
|
905 | - { |
|
906 | - } |
|
907 | - |
|
908 | - |
|
909 | - /** |
|
910 | - * static method for registering ee admin page. |
|
911 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
912 | - * |
|
913 | - * @param $page_basename |
|
914 | - * @param $page_path |
|
915 | - * @param array $config |
|
916 | - * @return void |
|
917 | - * @throws EE_Error |
|
918 | - * @see EE_Register_Admin_Page::register() |
|
919 | - * @since 4.3.0 |
|
920 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
921 | - */ |
|
922 | - public static function register_ee_admin_page($page_basename, $page_path, $config = []) |
|
923 | - { |
|
924 | - EE_Error::doing_it_wrong( |
|
925 | - __METHOD__, |
|
926 | - sprintf( |
|
927 | - esc_html__( |
|
928 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
929 | - 'event_espresso' |
|
930 | - ), |
|
931 | - $page_basename |
|
932 | - ), |
|
933 | - '4.3' |
|
934 | - ); |
|
935 | - if (class_exists('EE_Register_Admin_Page')) { |
|
936 | - $config['page_path'] = $page_path; |
|
937 | - } |
|
938 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
939 | - } |
|
940 | - |
|
941 | - |
|
942 | - /** |
|
943 | - * @param int $post_ID |
|
944 | - * @param \WP_Post $post |
|
945 | - * @return void |
|
946 | - * @deprecated 4.8.41 |
|
947 | - */ |
|
948 | - public static function parse_post_content_on_save($post_ID, $post) |
|
949 | - { |
|
950 | - EE_Error::doing_it_wrong( |
|
951 | - __METHOD__, |
|
952 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
953 | - '4.8.41' |
|
954 | - ); |
|
955 | - } |
|
956 | - |
|
957 | - |
|
958 | - /** |
|
959 | - * @param $option |
|
960 | - * @param $old_value |
|
961 | - * @param $value |
|
962 | - * @return void |
|
963 | - * @deprecated 4.8.41 |
|
964 | - */ |
|
965 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
966 | - { |
|
967 | - EE_Error::doing_it_wrong( |
|
968 | - __METHOD__, |
|
969 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
970 | - '4.8.41' |
|
971 | - ); |
|
972 | - } |
|
973 | - |
|
974 | - |
|
975 | - /** |
|
976 | - * @return void |
|
977 | - * @deprecated 4.9.27 |
|
978 | - */ |
|
979 | - public function get_persistent_admin_notices() |
|
980 | - { |
|
981 | - EE_Error::doing_it_wrong( |
|
982 | - __METHOD__, |
|
983 | - sprintf( |
|
984 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
985 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
986 | - ), |
|
987 | - '4.9.27' |
|
988 | - ); |
|
989 | - } |
|
990 | - |
|
991 | - |
|
992 | - /** |
|
993 | - * @throws InvalidInterfaceException |
|
994 | - * @throws InvalidDataTypeException |
|
995 | - * @throws DomainException |
|
996 | - * @deprecated 4.9.27 |
|
997 | - */ |
|
998 | - public function dismiss_ee_nag_notice_callback() |
|
999 | - { |
|
1000 | - EE_Error::doing_it_wrong( |
|
1001 | - __METHOD__, |
|
1002 | - sprintf( |
|
1003 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1004 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1005 | - ), |
|
1006 | - '4.9.27' |
|
1007 | - ); |
|
1008 | - $this->persistent_admin_notice_manager->dismissNotice(); |
|
1009 | - } |
|
1010 | - |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * @return void |
|
1014 | - * @deprecated $VID:$ |
|
1015 | - */ |
|
1016 | - public function enqueue_admin_scripts() |
|
1017 | - { |
|
1018 | - } |
|
1019 | - |
|
1020 | - |
|
1021 | - |
|
1022 | - /** |
|
1023 | - * @return RequestInterface |
|
1024 | - * @deprecated $VID:$ |
|
1025 | - */ |
|
1026 | - public function get_request() |
|
1027 | - { |
|
1028 | - EE_Error::doing_it_wrong( |
|
1029 | - __METHOD__, |
|
1030 | - sprintf( |
|
1031 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1032 | - 'EventEspresso\core\services\request\Request' |
|
1033 | - ), |
|
1034 | - '$VID:$' |
|
1035 | - ); |
|
1036 | - return $this->request; |
|
1037 | - } |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * @deprecated $VID:$ |
|
1041 | - */ |
|
1042 | - public function hookIntoWpPluginsPage() |
|
1043 | - { |
|
1044 | - } |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * Returns an array of event archive nav items. |
|
525 | + * |
|
526 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
527 | + * method we use for getting the extra nav menu items |
|
528 | + * @return array |
|
529 | + */ |
|
530 | + private function _get_extra_nav_menu_pages_items() |
|
531 | + { |
|
532 | + $menuitems[] = array( |
|
533 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
534 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
535 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
536 | + ); |
|
537 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
538 | + } |
|
539 | + |
|
540 | + |
|
541 | + /** |
|
542 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
543 | + * the properties and converts it to the menu item object. |
|
544 | + * |
|
545 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
546 | + * @param $menu_item_values |
|
547 | + * @return stdClass |
|
548 | + */ |
|
549 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
550 | + { |
|
551 | + $menu_item = new stdClass(); |
|
552 | + $keys = array( |
|
553 | + 'ID' => 0, |
|
554 | + 'db_id' => 0, |
|
555 | + 'menu_item_parent' => 0, |
|
556 | + 'object_id' => -1, |
|
557 | + 'post_parent' => 0, |
|
558 | + 'type' => 'custom', |
|
559 | + 'object' => '', |
|
560 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
561 | + 'title' => '', |
|
562 | + 'url' => '', |
|
563 | + 'target' => '', |
|
564 | + 'attr_title' => '', |
|
565 | + 'description' => '', |
|
566 | + 'classes' => array(), |
|
567 | + 'xfn' => '', |
|
568 | + ); |
|
569 | + |
|
570 | + foreach ($keys as $key => $value) { |
|
571 | + $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; |
|
572 | + } |
|
573 | + return $menu_item; |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * admin_init |
|
579 | + * |
|
580 | + * @return void |
|
581 | + * @throws InvalidArgumentException |
|
582 | + * @throws InvalidDataTypeException |
|
583 | + * @throws InvalidInterfaceException |
|
584 | + */ |
|
585 | + public function admin_init() |
|
586 | + { |
|
587 | + /** |
|
588 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
589 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
590 | + * - check if doing post processing. |
|
591 | + * - check if doing post processing of one of EE CPTs |
|
592 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
593 | + */ |
|
594 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
595 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
596 | + $custom_post_types = $this->loader->getShared( |
|
597 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
598 | + ); |
|
599 | + $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
|
600 | + } |
|
601 | + |
|
602 | + if (! $this->request->isAjax()) { |
|
603 | + /** |
|
604 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
605 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
606 | + * Pages" tab in the EE General Settings Admin page. |
|
607 | + * This is for user-proofing. |
|
608 | + */ |
|
609 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
610 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
611 | + $this->adminInitModelsReady(); |
|
612 | + } |
|
613 | + } |
|
614 | + } |
|
615 | + |
|
616 | + |
|
617 | + /** |
|
618 | + * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode) |
|
619 | + */ |
|
620 | + protected function adminInitModelsReady() |
|
621 | + { |
|
622 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
623 | + $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); |
|
624 | + } |
|
625 | + } |
|
626 | + |
|
627 | + |
|
628 | + /** |
|
629 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
630 | + * |
|
631 | + * @param string $output Current output. |
|
632 | + * @return string |
|
633 | + * @throws InvalidArgumentException |
|
634 | + * @throws InvalidDataTypeException |
|
635 | + * @throws InvalidInterfaceException |
|
636 | + */ |
|
637 | + public function modify_dropdown_pages($output) |
|
638 | + { |
|
639 | + // get critical pages |
|
640 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
641 | + |
|
642 | + // split current output by line break for easier parsing. |
|
643 | + $split_output = explode("\n", $output); |
|
644 | + |
|
645 | + // loop through to remove any critical pages from the array. |
|
646 | + foreach ($critical_pages as $page_id) { |
|
647 | + $needle = 'value="' . $page_id . '"'; |
|
648 | + foreach ($split_output as $key => $haystack) { |
|
649 | + if (strpos($haystack, $needle) !== false) { |
|
650 | + unset($split_output[ $key ]); |
|
651 | + } |
|
652 | + } |
|
653 | + } |
|
654 | + // replace output with the new contents |
|
655 | + return implode("\n", $split_output); |
|
656 | + } |
|
657 | + |
|
658 | + |
|
659 | + /** |
|
660 | + * display_admin_notices |
|
661 | + * |
|
662 | + * @return void |
|
663 | + */ |
|
664 | + public function display_admin_notices() |
|
665 | + { |
|
666 | + echo EE_Error::get_notices(); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * @param array $elements |
|
672 | + * @return array |
|
673 | + * @throws EE_Error |
|
674 | + * @throws InvalidArgumentException |
|
675 | + * @throws InvalidDataTypeException |
|
676 | + * @throws InvalidInterfaceException |
|
677 | + */ |
|
678 | + public function dashboard_glance_items($elements) |
|
679 | + { |
|
680 | + $elements = is_array($elements) ? $elements : array($elements); |
|
681 | + $events = EEM_Event::instance()->count(); |
|
682 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
683 | + array('page' => 'espresso_events'), |
|
684 | + admin_url('admin.php') |
|
685 | + ); |
|
686 | + $items['events']['text'] = sprintf( |
|
687 | + esc_html( |
|
688 | + _n('%s Event', '%s Events', $events, 'event_espresso') |
|
689 | + ), |
|
690 | + number_format_i18n($events) |
|
691 | + ); |
|
692 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
693 | + $registrations = EEM_Registration::instance()->count( |
|
694 | + array( |
|
695 | + array( |
|
696 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
697 | + ), |
|
698 | + ) |
|
699 | + ); |
|
700 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
701 | + array('page' => 'espresso_registrations'), |
|
702 | + admin_url('admin.php') |
|
703 | + ); |
|
704 | + $items['registrations']['text'] = sprintf( |
|
705 | + esc_html( |
|
706 | + _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
|
707 | + ), |
|
708 | + number_format_i18n($registrations) |
|
709 | + ); |
|
710 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
711 | + |
|
712 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
713 | + |
|
714 | + foreach ($items as $type => $item_properties) { |
|
715 | + $elements[] = sprintf( |
|
716 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
717 | + $item_properties['url'], |
|
718 | + $item_properties['title'], |
|
719 | + $item_properties['text'] |
|
720 | + ); |
|
721 | + } |
|
722 | + return $elements; |
|
723 | + } |
|
724 | + |
|
725 | + |
|
726 | + /** |
|
727 | + * check_for_invalid_datetime_formats |
|
728 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
729 | + * their selected format can be parsed by PHP |
|
730 | + * |
|
731 | + * @param $value |
|
732 | + * @param $option |
|
733 | + * @return string |
|
734 | + */ |
|
735 | + public function check_for_invalid_datetime_formats($value, $option) |
|
736 | + { |
|
737 | + // check for date_format or time_format |
|
738 | + switch ($option) { |
|
739 | + case 'date_format': |
|
740 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
741 | + break; |
|
742 | + case 'time_format': |
|
743 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
744 | + break; |
|
745 | + default: |
|
746 | + $date_time_format = false; |
|
747 | + } |
|
748 | + // do we have a date_time format to check ? |
|
749 | + if ($date_time_format) { |
|
750 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
751 | + |
|
752 | + if (is_array($error_msg)) { |
|
753 | + $msg = '<p>' |
|
754 | + . sprintf( |
|
755 | + esc_html__( |
|
756 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
757 | + 'event_espresso' |
|
758 | + ), |
|
759 | + date($date_time_format), |
|
760 | + $date_time_format |
|
761 | + ) |
|
762 | + . '</p><p><ul>'; |
|
763 | + |
|
764 | + |
|
765 | + foreach ($error_msg as $error) { |
|
766 | + $msg .= '<li>' . $error . '</li>'; |
|
767 | + } |
|
768 | + |
|
769 | + $msg .= '</ul></p><p>' |
|
770 | + . sprintf( |
|
771 | + esc_html__( |
|
772 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
773 | + 'event_espresso' |
|
774 | + ), |
|
775 | + '<span style="color:#D54E21;">', |
|
776 | + '</span>' |
|
777 | + ) |
|
778 | + . '</p>'; |
|
779 | + |
|
780 | + // trigger WP settings error |
|
781 | + add_settings_error( |
|
782 | + 'date_format', |
|
783 | + 'date_format', |
|
784 | + $msg |
|
785 | + ); |
|
786 | + |
|
787 | + // set format to something valid |
|
788 | + switch ($option) { |
|
789 | + case 'date_format': |
|
790 | + $value = 'F j, Y'; |
|
791 | + break; |
|
792 | + case 'time_format': |
|
793 | + $value = 'g:i a'; |
|
794 | + break; |
|
795 | + } |
|
796 | + } |
|
797 | + } |
|
798 | + return $value; |
|
799 | + } |
|
800 | + |
|
801 | + |
|
802 | + /** |
|
803 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
804 | + * |
|
805 | + * @param $content |
|
806 | + * @return string |
|
807 | + */ |
|
808 | + public function its_eSpresso($content) |
|
809 | + { |
|
810 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
811 | + } |
|
812 | + |
|
813 | + |
|
814 | + /** |
|
815 | + * espresso_admin_footer |
|
816 | + * |
|
817 | + * @return string |
|
818 | + */ |
|
819 | + public function espresso_admin_footer() |
|
820 | + { |
|
821 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + /** |
|
826 | + * Hooks into the "post states" filter in a wp post type list table. |
|
827 | + * |
|
828 | + * @param array $post_states |
|
829 | + * @param WP_Post $post |
|
830 | + * @return array |
|
831 | + * @throws InvalidArgumentException |
|
832 | + * @throws InvalidDataTypeException |
|
833 | + * @throws InvalidInterfaceException |
|
834 | + */ |
|
835 | + public function displayStateForCriticalPages($post_states, $post) |
|
836 | + { |
|
837 | + $post_states = (array) $post_states; |
|
838 | + if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
839 | + return $post_states; |
|
840 | + } |
|
841 | + /** @var EE_Core_Config $config */ |
|
842 | + $config = $this->loader->getShared('EE_Config')->core; |
|
843 | + if (in_array($post->ID, $config->get_critical_pages_array(), true)) { |
|
844 | + $post_states[] = sprintf( |
|
845 | + /* Translators: Using company name - Event Espresso Critical Page */ |
|
846 | + esc_html__('%s Critical Page', 'event_espresso'), |
|
847 | + 'Event Espresso' |
|
848 | + ); |
|
849 | + } |
|
850 | + return $post_states; |
|
851 | + } |
|
852 | + |
|
853 | + |
|
854 | + /** |
|
855 | + * Show documentation links on the plugins page |
|
856 | + * |
|
857 | + * @param mixed $meta Plugin Row Meta |
|
858 | + * @param mixed $file Plugin Base file |
|
859 | + * @return array |
|
860 | + */ |
|
861 | + public function addLinksToPluginRowMeta($meta, $file) |
|
862 | + { |
|
863 | + if (EE_PLUGIN_BASENAME === $file) { |
|
864 | + $row_meta = array( |
|
865 | + 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"' |
|
866 | + . ' aria-label="' |
|
867 | + . esc_attr__('View Event Espresso documentation', 'event_espresso') |
|
868 | + . '">' |
|
869 | + . esc_html__('Docs', 'event_espresso') |
|
870 | + . '</a>', |
|
871 | + 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"' |
|
872 | + . ' aria-label="' |
|
873 | + . esc_attr__('View Event Espresso API docs', 'event_espresso') |
|
874 | + . '">' |
|
875 | + . esc_html__('API docs', 'event_espresso') |
|
876 | + . '</a>', |
|
877 | + ); |
|
878 | + return array_merge($meta, $row_meta); |
|
879 | + } |
|
880 | + return (array) $meta; |
|
881 | + } |
|
882 | + |
|
883 | + /**************************************************************************************/ |
|
884 | + /************************************* DEPRECATED *************************************/ |
|
885 | + /**************************************************************************************/ |
|
886 | + |
|
887 | + |
|
888 | + /** |
|
889 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
890 | + * EE_Admin_Page route is called. |
|
891 | + * |
|
892 | + * @return void |
|
893 | + */ |
|
894 | + public function route_admin_request() |
|
895 | + { |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
901 | + * |
|
902 | + * @return void |
|
903 | + */ |
|
904 | + public function wp_loaded() |
|
905 | + { |
|
906 | + } |
|
907 | + |
|
908 | + |
|
909 | + /** |
|
910 | + * static method for registering ee admin page. |
|
911 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
912 | + * |
|
913 | + * @param $page_basename |
|
914 | + * @param $page_path |
|
915 | + * @param array $config |
|
916 | + * @return void |
|
917 | + * @throws EE_Error |
|
918 | + * @see EE_Register_Admin_Page::register() |
|
919 | + * @since 4.3.0 |
|
920 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
921 | + */ |
|
922 | + public static function register_ee_admin_page($page_basename, $page_path, $config = []) |
|
923 | + { |
|
924 | + EE_Error::doing_it_wrong( |
|
925 | + __METHOD__, |
|
926 | + sprintf( |
|
927 | + esc_html__( |
|
928 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
929 | + 'event_espresso' |
|
930 | + ), |
|
931 | + $page_basename |
|
932 | + ), |
|
933 | + '4.3' |
|
934 | + ); |
|
935 | + if (class_exists('EE_Register_Admin_Page')) { |
|
936 | + $config['page_path'] = $page_path; |
|
937 | + } |
|
938 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
939 | + } |
|
940 | + |
|
941 | + |
|
942 | + /** |
|
943 | + * @param int $post_ID |
|
944 | + * @param \WP_Post $post |
|
945 | + * @return void |
|
946 | + * @deprecated 4.8.41 |
|
947 | + */ |
|
948 | + public static function parse_post_content_on_save($post_ID, $post) |
|
949 | + { |
|
950 | + EE_Error::doing_it_wrong( |
|
951 | + __METHOD__, |
|
952 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
953 | + '4.8.41' |
|
954 | + ); |
|
955 | + } |
|
956 | + |
|
957 | + |
|
958 | + /** |
|
959 | + * @param $option |
|
960 | + * @param $old_value |
|
961 | + * @param $value |
|
962 | + * @return void |
|
963 | + * @deprecated 4.8.41 |
|
964 | + */ |
|
965 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
966 | + { |
|
967 | + EE_Error::doing_it_wrong( |
|
968 | + __METHOD__, |
|
969 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
970 | + '4.8.41' |
|
971 | + ); |
|
972 | + } |
|
973 | + |
|
974 | + |
|
975 | + /** |
|
976 | + * @return void |
|
977 | + * @deprecated 4.9.27 |
|
978 | + */ |
|
979 | + public function get_persistent_admin_notices() |
|
980 | + { |
|
981 | + EE_Error::doing_it_wrong( |
|
982 | + __METHOD__, |
|
983 | + sprintf( |
|
984 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
985 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
986 | + ), |
|
987 | + '4.9.27' |
|
988 | + ); |
|
989 | + } |
|
990 | + |
|
991 | + |
|
992 | + /** |
|
993 | + * @throws InvalidInterfaceException |
|
994 | + * @throws InvalidDataTypeException |
|
995 | + * @throws DomainException |
|
996 | + * @deprecated 4.9.27 |
|
997 | + */ |
|
998 | + public function dismiss_ee_nag_notice_callback() |
|
999 | + { |
|
1000 | + EE_Error::doing_it_wrong( |
|
1001 | + __METHOD__, |
|
1002 | + sprintf( |
|
1003 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1004 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1005 | + ), |
|
1006 | + '4.9.27' |
|
1007 | + ); |
|
1008 | + $this->persistent_admin_notice_manager->dismissNotice(); |
|
1009 | + } |
|
1010 | + |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * @return void |
|
1014 | + * @deprecated $VID:$ |
|
1015 | + */ |
|
1016 | + public function enqueue_admin_scripts() |
|
1017 | + { |
|
1018 | + } |
|
1019 | + |
|
1020 | + |
|
1021 | + |
|
1022 | + /** |
|
1023 | + * @return RequestInterface |
|
1024 | + * @deprecated $VID:$ |
|
1025 | + */ |
|
1026 | + public function get_request() |
|
1027 | + { |
|
1028 | + EE_Error::doing_it_wrong( |
|
1029 | + __METHOD__, |
|
1030 | + sprintf( |
|
1031 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1032 | + 'EventEspresso\core\services\request\Request' |
|
1033 | + ), |
|
1034 | + '$VID:$' |
|
1035 | + ); |
|
1036 | + return $this->request; |
|
1037 | + } |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * @deprecated $VID:$ |
|
1041 | + */ |
|
1042 | + public function hookIntoWpPluginsPage() |
|
1043 | + { |
|
1044 | + } |
|
1045 | 1045 | } |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | '_upload_to' => $this->_get_wp_uploads_dir(), |
66 | 66 | '_download_from' => '', |
67 | 67 | '_permissions' => 0644, |
68 | - '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default', |
|
68 | + '_new_file_name' => 'EE_Sideloader_'.uniqid().'.default', |
|
69 | 69 | ]; |
70 | 70 | |
71 | 71 | $props = array_merge($defaults, $init); |
72 | 72 | |
73 | 73 | foreach ($props as $property => $val) { |
74 | - $setter = 'set' . $property; |
|
74 | + $setter = 'set'.$property; |
|
75 | 75 | if (method_exists($this, $setter)) { |
76 | 76 | $this->$setter($val); |
77 | 77 | } else { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // make sure we include the required wp file for needed functions |
96 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
96 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // setup temp dir |
223 | 223 | $temp_file = wp_tempnam($this->_download_from); |
224 | 224 | |
225 | - if (! $temp_file) { |
|
225 | + if ( ! $temp_file) { |
|
226 | 226 | throw new RuntimeException( |
227 | 227 | esc_html__( |
228 | 228 | 'Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | // now we have the file, let's get it in the right directory with the right name. |
261 | - $path = apply_filters( |
|
261 | + $path = apply_filters( |
|
262 | 262 | 'FHEE__EEH_Sideloader__sideload__new_path', |
263 | - $this->_upload_to . $this->_new_file_name, |
|
263 | + $this->_upload_to.$this->_new_file_name, |
|
264 | 264 | $this |
265 | 265 | ); |
266 | - if (! EEH_File::move($temp_file, $path, true)) { |
|
266 | + if ( ! EEH_File::move($temp_file, $path, true)) { |
|
267 | 267 | return false; |
268 | 268 | } |
269 | 269 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | ); |
276 | 276 | // verify permissions are an integer but don't actually modify the value |
277 | 277 | $perms = absint($permissions); |
278 | - if (! $perms) { |
|
278 | + if ( ! $perms) { |
|
279 | 279 | EE_Error::add_error( |
280 | 280 | esc_html__('Supplied permissions are invalid', 'event_espresso'), |
281 | 281 | __FILE__, |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | private function isResponseError($response) |
307 | 307 | { |
308 | - if (! is_wp_error($response)) { |
|
308 | + if ( ! is_wp_error($response)) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | if (defined('WP_DEBUG') && WP_DEBUG) { |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | public function set_upload_from($upload_from) |
373 | 373 | { |
374 | 374 | EE_Error::doing_it_wrong( |
375 | - __CLASS__ . '::' . __FUNCTION__, |
|
375 | + __CLASS__.'::'.__FUNCTION__, |
|
376 | 376 | __( |
377 | 377 | 'EEH_Sideloader::set_upload_from was renamed to EEH_Sideloader::set_download_from', |
378 | 378 | 'event_espresso' |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | public function get_upload_from() |
392 | 392 | { |
393 | 393 | EE_Error::doing_it_wrong( |
394 | - __CLASS__ . '::' . __FUNCTION__, |
|
394 | + __CLASS__.'::'.__FUNCTION__, |
|
395 | 395 | __( |
396 | 396 | 'EEH_Sideloader::get_upload_from was renamed to EEH_Sideloader::get_download_from', |
397 | 397 | 'event_espresso' |
@@ -14,390 +14,390 @@ |
||
14 | 14 | class EEH_Sideloader extends EEH_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @since 4.1.0 |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - private $_upload_to; |
|
22 | - |
|
23 | - /** |
|
24 | - * @since 4.10.5.p |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - private $_download_from; |
|
28 | - |
|
29 | - /** |
|
30 | - * @since 4.1.0 |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - private $_permissions; |
|
34 | - |
|
35 | - /** |
|
36 | - * @since 4.1.0 |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - private $_new_file_name; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * constructor allows the user to set the properties on the sideloader on construct. However, there are also |
|
44 | - * setters for doing so. |
|
45 | - * |
|
46 | - * @param array $init array fo initializing the sideloader if keys match the properties. |
|
47 | - * @since 4.1.0 |
|
48 | - */ |
|
49 | - public function __construct($init = []) |
|
50 | - { |
|
51 | - $this->_init($init); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * sets the properties for class either to defaults or using incoming initialization array |
|
57 | - * |
|
58 | - * @param array $init array on init (keys match properties others ignored) |
|
59 | - * @return void |
|
60 | - * @since 4.1.0 |
|
61 | - */ |
|
62 | - private function _init($init) |
|
63 | - { |
|
64 | - $defaults = [ |
|
65 | - '_upload_to' => $this->_get_wp_uploads_dir(), |
|
66 | - '_download_from' => '', |
|
67 | - '_permissions' => 0644, |
|
68 | - '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default', |
|
69 | - ]; |
|
70 | - |
|
71 | - $props = array_merge($defaults, $init); |
|
72 | - |
|
73 | - foreach ($props as $property => $val) { |
|
74 | - $setter = 'set' . $property; |
|
75 | - if (method_exists($this, $setter)) { |
|
76 | - $this->$setter($val); |
|
77 | - } else { |
|
78 | - // No setter found. |
|
79 | - EE_Error::add_error( |
|
80 | - sprintf( |
|
81 | - esc_html__( |
|
82 | - 'EEH_Sideloader::%1$s not found. There is no setter for the %2$s property.', |
|
83 | - 'event_espresso' |
|
84 | - ), |
|
85 | - $setter, |
|
86 | - $property |
|
87 | - ), |
|
88 | - __FILE__, |
|
89 | - __FUNCTION__, |
|
90 | - __LINE__ |
|
91 | - ); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - // make sure we include the required wp file for needed functions |
|
96 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - // utilities |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @return string |
|
105 | - * @since 4.1.0 |
|
106 | - */ |
|
107 | - private function _get_wp_uploads_dir() |
|
108 | - { |
|
109 | - $uploads = wp_upload_dir(); |
|
110 | - return $uploads['basedir']; |
|
111 | - } |
|
112 | - |
|
113 | - // setters |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * sets the _upload_to property to the directory to upload to. |
|
118 | - * |
|
119 | - * @param $upload_to_folder |
|
120 | - * @return void |
|
121 | - * @since 4.1.0 |
|
122 | - */ |
|
123 | - public function set_upload_to($upload_to_folder) |
|
124 | - { |
|
125 | - $this->_upload_to = $upload_to_folder; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * sets the _download_from property to the location we should download the file from. |
|
131 | - * |
|
132 | - * @param string $download_from The full path to the file we should sideload. |
|
133 | - * @return void |
|
134 | - * @since 4.10.5.p |
|
135 | - */ |
|
136 | - public function set_download_from($download_from) |
|
137 | - { |
|
138 | - $this->_download_from = $download_from; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * sets the _permissions property used on the sideloaded file. |
|
144 | - * |
|
145 | - * @param int $permissions |
|
146 | - * @return void |
|
147 | - * @since 4.1.0 |
|
148 | - */ |
|
149 | - public function set_permissions($permissions) |
|
150 | - { |
|
151 | - $this->_permissions = $permissions; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * sets the _new_file_name property used on the sideloaded file. |
|
157 | - * |
|
158 | - * @param string $new_file_name |
|
159 | - * @return void |
|
160 | - * @since 4.1.0 |
|
161 | - */ |
|
162 | - public function set_new_file_name($new_file_name) |
|
163 | - { |
|
164 | - $this->_new_file_name = $new_file_name; |
|
165 | - } |
|
166 | - |
|
167 | - // getters |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @return string |
|
172 | - * @since 4.1.0 |
|
173 | - */ |
|
174 | - public function get_upload_to() |
|
175 | - { |
|
176 | - return $this->_upload_to; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * @return string |
|
182 | - * @since 4.10.5.p |
|
183 | - */ |
|
184 | - public function get_download_from() |
|
185 | - { |
|
186 | - return $this->_download_from; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * @return int |
|
192 | - * @since 4.1.0 |
|
193 | - */ |
|
194 | - public function get_permissions() |
|
195 | - { |
|
196 | - return $this->_permissions; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * @return string |
|
202 | - * @since 4.1.0 |
|
203 | - */ |
|
204 | - public function get_new_file_name() |
|
205 | - { |
|
206 | - return $this->_new_file_name; |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - // upload methods |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * Downloads the file using the WordPress HTTP API. |
|
215 | - * |
|
216 | - * @return bool |
|
217 | - * @since 4.1.0 |
|
218 | - */ |
|
219 | - public function sideload() |
|
220 | - { |
|
221 | - try { |
|
222 | - // setup temp dir |
|
223 | - $temp_file = wp_tempnam($this->_download_from); |
|
224 | - |
|
225 | - if (! $temp_file) { |
|
226 | - throw new RuntimeException( |
|
227 | - esc_html__( |
|
228 | - 'Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', |
|
229 | - 'event_espresso' |
|
230 | - ) |
|
231 | - ); |
|
232 | - } |
|
233 | - |
|
234 | - do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file); |
|
235 | - |
|
236 | - $wp_remote_args = apply_filters( |
|
237 | - 'FHEE__EEH_Sideloader__sideload__wp_remote_args', |
|
238 | - ['timeout' => 500, 'stream' => true, 'filename' => $temp_file], |
|
239 | - $this, |
|
240 | - $temp_file |
|
241 | - ); |
|
242 | - |
|
243 | - $response = wp_safe_remote_get($this->_download_from, $wp_remote_args); |
|
244 | - |
|
245 | - if ($this->isResponseError($response) || $this->isDownloadError($response)) { |
|
246 | - EEH_File::delete($temp_file); |
|
247 | - return false; |
|
248 | - } |
|
249 | - |
|
250 | - // possible md5 check |
|
251 | - $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
252 | - if ($content_md5) { |
|
253 | - $md5_check = verify_file_md5($temp_file, $content_md5); |
|
254 | - if ($this->isResponseError($md5_check)) { |
|
255 | - EEH_File::delete($temp_file); |
|
256 | - return false; |
|
257 | - } |
|
258 | - } |
|
259 | - |
|
260 | - // now we have the file, let's get it in the right directory with the right name. |
|
261 | - $path = apply_filters( |
|
262 | - 'FHEE__EEH_Sideloader__sideload__new_path', |
|
263 | - $this->_upload_to . $this->_new_file_name, |
|
264 | - $this |
|
265 | - ); |
|
266 | - if (! EEH_File::move($temp_file, $path, true)) { |
|
267 | - return false; |
|
268 | - } |
|
269 | - |
|
270 | - // set permissions |
|
271 | - $permissions = apply_filters( |
|
272 | - 'FHEE__EEH_Sideloader__sideload__permissions_applied', |
|
273 | - $this->_permissions, |
|
274 | - $this |
|
275 | - ); |
|
276 | - // verify permissions are an integer but don't actually modify the value |
|
277 | - $perms = absint($permissions); |
|
278 | - if (! $perms) { |
|
279 | - EE_Error::add_error( |
|
280 | - esc_html__('Supplied permissions are invalid', 'event_espresso'), |
|
281 | - __FILE__, |
|
282 | - __FUNCTION__, |
|
283 | - __LINE__ |
|
284 | - ); |
|
285 | - return false; |
|
286 | - } |
|
287 | - EEH_File::chmod($path, $permissions); |
|
288 | - |
|
289 | - // that's it. let's allow for actions after file uploaded. |
|
290 | - do_action('AHEE__EE_Sideloader__sideload_after', $this, $path); |
|
291 | - return true; |
|
292 | - } catch (Exception $exception) { |
|
293 | - EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
294 | - return false; |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * returns TRUE if there IS an error, FALSE if there is NO ERROR |
|
301 | - * |
|
302 | - * @param array|WP_Error $response |
|
303 | - * @return bool |
|
304 | - * @throws RuntimeException |
|
305 | - */ |
|
306 | - private function isResponseError($response) |
|
307 | - { |
|
308 | - if (! is_wp_error($response)) { |
|
309 | - return false; |
|
310 | - } |
|
311 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
312 | - EE_Error::add_error( |
|
313 | - sprintf( |
|
314 | - esc_html__( |
|
315 | - 'The following error occurred while attempting to download the file from "%1$s":', |
|
316 | - 'event_espresso' |
|
317 | - ), |
|
318 | - $this->_download_from, |
|
319 | - $response->get_error_message() |
|
320 | - ), |
|
321 | - __FILE__, |
|
322 | - __FUNCTION__, |
|
323 | - __LINE__ |
|
324 | - ); |
|
325 | - } |
|
326 | - return true; |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * returns TRUE if there IS an error, FALSE if there is NO ERROR |
|
332 | - * |
|
333 | - * @param array $response |
|
334 | - * @return bool |
|
335 | - * @throws RuntimeException |
|
336 | - */ |
|
337 | - private function isDownloadError(array $response) |
|
338 | - { |
|
339 | - $response_code = wp_remote_retrieve_response_code($response); |
|
340 | - if ($response_code === 200) { |
|
341 | - return false; |
|
342 | - } |
|
343 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
344 | - $msg = $response_code === 404 |
|
345 | - ? esc_html__( |
|
346 | - 'Attempted to download a file from "%1$s" but encountered a "404 File Not Found" error.', |
|
347 | - 'event_espresso' |
|
348 | - ) |
|
349 | - : esc_html__( |
|
350 | - 'Unable to download the file. Either the path given is incorrect, or something else happened. Here is the path given: %s', |
|
351 | - 'event_espresso' |
|
352 | - ); |
|
353 | - EE_Error::add_error( |
|
354 | - sprintf($msg, $this->_download_from), |
|
355 | - __FILE__, |
|
356 | - __FUNCTION__, |
|
357 | - __LINE__ |
|
358 | - ); |
|
359 | - } |
|
360 | - return true; |
|
361 | - } |
|
362 | - |
|
363 | - // deprecated |
|
364 | - |
|
365 | - /** |
|
366 | - * sets the _upload_from property to the location we should download the file from. |
|
367 | - * |
|
368 | - * @param string $upload_from The full path to the file we should sideload. |
|
369 | - * @return void |
|
370 | - * @deprecated since version 4.10.5.p |
|
371 | - */ |
|
372 | - public function set_upload_from($upload_from) |
|
373 | - { |
|
374 | - EE_Error::doing_it_wrong( |
|
375 | - __CLASS__ . '::' . __FUNCTION__, |
|
376 | - __( |
|
377 | - 'EEH_Sideloader::set_upload_from was renamed to EEH_Sideloader::set_download_from', |
|
378 | - 'event_espresso' |
|
379 | - ), |
|
380 | - '4.10.5.p' |
|
381 | - ); |
|
382 | - $this->set_download_from($upload_from); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * @return string |
|
388 | - * @since 4.1.0 |
|
389 | - * @deprecated since version 4.10.5.p |
|
390 | - */ |
|
391 | - public function get_upload_from() |
|
392 | - { |
|
393 | - EE_Error::doing_it_wrong( |
|
394 | - __CLASS__ . '::' . __FUNCTION__, |
|
395 | - __( |
|
396 | - 'EEH_Sideloader::get_upload_from was renamed to EEH_Sideloader::get_download_from', |
|
397 | - 'event_espresso' |
|
398 | - ), |
|
399 | - '4.10.5.p' |
|
400 | - ); |
|
401 | - return $this->_download_from; |
|
402 | - } |
|
17 | + /** |
|
18 | + * @since 4.1.0 |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + private $_upload_to; |
|
22 | + |
|
23 | + /** |
|
24 | + * @since 4.10.5.p |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + private $_download_from; |
|
28 | + |
|
29 | + /** |
|
30 | + * @since 4.1.0 |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + private $_permissions; |
|
34 | + |
|
35 | + /** |
|
36 | + * @since 4.1.0 |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + private $_new_file_name; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * constructor allows the user to set the properties on the sideloader on construct. However, there are also |
|
44 | + * setters for doing so. |
|
45 | + * |
|
46 | + * @param array $init array fo initializing the sideloader if keys match the properties. |
|
47 | + * @since 4.1.0 |
|
48 | + */ |
|
49 | + public function __construct($init = []) |
|
50 | + { |
|
51 | + $this->_init($init); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * sets the properties for class either to defaults or using incoming initialization array |
|
57 | + * |
|
58 | + * @param array $init array on init (keys match properties others ignored) |
|
59 | + * @return void |
|
60 | + * @since 4.1.0 |
|
61 | + */ |
|
62 | + private function _init($init) |
|
63 | + { |
|
64 | + $defaults = [ |
|
65 | + '_upload_to' => $this->_get_wp_uploads_dir(), |
|
66 | + '_download_from' => '', |
|
67 | + '_permissions' => 0644, |
|
68 | + '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default', |
|
69 | + ]; |
|
70 | + |
|
71 | + $props = array_merge($defaults, $init); |
|
72 | + |
|
73 | + foreach ($props as $property => $val) { |
|
74 | + $setter = 'set' . $property; |
|
75 | + if (method_exists($this, $setter)) { |
|
76 | + $this->$setter($val); |
|
77 | + } else { |
|
78 | + // No setter found. |
|
79 | + EE_Error::add_error( |
|
80 | + sprintf( |
|
81 | + esc_html__( |
|
82 | + 'EEH_Sideloader::%1$s not found. There is no setter for the %2$s property.', |
|
83 | + 'event_espresso' |
|
84 | + ), |
|
85 | + $setter, |
|
86 | + $property |
|
87 | + ), |
|
88 | + __FILE__, |
|
89 | + __FUNCTION__, |
|
90 | + __LINE__ |
|
91 | + ); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + // make sure we include the required wp file for needed functions |
|
96 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + // utilities |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @return string |
|
105 | + * @since 4.1.0 |
|
106 | + */ |
|
107 | + private function _get_wp_uploads_dir() |
|
108 | + { |
|
109 | + $uploads = wp_upload_dir(); |
|
110 | + return $uploads['basedir']; |
|
111 | + } |
|
112 | + |
|
113 | + // setters |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * sets the _upload_to property to the directory to upload to. |
|
118 | + * |
|
119 | + * @param $upload_to_folder |
|
120 | + * @return void |
|
121 | + * @since 4.1.0 |
|
122 | + */ |
|
123 | + public function set_upload_to($upload_to_folder) |
|
124 | + { |
|
125 | + $this->_upload_to = $upload_to_folder; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * sets the _download_from property to the location we should download the file from. |
|
131 | + * |
|
132 | + * @param string $download_from The full path to the file we should sideload. |
|
133 | + * @return void |
|
134 | + * @since 4.10.5.p |
|
135 | + */ |
|
136 | + public function set_download_from($download_from) |
|
137 | + { |
|
138 | + $this->_download_from = $download_from; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * sets the _permissions property used on the sideloaded file. |
|
144 | + * |
|
145 | + * @param int $permissions |
|
146 | + * @return void |
|
147 | + * @since 4.1.0 |
|
148 | + */ |
|
149 | + public function set_permissions($permissions) |
|
150 | + { |
|
151 | + $this->_permissions = $permissions; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * sets the _new_file_name property used on the sideloaded file. |
|
157 | + * |
|
158 | + * @param string $new_file_name |
|
159 | + * @return void |
|
160 | + * @since 4.1.0 |
|
161 | + */ |
|
162 | + public function set_new_file_name($new_file_name) |
|
163 | + { |
|
164 | + $this->_new_file_name = $new_file_name; |
|
165 | + } |
|
166 | + |
|
167 | + // getters |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @return string |
|
172 | + * @since 4.1.0 |
|
173 | + */ |
|
174 | + public function get_upload_to() |
|
175 | + { |
|
176 | + return $this->_upload_to; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * @return string |
|
182 | + * @since 4.10.5.p |
|
183 | + */ |
|
184 | + public function get_download_from() |
|
185 | + { |
|
186 | + return $this->_download_from; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * @return int |
|
192 | + * @since 4.1.0 |
|
193 | + */ |
|
194 | + public function get_permissions() |
|
195 | + { |
|
196 | + return $this->_permissions; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * @return string |
|
202 | + * @since 4.1.0 |
|
203 | + */ |
|
204 | + public function get_new_file_name() |
|
205 | + { |
|
206 | + return $this->_new_file_name; |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + // upload methods |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * Downloads the file using the WordPress HTTP API. |
|
215 | + * |
|
216 | + * @return bool |
|
217 | + * @since 4.1.0 |
|
218 | + */ |
|
219 | + public function sideload() |
|
220 | + { |
|
221 | + try { |
|
222 | + // setup temp dir |
|
223 | + $temp_file = wp_tempnam($this->_download_from); |
|
224 | + |
|
225 | + if (! $temp_file) { |
|
226 | + throw new RuntimeException( |
|
227 | + esc_html__( |
|
228 | + 'Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', |
|
229 | + 'event_espresso' |
|
230 | + ) |
|
231 | + ); |
|
232 | + } |
|
233 | + |
|
234 | + do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file); |
|
235 | + |
|
236 | + $wp_remote_args = apply_filters( |
|
237 | + 'FHEE__EEH_Sideloader__sideload__wp_remote_args', |
|
238 | + ['timeout' => 500, 'stream' => true, 'filename' => $temp_file], |
|
239 | + $this, |
|
240 | + $temp_file |
|
241 | + ); |
|
242 | + |
|
243 | + $response = wp_safe_remote_get($this->_download_from, $wp_remote_args); |
|
244 | + |
|
245 | + if ($this->isResponseError($response) || $this->isDownloadError($response)) { |
|
246 | + EEH_File::delete($temp_file); |
|
247 | + return false; |
|
248 | + } |
|
249 | + |
|
250 | + // possible md5 check |
|
251 | + $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
252 | + if ($content_md5) { |
|
253 | + $md5_check = verify_file_md5($temp_file, $content_md5); |
|
254 | + if ($this->isResponseError($md5_check)) { |
|
255 | + EEH_File::delete($temp_file); |
|
256 | + return false; |
|
257 | + } |
|
258 | + } |
|
259 | + |
|
260 | + // now we have the file, let's get it in the right directory with the right name. |
|
261 | + $path = apply_filters( |
|
262 | + 'FHEE__EEH_Sideloader__sideload__new_path', |
|
263 | + $this->_upload_to . $this->_new_file_name, |
|
264 | + $this |
|
265 | + ); |
|
266 | + if (! EEH_File::move($temp_file, $path, true)) { |
|
267 | + return false; |
|
268 | + } |
|
269 | + |
|
270 | + // set permissions |
|
271 | + $permissions = apply_filters( |
|
272 | + 'FHEE__EEH_Sideloader__sideload__permissions_applied', |
|
273 | + $this->_permissions, |
|
274 | + $this |
|
275 | + ); |
|
276 | + // verify permissions are an integer but don't actually modify the value |
|
277 | + $perms = absint($permissions); |
|
278 | + if (! $perms) { |
|
279 | + EE_Error::add_error( |
|
280 | + esc_html__('Supplied permissions are invalid', 'event_espresso'), |
|
281 | + __FILE__, |
|
282 | + __FUNCTION__, |
|
283 | + __LINE__ |
|
284 | + ); |
|
285 | + return false; |
|
286 | + } |
|
287 | + EEH_File::chmod($path, $permissions); |
|
288 | + |
|
289 | + // that's it. let's allow for actions after file uploaded. |
|
290 | + do_action('AHEE__EE_Sideloader__sideload_after', $this, $path); |
|
291 | + return true; |
|
292 | + } catch (Exception $exception) { |
|
293 | + EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
294 | + return false; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * returns TRUE if there IS an error, FALSE if there is NO ERROR |
|
301 | + * |
|
302 | + * @param array|WP_Error $response |
|
303 | + * @return bool |
|
304 | + * @throws RuntimeException |
|
305 | + */ |
|
306 | + private function isResponseError($response) |
|
307 | + { |
|
308 | + if (! is_wp_error($response)) { |
|
309 | + return false; |
|
310 | + } |
|
311 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
312 | + EE_Error::add_error( |
|
313 | + sprintf( |
|
314 | + esc_html__( |
|
315 | + 'The following error occurred while attempting to download the file from "%1$s":', |
|
316 | + 'event_espresso' |
|
317 | + ), |
|
318 | + $this->_download_from, |
|
319 | + $response->get_error_message() |
|
320 | + ), |
|
321 | + __FILE__, |
|
322 | + __FUNCTION__, |
|
323 | + __LINE__ |
|
324 | + ); |
|
325 | + } |
|
326 | + return true; |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * returns TRUE if there IS an error, FALSE if there is NO ERROR |
|
332 | + * |
|
333 | + * @param array $response |
|
334 | + * @return bool |
|
335 | + * @throws RuntimeException |
|
336 | + */ |
|
337 | + private function isDownloadError(array $response) |
|
338 | + { |
|
339 | + $response_code = wp_remote_retrieve_response_code($response); |
|
340 | + if ($response_code === 200) { |
|
341 | + return false; |
|
342 | + } |
|
343 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
344 | + $msg = $response_code === 404 |
|
345 | + ? esc_html__( |
|
346 | + 'Attempted to download a file from "%1$s" but encountered a "404 File Not Found" error.', |
|
347 | + 'event_espresso' |
|
348 | + ) |
|
349 | + : esc_html__( |
|
350 | + 'Unable to download the file. Either the path given is incorrect, or something else happened. Here is the path given: %s', |
|
351 | + 'event_espresso' |
|
352 | + ); |
|
353 | + EE_Error::add_error( |
|
354 | + sprintf($msg, $this->_download_from), |
|
355 | + __FILE__, |
|
356 | + __FUNCTION__, |
|
357 | + __LINE__ |
|
358 | + ); |
|
359 | + } |
|
360 | + return true; |
|
361 | + } |
|
362 | + |
|
363 | + // deprecated |
|
364 | + |
|
365 | + /** |
|
366 | + * sets the _upload_from property to the location we should download the file from. |
|
367 | + * |
|
368 | + * @param string $upload_from The full path to the file we should sideload. |
|
369 | + * @return void |
|
370 | + * @deprecated since version 4.10.5.p |
|
371 | + */ |
|
372 | + public function set_upload_from($upload_from) |
|
373 | + { |
|
374 | + EE_Error::doing_it_wrong( |
|
375 | + __CLASS__ . '::' . __FUNCTION__, |
|
376 | + __( |
|
377 | + 'EEH_Sideloader::set_upload_from was renamed to EEH_Sideloader::set_download_from', |
|
378 | + 'event_espresso' |
|
379 | + ), |
|
380 | + '4.10.5.p' |
|
381 | + ); |
|
382 | + $this->set_download_from($upload_from); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * @return string |
|
388 | + * @since 4.1.0 |
|
389 | + * @deprecated since version 4.10.5.p |
|
390 | + */ |
|
391 | + public function get_upload_from() |
|
392 | + { |
|
393 | + EE_Error::doing_it_wrong( |
|
394 | + __CLASS__ . '::' . __FUNCTION__, |
|
395 | + __( |
|
396 | + 'EEH_Sideloader::get_upload_from was renamed to EEH_Sideloader::get_download_from', |
|
397 | + 'event_espresso' |
|
398 | + ), |
|
399 | + '4.10.5.p' |
|
400 | + ); |
|
401 | + return $this->_download_from; |
|
402 | + } |
|
403 | 403 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | echo $class; |
31 | 31 | } else { ?> |
32 | 32 | <span class="<?php echo $class; ?>"> |
33 | - <?php if (! empty($details['icon'])) : ?> |
|
33 | + <?php if ( ! empty($details['icon'])) : ?> |
|
34 | 34 | <img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" |
35 | 35 | alt="<?php echo esc_attr($details['desc']); ?>"/> |
36 | 36 | <?php endif; ?> |
@@ -8,25 +8,25 @@ discard block |
||
8 | 8 | <div class="ee-list-table-legend-container"> |
9 | 9 | <h3><?php _e('Legend', 'event_espresso'); ?></h3> |
10 | 10 | <?php |
11 | - if (isset($status_change_notice)) { |
|
12 | - echo $status_change_notice; |
|
13 | - } |
|
14 | - ?> |
|
11 | + if (isset($status_change_notice)) { |
|
12 | + echo $status_change_notice; |
|
13 | + } |
|
14 | + ?> |
|
15 | 15 | <dl class="alignleft ee-list-table-legend"> |
16 | 16 | <?php foreach ($items as $item => $details) : ?> |
17 | 17 | <?php |
18 | - if ($per_col < $count) : ?> |
|
18 | + if ($per_col < $count) : ?> |
|
19 | 19 | </dl> |
20 | 20 | <dl class="alignleft ee-list-table-legend"> |
21 | 21 | <?php $count = 1; |
22 | - endif; ?> |
|
22 | + endif; ?> |
|
23 | 23 | <dt id="ee-legend-item-<?php echo $item; ?>"> |
24 | 24 | <?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?> |
25 | 25 | <span class="ee-legend-item-wrap"> |
26 | 26 | <?php |
27 | - if (strpos($details['class'], '<span') !== false) { |
|
28 | - echo $class; |
|
29 | - } else { ?> |
|
27 | + if (strpos($details['class'], '<span') !== false) { |
|
28 | + echo $class; |
|
29 | + } else { ?> |
|
30 | 30 | <span class="<?php echo $class; ?>"> |
31 | 31 | <?php if (! empty($details['icon'])) : ?> |
32 | 32 | <img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | <span class="ee-legend-description"><?php echo $details['desc']; ?></span> |
39 | 39 | </dt> |
40 | 40 | <?php $count++; |
41 | - endforeach; ?> |
|
41 | + endforeach; ?> |
|
42 | 42 | </dl> |
43 | 43 | <div style="clear:both"></div> |
44 | 44 | </div> |
@@ -41,7 +41,7 @@ |
||
41 | 41 | // $errors = []; |
42 | 42 | |
43 | 43 | try { |
44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
44 | + if (empty($input['uniqueInputs']) || ! is_array($input['uniqueInputs'])) { |
|
45 | 45 | throw new OutOfBoundsException( |
46 | 46 | esc_html__('A valid input was not provided.', 'event_espresso') |
47 | 47 | ); |
@@ -10,69 +10,69 @@ |
||
10 | 10 | class BulkEntityMutator extends EntityMutator |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @var callable $entity_mutator . |
|
15 | - */ |
|
16 | - protected $entity_mutator; |
|
13 | + /** |
|
14 | + * @var callable $entity_mutator . |
|
15 | + */ |
|
16 | + protected $entity_mutator; |
|
17 | 17 | |
18 | - /** |
|
19 | - * BulkEntityMutator constructor. |
|
20 | - * |
|
21 | - * @param callable $entity_mutator The mutator for an entity. |
|
22 | - */ |
|
23 | - public function __construct(callable $entity_mutator) |
|
24 | - { |
|
25 | - $this->entity_mutator = $entity_mutator; |
|
26 | - } |
|
27 | - /** |
|
28 | - * Bulk updates entities. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function updateEntities(array $input, AppContext $context, ResolveInfo $info): array |
|
36 | - { |
|
18 | + /** |
|
19 | + * BulkEntityMutator constructor. |
|
20 | + * |
|
21 | + * @param callable $entity_mutator The mutator for an entity. |
|
22 | + */ |
|
23 | + public function __construct(callable $entity_mutator) |
|
24 | + { |
|
25 | + $this->entity_mutator = $entity_mutator; |
|
26 | + } |
|
27 | + /** |
|
28 | + * Bulk updates entities. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function updateEntities(array $input, AppContext $context, ResolveInfo $info): array |
|
36 | + { |
|
37 | 37 | |
38 | - $updated = []; |
|
39 | - $failed = []; |
|
40 | - // TODO Add meaningful error messages for every failure. |
|
41 | - // $errors = []; |
|
38 | + $updated = []; |
|
39 | + $failed = []; |
|
40 | + // TODO Add meaningful error messages for every failure. |
|
41 | + // $errors = []; |
|
42 | 42 | |
43 | - try { |
|
44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
45 | - throw new OutOfBoundsException( |
|
46 | - esc_html__('A valid input was not provided.', 'event_espresso') |
|
47 | - ); |
|
48 | - } |
|
43 | + try { |
|
44 | + if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
45 | + throw new OutOfBoundsException( |
|
46 | + esc_html__('A valid input was not provided.', 'event_espresso') |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
50 | + $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
51 | 51 | |
52 | - foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
53 | - try { |
|
54 | - // values in $uniqueInput will override those in $sharedInput |
|
55 | - $finalInput = array_merge($sharedInput, $uniqueInput); |
|
56 | - // mutate the individual entity. |
|
57 | - $mutator = $this->entity_mutator; |
|
58 | - $mutator($finalInput, $context, $info); |
|
59 | - // we are here it means the update was successful. |
|
60 | - $updated[] = $uniqueInput['id']; |
|
61 | - } catch (Exception $e) { |
|
62 | - // sorry mate, couldn't help you :( |
|
63 | - $failed[] = $uniqueInput['id']; |
|
64 | - } |
|
65 | - } |
|
66 | - } catch (Exception $exception) { |
|
67 | - EntityMutator::handleExceptions( |
|
68 | - $exception, |
|
69 | - esc_html__( |
|
70 | - 'Could not perform the update because of the following error(s)', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
52 | + foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
53 | + try { |
|
54 | + // values in $uniqueInput will override those in $sharedInput |
|
55 | + $finalInput = array_merge($sharedInput, $uniqueInput); |
|
56 | + // mutate the individual entity. |
|
57 | + $mutator = $this->entity_mutator; |
|
58 | + $mutator($finalInput, $context, $info); |
|
59 | + // we are here it means the update was successful. |
|
60 | + $updated[] = $uniqueInput['id']; |
|
61 | + } catch (Exception $e) { |
|
62 | + // sorry mate, couldn't help you :( |
|
63 | + $failed[] = $uniqueInput['id']; |
|
64 | + } |
|
65 | + } |
|
66 | + } catch (Exception $exception) { |
|
67 | + EntityMutator::handleExceptions( |
|
68 | + $exception, |
|
69 | + esc_html__( |
|
70 | + 'Could not perform the update because of the following error(s)', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - return compact('updated', 'failed'); |
|
77 | - } |
|
76 | + return compact('updated', 'failed'); |
|
77 | + } |
|
78 | 78 | } |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class TicketBulkUpdate extends EntityMutator |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * Defines the mutation data modification closure. |
|
13 | - * |
|
14 | - * @param EEM_Ticket $model |
|
15 | - * @param Ticket $type |
|
16 | - * @return callable |
|
17 | - */ |
|
18 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
19 | - { |
|
20 | - $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | - return array($bulkMutator, 'updateEntities'); |
|
23 | - } |
|
11 | + /** |
|
12 | + * Defines the mutation data modification closure. |
|
13 | + * |
|
14 | + * @param EEM_Ticket $model |
|
15 | + * @param Ticket $type |
|
16 | + * @return callable |
|
17 | + */ |
|
18 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
19 | + { |
|
20 | + $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | + return array($bulkMutator, 'updateEntities'); |
|
23 | + } |
|
24 | 24 | } |