@@ -17,252 +17,252 @@ |
||
17 | 17 | |
18 | 18 | class ExpiredTransactionCheck extends CronJob |
19 | 19 | { |
20 | - private ?PaymentProcessor $payment_processor = null; |
|
21 | - |
|
22 | - private ?EE_Transaction_Processor $transaction_processor = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * array of TXN IDs |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected array $expired_transactions = []; |
|
30 | - |
|
31 | - |
|
32 | - private function loadTransactionProcessor() |
|
33 | - { |
|
34 | - $this->transaction_processor = $this->loader->getShared(EE_Transaction_Processor::class); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - private function loadPaymentProcessor() |
|
39 | - { |
|
40 | - $this->payment_processor = $this->loader->getShared(PaymentProcessor::class); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - public function setHooks(): void |
|
45 | - { |
|
46 | - add_action( |
|
47 | - 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
48 | - [$this, 'expiredTransactionCheck'] |
|
49 | - ); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * schedule_expired_transaction_check |
|
55 | - * sets a wp_schedule_single_event() for following up on TXNs after their session has expired |
|
56 | - * |
|
57 | - * @param int $timestamp |
|
58 | - * @param int $TXN_ID |
|
59 | - */ |
|
60 | - public static function scheduleExpiredTransactionCheck( |
|
61 | - int $timestamp, |
|
62 | - int $TXN_ID |
|
63 | - ): void { |
|
64 | - // validate $TXN_ID and $timestamp |
|
65 | - $TXN_ID = absint($TXN_ID); |
|
66 | - $timestamp = absint($timestamp); |
|
67 | - if ($TXN_ID && $timestamp) { |
|
68 | - wp_schedule_single_event( |
|
69 | - $timestamp, |
|
70 | - 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
71 | - [$TXN_ID] |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * this is the callback for the action hook: |
|
79 | - * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check' |
|
80 | - * which is utilized by wp_schedule_single_event() |
|
81 | - * in \EED_Single_Page_Checkout::_initialize_transaction(). |
|
82 | - * The passed TXN_ID gets added to an array, and then the |
|
83 | - * process_expired_transactions() function is hooked into |
|
84 | - * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
85 | - * processing of any failed transactions, because doing so now would be |
|
86 | - * too early and the required resources may not be available |
|
87 | - * |
|
88 | - * @param int $TXN_ID |
|
89 | - */ |
|
90 | - public function expiredTransactionCheck(int $TXN_ID = 0): void |
|
91 | - { |
|
92 | - if (absint($TXN_ID)) { |
|
93 | - $this->expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
94 | - add_action( |
|
95 | - 'shutdown', |
|
96 | - [$this, 'processExpiredTransactions'], |
|
97 | - 5 |
|
98 | - ); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * loops through the $this->expired_transactions array and processes any failed TXNs |
|
105 | - * |
|
106 | - * @throws EE_Error |
|
107 | - * @throws ReflectionException |
|
108 | - * @throws DomainException |
|
109 | - * @throws RuntimeException |
|
110 | - */ |
|
111 | - public function processExpiredTransactions(): void |
|
112 | - { |
|
113 | - if ( |
|
114 | - // are there any TXNs that need cleaning up ? |
|
115 | - empty($this->expired_transactions) |
|
116 | - // reschedule the cron if we can't hit the db right now |
|
117 | - || CronUtilities::rescheduleCronForTransactions( |
|
118 | - [ExpiredTransactionCheck::class, 'scheduleExpiredTransactionCheck'], |
|
119 | - $this->expired_transactions |
|
120 | - ) |
|
121 | - ) { |
|
122 | - return; |
|
123 | - } |
|
124 | - $this->loadTransactionProcessor(); |
|
125 | - // set revisit flag for txn processor |
|
126 | - $this->transaction_processor->set_revisit(); |
|
127 | - foreach ($this->expired_transactions as $TXN_ID) { |
|
128 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
129 | - // verify transaction and whether it is failed or not |
|
130 | - if ($transaction instanceof EE_Transaction) { |
|
131 | - switch ($transaction->status_ID()) { |
|
132 | - |
|
133 | - case EEM_Transaction::complete_status_code: |
|
134 | - $this->processCompletedTransaction($transaction); |
|
135 | - break; |
|
136 | - |
|
137 | - case EEM_Transaction::overpaid_status_code: |
|
138 | - $this->processOverpaidTransaction($transaction); |
|
139 | - break; |
|
140 | - |
|
141 | - case EEM_Transaction::incomplete_status_code: |
|
142 | - $this->processIncompletedTransaction($transaction); |
|
143 | - break; |
|
144 | - |
|
145 | - case EEM_Transaction::abandoned_status_code: |
|
146 | - $this->processAbandonedTransaction($transaction); |
|
147 | - break; |
|
148 | - |
|
149 | - case EEM_Transaction::failed_status_code: |
|
150 | - $this->processFailedTransaction($transaction); |
|
151 | - break; |
|
152 | - } |
|
153 | - } |
|
154 | - unset($this->expired_transactions[ $TXN_ID ]); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @param EE_Transaction $transaction |
|
161 | - * @return void |
|
162 | - * @throws EE_Error |
|
163 | - * @throws ReflectionException |
|
164 | - */ |
|
165 | - private function processCompletedTransaction(EE_Transaction $transaction) |
|
166 | - { |
|
167 | - // Don't update the transaction/registrations if the Primary Registration is Not Approved. |
|
168 | - $primary_registration = $transaction->primary_registration(); |
|
169 | - if ( |
|
170 | - $primary_registration instanceof EE_Registration |
|
171 | - && $primary_registration->status_ID() !== RegStatus::AWAITING_REVIEW |
|
172 | - ) { |
|
173 | - $this->transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
174 | - $transaction, |
|
175 | - $transaction->last_payment() |
|
176 | - ); |
|
177 | - do_action( |
|
178 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', |
|
179 | - $transaction |
|
180 | - ); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * @param EE_Transaction $transaction |
|
187 | - * @return void |
|
188 | - */ |
|
189 | - private function processOverpaidTransaction(EE_Transaction $transaction) |
|
190 | - { |
|
191 | - do_action( |
|
192 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', |
|
193 | - $transaction |
|
194 | - ); |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - /** |
|
199 | - * @param EE_Transaction $transaction |
|
200 | - * @return void |
|
201 | - */ |
|
202 | - private function processIncompletedTransaction(EE_Transaction $transaction) |
|
203 | - { |
|
204 | - do_action( |
|
205 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
206 | - $transaction |
|
207 | - ); |
|
208 | - // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * @param EE_Transaction $transaction |
|
214 | - * @return void |
|
215 | - * @throws EE_Error |
|
216 | - * @throws ReflectionException |
|
217 | - */ |
|
218 | - private function processAbandonedTransaction(EE_Transaction $transaction) |
|
219 | - { |
|
220 | - // run hook before updating transaction, primarily so |
|
221 | - // EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets |
|
222 | - do_action( |
|
223 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction', |
|
224 | - $transaction |
|
225 | - ); |
|
226 | - // don't finalize the TXN if it has already been completed |
|
227 | - if ($transaction->all_reg_steps_completed() !== true) { |
|
228 | - $this->loadPaymentProcessor(); |
|
229 | - // let's simulate an IPN here which will trigger any notifications that need to go out |
|
230 | - $this->payment_processor->updateTransactionBasedOnPayment( |
|
231 | - $transaction, |
|
232 | - $transaction->last_payment(), |
|
233 | - true, |
|
234 | - true |
|
235 | - ); |
|
236 | - } |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param EE_Transaction $transaction |
|
242 | - * @return void |
|
243 | - */ |
|
244 | - private function processFailedTransaction(EE_Transaction $transaction) |
|
245 | - { |
|
246 | - do_action( |
|
247 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
248 | - $transaction |
|
249 | - ); |
|
250 | - // todo : |
|
251 | - // perform garbage collection here and remove clean_out_junk_transactions() |
|
252 | - // $registrations = $transaction->registrations(); |
|
253 | - // if (! empty($registrations)) { |
|
254 | - // foreach ($registrations as $registration) { |
|
255 | - // if ($registration instanceof EE_Registration) { |
|
256 | - // $delete_registration = true; |
|
257 | - // if ($registration->attendee() instanceof EE_Attendee) { |
|
258 | - // $delete_registration = false; |
|
259 | - // } |
|
260 | - // if ($delete_registration) { |
|
261 | - // $registration->delete_permanently(); |
|
262 | - // $registration->delete_related_permanently(); |
|
263 | - // } |
|
264 | - // } |
|
265 | - // } |
|
266 | - // } |
|
267 | - } |
|
20 | + private ?PaymentProcessor $payment_processor = null; |
|
21 | + |
|
22 | + private ?EE_Transaction_Processor $transaction_processor = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * array of TXN IDs |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected array $expired_transactions = []; |
|
30 | + |
|
31 | + |
|
32 | + private function loadTransactionProcessor() |
|
33 | + { |
|
34 | + $this->transaction_processor = $this->loader->getShared(EE_Transaction_Processor::class); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + private function loadPaymentProcessor() |
|
39 | + { |
|
40 | + $this->payment_processor = $this->loader->getShared(PaymentProcessor::class); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + public function setHooks(): void |
|
45 | + { |
|
46 | + add_action( |
|
47 | + 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
48 | + [$this, 'expiredTransactionCheck'] |
|
49 | + ); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * schedule_expired_transaction_check |
|
55 | + * sets a wp_schedule_single_event() for following up on TXNs after their session has expired |
|
56 | + * |
|
57 | + * @param int $timestamp |
|
58 | + * @param int $TXN_ID |
|
59 | + */ |
|
60 | + public static function scheduleExpiredTransactionCheck( |
|
61 | + int $timestamp, |
|
62 | + int $TXN_ID |
|
63 | + ): void { |
|
64 | + // validate $TXN_ID and $timestamp |
|
65 | + $TXN_ID = absint($TXN_ID); |
|
66 | + $timestamp = absint($timestamp); |
|
67 | + if ($TXN_ID && $timestamp) { |
|
68 | + wp_schedule_single_event( |
|
69 | + $timestamp, |
|
70 | + 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
71 | + [$TXN_ID] |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * this is the callback for the action hook: |
|
79 | + * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check' |
|
80 | + * which is utilized by wp_schedule_single_event() |
|
81 | + * in \EED_Single_Page_Checkout::_initialize_transaction(). |
|
82 | + * The passed TXN_ID gets added to an array, and then the |
|
83 | + * process_expired_transactions() function is hooked into |
|
84 | + * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
85 | + * processing of any failed transactions, because doing so now would be |
|
86 | + * too early and the required resources may not be available |
|
87 | + * |
|
88 | + * @param int $TXN_ID |
|
89 | + */ |
|
90 | + public function expiredTransactionCheck(int $TXN_ID = 0): void |
|
91 | + { |
|
92 | + if (absint($TXN_ID)) { |
|
93 | + $this->expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
94 | + add_action( |
|
95 | + 'shutdown', |
|
96 | + [$this, 'processExpiredTransactions'], |
|
97 | + 5 |
|
98 | + ); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * loops through the $this->expired_transactions array and processes any failed TXNs |
|
105 | + * |
|
106 | + * @throws EE_Error |
|
107 | + * @throws ReflectionException |
|
108 | + * @throws DomainException |
|
109 | + * @throws RuntimeException |
|
110 | + */ |
|
111 | + public function processExpiredTransactions(): void |
|
112 | + { |
|
113 | + if ( |
|
114 | + // are there any TXNs that need cleaning up ? |
|
115 | + empty($this->expired_transactions) |
|
116 | + // reschedule the cron if we can't hit the db right now |
|
117 | + || CronUtilities::rescheduleCronForTransactions( |
|
118 | + [ExpiredTransactionCheck::class, 'scheduleExpiredTransactionCheck'], |
|
119 | + $this->expired_transactions |
|
120 | + ) |
|
121 | + ) { |
|
122 | + return; |
|
123 | + } |
|
124 | + $this->loadTransactionProcessor(); |
|
125 | + // set revisit flag for txn processor |
|
126 | + $this->transaction_processor->set_revisit(); |
|
127 | + foreach ($this->expired_transactions as $TXN_ID) { |
|
128 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
129 | + // verify transaction and whether it is failed or not |
|
130 | + if ($transaction instanceof EE_Transaction) { |
|
131 | + switch ($transaction->status_ID()) { |
|
132 | + |
|
133 | + case EEM_Transaction::complete_status_code: |
|
134 | + $this->processCompletedTransaction($transaction); |
|
135 | + break; |
|
136 | + |
|
137 | + case EEM_Transaction::overpaid_status_code: |
|
138 | + $this->processOverpaidTransaction($transaction); |
|
139 | + break; |
|
140 | + |
|
141 | + case EEM_Transaction::incomplete_status_code: |
|
142 | + $this->processIncompletedTransaction($transaction); |
|
143 | + break; |
|
144 | + |
|
145 | + case EEM_Transaction::abandoned_status_code: |
|
146 | + $this->processAbandonedTransaction($transaction); |
|
147 | + break; |
|
148 | + |
|
149 | + case EEM_Transaction::failed_status_code: |
|
150 | + $this->processFailedTransaction($transaction); |
|
151 | + break; |
|
152 | + } |
|
153 | + } |
|
154 | + unset($this->expired_transactions[ $TXN_ID ]); |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @param EE_Transaction $transaction |
|
161 | + * @return void |
|
162 | + * @throws EE_Error |
|
163 | + * @throws ReflectionException |
|
164 | + */ |
|
165 | + private function processCompletedTransaction(EE_Transaction $transaction) |
|
166 | + { |
|
167 | + // Don't update the transaction/registrations if the Primary Registration is Not Approved. |
|
168 | + $primary_registration = $transaction->primary_registration(); |
|
169 | + if ( |
|
170 | + $primary_registration instanceof EE_Registration |
|
171 | + && $primary_registration->status_ID() !== RegStatus::AWAITING_REVIEW |
|
172 | + ) { |
|
173 | + $this->transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
174 | + $transaction, |
|
175 | + $transaction->last_payment() |
|
176 | + ); |
|
177 | + do_action( |
|
178 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', |
|
179 | + $transaction |
|
180 | + ); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * @param EE_Transaction $transaction |
|
187 | + * @return void |
|
188 | + */ |
|
189 | + private function processOverpaidTransaction(EE_Transaction $transaction) |
|
190 | + { |
|
191 | + do_action( |
|
192 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', |
|
193 | + $transaction |
|
194 | + ); |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + /** |
|
199 | + * @param EE_Transaction $transaction |
|
200 | + * @return void |
|
201 | + */ |
|
202 | + private function processIncompletedTransaction(EE_Transaction $transaction) |
|
203 | + { |
|
204 | + do_action( |
|
205 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
206 | + $transaction |
|
207 | + ); |
|
208 | + // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * @param EE_Transaction $transaction |
|
214 | + * @return void |
|
215 | + * @throws EE_Error |
|
216 | + * @throws ReflectionException |
|
217 | + */ |
|
218 | + private function processAbandonedTransaction(EE_Transaction $transaction) |
|
219 | + { |
|
220 | + // run hook before updating transaction, primarily so |
|
221 | + // EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets |
|
222 | + do_action( |
|
223 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction', |
|
224 | + $transaction |
|
225 | + ); |
|
226 | + // don't finalize the TXN if it has already been completed |
|
227 | + if ($transaction->all_reg_steps_completed() !== true) { |
|
228 | + $this->loadPaymentProcessor(); |
|
229 | + // let's simulate an IPN here which will trigger any notifications that need to go out |
|
230 | + $this->payment_processor->updateTransactionBasedOnPayment( |
|
231 | + $transaction, |
|
232 | + $transaction->last_payment(), |
|
233 | + true, |
|
234 | + true |
|
235 | + ); |
|
236 | + } |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param EE_Transaction $transaction |
|
242 | + * @return void |
|
243 | + */ |
|
244 | + private function processFailedTransaction(EE_Transaction $transaction) |
|
245 | + { |
|
246 | + do_action( |
|
247 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
248 | + $transaction |
|
249 | + ); |
|
250 | + // todo : |
|
251 | + // perform garbage collection here and remove clean_out_junk_transactions() |
|
252 | + // $registrations = $transaction->registrations(); |
|
253 | + // if (! empty($registrations)) { |
|
254 | + // foreach ($registrations as $registration) { |
|
255 | + // if ($registration instanceof EE_Registration) { |
|
256 | + // $delete_registration = true; |
|
257 | + // if ($registration->attendee() instanceof EE_Attendee) { |
|
258 | + // $delete_registration = false; |
|
259 | + // } |
|
260 | + // if ($delete_registration) { |
|
261 | + // $registration->delete_permanently(); |
|
262 | + // $registration->delete_related_permanently(); |
|
263 | + // } |
|
264 | + // } |
|
265 | + // } |
|
266 | + // } |
|
267 | + } |
|
268 | 268 | } |
@@ -16,231 +16,231 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class DomainBase implements DomainInterface |
18 | 18 | { |
19 | - const ASSETS_FOLDER = 'assets/'; |
|
20 | - |
|
21 | - /** |
|
22 | - * Equivalent to `__FILE__` for main plugin file. |
|
23 | - * |
|
24 | - * @var FilePath |
|
25 | - */ |
|
26 | - private FilePath $plugin_file; |
|
27 | - |
|
28 | - /** |
|
29 | - * String indicating version for plugin |
|
30 | - * |
|
31 | - * @var Version |
|
32 | - */ |
|
33 | - private Version $version; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $plugin_basename |
|
37 | - */ |
|
38 | - private string $plugin_basename = ''; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string $plugin_path |
|
42 | - */ |
|
43 | - private string $plugin_path = ''; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string $plugin_url |
|
47 | - */ |
|
48 | - private string $plugin_url = ''; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string $asset_namespace |
|
52 | - */ |
|
53 | - private string $asset_namespace = ''; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $assets_path |
|
57 | - */ |
|
58 | - private string $assets_path = ''; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var bool |
|
62 | - */ |
|
63 | - protected bool $initialized = false; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Initializes internal properties. |
|
68 | - * |
|
69 | - * @param FilePath $plugin_file |
|
70 | - * @param Version $version |
|
71 | - * @param string $asset_namespace |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - FilePath $plugin_file, |
|
75 | - Version $version, |
|
76 | - string $asset_namespace = Domain::ASSET_NAMESPACE |
|
77 | - ) { |
|
78 | - $this->plugin_file = $plugin_file; |
|
79 | - $this->version = $version; |
|
80 | - $this->initialize($asset_namespace); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $asset_namespace |
|
86 | - * @return void |
|
87 | - * @since 5.0.0.p |
|
88 | - */ |
|
89 | - public function initialize(string $asset_namespace = Domain::ASSET_NAMESPACE) |
|
90 | - { |
|
91 | - if (! $this->initialized) { |
|
92 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
93 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
94 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
95 | - $this->setAssetNamespace($asset_namespace); |
|
96 | - $this->setDistributionAssetsPath(); |
|
97 | - $this->initialized = true; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $asset_namespace |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function setAssetNamespace(string $asset_namespace = Domain::ASSET_NAMESPACE) |
|
107 | - { |
|
108 | - if (! $this->asset_namespace) { |
|
109 | - $this->asset_namespace = sanitize_key( |
|
110 | - // convert directory separators to dashes and remove file extension |
|
111 | - str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
|
112 | - ); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @throws DomainException |
|
119 | - * @since 5.0.0.p |
|
120 | - */ |
|
121 | - private function setDistributionAssetsPath() |
|
122 | - { |
|
123 | - $assets_folder_paths = [ |
|
124 | - $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | - $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
126 | - ]; |
|
127 | - foreach ($assets_folder_paths as $assets_folder_path) { |
|
128 | - if (is_readable($assets_folder_path)) { |
|
129 | - $this->assets_path = trailingslashit($assets_folder_path); |
|
130 | - // once we find a valid path, just break out of loop |
|
131 | - break; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function pluginFile(): string |
|
141 | - { |
|
142 | - return (string) $this->plugin_file; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return FilePath |
|
148 | - */ |
|
149 | - public function pluginFileObject(): FilePath |
|
150 | - { |
|
151 | - return $this->plugin_file; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function pluginBasename(): string |
|
159 | - { |
|
160 | - return $this->plugin_basename; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param string $additional_path |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - public function pluginPath(string $additional_path = ''): string |
|
169 | - { |
|
170 | - return is_string($additional_path) && $additional_path !== '' |
|
171 | - ? $this->plugin_path . $additional_path |
|
172 | - : $this->plugin_path; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $additional_path |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function pluginUrl(string $additional_path = ''): string |
|
181 | - { |
|
182 | - return is_string($additional_path) && $additional_path !== '' |
|
183 | - ? $this->plugin_url . $additional_path |
|
184 | - : $this->plugin_url; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function version(): string |
|
192 | - { |
|
193 | - return (string) $this->version; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @return Version |
|
199 | - */ |
|
200 | - public function versionValueObject(): Version |
|
201 | - { |
|
202 | - return $this->version; |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * @return string |
|
208 | - */ |
|
209 | - public function distributionAssetsFolder(): string |
|
210 | - { |
|
211 | - return DomainBase::ASSETS_FOLDER; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * @param string $additional_path |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - public function distributionAssetsPath(string $additional_path = ''): string |
|
220 | - { |
|
221 | - return is_string($additional_path) && $additional_path !== '' |
|
222 | - ? $this->assets_path . $additional_path |
|
223 | - : $this->assets_path; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * @param string $additional_path |
|
229 | - * @return string |
|
230 | - */ |
|
231 | - public function distributionAssetsUrl(string $additional_path = ''): string |
|
232 | - { |
|
233 | - return is_string($additional_path) && $additional_path !== '' |
|
234 | - ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | - : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * @return string |
|
241 | - */ |
|
242 | - public function assetNamespace(): string |
|
243 | - { |
|
244 | - return $this->asset_namespace; |
|
245 | - } |
|
19 | + const ASSETS_FOLDER = 'assets/'; |
|
20 | + |
|
21 | + /** |
|
22 | + * Equivalent to `__FILE__` for main plugin file. |
|
23 | + * |
|
24 | + * @var FilePath |
|
25 | + */ |
|
26 | + private FilePath $plugin_file; |
|
27 | + |
|
28 | + /** |
|
29 | + * String indicating version for plugin |
|
30 | + * |
|
31 | + * @var Version |
|
32 | + */ |
|
33 | + private Version $version; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $plugin_basename |
|
37 | + */ |
|
38 | + private string $plugin_basename = ''; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string $plugin_path |
|
42 | + */ |
|
43 | + private string $plugin_path = ''; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string $plugin_url |
|
47 | + */ |
|
48 | + private string $plugin_url = ''; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string $asset_namespace |
|
52 | + */ |
|
53 | + private string $asset_namespace = ''; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $assets_path |
|
57 | + */ |
|
58 | + private string $assets_path = ''; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var bool |
|
62 | + */ |
|
63 | + protected bool $initialized = false; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Initializes internal properties. |
|
68 | + * |
|
69 | + * @param FilePath $plugin_file |
|
70 | + * @param Version $version |
|
71 | + * @param string $asset_namespace |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + FilePath $plugin_file, |
|
75 | + Version $version, |
|
76 | + string $asset_namespace = Domain::ASSET_NAMESPACE |
|
77 | + ) { |
|
78 | + $this->plugin_file = $plugin_file; |
|
79 | + $this->version = $version; |
|
80 | + $this->initialize($asset_namespace); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $asset_namespace |
|
86 | + * @return void |
|
87 | + * @since 5.0.0.p |
|
88 | + */ |
|
89 | + public function initialize(string $asset_namespace = Domain::ASSET_NAMESPACE) |
|
90 | + { |
|
91 | + if (! $this->initialized) { |
|
92 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
93 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
94 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
95 | + $this->setAssetNamespace($asset_namespace); |
|
96 | + $this->setDistributionAssetsPath(); |
|
97 | + $this->initialized = true; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $asset_namespace |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function setAssetNamespace(string $asset_namespace = Domain::ASSET_NAMESPACE) |
|
107 | + { |
|
108 | + if (! $this->asset_namespace) { |
|
109 | + $this->asset_namespace = sanitize_key( |
|
110 | + // convert directory separators to dashes and remove file extension |
|
111 | + str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
|
112 | + ); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @throws DomainException |
|
119 | + * @since 5.0.0.p |
|
120 | + */ |
|
121 | + private function setDistributionAssetsPath() |
|
122 | + { |
|
123 | + $assets_folder_paths = [ |
|
124 | + $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | + $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
126 | + ]; |
|
127 | + foreach ($assets_folder_paths as $assets_folder_path) { |
|
128 | + if (is_readable($assets_folder_path)) { |
|
129 | + $this->assets_path = trailingslashit($assets_folder_path); |
|
130 | + // once we find a valid path, just break out of loop |
|
131 | + break; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function pluginFile(): string |
|
141 | + { |
|
142 | + return (string) $this->plugin_file; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return FilePath |
|
148 | + */ |
|
149 | + public function pluginFileObject(): FilePath |
|
150 | + { |
|
151 | + return $this->plugin_file; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function pluginBasename(): string |
|
159 | + { |
|
160 | + return $this->plugin_basename; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param string $additional_path |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + public function pluginPath(string $additional_path = ''): string |
|
169 | + { |
|
170 | + return is_string($additional_path) && $additional_path !== '' |
|
171 | + ? $this->plugin_path . $additional_path |
|
172 | + : $this->plugin_path; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $additional_path |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function pluginUrl(string $additional_path = ''): string |
|
181 | + { |
|
182 | + return is_string($additional_path) && $additional_path !== '' |
|
183 | + ? $this->plugin_url . $additional_path |
|
184 | + : $this->plugin_url; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function version(): string |
|
192 | + { |
|
193 | + return (string) $this->version; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @return Version |
|
199 | + */ |
|
200 | + public function versionValueObject(): Version |
|
201 | + { |
|
202 | + return $this->version; |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * @return string |
|
208 | + */ |
|
209 | + public function distributionAssetsFolder(): string |
|
210 | + { |
|
211 | + return DomainBase::ASSETS_FOLDER; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * @param string $additional_path |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + public function distributionAssetsPath(string $additional_path = ''): string |
|
220 | + { |
|
221 | + return is_string($additional_path) && $additional_path !== '' |
|
222 | + ? $this->assets_path . $additional_path |
|
223 | + : $this->assets_path; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * @param string $additional_path |
|
229 | + * @return string |
|
230 | + */ |
|
231 | + public function distributionAssetsUrl(string $additional_path = ''): string |
|
232 | + { |
|
233 | + return is_string($additional_path) && $additional_path !== '' |
|
234 | + ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | + : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * @return string |
|
241 | + */ |
|
242 | + public function assetNamespace(): string |
|
243 | + { |
|
244 | + return $this->asset_namespace; |
|
245 | + } |
|
246 | 246 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function initialize(string $asset_namespace = Domain::ASSET_NAMESPACE) |
90 | 90 | { |
91 | - if (! $this->initialized) { |
|
91 | + if ( ! $this->initialized) { |
|
92 | 92 | $this->plugin_basename = plugin_basename($this->pluginFile()); |
93 | 93 | $this->plugin_path = plugin_dir_path($this->pluginFile()); |
94 | 94 | $this->plugin_url = plugin_dir_url($this->pluginFile()); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setAssetNamespace(string $asset_namespace = Domain::ASSET_NAMESPACE) |
107 | 107 | { |
108 | - if (! $this->asset_namespace) { |
|
108 | + if ( ! $this->asset_namespace) { |
|
109 | 109 | $this->asset_namespace = sanitize_key( |
110 | 110 | // convert directory separators to dashes and remove file extension |
111 | 111 | str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | private function setDistributionAssetsPath() |
122 | 122 | { |
123 | 123 | $assets_folder_paths = [ |
124 | - $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | - $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
124 | + $this->plugin_path.DomainBase::ASSETS_FOLDER, |
|
125 | + $this->plugin_path.'src/'.DomainBase::ASSETS_FOLDER, |
|
126 | 126 | ]; |
127 | 127 | foreach ($assets_folder_paths as $assets_folder_path) { |
128 | 128 | if (is_readable($assets_folder_path)) { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | public function pluginPath(string $additional_path = ''): string |
169 | 169 | { |
170 | 170 | return is_string($additional_path) && $additional_path !== '' |
171 | - ? $this->plugin_path . $additional_path |
|
171 | + ? $this->plugin_path.$additional_path |
|
172 | 172 | : $this->plugin_path; |
173 | 173 | } |
174 | 174 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | public function pluginUrl(string $additional_path = ''): string |
181 | 181 | { |
182 | 182 | return is_string($additional_path) && $additional_path !== '' |
183 | - ? $this->plugin_url . $additional_path |
|
183 | + ? $this->plugin_url.$additional_path |
|
184 | 184 | : $this->plugin_url; |
185 | 185 | } |
186 | 186 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | public function distributionAssetsPath(string $additional_path = ''): string |
220 | 220 | { |
221 | 221 | return is_string($additional_path) && $additional_path !== '' |
222 | - ? $this->assets_path . $additional_path |
|
222 | + ? $this->assets_path.$additional_path |
|
223 | 223 | : $this->assets_path; |
224 | 224 | } |
225 | 225 | |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | public function distributionAssetsUrl(string $additional_path = ''): string |
232 | 232 | { |
233 | 233 | return is_string($additional_path) && $additional_path !== '' |
234 | - ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | - : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
234 | + ? $this->plugin_url.DomainBase::ASSETS_FOLDER.$additional_path |
|
235 | + : $this->plugin_url.DomainBase::ASSETS_FOLDER; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 |
@@ -14,80 +14,80 @@ |
||
14 | 14 | */ |
15 | 15 | interface DomainInterface extends InterminableInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @param string $asset_namespace |
|
19 | - * @return void |
|
20 | - * @since 5.0.0.p |
|
21 | - */ |
|
22 | - public function initialize(string $asset_namespace = 'eventespresso'); |
|
17 | + /** |
|
18 | + * @param string $asset_namespace |
|
19 | + * @return void |
|
20 | + * @since 5.0.0.p |
|
21 | + */ |
|
22 | + public function initialize(string $asset_namespace = 'eventespresso'); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param string $asset_namespace |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function setAssetNamespace(string $asset_namespace = 'eventespresso'); |
|
25 | + /** |
|
26 | + * @param string $asset_namespace |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function setAssetNamespace(string $asset_namespace = 'eventespresso'); |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function pluginFile(): string; |
|
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function pluginFile(): string; |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function pluginBasename(): string; |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function pluginBasename(): string; |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @param string $additional_path |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function pluginPath(string $additional_path = ''): string; |
|
44 | + /** |
|
45 | + * @param string $additional_path |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function pluginPath(string $additional_path = ''): string; |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function pluginUrl(): string; |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function pluginUrl(): string; |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function version(): string; |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function version(): string; |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return Version |
|
65 | - */ |
|
66 | - public function versionValueObject(): Version; |
|
63 | + /** |
|
64 | + * @return Version |
|
65 | + */ |
|
66 | + public function versionValueObject(): Version; |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function distributionAssetsFolder(): string; |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function distributionAssetsFolder(): string; |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @param string $additional_path |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function distributionAssetsPath(string $additional_path = ''): string; |
|
75 | + /** |
|
76 | + * @param string $additional_path |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function distributionAssetsPath(string $additional_path = ''): string; |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @param string $additional_path |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function distributionAssetsUrl(string $additional_path = ''): string; |
|
82 | + /** |
|
83 | + * @param string $additional_path |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function distributionAssetsUrl(string $additional_path = ''): string; |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function assetNamespace(): string; |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function assetNamespace(): string; |
|
93 | 93 | } |
@@ -15,114 +15,114 @@ |
||
15 | 15 | */ |
16 | 16 | class Domain extends DomainBase implements CaffeinatedInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * URL path component used to denote an API request |
|
20 | - */ |
|
21 | - public const API_NAMESPACE = 'ee/v'; |
|
22 | - |
|
23 | - public const ASSET_NAMESPACE = 'eventespresso'; |
|
24 | - |
|
25 | - public const LICENSE_PLUGIN_NAME = 'Event Espresso Core'; |
|
26 | - |
|
27 | - public const LICENSE_PLUGIN_SLUG = 'event_espresso_core'; |
|
28 | - |
|
29 | - public const TEXT_DOMAIN = 'event_espresso'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
|
33 | - * Page ui. |
|
34 | - */ |
|
35 | - public const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN = 'manual_registration_status_change_from_registration_admin'; |
|
36 | - |
|
37 | - public const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY = 'manual_registration_status_change_from_registration_admin_and_notify'; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Whether EE core is the full premium version. |
|
42 | - * |
|
43 | - * @since 4.9.59.p |
|
44 | - * @var bool |
|
45 | - */ |
|
46 | - private bool $caffeinated = false; |
|
47 | - |
|
48 | - /** |
|
49 | - * @since 5.0.0.p |
|
50 | - * @var bool |
|
51 | - */ |
|
52 | - private bool $multisite; |
|
53 | - |
|
54 | - |
|
55 | - public function __construct(FilePath $plugin_file, Version $version) |
|
56 | - { |
|
57 | - parent::__construct($plugin_file, $version); |
|
58 | - $this->setCaffeinated(); |
|
59 | - $this->multisite = is_multisite(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Whether EE core is the full premium version. |
|
65 | - * |
|
66 | - * @return bool |
|
67 | - * @since 4.9.59.p |
|
68 | - */ |
|
69 | - public function isCaffeinated(): bool |
|
70 | - { |
|
71 | - return $this->caffeinated; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @return bool |
|
77 | - * @since 5.0.22.p |
|
78 | - */ |
|
79 | - public function isDecaf(): bool |
|
80 | - { |
|
81 | - return ! $this->isCaffeinated(); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Setter for $is_caffeinated property. |
|
87 | - * |
|
88 | - * @since 4.9.59.p |
|
89 | - */ |
|
90 | - private function setCaffeinated() |
|
91 | - { |
|
92 | - $this->caffeinated = ! (defined('EE_DECAF') && EE_DECAF) |
|
93 | - && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces |
|
99 | - * to allow for filtering the brand. |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public static function brandName(): string |
|
104 | - { |
|
105 | - return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso'); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return bool |
|
111 | - * @since 5.0.0.p |
|
112 | - */ |
|
113 | - public function isMultiSite(): bool |
|
114 | - { |
|
115 | - return $this->multisite; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public static function pluginName(): string |
|
120 | - { |
|
121 | - return self::LICENSE_PLUGIN_NAME; |
|
122 | - } |
|
123 | - |
|
124 | - public static function pluginSlug(): string |
|
125 | - { |
|
126 | - return self::LICENSE_PLUGIN_SLUG; |
|
127 | - } |
|
18 | + /** |
|
19 | + * URL path component used to denote an API request |
|
20 | + */ |
|
21 | + public const API_NAMESPACE = 'ee/v'; |
|
22 | + |
|
23 | + public const ASSET_NAMESPACE = 'eventespresso'; |
|
24 | + |
|
25 | + public const LICENSE_PLUGIN_NAME = 'Event Espresso Core'; |
|
26 | + |
|
27 | + public const LICENSE_PLUGIN_SLUG = 'event_espresso_core'; |
|
28 | + |
|
29 | + public const TEXT_DOMAIN = 'event_espresso'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
|
33 | + * Page ui. |
|
34 | + */ |
|
35 | + public const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN = 'manual_registration_status_change_from_registration_admin'; |
|
36 | + |
|
37 | + public const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY = 'manual_registration_status_change_from_registration_admin_and_notify'; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Whether EE core is the full premium version. |
|
42 | + * |
|
43 | + * @since 4.9.59.p |
|
44 | + * @var bool |
|
45 | + */ |
|
46 | + private bool $caffeinated = false; |
|
47 | + |
|
48 | + /** |
|
49 | + * @since 5.0.0.p |
|
50 | + * @var bool |
|
51 | + */ |
|
52 | + private bool $multisite; |
|
53 | + |
|
54 | + |
|
55 | + public function __construct(FilePath $plugin_file, Version $version) |
|
56 | + { |
|
57 | + parent::__construct($plugin_file, $version); |
|
58 | + $this->setCaffeinated(); |
|
59 | + $this->multisite = is_multisite(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Whether EE core is the full premium version. |
|
65 | + * |
|
66 | + * @return bool |
|
67 | + * @since 4.9.59.p |
|
68 | + */ |
|
69 | + public function isCaffeinated(): bool |
|
70 | + { |
|
71 | + return $this->caffeinated; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @return bool |
|
77 | + * @since 5.0.22.p |
|
78 | + */ |
|
79 | + public function isDecaf(): bool |
|
80 | + { |
|
81 | + return ! $this->isCaffeinated(); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Setter for $is_caffeinated property. |
|
87 | + * |
|
88 | + * @since 4.9.59.p |
|
89 | + */ |
|
90 | + private function setCaffeinated() |
|
91 | + { |
|
92 | + $this->caffeinated = ! (defined('EE_DECAF') && EE_DECAF) |
|
93 | + && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces |
|
99 | + * to allow for filtering the brand. |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public static function brandName(): string |
|
104 | + { |
|
105 | + return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso'); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return bool |
|
111 | + * @since 5.0.0.p |
|
112 | + */ |
|
113 | + public function isMultiSite(): bool |
|
114 | + { |
|
115 | + return $this->multisite; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public static function pluginName(): string |
|
120 | + { |
|
121 | + return self::LICENSE_PLUGIN_NAME; |
|
122 | + } |
|
123 | + |
|
124 | + public static function pluginSlug(): string |
|
125 | + { |
|
126 | + return self::LICENSE_PLUGIN_SLUG; |
|
127 | + } |
|
128 | 128 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public const LICENSE_PLUGIN_SLUG = 'event_espresso_core'; |
28 | 28 | |
29 | - public const TEXT_DOMAIN = 'event_espresso'; |
|
29 | + public const TEXT_DOMAIN = 'event_espresso'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | private function setCaffeinated() |
91 | 91 | { |
92 | 92 | $this->caffeinated = ! (defined('EE_DECAF') && EE_DECAF) |
93 | - && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
93 | + && is_readable($this->pluginPath().'caffeinated/brewing_regular.php'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 |
@@ -7,141 +7,141 @@ |
||
7 | 7 | */ |
8 | 8 | class EE_Admin_Config extends EE_Config_Base |
9 | 9 | { |
10 | - protected ?bool $useAdvancedEditor = true; |
|
11 | - |
|
12 | - public $use_remote_logging = false; |
|
13 | - |
|
14 | - public $show_reg_footer = false; |
|
15 | - |
|
16 | - protected ?bool $is_caffeinated = false; |
|
17 | - |
|
18 | - public $use_dashboard_widget = false; |
|
19 | - |
|
20 | - public $use_personnel_manager = false; |
|
21 | - |
|
22 | - public $use_event_timezones = false; |
|
23 | - |
|
24 | - /** |
|
25 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
26 | - * but is incompatible with some server configuration errors |
|
27 | - * if you get "500 internal server errors" during registration, try turning this on |
|
28 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
29 | - * |
|
30 | - * @var boolean $encode_session_data |
|
31 | - */ |
|
32 | - protected bool $encode_session_data = false; |
|
33 | - |
|
34 | - public ?string $log_file_name = ''; |
|
35 | - |
|
36 | - public ?string $debug_file_name = ''; |
|
37 | - |
|
38 | - public ?string $remote_logging_url = ''; |
|
39 | - |
|
40 | - public ?string $affiliate_id = 'default'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int|null $events_in_dashboard |
|
44 | - * @deprecated |
|
45 | - */ |
|
46 | - public ?int $events_in_dashboard = 30; |
|
47 | - |
|
48 | - |
|
49 | - public function __construct() |
|
50 | - { |
|
51 | - $this->setIsCaffeinated(); |
|
52 | - // set default general admin settings |
|
53 | - $this->show_reg_footer = (bool) apply_filters( |
|
54 | - 'FHEE__EE_Admin_Config__show_reg_footer__default', |
|
55 | - false |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @param bool $reset |
|
62 | - * @return string |
|
63 | - * @throws EE_Error |
|
64 | - * @throws ReflectionException |
|
65 | - */ |
|
66 | - public function log_file_name(bool $reset = false): string |
|
67 | - { |
|
68 | - if (empty($this->log_file_name) || $reset) { |
|
69 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
70 | - EE_Config::instance()->update_espresso_config(false, false); |
|
71 | - } |
|
72 | - return (string) $this->log_file_name; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param bool $reset |
|
78 | - * @return string |
|
79 | - * @throws EE_Error |
|
80 | - * @throws ReflectionException |
|
81 | - */ |
|
82 | - public function debug_file_name(bool $reset = false): string |
|
83 | - { |
|
84 | - if (empty($this->debug_file_name) || $reset) { |
|
85 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
86 | - EE_Config::instance()->update_espresso_config(false, false); |
|
87 | - } |
|
88 | - return (string) $this->debug_file_name; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function affiliate_id(): string |
|
96 | - { |
|
97 | - return ! empty($this->affiliate_id) ? (string) $this->affiliate_id : 'default'; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @return boolean |
|
103 | - */ |
|
104 | - public function encode_session_data(): bool |
|
105 | - { |
|
106 | - return $this->encode_session_data; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @param bool|int|string $encode_session_data |
|
112 | - */ |
|
113 | - public function set_encode_session_data($encode_session_data) |
|
114 | - { |
|
115 | - $this->encode_session_data = (bool) filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return boolean |
|
120 | - */ |
|
121 | - public function useAdvancedEditor(): bool |
|
122 | - { |
|
123 | - return $this->useAdvancedEditor; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @param bool|int|string $use_advanced_editor |
|
128 | - */ |
|
129 | - public function setUseAdvancedEditor($use_advanced_editor = true) |
|
130 | - { |
|
131 | - $this->useAdvancedEditor = (bool) filter_var( |
|
132 | - apply_filters( |
|
133 | - 'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor', |
|
134 | - $use_advanced_editor |
|
135 | - ), |
|
136 | - FILTER_VALIDATE_BOOLEAN |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - protected function setIsCaffeinated(): void |
|
142 | - { |
|
143 | - /** @var EventEspresso\core\domain\Domain $domain */ |
|
144 | - $domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain'); |
|
145 | - $this->is_caffeinated = (bool) filter_var($domain->isCaffeinated(), FILTER_VALIDATE_BOOLEAN); |
|
146 | - } |
|
10 | + protected ?bool $useAdvancedEditor = true; |
|
11 | + |
|
12 | + public $use_remote_logging = false; |
|
13 | + |
|
14 | + public $show_reg_footer = false; |
|
15 | + |
|
16 | + protected ?bool $is_caffeinated = false; |
|
17 | + |
|
18 | + public $use_dashboard_widget = false; |
|
19 | + |
|
20 | + public $use_personnel_manager = false; |
|
21 | + |
|
22 | + public $use_event_timezones = false; |
|
23 | + |
|
24 | + /** |
|
25 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
26 | + * but is incompatible with some server configuration errors |
|
27 | + * if you get "500 internal server errors" during registration, try turning this on |
|
28 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
29 | + * |
|
30 | + * @var boolean $encode_session_data |
|
31 | + */ |
|
32 | + protected bool $encode_session_data = false; |
|
33 | + |
|
34 | + public ?string $log_file_name = ''; |
|
35 | + |
|
36 | + public ?string $debug_file_name = ''; |
|
37 | + |
|
38 | + public ?string $remote_logging_url = ''; |
|
39 | + |
|
40 | + public ?string $affiliate_id = 'default'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int|null $events_in_dashboard |
|
44 | + * @deprecated |
|
45 | + */ |
|
46 | + public ?int $events_in_dashboard = 30; |
|
47 | + |
|
48 | + |
|
49 | + public function __construct() |
|
50 | + { |
|
51 | + $this->setIsCaffeinated(); |
|
52 | + // set default general admin settings |
|
53 | + $this->show_reg_footer = (bool) apply_filters( |
|
54 | + 'FHEE__EE_Admin_Config__show_reg_footer__default', |
|
55 | + false |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @param bool $reset |
|
62 | + * @return string |
|
63 | + * @throws EE_Error |
|
64 | + * @throws ReflectionException |
|
65 | + */ |
|
66 | + public function log_file_name(bool $reset = false): string |
|
67 | + { |
|
68 | + if (empty($this->log_file_name) || $reset) { |
|
69 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
70 | + EE_Config::instance()->update_espresso_config(false, false); |
|
71 | + } |
|
72 | + return (string) $this->log_file_name; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param bool $reset |
|
78 | + * @return string |
|
79 | + * @throws EE_Error |
|
80 | + * @throws ReflectionException |
|
81 | + */ |
|
82 | + public function debug_file_name(bool $reset = false): string |
|
83 | + { |
|
84 | + if (empty($this->debug_file_name) || $reset) { |
|
85 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
86 | + EE_Config::instance()->update_espresso_config(false, false); |
|
87 | + } |
|
88 | + return (string) $this->debug_file_name; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function affiliate_id(): string |
|
96 | + { |
|
97 | + return ! empty($this->affiliate_id) ? (string) $this->affiliate_id : 'default'; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @return boolean |
|
103 | + */ |
|
104 | + public function encode_session_data(): bool |
|
105 | + { |
|
106 | + return $this->encode_session_data; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @param bool|int|string $encode_session_data |
|
112 | + */ |
|
113 | + public function set_encode_session_data($encode_session_data) |
|
114 | + { |
|
115 | + $this->encode_session_data = (bool) filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return boolean |
|
120 | + */ |
|
121 | + public function useAdvancedEditor(): bool |
|
122 | + { |
|
123 | + return $this->useAdvancedEditor; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @param bool|int|string $use_advanced_editor |
|
128 | + */ |
|
129 | + public function setUseAdvancedEditor($use_advanced_editor = true) |
|
130 | + { |
|
131 | + $this->useAdvancedEditor = (bool) filter_var( |
|
132 | + apply_filters( |
|
133 | + 'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor', |
|
134 | + $use_advanced_editor |
|
135 | + ), |
|
136 | + FILTER_VALIDATE_BOOLEAN |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + protected function setIsCaffeinated(): void |
|
142 | + { |
|
143 | + /** @var EventEspresso\core\domain\Domain $domain */ |
|
144 | + $domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain'); |
|
145 | + $this->is_caffeinated = (bool) filter_var($domain->isCaffeinated(), FILTER_VALIDATE_BOOLEAN); |
|
146 | + } |
|
147 | 147 | } |
@@ -24,92 +24,92 @@ |
||
24 | 24 | */ |
25 | 25 | class EspressoTxnPage extends EspressoShortcode |
26 | 26 | { |
27 | - /** |
|
28 | - * the actual shortcode tag that gets registered with WordPress |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getTag() |
|
33 | - { |
|
34 | - return 'ESPRESSO_TXN_PAGE'; |
|
35 | - } |
|
27 | + /** |
|
28 | + * the actual shortcode tag that gets registered with WordPress |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getTag() |
|
33 | + { |
|
34 | + return 'ESPRESSO_TXN_PAGE'; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * the time in seconds to cache the results of the processShortcode() method |
|
40 | - * 0 means the processShortcode() results will NOT be cached at all |
|
41 | - * |
|
42 | - * @return int |
|
43 | - */ |
|
44 | - public function cacheExpiration() |
|
45 | - { |
|
46 | - return 0; |
|
47 | - } |
|
38 | + /** |
|
39 | + * the time in seconds to cache the results of the processShortcode() method |
|
40 | + * 0 means the processShortcode() results will NOT be cached at all |
|
41 | + * |
|
42 | + * @return int |
|
43 | + */ |
|
44 | + public function cacheExpiration() |
|
45 | + { |
|
46 | + return 0; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
52 | - * this may be required for shortcodes that utilize a corresponding module, |
|
53 | - * and need to enqueue assets for that module |
|
54 | - * |
|
55 | - * @return void |
|
56 | - * @throws Exception |
|
57 | - * @throws EE_Error |
|
58 | - */ |
|
59 | - public function initializeShortcode() |
|
60 | - { |
|
61 | - $transaction = null; |
|
62 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
63 | - $reg_url_link = $request->getRequestParam('e_reg_url_link'); |
|
64 | - if ($reg_url_link) { |
|
65 | - /** @var EEM_Transaction $EEM_Transaction */ |
|
66 | - $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
67 | - $transaction = $EEM_Transaction->get_transaction_from_reg_url_link($reg_url_link); |
|
68 | - } |
|
69 | - if ($transaction instanceof EE_Transaction) { |
|
70 | - $payment_method = null; |
|
71 | - $payment_method_slug = $request->getRequestParam('ee_payment_method'); |
|
72 | - if ($payment_method_slug) { |
|
73 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
74 | - } |
|
75 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
76 | - $gateway = $payment_method->type_obj()->get_gateway(); |
|
77 | - if ( |
|
78 | - $gateway instanceof EE_Offsite_Gateway |
|
79 | - && $gateway->handle_IPN_in_this_request( |
|
80 | - $request->requestParams(), |
|
81 | - true |
|
82 | - ) |
|
83 | - ) { |
|
84 | - /** @var RequestInterface $request */ |
|
85 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
86 | - /** @var IpnHandler $payment_processor */ |
|
87 | - $payment_processor = LoaderFactory::getShared(IpnHandler::class); |
|
88 | - $payment_processor->processIPN($request->requestParams(), $transaction, $payment_method); |
|
89 | - } |
|
90 | - } |
|
91 | - // allow gateways to add a filter to stop rendering the page |
|
92 | - if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
93 | - exit; |
|
94 | - } |
|
95 | - } |
|
96 | - $this->shortcodeHasBeenInitialized(); |
|
97 | - } |
|
50 | + /** |
|
51 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
52 | + * this may be required for shortcodes that utilize a corresponding module, |
|
53 | + * and need to enqueue assets for that module |
|
54 | + * |
|
55 | + * @return void |
|
56 | + * @throws Exception |
|
57 | + * @throws EE_Error |
|
58 | + */ |
|
59 | + public function initializeShortcode() |
|
60 | + { |
|
61 | + $transaction = null; |
|
62 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
63 | + $reg_url_link = $request->getRequestParam('e_reg_url_link'); |
|
64 | + if ($reg_url_link) { |
|
65 | + /** @var EEM_Transaction $EEM_Transaction */ |
|
66 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
67 | + $transaction = $EEM_Transaction->get_transaction_from_reg_url_link($reg_url_link); |
|
68 | + } |
|
69 | + if ($transaction instanceof EE_Transaction) { |
|
70 | + $payment_method = null; |
|
71 | + $payment_method_slug = $request->getRequestParam('ee_payment_method'); |
|
72 | + if ($payment_method_slug) { |
|
73 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
74 | + } |
|
75 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
76 | + $gateway = $payment_method->type_obj()->get_gateway(); |
|
77 | + if ( |
|
78 | + $gateway instanceof EE_Offsite_Gateway |
|
79 | + && $gateway->handle_IPN_in_this_request( |
|
80 | + $request->requestParams(), |
|
81 | + true |
|
82 | + ) |
|
83 | + ) { |
|
84 | + /** @var RequestInterface $request */ |
|
85 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
86 | + /** @var IpnHandler $payment_processor */ |
|
87 | + $payment_processor = LoaderFactory::getShared(IpnHandler::class); |
|
88 | + $payment_processor->processIPN($request->requestParams(), $transaction, $payment_method); |
|
89 | + } |
|
90 | + } |
|
91 | + // allow gateways to add a filter to stop rendering the page |
|
92 | + if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
93 | + exit; |
|
94 | + } |
|
95 | + } |
|
96 | + $this->shortcodeHasBeenInitialized(); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * callback that runs when the shortcode is encountered in post content. |
|
102 | - * IMPORTANT !!! |
|
103 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
104 | - * |
|
105 | - * @param array|string $attributes |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function processShortcode($attributes = array()) |
|
109 | - { |
|
110 | - return esc_html__( |
|
111 | - 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
112 | - 'event_espresso' |
|
113 | - ); |
|
114 | - } |
|
100 | + /** |
|
101 | + * callback that runs when the shortcode is encountered in post content. |
|
102 | + * IMPORTANT !!! |
|
103 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
104 | + * |
|
105 | + * @param array|string $attributes |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function processShortcode($attributes = array()) |
|
109 | + { |
|
110 | + return esc_html__( |
|
111 | + 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
112 | + 'event_espresso' |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | } |
@@ -16,40 +16,40 @@ |
||
16 | 16 | */ |
17 | 17 | class EspressoCoreDomain extends JsonDataNode |
18 | 18 | { |
19 | - const NODE_NAME = 'coreDomain'; |
|
20 | - |
|
21 | - private Domain $domain; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * JsonDataNode constructor. |
|
26 | - * |
|
27 | - * @param Domain $domain |
|
28 | - * @param JsonDataNodeValidator $validator |
|
29 | - */ |
|
30 | - public function __construct(Domain $domain, JsonDataNodeValidator $validator) |
|
31 | - { |
|
32 | - $this->domain = $domain; |
|
33 | - parent::__construct($validator); |
|
34 | - $this->setNodeName(EspressoCoreDomain::NODE_NAME); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @inheritDoc |
|
40 | - */ |
|
41 | - public function initialize() |
|
42 | - { |
|
43 | - $this->addData('assetNamespace', $this->domain->assetNamespace()); |
|
44 | - $this->addData('brandName', Domain::brandName()); |
|
45 | - $this->addData('coreVersion', $this->domain->version()); |
|
46 | - $this->addData('distributionAssetsPath', $this->domain->distributionAssetsPath()); |
|
47 | - $this->addData('distributionAssetsUrl', $this->domain->distributionAssetsUrl()); |
|
48 | - $this->addData('isCaffeinated', $this->domain->isCaffeinated()); |
|
49 | - $this->addData('isDecaf', $this->domain->isDecaf()); |
|
50 | - $this->addData('isMultiSite', $this->domain->isMultiSite()); |
|
51 | - $this->addData('pluginPath', $this->domain->pluginPath()); |
|
52 | - $this->addData('pluginUrl', $this->domain->pluginUrl()); |
|
53 | - $this->setInitialized(true); |
|
54 | - } |
|
19 | + const NODE_NAME = 'coreDomain'; |
|
20 | + |
|
21 | + private Domain $domain; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * JsonDataNode constructor. |
|
26 | + * |
|
27 | + * @param Domain $domain |
|
28 | + * @param JsonDataNodeValidator $validator |
|
29 | + */ |
|
30 | + public function __construct(Domain $domain, JsonDataNodeValidator $validator) |
|
31 | + { |
|
32 | + $this->domain = $domain; |
|
33 | + parent::__construct($validator); |
|
34 | + $this->setNodeName(EspressoCoreDomain::NODE_NAME); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @inheritDoc |
|
40 | + */ |
|
41 | + public function initialize() |
|
42 | + { |
|
43 | + $this->addData('assetNamespace', $this->domain->assetNamespace()); |
|
44 | + $this->addData('brandName', Domain::brandName()); |
|
45 | + $this->addData('coreVersion', $this->domain->version()); |
|
46 | + $this->addData('distributionAssetsPath', $this->domain->distributionAssetsPath()); |
|
47 | + $this->addData('distributionAssetsUrl', $this->domain->distributionAssetsUrl()); |
|
48 | + $this->addData('isCaffeinated', $this->domain->isCaffeinated()); |
|
49 | + $this->addData('isDecaf', $this->domain->isDecaf()); |
|
50 | + $this->addData('isMultiSite', $this->domain->isMultiSite()); |
|
51 | + $this->addData('pluginPath', $this->domain->pluginPath()); |
|
52 | + $this->addData('pluginUrl', $this->domain->pluginUrl()); |
|
53 | + $this->setInitialized(true); |
|
54 | + } |
|
55 | 55 | } |
@@ -24,991 +24,991 @@ |
||
24 | 24 | */ |
25 | 25 | final class EE_Admin implements InterminableInterface |
26 | 26 | { |
27 | - private static ?EE_Admin $_instance = null; |
|
28 | - |
|
29 | - private ?PersistentAdminNoticeManager $persistent_admin_notice_manager = null; |
|
30 | - |
|
31 | - protected LoaderInterface $loader; |
|
32 | - |
|
33 | - protected RequestInterface $request; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @singleton method used to instantiate class object |
|
38 | - * @param LoaderInterface|null $loader |
|
39 | - * @param RequestInterface|null $request |
|
40 | - * @return EE_Admin|null |
|
41 | - * @throws EE_Error |
|
42 | - */ |
|
43 | - public static function instance(?LoaderInterface $loader = null, ?RequestInterface $request = null): ?EE_Admin |
|
44 | - { |
|
45 | - // check if class object is instantiated |
|
46 | - if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
47 | - EE_Admin::$_instance = new EE_Admin($loader, $request); |
|
48 | - } |
|
49 | - return EE_Admin::$_instance; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return EE_Admin|null |
|
55 | - * @throws EE_Error |
|
56 | - */ |
|
57 | - public static function reset(): ?EE_Admin |
|
58 | - { |
|
59 | - EE_Admin::$_instance = null; |
|
60 | - $loader = LoaderFactory::getLoader(); |
|
61 | - $request = $loader->getShared('EventEspresso\core\services\request\Request'); |
|
62 | - return EE_Admin::instance($loader, $request); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @param LoaderInterface $loader |
|
68 | - * @param RequestInterface $request |
|
69 | - * @throws EE_Error |
|
70 | - * @throws InvalidDataTypeException |
|
71 | - * @throws InvalidInterfaceException |
|
72 | - * @throws InvalidArgumentException |
|
73 | - */ |
|
74 | - protected function __construct(LoaderInterface $loader, RequestInterface $request) |
|
75 | - { |
|
76 | - $this->loader = $loader; |
|
77 | - $this->request = $request; |
|
78 | - // define global EE_Admin constants |
|
79 | - $this->_define_all_constants(); |
|
80 | - // set autoloaders for our admin page classes based on included path information |
|
81 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
82 | - // reset Environment config (we only do this on admin page loads); |
|
83 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
84 | - // load EE_Request_Handler early |
|
85 | - add_action('AHEE__EE_System__initialize_last', [$this, 'init']); |
|
86 | - add_action('admin_init', [$this, 'admin_init'], 100); |
|
87 | - if (! $this->request->isActivation() && ! $this->request->isAjax()) { |
|
88 | - // admin hooks |
|
89 | - add_action('admin_notices', [$this, 'display_admin_notices']); |
|
90 | - add_action('network_admin_notices', [$this, 'display_admin_notices']); |
|
91 | - add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2); |
|
92 | - add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
|
93 | - add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
|
94 | - add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2); |
|
95 | - add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2); |
|
96 | - } |
|
97 | - do_action('AHEE__EE_Admin__loaded'); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * _define_all_constants |
|
103 | - * define constants that are set globally for all admin pages |
|
104 | - * |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - private function _define_all_constants() |
|
108 | - { |
|
109 | - if (! defined('EE_ADMIN_URL')) { |
|
110 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
111 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
112 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
113 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
114 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
121 | - * |
|
122 | - * @param array $links |
|
123 | - * @param string $plugin |
|
124 | - * @return array |
|
125 | - */ |
|
126 | - public function filter_plugin_actions($links, $plugin) |
|
127 | - { |
|
128 | - // set $main_file in stone |
|
129 | - static $main_file; |
|
130 | - // if $main_file is not set yet |
|
131 | - if (! $main_file) { |
|
132 | - $main_file = EE_PLUGIN_BASENAME; |
|
133 | - } |
|
134 | - if ($plugin === $main_file) { |
|
135 | - // compare current plugin to this one |
|
136 | - if (MaintenanceStatus::isFullSite()) { |
|
137 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
138 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
139 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
140 | - . '</a>'; |
|
141 | - array_unshift($links, $maintenance_link); |
|
142 | - } else { |
|
143 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
144 | - . esc_html__('Settings', 'event_espresso') |
|
145 | - . '</a>'; |
|
146 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
147 | - . esc_html__('Events', 'event_espresso') |
|
148 | - . '</a>'; |
|
149 | - // add before other links |
|
150 | - array_unshift($links, $org_settings_link, $events_link); |
|
151 | - } |
|
152 | - } |
|
153 | - return $links; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * hide_admin_pages_except_maintenance_mode |
|
159 | - * |
|
160 | - * @param array $admin_page_folder_names |
|
161 | - * @return array |
|
162 | - */ |
|
163 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = []) |
|
164 | - { |
|
165 | - return [ |
|
166 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
167 | - 'about' => EE_ADMIN_PAGES . 'about/', |
|
168 | - 'support' => EE_ADMIN_PAGES . 'support/', |
|
169 | - ]; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
175 | - * EE_Front_Controller's init phases have run |
|
176 | - * |
|
177 | - * @return void |
|
178 | - * @throws EE_Error |
|
179 | - * @throws InvalidArgumentException |
|
180 | - * @throws InvalidDataTypeException |
|
181 | - * @throws InvalidInterfaceException |
|
182 | - * @throws ReflectionException |
|
183 | - * @throws ServiceNotFoundException |
|
184 | - */ |
|
185 | - public function init() |
|
186 | - { |
|
187 | - // only enable most of the EE_Admin IF we're not in full maintenance mode |
|
188 | - if (DbStatus::isOnline()) { |
|
189 | - $this->initModelsReady(); |
|
190 | - } |
|
191 | - // run the admin page factory but ONLY if: |
|
192 | - // - it is a regular non ajax admin request |
|
193 | - // - we are doing an ee admin ajax request |
|
194 | - if ($this->request->isAdmin() || $this->request->isAdminAjax() || $this->request->isActivation()) { |
|
195 | - try { |
|
196 | - // this loads the controller for the admin pages which will setup routing etc |
|
197 | - $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]); |
|
198 | - /** @var EE_Admin_Page_Loader $admin_page_loader */ |
|
199 | - $admin_page_loader->init(); |
|
200 | - } catch (EE_Error $e) { |
|
201 | - $e->get_error(); |
|
202 | - } |
|
203 | - } |
|
204 | - if ($this->request->isAjax()) { |
|
205 | - return; |
|
206 | - } |
|
207 | - add_filter('content_save_pre', [$this, 'its_eSpresso']); |
|
208 | - // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
209 | - add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes']); |
|
210 | - add_action('admin_head', [$this, 'register_custom_nav_menu_boxes']); |
|
211 | - // exclude EE critical pages from all nav menus and wp_list_pages |
|
212 | - add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu']); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * Gets the loader (and if it wasn't previously set, sets it) |
|
218 | - * |
|
219 | - * @return LoaderInterface |
|
220 | - * @throws InvalidArgumentException |
|
221 | - * @throws InvalidDataTypeException |
|
222 | - * @throws InvalidInterfaceException |
|
223 | - */ |
|
224 | - protected function getLoader() |
|
225 | - { |
|
226 | - return $this->loader; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * Method that's fired on admin requests (including admin ajax) but only when the models are usable |
|
232 | - * (ie, the site isn't in maintenance mode) |
|
233 | - * |
|
234 | - * @return void |
|
235 | - * @throws EE_Error |
|
236 | - * @since 4.9.63.p |
|
237 | - */ |
|
238 | - protected function initModelsReady() |
|
239 | - { |
|
240 | - // ok so we want to enable the entire admin |
|
241 | - $this->persistent_admin_notice_manager = $this->loader->getShared( |
|
242 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
243 | - ); |
|
244 | - $this->persistent_admin_notice_manager->setReturnUrl( |
|
245 | - EE_Admin_Page::add_query_args_and_nonce( |
|
246 | - [ |
|
247 | - 'page' => $this->request->getRequestParam('page', ''), |
|
248 | - 'action' => $this->request->getRequestParam('action', ''), |
|
249 | - ], |
|
250 | - EE_ADMIN_URL |
|
251 | - ) |
|
252 | - ); |
|
253 | - $this->maybeSetDatetimeWarningNotice(); |
|
254 | - // at a glance dashboard widget |
|
255 | - add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items']); |
|
256 | - // filter for get_edit_post_link used on comments for custom post types |
|
257 | - add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * get_persistent_admin_notices |
|
263 | - * |
|
264 | - * @access public |
|
265 | - * @return void |
|
266 | - * @throws EE_Error |
|
267 | - * @throws InvalidArgumentException |
|
268 | - * @throws InvalidDataTypeException |
|
269 | - * @throws InvalidInterfaceException |
|
270 | - * @throws ReflectionException |
|
271 | - */ |
|
272 | - public function maybeSetDatetimeWarningNotice() |
|
273 | - { |
|
274 | - // add dismissible notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
275 | - // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
276 | - // with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
277 | - // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
278 | - if ( |
|
279 | - apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
280 | - && ! get_option('timezone_string') |
|
281 | - && EEM_Event::instance()->count() > 0 |
|
282 | - ) { |
|
283 | - new PersistentAdminNotice( |
|
284 | - 'datetime_fix_notice', |
|
285 | - sprintf( |
|
286 | - esc_html__( |
|
287 | - '%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.', |
|
288 | - 'event_espresso' |
|
289 | - ), |
|
290 | - '<strong>', |
|
291 | - '</strong>', |
|
292 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
293 | - '</a>', |
|
294 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
295 | - [ |
|
296 | - 'page' => 'espresso_maintenance_settings', |
|
297 | - 'action' => 'datetime_tools', |
|
298 | - ], |
|
299 | - admin_url('admin.php') |
|
300 | - ) . '">' |
|
301 | - ), |
|
302 | - false, |
|
303 | - 'manage_options', |
|
304 | - 'datetime_fix_persistent_notice' |
|
305 | - ); |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
312 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
313 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
314 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
315 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
316 | - * |
|
317 | - * @param WP_Post $post_type WP post type object |
|
318 | - * @return WP_Post |
|
319 | - * @throws InvalidArgumentException |
|
320 | - * @throws InvalidDataTypeException |
|
321 | - * @throws InvalidInterfaceException |
|
322 | - */ |
|
323 | - public function remove_pages_from_nav_menu($post_type) |
|
324 | - { |
|
325 | - // if this isn't the "pages" post type let's get out |
|
326 | - if ($post_type->name !== 'page') { |
|
327 | - return $post_type; |
|
328 | - } |
|
329 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
330 | - $post_type->_default_query = [ |
|
331 | - 'post__not_in' => $critical_pages, |
|
332 | - ]; |
|
333 | - return $post_type; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. |
|
339 | - * We want to make sure our metaboxes get shown as well |
|
340 | - * |
|
341 | - * @return void |
|
342 | - */ |
|
343 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
344 | - { |
|
345 | - global $wp_meta_boxes, $pagenow; |
|
346 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
347 | - return; |
|
348 | - } |
|
349 | - $user = wp_get_current_user(); |
|
350 | - // has this been done yet? |
|
351 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
352 | - return; |
|
353 | - } |
|
354 | - |
|
355 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
356 | - $initial_meta_boxes = apply_filters( |
|
357 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
358 | - [ |
|
359 | - 'nav-menu-theme-locations', |
|
360 | - 'add-page', |
|
361 | - 'add-custom-links', |
|
362 | - 'add-category', |
|
363 | - 'add-espresso_events', |
|
364 | - 'add-espresso_venues', |
|
365 | - 'add-espresso_event_categories', |
|
366 | - 'add-espresso_venue_categories', |
|
367 | - 'add-post-type-post', |
|
368 | - 'add-post-type-page', |
|
369 | - ] |
|
370 | - ); |
|
371 | - |
|
372 | - if (is_array($hidden_meta_boxes)) { |
|
373 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
374 | - if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
375 | - unset($hidden_meta_boxes[ $key ]); |
|
376 | - } |
|
377 | - } |
|
378 | - } |
|
379 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
380 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
386 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
387 | - * |
|
388 | - * @return void |
|
389 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
390 | - * addons etc. |
|
391 | - */ |
|
392 | - public function register_custom_nav_menu_boxes() |
|
393 | - { |
|
394 | - add_meta_box( |
|
395 | - 'add-extra-nav-menu-pages', |
|
396 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
397 | - [$this, 'ee_cpt_archive_pages'], |
|
398 | - 'nav-menus', |
|
399 | - 'side', |
|
400 | - 'core' |
|
401 | - ); |
|
402 | - add_filter( |
|
403 | - "postbox_classes_nav-menus_add-extra-nav-menu-pages", |
|
404 | - function ($classes) { |
|
405 | - $classes[] = 'ee-admin-container'; |
|
406 | - return $classes; |
|
407 | - } |
|
408 | - ); |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
414 | - * |
|
415 | - * @param string $link the original link generated by wp |
|
416 | - * @param int $id post id |
|
417 | - * @return string the (maybe) modified link |
|
418 | - * @since 4.3.0 |
|
419 | - */ |
|
420 | - public function modify_edit_post_link($link, $id) |
|
421 | - { |
|
422 | - if (! $post = get_post($id)) { |
|
423 | - return $link; |
|
424 | - } |
|
425 | - if ($post->post_type === EspressoPostType::ATTENDEES) { |
|
426 | - $query_args = [ |
|
427 | - 'action' => 'edit_attendee', |
|
428 | - 'post' => $id, |
|
429 | - ]; |
|
430 | - return EEH_URL::add_query_args_and_nonce( |
|
431 | - $query_args, |
|
432 | - admin_url('admin.php?page=espresso_registrations') |
|
433 | - ); |
|
434 | - } |
|
435 | - return $link; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - public function ee_cpt_archive_pages() |
|
440 | - { |
|
441 | - global $nav_menu_selected_id; |
|
442 | - $removed_args = [ |
|
443 | - 'action', |
|
444 | - 'customlink-tab', |
|
445 | - 'edit-menu-item', |
|
446 | - 'menu-item', |
|
447 | - 'page-tab', |
|
448 | - '_wpnonce', |
|
449 | - ]; |
|
450 | - $nav_tab_link = $nav_menu_selected_id |
|
451 | - ? esc_url( |
|
452 | - add_query_arg( |
|
453 | - 'extra-nav-menu-pages-tab', |
|
454 | - 'event-archives', |
|
455 | - remove_query_arg($removed_args) |
|
456 | - ) |
|
457 | - ) |
|
458 | - : ''; |
|
459 | - $select_all_link = esc_url( |
|
460 | - add_query_arg( |
|
461 | - [ |
|
462 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
463 | - 'selectall' => 1, |
|
464 | - ], |
|
465 | - remove_query_arg($removed_args) |
|
466 | - ) |
|
467 | - ); |
|
468 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
469 | - $args['walker'] = new Walker_Nav_Menu_Checklist(false); |
|
470 | - $nav_menu_pages_items = walk_nav_menu_tree( |
|
471 | - array_map( |
|
472 | - [$this, '_setup_extra_nav_menu_pages_items'], |
|
473 | - $pages |
|
474 | - ), |
|
475 | - 0, |
|
476 | - (object) $args |
|
477 | - ); |
|
478 | - EEH_Template::display_template( |
|
479 | - EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php', |
|
480 | - [ |
|
481 | - 'nav_menu_selected_id' => $nav_menu_selected_id, |
|
482 | - 'nav_menu_pages_items' => $nav_menu_pages_items, |
|
483 | - 'nav_tab_link' => $nav_tab_link, |
|
484 | - 'select_all_link' => $select_all_link, |
|
485 | - ] |
|
486 | - ); |
|
487 | - } |
|
488 | - |
|
489 | - |
|
490 | - /** |
|
491 | - * Returns an array of event archive nav items. |
|
492 | - * |
|
493 | - * @return array |
|
494 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
495 | - * method we use for getting the extra nav menu items |
|
496 | - */ |
|
497 | - private function _get_extra_nav_menu_pages_items() |
|
498 | - { |
|
499 | - $menuitems[] = [ |
|
500 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
501 | - 'url' => get_post_type_archive_link(EspressoPostType::EVENTS), |
|
502 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
503 | - ]; |
|
504 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
510 | - * the properties and converts it to the menu item object. |
|
511 | - * |
|
512 | - * @param $menu_item_values |
|
513 | - * @return stdClass |
|
514 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
515 | - */ |
|
516 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
517 | - { |
|
518 | - $menu_item = new stdClass(); |
|
519 | - $keys = [ |
|
520 | - 'ID' => 0, |
|
521 | - 'db_id' => 0, |
|
522 | - 'menu_item_parent' => 0, |
|
523 | - 'object_id' => -1, |
|
524 | - 'post_parent' => 0, |
|
525 | - 'type' => 'custom', |
|
526 | - 'object' => '', |
|
527 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
528 | - 'title' => '', |
|
529 | - 'url' => '', |
|
530 | - 'target' => '', |
|
531 | - 'attr_title' => '', |
|
532 | - 'description' => '', |
|
533 | - 'classes' => [], |
|
534 | - 'xfn' => '', |
|
535 | - ]; |
|
536 | - foreach ($keys as $key => $value) { |
|
537 | - $menu_item->{$key} = $menu_item_values[ $key ] ?? $value; |
|
538 | - } |
|
539 | - return $menu_item; |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - /** |
|
544 | - * admin_init |
|
545 | - * |
|
546 | - * @return void |
|
547 | - * @throws InvalidArgumentException |
|
548 | - * @throws InvalidDataTypeException |
|
549 | - * @throws InvalidInterfaceException |
|
550 | - */ |
|
551 | - public function admin_init() |
|
552 | - { |
|
553 | - /** |
|
554 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
555 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
556 | - * - check if doing post processing. |
|
557 | - * - check if doing post processing of one of EE CPTs |
|
558 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
559 | - */ |
|
560 | - $action = $this->request->getRequestParam('action'); |
|
561 | - $post_type = $this->request->getRequestParam('post_type'); |
|
562 | - if ($post_type && $action === 'editpost') { |
|
563 | - /** @var CustomPostTypeDefinitions $custom_post_types */ |
|
564 | - $custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class); |
|
565 | - $custom_post_types->getCustomPostTypeModels($post_type); |
|
566 | - } |
|
567 | - |
|
568 | - |
|
569 | - if (! $this->request->isAjax()) { |
|
570 | - /** |
|
571 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
572 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
573 | - * Pages" tab in the EE General Settings Admin page. |
|
574 | - * This is for user-proofing. |
|
575 | - */ |
|
576 | - add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']); |
|
577 | - if (DbStatus::isOnline()) { |
|
578 | - $this->adminInitModelsReady(); |
|
579 | - } |
|
580 | - } |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode) |
|
586 | - */ |
|
587 | - protected function adminInitModelsReady() |
|
588 | - { |
|
589 | - if (function_exists('wp_add_privacy_policy_content')) { |
|
590 | - $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); |
|
591 | - } |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - /** |
|
596 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
597 | - * |
|
598 | - * @param string $output Current output. |
|
599 | - * @return string |
|
600 | - * @throws InvalidArgumentException |
|
601 | - * @throws InvalidDataTypeException |
|
602 | - * @throws InvalidInterfaceException |
|
603 | - */ |
|
604 | - public function modify_dropdown_pages($output) |
|
605 | - { |
|
606 | - // get critical pages |
|
607 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
608 | - |
|
609 | - // split current output by line break for easier parsing. |
|
610 | - $split_output = explode("\n", $output); |
|
611 | - |
|
612 | - // loop through to remove any critical pages from the array. |
|
613 | - foreach ($critical_pages as $page_id) { |
|
614 | - $needle = 'value="' . $page_id . '"'; |
|
615 | - foreach ($split_output as $key => $haystack) { |
|
616 | - if (strpos($haystack, $needle) !== false) { |
|
617 | - unset($split_output[ $key ]); |
|
618 | - } |
|
619 | - } |
|
620 | - } |
|
621 | - // replace output with the new contents |
|
622 | - return implode("\n", $split_output); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * display_admin_notices |
|
628 | - * |
|
629 | - * @return void |
|
630 | - */ |
|
631 | - public function display_admin_notices() |
|
632 | - { |
|
633 | - echo EE_Error::get_notices(); // already escaped |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * @param array $elements |
|
639 | - * @return array |
|
640 | - * @throws EE_Error |
|
641 | - * @throws InvalidArgumentException |
|
642 | - * @throws InvalidDataTypeException |
|
643 | - * @throws InvalidInterfaceException |
|
644 | - * @throws ReflectionException |
|
645 | - */ |
|
646 | - public function dashboard_glance_items($elements) |
|
647 | - { |
|
648 | - $elements = is_array($elements) ? $elements : [$elements]; |
|
649 | - $events = EEM_Event::instance()->count(); |
|
650 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
651 | - ['page' => 'espresso_events'], |
|
652 | - admin_url('admin.php') |
|
653 | - ); |
|
654 | - $items['events']['text'] = sprintf( |
|
655 | - esc_html( |
|
656 | - _n('%s Event', '%s Events', $events, 'event_espresso') |
|
657 | - ), |
|
658 | - number_format_i18n($events) |
|
659 | - ); |
|
660 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
661 | - $registrations = EEM_Registration::instance()->count( |
|
662 | - [ |
|
663 | - [ |
|
664 | - 'STS_ID' => ['!=', RegStatus::INCOMPLETE], |
|
665 | - ], |
|
666 | - ] |
|
667 | - ); |
|
668 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
669 | - ['page' => 'espresso_registrations'], |
|
670 | - admin_url('admin.php') |
|
671 | - ); |
|
672 | - $items['registrations']['text'] = sprintf( |
|
673 | - esc_html( |
|
674 | - _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
|
675 | - ), |
|
676 | - number_format_i18n($registrations) |
|
677 | - ); |
|
678 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
679 | - |
|
680 | - $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
681 | - |
|
682 | - foreach ($items as $type => $item_properties) { |
|
683 | - $elements[] = sprintf( |
|
684 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
685 | - $item_properties['url'], |
|
686 | - $item_properties['title'], |
|
687 | - $item_properties['text'] |
|
688 | - ); |
|
689 | - } |
|
690 | - return $elements; |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * check_for_invalid_datetime_formats |
|
696 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
697 | - * their selected format can be parsed by PHP |
|
698 | - * |
|
699 | - * @param $value |
|
700 | - * @param $option |
|
701 | - * @return string |
|
702 | - */ |
|
703 | - public function check_for_invalid_datetime_formats($value, $option) |
|
704 | - { |
|
705 | - // check for date_format or time_format |
|
706 | - switch ($option) { |
|
707 | - case 'date_format': |
|
708 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
709 | - break; |
|
710 | - case 'time_format': |
|
711 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
712 | - break; |
|
713 | - default: |
|
714 | - $date_time_format = false; |
|
715 | - } |
|
716 | - // do we have a date_time format to check ? |
|
717 | - if ($date_time_format) { |
|
718 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
719 | - |
|
720 | - if (is_array($error_msg)) { |
|
721 | - $msg = '<p>' |
|
722 | - . sprintf( |
|
723 | - esc_html__( |
|
724 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
725 | - 'event_espresso' |
|
726 | - ), |
|
727 | - date($date_time_format), |
|
728 | - $date_time_format |
|
729 | - ) |
|
730 | - . '</p><p><ul>'; |
|
731 | - |
|
732 | - |
|
733 | - foreach ($error_msg as $error) { |
|
734 | - $msg .= '<li>' . $error . '</li>'; |
|
735 | - } |
|
736 | - |
|
737 | - $msg .= '</ul></p><p>' |
|
738 | - . sprintf( |
|
739 | - esc_html__( |
|
740 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
741 | - 'event_espresso' |
|
742 | - ), |
|
743 | - '<span style="color:#D54E21;">', |
|
744 | - '</span>' |
|
745 | - ) |
|
746 | - . '</p>'; |
|
747 | - |
|
748 | - // trigger WP settings error |
|
749 | - add_settings_error( |
|
750 | - 'date_format', |
|
751 | - 'date_format', |
|
752 | - $msg |
|
753 | - ); |
|
754 | - |
|
755 | - // set format to something valid |
|
756 | - switch ($option) { |
|
757 | - case 'date_format': |
|
758 | - $value = 'F j, Y'; |
|
759 | - break; |
|
760 | - case 'time_format': |
|
761 | - $value = 'g:i a'; |
|
762 | - break; |
|
763 | - } |
|
764 | - } |
|
765 | - } |
|
766 | - return $value; |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - /** |
|
771 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
772 | - * |
|
773 | - * @param $content |
|
774 | - * @return string |
|
775 | - */ |
|
776 | - public function its_eSpresso($content) |
|
777 | - { |
|
778 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
779 | - } |
|
780 | - |
|
781 | - |
|
782 | - /** |
|
783 | - * espresso_admin_footer |
|
784 | - * |
|
785 | - * @return string |
|
786 | - */ |
|
787 | - public function espresso_admin_footer() |
|
788 | - { |
|
789 | - return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']); |
|
790 | - } |
|
791 | - |
|
792 | - |
|
793 | - /** |
|
794 | - * Hooks into the "post states" filter in a wp post type list table. |
|
795 | - * |
|
796 | - * @param array $post_states |
|
797 | - * @param WP_Post $post |
|
798 | - * @return array |
|
799 | - * @throws InvalidArgumentException |
|
800 | - * @throws InvalidDataTypeException |
|
801 | - * @throws InvalidInterfaceException |
|
802 | - */ |
|
803 | - public function displayStateForCriticalPages($post_states, $post) |
|
804 | - { |
|
805 | - $post_states = (array) $post_states; |
|
806 | - if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
807 | - return $post_states; |
|
808 | - } |
|
809 | - /** @var EE_Core_Config $config */ |
|
810 | - $config = $this->loader->getShared('EE_Config')->core; |
|
811 | - if (in_array($post->ID, $config->get_critical_pages_array(), true)) { |
|
812 | - $post_states[] = sprintf( |
|
813 | - /* Translators: Using company name - Event Espresso Critical Page */ |
|
814 | - esc_html__('%s Critical Page', 'event_espresso'), |
|
815 | - 'Event Espresso' |
|
816 | - ); |
|
817 | - } |
|
818 | - return $post_states; |
|
819 | - } |
|
820 | - |
|
821 | - |
|
822 | - /** |
|
823 | - * Show documentation links on the plugins page |
|
824 | - * |
|
825 | - * @param mixed $meta Plugin Row Meta |
|
826 | - * @param mixed $file Plugin Base file |
|
827 | - * @return array |
|
828 | - */ |
|
829 | - public function addLinksToPluginRowMeta($meta, $file) |
|
830 | - { |
|
831 | - if (EE_PLUGIN_BASENAME === $file) { |
|
832 | - $row_meta = [ |
|
833 | - 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"' |
|
834 | - . ' aria-label="' |
|
835 | - . esc_attr__('View Event Espresso documentation', 'event_espresso') |
|
836 | - . '">' |
|
837 | - . esc_html__('Docs', 'event_espresso') |
|
838 | - . '</a>', |
|
839 | - 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"' |
|
840 | - . ' aria-label="' |
|
841 | - . esc_attr__('View Event Espresso API docs', 'event_espresso') |
|
842 | - . '">' |
|
843 | - . esc_html__('API docs', 'event_espresso') |
|
844 | - . '</a>', |
|
845 | - ]; |
|
846 | - return array_merge($meta, $row_meta); |
|
847 | - } |
|
848 | - return (array) $meta; |
|
849 | - } |
|
850 | - |
|
851 | - /**************************************************************************************/ |
|
852 | - /************************************* DEPRECATED *************************************/ |
|
853 | - /**************************************************************************************/ |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
858 | - * EE_Admin_Page route is called. |
|
859 | - * |
|
860 | - * @return void |
|
861 | - */ |
|
862 | - public function route_admin_request() |
|
863 | - { |
|
864 | - } |
|
865 | - |
|
866 | - |
|
867 | - /** |
|
868 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
869 | - * |
|
870 | - * @return void |
|
871 | - */ |
|
872 | - public function wp_loaded() |
|
873 | - { |
|
874 | - } |
|
875 | - |
|
876 | - |
|
877 | - /** |
|
878 | - * static method for registering ee admin page. |
|
879 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
880 | - * |
|
881 | - * @param $page_basename |
|
882 | - * @param $page_path |
|
883 | - * @param array $config |
|
884 | - * @return void |
|
885 | - * @throws EE_Error |
|
886 | - * @see EE_Register_Admin_Page::register() |
|
887 | - * @since 4.3.0 |
|
888 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
889 | - */ |
|
890 | - public static function register_ee_admin_page($page_basename, $page_path, $config = []) |
|
891 | - { |
|
892 | - EE_Error::doing_it_wrong( |
|
893 | - __METHOD__, |
|
894 | - sprintf( |
|
895 | - esc_html__( |
|
896 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
897 | - 'event_espresso' |
|
898 | - ), |
|
899 | - $page_basename |
|
900 | - ), |
|
901 | - '4.3' |
|
902 | - ); |
|
903 | - if (class_exists('EE_Register_Admin_Page')) { |
|
904 | - $config['page_path'] = $page_path; |
|
905 | - } |
|
906 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
907 | - } |
|
908 | - |
|
909 | - |
|
910 | - /** |
|
911 | - * @param int $post_ID |
|
912 | - * @param WP_Post $post |
|
913 | - * @return void |
|
914 | - * @deprecated 4.8.41 |
|
915 | - */ |
|
916 | - public static function parse_post_content_on_save($post_ID, $post) |
|
917 | - { |
|
918 | - EE_Error::doing_it_wrong( |
|
919 | - __METHOD__, |
|
920 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
921 | - '4.8.41' |
|
922 | - ); |
|
923 | - } |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * @param $option |
|
928 | - * @param $old_value |
|
929 | - * @param $value |
|
930 | - * @return void |
|
931 | - * @deprecated 4.8.41 |
|
932 | - */ |
|
933 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
934 | - { |
|
935 | - EE_Error::doing_it_wrong( |
|
936 | - __METHOD__, |
|
937 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
938 | - '4.8.41' |
|
939 | - ); |
|
940 | - } |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * @return void |
|
945 | - * @deprecated 4.9.27 |
|
946 | - */ |
|
947 | - public function get_persistent_admin_notices() |
|
948 | - { |
|
949 | - EE_Error::doing_it_wrong( |
|
950 | - __METHOD__, |
|
951 | - sprintf( |
|
952 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
953 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
954 | - ), |
|
955 | - '4.9.27' |
|
956 | - ); |
|
957 | - } |
|
958 | - |
|
959 | - |
|
960 | - /** |
|
961 | - * @throws InvalidInterfaceException |
|
962 | - * @throws InvalidDataTypeException |
|
963 | - * @throws DomainException |
|
964 | - * @deprecated 4.9.27 |
|
965 | - */ |
|
966 | - public function dismiss_ee_nag_notice_callback() |
|
967 | - { |
|
968 | - EE_Error::doing_it_wrong( |
|
969 | - __METHOD__, |
|
970 | - sprintf( |
|
971 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
972 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
973 | - ), |
|
974 | - '4.9.27' |
|
975 | - ); |
|
976 | - $this->persistent_admin_notice_manager->dismissNotice(); |
|
977 | - } |
|
978 | - |
|
979 | - |
|
980 | - /** |
|
981 | - * @return void |
|
982 | - * @deprecated 5.0.0.p |
|
983 | - */ |
|
984 | - public function enqueue_admin_scripts() |
|
985 | - { |
|
986 | - } |
|
987 | - |
|
988 | - |
|
989 | - |
|
990 | - /** |
|
991 | - * @return RequestInterface |
|
992 | - * @deprecated 5.0.0.p |
|
993 | - */ |
|
994 | - public function get_request() |
|
995 | - { |
|
996 | - EE_Error::doing_it_wrong( |
|
997 | - __METHOD__, |
|
998 | - sprintf( |
|
999 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1000 | - 'EventEspresso\core\services\request\Request' |
|
1001 | - ), |
|
1002 | - '5.0.0.p' |
|
1003 | - ); |
|
1004 | - return $this->request; |
|
1005 | - } |
|
1006 | - |
|
1007 | - |
|
1008 | - /** |
|
1009 | - * @deprecated 5.0.0.p |
|
1010 | - */ |
|
1011 | - public function hookIntoWpPluginsPage() |
|
1012 | - { |
|
1013 | - } |
|
27 | + private static ?EE_Admin $_instance = null; |
|
28 | + |
|
29 | + private ?PersistentAdminNoticeManager $persistent_admin_notice_manager = null; |
|
30 | + |
|
31 | + protected LoaderInterface $loader; |
|
32 | + |
|
33 | + protected RequestInterface $request; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @singleton method used to instantiate class object |
|
38 | + * @param LoaderInterface|null $loader |
|
39 | + * @param RequestInterface|null $request |
|
40 | + * @return EE_Admin|null |
|
41 | + * @throws EE_Error |
|
42 | + */ |
|
43 | + public static function instance(?LoaderInterface $loader = null, ?RequestInterface $request = null): ?EE_Admin |
|
44 | + { |
|
45 | + // check if class object is instantiated |
|
46 | + if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
47 | + EE_Admin::$_instance = new EE_Admin($loader, $request); |
|
48 | + } |
|
49 | + return EE_Admin::$_instance; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return EE_Admin|null |
|
55 | + * @throws EE_Error |
|
56 | + */ |
|
57 | + public static function reset(): ?EE_Admin |
|
58 | + { |
|
59 | + EE_Admin::$_instance = null; |
|
60 | + $loader = LoaderFactory::getLoader(); |
|
61 | + $request = $loader->getShared('EventEspresso\core\services\request\Request'); |
|
62 | + return EE_Admin::instance($loader, $request); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @param LoaderInterface $loader |
|
68 | + * @param RequestInterface $request |
|
69 | + * @throws EE_Error |
|
70 | + * @throws InvalidDataTypeException |
|
71 | + * @throws InvalidInterfaceException |
|
72 | + * @throws InvalidArgumentException |
|
73 | + */ |
|
74 | + protected function __construct(LoaderInterface $loader, RequestInterface $request) |
|
75 | + { |
|
76 | + $this->loader = $loader; |
|
77 | + $this->request = $request; |
|
78 | + // define global EE_Admin constants |
|
79 | + $this->_define_all_constants(); |
|
80 | + // set autoloaders for our admin page classes based on included path information |
|
81 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
82 | + // reset Environment config (we only do this on admin page loads); |
|
83 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
84 | + // load EE_Request_Handler early |
|
85 | + add_action('AHEE__EE_System__initialize_last', [$this, 'init']); |
|
86 | + add_action('admin_init', [$this, 'admin_init'], 100); |
|
87 | + if (! $this->request->isActivation() && ! $this->request->isAjax()) { |
|
88 | + // admin hooks |
|
89 | + add_action('admin_notices', [$this, 'display_admin_notices']); |
|
90 | + add_action('network_admin_notices', [$this, 'display_admin_notices']); |
|
91 | + add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2); |
|
92 | + add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
|
93 | + add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
|
94 | + add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2); |
|
95 | + add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2); |
|
96 | + } |
|
97 | + do_action('AHEE__EE_Admin__loaded'); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * _define_all_constants |
|
103 | + * define constants that are set globally for all admin pages |
|
104 | + * |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + private function _define_all_constants() |
|
108 | + { |
|
109 | + if (! defined('EE_ADMIN_URL')) { |
|
110 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
111 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
112 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
113 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
114 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
121 | + * |
|
122 | + * @param array $links |
|
123 | + * @param string $plugin |
|
124 | + * @return array |
|
125 | + */ |
|
126 | + public function filter_plugin_actions($links, $plugin) |
|
127 | + { |
|
128 | + // set $main_file in stone |
|
129 | + static $main_file; |
|
130 | + // if $main_file is not set yet |
|
131 | + if (! $main_file) { |
|
132 | + $main_file = EE_PLUGIN_BASENAME; |
|
133 | + } |
|
134 | + if ($plugin === $main_file) { |
|
135 | + // compare current plugin to this one |
|
136 | + if (MaintenanceStatus::isFullSite()) { |
|
137 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
138 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
139 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
140 | + . '</a>'; |
|
141 | + array_unshift($links, $maintenance_link); |
|
142 | + } else { |
|
143 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
144 | + . esc_html__('Settings', 'event_espresso') |
|
145 | + . '</a>'; |
|
146 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
147 | + . esc_html__('Events', 'event_espresso') |
|
148 | + . '</a>'; |
|
149 | + // add before other links |
|
150 | + array_unshift($links, $org_settings_link, $events_link); |
|
151 | + } |
|
152 | + } |
|
153 | + return $links; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * hide_admin_pages_except_maintenance_mode |
|
159 | + * |
|
160 | + * @param array $admin_page_folder_names |
|
161 | + * @return array |
|
162 | + */ |
|
163 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = []) |
|
164 | + { |
|
165 | + return [ |
|
166 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
167 | + 'about' => EE_ADMIN_PAGES . 'about/', |
|
168 | + 'support' => EE_ADMIN_PAGES . 'support/', |
|
169 | + ]; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
175 | + * EE_Front_Controller's init phases have run |
|
176 | + * |
|
177 | + * @return void |
|
178 | + * @throws EE_Error |
|
179 | + * @throws InvalidArgumentException |
|
180 | + * @throws InvalidDataTypeException |
|
181 | + * @throws InvalidInterfaceException |
|
182 | + * @throws ReflectionException |
|
183 | + * @throws ServiceNotFoundException |
|
184 | + */ |
|
185 | + public function init() |
|
186 | + { |
|
187 | + // only enable most of the EE_Admin IF we're not in full maintenance mode |
|
188 | + if (DbStatus::isOnline()) { |
|
189 | + $this->initModelsReady(); |
|
190 | + } |
|
191 | + // run the admin page factory but ONLY if: |
|
192 | + // - it is a regular non ajax admin request |
|
193 | + // - we are doing an ee admin ajax request |
|
194 | + if ($this->request->isAdmin() || $this->request->isAdminAjax() || $this->request->isActivation()) { |
|
195 | + try { |
|
196 | + // this loads the controller for the admin pages which will setup routing etc |
|
197 | + $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]); |
|
198 | + /** @var EE_Admin_Page_Loader $admin_page_loader */ |
|
199 | + $admin_page_loader->init(); |
|
200 | + } catch (EE_Error $e) { |
|
201 | + $e->get_error(); |
|
202 | + } |
|
203 | + } |
|
204 | + if ($this->request->isAjax()) { |
|
205 | + return; |
|
206 | + } |
|
207 | + add_filter('content_save_pre', [$this, 'its_eSpresso']); |
|
208 | + // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
209 | + add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes']); |
|
210 | + add_action('admin_head', [$this, 'register_custom_nav_menu_boxes']); |
|
211 | + // exclude EE critical pages from all nav menus and wp_list_pages |
|
212 | + add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu']); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * Gets the loader (and if it wasn't previously set, sets it) |
|
218 | + * |
|
219 | + * @return LoaderInterface |
|
220 | + * @throws InvalidArgumentException |
|
221 | + * @throws InvalidDataTypeException |
|
222 | + * @throws InvalidInterfaceException |
|
223 | + */ |
|
224 | + protected function getLoader() |
|
225 | + { |
|
226 | + return $this->loader; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * Method that's fired on admin requests (including admin ajax) but only when the models are usable |
|
232 | + * (ie, the site isn't in maintenance mode) |
|
233 | + * |
|
234 | + * @return void |
|
235 | + * @throws EE_Error |
|
236 | + * @since 4.9.63.p |
|
237 | + */ |
|
238 | + protected function initModelsReady() |
|
239 | + { |
|
240 | + // ok so we want to enable the entire admin |
|
241 | + $this->persistent_admin_notice_manager = $this->loader->getShared( |
|
242 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
243 | + ); |
|
244 | + $this->persistent_admin_notice_manager->setReturnUrl( |
|
245 | + EE_Admin_Page::add_query_args_and_nonce( |
|
246 | + [ |
|
247 | + 'page' => $this->request->getRequestParam('page', ''), |
|
248 | + 'action' => $this->request->getRequestParam('action', ''), |
|
249 | + ], |
|
250 | + EE_ADMIN_URL |
|
251 | + ) |
|
252 | + ); |
|
253 | + $this->maybeSetDatetimeWarningNotice(); |
|
254 | + // at a glance dashboard widget |
|
255 | + add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items']); |
|
256 | + // filter for get_edit_post_link used on comments for custom post types |
|
257 | + add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * get_persistent_admin_notices |
|
263 | + * |
|
264 | + * @access public |
|
265 | + * @return void |
|
266 | + * @throws EE_Error |
|
267 | + * @throws InvalidArgumentException |
|
268 | + * @throws InvalidDataTypeException |
|
269 | + * @throws InvalidInterfaceException |
|
270 | + * @throws ReflectionException |
|
271 | + */ |
|
272 | + public function maybeSetDatetimeWarningNotice() |
|
273 | + { |
|
274 | + // add dismissible notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
275 | + // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
276 | + // with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
277 | + // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
278 | + if ( |
|
279 | + apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
280 | + && ! get_option('timezone_string') |
|
281 | + && EEM_Event::instance()->count() > 0 |
|
282 | + ) { |
|
283 | + new PersistentAdminNotice( |
|
284 | + 'datetime_fix_notice', |
|
285 | + sprintf( |
|
286 | + esc_html__( |
|
287 | + '%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.', |
|
288 | + 'event_espresso' |
|
289 | + ), |
|
290 | + '<strong>', |
|
291 | + '</strong>', |
|
292 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
293 | + '</a>', |
|
294 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
295 | + [ |
|
296 | + 'page' => 'espresso_maintenance_settings', |
|
297 | + 'action' => 'datetime_tools', |
|
298 | + ], |
|
299 | + admin_url('admin.php') |
|
300 | + ) . '">' |
|
301 | + ), |
|
302 | + false, |
|
303 | + 'manage_options', |
|
304 | + 'datetime_fix_persistent_notice' |
|
305 | + ); |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
312 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
313 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
314 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
315 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
316 | + * |
|
317 | + * @param WP_Post $post_type WP post type object |
|
318 | + * @return WP_Post |
|
319 | + * @throws InvalidArgumentException |
|
320 | + * @throws InvalidDataTypeException |
|
321 | + * @throws InvalidInterfaceException |
|
322 | + */ |
|
323 | + public function remove_pages_from_nav_menu($post_type) |
|
324 | + { |
|
325 | + // if this isn't the "pages" post type let's get out |
|
326 | + if ($post_type->name !== 'page') { |
|
327 | + return $post_type; |
|
328 | + } |
|
329 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
330 | + $post_type->_default_query = [ |
|
331 | + 'post__not_in' => $critical_pages, |
|
332 | + ]; |
|
333 | + return $post_type; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. |
|
339 | + * We want to make sure our metaboxes get shown as well |
|
340 | + * |
|
341 | + * @return void |
|
342 | + */ |
|
343 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
344 | + { |
|
345 | + global $wp_meta_boxes, $pagenow; |
|
346 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
347 | + return; |
|
348 | + } |
|
349 | + $user = wp_get_current_user(); |
|
350 | + // has this been done yet? |
|
351 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
352 | + return; |
|
353 | + } |
|
354 | + |
|
355 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
356 | + $initial_meta_boxes = apply_filters( |
|
357 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
358 | + [ |
|
359 | + 'nav-menu-theme-locations', |
|
360 | + 'add-page', |
|
361 | + 'add-custom-links', |
|
362 | + 'add-category', |
|
363 | + 'add-espresso_events', |
|
364 | + 'add-espresso_venues', |
|
365 | + 'add-espresso_event_categories', |
|
366 | + 'add-espresso_venue_categories', |
|
367 | + 'add-post-type-post', |
|
368 | + 'add-post-type-page', |
|
369 | + ] |
|
370 | + ); |
|
371 | + |
|
372 | + if (is_array($hidden_meta_boxes)) { |
|
373 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
374 | + if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
375 | + unset($hidden_meta_boxes[ $key ]); |
|
376 | + } |
|
377 | + } |
|
378 | + } |
|
379 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
380 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
386 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
387 | + * |
|
388 | + * @return void |
|
389 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
390 | + * addons etc. |
|
391 | + */ |
|
392 | + public function register_custom_nav_menu_boxes() |
|
393 | + { |
|
394 | + add_meta_box( |
|
395 | + 'add-extra-nav-menu-pages', |
|
396 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
397 | + [$this, 'ee_cpt_archive_pages'], |
|
398 | + 'nav-menus', |
|
399 | + 'side', |
|
400 | + 'core' |
|
401 | + ); |
|
402 | + add_filter( |
|
403 | + "postbox_classes_nav-menus_add-extra-nav-menu-pages", |
|
404 | + function ($classes) { |
|
405 | + $classes[] = 'ee-admin-container'; |
|
406 | + return $classes; |
|
407 | + } |
|
408 | + ); |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + /** |
|
413 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
414 | + * |
|
415 | + * @param string $link the original link generated by wp |
|
416 | + * @param int $id post id |
|
417 | + * @return string the (maybe) modified link |
|
418 | + * @since 4.3.0 |
|
419 | + */ |
|
420 | + public function modify_edit_post_link($link, $id) |
|
421 | + { |
|
422 | + if (! $post = get_post($id)) { |
|
423 | + return $link; |
|
424 | + } |
|
425 | + if ($post->post_type === EspressoPostType::ATTENDEES) { |
|
426 | + $query_args = [ |
|
427 | + 'action' => 'edit_attendee', |
|
428 | + 'post' => $id, |
|
429 | + ]; |
|
430 | + return EEH_URL::add_query_args_and_nonce( |
|
431 | + $query_args, |
|
432 | + admin_url('admin.php?page=espresso_registrations') |
|
433 | + ); |
|
434 | + } |
|
435 | + return $link; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + public function ee_cpt_archive_pages() |
|
440 | + { |
|
441 | + global $nav_menu_selected_id; |
|
442 | + $removed_args = [ |
|
443 | + 'action', |
|
444 | + 'customlink-tab', |
|
445 | + 'edit-menu-item', |
|
446 | + 'menu-item', |
|
447 | + 'page-tab', |
|
448 | + '_wpnonce', |
|
449 | + ]; |
|
450 | + $nav_tab_link = $nav_menu_selected_id |
|
451 | + ? esc_url( |
|
452 | + add_query_arg( |
|
453 | + 'extra-nav-menu-pages-tab', |
|
454 | + 'event-archives', |
|
455 | + remove_query_arg($removed_args) |
|
456 | + ) |
|
457 | + ) |
|
458 | + : ''; |
|
459 | + $select_all_link = esc_url( |
|
460 | + add_query_arg( |
|
461 | + [ |
|
462 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
463 | + 'selectall' => 1, |
|
464 | + ], |
|
465 | + remove_query_arg($removed_args) |
|
466 | + ) |
|
467 | + ); |
|
468 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
469 | + $args['walker'] = new Walker_Nav_Menu_Checklist(false); |
|
470 | + $nav_menu_pages_items = walk_nav_menu_tree( |
|
471 | + array_map( |
|
472 | + [$this, '_setup_extra_nav_menu_pages_items'], |
|
473 | + $pages |
|
474 | + ), |
|
475 | + 0, |
|
476 | + (object) $args |
|
477 | + ); |
|
478 | + EEH_Template::display_template( |
|
479 | + EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php', |
|
480 | + [ |
|
481 | + 'nav_menu_selected_id' => $nav_menu_selected_id, |
|
482 | + 'nav_menu_pages_items' => $nav_menu_pages_items, |
|
483 | + 'nav_tab_link' => $nav_tab_link, |
|
484 | + 'select_all_link' => $select_all_link, |
|
485 | + ] |
|
486 | + ); |
|
487 | + } |
|
488 | + |
|
489 | + |
|
490 | + /** |
|
491 | + * Returns an array of event archive nav items. |
|
492 | + * |
|
493 | + * @return array |
|
494 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
495 | + * method we use for getting the extra nav menu items |
|
496 | + */ |
|
497 | + private function _get_extra_nav_menu_pages_items() |
|
498 | + { |
|
499 | + $menuitems[] = [ |
|
500 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
501 | + 'url' => get_post_type_archive_link(EspressoPostType::EVENTS), |
|
502 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
503 | + ]; |
|
504 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
510 | + * the properties and converts it to the menu item object. |
|
511 | + * |
|
512 | + * @param $menu_item_values |
|
513 | + * @return stdClass |
|
514 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
515 | + */ |
|
516 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
517 | + { |
|
518 | + $menu_item = new stdClass(); |
|
519 | + $keys = [ |
|
520 | + 'ID' => 0, |
|
521 | + 'db_id' => 0, |
|
522 | + 'menu_item_parent' => 0, |
|
523 | + 'object_id' => -1, |
|
524 | + 'post_parent' => 0, |
|
525 | + 'type' => 'custom', |
|
526 | + 'object' => '', |
|
527 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
528 | + 'title' => '', |
|
529 | + 'url' => '', |
|
530 | + 'target' => '', |
|
531 | + 'attr_title' => '', |
|
532 | + 'description' => '', |
|
533 | + 'classes' => [], |
|
534 | + 'xfn' => '', |
|
535 | + ]; |
|
536 | + foreach ($keys as $key => $value) { |
|
537 | + $menu_item->{$key} = $menu_item_values[ $key ] ?? $value; |
|
538 | + } |
|
539 | + return $menu_item; |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + /** |
|
544 | + * admin_init |
|
545 | + * |
|
546 | + * @return void |
|
547 | + * @throws InvalidArgumentException |
|
548 | + * @throws InvalidDataTypeException |
|
549 | + * @throws InvalidInterfaceException |
|
550 | + */ |
|
551 | + public function admin_init() |
|
552 | + { |
|
553 | + /** |
|
554 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
555 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
556 | + * - check if doing post processing. |
|
557 | + * - check if doing post processing of one of EE CPTs |
|
558 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
559 | + */ |
|
560 | + $action = $this->request->getRequestParam('action'); |
|
561 | + $post_type = $this->request->getRequestParam('post_type'); |
|
562 | + if ($post_type && $action === 'editpost') { |
|
563 | + /** @var CustomPostTypeDefinitions $custom_post_types */ |
|
564 | + $custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class); |
|
565 | + $custom_post_types->getCustomPostTypeModels($post_type); |
|
566 | + } |
|
567 | + |
|
568 | + |
|
569 | + if (! $this->request->isAjax()) { |
|
570 | + /** |
|
571 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
572 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
573 | + * Pages" tab in the EE General Settings Admin page. |
|
574 | + * This is for user-proofing. |
|
575 | + */ |
|
576 | + add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']); |
|
577 | + if (DbStatus::isOnline()) { |
|
578 | + $this->adminInitModelsReady(); |
|
579 | + } |
|
580 | + } |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode) |
|
586 | + */ |
|
587 | + protected function adminInitModelsReady() |
|
588 | + { |
|
589 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
590 | + $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); |
|
591 | + } |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + /** |
|
596 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
597 | + * |
|
598 | + * @param string $output Current output. |
|
599 | + * @return string |
|
600 | + * @throws InvalidArgumentException |
|
601 | + * @throws InvalidDataTypeException |
|
602 | + * @throws InvalidInterfaceException |
|
603 | + */ |
|
604 | + public function modify_dropdown_pages($output) |
|
605 | + { |
|
606 | + // get critical pages |
|
607 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
608 | + |
|
609 | + // split current output by line break for easier parsing. |
|
610 | + $split_output = explode("\n", $output); |
|
611 | + |
|
612 | + // loop through to remove any critical pages from the array. |
|
613 | + foreach ($critical_pages as $page_id) { |
|
614 | + $needle = 'value="' . $page_id . '"'; |
|
615 | + foreach ($split_output as $key => $haystack) { |
|
616 | + if (strpos($haystack, $needle) !== false) { |
|
617 | + unset($split_output[ $key ]); |
|
618 | + } |
|
619 | + } |
|
620 | + } |
|
621 | + // replace output with the new contents |
|
622 | + return implode("\n", $split_output); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * display_admin_notices |
|
628 | + * |
|
629 | + * @return void |
|
630 | + */ |
|
631 | + public function display_admin_notices() |
|
632 | + { |
|
633 | + echo EE_Error::get_notices(); // already escaped |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * @param array $elements |
|
639 | + * @return array |
|
640 | + * @throws EE_Error |
|
641 | + * @throws InvalidArgumentException |
|
642 | + * @throws InvalidDataTypeException |
|
643 | + * @throws InvalidInterfaceException |
|
644 | + * @throws ReflectionException |
|
645 | + */ |
|
646 | + public function dashboard_glance_items($elements) |
|
647 | + { |
|
648 | + $elements = is_array($elements) ? $elements : [$elements]; |
|
649 | + $events = EEM_Event::instance()->count(); |
|
650 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
651 | + ['page' => 'espresso_events'], |
|
652 | + admin_url('admin.php') |
|
653 | + ); |
|
654 | + $items['events']['text'] = sprintf( |
|
655 | + esc_html( |
|
656 | + _n('%s Event', '%s Events', $events, 'event_espresso') |
|
657 | + ), |
|
658 | + number_format_i18n($events) |
|
659 | + ); |
|
660 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
661 | + $registrations = EEM_Registration::instance()->count( |
|
662 | + [ |
|
663 | + [ |
|
664 | + 'STS_ID' => ['!=', RegStatus::INCOMPLETE], |
|
665 | + ], |
|
666 | + ] |
|
667 | + ); |
|
668 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
669 | + ['page' => 'espresso_registrations'], |
|
670 | + admin_url('admin.php') |
|
671 | + ); |
|
672 | + $items['registrations']['text'] = sprintf( |
|
673 | + esc_html( |
|
674 | + _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
|
675 | + ), |
|
676 | + number_format_i18n($registrations) |
|
677 | + ); |
|
678 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
679 | + |
|
680 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
681 | + |
|
682 | + foreach ($items as $type => $item_properties) { |
|
683 | + $elements[] = sprintf( |
|
684 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
685 | + $item_properties['url'], |
|
686 | + $item_properties['title'], |
|
687 | + $item_properties['text'] |
|
688 | + ); |
|
689 | + } |
|
690 | + return $elements; |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * check_for_invalid_datetime_formats |
|
696 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
697 | + * their selected format can be parsed by PHP |
|
698 | + * |
|
699 | + * @param $value |
|
700 | + * @param $option |
|
701 | + * @return string |
|
702 | + */ |
|
703 | + public function check_for_invalid_datetime_formats($value, $option) |
|
704 | + { |
|
705 | + // check for date_format or time_format |
|
706 | + switch ($option) { |
|
707 | + case 'date_format': |
|
708 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
709 | + break; |
|
710 | + case 'time_format': |
|
711 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
712 | + break; |
|
713 | + default: |
|
714 | + $date_time_format = false; |
|
715 | + } |
|
716 | + // do we have a date_time format to check ? |
|
717 | + if ($date_time_format) { |
|
718 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
719 | + |
|
720 | + if (is_array($error_msg)) { |
|
721 | + $msg = '<p>' |
|
722 | + . sprintf( |
|
723 | + esc_html__( |
|
724 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
725 | + 'event_espresso' |
|
726 | + ), |
|
727 | + date($date_time_format), |
|
728 | + $date_time_format |
|
729 | + ) |
|
730 | + . '</p><p><ul>'; |
|
731 | + |
|
732 | + |
|
733 | + foreach ($error_msg as $error) { |
|
734 | + $msg .= '<li>' . $error . '</li>'; |
|
735 | + } |
|
736 | + |
|
737 | + $msg .= '</ul></p><p>' |
|
738 | + . sprintf( |
|
739 | + esc_html__( |
|
740 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
741 | + 'event_espresso' |
|
742 | + ), |
|
743 | + '<span style="color:#D54E21;">', |
|
744 | + '</span>' |
|
745 | + ) |
|
746 | + . '</p>'; |
|
747 | + |
|
748 | + // trigger WP settings error |
|
749 | + add_settings_error( |
|
750 | + 'date_format', |
|
751 | + 'date_format', |
|
752 | + $msg |
|
753 | + ); |
|
754 | + |
|
755 | + // set format to something valid |
|
756 | + switch ($option) { |
|
757 | + case 'date_format': |
|
758 | + $value = 'F j, Y'; |
|
759 | + break; |
|
760 | + case 'time_format': |
|
761 | + $value = 'g:i a'; |
|
762 | + break; |
|
763 | + } |
|
764 | + } |
|
765 | + } |
|
766 | + return $value; |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + /** |
|
771 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
772 | + * |
|
773 | + * @param $content |
|
774 | + * @return string |
|
775 | + */ |
|
776 | + public function its_eSpresso($content) |
|
777 | + { |
|
778 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
779 | + } |
|
780 | + |
|
781 | + |
|
782 | + /** |
|
783 | + * espresso_admin_footer |
|
784 | + * |
|
785 | + * @return string |
|
786 | + */ |
|
787 | + public function espresso_admin_footer() |
|
788 | + { |
|
789 | + return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']); |
|
790 | + } |
|
791 | + |
|
792 | + |
|
793 | + /** |
|
794 | + * Hooks into the "post states" filter in a wp post type list table. |
|
795 | + * |
|
796 | + * @param array $post_states |
|
797 | + * @param WP_Post $post |
|
798 | + * @return array |
|
799 | + * @throws InvalidArgumentException |
|
800 | + * @throws InvalidDataTypeException |
|
801 | + * @throws InvalidInterfaceException |
|
802 | + */ |
|
803 | + public function displayStateForCriticalPages($post_states, $post) |
|
804 | + { |
|
805 | + $post_states = (array) $post_states; |
|
806 | + if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
807 | + return $post_states; |
|
808 | + } |
|
809 | + /** @var EE_Core_Config $config */ |
|
810 | + $config = $this->loader->getShared('EE_Config')->core; |
|
811 | + if (in_array($post->ID, $config->get_critical_pages_array(), true)) { |
|
812 | + $post_states[] = sprintf( |
|
813 | + /* Translators: Using company name - Event Espresso Critical Page */ |
|
814 | + esc_html__('%s Critical Page', 'event_espresso'), |
|
815 | + 'Event Espresso' |
|
816 | + ); |
|
817 | + } |
|
818 | + return $post_states; |
|
819 | + } |
|
820 | + |
|
821 | + |
|
822 | + /** |
|
823 | + * Show documentation links on the plugins page |
|
824 | + * |
|
825 | + * @param mixed $meta Plugin Row Meta |
|
826 | + * @param mixed $file Plugin Base file |
|
827 | + * @return array |
|
828 | + */ |
|
829 | + public function addLinksToPluginRowMeta($meta, $file) |
|
830 | + { |
|
831 | + if (EE_PLUGIN_BASENAME === $file) { |
|
832 | + $row_meta = [ |
|
833 | + 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"' |
|
834 | + . ' aria-label="' |
|
835 | + . esc_attr__('View Event Espresso documentation', 'event_espresso') |
|
836 | + . '">' |
|
837 | + . esc_html__('Docs', 'event_espresso') |
|
838 | + . '</a>', |
|
839 | + 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"' |
|
840 | + . ' aria-label="' |
|
841 | + . esc_attr__('View Event Espresso API docs', 'event_espresso') |
|
842 | + . '">' |
|
843 | + . esc_html__('API docs', 'event_espresso') |
|
844 | + . '</a>', |
|
845 | + ]; |
|
846 | + return array_merge($meta, $row_meta); |
|
847 | + } |
|
848 | + return (array) $meta; |
|
849 | + } |
|
850 | + |
|
851 | + /**************************************************************************************/ |
|
852 | + /************************************* DEPRECATED *************************************/ |
|
853 | + /**************************************************************************************/ |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
858 | + * EE_Admin_Page route is called. |
|
859 | + * |
|
860 | + * @return void |
|
861 | + */ |
|
862 | + public function route_admin_request() |
|
863 | + { |
|
864 | + } |
|
865 | + |
|
866 | + |
|
867 | + /** |
|
868 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
869 | + * |
|
870 | + * @return void |
|
871 | + */ |
|
872 | + public function wp_loaded() |
|
873 | + { |
|
874 | + } |
|
875 | + |
|
876 | + |
|
877 | + /** |
|
878 | + * static method for registering ee admin page. |
|
879 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
880 | + * |
|
881 | + * @param $page_basename |
|
882 | + * @param $page_path |
|
883 | + * @param array $config |
|
884 | + * @return void |
|
885 | + * @throws EE_Error |
|
886 | + * @see EE_Register_Admin_Page::register() |
|
887 | + * @since 4.3.0 |
|
888 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
889 | + */ |
|
890 | + public static function register_ee_admin_page($page_basename, $page_path, $config = []) |
|
891 | + { |
|
892 | + EE_Error::doing_it_wrong( |
|
893 | + __METHOD__, |
|
894 | + sprintf( |
|
895 | + esc_html__( |
|
896 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
897 | + 'event_espresso' |
|
898 | + ), |
|
899 | + $page_basename |
|
900 | + ), |
|
901 | + '4.3' |
|
902 | + ); |
|
903 | + if (class_exists('EE_Register_Admin_Page')) { |
|
904 | + $config['page_path'] = $page_path; |
|
905 | + } |
|
906 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
907 | + } |
|
908 | + |
|
909 | + |
|
910 | + /** |
|
911 | + * @param int $post_ID |
|
912 | + * @param WP_Post $post |
|
913 | + * @return void |
|
914 | + * @deprecated 4.8.41 |
|
915 | + */ |
|
916 | + public static function parse_post_content_on_save($post_ID, $post) |
|
917 | + { |
|
918 | + EE_Error::doing_it_wrong( |
|
919 | + __METHOD__, |
|
920 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
921 | + '4.8.41' |
|
922 | + ); |
|
923 | + } |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * @param $option |
|
928 | + * @param $old_value |
|
929 | + * @param $value |
|
930 | + * @return void |
|
931 | + * @deprecated 4.8.41 |
|
932 | + */ |
|
933 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
934 | + { |
|
935 | + EE_Error::doing_it_wrong( |
|
936 | + __METHOD__, |
|
937 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
938 | + '4.8.41' |
|
939 | + ); |
|
940 | + } |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * @return void |
|
945 | + * @deprecated 4.9.27 |
|
946 | + */ |
|
947 | + public function get_persistent_admin_notices() |
|
948 | + { |
|
949 | + EE_Error::doing_it_wrong( |
|
950 | + __METHOD__, |
|
951 | + sprintf( |
|
952 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
953 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
954 | + ), |
|
955 | + '4.9.27' |
|
956 | + ); |
|
957 | + } |
|
958 | + |
|
959 | + |
|
960 | + /** |
|
961 | + * @throws InvalidInterfaceException |
|
962 | + * @throws InvalidDataTypeException |
|
963 | + * @throws DomainException |
|
964 | + * @deprecated 4.9.27 |
|
965 | + */ |
|
966 | + public function dismiss_ee_nag_notice_callback() |
|
967 | + { |
|
968 | + EE_Error::doing_it_wrong( |
|
969 | + __METHOD__, |
|
970 | + sprintf( |
|
971 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
972 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
973 | + ), |
|
974 | + '4.9.27' |
|
975 | + ); |
|
976 | + $this->persistent_admin_notice_manager->dismissNotice(); |
|
977 | + } |
|
978 | + |
|
979 | + |
|
980 | + /** |
|
981 | + * @return void |
|
982 | + * @deprecated 5.0.0.p |
|
983 | + */ |
|
984 | + public function enqueue_admin_scripts() |
|
985 | + { |
|
986 | + } |
|
987 | + |
|
988 | + |
|
989 | + |
|
990 | + /** |
|
991 | + * @return RequestInterface |
|
992 | + * @deprecated 5.0.0.p |
|
993 | + */ |
|
994 | + public function get_request() |
|
995 | + { |
|
996 | + EE_Error::doing_it_wrong( |
|
997 | + __METHOD__, |
|
998 | + sprintf( |
|
999 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1000 | + 'EventEspresso\core\services\request\Request' |
|
1001 | + ), |
|
1002 | + '5.0.0.p' |
|
1003 | + ); |
|
1004 | + return $this->request; |
|
1005 | + } |
|
1006 | + |
|
1007 | + |
|
1008 | + /** |
|
1009 | + * @deprecated 5.0.0.p |
|
1010 | + */ |
|
1011 | + public function hookIntoWpPluginsPage() |
|
1012 | + { |
|
1013 | + } |
|
1014 | 1014 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public static function instance(?LoaderInterface $loader = null, ?RequestInterface $request = null): ?EE_Admin |
44 | 44 | { |
45 | 45 | // check if class object is instantiated |
46 | - if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
46 | + if ( ! EE_Admin::$_instance instanceof EE_Admin) { |
|
47 | 47 | EE_Admin::$_instance = new EE_Admin($loader, $request); |
48 | 48 | } |
49 | 49 | return EE_Admin::$_instance; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | // load EE_Request_Handler early |
85 | 85 | add_action('AHEE__EE_System__initialize_last', [$this, 'init']); |
86 | 86 | add_action('admin_init', [$this, 'admin_init'], 100); |
87 | - if (! $this->request->isActivation() && ! $this->request->isAjax()) { |
|
87 | + if ( ! $this->request->isActivation() && ! $this->request->isAjax()) { |
|
88 | 88 | // admin hooks |
89 | 89 | add_action('admin_notices', [$this, 'display_admin_notices']); |
90 | 90 | add_action('network_admin_notices', [$this, 'display_admin_notices']); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function _define_all_constants() |
108 | 108 | { |
109 | - if (! defined('EE_ADMIN_URL')) { |
|
110 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
111 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
112 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
113 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
109 | + if ( ! defined('EE_ADMIN_URL')) { |
|
110 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
111 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
112 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates/'); |
|
113 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
114 | 114 | define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
115 | 115 | } |
116 | 116 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // set $main_file in stone |
129 | 129 | static $main_file; |
130 | 130 | // if $main_file is not set yet |
131 | - if (! $main_file) { |
|
131 | + if ( ! $main_file) { |
|
132 | 132 | $main_file = EE_PLUGIN_BASENAME; |
133 | 133 | } |
134 | 134 | if ($plugin === $main_file) { |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = []) |
164 | 164 | { |
165 | 165 | return [ |
166 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
167 | - 'about' => EE_ADMIN_PAGES . 'about/', |
|
168 | - 'support' => EE_ADMIN_PAGES . 'support/', |
|
166 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance/', |
|
167 | + 'about' => EE_ADMIN_PAGES.'about/', |
|
168 | + 'support' => EE_ADMIN_PAGES.'support/', |
|
169 | 169 | ]; |
170 | 170 | } |
171 | 171 | |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | '</strong>', |
292 | 292 | '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
293 | 293 | '</a>', |
294 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
294 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
295 | 295 | [ |
296 | 296 | 'page' => 'espresso_maintenance_settings', |
297 | 297 | 'action' => 'datetime_tools', |
298 | 298 | ], |
299 | 299 | admin_url('admin.php') |
300 | - ) . '">' |
|
300 | + ).'">' |
|
301 | 301 | ), |
302 | 302 | false, |
303 | 303 | 'manage_options', |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | public function enable_hidden_ee_nav_menu_metaboxes() |
344 | 344 | { |
345 | 345 | global $wp_meta_boxes, $pagenow; |
346 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
346 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
347 | 347 | return; |
348 | 348 | } |
349 | 349 | $user = wp_get_current_user(); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | if (is_array($hidden_meta_boxes)) { |
373 | 373 | foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
374 | 374 | if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
375 | - unset($hidden_meta_boxes[ $key ]); |
|
375 | + unset($hidden_meta_boxes[$key]); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | ); |
402 | 402 | add_filter( |
403 | 403 | "postbox_classes_nav-menus_add-extra-nav-menu-pages", |
404 | - function ($classes) { |
|
404 | + function($classes) { |
|
405 | 405 | $classes[] = 'ee-admin-container'; |
406 | 406 | return $classes; |
407 | 407 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function modify_edit_post_link($link, $id) |
421 | 421 | { |
422 | - if (! $post = get_post($id)) { |
|
422 | + if ( ! $post = get_post($id)) { |
|
423 | 423 | return $link; |
424 | 424 | } |
425 | 425 | if ($post->post_type === EspressoPostType::ATTENDEES) { |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | (object) $args |
477 | 477 | ); |
478 | 478 | EEH_Template::display_template( |
479 | - EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php', |
|
479 | + EE_ADMIN_TEMPLATE.'cpt_archive_page.template.php', |
|
480 | 480 | [ |
481 | 481 | 'nav_menu_selected_id' => $nav_menu_selected_id, |
482 | 482 | 'nav_menu_pages_items' => $nav_menu_pages_items, |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | 'xfn' => '', |
535 | 535 | ]; |
536 | 536 | foreach ($keys as $key => $value) { |
537 | - $menu_item->{$key} = $menu_item_values[ $key ] ?? $value; |
|
537 | + $menu_item->{$key} = $menu_item_values[$key] ?? $value; |
|
538 | 538 | } |
539 | 539 | return $menu_item; |
540 | 540 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | - if (! $this->request->isAjax()) { |
|
569 | + if ( ! $this->request->isAjax()) { |
|
570 | 570 | /** |
571 | 571 | * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
572 | 572 | * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | |
612 | 612 | // loop through to remove any critical pages from the array. |
613 | 613 | foreach ($critical_pages as $page_id) { |
614 | - $needle = 'value="' . $page_id . '"'; |
|
614 | + $needle = 'value="'.$page_id.'"'; |
|
615 | 615 | foreach ($split_output as $key => $haystack) { |
616 | 616 | if (strpos($haystack, $needle) !== false) { |
617 | - unset($split_output[ $key ]); |
|
617 | + unset($split_output[$key]); |
|
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | ['page' => 'espresso_events'], |
652 | 652 | admin_url('admin.php') |
653 | 653 | ); |
654 | - $items['events']['text'] = sprintf( |
|
654 | + $items['events']['text'] = sprintf( |
|
655 | 655 | esc_html( |
656 | 656 | _n('%s Event', '%s Events', $events, 'event_espresso') |
657 | 657 | ), |
@@ -665,11 +665,11 @@ discard block |
||
665 | 665 | ], |
666 | 666 | ] |
667 | 667 | ); |
668 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
668 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
669 | 669 | ['page' => 'espresso_registrations'], |
670 | 670 | admin_url('admin.php') |
671 | 671 | ); |
672 | - $items['registrations']['text'] = sprintf( |
|
672 | + $items['registrations']['text'] = sprintf( |
|
673 | 673 | esc_html( |
674 | 674 | _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
675 | 675 | ), |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | |
682 | 682 | foreach ($items as $type => $item_properties) { |
683 | 683 | $elements[] = sprintf( |
684 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
684 | + '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', |
|
685 | 685 | $item_properties['url'], |
686 | 686 | $item_properties['title'], |
687 | 687 | $item_properties['text'] |
@@ -705,10 +705,10 @@ discard block |
||
705 | 705 | // check for date_format or time_format |
706 | 706 | switch ($option) { |
707 | 707 | case 'date_format': |
708 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
708 | + $date_time_format = $value.' '.get_option('time_format'); |
|
709 | 709 | break; |
710 | 710 | case 'time_format': |
711 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
711 | + $date_time_format = get_option('date_format').' '.$value; |
|
712 | 712 | break; |
713 | 713 | default: |
714 | 714 | $date_time_format = false; |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | |
732 | 732 | |
733 | 733 | foreach ($error_msg as $error) { |
734 | - $msg .= '<li>' . $error . '</li>'; |
|
734 | + $msg .= '<li>'.$error.'</li>'; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | $msg .= '</ul></p><p>' |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | public function displayStateForCriticalPages($post_states, $post) |
804 | 804 | { |
805 | 805 | $post_states = (array) $post_states; |
806 | - if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
806 | + if ( ! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
807 | 807 | return $post_states; |
808 | 808 | } |
809 | 809 | /** @var EE_Core_Config $config */ |
@@ -18,119 +18,119 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class EE_Admin_Page_Loader |
20 | 20 | { |
21 | - /** |
|
22 | - * @var AdminMenuManager $menu_manager |
|
23 | - */ |
|
24 | - protected $menu_manager; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var LoaderInterface $loader |
|
28 | - */ |
|
29 | - protected $loader; |
|
30 | - |
|
31 | - /** |
|
32 | - * _installed_pages |
|
33 | - * objects for page_init objects detected and loaded |
|
34 | - * |
|
35 | - * @access private |
|
36 | - * @var EE_Admin_Page_Init[] |
|
37 | - */ |
|
38 | - private $_installed_pages = []; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * this is used to hold the registry of menu slugs for all the installed admin pages |
|
43 | - * |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - private $_menu_slugs = []; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * _caffeinated_extends |
|
51 | - * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and |
|
52 | - * pieces needed to do so). This property is defined in the _set_caffeinated method. |
|
53 | - * |
|
54 | - * @var array |
|
55 | - */ |
|
56 | - private $_caffeinated_extends = []; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * This property will hold the hook file for setting up the filter that does all the connections between admin |
|
61 | - * pages. |
|
62 | - * |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - public $hook_file; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var bool |
|
69 | - * @since 5.0.0.p |
|
70 | - */ |
|
71 | - private bool $full_site_maintenance = false; |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @throws InvalidArgumentException |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - * @throws InvalidInterfaceException |
|
78 | - */ |
|
79 | - public function __construct(?LoaderInterface $loader) |
|
80 | - { |
|
81 | - $this->loader = $loader instanceof LoaderInterface ? $loader : LoaderFactory::getLoader(); |
|
82 | - $this->menu_manager = $this->loader->getShared(AdminMenuManager::class); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @throws EE_Error |
|
88 | - * @throws ReflectionException |
|
89 | - * @since 5.0.0.p |
|
90 | - */ |
|
91 | - public function init() |
|
92 | - { |
|
93 | - $this->menu_manager->initialize(); |
|
94 | - $this->full_site_maintenance = MaintenanceStatus::isFullSite(); |
|
95 | - // let's do a scan and see what installed pages we have |
|
96 | - $this->findAndLoadAdminPages(); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by |
|
102 | - * files in the caffeinated folder. |
|
103 | - * |
|
104 | - * @access private |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - private function defineCaffeinatedConstants() |
|
108 | - { |
|
109 | - if (! defined('EE_CORE_CAF_ADMIN')) { |
|
110 | - define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/'); |
|
111 | - define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/'); |
|
112 | - define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/'); |
|
113 | - define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/'); |
|
114 | - define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/'); |
|
115 | - define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/'); |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * This just gets the list of installed EE_Admin_pages. |
|
122 | - * |
|
123 | - * @access private |
|
124 | - * @return void |
|
125 | - * @throws EE_Error |
|
126 | - * @throws InvalidArgumentException |
|
127 | - * @throws InvalidDataTypeException |
|
128 | - * @throws InvalidInterfaceException |
|
129 | - * @throws ReflectionException |
|
130 | - */ |
|
131 | - private function findAndLoadAdminPages() |
|
132 | - { |
|
133 | - $admin_pages = $this->findAdminPages(); |
|
21 | + /** |
|
22 | + * @var AdminMenuManager $menu_manager |
|
23 | + */ |
|
24 | + protected $menu_manager; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var LoaderInterface $loader |
|
28 | + */ |
|
29 | + protected $loader; |
|
30 | + |
|
31 | + /** |
|
32 | + * _installed_pages |
|
33 | + * objects for page_init objects detected and loaded |
|
34 | + * |
|
35 | + * @access private |
|
36 | + * @var EE_Admin_Page_Init[] |
|
37 | + */ |
|
38 | + private $_installed_pages = []; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * this is used to hold the registry of menu slugs for all the installed admin pages |
|
43 | + * |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + private $_menu_slugs = []; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * _caffeinated_extends |
|
51 | + * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and |
|
52 | + * pieces needed to do so). This property is defined in the _set_caffeinated method. |
|
53 | + * |
|
54 | + * @var array |
|
55 | + */ |
|
56 | + private $_caffeinated_extends = []; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * This property will hold the hook file for setting up the filter that does all the connections between admin |
|
61 | + * pages. |
|
62 | + * |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + public $hook_file; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var bool |
|
69 | + * @since 5.0.0.p |
|
70 | + */ |
|
71 | + private bool $full_site_maintenance = false; |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @throws InvalidArgumentException |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + * @throws InvalidInterfaceException |
|
78 | + */ |
|
79 | + public function __construct(?LoaderInterface $loader) |
|
80 | + { |
|
81 | + $this->loader = $loader instanceof LoaderInterface ? $loader : LoaderFactory::getLoader(); |
|
82 | + $this->menu_manager = $this->loader->getShared(AdminMenuManager::class); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @throws EE_Error |
|
88 | + * @throws ReflectionException |
|
89 | + * @since 5.0.0.p |
|
90 | + */ |
|
91 | + public function init() |
|
92 | + { |
|
93 | + $this->menu_manager->initialize(); |
|
94 | + $this->full_site_maintenance = MaintenanceStatus::isFullSite(); |
|
95 | + // let's do a scan and see what installed pages we have |
|
96 | + $this->findAndLoadAdminPages(); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by |
|
102 | + * files in the caffeinated folder. |
|
103 | + * |
|
104 | + * @access private |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + private function defineCaffeinatedConstants() |
|
108 | + { |
|
109 | + if (! defined('EE_CORE_CAF_ADMIN')) { |
|
110 | + define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/'); |
|
111 | + define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/'); |
|
112 | + define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/'); |
|
113 | + define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/'); |
|
114 | + define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/'); |
|
115 | + define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/'); |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * This just gets the list of installed EE_Admin_pages. |
|
122 | + * |
|
123 | + * @access private |
|
124 | + * @return void |
|
125 | + * @throws EE_Error |
|
126 | + * @throws InvalidArgumentException |
|
127 | + * @throws InvalidDataTypeException |
|
128 | + * @throws InvalidInterfaceException |
|
129 | + * @throws ReflectionException |
|
130 | + */ |
|
131 | + private function findAndLoadAdminPages() |
|
132 | + { |
|
133 | + $admin_pages = $this->findAdminPages(); |
|
134 | 134 | $isCaffeinated = ! (defined('EE_DECAF') && EE_DECAF) && is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin'); |
135 | 135 | // first let's check if there IS a caffeinated folder. |
136 | 136 | if ($isCaffeinated) { |
@@ -140,325 +140,325 @@ discard block |
||
140 | 140 | $this->findAdminPageExtensions(); |
141 | 141 | $this->findAdminPageHooks(); |
142 | 142 | } |
143 | - // allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.; |
|
144 | - // loop through admin pages and setup the $_installed_pages array. |
|
145 | - $hooks_ref = []; |
|
146 | - $menu_pages = []; |
|
147 | - foreach ($admin_pages as $page => $path) { |
|
148 | - // don't load the page init class IF IT's ALREADY LOADED !!! |
|
149 | - if ( |
|
150 | - isset($this->_installed_pages[ $page ]) |
|
151 | - && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init |
|
152 | - ) { |
|
153 | - continue; |
|
154 | - } |
|
155 | - // build list of installed pages |
|
156 | - $admin_page_init = $this->loadAdminPageInit($page); |
|
157 | - $this->_installed_pages[ $page ] = $admin_page_init; |
|
158 | - $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init); |
|
159 | - $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug()); |
|
160 | - // skip if in full maintenance mode and maintenance_mode_parent is NOT set |
|
161 | - if ($this->full_site_maintenance && ! $admin_menu->maintenanceModeParent()) { |
|
162 | - unset($admin_pages[ $page ]); |
|
163 | - continue; |
|
164 | - } |
|
165 | - $menu_slug = $admin_menu->menuSlug(); |
|
166 | - $this->_menu_slugs[ $menu_slug ] = $page; |
|
167 | - $menu_pages[ $menu_slug ] = $admin_page_init; |
|
168 | - |
|
169 | - // now that we've got the admin_init objects... |
|
170 | - // let's see if there are any caffeinated pages extending the originals. |
|
171 | - // If there are then let's hook into the init admin filter and load our extentions instead. |
|
172 | - // Set flag for register hooks on extended pages b/c extended pages use the default INIT. |
|
173 | - $extended_hooks = $admin_page_init->register_hooks( |
|
174 | - $this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug) |
|
175 | - ); |
|
176 | - $hooks_ref = array_merge($hooks_ref, $extended_hooks); |
|
177 | - } |
|
143 | + // allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.; |
|
144 | + // loop through admin pages and setup the $_installed_pages array. |
|
145 | + $hooks_ref = []; |
|
146 | + $menu_pages = []; |
|
147 | + foreach ($admin_pages as $page => $path) { |
|
148 | + // don't load the page init class IF IT's ALREADY LOADED !!! |
|
149 | + if ( |
|
150 | + isset($this->_installed_pages[ $page ]) |
|
151 | + && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init |
|
152 | + ) { |
|
153 | + continue; |
|
154 | + } |
|
155 | + // build list of installed pages |
|
156 | + $admin_page_init = $this->loadAdminPageInit($page); |
|
157 | + $this->_installed_pages[ $page ] = $admin_page_init; |
|
158 | + $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init); |
|
159 | + $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug()); |
|
160 | + // skip if in full maintenance mode and maintenance_mode_parent is NOT set |
|
161 | + if ($this->full_site_maintenance && ! $admin_menu->maintenanceModeParent()) { |
|
162 | + unset($admin_pages[ $page ]); |
|
163 | + continue; |
|
164 | + } |
|
165 | + $menu_slug = $admin_menu->menuSlug(); |
|
166 | + $this->_menu_slugs[ $menu_slug ] = $page; |
|
167 | + $menu_pages[ $menu_slug ] = $admin_page_init; |
|
168 | + |
|
169 | + // now that we've got the admin_init objects... |
|
170 | + // let's see if there are any caffeinated pages extending the originals. |
|
171 | + // If there are then let's hook into the init admin filter and load our extentions instead. |
|
172 | + // Set flag for register hooks on extended pages b/c extended pages use the default INIT. |
|
173 | + $extended_hooks = $admin_page_init->register_hooks( |
|
174 | + $this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug) |
|
175 | + ); |
|
176 | + $hooks_ref = array_merge($hooks_ref, $extended_hooks); |
|
177 | + } |
|
178 | 178 | // the hooks_ref is all the pages where we have $extended _Hooks files |
179 | - // that will extend a class in a different folder. |
|
180 | - // So we want to make sure we load the file for the parent. |
|
181 | - // first make sure we've got unique values |
|
182 | - $hooks_ref = array_unique($hooks_ref); |
|
183 | - // now let's loop and require! |
|
184 | - foreach ($hooks_ref as $path) { |
|
185 | - // if we're not caffeinated, then we don't need to do any of the following. |
|
186 | - if (! $isCaffeinated && strpos($path, 'caffeinated') !== false) { |
|
187 | - continue; |
|
188 | - } |
|
189 | - require_once($path); |
|
190 | - } |
|
191 | - // make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested. |
|
192 | - global $ee_menu_slugs; |
|
193 | - $ee_menu_slugs = $this->_menu_slugs; |
|
194 | - // we need to loop again to run any early code |
|
195 | - foreach ($this->_installed_pages as $page) { |
|
196 | - $page->do_initial_loads(); |
|
197 | - } |
|
198 | - $this->menu_manager->setInstalledPages($menu_pages); |
|
199 | - do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * @return array |
|
205 | - * @throws EE_Error |
|
206 | - * @since 5.0.0.p |
|
207 | - */ |
|
208 | - private function findAdminPages(): array |
|
209 | - { |
|
210 | - // grab everything in the admin core directory |
|
211 | - $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*'); |
|
212 | - $admin_page_folders = apply_filters( |
|
213 | - 'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders', |
|
214 | - $admin_page_folders |
|
215 | - ); |
|
216 | - if (! empty($admin_page_folders)) { |
|
217 | - return $admin_page_folders; |
|
218 | - } |
|
219 | - $error_msg = esc_html__( |
|
220 | - 'There are no EE_Admin pages detected, it looks like EE did not install properly', |
|
221 | - 'event_espresso' |
|
222 | - ); |
|
223 | - $error_msg .= '||'; |
|
224 | - $error_msg .= sprintf( |
|
225 | - esc_html__( |
|
226 | - 'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', |
|
227 | - 'event_espresso' |
|
228 | - ), |
|
229 | - EE_ADMIN_PAGES |
|
230 | - ); |
|
231 | - throw new RuntimeException($error_msg); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * get_admin_page_object |
|
237 | - * |
|
238 | - * @param string $page_slug |
|
239 | - * @return EE_Admin_Page |
|
240 | - */ |
|
241 | - public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page |
|
242 | - { |
|
243 | - return isset($this->_installed_pages[ $page_slug ]) |
|
244 | - && $this->_installed_pages[ $page_slug ] instanceof EE_Admin_Page_Init |
|
245 | - ? $this->_installed_pages[ $page_slug ]->loaded_page_object() |
|
246 | - : null; |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * generates an "Admin Page Init" class based on the directory name |
|
252 | - * |
|
253 | - * @param string $dir_name |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - private function getClassnameForAdminPageInit(string $dir_name = ''): string |
|
257 | - { |
|
258 | - $class_name = str_replace('_', ' ', strtolower($dir_name)); |
|
259 | - return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init'; |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * _load_admin_page |
|
265 | - * Loads and instantiates page_init object for a single EE_admin page. |
|
266 | - * |
|
267 | - * @param string $page page_reference |
|
268 | - * @return EE_Admin_Page_Init |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - private function loadAdminPageInit(string $page = ''): EE_Admin_Page_Init |
|
272 | - { |
|
273 | - $class_name = $this->getClassnameForAdminPageInit($page); |
|
274 | - if (class_exists($class_name)) { |
|
275 | - $admin_page_init = $this->loader->getShared($class_name); |
|
276 | - // verify returned object |
|
277 | - if ($admin_page_init instanceof EE_Admin_Page_Init) { |
|
278 | - return $admin_page_init; |
|
279 | - } |
|
280 | - } |
|
281 | - $error_msg = sprintf( |
|
282 | - esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'), |
|
283 | - $page |
|
284 | - ); |
|
285 | - $error_msg .= '||'; // separates public from developer messages |
|
286 | - $error_msg .= "\r\n"; |
|
287 | - $error_msg .= sprintf( |
|
288 | - esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
289 | - $page |
|
290 | - ); |
|
291 | - $error_msg .= '<br />'; |
|
292 | - $error_msg .= sprintf( |
|
293 | - esc_html__( |
|
294 | - 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
295 | - 'event_espresso' |
|
296 | - ), |
|
297 | - '<strong>' . $class_name . '</strong>' |
|
298 | - ); |
|
299 | - throw new EE_Error($error_msg); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * This method is the "workhorse" for detecting and setting up caffeinated functionality. |
|
305 | - * In this method there are three checks being done: |
|
306 | - * 1. Do we have any NEW admin page sets. If we do, lets add them into the menu setup (via the $admin_pages |
|
307 | - * array) etc. (new page sets are found in caffeinated/new/{page}) |
|
308 | - * 2. Do we have any EXTENDED page sets. Basically an extended EE_Admin Page extends the core {child}_Admin_Page |
|
309 | - * class. eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class: |
|
310 | - * Extend_Events_Admin_Page extends Events_Admin_Page. |
|
311 | - * 3. Do we have any files just for setting up hooks into other core pages. The files can be any name in |
|
312 | - * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the |
|
313 | - * classname inside. These classes are instantiated really early so that any hooks in them are run before the |
|
314 | - * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated |
|
315 | - * admin_pages) |
|
316 | - * |
|
317 | - * @param array $admin_pages the original installed_refs array that may contain our NEW EE_Admin_Pages to be |
|
318 | - * loaded. |
|
319 | - * @return array |
|
320 | - * @throws EE_Error |
|
321 | - */ |
|
322 | - private function findCaffeinatedAdminPages(array $admin_pages): array |
|
323 | - { |
|
324 | - $this->defineCaffeinatedConstants(); |
|
325 | - |
|
326 | - $exclude = ['tickets']; |
|
327 | - $feature = $this->loader->getShared(FeatureFlags::class); |
|
328 | - if (! $feature->allowed('use_edd_plugin_licensing')) { |
|
329 | - $exclude[] = 'license_keys'; |
|
330 | - } |
|
331 | - // okay let's setup an "New" pages first (we'll return installed refs later) |
|
332 | - $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', $exclude); |
|
333 | - |
|
334 | - return apply_filters( |
|
335 | - 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', |
|
336 | - $admin_pages |
|
337 | - ); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * @throws EE_Error |
|
343 | - * @since 5.0.0.p |
|
344 | - */ |
|
345 | - private function findAdminPageExtensions() |
|
346 | - { |
|
347 | - // let's see if there are any EXTENDS to set up in the $_caffeinated_extends array |
|
348 | - // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page) |
|
349 | - $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*'); |
|
350 | - if ($extensions) { |
|
351 | - foreach ($extensions as $folder => $extension) { |
|
352 | - // convert lowercase_snake_case to Uppercase_Snake_Case |
|
353 | - $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder))); |
|
354 | - $filename = "Extend_{$filename}_Admin_Page"; |
|
355 | - $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php"; |
|
356 | - // save filename and filepath for later |
|
357 | - $this->_caffeinated_extends[ $folder ]['path'] = str_replace(['\\', '/'], '/', $filepath); |
|
358 | - $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename; |
|
359 | - } |
|
360 | - } |
|
361 | - $this->_caffeinated_extends = apply_filters( |
|
362 | - 'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', |
|
363 | - $this->_caffeinated_extends |
|
364 | - ); |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - private function loadCaffeinatedExtensions( |
|
369 | - EE_Admin_Page_Init $admin_page_init, |
|
370 | - string $page, |
|
371 | - string $menu_slug |
|
372 | - ): bool { |
|
373 | - if (! isset($this->_caffeinated_extends[ $page ])) { |
|
374 | - return false; |
|
375 | - } |
|
376 | - $admin_page_name = $admin_page_init->get_admin_page_name(); |
|
377 | - $caf_path = $this->_caffeinated_extends[ $page ]['path']; |
|
378 | - $caf_admin_page = $this->_caffeinated_extends[ $page ]['admin_page']; |
|
379 | - add_filter( |
|
380 | - "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name", |
|
381 | - static function ($path_to_file) use ($caf_path) { |
|
382 | - return $caf_path; |
|
383 | - } |
|
384 | - ); |
|
385 | - add_filter( |
|
386 | - "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name", |
|
387 | - static function ($admin_page) use ($caf_admin_page) { |
|
388 | - return $caf_admin_page; |
|
389 | - } |
|
390 | - ); |
|
391 | - return true; |
|
392 | - } |
|
393 | - |
|
394 | - |
|
395 | - /** |
|
396 | - * @throws EE_Error |
|
397 | - * @since 5.0.0.p |
|
398 | - */ |
|
399 | - private function findAdminPageHooks() |
|
400 | - { |
|
401 | - // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!). |
|
402 | - $ee_admin_hooks = []; |
|
403 | - $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false); |
|
404 | - if ($admin_page_hooks) { |
|
405 | - foreach ($admin_page_hooks as $hook) { |
|
406 | - if (is_readable($hook)) { |
|
407 | - require_once $hook; |
|
408 | - $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook); |
|
409 | - if (class_exists($classname)) { |
|
410 | - $ee_admin_hooks[] = $this->loader->getShared($classname); |
|
411 | - } |
|
412 | - } |
|
413 | - } |
|
414 | - } |
|
415 | - apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks); |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * _default_header_link |
|
421 | - * This is just a dummy method to use with header submenu items |
|
422 | - * |
|
423 | - * @return bool false |
|
424 | - */ |
|
425 | - public function _default_header_link(): bool |
|
426 | - { |
|
427 | - return false; |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * @param string $path |
|
433 | - * @param int $flags |
|
434 | - * @param array $exclude |
|
435 | - * @param bool $register_autoloaders |
|
436 | - * @return array |
|
437 | - * @throws EE_Error |
|
438 | - * @since 5.0.0.p |
|
439 | - */ |
|
440 | - private function findAdminPageFolders( |
|
441 | - string $path, |
|
442 | - array $exclude = [], |
|
443 | - int $flags = GLOB_ONLYDIR, |
|
444 | - bool $register_autoloaders = true |
|
445 | - ): array { |
|
446 | - $folders = []; |
|
447 | - $subfolders = glob($path, $flags); |
|
448 | - if ($subfolders) { |
|
449 | - foreach ($subfolders as $admin_screen) { |
|
450 | - $admin_screen_name = basename($admin_screen); |
|
451 | - // files and anything in the exclude array need not apply |
|
452 | - if (! in_array($admin_screen_name, $exclude, true)) { |
|
453 | - // these folders represent the different EE admin pages |
|
454 | - $folders[ $admin_screen_name ] = $admin_screen; |
|
455 | - if ($register_autoloaders) { |
|
456 | - // set autoloaders for our admin page classes based on included path information |
|
457 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen); |
|
458 | - } |
|
459 | - } |
|
460 | - } |
|
461 | - } |
|
462 | - return $folders; |
|
463 | - } |
|
179 | + // that will extend a class in a different folder. |
|
180 | + // So we want to make sure we load the file for the parent. |
|
181 | + // first make sure we've got unique values |
|
182 | + $hooks_ref = array_unique($hooks_ref); |
|
183 | + // now let's loop and require! |
|
184 | + foreach ($hooks_ref as $path) { |
|
185 | + // if we're not caffeinated, then we don't need to do any of the following. |
|
186 | + if (! $isCaffeinated && strpos($path, 'caffeinated') !== false) { |
|
187 | + continue; |
|
188 | + } |
|
189 | + require_once($path); |
|
190 | + } |
|
191 | + // make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested. |
|
192 | + global $ee_menu_slugs; |
|
193 | + $ee_menu_slugs = $this->_menu_slugs; |
|
194 | + // we need to loop again to run any early code |
|
195 | + foreach ($this->_installed_pages as $page) { |
|
196 | + $page->do_initial_loads(); |
|
197 | + } |
|
198 | + $this->menu_manager->setInstalledPages($menu_pages); |
|
199 | + do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * @return array |
|
205 | + * @throws EE_Error |
|
206 | + * @since 5.0.0.p |
|
207 | + */ |
|
208 | + private function findAdminPages(): array |
|
209 | + { |
|
210 | + // grab everything in the admin core directory |
|
211 | + $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*'); |
|
212 | + $admin_page_folders = apply_filters( |
|
213 | + 'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders', |
|
214 | + $admin_page_folders |
|
215 | + ); |
|
216 | + if (! empty($admin_page_folders)) { |
|
217 | + return $admin_page_folders; |
|
218 | + } |
|
219 | + $error_msg = esc_html__( |
|
220 | + 'There are no EE_Admin pages detected, it looks like EE did not install properly', |
|
221 | + 'event_espresso' |
|
222 | + ); |
|
223 | + $error_msg .= '||'; |
|
224 | + $error_msg .= sprintf( |
|
225 | + esc_html__( |
|
226 | + 'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', |
|
227 | + 'event_espresso' |
|
228 | + ), |
|
229 | + EE_ADMIN_PAGES |
|
230 | + ); |
|
231 | + throw new RuntimeException($error_msg); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * get_admin_page_object |
|
237 | + * |
|
238 | + * @param string $page_slug |
|
239 | + * @return EE_Admin_Page |
|
240 | + */ |
|
241 | + public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page |
|
242 | + { |
|
243 | + return isset($this->_installed_pages[ $page_slug ]) |
|
244 | + && $this->_installed_pages[ $page_slug ] instanceof EE_Admin_Page_Init |
|
245 | + ? $this->_installed_pages[ $page_slug ]->loaded_page_object() |
|
246 | + : null; |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * generates an "Admin Page Init" class based on the directory name |
|
252 | + * |
|
253 | + * @param string $dir_name |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + private function getClassnameForAdminPageInit(string $dir_name = ''): string |
|
257 | + { |
|
258 | + $class_name = str_replace('_', ' ', strtolower($dir_name)); |
|
259 | + return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init'; |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * _load_admin_page |
|
265 | + * Loads and instantiates page_init object for a single EE_admin page. |
|
266 | + * |
|
267 | + * @param string $page page_reference |
|
268 | + * @return EE_Admin_Page_Init |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + private function loadAdminPageInit(string $page = ''): EE_Admin_Page_Init |
|
272 | + { |
|
273 | + $class_name = $this->getClassnameForAdminPageInit($page); |
|
274 | + if (class_exists($class_name)) { |
|
275 | + $admin_page_init = $this->loader->getShared($class_name); |
|
276 | + // verify returned object |
|
277 | + if ($admin_page_init instanceof EE_Admin_Page_Init) { |
|
278 | + return $admin_page_init; |
|
279 | + } |
|
280 | + } |
|
281 | + $error_msg = sprintf( |
|
282 | + esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'), |
|
283 | + $page |
|
284 | + ); |
|
285 | + $error_msg .= '||'; // separates public from developer messages |
|
286 | + $error_msg .= "\r\n"; |
|
287 | + $error_msg .= sprintf( |
|
288 | + esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
289 | + $page |
|
290 | + ); |
|
291 | + $error_msg .= '<br />'; |
|
292 | + $error_msg .= sprintf( |
|
293 | + esc_html__( |
|
294 | + 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
295 | + 'event_espresso' |
|
296 | + ), |
|
297 | + '<strong>' . $class_name . '</strong>' |
|
298 | + ); |
|
299 | + throw new EE_Error($error_msg); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * This method is the "workhorse" for detecting and setting up caffeinated functionality. |
|
305 | + * In this method there are three checks being done: |
|
306 | + * 1. Do we have any NEW admin page sets. If we do, lets add them into the menu setup (via the $admin_pages |
|
307 | + * array) etc. (new page sets are found in caffeinated/new/{page}) |
|
308 | + * 2. Do we have any EXTENDED page sets. Basically an extended EE_Admin Page extends the core {child}_Admin_Page |
|
309 | + * class. eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class: |
|
310 | + * Extend_Events_Admin_Page extends Events_Admin_Page. |
|
311 | + * 3. Do we have any files just for setting up hooks into other core pages. The files can be any name in |
|
312 | + * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the |
|
313 | + * classname inside. These classes are instantiated really early so that any hooks in them are run before the |
|
314 | + * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated |
|
315 | + * admin_pages) |
|
316 | + * |
|
317 | + * @param array $admin_pages the original installed_refs array that may contain our NEW EE_Admin_Pages to be |
|
318 | + * loaded. |
|
319 | + * @return array |
|
320 | + * @throws EE_Error |
|
321 | + */ |
|
322 | + private function findCaffeinatedAdminPages(array $admin_pages): array |
|
323 | + { |
|
324 | + $this->defineCaffeinatedConstants(); |
|
325 | + |
|
326 | + $exclude = ['tickets']; |
|
327 | + $feature = $this->loader->getShared(FeatureFlags::class); |
|
328 | + if (! $feature->allowed('use_edd_plugin_licensing')) { |
|
329 | + $exclude[] = 'license_keys'; |
|
330 | + } |
|
331 | + // okay let's setup an "New" pages first (we'll return installed refs later) |
|
332 | + $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', $exclude); |
|
333 | + |
|
334 | + return apply_filters( |
|
335 | + 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', |
|
336 | + $admin_pages |
|
337 | + ); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * @throws EE_Error |
|
343 | + * @since 5.0.0.p |
|
344 | + */ |
|
345 | + private function findAdminPageExtensions() |
|
346 | + { |
|
347 | + // let's see if there are any EXTENDS to set up in the $_caffeinated_extends array |
|
348 | + // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page) |
|
349 | + $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*'); |
|
350 | + if ($extensions) { |
|
351 | + foreach ($extensions as $folder => $extension) { |
|
352 | + // convert lowercase_snake_case to Uppercase_Snake_Case |
|
353 | + $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder))); |
|
354 | + $filename = "Extend_{$filename}_Admin_Page"; |
|
355 | + $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php"; |
|
356 | + // save filename and filepath for later |
|
357 | + $this->_caffeinated_extends[ $folder ]['path'] = str_replace(['\\', '/'], '/', $filepath); |
|
358 | + $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename; |
|
359 | + } |
|
360 | + } |
|
361 | + $this->_caffeinated_extends = apply_filters( |
|
362 | + 'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', |
|
363 | + $this->_caffeinated_extends |
|
364 | + ); |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + private function loadCaffeinatedExtensions( |
|
369 | + EE_Admin_Page_Init $admin_page_init, |
|
370 | + string $page, |
|
371 | + string $menu_slug |
|
372 | + ): bool { |
|
373 | + if (! isset($this->_caffeinated_extends[ $page ])) { |
|
374 | + return false; |
|
375 | + } |
|
376 | + $admin_page_name = $admin_page_init->get_admin_page_name(); |
|
377 | + $caf_path = $this->_caffeinated_extends[ $page ]['path']; |
|
378 | + $caf_admin_page = $this->_caffeinated_extends[ $page ]['admin_page']; |
|
379 | + add_filter( |
|
380 | + "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name", |
|
381 | + static function ($path_to_file) use ($caf_path) { |
|
382 | + return $caf_path; |
|
383 | + } |
|
384 | + ); |
|
385 | + add_filter( |
|
386 | + "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name", |
|
387 | + static function ($admin_page) use ($caf_admin_page) { |
|
388 | + return $caf_admin_page; |
|
389 | + } |
|
390 | + ); |
|
391 | + return true; |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + /** |
|
396 | + * @throws EE_Error |
|
397 | + * @since 5.0.0.p |
|
398 | + */ |
|
399 | + private function findAdminPageHooks() |
|
400 | + { |
|
401 | + // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!). |
|
402 | + $ee_admin_hooks = []; |
|
403 | + $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false); |
|
404 | + if ($admin_page_hooks) { |
|
405 | + foreach ($admin_page_hooks as $hook) { |
|
406 | + if (is_readable($hook)) { |
|
407 | + require_once $hook; |
|
408 | + $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook); |
|
409 | + if (class_exists($classname)) { |
|
410 | + $ee_admin_hooks[] = $this->loader->getShared($classname); |
|
411 | + } |
|
412 | + } |
|
413 | + } |
|
414 | + } |
|
415 | + apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks); |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * _default_header_link |
|
421 | + * This is just a dummy method to use with header submenu items |
|
422 | + * |
|
423 | + * @return bool false |
|
424 | + */ |
|
425 | + public function _default_header_link(): bool |
|
426 | + { |
|
427 | + return false; |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * @param string $path |
|
433 | + * @param int $flags |
|
434 | + * @param array $exclude |
|
435 | + * @param bool $register_autoloaders |
|
436 | + * @return array |
|
437 | + * @throws EE_Error |
|
438 | + * @since 5.0.0.p |
|
439 | + */ |
|
440 | + private function findAdminPageFolders( |
|
441 | + string $path, |
|
442 | + array $exclude = [], |
|
443 | + int $flags = GLOB_ONLYDIR, |
|
444 | + bool $register_autoloaders = true |
|
445 | + ): array { |
|
446 | + $folders = []; |
|
447 | + $subfolders = glob($path, $flags); |
|
448 | + if ($subfolders) { |
|
449 | + foreach ($subfolders as $admin_screen) { |
|
450 | + $admin_screen_name = basename($admin_screen); |
|
451 | + // files and anything in the exclude array need not apply |
|
452 | + if (! in_array($admin_screen_name, $exclude, true)) { |
|
453 | + // these folders represent the different EE admin pages |
|
454 | + $folders[ $admin_screen_name ] = $admin_screen; |
|
455 | + if ($register_autoloaders) { |
|
456 | + // set autoloaders for our admin page classes based on included path information |
|
457 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen); |
|
458 | + } |
|
459 | + } |
|
460 | + } |
|
461 | + } |
|
462 | + return $folders; |
|
463 | + } |
|
464 | 464 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function defineCaffeinatedConstants() |
108 | 108 | { |
109 | - if (! defined('EE_CORE_CAF_ADMIN')) { |
|
110 | - define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/'); |
|
111 | - define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/'); |
|
112 | - define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/'); |
|
113 | - define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/'); |
|
114 | - define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/'); |
|
115 | - define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/'); |
|
109 | + if ( ! defined('EE_CORE_CAF_ADMIN')) { |
|
110 | + define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/'); |
|
111 | + define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/'); |
|
112 | + define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/'); |
|
113 | + define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/'); |
|
114 | + define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/'); |
|
115 | + define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | private function findAndLoadAdminPages() |
132 | 132 | { |
133 | 133 | $admin_pages = $this->findAdminPages(); |
134 | - $isCaffeinated = ! (defined('EE_DECAF') && EE_DECAF) && is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin'); |
|
134 | + $isCaffeinated = ! (defined('EE_DECAF') && EE_DECAF) && is_dir(EE_PLUGIN_DIR_PATH.'caffeinated/admin'); |
|
135 | 135 | // first let's check if there IS a caffeinated folder. |
136 | 136 | if ($isCaffeinated) { |
137 | 137 | // this just checks the caffeinated folder and takes care of setting up any caffeinated stuff. |
@@ -147,24 +147,24 @@ discard block |
||
147 | 147 | foreach ($admin_pages as $page => $path) { |
148 | 148 | // don't load the page init class IF IT's ALREADY LOADED !!! |
149 | 149 | if ( |
150 | - isset($this->_installed_pages[ $page ]) |
|
151 | - && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init |
|
150 | + isset($this->_installed_pages[$page]) |
|
151 | + && $this->_installed_pages[$page] instanceof EE_Admin_Page_Init |
|
152 | 152 | ) { |
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | // build list of installed pages |
156 | 156 | $admin_page_init = $this->loadAdminPageInit($page); |
157 | - $this->_installed_pages[ $page ] = $admin_page_init; |
|
157 | + $this->_installed_pages[$page] = $admin_page_init; |
|
158 | 158 | $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init); |
159 | 159 | $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug()); |
160 | 160 | // skip if in full maintenance mode and maintenance_mode_parent is NOT set |
161 | 161 | if ($this->full_site_maintenance && ! $admin_menu->maintenanceModeParent()) { |
162 | - unset($admin_pages[ $page ]); |
|
162 | + unset($admin_pages[$page]); |
|
163 | 163 | continue; |
164 | 164 | } |
165 | 165 | $menu_slug = $admin_menu->menuSlug(); |
166 | - $this->_menu_slugs[ $menu_slug ] = $page; |
|
167 | - $menu_pages[ $menu_slug ] = $admin_page_init; |
|
166 | + $this->_menu_slugs[$menu_slug] = $page; |
|
167 | + $menu_pages[$menu_slug] = $admin_page_init; |
|
168 | 168 | |
169 | 169 | // now that we've got the admin_init objects... |
170 | 170 | // let's see if there are any caffeinated pages extending the originals. |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | // now let's loop and require! |
184 | 184 | foreach ($hooks_ref as $path) { |
185 | 185 | // if we're not caffeinated, then we don't need to do any of the following. |
186 | - if (! $isCaffeinated && strpos($path, 'caffeinated') !== false) { |
|
186 | + if ( ! $isCaffeinated && strpos($path, 'caffeinated') !== false) { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | require_once($path); |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | private function findAdminPages(): array |
209 | 209 | { |
210 | 210 | // grab everything in the admin core directory |
211 | - $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*'); |
|
211 | + $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES.'*'); |
|
212 | 212 | $admin_page_folders = apply_filters( |
213 | 213 | 'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders', |
214 | 214 | $admin_page_folders |
215 | 215 | ); |
216 | - if (! empty($admin_page_folders)) { |
|
216 | + if ( ! empty($admin_page_folders)) { |
|
217 | 217 | return $admin_page_folders; |
218 | 218 | } |
219 | 219 | $error_msg = esc_html__( |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page |
242 | 242 | { |
243 | - return isset($this->_installed_pages[ $page_slug ]) |
|
244 | - && $this->_installed_pages[ $page_slug ] instanceof EE_Admin_Page_Init |
|
245 | - ? $this->_installed_pages[ $page_slug ]->loaded_page_object() |
|
243 | + return isset($this->_installed_pages[$page_slug]) |
|
244 | + && $this->_installed_pages[$page_slug] instanceof EE_Admin_Page_Init |
|
245 | + ? $this->_installed_pages[$page_slug]->loaded_page_object() |
|
246 | 246 | : null; |
247 | 247 | } |
248 | 248 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | private function getClassnameForAdminPageInit(string $dir_name = ''): string |
257 | 257 | { |
258 | 258 | $class_name = str_replace('_', ' ', strtolower($dir_name)); |
259 | - return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init'; |
|
259 | + return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init'; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
295 | 295 | 'event_espresso' |
296 | 296 | ), |
297 | - '<strong>' . $class_name . '</strong>' |
|
297 | + '<strong>'.$class_name.'</strong>' |
|
298 | 298 | ); |
299 | 299 | throw new EE_Error($error_msg); |
300 | 300 | } |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | |
326 | 326 | $exclude = ['tickets']; |
327 | 327 | $feature = $this->loader->getShared(FeatureFlags::class); |
328 | - if (! $feature->allowed('use_edd_plugin_licensing')) { |
|
328 | + if ( ! $feature->allowed('use_edd_plugin_licensing')) { |
|
329 | 329 | $exclude[] = 'license_keys'; |
330 | 330 | } |
331 | 331 | // okay let's setup an "New" pages first (we'll return installed refs later) |
332 | - $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', $exclude); |
|
332 | + $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'new/*', $exclude); |
|
333 | 333 | |
334 | 334 | return apply_filters( |
335 | 335 | 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', |
@@ -346,16 +346,16 @@ discard block |
||
346 | 346 | { |
347 | 347 | // let's see if there are any EXTENDS to set up in the $_caffeinated_extends array |
348 | 348 | // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page) |
349 | - $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*'); |
|
349 | + $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'extend/*'); |
|
350 | 350 | if ($extensions) { |
351 | 351 | foreach ($extensions as $folder => $extension) { |
352 | 352 | // convert lowercase_snake_case to Uppercase_Snake_Case |
353 | 353 | $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder))); |
354 | 354 | $filename = "Extend_{$filename}_Admin_Page"; |
355 | - $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php"; |
|
355 | + $filepath = EE_CORE_CAF_ADMIN."extend/$folder/$filename.core.php"; |
|
356 | 356 | // save filename and filepath for later |
357 | - $this->_caffeinated_extends[ $folder ]['path'] = str_replace(['\\', '/'], '/', $filepath); |
|
358 | - $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename; |
|
357 | + $this->_caffeinated_extends[$folder]['path'] = str_replace(['\\', '/'], '/', $filepath); |
|
358 | + $this->_caffeinated_extends[$folder]['admin_page'] = $filename; |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | $this->_caffeinated_extends = apply_filters( |
@@ -370,21 +370,21 @@ discard block |
||
370 | 370 | string $page, |
371 | 371 | string $menu_slug |
372 | 372 | ): bool { |
373 | - if (! isset($this->_caffeinated_extends[ $page ])) { |
|
373 | + if ( ! isset($this->_caffeinated_extends[$page])) { |
|
374 | 374 | return false; |
375 | 375 | } |
376 | 376 | $admin_page_name = $admin_page_init->get_admin_page_name(); |
377 | - $caf_path = $this->_caffeinated_extends[ $page ]['path']; |
|
378 | - $caf_admin_page = $this->_caffeinated_extends[ $page ]['admin_page']; |
|
377 | + $caf_path = $this->_caffeinated_extends[$page]['path']; |
|
378 | + $caf_admin_page = $this->_caffeinated_extends[$page]['admin_page']; |
|
379 | 379 | add_filter( |
380 | 380 | "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name", |
381 | - static function ($path_to_file) use ($caf_path) { |
|
381 | + static function($path_to_file) use ($caf_path) { |
|
382 | 382 | return $caf_path; |
383 | 383 | } |
384 | 384 | ); |
385 | 385 | add_filter( |
386 | 386 | "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name", |
387 | - static function ($admin_page) use ($caf_admin_page) { |
|
387 | + static function($admin_page) use ($caf_admin_page) { |
|
388 | 388 | return $caf_admin_page; |
389 | 389 | } |
390 | 390 | ); |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | { |
401 | 401 | // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!). |
402 | 402 | $ee_admin_hooks = []; |
403 | - $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false); |
|
403 | + $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'hooks/*.class.php', [], 0, false); |
|
404 | 404 | if ($admin_page_hooks) { |
405 | 405 | foreach ($admin_page_hooks as $hook) { |
406 | 406 | if (is_readable($hook)) { |
407 | 407 | require_once $hook; |
408 | - $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook); |
|
408 | + $classname = str_replace([EE_CORE_CAF_ADMIN.'hooks/', '.class.php'], '', $hook); |
|
409 | 409 | if (class_exists($classname)) { |
410 | 410 | $ee_admin_hooks[] = $this->loader->getShared($classname); |
411 | 411 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | foreach ($subfolders as $admin_screen) { |
450 | 450 | $admin_screen_name = basename($admin_screen); |
451 | 451 | // files and anything in the exclude array need not apply |
452 | - if (! in_array($admin_screen_name, $exclude, true)) { |
|
452 | + if ( ! in_array($admin_screen_name, $exclude, true)) { |
|
453 | 453 | // these folders represent the different EE admin pages |
454 | - $folders[ $admin_screen_name ] = $admin_screen; |
|
454 | + $folders[$admin_screen_name] = $admin_screen; |
|
455 | 455 | if ($register_autoloaders) { |
456 | 456 | // set autoloaders for our admin page classes based on included path information |
457 | 457 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen); |