Completed
Branch EDTR/refactor-master (6f4a48)
by
unknown
19:30 queued 10:54
created
core/domain/services/pue/StatsGatherer.php 2 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -16,314 +16,314 @@
 block discarded – undo
16 16
 class StatsGatherer
17 17
 {
18 18
 
19
-    const COUNT_ALL_EVENTS = 'event';
20
-    const COUNT_ACTIVE_EVENTS = 'active_event';
21
-    const COUNT_DATETIMES = 'datetime';
22
-    const COUNT_TICKETS = 'ticket';
23
-    const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
-    const COUNT_TICKETS_FREE = 'free_ticket';
25
-    const COUNT_TICKETS_PAID = 'paid_ticket';
26
-    const COUNT_TICKETS_SOLD = 'ticket_sold';
27
-    const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
-    const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
-    const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
-    const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
-    const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
-    const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
-    const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
-    const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
-    const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
-    const INFO_SITE_CURRENCY = 'site_currency';
19
+	const COUNT_ALL_EVENTS = 'event';
20
+	const COUNT_ACTIVE_EVENTS = 'active_event';
21
+	const COUNT_DATETIMES = 'datetime';
22
+	const COUNT_TICKETS = 'ticket';
23
+	const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
+	const COUNT_TICKETS_FREE = 'free_ticket';
25
+	const COUNT_TICKETS_PAID = 'paid_ticket';
26
+	const COUNT_TICKETS_SOLD = 'ticket_sold';
27
+	const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
+	const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
+	const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
+	const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
+	const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
+	const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
+	const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
+	const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
+	const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
+	const INFO_SITE_CURRENCY = 'site_currency';
37 37
 
38 38
 
39
-    /**
40
-     * @var EEM_Payment_Method
41
-     */
42
-    private $payment_method_model;
39
+	/**
40
+	 * @var EEM_Payment_Method
41
+	 */
42
+	private $payment_method_model;
43 43
 
44 44
 
45
-    /**
46
-     * @var EEM_Event
47
-     */
48
-    private $event_model;
45
+	/**
46
+	 * @var EEM_Event
47
+	 */
48
+	private $event_model;
49 49
 
50
-    /**
51
-     * @var EEM_Datetime
52
-     */
53
-    private $datetime_model;
50
+	/**
51
+	 * @var EEM_Datetime
52
+	 */
53
+	private $datetime_model;
54 54
 
55 55
 
56
-    /**
57
-     * @var EEM_Ticket
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket
58
+	 */
59
+	private $ticket_model;
60 60
 
61 61
 
62
-    /**
63
-     * @var EEM_Registration
64
-     */
65
-    private $registration_model;
62
+	/**
63
+	 * @var EEM_Registration
64
+	 */
65
+	private $registration_model;
66 66
 
67 67
 
68
-    /**
69
-     * @var EEM_Transaction
70
-     */
71
-    private $transaction_model;
68
+	/**
69
+	 * @var EEM_Transaction
70
+	 */
71
+	private $transaction_model;
72 72
 
73 73
 
74
-    /**
75
-     * @var EE_Config
76
-     */
77
-    private $config;
74
+	/**
75
+	 * @var EE_Config
76
+	 */
77
+	private $config;
78 78
 
79 79
 
80
-    /**
81
-     * StatsGatherer constructor.
82
-     *
83
-     * @param EEM_Payment_Method $payment_method_model
84
-     * @param EEM_Event          $event_model
85
-     * @param EEM_Datetime       $datetime_model
86
-     * @param EEM_Ticket         $ticket_model
87
-     * @param EEM_Registration   $registration_model
88
-     * @param EEM_Transaction    $transaction_model
89
-     * @param EE_Config          $config
90
-     */
91
-    public function __construct(
92
-        EEM_Payment_Method $payment_method_model,
93
-        EEM_Event $event_model,
94
-        EEM_Datetime $datetime_model,
95
-        EEM_Ticket $ticket_model,
96
-        EEM_Registration $registration_model,
97
-        EEM_Transaction $transaction_model,
98
-        EE_Config $config
99
-    ) {
100
-        $this->payment_method_model = $payment_method_model;
101
-        $this->event_model = $event_model;
102
-        $this->datetime_model = $datetime_model;
103
-        $this->ticket_model = $ticket_model;
104
-        $this->registration_model = $registration_model;
105
-        $this->transaction_model = $transaction_model;
106
-        $this->config = $config;
107
-    }
80
+	/**
81
+	 * StatsGatherer constructor.
82
+	 *
83
+	 * @param EEM_Payment_Method $payment_method_model
84
+	 * @param EEM_Event          $event_model
85
+	 * @param EEM_Datetime       $datetime_model
86
+	 * @param EEM_Ticket         $ticket_model
87
+	 * @param EEM_Registration   $registration_model
88
+	 * @param EEM_Transaction    $transaction_model
89
+	 * @param EE_Config          $config
90
+	 */
91
+	public function __construct(
92
+		EEM_Payment_Method $payment_method_model,
93
+		EEM_Event $event_model,
94
+		EEM_Datetime $datetime_model,
95
+		EEM_Ticket $ticket_model,
96
+		EEM_Registration $registration_model,
97
+		EEM_Transaction $transaction_model,
98
+		EE_Config $config
99
+	) {
100
+		$this->payment_method_model = $payment_method_model;
101
+		$this->event_model = $event_model;
102
+		$this->datetime_model = $datetime_model;
103
+		$this->ticket_model = $ticket_model;
104
+		$this->registration_model = $registration_model;
105
+		$this->transaction_model = $transaction_model;
106
+		$this->config = $config;
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * Return the stats array for PUE UXIP stats.
112
-     *
113
-     * @return array
114
-     */
115
-    public function stats()
116
-    {
117
-        global $wp_version;
118
-        $stats = $this->paymentMethodStats();
119
-        // a-ok so let's setup our stats.
120
-        $stats = array_merge($stats, array(
121
-            'is_multisite'                    => is_multisite() && is_main_site(),
122
-            'active_theme'                    => $this->getActiveThemeStat(),
123
-            'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
124
-            'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
125
-            'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
126
-            'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
127
-            'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
128
-            'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
129
-            'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
130
-            'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
131
-            'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
132
-            'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
133
-            'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
134
-            'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
135
-            'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
136
-            'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
137
-            'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
138
-            'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
139
-            'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
140
-            self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
141
-                ? $this->config->currency->code
142
-                : 'unknown',
143
-            'phpversion'                      => implode(
144
-                '.',
145
-                array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
146
-            ),
147
-            'wpversion'                       => $wp_version,
148
-            'active_addons'                   => $this->getActiveAddons(),
149
-        ));
150
-        // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
-        return array_filter($stats, function ($value) {
152
-            return $value !== null;
153
-        });
154
-    }
110
+	/**
111
+	 * Return the stats array for PUE UXIP stats.
112
+	 *
113
+	 * @return array
114
+	 */
115
+	public function stats()
116
+	{
117
+		global $wp_version;
118
+		$stats = $this->paymentMethodStats();
119
+		// a-ok so let's setup our stats.
120
+		$stats = array_merge($stats, array(
121
+			'is_multisite'                    => is_multisite() && is_main_site(),
122
+			'active_theme'                    => $this->getActiveThemeStat(),
123
+			'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
124
+			'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
125
+			'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
126
+			'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
127
+			'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
128
+			'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
129
+			'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
130
+			'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
131
+			'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
132
+			'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
133
+			'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
134
+			'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
135
+			'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
136
+			'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
137
+			'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
138
+			'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
139
+			'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
140
+			self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
141
+				? $this->config->currency->code
142
+				: 'unknown',
143
+			'phpversion'                      => implode(
144
+				'.',
145
+				array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
146
+			),
147
+			'wpversion'                       => $wp_version,
148
+			'active_addons'                   => $this->getActiveAddons(),
149
+		));
150
+		// remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
+		return array_filter($stats, function ($value) {
152
+			return $value !== null;
153
+		});
154
+	}
155 155
 
156
-    /**
157
-     * @param string $which enum (@see constants prefixed with COUNT)
158
-     * @return int|null
159
-     */
160
-    private function getCountFor($which)
161
-    {
162
-        try {
163
-            switch ($which) {
164
-                case self::COUNT_ALL_EVENTS:
165
-                    $count = $this->event_model->count();
166
-                    break;
167
-                case self::COUNT_TICKETS:
168
-                    $count = $this->ticket_model->count();
169
-                    break;
170
-                case self::COUNT_DATETIMES:
171
-                    $count = $this->datetime_model->count();
172
-                    break;
173
-                case self::COUNT_ACTIVE_EVENTS:
174
-                    $count = $this->event_model->get_active_events(array(), true);
175
-                    break;
176
-                case self::COUNT_DATETIMES_SOLD:
177
-                    $count = $this->datetime_model->sum(array(), 'DTT_sold');
178
-                    break;
179
-                case self::COUNT_TICKETS_FREE:
180
-                    $count = $this->ticket_model->count(array(
181
-                        array(
182
-                            'TKT_price' => 0,
183
-                        ),
184
-                    ));
185
-                    break;
186
-                case self::COUNT_TICKETS_PAID:
187
-                    $count = $this->ticket_model->count(array(
188
-                        array(
189
-                            'TKT_price' => array('>', 0),
190
-                        ),
191
-                    ));
192
-                    break;
193
-                case self::COUNT_TICKETS_SOLD:
194
-                    $count = $this->ticket_model->sum(array(), 'TKT_sold');
195
-                    break;
196
-                case self::COUNT_REGISTRATIONS_ALL:
197
-                    $count = $this->registration_model->count();
198
-                    break;
199
-                case self::COUNT_REGISTRATIONS_CANCELLED:
200
-                    $count = $this->registration_model->count(
201
-                        array(
202
-                            array(
203
-                                'STS_ID' => EEM_Registration::status_id_cancelled,
204
-                            ),
205
-                        )
206
-                    );
207
-                    break;
208
-                case self::COUNT_REGISTRATIONS_INCOMPLETE:
209
-                    $count = $this->registration_model->count(
210
-                        array(
211
-                            array(
212
-                                'STS_ID' => EEM_Registration::status_id_incomplete,
213
-                            ),
214
-                        )
215
-                    );
216
-                    break;
217
-                case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
-                    $count = $this->registration_model->count(
219
-                        array(
220
-                            array(
221
-                                'STS_ID' => EEM_Registration::status_id_not_approved,
222
-                            ),
223
-                        )
224
-                    );
225
-                    break;
226
-                case self::COUNT_REGISTRATIONS_DECLINED:
227
-                    $count = $this->registration_model->count(
228
-                        array(
229
-                            array(
230
-                                'STS_ID' => EEM_Registration::status_id_declined,
231
-                            ),
232
-                        )
233
-                    );
234
-                    break;
235
-                case self::COUNT_REGISTRATIONS_PENDING:
236
-                    $count = $this->registration_model->count(
237
-                        array(
238
-                            array(
239
-                                'STS_ID' => EEM_Registration::status_id_pending_payment,
240
-                            ),
241
-                        )
242
-                    );
243
-                    break;
244
-                case self::COUNT_REGISTRATIONS_APPROVED:
245
-                    $count = $this->registration_model->count(
246
-                        array(
247
-                            array(
248
-                                'STS_ID' => EEM_Registration::status_id_approved,
249
-                            ),
250
-                        )
251
-                    );
252
-                    break;
253
-                case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
254
-                    $count = $this->transaction_model->sum(
255
-                        array(
256
-                            array(
257
-                                'STS_ID' => EEM_Transaction::complete_status_code,
258
-                            ),
259
-                        ),
260
-                        'TXN_total'
261
-                    );
262
-                    break;
263
-                case self::SUM_TRANSACTIONS_ALL_PAID:
264
-                    $count = $this->transaction_model->sum(
265
-                        array(),
266
-                        'TXN_paid'
267
-                    );
268
-                    break;
269
-                default:
270
-                    $count = null;
271
-                    break;
272
-            }
273
-        } catch (Exception $e) {
274
-            $count = null;
275
-        }
276
-        return $count;
277
-    }
156
+	/**
157
+	 * @param string $which enum (@see constants prefixed with COUNT)
158
+	 * @return int|null
159
+	 */
160
+	private function getCountFor($which)
161
+	{
162
+		try {
163
+			switch ($which) {
164
+				case self::COUNT_ALL_EVENTS:
165
+					$count = $this->event_model->count();
166
+					break;
167
+				case self::COUNT_TICKETS:
168
+					$count = $this->ticket_model->count();
169
+					break;
170
+				case self::COUNT_DATETIMES:
171
+					$count = $this->datetime_model->count();
172
+					break;
173
+				case self::COUNT_ACTIVE_EVENTS:
174
+					$count = $this->event_model->get_active_events(array(), true);
175
+					break;
176
+				case self::COUNT_DATETIMES_SOLD:
177
+					$count = $this->datetime_model->sum(array(), 'DTT_sold');
178
+					break;
179
+				case self::COUNT_TICKETS_FREE:
180
+					$count = $this->ticket_model->count(array(
181
+						array(
182
+							'TKT_price' => 0,
183
+						),
184
+					));
185
+					break;
186
+				case self::COUNT_TICKETS_PAID:
187
+					$count = $this->ticket_model->count(array(
188
+						array(
189
+							'TKT_price' => array('>', 0),
190
+						),
191
+					));
192
+					break;
193
+				case self::COUNT_TICKETS_SOLD:
194
+					$count = $this->ticket_model->sum(array(), 'TKT_sold');
195
+					break;
196
+				case self::COUNT_REGISTRATIONS_ALL:
197
+					$count = $this->registration_model->count();
198
+					break;
199
+				case self::COUNT_REGISTRATIONS_CANCELLED:
200
+					$count = $this->registration_model->count(
201
+						array(
202
+							array(
203
+								'STS_ID' => EEM_Registration::status_id_cancelled,
204
+							),
205
+						)
206
+					);
207
+					break;
208
+				case self::COUNT_REGISTRATIONS_INCOMPLETE:
209
+					$count = $this->registration_model->count(
210
+						array(
211
+							array(
212
+								'STS_ID' => EEM_Registration::status_id_incomplete,
213
+							),
214
+						)
215
+					);
216
+					break;
217
+				case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
+					$count = $this->registration_model->count(
219
+						array(
220
+							array(
221
+								'STS_ID' => EEM_Registration::status_id_not_approved,
222
+							),
223
+						)
224
+					);
225
+					break;
226
+				case self::COUNT_REGISTRATIONS_DECLINED:
227
+					$count = $this->registration_model->count(
228
+						array(
229
+							array(
230
+								'STS_ID' => EEM_Registration::status_id_declined,
231
+							),
232
+						)
233
+					);
234
+					break;
235
+				case self::COUNT_REGISTRATIONS_PENDING:
236
+					$count = $this->registration_model->count(
237
+						array(
238
+							array(
239
+								'STS_ID' => EEM_Registration::status_id_pending_payment,
240
+							),
241
+						)
242
+					);
243
+					break;
244
+				case self::COUNT_REGISTRATIONS_APPROVED:
245
+					$count = $this->registration_model->count(
246
+						array(
247
+							array(
248
+								'STS_ID' => EEM_Registration::status_id_approved,
249
+							),
250
+						)
251
+					);
252
+					break;
253
+				case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
254
+					$count = $this->transaction_model->sum(
255
+						array(
256
+							array(
257
+								'STS_ID' => EEM_Transaction::complete_status_code,
258
+							),
259
+						),
260
+						'TXN_total'
261
+					);
262
+					break;
263
+				case self::SUM_TRANSACTIONS_ALL_PAID:
264
+					$count = $this->transaction_model->sum(
265
+						array(),
266
+						'TXN_paid'
267
+					);
268
+					break;
269
+				default:
270
+					$count = null;
271
+					break;
272
+			}
273
+		} catch (Exception $e) {
274
+			$count = null;
275
+		}
276
+		return $count;
277
+	}
278 278
 
279
-    /**
280
-     * Return the active theme.
281
-     *
282
-     * @return false|string
283
-     */
284
-    private function getActiveThemeStat()
285
-    {
286
-        $theme = wp_get_theme();
287
-        return $theme->get('Name');
288
-    }
279
+	/**
280
+	 * Return the active theme.
281
+	 *
282
+	 * @return false|string
283
+	 */
284
+	private function getActiveThemeStat()
285
+	{
286
+		$theme = wp_get_theme();
287
+		return $theme->get('Name');
288
+	}
289 289
 
290
-    /**
291
-     * @return array
292
-     */
293
-    private function paymentMethodStats()
294
-    {
295
-        $payment_method_stats = array();
296
-        try {
297
-            $active_payment_methods = $this->payment_method_model->get_all_active(
298
-                null,
299
-                array('group_by' => 'PMD_type')
300
-            );
301
-            if ($active_payment_methods) {
302
-                foreach ($active_payment_methods as $payment_method) {
303
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
304
-                }
305
-            }
306
-        } catch (Exception $e) {
307
-            // do nothing just prevents fatals.
308
-        }
309
-        return $payment_method_stats;
310
-    }
290
+	/**
291
+	 * @return array
292
+	 */
293
+	private function paymentMethodStats()
294
+	{
295
+		$payment_method_stats = array();
296
+		try {
297
+			$active_payment_methods = $this->payment_method_model->get_all_active(
298
+				null,
299
+				array('group_by' => 'PMD_type')
300
+			);
301
+			if ($active_payment_methods) {
302
+				foreach ($active_payment_methods as $payment_method) {
303
+					$payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
304
+				}
305
+			}
306
+		} catch (Exception $e) {
307
+			// do nothing just prevents fatals.
308
+		}
309
+		return $payment_method_stats;
310
+	}
311 311
 
312 312
 
313
-    /**
314
-     * Return a list of active EE add-ons and their versions.
315
-     *
316
-     * @return string
317
-     */
318
-    private function getActiveAddons()
319
-    {
320
-        $activeAddons = [];
321
-        $addOns = EE_Registry::instance()->addons;
322
-        if (! empty($addOns)) {
323
-            foreach ($addOns as $addon) {
324
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
325
-            }
326
-        }
327
-        return implode(',', $activeAddons);
328
-    }
313
+	/**
314
+	 * Return a list of active EE add-ons and their versions.
315
+	 *
316
+	 * @return string
317
+	 */
318
+	private function getActiveAddons()
319
+	{
320
+		$activeAddons = [];
321
+		$addOns = EE_Registry::instance()->addons;
322
+		if (! empty($addOns)) {
323
+			foreach ($addOns as $addon) {
324
+				$activeAddons[] = $addon->name() . '@' . $addon->version();
325
+			}
326
+		}
327
+		return implode(',', $activeAddons);
328
+	}
329 329
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             'active_addons'                   => $this->getActiveAddons(),
149 149
         ));
150 150
         // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
-        return array_filter($stats, function ($value) {
151
+        return array_filter($stats, function($value) {
152 152
             return $value !== null;
153 153
         });
154 154
     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             );
301 301
             if ($active_payment_methods) {
302 302
                 foreach ($active_payment_methods as $payment_method) {
303
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
303
+                    $payment_method_stats[$payment_method->name().'_active_payment_method'] = 1;
304 304
                 }
305 305
             }
306 306
         } catch (Exception $e) {
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
     {
320 320
         $activeAddons = [];
321 321
         $addOns = EE_Registry::instance()->addons;
322
-        if (! empty($addOns)) {
322
+        if ( ! empty($addOns)) {
323 323
             foreach ($addOns as $addon) {
324
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
324
+                $activeAddons[] = $addon->name().'@'.$addon->version();
325 325
             }
326 326
         }
327 327
         return implode(',', $activeAddons);
Please login to merge, or discard this patch.
core/domain/services/admin/registrations/list_table/QueryBuilder.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -383,7 +383,7 @@
 block discarded – undo
383 383
     /**
384 384
      * Sets up the limit for the registrations query.
385 385
      *
386
-     * @param $per_page
386
+     * @param integer $per_page
387 387
      * @return array
388 388
      */
389 389
     protected function getLimitClause($per_page)
Please login to merge, or discard this patch.
Indentation   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -21,384 +21,384 @@
 block discarded – undo
21 21
 class QueryBuilder
22 22
 {
23 23
 
24
-    /**
25
-     * @var RequestInterface $request
26
-     */
27
-    protected $request;
28
-
29
-    /**
30
-     * @var EEM_Registration $registration_model
31
-     */
32
-    protected $registration_model;
33
-
34
-    /**
35
-     * @var string $view
36
-     */
37
-    protected $view;
38
-
39
-    /**
40
-     * @var array $where_params
41
-     */
42
-    protected $where_params;
43
-
44
-
45
-    /**
46
-     * QueryBuilder constructor.
47
-     *
48
-     * @param array            $extra_request_params
49
-     * @param RequestInterface $request
50
-     * @param EEM_Registration $registration_model
51
-     */
52
-    public function __construct(
53
-        array $extra_request_params,
54
-        RequestInterface $request,
55
-        EEM_Registration $registration_model
56
-    ) {
57
-        $this->request = $request;
58
-        $this->registration_model = $registration_model;
59
-        foreach ($extra_request_params as $key => $value) {
60
-            $this->request->setRequestParam($key, $value);
61
-        }
62
-        $this->view = $this->request->getRequestParam('status', '');
63
-        $this->where_params = [];
64
-    }
65
-
66
-
67
-    /**
68
-     * Sets up the where conditions for the registrations query.
69
-     *
70
-     * @param int  $per_page
71
-     * @param bool $count_query
72
-     * @return array
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     */
78
-    public function getQueryParams($per_page = 10, $count_query = false)
79
-    {
80
-        $query_params = [
81
-            0                          => $this->getWhereClause(),
82
-            'caps'                     => EEM_Registration::caps_read_admin,
83
-            'default_where_conditions' => 'this_model_only',
84
-        ];
85
-        if (! $count_query) {
86
-            $query_params = array_merge(
87
-                $query_params,
88
-                $this->getOrderbyClause(),
89
-                $this->getLimitClause($per_page)
90
-            );
91
-        }
92
-
93
-        return $query_params;
94
-    }
95
-
96
-
97
-    /**
98
-     * Sets up the where conditions for the registrations query.
99
-     *
100
-     * @return array
101
-     * @throws EE_Error
102
-     * @throws InvalidArgumentException
103
-     * @throws InvalidDataTypeException
104
-     * @throws InvalidInterfaceException
105
-     */
106
-    protected function getWhereClause()
107
-    {
108
-        $this->addAttendeeIdToWhereConditions();
109
-        $this->addEventIdToWhereConditions();
110
-        $this->addCategoryIdToWhereConditions();
111
-        $this->addDatetimeIdToWhereConditions();
112
-        $this->addTicketIdToWhereConditions();
113
-        $this->addRegistrationStatusToWhereConditions();
114
-        $this->addDateToWhereConditions();
115
-        $this->addSearchToWhereConditions();
116
-        return apply_filters(
117
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
-            $this->where_params,
119
-            $this->request->requestParams()
120
-        );
121
-    }
122
-
123
-
124
-    /**
125
-     * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
-     */
127
-    protected function addAttendeeIdToWhereConditions()
128
-    {
129
-        $ATT_ID = $this->request->getRequestParam('attendee_id');
130
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID);
131
-        if ($ATT_ID) {
132
-            $this->where_params['ATT_ID'] = absint($ATT_ID);
133
-        }
134
-    }
135
-
136
-
137
-    /**
138
-     * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
-     */
140
-    protected function addEventIdToWhereConditions()
141
-    {
142
-        $EVT_ID = $this->request->getRequestParam('event_id');
143
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID);
144
-        if ($EVT_ID) {
145
-            $this->where_params['EVT_ID'] = absint($EVT_ID);
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
-     */
153
-    protected function addCategoryIdToWhereConditions()
154
-    {
155
-        $EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT');
156
-        if ($EVT_CAT > 0) {
157
-            $this->where_params['Event.Term_Taxonomy.term_id'] = absint($EVT_CAT);
158
-        }
159
-    }
160
-
161
-
162
-    /**
163
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
-     */
165
-    protected function addDatetimeIdToWhereConditions()
166
-    {
167
-        // first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
-        $DTT_ID = $this->request->getRequestParam('datetime_id');
169
-        $DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID);
170
-        if ($DTT_ID) {
171
-            $this->where_params['Ticket.Datetime.DTT_ID'] = absint($DTT_ID);
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
-     */
179
-    protected function addTicketIdToWhereConditions()
180
-    {
181
-        // first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
-        $TKT_ID = $this->request->getRequestParam('ticket_id');
183
-        $TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID);
184
-        if ($TKT_ID) {
185
-            $this->where_params['TKT_ID'] = absint($TKT_ID);
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * Adds the correct registration status to the where conditions for the registrations query.
192
-     * If filtering by registration status, then we show registrations matching that status.
193
-     * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
-     * UNLESS viewing trashed registrations.
195
-     */
196
-    protected function addRegistrationStatusToWhereConditions()
197
-    {
198
-        $registration_status = $this->request->getRequestParam('_reg_status');
199
-        if ($registration_status) {
200
-            $this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
-            return;
202
-        }
203
-        // make sure we exclude incomplete registrations, but only if not trashed.
204
-        if ($this->view === 'trash') {
205
-            $this->where_params['REG_deleted'] = true;
206
-            return;
207
-        }
208
-        $this->where_params['STS_ID'] = $this->view === 'incomplete'
209
-            ? EEM_Registration::status_id_incomplete
210
-            : ['!=', EEM_Registration::status_id_incomplete];
211
-    }
212
-
213
-
214
-    /**
215
-     * Adds any provided date restraints to the where conditions for the registrations query.
216
-     *
217
-     * @throws EE_Error
218
-     * @throws InvalidArgumentException
219
-     * @throws InvalidDataTypeException
220
-     * @throws InvalidInterfaceException
221
-     */
222
-    protected function addDateToWhereConditions()
223
-    {
224
-        if ($this->view === 'today') {
225
-            $now = date('Y-m-d', current_time('timestamp'));
226
-            $this->where_params['REG_date'] = [
227
-                'BETWEEN',
228
-                [
229
-                    $this->registration_model->convert_datetime_for_query(
230
-                        'REG_date',
231
-                        $now . ' 00:00:00',
232
-                        'Y-m-d H:i:s'
233
-                    ),
234
-                    $this->registration_model->convert_datetime_for_query(
235
-                        'REG_date',
236
-                        $now . ' 23:59:59',
237
-                        'Y-m-d H:i:s'
238
-                    ),
239
-                ],
240
-            ];
241
-            return;
242
-        }
243
-        if ($this->view === 'month') {
244
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
245
-            $days_this_month = date('t', current_time('timestamp'));
246
-            $this->where_params['REG_date'] = [
247
-                'BETWEEN',
248
-                [
249
-                    $this->registration_model->convert_datetime_for_query(
250
-                        'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
252
-                        'Y-m-d H:i:s'
253
-                    ),
254
-                    $this->registration_model->convert_datetime_for_query(
255
-                        'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
-                        'Y-m-d H:i:s'
258
-                    ),
259
-                ],
260
-            ];
261
-            return;
262
-        }
263
-        $month_range = $this->request->getRequestParam('month_range');
264
-        if ($month_range) {
265
-            $month_range = sanitize_text_field($month_range);
266
-            $pieces = explode(' ', $month_range, 3);
267
-            $month_requested = ! empty($pieces[0])
268
-                ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
-                : '';
270
-            $year_requested = ! empty($pieces[1])
271
-                ? $pieces[1]
272
-                : '';
273
-            // if there is not a month or year then we can't go further
274
-            if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
-                $this->where_params['REG_date'] = [
277
-                    'BETWEEN',
278
-                    [
279
-                        $this->registration_model->convert_datetime_for_query(
280
-                            'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
282
-                            'Y-m-d H:i:s'
283
-                        ),
284
-                        $this->registration_model->convert_datetime_for_query(
285
-                            'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
-                            'Y-m-d H:i:s'
288
-                        ),
289
-                    ],
290
-                ];
291
-            }
292
-        }
293
-    }
294
-
295
-
296
-    /**
297
-     * Adds any provided search restraints to the where conditions for the registrations query
298
-     */
299
-    protected function addSearchToWhereConditions()
300
-    {
301
-        $search = $this->request->getRequestParam('s');
302
-        if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
304
-            $this->where_params['OR*search_conditions'] = [
305
-                'Event.EVT_name'                          => ['LIKE', $search_string],
306
-                'Event.EVT_desc'                          => ['LIKE', $search_string],
307
-                'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
-                'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
-                'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
-                'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
-                'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
-                'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
-                'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
-                'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
-                'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
-                'REG_final_price'                         => ['LIKE', $search_string],
317
-                'REG_code'                                => ['LIKE', $search_string],
318
-                'REG_count'                               => ['LIKE', $search_string],
319
-                'REG_group_size'                          => ['LIKE', $search_string],
320
-                'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
-                'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
-            ];
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * Sets up the orderby for the registrations query.
330
-     *
331
-     * @return array
332
-     */
333
-    protected function getOrderbyClause()
334
-    {
335
-        $orderby_field = $this->request->getRequestParam('orderby');
336
-        $orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
-        switch ($orderby_field) {
338
-            case '_REG_ID':
339
-                $orderby = ['REG_ID'];
340
-                break;
341
-            case '_Reg_status':
342
-                $orderby = ['STS_ID'];
343
-                break;
344
-            case 'ATT_fname':
345
-                $orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
-                break;
347
-            case 'ATT_lname':
348
-                $orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
-                break;
350
-            case 'event_name':
351
-                $orderby = ['Event.EVT_name'];
352
-                break;
353
-            case 'DTT_EVT_start':
354
-                $orderby = ['Event.Datetime.DTT_EVT_start'];
355
-                break;
356
-            case '_REG_date':
357
-                $orderby = ['REG_date'];
358
-                break;
359
-            default:
360
-                $orderby = [$orderby_field];
361
-                break;
362
-        }
363
-        $order = $this->request->getRequestParam('order');
364
-        $order = $order ? sanitize_text_field($order) : 'DESC';
365
-
366
-        $orderby = array_combine(
367
-            $orderby,
368
-            array_fill(0, count($orderby), $order)
369
-        );
370
-        // because there are many registrations with the same date, define
371
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
372
-        if (empty($orderby['REG_ID'])) {
373
-            $orderby['REG_ID'] = $order;
374
-        }
375
-
376
-        $orderby = apply_filters(
377
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
-            $orderby,
379
-            $this->request->requestParams()
380
-        );
381
-        return ['order_by' => $orderby];
382
-    }
383
-
384
-
385
-    /**
386
-     * Sets up the limit for the registrations query.
387
-     *
388
-     * @param $per_page
389
-     * @return array
390
-     */
391
-    protected function getLimitClause($per_page)
392
-    {
393
-        $current_page = $this->request->getRequestParam('paged');
394
-        $current_page = $current_page ? absint($current_page) : 1;
395
-        $per_page = (int) $this->request->getRequestParam('perpage', $per_page);
396
-        // -1 means return all results so get out if that's set.
397
-        if ($per_page === -1) {
398
-            return [];
399
-        }
400
-        $per_page = absint($per_page);
401
-        $offset = ($current_page - 1) * $per_page;
402
-        return ['limit' => [$offset, $per_page]];
403
-    }
24
+	/**
25
+	 * @var RequestInterface $request
26
+	 */
27
+	protected $request;
28
+
29
+	/**
30
+	 * @var EEM_Registration $registration_model
31
+	 */
32
+	protected $registration_model;
33
+
34
+	/**
35
+	 * @var string $view
36
+	 */
37
+	protected $view;
38
+
39
+	/**
40
+	 * @var array $where_params
41
+	 */
42
+	protected $where_params;
43
+
44
+
45
+	/**
46
+	 * QueryBuilder constructor.
47
+	 *
48
+	 * @param array            $extra_request_params
49
+	 * @param RequestInterface $request
50
+	 * @param EEM_Registration $registration_model
51
+	 */
52
+	public function __construct(
53
+		array $extra_request_params,
54
+		RequestInterface $request,
55
+		EEM_Registration $registration_model
56
+	) {
57
+		$this->request = $request;
58
+		$this->registration_model = $registration_model;
59
+		foreach ($extra_request_params as $key => $value) {
60
+			$this->request->setRequestParam($key, $value);
61
+		}
62
+		$this->view = $this->request->getRequestParam('status', '');
63
+		$this->where_params = [];
64
+	}
65
+
66
+
67
+	/**
68
+	 * Sets up the where conditions for the registrations query.
69
+	 *
70
+	 * @param int  $per_page
71
+	 * @param bool $count_query
72
+	 * @return array
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 */
78
+	public function getQueryParams($per_page = 10, $count_query = false)
79
+	{
80
+		$query_params = [
81
+			0                          => $this->getWhereClause(),
82
+			'caps'                     => EEM_Registration::caps_read_admin,
83
+			'default_where_conditions' => 'this_model_only',
84
+		];
85
+		if (! $count_query) {
86
+			$query_params = array_merge(
87
+				$query_params,
88
+				$this->getOrderbyClause(),
89
+				$this->getLimitClause($per_page)
90
+			);
91
+		}
92
+
93
+		return $query_params;
94
+	}
95
+
96
+
97
+	/**
98
+	 * Sets up the where conditions for the registrations query.
99
+	 *
100
+	 * @return array
101
+	 * @throws EE_Error
102
+	 * @throws InvalidArgumentException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws InvalidInterfaceException
105
+	 */
106
+	protected function getWhereClause()
107
+	{
108
+		$this->addAttendeeIdToWhereConditions();
109
+		$this->addEventIdToWhereConditions();
110
+		$this->addCategoryIdToWhereConditions();
111
+		$this->addDatetimeIdToWhereConditions();
112
+		$this->addTicketIdToWhereConditions();
113
+		$this->addRegistrationStatusToWhereConditions();
114
+		$this->addDateToWhereConditions();
115
+		$this->addSearchToWhereConditions();
116
+		return apply_filters(
117
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
+			$this->where_params,
119
+			$this->request->requestParams()
120
+		);
121
+	}
122
+
123
+
124
+	/**
125
+	 * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
+	 */
127
+	protected function addAttendeeIdToWhereConditions()
128
+	{
129
+		$ATT_ID = $this->request->getRequestParam('attendee_id');
130
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID);
131
+		if ($ATT_ID) {
132
+			$this->where_params['ATT_ID'] = absint($ATT_ID);
133
+		}
134
+	}
135
+
136
+
137
+	/**
138
+	 * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
+	 */
140
+	protected function addEventIdToWhereConditions()
141
+	{
142
+		$EVT_ID = $this->request->getRequestParam('event_id');
143
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID);
144
+		if ($EVT_ID) {
145
+			$this->where_params['EVT_ID'] = absint($EVT_ID);
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
+	 */
153
+	protected function addCategoryIdToWhereConditions()
154
+	{
155
+		$EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT');
156
+		if ($EVT_CAT > 0) {
157
+			$this->where_params['Event.Term_Taxonomy.term_id'] = absint($EVT_CAT);
158
+		}
159
+	}
160
+
161
+
162
+	/**
163
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
+	 */
165
+	protected function addDatetimeIdToWhereConditions()
166
+	{
167
+		// first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
+		$DTT_ID = $this->request->getRequestParam('datetime_id');
169
+		$DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID);
170
+		if ($DTT_ID) {
171
+			$this->where_params['Ticket.Datetime.DTT_ID'] = absint($DTT_ID);
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
+	 */
179
+	protected function addTicketIdToWhereConditions()
180
+	{
181
+		// first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
+		$TKT_ID = $this->request->getRequestParam('ticket_id');
183
+		$TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID);
184
+		if ($TKT_ID) {
185
+			$this->where_params['TKT_ID'] = absint($TKT_ID);
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * Adds the correct registration status to the where conditions for the registrations query.
192
+	 * If filtering by registration status, then we show registrations matching that status.
193
+	 * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
+	 * UNLESS viewing trashed registrations.
195
+	 */
196
+	protected function addRegistrationStatusToWhereConditions()
197
+	{
198
+		$registration_status = $this->request->getRequestParam('_reg_status');
199
+		if ($registration_status) {
200
+			$this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
+			return;
202
+		}
203
+		// make sure we exclude incomplete registrations, but only if not trashed.
204
+		if ($this->view === 'trash') {
205
+			$this->where_params['REG_deleted'] = true;
206
+			return;
207
+		}
208
+		$this->where_params['STS_ID'] = $this->view === 'incomplete'
209
+			? EEM_Registration::status_id_incomplete
210
+			: ['!=', EEM_Registration::status_id_incomplete];
211
+	}
212
+
213
+
214
+	/**
215
+	 * Adds any provided date restraints to the where conditions for the registrations query.
216
+	 *
217
+	 * @throws EE_Error
218
+	 * @throws InvalidArgumentException
219
+	 * @throws InvalidDataTypeException
220
+	 * @throws InvalidInterfaceException
221
+	 */
222
+	protected function addDateToWhereConditions()
223
+	{
224
+		if ($this->view === 'today') {
225
+			$now = date('Y-m-d', current_time('timestamp'));
226
+			$this->where_params['REG_date'] = [
227
+				'BETWEEN',
228
+				[
229
+					$this->registration_model->convert_datetime_for_query(
230
+						'REG_date',
231
+						$now . ' 00:00:00',
232
+						'Y-m-d H:i:s'
233
+					),
234
+					$this->registration_model->convert_datetime_for_query(
235
+						'REG_date',
236
+						$now . ' 23:59:59',
237
+						'Y-m-d H:i:s'
238
+					),
239
+				],
240
+			];
241
+			return;
242
+		}
243
+		if ($this->view === 'month') {
244
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
245
+			$days_this_month = date('t', current_time('timestamp'));
246
+			$this->where_params['REG_date'] = [
247
+				'BETWEEN',
248
+				[
249
+					$this->registration_model->convert_datetime_for_query(
250
+						'REG_date',
251
+						$current_year_and_month . '-01 00:00:00',
252
+						'Y-m-d H:i:s'
253
+					),
254
+					$this->registration_model->convert_datetime_for_query(
255
+						'REG_date',
256
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
+						'Y-m-d H:i:s'
258
+					),
259
+				],
260
+			];
261
+			return;
262
+		}
263
+		$month_range = $this->request->getRequestParam('month_range');
264
+		if ($month_range) {
265
+			$month_range = sanitize_text_field($month_range);
266
+			$pieces = explode(' ', $month_range, 3);
267
+			$month_requested = ! empty($pieces[0])
268
+				? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
+				: '';
270
+			$year_requested = ! empty($pieces[1])
271
+				? $pieces[1]
272
+				: '';
273
+			// if there is not a month or year then we can't go further
274
+			if ($month_requested && $year_requested) {
275
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
+				$this->where_params['REG_date'] = [
277
+					'BETWEEN',
278
+					[
279
+						$this->registration_model->convert_datetime_for_query(
280
+							'REG_date',
281
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
282
+							'Y-m-d H:i:s'
283
+						),
284
+						$this->registration_model->convert_datetime_for_query(
285
+							'REG_date',
286
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
+							'Y-m-d H:i:s'
288
+						),
289
+					],
290
+				];
291
+			}
292
+		}
293
+	}
294
+
295
+
296
+	/**
297
+	 * Adds any provided search restraints to the where conditions for the registrations query
298
+	 */
299
+	protected function addSearchToWhereConditions()
300
+	{
301
+		$search = $this->request->getRequestParam('s');
302
+		if ($search) {
303
+			$search_string = '%' . sanitize_text_field($search) . '%';
304
+			$this->where_params['OR*search_conditions'] = [
305
+				'Event.EVT_name'                          => ['LIKE', $search_string],
306
+				'Event.EVT_desc'                          => ['LIKE', $search_string],
307
+				'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
+				'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
+				'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
+				'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
+				'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
+				'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
+				'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
+				'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
+				'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
+				'REG_final_price'                         => ['LIKE', $search_string],
317
+				'REG_code'                                => ['LIKE', $search_string],
318
+				'REG_count'                               => ['LIKE', $search_string],
319
+				'REG_group_size'                          => ['LIKE', $search_string],
320
+				'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
+				'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
+			];
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * Sets up the orderby for the registrations query.
330
+	 *
331
+	 * @return array
332
+	 */
333
+	protected function getOrderbyClause()
334
+	{
335
+		$orderby_field = $this->request->getRequestParam('orderby');
336
+		$orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
+		switch ($orderby_field) {
338
+			case '_REG_ID':
339
+				$orderby = ['REG_ID'];
340
+				break;
341
+			case '_Reg_status':
342
+				$orderby = ['STS_ID'];
343
+				break;
344
+			case 'ATT_fname':
345
+				$orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
+				break;
347
+			case 'ATT_lname':
348
+				$orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
+				break;
350
+			case 'event_name':
351
+				$orderby = ['Event.EVT_name'];
352
+				break;
353
+			case 'DTT_EVT_start':
354
+				$orderby = ['Event.Datetime.DTT_EVT_start'];
355
+				break;
356
+			case '_REG_date':
357
+				$orderby = ['REG_date'];
358
+				break;
359
+			default:
360
+				$orderby = [$orderby_field];
361
+				break;
362
+		}
363
+		$order = $this->request->getRequestParam('order');
364
+		$order = $order ? sanitize_text_field($order) : 'DESC';
365
+
366
+		$orderby = array_combine(
367
+			$orderby,
368
+			array_fill(0, count($orderby), $order)
369
+		);
370
+		// because there are many registrations with the same date, define
371
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
372
+		if (empty($orderby['REG_ID'])) {
373
+			$orderby['REG_ID'] = $order;
374
+		}
375
+
376
+		$orderby = apply_filters(
377
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
+			$orderby,
379
+			$this->request->requestParams()
380
+		);
381
+		return ['order_by' => $orderby];
382
+	}
383
+
384
+
385
+	/**
386
+	 * Sets up the limit for the registrations query.
387
+	 *
388
+	 * @param $per_page
389
+	 * @return array
390
+	 */
391
+	protected function getLimitClause($per_page)
392
+	{
393
+		$current_page = $this->request->getRequestParam('paged');
394
+		$current_page = $current_page ? absint($current_page) : 1;
395
+		$per_page = (int) $this->request->getRequestParam('perpage', $per_page);
396
+		// -1 means return all results so get out if that's set.
397
+		if ($per_page === -1) {
398
+			return [];
399
+		}
400
+		$per_page = absint($per_page);
401
+		$offset = ($current_page - 1) * $per_page;
402
+		return ['limit' => [$offset, $per_page]];
403
+	}
404 404
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'caps'                     => EEM_Registration::caps_read_admin,
83 83
             'default_where_conditions' => 'this_model_only',
84 84
         ];
85
-        if (! $count_query) {
85
+        if ( ! $count_query) {
86 86
             $query_params = array_merge(
87 87
                 $query_params,
88 88
                 $this->getOrderbyClause(),
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
                 [
229 229
                     $this->registration_model->convert_datetime_for_query(
230 230
                         'REG_date',
231
-                        $now . ' 00:00:00',
231
+                        $now.' 00:00:00',
232 232
                         'Y-m-d H:i:s'
233 233
                     ),
234 234
                     $this->registration_model->convert_datetime_for_query(
235 235
                         'REG_date',
236
-                        $now . ' 23:59:59',
236
+                        $now.' 23:59:59',
237 237
                         'Y-m-d H:i:s'
238 238
                     ),
239 239
                 ],
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                 [
249 249
                     $this->registration_model->convert_datetime_for_query(
250 250
                         'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
251
+                        $current_year_and_month.'-01 00:00:00',
252 252
                         'Y-m-d H:i:s'
253 253
                     ),
254 254
                     $this->registration_model->convert_datetime_for_query(
255 255
                         'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
256
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
257 257
                         'Y-m-d H:i:s'
258 258
                     ),
259 259
                 ],
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
                 : '';
273 273
             // if there is not a month or year then we can't go further
274 274
             if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
275
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
276 276
                 $this->where_params['REG_date'] = [
277 277
                     'BETWEEN',
278 278
                     [
279 279
                         $this->registration_model->convert_datetime_for_query(
280 280
                             'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
281
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
282 282
                             'Y-m-d H:i:s'
283 283
                         ),
284 284
                         $this->registration_model->convert_datetime_for_query(
285 285
                             'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
286
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
287 287
                             'Y-m-d H:i:s'
288 288
                         ),
289 289
                     ],
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         $search = $this->request->getRequestParam('s');
302 302
         if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
303
+            $search_string = '%'.sanitize_text_field($search).'%';
304 304
             $this->where_params['OR*search_conditions'] = [
305 305
                 'Event.EVT_name'                          => ['LIKE', $search_string],
306 306
                 'Event.EVT_desc'                          => ['LIKE', $search_string],
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1124 added lines, -1124 removed lines patch added patch discarded remove patch
@@ -20,1128 +20,1128 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Cart'                                                                                                     => array(
463
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_Front_Controller'                                                                                         => array(
466
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messenger_Collection_Loader'                                                                              => array(
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ),
473
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Message_Resource_Manager'                                                                                 => array(
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ),
481
-            'EE_Message_Factory'                                                                                          => array(
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_messages'                                                                                                 => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Generator'                                                                                       => array(
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ),
493
-            'EE_Messages_Processor'                                                                                       => array(
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Messages_Queue'                                                                                           => array(
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ),
499
-            'EE_Messages_Template_Defaults'                                                                               => array(
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ),
503
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ),
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_Data_Migration_Class_Base'                                                                                => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EE_DMS_Core_4_9_0' => array(
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EE_DMS_Core_4_10_0' => array(
604
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
-            ),
608
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
-                array(),
610
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
-            ),
647
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
-                null,
649
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
-            ),
654
-            'LEGACY_MODELS'                                                                                               => array(
655
-                null,
656
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EE_Module_Request_Router'                                                                                    => array(
659
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
660
-            ),
661
-            'EE_Registration_Processor'                                                                                   => array(
662
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
-                null,
666
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
674
-                null,
675
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
-            ),
682
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
-            ),
686
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
-            ),
698
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
-            ),
701
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
-            ),
705
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
-            ),
708
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
-            ),
715
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
-            ),
718
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
-            ),
725
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
-            ),
728
-            'EE_CPT_Strategy'                                                                                             => array(
729
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
-            ),
732
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
-            ),
735
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
-            ),
742
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
-            ),
746
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
-            ),
749
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
-            ),
759
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
-            ),
762
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
-            ),
765
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
-            ),
769
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
-                null,
771
-                null,
772
-                null,
773
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
-            ),
777
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
-                'EE_Config' => EE_Dependency_Map::load_from_cache
780
-            ),
781
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
-            ),
787
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
-            ),
792
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
-            ),
801
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
-            ),
806
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
-            ),
810
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
-            ),
814
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
-            ),
817
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
-            ),
820
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
-            ),
823
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
-            ),
827
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
-            ),
831
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
-            ),
834
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
835
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
-            ),
837
-            'EE_URL_Validation_Strategy' => array(
838
-                null,
839
-                null,
840
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
-            ),
842
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
-            ),
849
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
-            ),
853
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
-            ),
857
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
-            ),
861
-            'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
-            ),
864
-            'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
-            ],
867
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
-                null,
869
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
-                'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
-            ],
872
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
-                'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
-            ],
876
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
-                'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
-            ],
880
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
-                'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
-            ],
884
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
-                'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
-            ],
888
-        );
889
-    }
890
-
891
-
892
-    /**
893
-     * Registers how core classes are loaded.
894
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
895
-     *        'EE_Request_Handler' => 'load_core'
896
-     *        'EE_Messages_Queue'  => 'load_lib'
897
-     *        'EEH_Debug_Tools'    => 'load_helper'
898
-     * or, if greater control is required, by providing a custom closure. For example:
899
-     *        'Some_Class' => function () {
900
-     *            return new Some_Class();
901
-     *        },
902
-     * This is required for instantiating dependencies
903
-     * where an interface has been type hinted in a class constructor. For example:
904
-     *        'Required_Interface' => function () {
905
-     *            return new A_Class_That_Implements_Required_Interface();
906
-     *        },
907
-     */
908
-    protected function _register_core_class_loaders()
909
-    {
910
-        $this->_class_loaders = array(
911
-            // load_core
912
-            'EE_Dependency_Map'                            => function () {
913
-                return $this;
914
-            },
915
-            'EE_Capabilities'                              => 'load_core',
916
-            'EE_Encryption'                                => 'load_core',
917
-            'EE_Front_Controller'                          => 'load_core',
918
-            'EE_Module_Request_Router'                     => 'load_core',
919
-            'EE_Registry'                                  => 'load_core',
920
-            'EE_Request'                                   => function () {
921
-                return $this->legacy_request;
922
-            },
923
-            'EventEspresso\core\services\request\Request'  => function () {
924
-                return $this->request;
925
-            },
926
-            'EventEspresso\core\services\request\Response' => function () {
927
-                return $this->response;
928
-            },
929
-            'EE_Base'                                      => 'load_core',
930
-            'EE_Request_Handler'                           => 'load_core',
931
-            'EE_Session'                                   => 'load_core',
932
-            'EE_Cron_Tasks'                                => 'load_core',
933
-            'EE_System'                                    => 'load_core',
934
-            'EE_Maintenance_Mode'                          => 'load_core',
935
-            'EE_Register_CPTs'                             => 'load_core',
936
-            'EE_Admin'                                     => 'load_core',
937
-            'EE_CPT_Strategy'                              => 'load_core',
938
-            // load_class
939
-            'EE_Registration_Processor'                    => 'load_class',
940
-            // load_lib
941
-            'EE_Message_Resource_Manager'                  => 'load_lib',
942
-            'EE_Message_Type_Collection'                   => 'load_lib',
943
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
944
-            'EE_Messenger_Collection'                      => 'load_lib',
945
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
946
-            'EE_Messages_Processor'                        => 'load_lib',
947
-            'EE_Message_Repository'                        => 'load_lib',
948
-            'EE_Messages_Queue'                            => 'load_lib',
949
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
950
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
951
-            'EE_Payment_Method_Manager'                    => 'load_lib',
952
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
953
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
954
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
955
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
956
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
957
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
958
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
959
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
960
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
961
-            'EE_Messages_Generator'                        => function () {
962
-                return EE_Registry::instance()->load_lib(
963
-                    'Messages_Generator',
964
-                    array(),
965
-                    false,
966
-                    false
967
-                );
968
-            },
969
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
970
-                return EE_Registry::instance()->load_lib(
971
-                    'Messages_Template_Defaults',
972
-                    $arguments,
973
-                    false,
974
-                    false
975
-                );
976
-            },
977
-            // load_helper
978
-            'EEH_Parse_Shortcodes'                         => function () {
979
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
980
-                    return new EEH_Parse_Shortcodes();
981
-                }
982
-                return null;
983
-            },
984
-            'EE_Template_Config'                           => function () {
985
-                return EE_Config::instance()->template_settings;
986
-            },
987
-            'EE_Currency_Config'                           => function () {
988
-                return EE_Config::instance()->currency;
989
-            },
990
-            'EE_Registration_Config'                       => function () {
991
-                return EE_Config::instance()->registration;
992
-            },
993
-            'EE_Core_Config'                               => function () {
994
-                return EE_Config::instance()->core;
995
-            },
996
-            'EventEspresso\core\services\loaders\Loader'   => function () {
997
-                return LoaderFactory::getLoader();
998
-            },
999
-            'EE_Network_Config'                            => function () {
1000
-                return EE_Network_Config::instance();
1001
-            },
1002
-            'EE_Config'                                    => function () {
1003
-                return EE_Config::instance();
1004
-            },
1005
-            'EventEspresso\core\domain\Domain'             => function () {
1006
-                return DomainFactory::getEventEspressoCoreDomain();
1007
-            },
1008
-            'EE_Admin_Config'                              => function () {
1009
-                return EE_Config::instance()->admin;
1010
-            },
1011
-            'EE_Organization_Config'                       => function () {
1012
-                return EE_Config::instance()->organization;
1013
-            },
1014
-            'EE_Network_Core_Config'                       => function () {
1015
-                return EE_Network_Config::instance()->core;
1016
-            },
1017
-            'EE_Environment_Config'                        => function () {
1018
-                return EE_Config::instance()->environment;
1019
-            },
1020
-        );
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * can be used for supplying alternate names for classes,
1026
-     * or for connecting interface names to instantiable classes
1027
-     */
1028
-    protected function _register_core_aliases()
1029
-    {
1030
-        $aliases = array(
1031
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1032
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1033
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1034
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1035
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1036
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1037
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1038
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1039
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1040
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1041
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1042
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1043
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1044
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1045
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1046
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1047
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1048
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1049
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1050
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1051
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1052
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1053
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1054
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1055
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1056
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1057
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1058
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1059
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1060
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1061
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1062
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1063
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1064
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1065
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1066
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1067
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1068
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1069
-        );
1070
-        foreach ($aliases as $alias => $fqn) {
1071
-            if (is_array($fqn)) {
1072
-                foreach ($fqn as $class => $for_class) {
1073
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1074
-                }
1075
-                continue;
1076
-            }
1077
-            $this->class_cache->addAlias($fqn, $alias);
1078
-        }
1079
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1080
-            $this->class_cache->addAlias(
1081
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1082
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1083
-            );
1084
-        }
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1090
-     * request Primarily used by unit tests.
1091
-     */
1092
-    public function reset()
1093
-    {
1094
-        $this->_register_core_class_loaders();
1095
-        $this->_register_core_dependencies();
1096
-    }
1097
-
1098
-
1099
-    /**
1100
-     * PLZ NOTE: a better name for this method would be is_alias()
1101
-     * because it returns TRUE if the provided fully qualified name IS an alias
1102
-     * WHY?
1103
-     * Because if a class is type hinting for a concretion,
1104
-     * then why would we need to find another class to supply it?
1105
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1106
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1107
-     * Don't go looking for some substitute.
1108
-     * Whereas if a class is type hinting for an interface...
1109
-     * then we need to find an actual class to use.
1110
-     * So the interface IS the alias for some other FQN,
1111
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1112
-     * represents some other class.
1113
-     *
1114
-     * @deprecated 4.9.62.p
1115
-     * @param string $fqn
1116
-     * @param string $for_class
1117
-     * @return bool
1118
-     */
1119
-    public function has_alias($fqn = '', $for_class = '')
1120
-    {
1121
-        return $this->isAlias($fqn, $for_class);
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1127
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1128
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1129
-     *  for example:
1130
-     *      if the following two entries were added to the _aliases array:
1131
-     *          array(
1132
-     *              'interface_alias'           => 'some\namespace\interface'
1133
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1134
-     *          )
1135
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1136
-     *      to load an instance of 'some\namespace\classname'
1137
-     *
1138
-     * @deprecated 4.9.62.p
1139
-     * @param string $alias
1140
-     * @param string $for_class
1141
-     * @return string
1142
-     */
1143
-    public function get_alias($alias = '', $for_class = '')
1144
-    {
1145
-        return $this->getFqnForAlias($alias, $for_class);
1146
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Cart'                                                                                                     => array(
463
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_Front_Controller'                                                                                         => array(
466
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messenger_Collection_Loader'                                                                              => array(
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			),
473
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Message_Resource_Manager'                                                                                 => array(
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			),
481
+			'EE_Message_Factory'                                                                                          => array(
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_messages'                                                                                                 => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Generator'                                                                                       => array(
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			),
493
+			'EE_Messages_Processor'                                                                                       => array(
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Messages_Queue'                                                                                           => array(
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			),
499
+			'EE_Messages_Template_Defaults'                                                                               => array(
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			),
503
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			),
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_Data_Migration_Class_Base'                                                                                => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EE_DMS_Core_4_9_0' => array(
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EE_DMS_Core_4_10_0' => array(
604
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
+			),
608
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
+				array(),
610
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
+			),
647
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
+				null,
649
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
+			),
654
+			'LEGACY_MODELS'                                                                                               => array(
655
+				null,
656
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EE_Module_Request_Router'                                                                                    => array(
659
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
660
+			),
661
+			'EE_Registration_Processor'                                                                                   => array(
662
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
+				null,
666
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
674
+				null,
675
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
+			),
682
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
+			),
686
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
+			),
698
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
+			),
701
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
+			),
705
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
+			),
708
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
+			),
715
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
+			),
718
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
+			),
725
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
+			),
728
+			'EE_CPT_Strategy'                                                                                             => array(
729
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
+			),
732
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
+			),
735
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
+			),
742
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
+			),
746
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
+			),
749
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
+			),
759
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
+			),
762
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
+			),
765
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
+			),
769
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
+				null,
771
+				null,
772
+				null,
773
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
+			),
777
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
+				'EE_Config' => EE_Dependency_Map::load_from_cache
780
+			),
781
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
+			),
787
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
+			),
792
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
+			),
796
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
+			),
801
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
+			),
806
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
+			),
810
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
+			),
814
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
+			),
817
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
+			),
820
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
+			),
823
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
+			),
827
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
+			),
831
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
+			),
834
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
835
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
+			),
837
+			'EE_URL_Validation_Strategy' => array(
838
+				null,
839
+				null,
840
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
+			),
842
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
+			),
849
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
+			),
853
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
+			),
857
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
+			),
861
+			'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
+			),
864
+			'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
+			],
867
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
+				null,
869
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
+				'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
+			],
872
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
+				'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
+			],
876
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
+				'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
+			],
880
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
+				'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
+			],
884
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
+				'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
+			],
888
+		);
889
+	}
890
+
891
+
892
+	/**
893
+	 * Registers how core classes are loaded.
894
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
895
+	 *        'EE_Request_Handler' => 'load_core'
896
+	 *        'EE_Messages_Queue'  => 'load_lib'
897
+	 *        'EEH_Debug_Tools'    => 'load_helper'
898
+	 * or, if greater control is required, by providing a custom closure. For example:
899
+	 *        'Some_Class' => function () {
900
+	 *            return new Some_Class();
901
+	 *        },
902
+	 * This is required for instantiating dependencies
903
+	 * where an interface has been type hinted in a class constructor. For example:
904
+	 *        'Required_Interface' => function () {
905
+	 *            return new A_Class_That_Implements_Required_Interface();
906
+	 *        },
907
+	 */
908
+	protected function _register_core_class_loaders()
909
+	{
910
+		$this->_class_loaders = array(
911
+			// load_core
912
+			'EE_Dependency_Map'                            => function () {
913
+				return $this;
914
+			},
915
+			'EE_Capabilities'                              => 'load_core',
916
+			'EE_Encryption'                                => 'load_core',
917
+			'EE_Front_Controller'                          => 'load_core',
918
+			'EE_Module_Request_Router'                     => 'load_core',
919
+			'EE_Registry'                                  => 'load_core',
920
+			'EE_Request'                                   => function () {
921
+				return $this->legacy_request;
922
+			},
923
+			'EventEspresso\core\services\request\Request'  => function () {
924
+				return $this->request;
925
+			},
926
+			'EventEspresso\core\services\request\Response' => function () {
927
+				return $this->response;
928
+			},
929
+			'EE_Base'                                      => 'load_core',
930
+			'EE_Request_Handler'                           => 'load_core',
931
+			'EE_Session'                                   => 'load_core',
932
+			'EE_Cron_Tasks'                                => 'load_core',
933
+			'EE_System'                                    => 'load_core',
934
+			'EE_Maintenance_Mode'                          => 'load_core',
935
+			'EE_Register_CPTs'                             => 'load_core',
936
+			'EE_Admin'                                     => 'load_core',
937
+			'EE_CPT_Strategy'                              => 'load_core',
938
+			// load_class
939
+			'EE_Registration_Processor'                    => 'load_class',
940
+			// load_lib
941
+			'EE_Message_Resource_Manager'                  => 'load_lib',
942
+			'EE_Message_Type_Collection'                   => 'load_lib',
943
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
944
+			'EE_Messenger_Collection'                      => 'load_lib',
945
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
946
+			'EE_Messages_Processor'                        => 'load_lib',
947
+			'EE_Message_Repository'                        => 'load_lib',
948
+			'EE_Messages_Queue'                            => 'load_lib',
949
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
950
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
951
+			'EE_Payment_Method_Manager'                    => 'load_lib',
952
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
953
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
954
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
955
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
956
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
957
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
958
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
959
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
960
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
961
+			'EE_Messages_Generator'                        => function () {
962
+				return EE_Registry::instance()->load_lib(
963
+					'Messages_Generator',
964
+					array(),
965
+					false,
966
+					false
967
+				);
968
+			},
969
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
970
+				return EE_Registry::instance()->load_lib(
971
+					'Messages_Template_Defaults',
972
+					$arguments,
973
+					false,
974
+					false
975
+				);
976
+			},
977
+			// load_helper
978
+			'EEH_Parse_Shortcodes'                         => function () {
979
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
980
+					return new EEH_Parse_Shortcodes();
981
+				}
982
+				return null;
983
+			},
984
+			'EE_Template_Config'                           => function () {
985
+				return EE_Config::instance()->template_settings;
986
+			},
987
+			'EE_Currency_Config'                           => function () {
988
+				return EE_Config::instance()->currency;
989
+			},
990
+			'EE_Registration_Config'                       => function () {
991
+				return EE_Config::instance()->registration;
992
+			},
993
+			'EE_Core_Config'                               => function () {
994
+				return EE_Config::instance()->core;
995
+			},
996
+			'EventEspresso\core\services\loaders\Loader'   => function () {
997
+				return LoaderFactory::getLoader();
998
+			},
999
+			'EE_Network_Config'                            => function () {
1000
+				return EE_Network_Config::instance();
1001
+			},
1002
+			'EE_Config'                                    => function () {
1003
+				return EE_Config::instance();
1004
+			},
1005
+			'EventEspresso\core\domain\Domain'             => function () {
1006
+				return DomainFactory::getEventEspressoCoreDomain();
1007
+			},
1008
+			'EE_Admin_Config'                              => function () {
1009
+				return EE_Config::instance()->admin;
1010
+			},
1011
+			'EE_Organization_Config'                       => function () {
1012
+				return EE_Config::instance()->organization;
1013
+			},
1014
+			'EE_Network_Core_Config'                       => function () {
1015
+				return EE_Network_Config::instance()->core;
1016
+			},
1017
+			'EE_Environment_Config'                        => function () {
1018
+				return EE_Config::instance()->environment;
1019
+			},
1020
+		);
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * can be used for supplying alternate names for classes,
1026
+	 * or for connecting interface names to instantiable classes
1027
+	 */
1028
+	protected function _register_core_aliases()
1029
+	{
1030
+		$aliases = array(
1031
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1032
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1033
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1034
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1035
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1036
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1037
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1038
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1039
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1040
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1041
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1042
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1043
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1044
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1045
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1046
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1047
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1048
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1049
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1050
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1051
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1052
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1053
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1054
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1055
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1056
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1057
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1058
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1059
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1060
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1061
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1062
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1063
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1064
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1065
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1066
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1067
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1068
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1069
+		);
1070
+		foreach ($aliases as $alias => $fqn) {
1071
+			if (is_array($fqn)) {
1072
+				foreach ($fqn as $class => $for_class) {
1073
+					$this->class_cache->addAlias($class, $alias, $for_class);
1074
+				}
1075
+				continue;
1076
+			}
1077
+			$this->class_cache->addAlias($fqn, $alias);
1078
+		}
1079
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1080
+			$this->class_cache->addAlias(
1081
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1082
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1083
+			);
1084
+		}
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1090
+	 * request Primarily used by unit tests.
1091
+	 */
1092
+	public function reset()
1093
+	{
1094
+		$this->_register_core_class_loaders();
1095
+		$this->_register_core_dependencies();
1096
+	}
1097
+
1098
+
1099
+	/**
1100
+	 * PLZ NOTE: a better name for this method would be is_alias()
1101
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1102
+	 * WHY?
1103
+	 * Because if a class is type hinting for a concretion,
1104
+	 * then why would we need to find another class to supply it?
1105
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1106
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1107
+	 * Don't go looking for some substitute.
1108
+	 * Whereas if a class is type hinting for an interface...
1109
+	 * then we need to find an actual class to use.
1110
+	 * So the interface IS the alias for some other FQN,
1111
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1112
+	 * represents some other class.
1113
+	 *
1114
+	 * @deprecated 4.9.62.p
1115
+	 * @param string $fqn
1116
+	 * @param string $for_class
1117
+	 * @return bool
1118
+	 */
1119
+	public function has_alias($fqn = '', $for_class = '')
1120
+	{
1121
+		return $this->isAlias($fqn, $for_class);
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1127
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1128
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1129
+	 *  for example:
1130
+	 *      if the following two entries were added to the _aliases array:
1131
+	 *          array(
1132
+	 *              'interface_alias'           => 'some\namespace\interface'
1133
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1134
+	 *          )
1135
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1136
+	 *      to load an instance of 'some\namespace\classname'
1137
+	 *
1138
+	 * @deprecated 4.9.62.p
1139
+	 * @param string $alias
1140
+	 * @param string $for_class
1141
+	 * @return string
1142
+	 */
1143
+	public function get_alias($alias = '', $for_class = '')
1144
+	{
1145
+		return $this->getFqnForAlias($alias, $for_class);
1146
+	}
1147 1147
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     protected function getLoader()
166 166
     {
167
-        if (! $this->loader instanceof LoaderInterface) {
167
+        if ( ! $this->loader instanceof LoaderInterface) {
168 168
             $this->loader = LoaderFactory::getLoader();
169 169
         }
170 170
         return $this->loader;
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
             $this->_cpt_routes
189 189
         );
190 190
         // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
191
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
192
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
191
+        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
192
+            ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
193 193
             : get_post_type_object($page);
194 194
         // tweak pagenow for page loading.
195
-        if (! $this->_pagenow_map) {
195
+        if ( ! $this->_pagenow_map) {
196 196
             $this->_pagenow_map = array(
197 197
                 'create_new' => 'post-new.php',
198 198
                 'edit'       => 'post.php',
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
     {
227 227
         global $pagenow, $hook_suffix;
228 228
         // possibly reset pagenow.
229
-        if (! empty($this->_req_data['page'])
229
+        if ( ! empty($this->_req_data['page'])
230 230
             && $this->_req_data['page'] == $this->page_slug
231 231
             && ! empty($this->_req_data['action'])
232
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
232
+            && isset($this->_pagenow_map[$this->_req_data['action']])
233 233
         ) {
234
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
234
+            $pagenow = $this->_pagenow_map[$this->_req_data['action']];
235 235
             $hook_suffix = $pagenow;
236 236
         }
237 237
     }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         if (empty($wp_meta_boxes)) {
264 264
             return;
265 265
         }
266
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
266
+        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
267 267
         foreach ($current_metaboxes as $box_context) {
268 268
             foreach ($box_context as $box_details) {
269 269
                 foreach ($box_details as $box) {
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             $this
297 297
         );
298 298
         $containers = apply_filters(
299
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
299
+            'FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
300 300
             $containers,
301 301
             $this
302 302
         );
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     protected function _load_page_dependencies()
341 341
     {
342 342
         // we only add stuff if this is a cpt_route!
343
-        if (! $this->_cpt_route) {
343
+        if ( ! $this->_cpt_route) {
344 344
             parent::_load_page_dependencies();
345 345
             return;
346 346
         }
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
         add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
365 365
         // This basically allows us to change the title of the "publish" metabox area
366 366
         // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
367
-        if (! empty($this->_labels['publishbox'])) {
367
+        if ( ! empty($this->_labels['publishbox'])) {
368 368
             $box_label = is_array($this->_labels['publishbox'])
369
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
370
-                ? $this->_labels['publishbox'][ $this->_req_action ]
369
+                         && isset($this->_labels['publishbox'][$this->_req_action])
370
+                ? $this->_labels['publishbox'][$this->_req_action]
371 371
                 : $this->_labels['publishbox'];
372 372
             add_meta_box(
373 373
                 'submitdiv',
374 374
                 $box_label,
375 375
                 'post_submit_meta_box',
376
-                $this->_cpt_routes[ $this->_req_action ],
376
+                $this->_cpt_routes[$this->_req_action],
377 377
                 'side',
378 378
                 'core'
379 379
             );
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
                 'page_templates',
385 385
                 __('Page Template', 'event_espresso'),
386 386
                 array($this, 'page_template_meta_box'),
387
-                $this->_cpt_routes[ $this->_req_action ],
387
+                $this->_cpt_routes[$this->_req_action],
388 388
                 'side',
389 389
                 'default'
390 390
             );
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
         // This is for any plugins that are doing things properly
417 417
         // and hooking into the load page hook for core wp cpt routes.
418 418
         global $pagenow;
419
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
420
-        do_action('load-' . $pagenow);
419
+        add_action('load-'.$pagenow, array($this, 'modify_current_screen'), 20);
420
+        do_action('load-'.$pagenow);
421 421
         add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
422 422
         // we route REALLY early.
423 423
         try {
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
                 'admin.php?page=espresso_registrations&action=contact_list',
447 447
             ),
448 448
             1 => array(
449
-                'edit.php?post_type=' . $this->_cpt_object->name,
450
-                'admin.php?page=' . $this->_cpt_object->name,
449
+                'edit.php?post_type='.$this->_cpt_object->name,
450
+                'admin.php?page='.$this->_cpt_object->name,
451 451
             ),
452 452
         );
453 453
         foreach ($routes_to_match as $route_matches) {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
             'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
477 477
         );
478 478
         $cpt_args = $custom_post_types->getDefinitions();
479
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
479
+        $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
480 480
         $cpt_has_support = ! empty($cpt_args['page_templates']);
481 481
 
482 482
         // if the installed version of WP is > 4.7 we do some additional checks.
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
             // if there are $post_templates for this cpt, then we return false for this method because
486 486
             // that means we aren't going to load our page template manager and leave that up to the native
487 487
             // cpt template manager.
488
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
488
+            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
489 489
         }
490 490
 
491 491
         return $cpt_has_support;
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 
560 560
         $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
561 561
         $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
-            ? $statuses[ $this->_cpt_model_obj->status() ]
562
+            ? $statuses[$this->_cpt_model_obj->status()]
563 563
             : '';
564 564
         $template_args = array(
565 565
             'cur_status'            => $this->_cpt_model_obj->status(),
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             $template_args['statuses'] = $statuses;
575 575
         }
576 576
 
577
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
577
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
578 578
         EEH_Template::display_template($template, $template_args);
579 579
     }
580 580
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             : null;
616 616
         $this->_verify_nonce($nonce, 'autosave');
617 617
         // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
618
-        if (! defined('DOING_AUTOSAVE')) {
618
+        if ( ! defined('DOING_AUTOSAVE')) {
619 619
             define('DOING_AUTOSAVE', true);
620 620
         }
621 621
         // if we made it here then the nonce checked out.  Let's run our methods and actions
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
             $this->_template_args['success'] = true;
627 627
         }
628 628
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
629
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
629
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
630 630
         // now let's return json
631 631
         $this->_return_json();
632 632
     }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
             return;
649 649
         }
650 650
         // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
651
-        if (! empty($this->_cpt_object)) {
651
+        if ( ! empty($this->_cpt_object)) {
652 652
             $this->_page_routes = array_merge(
653 653
                 array(
654 654
                     'create_new' => '_create_new_cpt_item',
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
             );
680 680
         }
681 681
         // load the next section only if this is a matching cpt route as set in the cpt routes array.
682
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
682
+        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
683 683
             return;
684 684
         }
685
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
685
+        $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
686 686
         // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
687 687
         if (empty($this->_cpt_object)) {
688 688
             $msg = sprintf(
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
         if (empty($this->_cpt_model_names)
723 723
             || (
724 724
                 ! $ignore_route_check
725
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
725
+                && ! isset($this->_cpt_routes[$this->_req_action])
726 726
             ) || (
727 727
                 $this->_cpt_model_obj instanceof EE_CPT_Base
728 728
                 && $this->_cpt_model_obj->ID() === $id
@@ -739,11 +739,11 @@  discard block
 block discarded – undo
739 739
                 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
740 740
             );
741 741
             $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
742
-            if (isset($model_names[ $post_type ])) {
743
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
742
+            if (isset($model_names[$post_type])) {
743
+                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
744 744
             }
745 745
         } else {
746
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
746
+            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
747 747
         }
748 748
         if ($model instanceof EEM_Base) {
749 749
             $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
         $current_route = isset($this->_req_data['current_route'])
774 774
             ? $this->_req_data['current_route']
775 775
             : 'shouldneverwork';
776
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
777
-            ? $this->_cpt_routes[ $current_route ]
776
+        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
777
+            ? $this->_cpt_routes[$current_route]
778 778
             : '';
779 779
         add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
780 780
         add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
         }
784 784
         // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
785 785
         $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
786
-        if (! empty($revision)) {
786
+        if ( ! empty($revision)) {
787 787
             $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
788 788
             // doing a restore?
789
-            if (! empty($action) && $action === 'restore') {
789
+            if ( ! empty($action) && $action === 'restore') {
790 790
                 // get post for revision
791 791
                 $rev_post = get_post($revision);
792 792
                 $rev_parent = get_post($rev_post->post_parent);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
     {
823 823
         $this->_set_model_object($post_id, true, 'trash');
824 824
         // if our cpt object isn't existent then get out immediately.
825
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
825
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826 826
             return;
827 827
         }
828 828
         $this->trash_cpt_item($post_id);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
     {
841 841
         $this->_set_model_object($post_id, true, 'restore');
842 842
         // if our cpt object isn't existent then get out immediately.
843
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
843
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
844 844
             return;
845 845
         }
846 846
         $this->restore_cpt_item($post_id);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     {
859 859
         $this->_set_model_object($post_id, true, 'delete');
860 860
         // if our cpt object isn't existent then get out immediately.
861
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
861
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862 862
             return;
863 863
         }
864 864
         $this->delete_cpt_item($post_id);
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
     {
878 878
         $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879 879
         // verify event object
880
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
880
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881 881
             throw new EE_Error(
882 882
                 sprintf(
883 883
                     __(
@@ -933,13 +933,13 @@  discard block
 block discarded – undo
933 933
         if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
934 934
             // setup custom post status object for localize script but only if we've got a cpt object
935 935
             $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
936
-            if (! empty($statuses)) {
936
+            if ( ! empty($statuses)) {
937 937
                 // get ALL statuses!
938 938
                 $statuses = $this->_cpt_model_obj->get_all_post_statuses();
939 939
                 // setup object
940 940
                 $ee_cpt_statuses = array();
941 941
                 foreach ($statuses as $status => $label) {
942
-                    $ee_cpt_statuses[ $status ] = array(
942
+                    $ee_cpt_statuses[$status] = array(
943 943
                         'label'      => $label,
944 944
                         'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
945 945
                     );
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
                 $post->page_template = $this->_req_data['page_template'];
1002 1002
                 $page_templates = wp_get_theme()->get_page_templates($post);
1003 1003
             }
1004
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1004
+            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
1005 1005
                 EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1006 1006
             } else {
1007 1007
                 update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
     {
1027 1027
         // only do this if we're actually processing one of our CPTs
1028 1028
         // if our cpt object isn't existent then get out immediately.
1029
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1029
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1030 1030
             return;
1031 1031
         }
1032 1032
         delete_post_meta($post_id, '_wp_trash_meta_status');
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
         // global action
1052 1052
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1053 1053
         // class specific action so you can limit hooking into a specific page.
1054
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1054
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
1055 1055
     }
1056 1056
 
1057 1057
 
@@ -1078,11 +1078,11 @@  discard block
 block discarded – undo
1078 1078
     public function modify_current_screen()
1079 1079
     {
1080 1080
         // ONLY do this if the current page_route IS a cpt route
1081
-        if (! $this->_cpt_route) {
1081
+        if ( ! $this->_cpt_route) {
1082 1082
             return;
1083 1083
         }
1084 1084
         // routing things REALLY early b/c this is a cpt admin page
1085
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1085
+        set_current_screen($this->_cpt_routes[$this->_req_action]);
1086 1086
         $this->_current_screen = get_current_screen();
1087 1087
         $this->_current_screen->base = 'event-espresso';
1088 1088
         $this->_add_help_tabs(); // we make sure we add any help tabs back in!
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
      */
1106 1106
     public function add_custom_editor_default_title($title)
1107 1107
     {
1108
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1109
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1108
+        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1109
+            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1110 1110
             : $title;
1111 1111
     }
1112 1112
 
@@ -1122,10 +1122,10 @@  discard block
 block discarded – undo
1122 1122
      */
1123 1123
     public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1124 1124
     {
1125
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1125
+        if ( ! empty($id) && get_option('permalink_structure') !== '') {
1126 1126
             $post = get_post($id);
1127 1127
             if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1128
-                $shortlink = home_url('?p=' . $post->ID);
1128
+                $shortlink = home_url('?p='.$post->ID);
1129 1129
             }
1130 1130
         }
1131 1131
         return $shortlink;
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
      */
1159 1159
     public function cpt_post_form_hidden_input()
1160 1160
     {
1161
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1161
+        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />';
1162 1162
         // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1163 1163
         echo '<div id="ee-cpt-hidden-inputs">';
1164
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1165
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1164
+        echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />';
1165
+        echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />';
1166 1166
         echo '</div>';
1167 1167
     }
1168 1168
 
@@ -1207,15 +1207,15 @@  discard block
 block discarded – undo
1207 1207
     public function modify_edit_post_link($link, $id, $context)
1208 1208
     {
1209 1209
         $post = get_post($id);
1210
-        if (! isset($this->_req_data['action'])
1211
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1212
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1210
+        if ( ! isset($this->_req_data['action'])
1211
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1212
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1213 1213
         ) {
1214 1214
             return $link;
1215 1215
         }
1216 1216
         $query_args = array(
1217
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1218
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1217
+            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1218
+                ? $this->_cpt_edit_routes[$post->post_type]
1219 1219
                 : 'edit',
1220 1220
             'post'   => $id,
1221 1221
         );
@@ -1238,16 +1238,16 @@  discard block
 block discarded – undo
1238 1238
         $post = get_post($post_id);
1239 1239
 
1240 1240
         if (empty($this->_req_data['action'])
1241
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1241
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1242 1242
             || ! $post instanceof WP_Post
1243
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1243
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1244 1244
         ) {
1245 1245
             return $delete_link;
1246 1246
         }
1247 1247
         $this->_set_model_object($post->ID, true);
1248 1248
 
1249 1249
         // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1250
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1250
+        $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1251 1251
 
1252 1252
         return EE_Admin_Page::add_query_args_and_nonce(
1253 1253
             array(
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
         // we DO have a match so let's setup the url
1276 1276
         // we have to get the post to determine our route
1277 1277
         $post = get_post($post_id);
1278
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1278
+        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1279 1279
         // shared query_args
1280 1280
         $query_args = array('action' => $edit_route, 'post' => $post_id);
1281 1281
         $admin_url = $this->_admin_base_url;
@@ -1347,12 +1347,12 @@  discard block
 block discarded – undo
1347 1347
         /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1348 1348
 
1349 1349
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1350
-        $messages[ $post->post_type ] = array(
1350
+        $messages[$post->post_type] = array(
1351 1351
             0  => '', // Unused. Messages start at index 1.
1352 1352
             1  => sprintf(
1353 1353
                 __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1354 1354
                 $this->_cpt_object->labels->singular_name,
1355
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1355
+                '<a href="'.esc_url(get_permalink($id)).'">',
1356 1356
                 '</a>'
1357 1357
             ),
1358 1358
             2  => __('Custom field updated', 'event_espresso'),
@@ -1367,27 +1367,27 @@  discard block
 block discarded – undo
1367 1367
             6  => sprintf(
1368 1368
                 __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1369 1369
                 $this->_cpt_object->labels->singular_name,
1370
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1370
+                '<a href="'.esc_url(get_permalink($id)).'">',
1371 1371
                 '</a>'
1372 1372
             ),
1373 1373
             7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1374 1374
             8  => sprintf(
1375 1375
                 __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1376 1376
                 $this->_cpt_object->labels->singular_name,
1377
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1377
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1378 1378
                 '</a>'
1379 1379
             ),
1380 1380
             9  => sprintf(
1381 1381
                 __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1382 1382
                 $this->_cpt_object->labels->singular_name,
1383
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1384
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1383
+                '<strong>'.date_i18n('M j, Y @ G:i', strtotime($post->post_date)).'</strong>',
1384
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1385 1385
                 '</a>'
1386 1386
             ),
1387 1387
             10 => sprintf(
1388 1388
                 __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1389 1389
                 $this->_cpt_object->labels->singular_name,
1390
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1390
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1391 1391
                 '</a>'
1392 1392
             ),
1393 1393
         );
@@ -1406,10 +1406,10 @@  discard block
 block discarded – undo
1406 1406
     {
1407 1407
         // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1408 1408
         global $post, $title, $is_IE, $post_type, $post_type_object;
1409
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1409
+        $post_type = $this->_cpt_routes[$this->_req_action];
1410 1410
         $post_type_object = $this->_cpt_object;
1411 1411
         $title = $post_type_object->labels->add_new_item;
1412
-        $post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1412
+        $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1413 1413
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1414 1414
         // modify the default editor title field with default title.
1415 1415
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
@@ -1434,8 +1434,8 @@  discard block
 block discarded – undo
1434 1434
             if ($creating) {
1435 1435
                 wp_enqueue_script('autosave');
1436 1436
             } else {
1437
-                if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1438
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1437
+                if (isset($this->_cpt_routes[$this->_req_data['action']])
1438
+                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1439 1439
                 ) {
1440 1440
                     $create_new_action = apply_filters(
1441 1441
                         'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
                     );
1452 1452
                 }
1453 1453
             }
1454
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1454
+            include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1455 1455
         }
1456 1456
     }
1457 1457
 
@@ -1482,21 +1482,21 @@  discard block
 block discarded – undo
1482 1482
         if (empty($post)) {
1483 1483
             wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1484 1484
         }
1485
-        if (! empty($_GET['get-post-lock'])) {
1485
+        if ( ! empty($_GET['get-post-lock'])) {
1486 1486
             wp_set_post_lock($post_id);
1487 1487
             wp_redirect(get_edit_post_link($post_id, 'url'));
1488 1488
             exit();
1489 1489
         }
1490 1490
 
1491 1491
         // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1492
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1492
+        $post_type = $this->_cpt_routes[$this->_req_action];
1493 1493
         $post_type_object = $this->_cpt_object;
1494 1494
 
1495
-        if (! wp_check_post_lock($post->ID)) {
1495
+        if ( ! wp_check_post_lock($post->ID)) {
1496 1496
             wp_set_post_lock($post->ID);
1497 1497
         }
1498 1498
         add_action('admin_footer', '_admin_notice_post_locked');
1499
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1499
+        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1500 1500
             wp_enqueue_script('admin-comments');
1501 1501
             enqueue_comment_hotkeys_js();
1502 1502
         }
Please login to merge, or discard this patch.
Indentation   +1503 added lines, -1503 removed lines patch added patch discarded remove patch
@@ -29,492 +29,492 @@  discard block
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    /**
33
-     * This gets set in _setup_cpt
34
-     * It will contain the object for the custom post type.
35
-     *
36
-     * @var EE_CPT_Base
37
-     */
38
-    protected $_cpt_object;
39
-
40
-
41
-    /**
42
-     * a boolean flag to set whether the current route is a cpt route or not.
43
-     *
44
-     * @var bool
45
-     */
46
-    protected $_cpt_route = false;
47
-
48
-
49
-    /**
50
-     * This property allows cpt classes to define multiple routes as cpt routes.
51
-     * //in this array we define what the custom post type for this route is.
52
-     * array(
53
-     * 'route_name' => 'custom_post_type_slug'
54
-     * )
55
-     *
56
-     * @var array
57
-     */
58
-    protected $_cpt_routes = array();
59
-
60
-
61
-    /**
62
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
63
-     * in this format:
64
-     * array(
65
-     * 'post_type_slug' => 'edit_route'
66
-     * )
67
-     *
68
-     * @var array
69
-     */
70
-    protected $_cpt_edit_routes = array();
71
-
72
-
73
-    /**
74
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
75
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
76
-     * _cpt_model_names property should be in the following format: array(
77
-     * 'route_defined_by_action_param' => 'Model_Name')
78
-     *
79
-     * @var array $_cpt_model_names
80
-     */
81
-    protected $_cpt_model_names = array();
82
-
83
-
84
-    /**
85
-     * @var EE_CPT_Base
86
-     */
87
-    protected $_cpt_model_obj = false;
88
-
89
-    /**
90
-     * @var LoaderInterface $loader ;
91
-     */
92
-    protected $loader;
93
-
94
-    /**
95
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
96
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
97
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
98
-     * Registration of containers should be done before load_page_dependencies() is run.
99
-     *
100
-     * @var array()
101
-     */
102
-    protected $_autosave_containers = array();
103
-    protected $_autosave_fields = array();
104
-
105
-    /**
106
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
107
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
108
-     *
109
-     * @var array
110
-     */
111
-    protected $_pagenow_map;
112
-
113
-
114
-    /**
115
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
116
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
117
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
118
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
119
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
120
-     *
121
-     * @access protected
122
-     * @abstract
123
-     * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
124
-     * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
125
-     * @return void
126
-     */
127
-    abstract protected function _insert_update_cpt_item($post_id, $post);
128
-
129
-
130
-    /**
131
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
132
-     *
133
-     * @abstract
134
-     * @access public
135
-     * @param  string $post_id The ID of the cpt that was trashed
136
-     * @return void
137
-     */
138
-    abstract public function trash_cpt_item($post_id);
139
-
140
-
141
-    /**
142
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
143
-     *
144
-     * @param  string $post_id theID of the cpt that was untrashed
145
-     * @return void
146
-     */
147
-    abstract public function restore_cpt_item($post_id);
148
-
149
-
150
-    /**
151
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
152
-     * from the db
153
-     *
154
-     * @param  string $post_id the ID of the cpt that was deleted
155
-     * @return void
156
-     */
157
-    abstract public function delete_cpt_item($post_id);
158
-
159
-
160
-    /**
161
-     * @return LoaderInterface
162
-     * @throws InvalidArgumentException
163
-     * @throws InvalidDataTypeException
164
-     * @throws InvalidInterfaceException
165
-     */
166
-    protected function getLoader()
167
-    {
168
-        if (! $this->loader instanceof LoaderInterface) {
169
-            $this->loader = LoaderFactory::getLoader();
170
-        }
171
-        return $this->loader;
172
-    }
173
-
174
-    /**
175
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
176
-     *
177
-     * @access protected
178
-     * @return void
179
-     */
180
-    protected function _before_page_setup()
181
-    {
182
-        $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
183
-        $this->_cpt_routes = array_merge(
184
-            array(
185
-                'create_new' => $this->page_slug,
186
-                'edit'       => $this->page_slug,
187
-                'trash'      => $this->page_slug,
188
-            ),
189
-            $this->_cpt_routes
190
-        );
191
-        // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
192
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
193
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
194
-            : get_post_type_object($page);
195
-        // tweak pagenow for page loading.
196
-        if (! $this->_pagenow_map) {
197
-            $this->_pagenow_map = array(
198
-                'create_new' => 'post-new.php',
199
-                'edit'       => 'post.php',
200
-                'trash'      => 'post.php',
201
-            );
202
-        }
203
-        add_action('current_screen', array($this, 'modify_pagenow'));
204
-        // TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
205
-        // get current page from autosave
206
-        $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
207
-            ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
208
-            : null;
209
-        $this->_current_page = isset($this->_req_data['current_page'])
210
-            ? $this->_req_data['current_page']
211
-            : $current_page;
212
-        // autosave... make sure its only for the correct page
213
-        // if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
214
-        // setup autosave ajax hook
215
-        // add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
216
-        // }
217
-    }
218
-
219
-
220
-    /**
221
-     * Simply ensure that we simulate the correct post route for cpt screens
222
-     *
223
-     * @param WP_Screen $current_screen
224
-     * @return void
225
-     */
226
-    public function modify_pagenow($current_screen)
227
-    {
228
-        global $pagenow, $hook_suffix;
229
-        // possibly reset pagenow.
230
-        if (! empty($this->_req_data['page'])
231
-            && $this->_req_data['page'] == $this->page_slug
232
-            && ! empty($this->_req_data['action'])
233
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
234
-        ) {
235
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
236
-            $hook_suffix = $pagenow;
237
-        }
238
-    }
239
-
240
-
241
-    /**
242
-     * This method is used to register additional autosave containers to the _autosave_containers property.
243
-     *
244
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
245
-     *       automatically register the id for the post metabox as a container.
246
-     * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
247
-     *                    you would send along the id of a metabox container.
248
-     * @return void
249
-     */
250
-    protected function _register_autosave_containers($ids)
251
-    {
252
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
253
-    }
254
-
255
-
256
-    /**
257
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
258
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
259
-     */
260
-    protected function _set_autosave_containers()
261
-    {
262
-        global $wp_meta_boxes;
263
-        $containers = array();
264
-        if (empty($wp_meta_boxes)) {
265
-            return;
266
-        }
267
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
268
-        foreach ($current_metaboxes as $box_context) {
269
-            foreach ($box_context as $box_details) {
270
-                foreach ($box_details as $box) {
271
-                    if (is_array($box['callback'])
272
-                        && (
273
-                            $box['callback'][0] instanceof EE_Admin_Page
274
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
275
-                        )
276
-                    ) {
277
-                        $containers[] = $box['id'];
278
-                    }
279
-                }
280
-            }
281
-        }
282
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
283
-        // add hidden inputs container
284
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
285
-    }
286
-
287
-
288
-    protected function _load_autosave_scripts_styles()
289
-    {
290
-        /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
32
+	/**
33
+	 * This gets set in _setup_cpt
34
+	 * It will contain the object for the custom post type.
35
+	 *
36
+	 * @var EE_CPT_Base
37
+	 */
38
+	protected $_cpt_object;
39
+
40
+
41
+	/**
42
+	 * a boolean flag to set whether the current route is a cpt route or not.
43
+	 *
44
+	 * @var bool
45
+	 */
46
+	protected $_cpt_route = false;
47
+
48
+
49
+	/**
50
+	 * This property allows cpt classes to define multiple routes as cpt routes.
51
+	 * //in this array we define what the custom post type for this route is.
52
+	 * array(
53
+	 * 'route_name' => 'custom_post_type_slug'
54
+	 * )
55
+	 *
56
+	 * @var array
57
+	 */
58
+	protected $_cpt_routes = array();
59
+
60
+
61
+	/**
62
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
63
+	 * in this format:
64
+	 * array(
65
+	 * 'post_type_slug' => 'edit_route'
66
+	 * )
67
+	 *
68
+	 * @var array
69
+	 */
70
+	protected $_cpt_edit_routes = array();
71
+
72
+
73
+	/**
74
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
75
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
76
+	 * _cpt_model_names property should be in the following format: array(
77
+	 * 'route_defined_by_action_param' => 'Model_Name')
78
+	 *
79
+	 * @var array $_cpt_model_names
80
+	 */
81
+	protected $_cpt_model_names = array();
82
+
83
+
84
+	/**
85
+	 * @var EE_CPT_Base
86
+	 */
87
+	protected $_cpt_model_obj = false;
88
+
89
+	/**
90
+	 * @var LoaderInterface $loader ;
91
+	 */
92
+	protected $loader;
93
+
94
+	/**
95
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
96
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
97
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
98
+	 * Registration of containers should be done before load_page_dependencies() is run.
99
+	 *
100
+	 * @var array()
101
+	 */
102
+	protected $_autosave_containers = array();
103
+	protected $_autosave_fields = array();
104
+
105
+	/**
106
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
107
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
108
+	 *
109
+	 * @var array
110
+	 */
111
+	protected $_pagenow_map;
112
+
113
+
114
+	/**
115
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
116
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
117
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
118
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
119
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
120
+	 *
121
+	 * @access protected
122
+	 * @abstract
123
+	 * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
124
+	 * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
125
+	 * @return void
126
+	 */
127
+	abstract protected function _insert_update_cpt_item($post_id, $post);
128
+
129
+
130
+	/**
131
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
132
+	 *
133
+	 * @abstract
134
+	 * @access public
135
+	 * @param  string $post_id The ID of the cpt that was trashed
136
+	 * @return void
137
+	 */
138
+	abstract public function trash_cpt_item($post_id);
139
+
140
+
141
+	/**
142
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
143
+	 *
144
+	 * @param  string $post_id theID of the cpt that was untrashed
145
+	 * @return void
146
+	 */
147
+	abstract public function restore_cpt_item($post_id);
148
+
149
+
150
+	/**
151
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
152
+	 * from the db
153
+	 *
154
+	 * @param  string $post_id the ID of the cpt that was deleted
155
+	 * @return void
156
+	 */
157
+	abstract public function delete_cpt_item($post_id);
158
+
159
+
160
+	/**
161
+	 * @return LoaderInterface
162
+	 * @throws InvalidArgumentException
163
+	 * @throws InvalidDataTypeException
164
+	 * @throws InvalidInterfaceException
165
+	 */
166
+	protected function getLoader()
167
+	{
168
+		if (! $this->loader instanceof LoaderInterface) {
169
+			$this->loader = LoaderFactory::getLoader();
170
+		}
171
+		return $this->loader;
172
+	}
173
+
174
+	/**
175
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
176
+	 *
177
+	 * @access protected
178
+	 * @return void
179
+	 */
180
+	protected function _before_page_setup()
181
+	{
182
+		$page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
183
+		$this->_cpt_routes = array_merge(
184
+			array(
185
+				'create_new' => $this->page_slug,
186
+				'edit'       => $this->page_slug,
187
+				'trash'      => $this->page_slug,
188
+			),
189
+			$this->_cpt_routes
190
+		);
191
+		// let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
192
+		$this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
193
+			? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
194
+			: get_post_type_object($page);
195
+		// tweak pagenow for page loading.
196
+		if (! $this->_pagenow_map) {
197
+			$this->_pagenow_map = array(
198
+				'create_new' => 'post-new.php',
199
+				'edit'       => 'post.php',
200
+				'trash'      => 'post.php',
201
+			);
202
+		}
203
+		add_action('current_screen', array($this, 'modify_pagenow'));
204
+		// TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
205
+		// get current page from autosave
206
+		$current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
207
+			? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
208
+			: null;
209
+		$this->_current_page = isset($this->_req_data['current_page'])
210
+			? $this->_req_data['current_page']
211
+			: $current_page;
212
+		// autosave... make sure its only for the correct page
213
+		// if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
214
+		// setup autosave ajax hook
215
+		// add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
216
+		// }
217
+	}
218
+
219
+
220
+	/**
221
+	 * Simply ensure that we simulate the correct post route for cpt screens
222
+	 *
223
+	 * @param WP_Screen $current_screen
224
+	 * @return void
225
+	 */
226
+	public function modify_pagenow($current_screen)
227
+	{
228
+		global $pagenow, $hook_suffix;
229
+		// possibly reset pagenow.
230
+		if (! empty($this->_req_data['page'])
231
+			&& $this->_req_data['page'] == $this->page_slug
232
+			&& ! empty($this->_req_data['action'])
233
+			&& isset($this->_pagenow_map[ $this->_req_data['action'] ])
234
+		) {
235
+			$pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
236
+			$hook_suffix = $pagenow;
237
+		}
238
+	}
239
+
240
+
241
+	/**
242
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
243
+	 *
244
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
245
+	 *       automatically register the id for the post metabox as a container.
246
+	 * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
247
+	 *                    you would send along the id of a metabox container.
248
+	 * @return void
249
+	 */
250
+	protected function _register_autosave_containers($ids)
251
+	{
252
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
253
+	}
254
+
255
+
256
+	/**
257
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
258
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
259
+	 */
260
+	protected function _set_autosave_containers()
261
+	{
262
+		global $wp_meta_boxes;
263
+		$containers = array();
264
+		if (empty($wp_meta_boxes)) {
265
+			return;
266
+		}
267
+		$current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
268
+		foreach ($current_metaboxes as $box_context) {
269
+			foreach ($box_context as $box_details) {
270
+				foreach ($box_details as $box) {
271
+					if (is_array($box['callback'])
272
+						&& (
273
+							$box['callback'][0] instanceof EE_Admin_Page
274
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
275
+						)
276
+					) {
277
+						$containers[] = $box['id'];
278
+					}
279
+				}
280
+			}
281
+		}
282
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
283
+		// add hidden inputs container
284
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
285
+	}
286
+
287
+
288
+	protected function _load_autosave_scripts_styles()
289
+	{
290
+		/*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
291 291
         wp_enqueue_script('cpt-autosave');/**/ // todo re-enable when we start doing autosave again in 4.2
292 292
 
293
-        // filter _autosave_containers
294
-        $containers = apply_filters(
295
-            'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
296
-            $this->_autosave_containers,
297
-            $this
298
-        );
299
-        $containers = apply_filters(
300
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
301
-            $containers,
302
-            $this
303
-        );
304
-
305
-        wp_localize_script(
306
-            'event_editor_js',
307
-            'EE_AUTOSAVE_IDS',
308
-            $containers
309
-        ); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
310
-
311
-        $unsaved_data_msg = array(
312
-            'eventmsg'     => sprintf(
313
-                __(
314
-                    "The changes you made to this %s will be lost if you navigate away from this page.",
315
-                    'event_espresso'
316
-                ),
317
-                $this->_cpt_object->labels->singular_name
318
-            ),
319
-            'inputChanged' => 0,
320
-        );
321
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
322
-    }
323
-
324
-
325
-    public function load_page_dependencies()
326
-    {
327
-        try {
328
-            $this->_load_page_dependencies();
329
-        } catch (EE_Error $e) {
330
-            $e->get_error();
331
-        }
332
-    }
333
-
334
-
335
-    /**
336
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
337
-     *
338
-     * @access protected
339
-     * @return void
340
-     */
341
-    protected function _load_page_dependencies()
342
-    {
343
-        // we only add stuff if this is a cpt_route!
344
-        if (! $this->_cpt_route) {
345
-            parent::_load_page_dependencies();
346
-            return;
347
-        }
348
-        // now let's do some automatic filters into the wp_system
349
-        // and we'll check to make sure the CHILD class
350
-        // automatically has the required methods in place.
351
-        // the following filters are for setting all the redirects
352
-        // on DEFAULT WP custom post type actions
353
-        // let's add a hidden input to the post-edit form
354
-        // so we know when we have to trigger our custom redirects!
355
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
356
-        add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
357
-        // inject our Admin page nav tabs...
358
-        // let's make sure the nav tabs are set if they aren't already
359
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
360
-        add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
361
-        // modify the post_updated messages array
362
-        add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
363
-        // add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
364
-        // cpts use the same format for shortlinks as posts!
365
-        add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
366
-        // This basically allows us to change the title of the "publish" metabox area
367
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
368
-        if (! empty($this->_labels['publishbox'])) {
369
-            $box_label = is_array($this->_labels['publishbox'])
370
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
371
-                ? $this->_labels['publishbox'][ $this->_req_action ]
372
-                : $this->_labels['publishbox'];
373
-            add_meta_box(
374
-                'submitdiv',
375
-                $box_label,
376
-                'post_submit_meta_box',
377
-                $this->_cpt_routes[ $this->_req_action ],
378
-                'side',
379
-                'core'
380
-            );
381
-        }
382
-        // let's add page_templates metabox if this cpt added support for it.
383
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
384
-            add_meta_box(
385
-                'page_templates',
386
-                __('Page Template', 'event_espresso'),
387
-                array($this, 'page_template_meta_box'),
388
-                $this->_cpt_routes[ $this->_req_action ],
389
-                'side',
390
-                'default'
391
-            );
392
-        }
393
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
394
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
395
-            add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
396
-        }
397
-        // add preview button
398
-        add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
399
-        // insert our own post_stati dropdown
400
-        add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
401
-        // This allows adding additional information to the publish post submitbox on the wp post edit form
402
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
403
-            add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
404
-        }
405
-        // This allows for adding additional stuff after the title field on the wp post edit form.
406
-        // This is also before the wp_editor for post description field.
407
-        if (method_exists($this, 'edit_form_after_title')) {
408
-            add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
409
-        }
410
-        /**
411
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
412
-         */
413
-        add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
414
-        parent::_load_page_dependencies();
415
-        // notice we are ALSO going to load the pagenow hook set for this route
416
-        // (see _before_page_setup for the reset of the pagenow global ).
417
-        // This is for any plugins that are doing things properly
418
-        // and hooking into the load page hook for core wp cpt routes.
419
-        global $pagenow;
420
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
421
-        do_action('load-' . $pagenow);
422
-        add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
423
-        // we route REALLY early.
424
-        try {
425
-            $this->_route_admin_request();
426
-        } catch (EE_Error $e) {
427
-            $e->get_error();
428
-        }
429
-    }
430
-
431
-
432
-    /**
433
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
434
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
435
-     * route instead.
436
-     *
437
-     * @param string $good_protocol_url The escaped url.
438
-     * @param string $original_url      The original url.
439
-     * @param string $_context          The context sent to the esc_url method.
440
-     * @return string possibly a new url for our route.
441
-     */
442
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
443
-    {
444
-        $routes_to_match = array(
445
-            0 => array(
446
-                'edit.php?post_type=espresso_attendees',
447
-                'admin.php?page=espresso_registrations&action=contact_list',
448
-            ),
449
-            1 => array(
450
-                'edit.php?post_type=' . $this->_cpt_object->name,
451
-                'admin.php?page=' . $this->_cpt_object->name,
452
-            ),
453
-        );
454
-        foreach ($routes_to_match as $route_matches) {
455
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
456
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
457
-            }
458
-        }
459
-        return $good_protocol_url;
460
-    }
461
-
462
-
463
-    /**
464
-     * Determine whether the current cpt supports page templates or not.
465
-     *
466
-     * @since %VER%
467
-     * @param string $cpt_name The cpt slug we're checking on.
468
-     * @return bool True supported, false not.
469
-     * @throws InvalidArgumentException
470
-     * @throws InvalidDataTypeException
471
-     * @throws InvalidInterfaceException
472
-     */
473
-    private function _supports_page_templates($cpt_name)
474
-    {
475
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
476
-        $custom_post_types = $this->getLoader()->getShared(
477
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
478
-        );
479
-        $cpt_args = $custom_post_types->getDefinitions();
480
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
481
-        $cpt_has_support = ! empty($cpt_args['page_templates']);
482
-
483
-        // if the installed version of WP is > 4.7 we do some additional checks.
484
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
485
-            $post_templates = wp_get_theme()->get_post_templates();
486
-            // if there are $post_templates for this cpt, then we return false for this method because
487
-            // that means we aren't going to load our page template manager and leave that up to the native
488
-            // cpt template manager.
489
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
490
-        }
491
-
492
-        return $cpt_has_support;
493
-    }
494
-
495
-
496
-    /**
497
-     * Callback for the page_templates metabox selector.
498
-     *
499
-     * @since %VER%
500
-     * @return void
501
-     */
502
-    public function page_template_meta_box()
503
-    {
504
-        global $post;
505
-        $template = '';
506
-
507
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
508
-            $page_template_count = count(get_page_templates());
509
-        } else {
510
-            $page_template_count = count(get_page_templates($post));
511
-        };
512
-
513
-        if ($page_template_count) {
514
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
515
-            $template = ! empty($page_template) ? $page_template : '';
516
-        }
517
-        ?>
293
+		// filter _autosave_containers
294
+		$containers = apply_filters(
295
+			'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
296
+			$this->_autosave_containers,
297
+			$this
298
+		);
299
+		$containers = apply_filters(
300
+			'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
301
+			$containers,
302
+			$this
303
+		);
304
+
305
+		wp_localize_script(
306
+			'event_editor_js',
307
+			'EE_AUTOSAVE_IDS',
308
+			$containers
309
+		); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
310
+
311
+		$unsaved_data_msg = array(
312
+			'eventmsg'     => sprintf(
313
+				__(
314
+					"The changes you made to this %s will be lost if you navigate away from this page.",
315
+					'event_espresso'
316
+				),
317
+				$this->_cpt_object->labels->singular_name
318
+			),
319
+			'inputChanged' => 0,
320
+		);
321
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
322
+	}
323
+
324
+
325
+	public function load_page_dependencies()
326
+	{
327
+		try {
328
+			$this->_load_page_dependencies();
329
+		} catch (EE_Error $e) {
330
+			$e->get_error();
331
+		}
332
+	}
333
+
334
+
335
+	/**
336
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
337
+	 *
338
+	 * @access protected
339
+	 * @return void
340
+	 */
341
+	protected function _load_page_dependencies()
342
+	{
343
+		// we only add stuff if this is a cpt_route!
344
+		if (! $this->_cpt_route) {
345
+			parent::_load_page_dependencies();
346
+			return;
347
+		}
348
+		// now let's do some automatic filters into the wp_system
349
+		// and we'll check to make sure the CHILD class
350
+		// automatically has the required methods in place.
351
+		// the following filters are for setting all the redirects
352
+		// on DEFAULT WP custom post type actions
353
+		// let's add a hidden input to the post-edit form
354
+		// so we know when we have to trigger our custom redirects!
355
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
356
+		add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
357
+		// inject our Admin page nav tabs...
358
+		// let's make sure the nav tabs are set if they aren't already
359
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
360
+		add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
361
+		// modify the post_updated messages array
362
+		add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
363
+		// add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
364
+		// cpts use the same format for shortlinks as posts!
365
+		add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
366
+		// This basically allows us to change the title of the "publish" metabox area
367
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
368
+		if (! empty($this->_labels['publishbox'])) {
369
+			$box_label = is_array($this->_labels['publishbox'])
370
+						 && isset($this->_labels['publishbox'][ $this->_req_action ])
371
+				? $this->_labels['publishbox'][ $this->_req_action ]
372
+				: $this->_labels['publishbox'];
373
+			add_meta_box(
374
+				'submitdiv',
375
+				$box_label,
376
+				'post_submit_meta_box',
377
+				$this->_cpt_routes[ $this->_req_action ],
378
+				'side',
379
+				'core'
380
+			);
381
+		}
382
+		// let's add page_templates metabox if this cpt added support for it.
383
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
384
+			add_meta_box(
385
+				'page_templates',
386
+				__('Page Template', 'event_espresso'),
387
+				array($this, 'page_template_meta_box'),
388
+				$this->_cpt_routes[ $this->_req_action ],
389
+				'side',
390
+				'default'
391
+			);
392
+		}
393
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
394
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
395
+			add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
396
+		}
397
+		// add preview button
398
+		add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
399
+		// insert our own post_stati dropdown
400
+		add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
401
+		// This allows adding additional information to the publish post submitbox on the wp post edit form
402
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
403
+			add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
404
+		}
405
+		// This allows for adding additional stuff after the title field on the wp post edit form.
406
+		// This is also before the wp_editor for post description field.
407
+		if (method_exists($this, 'edit_form_after_title')) {
408
+			add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
409
+		}
410
+		/**
411
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
412
+		 */
413
+		add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
414
+		parent::_load_page_dependencies();
415
+		// notice we are ALSO going to load the pagenow hook set for this route
416
+		// (see _before_page_setup for the reset of the pagenow global ).
417
+		// This is for any plugins that are doing things properly
418
+		// and hooking into the load page hook for core wp cpt routes.
419
+		global $pagenow;
420
+		add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
421
+		do_action('load-' . $pagenow);
422
+		add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
423
+		// we route REALLY early.
424
+		try {
425
+			$this->_route_admin_request();
426
+		} catch (EE_Error $e) {
427
+			$e->get_error();
428
+		}
429
+	}
430
+
431
+
432
+	/**
433
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
434
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
435
+	 * route instead.
436
+	 *
437
+	 * @param string $good_protocol_url The escaped url.
438
+	 * @param string $original_url      The original url.
439
+	 * @param string $_context          The context sent to the esc_url method.
440
+	 * @return string possibly a new url for our route.
441
+	 */
442
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
443
+	{
444
+		$routes_to_match = array(
445
+			0 => array(
446
+				'edit.php?post_type=espresso_attendees',
447
+				'admin.php?page=espresso_registrations&action=contact_list',
448
+			),
449
+			1 => array(
450
+				'edit.php?post_type=' . $this->_cpt_object->name,
451
+				'admin.php?page=' . $this->_cpt_object->name,
452
+			),
453
+		);
454
+		foreach ($routes_to_match as $route_matches) {
455
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
456
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
457
+			}
458
+		}
459
+		return $good_protocol_url;
460
+	}
461
+
462
+
463
+	/**
464
+	 * Determine whether the current cpt supports page templates or not.
465
+	 *
466
+	 * @since %VER%
467
+	 * @param string $cpt_name The cpt slug we're checking on.
468
+	 * @return bool True supported, false not.
469
+	 * @throws InvalidArgumentException
470
+	 * @throws InvalidDataTypeException
471
+	 * @throws InvalidInterfaceException
472
+	 */
473
+	private function _supports_page_templates($cpt_name)
474
+	{
475
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
476
+		$custom_post_types = $this->getLoader()->getShared(
477
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
478
+		);
479
+		$cpt_args = $custom_post_types->getDefinitions();
480
+		$cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
481
+		$cpt_has_support = ! empty($cpt_args['page_templates']);
482
+
483
+		// if the installed version of WP is > 4.7 we do some additional checks.
484
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
485
+			$post_templates = wp_get_theme()->get_post_templates();
486
+			// if there are $post_templates for this cpt, then we return false for this method because
487
+			// that means we aren't going to load our page template manager and leave that up to the native
488
+			// cpt template manager.
489
+			$cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
490
+		}
491
+
492
+		return $cpt_has_support;
493
+	}
494
+
495
+
496
+	/**
497
+	 * Callback for the page_templates metabox selector.
498
+	 *
499
+	 * @since %VER%
500
+	 * @return void
501
+	 */
502
+	public function page_template_meta_box()
503
+	{
504
+		global $post;
505
+		$template = '';
506
+
507
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
508
+			$page_template_count = count(get_page_templates());
509
+		} else {
510
+			$page_template_count = count(get_page_templates($post));
511
+		};
512
+
513
+		if ($page_template_count) {
514
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
515
+			$template = ! empty($page_template) ? $page_template : '';
516
+		}
517
+		?>
518 518
         <p><strong><?php _e('Template', 'event_espresso') ?></strong></p>
519 519
         <label class="screen-reader-text" for="page_template"><?php _e('Page Template', 'event_espresso') ?></label><select
520 520
         name="page_template" id="page_template">
@@ -522,507 +522,507 @@  discard block
 block discarded – undo
522 522
         <?php page_template_dropdown($template); ?>
523 523
     </select>
524 524
         <?php
525
-    }
526
-
527
-
528
-    /**
529
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
530
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
531
-     *
532
-     * @param  string $return    the current html
533
-     * @param  int    $id        the post id for the page
534
-     * @param  string $new_title What the title is
535
-     * @param  string $new_slug  what the slug is
536
-     * @return string            The new html string for the permalink area
537
-     */
538
-    public function preview_button_html($return, $id, $new_title, $new_slug)
539
-    {
540
-        $post = get_post($id);
541
-        if ('publish' !== get_post_status($post)) {
542
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
543
-                       . get_preview_post_link($id)
544
-                       . '" class="button button-small">'
545
-                       . __('Preview', 'event_espresso')
546
-                       . '</a></span>'
547
-                       . "\n";
548
-        }
549
-        return $return;
550
-    }
551
-
552
-
553
-    /**
554
-     * add our custom post stati dropdown on the wp post page for this cpt
555
-     *
556
-     * @return void
557
-     */
558
-    public function custom_post_stati_dropdown()
559
-    {
560
-
561
-        $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
562
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
563
-            ? $statuses[ $this->_cpt_model_obj->status() ]
564
-            : '';
565
-        $template_args = array(
566
-            'cur_status'            => $this->_cpt_model_obj->status(),
567
-            'statuses'              => $statuses,
568
-            'cur_status_label'      => $cur_status_label,
569
-            'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
570
-        );
571
-        // we'll add a trash post status (WP doesn't add one for some reason)
572
-        if ($this->_cpt_model_obj->status() === 'trash') {
573
-            $template_args['cur_status_label'] = __('Trashed', 'event_espresso');
574
-            $statuses['trash'] = __('Trashed', 'event_espresso');
575
-            $template_args['statuses'] = $statuses;
576
-        }
577
-
578
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
579
-        EEH_Template::display_template($template, $template_args);
580
-    }
581
-
582
-
583
-    public function setup_autosave_hooks()
584
-    {
585
-        $this->_set_autosave_containers();
586
-        $this->_load_autosave_scripts_styles();
587
-    }
588
-
589
-
590
-    /**
591
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
592
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
593
-     * for the nonce in here, but then this method looks for two things:
594
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
595
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
596
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
597
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
598
-     * template args.
599
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
600
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
601
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
602
-     *    $this->_template_args['data']['items'] = array(
603
-     *        'event-datetime-ids' => '1,2,3';
604
-     *    );
605
-     *    Keep in mind the following things:
606
-     *    - "where" index is for the input with the id as that string.
607
-     *    - "what" index is what will be used for the value of that input.
608
-     *
609
-     * @return void
610
-     */
611
-    public function do_extra_autosave_stuff()
612
-    {
613
-        // next let's check for the autosave nonce (we'll use _verify_nonce )
614
-        $nonce = isset($this->_req_data['autosavenonce'])
615
-            ? $this->_req_data['autosavenonce']
616
-            : null;
617
-        $this->_verify_nonce($nonce, 'autosave');
618
-        // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
619
-        if (! defined('DOING_AUTOSAVE')) {
620
-            define('DOING_AUTOSAVE', true);
621
-        }
622
-        // if we made it here then the nonce checked out.  Let's run our methods and actions
623
-        $autosave = "_ee_autosave_{$this->_current_view}";
624
-        if (method_exists($this, $autosave)) {
625
-            $this->$autosave();
626
-        } else {
627
-            $this->_template_args['success'] = true;
628
-        }
629
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
630
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
631
-        // now let's return json
632
-        $this->_return_json();
633
-    }
634
-
635
-
636
-    /**
637
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
638
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
639
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
640
-     *
641
-     * @access protected
642
-     * @throws EE_Error
643
-     * @return void
644
-     */
645
-    protected function _extend_page_config_for_cpt()
646
-    {
647
-        // before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
648
-        if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
649
-            return;
650
-        }
651
-        // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
652
-        if (! empty($this->_cpt_object)) {
653
-            $this->_page_routes = array_merge(
654
-                array(
655
-                    'create_new' => '_create_new_cpt_item',
656
-                    'edit'       => '_edit_cpt_item',
657
-                ),
658
-                $this->_page_routes
659
-            );
660
-            $this->_page_config = array_merge(
661
-                array(
662
-                    'create_new' => array(
663
-                        'nav'           => array(
664
-                            'label' => $this->_cpt_object->labels->add_new_item,
665
-                            'order' => 5,
666
-                        ),
667
-                        'require_nonce' => false,
668
-                    ),
669
-                    'edit'       => array(
670
-                        'nav'           => array(
671
-                            'label'      => $this->_cpt_object->labels->edit_item,
672
-                            'order'      => 5,
673
-                            'persistent' => false,
674
-                            'url'        => '',
675
-                        ),
676
-                        'require_nonce' => false,
677
-                    ),
678
-                ),
679
-                $this->_page_config
680
-            );
681
-        }
682
-        // load the next section only if this is a matching cpt route as set in the cpt routes array.
683
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
684
-            return;
685
-        }
686
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
687
-        // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
688
-        if (empty($this->_cpt_object)) {
689
-            $msg = sprintf(
690
-                __(
691
-                    'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
692
-                    'event_espresso'
693
-                ),
694
-                $this->page_slug,
695
-                $this->_req_action,
696
-                get_class($this)
697
-            );
698
-            throw new EE_Error($msg);
699
-        }
700
-        if ($this->_cpt_route) {
701
-            $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
702
-            $this->_set_model_object($id);
703
-        }
704
-    }
705
-
706
-
707
-    /**
708
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
709
-     *
710
-     * @access protected
711
-     * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
712
-     * @param bool   $ignore_route_check
713
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
714
-     * @throws EE_Error
715
-     * @throws InvalidArgumentException
716
-     * @throws InvalidDataTypeException
717
-     * @throws InvalidInterfaceException
718
-     * @throws ReflectionException
719
-     */
720
-    protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
721
-    {
722
-        $model = null;
723
-        if (empty($this->_cpt_model_names)
724
-            || (
725
-                ! $ignore_route_check
726
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
727
-            ) || (
728
-                $this->_cpt_model_obj instanceof EE_CPT_Base
729
-                && $this->_cpt_model_obj->ID() === $id
730
-            )
731
-        ) {
732
-            // get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
733
-            return;
734
-        }
735
-        // if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
736
-        if ($ignore_route_check) {
737
-            $post_type = get_post_type($id);
738
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
739
-            $custom_post_types = $this->getLoader()->getShared(
740
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
741
-            );
742
-            $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
743
-            if (isset($model_names[ $post_type ])) {
744
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
745
-            }
746
-        } else {
747
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
748
-        }
749
-        if ($model instanceof EEM_Base) {
750
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
751
-        }
752
-        do_action(
753
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
754
-            $this->_cpt_model_obj,
755
-            $req_type
756
-        );
757
-    }
758
-
759
-
760
-    /**
761
-     * admin_init_global
762
-     * This runs all the code that we want executed within the WP admin_init hook.
763
-     * This method executes for ALL EE Admin pages.
764
-     *
765
-     * @access public
766
-     * @return void
767
-     */
768
-    public function admin_init_global()
769
-    {
770
-        $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
771
-        // its possible this is a new save so let's catch that instead
772
-        $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
773
-        $post_type = $post ? $post->post_type : false;
774
-        $current_route = isset($this->_req_data['current_route'])
775
-            ? $this->_req_data['current_route']
776
-            : 'shouldneverwork';
777
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
778
-            ? $this->_cpt_routes[ $current_route ]
779
-            : '';
780
-        add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
781
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
782
-        if ($post_type === $route_to_check) {
783
-            add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
784
-        }
785
-        // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
786
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
787
-        if (! empty($revision)) {
788
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
789
-            // doing a restore?
790
-            if (! empty($action) && $action === 'restore') {
791
-                // get post for revision
792
-                $rev_post = get_post($revision);
793
-                $rev_parent = get_post($rev_post->post_parent);
794
-                // only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
795
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
796
-                    add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
797
-                    // restores of revisions
798
-                    add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
799
-                }
800
-            }
801
-        }
802
-        // NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
803
-        if ($post_type && $post_type === $route_to_check) {
804
-            // $post_id, $post
805
-            add_action('save_post', array($this, 'insert_update'), 10, 3);
806
-            // $post_id
807
-            add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
808
-            add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
809
-            add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
810
-            add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
811
-        }
812
-    }
813
-
814
-
815
-    /**
816
-     * Callback for the WordPress trashed_post hook.
817
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
818
-     *
819
-     * @param int $post_id
820
-     * @throws \EE_Error
821
-     */
822
-    public function before_trash_cpt_item($post_id)
823
-    {
824
-        $this->_set_model_object($post_id, true, 'trash');
825
-        // if our cpt object isn't existent then get out immediately.
826
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
827
-            return;
828
-        }
829
-        $this->trash_cpt_item($post_id);
830
-    }
831
-
832
-
833
-    /**
834
-     * Callback for the WordPress untrashed_post hook.
835
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
836
-     *
837
-     * @param $post_id
838
-     * @throws \EE_Error
839
-     */
840
-    public function before_restore_cpt_item($post_id)
841
-    {
842
-        $this->_set_model_object($post_id, true, 'restore');
843
-        // if our cpt object isn't existent then get out immediately.
844
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
845
-            return;
846
-        }
847
-        $this->restore_cpt_item($post_id);
848
-    }
849
-
850
-
851
-    /**
852
-     * Callback for the WordPress after_delete_post hook.
853
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
854
-     *
855
-     * @param $post_id
856
-     * @throws \EE_Error
857
-     */
858
-    public function before_delete_cpt_item($post_id)
859
-    {
860
-        $this->_set_model_object($post_id, true, 'delete');
861
-        // if our cpt object isn't existent then get out immediately.
862
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
863
-            return;
864
-        }
865
-        $this->delete_cpt_item($post_id);
866
-    }
867
-
868
-
869
-    /**
870
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
871
-     * accordingly.
872
-     *
873
-     * @return void
874
-     * @throws EE_Error
875
-     * @throws InvalidArgumentException
876
-     * @throws InvalidDataTypeException
877
-     * @throws InvalidInterfaceException
878
-     * @throws ReflectionException
879
-     */
880
-    public function verify_cpt_object()
881
-    {
882
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
883
-        // verify event object
884
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
885
-            throw new EE_Error(
886
-                sprintf(
887
-                    __(
888
-                        'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
889
-                        'event_espresso'
890
-                    ),
891
-                    $label
892
-                )
893
-            );
894
-        }
895
-        // if auto-draft then throw an error
896
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
897
-            EE_Error::overwrite_errors();
898
-            EE_Error::add_error(
899
-                sprintf(
900
-                    __(
901
-                        'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
902
-                        'event_espresso'
903
-                    ),
904
-                    $label
905
-                ),
906
-                __FILE__,
907
-                __FUNCTION__,
908
-                __LINE__
909
-            );
910
-        }
911
-        $this->loadEspressoEditorAssetManager();
912
-    }
913
-
914
-
915
-    /**
916
-     * admin_footer_scripts_global
917
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
918
-     * will apply on ALL EE_Admin pages.
919
-     *
920
-     * @access public
921
-     * @return void
922
-     */
923
-    public function admin_footer_scripts_global()
924
-    {
925
-        $this->_add_admin_page_ajax_loading_img();
926
-        $this->_add_admin_page_overlay();
927
-    }
928
-
929
-
930
-    /**
931
-     * add in any global scripts for cpt routes
932
-     *
933
-     * @return void
934
-     */
935
-    public function load_global_scripts_styles()
936
-    {
937
-        parent::load_global_scripts_styles();
938
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
939
-            // setup custom post status object for localize script but only if we've got a cpt object
940
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
941
-            if (! empty($statuses)) {
942
-                // get ALL statuses!
943
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
944
-                // setup object
945
-                $ee_cpt_statuses = array();
946
-                foreach ($statuses as $status => $label) {
947
-                    $ee_cpt_statuses[ $status ] = array(
948
-                        'label'      => $label,
949
-                        'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
950
-                    );
951
-                }
952
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
953
-            }
954
-        }
955
-    }
956
-
957
-
958
-    /**
959
-     * @throws InvalidArgumentException
960
-     * @throws InvalidDataTypeException
961
-     * @throws InvalidInterfaceException
962
-     */
963
-    private function loadEspressoEditorAssetManager()
964
-    {
965
-        EE_Dependency_Map::register_dependencies(
966
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
967
-            array(
968
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
969
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
970
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
971
-            )
972
-        );
973
-        LoaderFactory::getLoader()->getShared(
974
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
975
-        );
976
-        add_action('admin_enqueue_scripts', array($this, 'enqueueEspressoEditorAssets'), 100);
977
-    }
978
-
979
-
980
-    /**
981
-     * enqueue_scripts - Load the scripts and css
982
-     *
983
-     * @return void
984
-     * @throws DomainException
985
-     */
986
-    public function enqueueEspressoEditorAssets()
987
-    {
988
-        wp_enqueue_style(EspressoEditorAssetManager::CSS_HANDLE_EDITOR);
989
-        wp_enqueue_script(EspressoEditorAssetManager::JS_HANDLE_EDITOR);
990
-    }
991
-
992
-
993
-    /**
994
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
995
-     * insert/updates
996
-     *
997
-     * @param  int     $post_id ID of post being updated
998
-     * @param  WP_Post $post    Post object from WP
999
-     * @param  bool    $update  Whether this is an update or a new save.
1000
-     * @return void
1001
-     * @throws \EE_Error
1002
-     */
1003
-    public function insert_update($post_id, $post, $update)
1004
-    {
1005
-        // make sure that if this is a revision OR trash action that we don't do any updates!
1006
-        if (isset($this->_req_data['action'])
1007
-            && (
1008
-                $this->_req_data['action'] === 'restore'
1009
-                || $this->_req_data['action'] === 'trash'
1010
-            )
1011
-        ) {
1012
-            return;
1013
-        }
1014
-        $this->_set_model_object($post_id, true, 'insert_update');
1015
-        // if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
1016
-        if ($update
1017
-            && (
1018
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
1019
-                || $this->_cpt_model_obj->ID() !== $post_id
1020
-            )
1021
-        ) {
1022
-            return;
1023
-        }
1024
-        // check for autosave and update our req_data property accordingly.
1025
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
525
+	}
526
+
527
+
528
+	/**
529
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
530
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
531
+	 *
532
+	 * @param  string $return    the current html
533
+	 * @param  int    $id        the post id for the page
534
+	 * @param  string $new_title What the title is
535
+	 * @param  string $new_slug  what the slug is
536
+	 * @return string            The new html string for the permalink area
537
+	 */
538
+	public function preview_button_html($return, $id, $new_title, $new_slug)
539
+	{
540
+		$post = get_post($id);
541
+		if ('publish' !== get_post_status($post)) {
542
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
543
+					   . get_preview_post_link($id)
544
+					   . '" class="button button-small">'
545
+					   . __('Preview', 'event_espresso')
546
+					   . '</a></span>'
547
+					   . "\n";
548
+		}
549
+		return $return;
550
+	}
551
+
552
+
553
+	/**
554
+	 * add our custom post stati dropdown on the wp post page for this cpt
555
+	 *
556
+	 * @return void
557
+	 */
558
+	public function custom_post_stati_dropdown()
559
+	{
560
+
561
+		$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
562
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
563
+			? $statuses[ $this->_cpt_model_obj->status() ]
564
+			: '';
565
+		$template_args = array(
566
+			'cur_status'            => $this->_cpt_model_obj->status(),
567
+			'statuses'              => $statuses,
568
+			'cur_status_label'      => $cur_status_label,
569
+			'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
570
+		);
571
+		// we'll add a trash post status (WP doesn't add one for some reason)
572
+		if ($this->_cpt_model_obj->status() === 'trash') {
573
+			$template_args['cur_status_label'] = __('Trashed', 'event_espresso');
574
+			$statuses['trash'] = __('Trashed', 'event_espresso');
575
+			$template_args['statuses'] = $statuses;
576
+		}
577
+
578
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
579
+		EEH_Template::display_template($template, $template_args);
580
+	}
581
+
582
+
583
+	public function setup_autosave_hooks()
584
+	{
585
+		$this->_set_autosave_containers();
586
+		$this->_load_autosave_scripts_styles();
587
+	}
588
+
589
+
590
+	/**
591
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
592
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
593
+	 * for the nonce in here, but then this method looks for two things:
594
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
595
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
596
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
597
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
598
+	 * template args.
599
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
600
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
601
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
602
+	 *    $this->_template_args['data']['items'] = array(
603
+	 *        'event-datetime-ids' => '1,2,3';
604
+	 *    );
605
+	 *    Keep in mind the following things:
606
+	 *    - "where" index is for the input with the id as that string.
607
+	 *    - "what" index is what will be used for the value of that input.
608
+	 *
609
+	 * @return void
610
+	 */
611
+	public function do_extra_autosave_stuff()
612
+	{
613
+		// next let's check for the autosave nonce (we'll use _verify_nonce )
614
+		$nonce = isset($this->_req_data['autosavenonce'])
615
+			? $this->_req_data['autosavenonce']
616
+			: null;
617
+		$this->_verify_nonce($nonce, 'autosave');
618
+		// make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
619
+		if (! defined('DOING_AUTOSAVE')) {
620
+			define('DOING_AUTOSAVE', true);
621
+		}
622
+		// if we made it here then the nonce checked out.  Let's run our methods and actions
623
+		$autosave = "_ee_autosave_{$this->_current_view}";
624
+		if (method_exists($this, $autosave)) {
625
+			$this->$autosave();
626
+		} else {
627
+			$this->_template_args['success'] = true;
628
+		}
629
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
630
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
631
+		// now let's return json
632
+		$this->_return_json();
633
+	}
634
+
635
+
636
+	/**
637
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
638
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
639
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
640
+	 *
641
+	 * @access protected
642
+	 * @throws EE_Error
643
+	 * @return void
644
+	 */
645
+	protected function _extend_page_config_for_cpt()
646
+	{
647
+		// before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
648
+		if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
649
+			return;
650
+		}
651
+		// set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
652
+		if (! empty($this->_cpt_object)) {
653
+			$this->_page_routes = array_merge(
654
+				array(
655
+					'create_new' => '_create_new_cpt_item',
656
+					'edit'       => '_edit_cpt_item',
657
+				),
658
+				$this->_page_routes
659
+			);
660
+			$this->_page_config = array_merge(
661
+				array(
662
+					'create_new' => array(
663
+						'nav'           => array(
664
+							'label' => $this->_cpt_object->labels->add_new_item,
665
+							'order' => 5,
666
+						),
667
+						'require_nonce' => false,
668
+					),
669
+					'edit'       => array(
670
+						'nav'           => array(
671
+							'label'      => $this->_cpt_object->labels->edit_item,
672
+							'order'      => 5,
673
+							'persistent' => false,
674
+							'url'        => '',
675
+						),
676
+						'require_nonce' => false,
677
+					),
678
+				),
679
+				$this->_page_config
680
+			);
681
+		}
682
+		// load the next section only if this is a matching cpt route as set in the cpt routes array.
683
+		if (! isset($this->_cpt_routes[ $this->_req_action ])) {
684
+			return;
685
+		}
686
+		$this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
687
+		// add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
688
+		if (empty($this->_cpt_object)) {
689
+			$msg = sprintf(
690
+				__(
691
+					'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
692
+					'event_espresso'
693
+				),
694
+				$this->page_slug,
695
+				$this->_req_action,
696
+				get_class($this)
697
+			);
698
+			throw new EE_Error($msg);
699
+		}
700
+		if ($this->_cpt_route) {
701
+			$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
702
+			$this->_set_model_object($id);
703
+		}
704
+	}
705
+
706
+
707
+	/**
708
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
709
+	 *
710
+	 * @access protected
711
+	 * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
712
+	 * @param bool   $ignore_route_check
713
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
714
+	 * @throws EE_Error
715
+	 * @throws InvalidArgumentException
716
+	 * @throws InvalidDataTypeException
717
+	 * @throws InvalidInterfaceException
718
+	 * @throws ReflectionException
719
+	 */
720
+	protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
721
+	{
722
+		$model = null;
723
+		if (empty($this->_cpt_model_names)
724
+			|| (
725
+				! $ignore_route_check
726
+				&& ! isset($this->_cpt_routes[ $this->_req_action ])
727
+			) || (
728
+				$this->_cpt_model_obj instanceof EE_CPT_Base
729
+				&& $this->_cpt_model_obj->ID() === $id
730
+			)
731
+		) {
732
+			// get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
733
+			return;
734
+		}
735
+		// if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
736
+		if ($ignore_route_check) {
737
+			$post_type = get_post_type($id);
738
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
739
+			$custom_post_types = $this->getLoader()->getShared(
740
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
741
+			);
742
+			$model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
743
+			if (isset($model_names[ $post_type ])) {
744
+				$model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
745
+			}
746
+		} else {
747
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
748
+		}
749
+		if ($model instanceof EEM_Base) {
750
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
751
+		}
752
+		do_action(
753
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
754
+			$this->_cpt_model_obj,
755
+			$req_type
756
+		);
757
+	}
758
+
759
+
760
+	/**
761
+	 * admin_init_global
762
+	 * This runs all the code that we want executed within the WP admin_init hook.
763
+	 * This method executes for ALL EE Admin pages.
764
+	 *
765
+	 * @access public
766
+	 * @return void
767
+	 */
768
+	public function admin_init_global()
769
+	{
770
+		$post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
771
+		// its possible this is a new save so let's catch that instead
772
+		$post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
773
+		$post_type = $post ? $post->post_type : false;
774
+		$current_route = isset($this->_req_data['current_route'])
775
+			? $this->_req_data['current_route']
776
+			: 'shouldneverwork';
777
+		$route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
778
+			? $this->_cpt_routes[ $current_route ]
779
+			: '';
780
+		add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
781
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
782
+		if ($post_type === $route_to_check) {
783
+			add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
784
+		}
785
+		// now let's filter redirect if we're on a revision page and the revision is for an event CPT.
786
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
787
+		if (! empty($revision)) {
788
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
789
+			// doing a restore?
790
+			if (! empty($action) && $action === 'restore') {
791
+				// get post for revision
792
+				$rev_post = get_post($revision);
793
+				$rev_parent = get_post($rev_post->post_parent);
794
+				// only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
795
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
796
+					add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
797
+					// restores of revisions
798
+					add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
799
+				}
800
+			}
801
+		}
802
+		// NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
803
+		if ($post_type && $post_type === $route_to_check) {
804
+			// $post_id, $post
805
+			add_action('save_post', array($this, 'insert_update'), 10, 3);
806
+			// $post_id
807
+			add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
808
+			add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
809
+			add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
810
+			add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
811
+		}
812
+	}
813
+
814
+
815
+	/**
816
+	 * Callback for the WordPress trashed_post hook.
817
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
818
+	 *
819
+	 * @param int $post_id
820
+	 * @throws \EE_Error
821
+	 */
822
+	public function before_trash_cpt_item($post_id)
823
+	{
824
+		$this->_set_model_object($post_id, true, 'trash');
825
+		// if our cpt object isn't existent then get out immediately.
826
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
827
+			return;
828
+		}
829
+		$this->trash_cpt_item($post_id);
830
+	}
831
+
832
+
833
+	/**
834
+	 * Callback for the WordPress untrashed_post hook.
835
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
836
+	 *
837
+	 * @param $post_id
838
+	 * @throws \EE_Error
839
+	 */
840
+	public function before_restore_cpt_item($post_id)
841
+	{
842
+		$this->_set_model_object($post_id, true, 'restore');
843
+		// if our cpt object isn't existent then get out immediately.
844
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
845
+			return;
846
+		}
847
+		$this->restore_cpt_item($post_id);
848
+	}
849
+
850
+
851
+	/**
852
+	 * Callback for the WordPress after_delete_post hook.
853
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
854
+	 *
855
+	 * @param $post_id
856
+	 * @throws \EE_Error
857
+	 */
858
+	public function before_delete_cpt_item($post_id)
859
+	{
860
+		$this->_set_model_object($post_id, true, 'delete');
861
+		// if our cpt object isn't existent then get out immediately.
862
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
863
+			return;
864
+		}
865
+		$this->delete_cpt_item($post_id);
866
+	}
867
+
868
+
869
+	/**
870
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
871
+	 * accordingly.
872
+	 *
873
+	 * @return void
874
+	 * @throws EE_Error
875
+	 * @throws InvalidArgumentException
876
+	 * @throws InvalidDataTypeException
877
+	 * @throws InvalidInterfaceException
878
+	 * @throws ReflectionException
879
+	 */
880
+	public function verify_cpt_object()
881
+	{
882
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
883
+		// verify event object
884
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
885
+			throw new EE_Error(
886
+				sprintf(
887
+					__(
888
+						'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
889
+						'event_espresso'
890
+					),
891
+					$label
892
+				)
893
+			);
894
+		}
895
+		// if auto-draft then throw an error
896
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
897
+			EE_Error::overwrite_errors();
898
+			EE_Error::add_error(
899
+				sprintf(
900
+					__(
901
+						'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
902
+						'event_espresso'
903
+					),
904
+					$label
905
+				),
906
+				__FILE__,
907
+				__FUNCTION__,
908
+				__LINE__
909
+			);
910
+		}
911
+		$this->loadEspressoEditorAssetManager();
912
+	}
913
+
914
+
915
+	/**
916
+	 * admin_footer_scripts_global
917
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
918
+	 * will apply on ALL EE_Admin pages.
919
+	 *
920
+	 * @access public
921
+	 * @return void
922
+	 */
923
+	public function admin_footer_scripts_global()
924
+	{
925
+		$this->_add_admin_page_ajax_loading_img();
926
+		$this->_add_admin_page_overlay();
927
+	}
928
+
929
+
930
+	/**
931
+	 * add in any global scripts for cpt routes
932
+	 *
933
+	 * @return void
934
+	 */
935
+	public function load_global_scripts_styles()
936
+	{
937
+		parent::load_global_scripts_styles();
938
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
939
+			// setup custom post status object for localize script but only if we've got a cpt object
940
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
941
+			if (! empty($statuses)) {
942
+				// get ALL statuses!
943
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
944
+				// setup object
945
+				$ee_cpt_statuses = array();
946
+				foreach ($statuses as $status => $label) {
947
+					$ee_cpt_statuses[ $status ] = array(
948
+						'label'      => $label,
949
+						'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
950
+					);
951
+				}
952
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
953
+			}
954
+		}
955
+	}
956
+
957
+
958
+	/**
959
+	 * @throws InvalidArgumentException
960
+	 * @throws InvalidDataTypeException
961
+	 * @throws InvalidInterfaceException
962
+	 */
963
+	private function loadEspressoEditorAssetManager()
964
+	{
965
+		EE_Dependency_Map::register_dependencies(
966
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
967
+			array(
968
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
969
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
970
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
971
+			)
972
+		);
973
+		LoaderFactory::getLoader()->getShared(
974
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
975
+		);
976
+		add_action('admin_enqueue_scripts', array($this, 'enqueueEspressoEditorAssets'), 100);
977
+	}
978
+
979
+
980
+	/**
981
+	 * enqueue_scripts - Load the scripts and css
982
+	 *
983
+	 * @return void
984
+	 * @throws DomainException
985
+	 */
986
+	public function enqueueEspressoEditorAssets()
987
+	{
988
+		wp_enqueue_style(EspressoEditorAssetManager::CSS_HANDLE_EDITOR);
989
+		wp_enqueue_script(EspressoEditorAssetManager::JS_HANDLE_EDITOR);
990
+	}
991
+
992
+
993
+	/**
994
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
995
+	 * insert/updates
996
+	 *
997
+	 * @param  int     $post_id ID of post being updated
998
+	 * @param  WP_Post $post    Post object from WP
999
+	 * @param  bool    $update  Whether this is an update or a new save.
1000
+	 * @return void
1001
+	 * @throws \EE_Error
1002
+	 */
1003
+	public function insert_update($post_id, $post, $update)
1004
+	{
1005
+		// make sure that if this is a revision OR trash action that we don't do any updates!
1006
+		if (isset($this->_req_data['action'])
1007
+			&& (
1008
+				$this->_req_data['action'] === 'restore'
1009
+				|| $this->_req_data['action'] === 'trash'
1010
+			)
1011
+		) {
1012
+			return;
1013
+		}
1014
+		$this->_set_model_object($post_id, true, 'insert_update');
1015
+		// if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
1016
+		if ($update
1017
+			&& (
1018
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
1019
+				|| $this->_cpt_model_obj->ID() !== $post_id
1020
+			)
1021
+		) {
1022
+			return;
1023
+		}
1024
+		// check for autosave and update our req_data property accordingly.
1025
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
1026 1026
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
1027 1027
 
1028 1028
                 foreach ( (array) $values as $key => $value ) {
@@ -1032,532 +1032,532 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
         }/**/ // TODO reactivate after autosave is implemented in 4.2
1034 1034
 
1035
-        // take care of updating any selected page_template IF this cpt supports it.
1036
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1037
-            // wp version aware.
1038
-            if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1039
-                $page_templates = wp_get_theme()->get_page_templates();
1040
-            } else {
1041
-                $post->page_template = $this->_req_data['page_template'];
1042
-                $page_templates = wp_get_theme()->get_page_templates($post);
1043
-            }
1044
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1045
-                EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1046
-            } else {
1047
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1048
-            }
1049
-        }
1050
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1051
-            return;
1052
-        } //TODO we'll remove this after reimplementing autosave in 4.2
1053
-        $this->_insert_update_cpt_item($post_id, $post);
1054
-    }
1055
-
1056
-
1057
-    /**
1058
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1059
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1060
-     * so we don't have to check for our CPT.
1061
-     *
1062
-     * @param  int $post_id ID of the post
1063
-     * @return void
1064
-     */
1065
-    public function dont_permanently_delete_ee_cpts($post_id)
1066
-    {
1067
-        // only do this if we're actually processing one of our CPTs
1068
-        // if our cpt object isn't existent then get out immediately.
1069
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1070
-            return;
1071
-        }
1072
-        delete_post_meta($post_id, '_wp_trash_meta_status');
1073
-        delete_post_meta($post_id, '_wp_trash_meta_time');
1074
-        // our cpts may have comments so let's take care of that too
1075
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1076
-    }
1077
-
1078
-
1079
-    /**
1080
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1081
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1082
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1083
-     *
1084
-     * @param  int $post_id     ID of cpt item
1085
-     * @param  int $revision_id ID of revision being restored
1086
-     * @return void
1087
-     */
1088
-    public function restore_revision($post_id, $revision_id)
1089
-    {
1090
-        $this->_restore_cpt_item($post_id, $revision_id);
1091
-        // global action
1092
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1093
-        // class specific action so you can limit hooking into a specific page.
1094
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1095
-    }
1096
-
1097
-
1098
-    /**
1099
-     * @see restore_revision() for details
1100
-     * @param  int $post_id     ID of cpt item
1101
-     * @param  int $revision_id ID of revision for item
1102
-     * @return void
1103
-     */
1104
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
1105
-
1106
-
1107
-    /**
1108
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1109
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1110
-     * To fix we have to reset the current_screen using the page_slug
1111
-     * (which is identical - or should be - to our registered_post_type id.)
1112
-     * Also, since the core WP file loads the admin_header.php for WP
1113
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1114
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1115
-     *
1116
-     * @return void
1117
-     */
1118
-    public function modify_current_screen()
1119
-    {
1120
-        // ONLY do this if the current page_route IS a cpt route
1121
-        if (! $this->_cpt_route) {
1122
-            return;
1123
-        }
1124
-        // routing things REALLY early b/c this is a cpt admin page
1125
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1126
-        $this->_current_screen = get_current_screen();
1127
-        $this->_current_screen->base = 'event-espresso';
1128
-        $this->_add_help_tabs(); // we make sure we add any help tabs back in!
1129
-        /*try {
1035
+		// take care of updating any selected page_template IF this cpt supports it.
1036
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1037
+			// wp version aware.
1038
+			if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1039
+				$page_templates = wp_get_theme()->get_page_templates();
1040
+			} else {
1041
+				$post->page_template = $this->_req_data['page_template'];
1042
+				$page_templates = wp_get_theme()->get_page_templates($post);
1043
+			}
1044
+			if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1045
+				EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1046
+			} else {
1047
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1048
+			}
1049
+		}
1050
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1051
+			return;
1052
+		} //TODO we'll remove this after reimplementing autosave in 4.2
1053
+		$this->_insert_update_cpt_item($post_id, $post);
1054
+	}
1055
+
1056
+
1057
+	/**
1058
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1059
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1060
+	 * so we don't have to check for our CPT.
1061
+	 *
1062
+	 * @param  int $post_id ID of the post
1063
+	 * @return void
1064
+	 */
1065
+	public function dont_permanently_delete_ee_cpts($post_id)
1066
+	{
1067
+		// only do this if we're actually processing one of our CPTs
1068
+		// if our cpt object isn't existent then get out immediately.
1069
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1070
+			return;
1071
+		}
1072
+		delete_post_meta($post_id, '_wp_trash_meta_status');
1073
+		delete_post_meta($post_id, '_wp_trash_meta_time');
1074
+		// our cpts may have comments so let's take care of that too
1075
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1076
+	}
1077
+
1078
+
1079
+	/**
1080
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1081
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1082
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1083
+	 *
1084
+	 * @param  int $post_id     ID of cpt item
1085
+	 * @param  int $revision_id ID of revision being restored
1086
+	 * @return void
1087
+	 */
1088
+	public function restore_revision($post_id, $revision_id)
1089
+	{
1090
+		$this->_restore_cpt_item($post_id, $revision_id);
1091
+		// global action
1092
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1093
+		// class specific action so you can limit hooking into a specific page.
1094
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1095
+	}
1096
+
1097
+
1098
+	/**
1099
+	 * @see restore_revision() for details
1100
+	 * @param  int $post_id     ID of cpt item
1101
+	 * @param  int $revision_id ID of revision for item
1102
+	 * @return void
1103
+	 */
1104
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
1105
+
1106
+
1107
+	/**
1108
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1109
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1110
+	 * To fix we have to reset the current_screen using the page_slug
1111
+	 * (which is identical - or should be - to our registered_post_type id.)
1112
+	 * Also, since the core WP file loads the admin_header.php for WP
1113
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1114
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1115
+	 *
1116
+	 * @return void
1117
+	 */
1118
+	public function modify_current_screen()
1119
+	{
1120
+		// ONLY do this if the current page_route IS a cpt route
1121
+		if (! $this->_cpt_route) {
1122
+			return;
1123
+		}
1124
+		// routing things REALLY early b/c this is a cpt admin page
1125
+		set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1126
+		$this->_current_screen = get_current_screen();
1127
+		$this->_current_screen->base = 'event-espresso';
1128
+		$this->_add_help_tabs(); // we make sure we add any help tabs back in!
1129
+		/*try {
1130 1130
             $this->_route_admin_request();
1131 1131
         } catch ( EE_Error $e ) {
1132 1132
             $e->get_error();
1133 1133
         }/**/
1134
-    }
1135
-
1136
-
1137
-    /**
1138
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1139
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1140
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1141
-     * default to be.
1142
-     *
1143
-     * @param string $title The new title (or existing if there is no editor_title defined)
1144
-     * @return string
1145
-     */
1146
-    public function add_custom_editor_default_title($title)
1147
-    {
1148
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1149
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1150
-            : $title;
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1156
-     *
1157
-     * @param string $shortlink   The already generated shortlink
1158
-     * @param int    $id          Post ID for this item
1159
-     * @param string $context     The context for the link
1160
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1161
-     * @return string
1162
-     */
1163
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1164
-    {
1165
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1166
-            $post = get_post($id);
1167
-            if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1168
-                $shortlink = home_url('?p=' . $post->ID);
1169
-            }
1170
-        }
1171
-        return $shortlink;
1172
-    }
1173
-
1174
-
1175
-    /**
1176
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1177
-     * already run in modify_current_screen())
1178
-     *
1179
-     * @return void
1180
-     */
1181
-    public function route_admin_request()
1182
-    {
1183
-        if ($this->_cpt_route) {
1184
-            return;
1185
-        }
1186
-        try {
1187
-            $this->_route_admin_request();
1188
-        } catch (EE_Error $e) {
1189
-            $e->get_error();
1190
-        }
1191
-    }
1192
-
1193
-
1194
-    /**
1195
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1196
-     *
1197
-     * @return void
1198
-     */
1199
-    public function cpt_post_form_hidden_input()
1200
-    {
1201
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1202
-        // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1203
-        echo '<div id="ee-cpt-hidden-inputs">';
1204
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1205
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1206
-        echo '</div>';
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1212
-     *
1213
-     * @param  string $location Original location url
1214
-     * @param  int    $status   Status for http header
1215
-     * @return string           new (or original) url to redirect to.
1216
-     */
1217
-    public function revision_redirect($location, $status)
1218
-    {
1219
-        // get revision
1220
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1221
-        // can't do anything without revision so let's get out if not present
1222
-        if (empty($rev_id)) {
1223
-            return $location;
1224
-        }
1225
-        // get rev_post_data
1226
-        $rev = get_post($rev_id);
1227
-        $admin_url = $this->_admin_base_url;
1228
-        $query_args = array(
1229
-            'action'   => 'edit',
1230
-            'post'     => $rev->post_parent,
1231
-            'revision' => $rev_id,
1232
-            'message'  => 5,
1233
-        );
1234
-        $this->_process_notices($query_args, true);
1235
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1241
-     *
1242
-     * @param  string $link    the original generated link
1243
-     * @param  int    $id      post id
1244
-     * @param  string $context optional, defaults to display.  How to write the '&'
1245
-     * @return string          the link
1246
-     */
1247
-    public function modify_edit_post_link($link, $id, $context)
1248
-    {
1249
-        $post = get_post($id);
1250
-        if (! isset($this->_req_data['action'])
1251
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1252
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1253
-        ) {
1254
-            return $link;
1255
-        }
1256
-        $query_args = array(
1257
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1258
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1259
-                : 'edit',
1260
-            'post'   => $id,
1261
-        );
1262
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1263
-    }
1264
-
1265
-
1266
-    /**
1267
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1268
-     * our routes.
1269
-     *
1270
-     * @param  string $delete_link  original delete link
1271
-     * @param  int    $post_id      id of cpt object
1272
-     * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1273
-     * @return string new delete link
1274
-     * @throws EE_Error
1275
-     */
1276
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1277
-    {
1278
-        $post = get_post($post_id);
1279
-
1280
-        if (empty($this->_req_data['action'])
1281
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1282
-            || ! $post instanceof WP_Post
1283
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1284
-        ) {
1285
-            return $delete_link;
1286
-        }
1287
-        $this->_set_model_object($post->ID, true);
1288
-
1289
-        // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1290
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1291
-
1292
-        return EE_Admin_Page::add_query_args_and_nonce(
1293
-            array(
1294
-                'page'   => $this->_req_data['page'],
1295
-                'action' => $action,
1296
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1297
-                         => $post->ID,
1298
-            ),
1299
-            admin_url()
1300
-        );
1301
-    }
1302
-
1303
-
1304
-    /**
1305
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1306
-     * so that we can hijack the default redirect locations for wp custom post types
1307
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1308
-     *
1309
-     * @param  string $location This is the incoming currently set redirect location
1310
-     * @param  string $post_id  This is the 'ID' value of the wp_posts table
1311
-     * @return string           the new location to redirect to
1312
-     */
1313
-    public function cpt_post_location_redirect($location, $post_id)
1314
-    {
1315
-        // we DO have a match so let's setup the url
1316
-        // we have to get the post to determine our route
1317
-        $post = get_post($post_id);
1318
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1319
-        // shared query_args
1320
-        $query_args = array('action' => $edit_route, 'post' => $post_id);
1321
-        $admin_url = $this->_admin_base_url;
1322
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1323
-            $status = get_post_status($post_id);
1324
-            if (isset($this->_req_data['publish'])) {
1325
-                switch ($status) {
1326
-                    case 'pending':
1327
-                        $message = 8;
1328
-                        break;
1329
-                    case 'future':
1330
-                        $message = 9;
1331
-                        break;
1332
-                    default:
1333
-                        $message = 6;
1334
-                }
1335
-            } else {
1336
-                $message = 'draft' === $status ? 10 : 1;
1337
-            }
1338
-        } elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1339
-            $message = 2;
1340
-        } elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1341
-            $message = 3;
1342
-        } elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1343
-            $message = 7;
1344
-        } else {
1345
-            $message = 4;
1346
-        }
1347
-        // change the message if the post type is not viewable on the frontend
1348
-        $this->_cpt_object = get_post_type_object($post->post_type);
1349
-        $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1350
-        $query_args = array_merge(array('message' => $message), $query_args);
1351
-        $this->_process_notices($query_args, true);
1352
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1353
-    }
1354
-
1355
-
1356
-    /**
1357
-     * This method is called to inject nav tabs on core WP cpt pages
1358
-     *
1359
-     * @access public
1360
-     * @return void
1361
-     */
1362
-    public function inject_nav_tabs()
1363
-    {
1364
-        // can we hijack and insert the nav_tabs?
1365
-        $nav_tabs = $this->_get_main_nav_tabs();
1366
-        // first close off existing form tag
1367
-        $html = '>';
1368
-        $html .= $nav_tabs;
1369
-        // now let's handle the remaining tag ( missing ">" is CORRECT )
1370
-        $html .= '<span></span';
1371
-        echo $html;
1372
-    }
1373
-
1374
-
1375
-    /**
1376
-     * This just sets up the post update messages when an update form is loaded
1377
-     *
1378
-     * @access public
1379
-     * @param  array $messages the original messages array
1380
-     * @return array           the new messages array
1381
-     */
1382
-    public function post_update_messages($messages)
1383
-    {
1384
-        global $post;
1385
-        $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1386
-        $id = empty($id) && is_object($post) ? $post->ID : null;
1387
-        /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1134
+	}
1135
+
1136
+
1137
+	/**
1138
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1139
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1140
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1141
+	 * default to be.
1142
+	 *
1143
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1144
+	 * @return string
1145
+	 */
1146
+	public function add_custom_editor_default_title($title)
1147
+	{
1148
+		return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1149
+			? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1150
+			: $title;
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1156
+	 *
1157
+	 * @param string $shortlink   The already generated shortlink
1158
+	 * @param int    $id          Post ID for this item
1159
+	 * @param string $context     The context for the link
1160
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1161
+	 * @return string
1162
+	 */
1163
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1164
+	{
1165
+		if (! empty($id) && get_option('permalink_structure') !== '') {
1166
+			$post = get_post($id);
1167
+			if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1168
+				$shortlink = home_url('?p=' . $post->ID);
1169
+			}
1170
+		}
1171
+		return $shortlink;
1172
+	}
1173
+
1174
+
1175
+	/**
1176
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1177
+	 * already run in modify_current_screen())
1178
+	 *
1179
+	 * @return void
1180
+	 */
1181
+	public function route_admin_request()
1182
+	{
1183
+		if ($this->_cpt_route) {
1184
+			return;
1185
+		}
1186
+		try {
1187
+			$this->_route_admin_request();
1188
+		} catch (EE_Error $e) {
1189
+			$e->get_error();
1190
+		}
1191
+	}
1192
+
1193
+
1194
+	/**
1195
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1196
+	 *
1197
+	 * @return void
1198
+	 */
1199
+	public function cpt_post_form_hidden_input()
1200
+	{
1201
+		echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1202
+		// we're also going to add the route value and the current page so we can direct autosave parsing correctly
1203
+		echo '<div id="ee-cpt-hidden-inputs">';
1204
+		echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1205
+		echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1206
+		echo '</div>';
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1212
+	 *
1213
+	 * @param  string $location Original location url
1214
+	 * @param  int    $status   Status for http header
1215
+	 * @return string           new (or original) url to redirect to.
1216
+	 */
1217
+	public function revision_redirect($location, $status)
1218
+	{
1219
+		// get revision
1220
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1221
+		// can't do anything without revision so let's get out if not present
1222
+		if (empty($rev_id)) {
1223
+			return $location;
1224
+		}
1225
+		// get rev_post_data
1226
+		$rev = get_post($rev_id);
1227
+		$admin_url = $this->_admin_base_url;
1228
+		$query_args = array(
1229
+			'action'   => 'edit',
1230
+			'post'     => $rev->post_parent,
1231
+			'revision' => $rev_id,
1232
+			'message'  => 5,
1233
+		);
1234
+		$this->_process_notices($query_args, true);
1235
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1241
+	 *
1242
+	 * @param  string $link    the original generated link
1243
+	 * @param  int    $id      post id
1244
+	 * @param  string $context optional, defaults to display.  How to write the '&'
1245
+	 * @return string          the link
1246
+	 */
1247
+	public function modify_edit_post_link($link, $id, $context)
1248
+	{
1249
+		$post = get_post($id);
1250
+		if (! isset($this->_req_data['action'])
1251
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1252
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1253
+		) {
1254
+			return $link;
1255
+		}
1256
+		$query_args = array(
1257
+			'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1258
+				? $this->_cpt_edit_routes[ $post->post_type ]
1259
+				: 'edit',
1260
+			'post'   => $id,
1261
+		);
1262
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1263
+	}
1264
+
1265
+
1266
+	/**
1267
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1268
+	 * our routes.
1269
+	 *
1270
+	 * @param  string $delete_link  original delete link
1271
+	 * @param  int    $post_id      id of cpt object
1272
+	 * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1273
+	 * @return string new delete link
1274
+	 * @throws EE_Error
1275
+	 */
1276
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1277
+	{
1278
+		$post = get_post($post_id);
1279
+
1280
+		if (empty($this->_req_data['action'])
1281
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1282
+			|| ! $post instanceof WP_Post
1283
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1284
+		) {
1285
+			return $delete_link;
1286
+		}
1287
+		$this->_set_model_object($post->ID, true);
1288
+
1289
+		// returns something like `trash_event` or `trash_attendee` or `trash_venue`
1290
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1291
+
1292
+		return EE_Admin_Page::add_query_args_and_nonce(
1293
+			array(
1294
+				'page'   => $this->_req_data['page'],
1295
+				'action' => $action,
1296
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1297
+						 => $post->ID,
1298
+			),
1299
+			admin_url()
1300
+		);
1301
+	}
1302
+
1303
+
1304
+	/**
1305
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1306
+	 * so that we can hijack the default redirect locations for wp custom post types
1307
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1308
+	 *
1309
+	 * @param  string $location This is the incoming currently set redirect location
1310
+	 * @param  string $post_id  This is the 'ID' value of the wp_posts table
1311
+	 * @return string           the new location to redirect to
1312
+	 */
1313
+	public function cpt_post_location_redirect($location, $post_id)
1314
+	{
1315
+		// we DO have a match so let's setup the url
1316
+		// we have to get the post to determine our route
1317
+		$post = get_post($post_id);
1318
+		$edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1319
+		// shared query_args
1320
+		$query_args = array('action' => $edit_route, 'post' => $post_id);
1321
+		$admin_url = $this->_admin_base_url;
1322
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1323
+			$status = get_post_status($post_id);
1324
+			if (isset($this->_req_data['publish'])) {
1325
+				switch ($status) {
1326
+					case 'pending':
1327
+						$message = 8;
1328
+						break;
1329
+					case 'future':
1330
+						$message = 9;
1331
+						break;
1332
+					default:
1333
+						$message = 6;
1334
+				}
1335
+			} else {
1336
+				$message = 'draft' === $status ? 10 : 1;
1337
+			}
1338
+		} elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1339
+			$message = 2;
1340
+		} elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1341
+			$message = 3;
1342
+		} elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1343
+			$message = 7;
1344
+		} else {
1345
+			$message = 4;
1346
+		}
1347
+		// change the message if the post type is not viewable on the frontend
1348
+		$this->_cpt_object = get_post_type_object($post->post_type);
1349
+		$message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1350
+		$query_args = array_merge(array('message' => $message), $query_args);
1351
+		$this->_process_notices($query_args, true);
1352
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1353
+	}
1354
+
1355
+
1356
+	/**
1357
+	 * This method is called to inject nav tabs on core WP cpt pages
1358
+	 *
1359
+	 * @access public
1360
+	 * @return void
1361
+	 */
1362
+	public function inject_nav_tabs()
1363
+	{
1364
+		// can we hijack and insert the nav_tabs?
1365
+		$nav_tabs = $this->_get_main_nav_tabs();
1366
+		// first close off existing form tag
1367
+		$html = '>';
1368
+		$html .= $nav_tabs;
1369
+		// now let's handle the remaining tag ( missing ">" is CORRECT )
1370
+		$html .= '<span></span';
1371
+		echo $html;
1372
+	}
1373
+
1374
+
1375
+	/**
1376
+	 * This just sets up the post update messages when an update form is loaded
1377
+	 *
1378
+	 * @access public
1379
+	 * @param  array $messages the original messages array
1380
+	 * @return array           the new messages array
1381
+	 */
1382
+	public function post_update_messages($messages)
1383
+	{
1384
+		global $post;
1385
+		$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1386
+		$id = empty($id) && is_object($post) ? $post->ID : null;
1387
+		/*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1388 1388
 
1389 1389
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1390
-        $messages[ $post->post_type ] = array(
1391
-            0  => '', // Unused. Messages start at index 1.
1392
-            1  => sprintf(
1393
-                __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1394
-                $this->_cpt_object->labels->singular_name,
1395
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1396
-                '</a>'
1397
-            ),
1398
-            2  => __('Custom field updated', 'event_espresso'),
1399
-            3  => __('Custom field deleted.', 'event_espresso'),
1400
-            4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1401
-            5  => isset($_GET['revision']) ? sprintf(
1402
-                __('%s restored to revision from %s', 'event_espresso'),
1403
-                $this->_cpt_object->labels->singular_name,
1404
-                wp_post_revision_title((int) $_GET['revision'], false)
1405
-            )
1406
-                : false,
1407
-            6  => sprintf(
1408
-                __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1409
-                $this->_cpt_object->labels->singular_name,
1410
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1411
-                '</a>'
1412
-            ),
1413
-            7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1414
-            8  => sprintf(
1415
-                __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1416
-                $this->_cpt_object->labels->singular_name,
1417
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1418
-                '</a>'
1419
-            ),
1420
-            9  => sprintf(
1421
-                __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1422
-                $this->_cpt_object->labels->singular_name,
1423
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1424
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1425
-                '</a>'
1426
-            ),
1427
-            10 => sprintf(
1428
-                __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1429
-                $this->_cpt_object->labels->singular_name,
1430
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1431
-                '</a>'
1432
-            ),
1433
-        );
1434
-        return $messages;
1435
-    }
1436
-
1437
-
1438
-    /**
1439
-     * default method for the 'create_new' route for cpt admin pages.
1440
-     * For reference what to include in here, see wp-admin/post-new.php
1441
-     *
1442
-     * @access  protected
1443
-     * @return void
1444
-     */
1445
-    protected function _create_new_cpt_item()
1446
-    {
1447
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1448
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1449
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1450
-        $post_type_object = $this->_cpt_object;
1451
-        $title = $post_type_object->labels->add_new_item;
1452
-        $post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1453
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1454
-        // modify the default editor title field with default title.
1455
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1456
-        $this->loadEditorTemplate(true);
1457
-    }
1458
-
1459
-
1460
-    /**
1461
-     * Enqueues auto-save and loads the editor template
1462
-     *
1463
-     * @param bool $creating
1464
-     */
1465
-    private function loadEditorTemplate($creating = true)
1466
-    {
1467
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1468
-        // these vars are used by the template
1469
-        $editing = true;
1470
-        $post_ID = $post->ID;
1471
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1472
-            // only enqueue autosave when creating event (necessary to get permalink/url generated)
1473
-            // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1474
-            if ($creating) {
1475
-                wp_enqueue_script('autosave');
1476
-            } else {
1477
-                if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1478
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1479
-                ) {
1480
-                    $create_new_action = apply_filters(
1481
-                        'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1482
-                        'create_new',
1483
-                        $this
1484
-                    );
1485
-                    $post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1486
-                        array(
1487
-                            'action' => $create_new_action,
1488
-                            'page'   => $this->page_slug,
1489
-                        ),
1490
-                        'admin.php'
1491
-                    );
1492
-                }
1493
-            }
1494
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1495
-        }
1496
-    }
1497
-
1498
-
1499
-    public function add_new_admin_page_global()
1500
-    {
1501
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1502
-        ?>
1390
+		$messages[ $post->post_type ] = array(
1391
+			0  => '', // Unused. Messages start at index 1.
1392
+			1  => sprintf(
1393
+				__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1394
+				$this->_cpt_object->labels->singular_name,
1395
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1396
+				'</a>'
1397
+			),
1398
+			2  => __('Custom field updated', 'event_espresso'),
1399
+			3  => __('Custom field deleted.', 'event_espresso'),
1400
+			4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1401
+			5  => isset($_GET['revision']) ? sprintf(
1402
+				__('%s restored to revision from %s', 'event_espresso'),
1403
+				$this->_cpt_object->labels->singular_name,
1404
+				wp_post_revision_title((int) $_GET['revision'], false)
1405
+			)
1406
+				: false,
1407
+			6  => sprintf(
1408
+				__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1409
+				$this->_cpt_object->labels->singular_name,
1410
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1411
+				'</a>'
1412
+			),
1413
+			7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1414
+			8  => sprintf(
1415
+				__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1416
+				$this->_cpt_object->labels->singular_name,
1417
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1418
+				'</a>'
1419
+			),
1420
+			9  => sprintf(
1421
+				__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1422
+				$this->_cpt_object->labels->singular_name,
1423
+				'<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1424
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1425
+				'</a>'
1426
+			),
1427
+			10 => sprintf(
1428
+				__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1429
+				$this->_cpt_object->labels->singular_name,
1430
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1431
+				'</a>'
1432
+			),
1433
+		);
1434
+		return $messages;
1435
+	}
1436
+
1437
+
1438
+	/**
1439
+	 * default method for the 'create_new' route for cpt admin pages.
1440
+	 * For reference what to include in here, see wp-admin/post-new.php
1441
+	 *
1442
+	 * @access  protected
1443
+	 * @return void
1444
+	 */
1445
+	protected function _create_new_cpt_item()
1446
+	{
1447
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1448
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1449
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1450
+		$post_type_object = $this->_cpt_object;
1451
+		$title = $post_type_object->labels->add_new_item;
1452
+		$post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1453
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1454
+		// modify the default editor title field with default title.
1455
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1456
+		$this->loadEditorTemplate(true);
1457
+	}
1458
+
1459
+
1460
+	/**
1461
+	 * Enqueues auto-save and loads the editor template
1462
+	 *
1463
+	 * @param bool $creating
1464
+	 */
1465
+	private function loadEditorTemplate($creating = true)
1466
+	{
1467
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1468
+		// these vars are used by the template
1469
+		$editing = true;
1470
+		$post_ID = $post->ID;
1471
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1472
+			// only enqueue autosave when creating event (necessary to get permalink/url generated)
1473
+			// otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1474
+			if ($creating) {
1475
+				wp_enqueue_script('autosave');
1476
+			} else {
1477
+				if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1478
+					&& ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1479
+				) {
1480
+					$create_new_action = apply_filters(
1481
+						'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1482
+						'create_new',
1483
+						$this
1484
+					);
1485
+					$post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1486
+						array(
1487
+							'action' => $create_new_action,
1488
+							'page'   => $this->page_slug,
1489
+						),
1490
+						'admin.php'
1491
+					);
1492
+				}
1493
+			}
1494
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1495
+		}
1496
+	}
1497
+
1498
+
1499
+	public function add_new_admin_page_global()
1500
+	{
1501
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1502
+		?>
1503 1503
         <script type="text/javascript">
1504 1504
             adminpage = '<?php echo $admin_page; ?>';
1505 1505
         </script>
1506 1506
         <?php
1507
-    }
1508
-
1509
-
1510
-    /**
1511
-     * default method for the 'edit' route for cpt admin pages
1512
-     * For reference on what to put in here, refer to wp-admin/post.php
1513
-     *
1514
-     * @access protected
1515
-     * @return string   template for edit cpt form
1516
-     */
1517
-    protected function _edit_cpt_item()
1518
-    {
1519
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1520
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1521
-        $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1522
-        if (empty($post)) {
1523
-            wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1524
-        }
1525
-        if (! empty($_GET['get-post-lock'])) {
1526
-            wp_set_post_lock($post_id);
1527
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1528
-            exit();
1529
-        }
1530
-
1531
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1532
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1533
-        $post_type_object = $this->_cpt_object;
1534
-
1535
-        if (! wp_check_post_lock($post->ID)) {
1536
-            wp_set_post_lock($post->ID);
1537
-        }
1538
-        add_action('admin_footer', '_admin_notice_post_locked');
1539
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1540
-            wp_enqueue_script('admin-comments');
1541
-            enqueue_comment_hotkeys_js();
1542
-        }
1543
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1544
-        // modify the default editor title field with default title.
1545
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1546
-        $this->loadEditorTemplate(false);
1547
-    }
1548
-
1549
-
1550
-
1551
-    /**
1552
-     * some getters
1553
-     */
1554
-    /**
1555
-     * This returns the protected _cpt_model_obj property
1556
-     *
1557
-     * @return EE_CPT_Base
1558
-     */
1559
-    public function get_cpt_model_obj()
1560
-    {
1561
-        return $this->_cpt_model_obj;
1562
-    }
1507
+	}
1508
+
1509
+
1510
+	/**
1511
+	 * default method for the 'edit' route for cpt admin pages
1512
+	 * For reference on what to put in here, refer to wp-admin/post.php
1513
+	 *
1514
+	 * @access protected
1515
+	 * @return string   template for edit cpt form
1516
+	 */
1517
+	protected function _edit_cpt_item()
1518
+	{
1519
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1520
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1521
+		$post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1522
+		if (empty($post)) {
1523
+			wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1524
+		}
1525
+		if (! empty($_GET['get-post-lock'])) {
1526
+			wp_set_post_lock($post_id);
1527
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1528
+			exit();
1529
+		}
1530
+
1531
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1532
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1533
+		$post_type_object = $this->_cpt_object;
1534
+
1535
+		if (! wp_check_post_lock($post->ID)) {
1536
+			wp_set_post_lock($post->ID);
1537
+		}
1538
+		add_action('admin_footer', '_admin_notice_post_locked');
1539
+		if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1540
+			wp_enqueue_script('admin-comments');
1541
+			enqueue_comment_hotkeys_js();
1542
+		}
1543
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1544
+		// modify the default editor title field with default title.
1545
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1546
+		$this->loadEditorTemplate(false);
1547
+	}
1548
+
1549
+
1550
+
1551
+	/**
1552
+	 * some getters
1553
+	 */
1554
+	/**
1555
+	 * This returns the protected _cpt_model_obj property
1556
+	 *
1557
+	 * @return EE_CPT_Base
1558
+	 */
1559
+	public function get_cpt_model_obj()
1560
+	{
1561
+		return $this->_cpt_model_obj;
1562
+	}
1563 1563
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/DateFilterHeader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
                 $text .= '<span class="drk-grey-text">';
71 71
                 $text .= '<span class="dashicons dashicons-calendar"></span>';
72 72
                 $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
73
+                $text .= ' ( '.$datetime->start_date().' )';
74 74
                 $text .= '</span></h3>';
75 75
             }
76 76
         }
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@
 block discarded – undo
23 23
 class DateFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Datetime $datetime_model
28
-     */
29
-    private $datetime_model;
26
+	/**
27
+	 * @var EEM_Datetime $datetime_model
28
+	 */
29
+	private $datetime_model;
30 30
 
31 31
 
32
-    /**
33
-     * DateFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Datetime     $datetime_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->datetime_model = $datetime_model;
42
-    }
32
+	/**
33
+	 * DateFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Datetime     $datetime_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->datetime_model = $datetime_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since $VID:$
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $DTT_ID = $this->request->getRequestParam('DTT_ID');
58
-        $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID);
59
-        $DTT_ID = absint($DTT_ID);
60
-        if ($DTT_ID) {
61
-            $datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
62
-            if ($datetime instanceof EE_Datetime && $text !== '') {
63
-                // remove the closing h3 heading tag if it exists
64
-                $text = str_replace(
65
-                    '</h3>',
66
-                    '',
67
-                    $text
68
-                );
69
-                $text .= '&nbsp; &nbsp; ';
70
-                $text .= '<span class="drk-grey-text">';
71
-                $text .= '<span class="dashicons dashicons-calendar"></span>';
72
-                $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
74
-                $text .= '</span></h3>';
75
-            }
76
-        }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since $VID:$
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$DTT_ID = $this->request->getRequestParam('DTT_ID');
58
+		$DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID);
59
+		$DTT_ID = absint($DTT_ID);
60
+		if ($DTT_ID) {
61
+			$datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
62
+			if ($datetime instanceof EE_Datetime && $text !== '') {
63
+				// remove the closing h3 heading tag if it exists
64
+				$text = str_replace(
65
+					'</h3>',
66
+					'',
67
+					$text
68
+				);
69
+				$text .= '&nbsp; &nbsp; ';
70
+				$text .= '<span class="drk-grey-text">';
71
+				$text .= '<span class="dashicons dashicons-calendar"></span>';
72
+				$text .= $datetime->name();
73
+				$text .= ' ( ' . $datetime->start_date() . ' )';
74
+				$text .= '</span></h3>';
75
+			}
76
+		}
77 77
 
78
-        return $text;
79
-    }
78
+		return $text;
79
+	}
80 80
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/TicketFilterHeader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
         if ($TKT_ID) {
61 61
             $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62 62
             if ($ticket instanceof EE_Ticket) {
63
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
63
+                $ticket_details = '<span class="ee-ticket-name">'.$ticket->name().'</span> ';
64 64
                 $ticket_details .= ! $ticket->is_free()
65
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
65
+                    ? '<span class="ee-ticket-price">'.$ticket->pretty_price().'</span>'
66 66
                     : '<span class="reg-overview-free-event-spn">'
67 67
                       . __('free', 'event_espresso')
68 68
                       . '</span>';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 $text .= '&nbsp; &nbsp; ';
81 81
                 $text .= '<span class="drk-grey-text" style="font-size:.9em;">';
82 82
                 $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
83
-                $text .= $ticket_details . '</span></h3>';
83
+                $text .= $ticket_details.'</span></h3>';
84 84
             }
85 85
         }
86 86
         return $text;
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -23,65 +23,65 @@
 block discarded – undo
23 23
 class TicketFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Ticket $ticket_model
28
-     */
29
-    private $ticket_model;
26
+	/**
27
+	 * @var EEM_Ticket $ticket_model
28
+	 */
29
+	private $ticket_model;
30 30
 
31 31
 
32
-    /**
33
-     * TicketFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Ticket       $ticket_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->ticket_model = $ticket_model;
42
-    }
32
+	/**
33
+	 * TicketFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Ticket       $ticket_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->ticket_model = $ticket_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since $VID:$
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $TKT_ID = $this->request->getRequestParam('TKT_ID');
58
-        $TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID);
59
-        $TKT_ID = absint($TKT_ID);
60
-        if ($TKT_ID) {
61
-            $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62
-            if ($ticket instanceof EE_Ticket) {
63
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
64
-                $ticket_details .= ! $ticket->is_free()
65
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
66
-                    : '<span class="reg-overview-free-event-spn">'
67
-                      . __('free', 'event_espresso')
68
-                      . '</span>';
69
-                // remove the closing h3 heading tag if it exists
70
-                $text = str_replace(
71
-                    '</h3>',
72
-                    '',
73
-                    $text
74
-                );
75
-                if (empty($text)) {
76
-                    $text = '<h3 style="line-height:1.5em;">';
77
-                    $text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
78
-                }
79
-                $text .= '&nbsp; &nbsp; ';
80
-                $text .= '<span class="drk-grey-text" style="font-size:.9em;">';
81
-                $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
82
-                $text .= $ticket_details . '</span></h3>';
83
-            }
84
-        }
85
-        return $text;
86
-    }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since $VID:$
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$TKT_ID = $this->request->getRequestParam('TKT_ID');
58
+		$TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID);
59
+		$TKT_ID = absint($TKT_ID);
60
+		if ($TKT_ID) {
61
+			$ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62
+			if ($ticket instanceof EE_Ticket) {
63
+				$ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
64
+				$ticket_details .= ! $ticket->is_free()
65
+					? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
66
+					: '<span class="reg-overview-free-event-spn">'
67
+					  . __('free', 'event_espresso')
68
+					  . '</span>';
69
+				// remove the closing h3 heading tag if it exists
70
+				$text = str_replace(
71
+					'</h3>',
72
+					'',
73
+					$text
74
+				);
75
+				if (empty($text)) {
76
+					$text = '<h3 style="line-height:1.5em;">';
77
+					$text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
78
+				}
79
+				$text .= '&nbsp; &nbsp; ';
80
+				$text .= '<span class="drk-grey-text" style="font-size:.9em;">';
81
+				$text .= '<span class="dashicons dashicons-tickets-alt"></span>';
82
+				$text .= $ticket_details . '</span></h3>';
83
+			}
84
+		}
85
+		return $text;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
admin/registrations/list_table/page_header/AttendeeFilterHeader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@
 block discarded – undo
59 59
                         'event_espresso'
60 60
                     ),
61 61
                     '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
62
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
63 63
                         array(
64 64
                             'action' => 'edit_attendee',
65 65
                             'post'   => $ATT_ID,
66 66
                         ),
67 67
                         REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
68
+                    ).'">'.$attendee->full_name().'</a>',
69 69
                     '</h3>'
70 70
                 );
71 71
             }
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -20,56 +20,56 @@
 block discarded – undo
20 20
 class AttendeeFilterHeader extends AdminPageHeaderDecorator
21 21
 {
22 22
 
23
-    /**
24
-     * @var EEM_Attendee $attendee_model
25
-     */
26
-    private $attendee_model;
23
+	/**
24
+	 * @var EEM_Attendee $attendee_model
25
+	 */
26
+	private $attendee_model;
27 27
 
28 28
 
29
-    /**
30
-     * AttendeeFilterHeader constructor.
31
-     *
32
-     * @param RequestInterface $request
33
-     * @param EEM_Attendee     $attendee_model
34
-     */
35
-    public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
-    {
37
-        parent::__construct($request);
38
-        $this->attendee_model = $attendee_model;
39
-    }
29
+	/**
30
+	 * AttendeeFilterHeader constructor.
31
+	 *
32
+	 * @param RequestInterface $request
33
+	 * @param EEM_Attendee     $attendee_model
34
+	 */
35
+	public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
+	{
37
+		parent::__construct($request);
38
+		$this->attendee_model = $attendee_model;
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * @param string $text
44
-     * @return string
45
-     * @throws EE_Error
46
-     * @since $VID:$
47
-     */
48
-    public function getHeaderText($text = '')
49
-    {
50
-        $ATT_ID = $this->request->getRequestParam('ATT_ID');
51
-        $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID);
52
-        $ATT_ID = absint($ATT_ID);
53
-        if ($ATT_ID) {
54
-            $attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
55
-            if ($attendee instanceof EE_Attendee) {
56
-                $text .= sprintf(
57
-                    esc_html__(
58
-                        '%1$s Viewing registrations for %2$s%3$s',
59
-                        'event_espresso'
60
-                    ),
61
-                    '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
63
-                        array(
64
-                            'action' => 'edit_attendee',
65
-                            'post'   => $ATT_ID,
66
-                        ),
67
-                        REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
69
-                    '</h3>'
70
-                );
71
-            }
72
-        }
73
-        return $text;
74
-    }
42
+	/**
43
+	 * @param string $text
44
+	 * @return string
45
+	 * @throws EE_Error
46
+	 * @since $VID:$
47
+	 */
48
+	public function getHeaderText($text = '')
49
+	{
50
+		$ATT_ID = $this->request->getRequestParam('ATT_ID');
51
+		$ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID);
52
+		$ATT_ID = absint($ATT_ID);
53
+		if ($ATT_ID) {
54
+			$attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
55
+			if ($attendee instanceof EE_Attendee) {
56
+				$text .= sprintf(
57
+					esc_html__(
58
+						'%1$s Viewing registrations for %2$s%3$s',
59
+						'event_espresso'
60
+					),
61
+					'<h3 style="line-height:1.5em;">',
62
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
63
+						array(
64
+							'action' => 'edit_attendee',
65
+							'post'   => $ATT_ID,
66
+						),
67
+						REG_ADMIN_URL
68
+					) . '">' . $attendee->full_name() . '</a>',
69
+					'</h3>'
70
+				);
71
+			}
72
+		}
73
+		return $text;
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -16,155 +16,155 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23
-
24
-    /**
25
-     * @return array
26
-     */
27
-    public function getParams();
28
-
29
-
30
-    /**
31
-     * @return array
32
-     */
33
-    public function postParams();
34
-
35
-
36
-    /**
37
-     * @return array
38
-     */
39
-    public function cookieParams();
40
-
41
-
42
-    /**
43
-     * @return array
44
-     */
45
-    public function serverParams();
46
-
47
-
48
-    /**
49
-     * @return array
50
-     */
51
-    public function filesParams();
52
-
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23
+
24
+	/**
25
+	 * @return array
26
+	 */
27
+	public function getParams();
28
+
29
+
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function postParams();
34
+
35
+
36
+	/**
37
+	 * @return array
38
+	 */
39
+	public function cookieParams();
40
+
41
+
42
+	/**
43
+	 * @return array
44
+	 */
45
+	public function serverParams();
46
+
47
+
48
+	/**
49
+	 * @return array
50
+	 */
51
+	public function filesParams();
52
+
53 53
 
54
-    /**
55
-     * returns contents of $_REQUEST
56
-     *
57
-     * @return array
58
-     */
59
-    public function requestParams();
54
+	/**
55
+	 * returns contents of $_REQUEST
56
+	 *
57
+	 * @return array
58
+	 */
59
+	public function requestParams();
60 60
 
61 61
 
62
-    /**
63
-     * @param string $key
64
-     * @param string $value
65
-     * @param bool   $override_ee
66
-     * @return    void
67
-     */
68
-    public function setRequestParam($key, $value, $override_ee = false);
62
+	/**
63
+	 * @param string $key
64
+	 * @param string $value
65
+	 * @param bool   $override_ee
66
+	 * @return    void
67
+	 */
68
+	public function setRequestParam($key, $value, $override_ee = false);
69 69
 
70 70
 
71
-    /**
72
-     * returns the value for a request param if the given key exists
73
-     *
74
-     * @param string $key
75
-     * @param null   $default
76
-     * @return mixed
77
-     */
78
-    public function getRequestParam($key, $default = null);
71
+	/**
72
+	 * returns the value for a request param if the given key exists
73
+	 *
74
+	 * @param string $key
75
+	 * @param null   $default
76
+	 * @return mixed
77
+	 */
78
+	public function getRequestParam($key, $default = null);
79 79
 
80 80
 
81
-    /**
82
-     * check if param exists
83
-     *
84
-     * @param string $key
85
-     * @return bool
86
-     */
87
-    public function requestParamIsSet($key);
81
+	/**
82
+	 * check if param exists
83
+	 *
84
+	 * @param string $key
85
+	 * @return bool
86
+	 */
87
+	public function requestParamIsSet($key);
88 88
 
89 89
 
90
-    /**
91
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
92
-     * and return the value for the first match found
93
-     * wildcards can be either of the following:
94
-     *      ? to represent a single character of any type
95
-     *      * to represent one or more characters of any type
96
-     *
97
-     * @param string     $pattern
98
-     * @param null|mixed $default
99
-     * @return false|int
100
-     */
101
-    public function getMatch($pattern, $default = null);
90
+	/**
91
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
92
+	 * and return the value for the first match found
93
+	 * wildcards can be either of the following:
94
+	 *      ? to represent a single character of any type
95
+	 *      * to represent one or more characters of any type
96
+	 *
97
+	 * @param string     $pattern
98
+	 * @param null|mixed $default
99
+	 * @return false|int
100
+	 */
101
+	public function getMatch($pattern, $default = null);
102 102
 
103 103
 
104
-    /**
105
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
106
-     * wildcards can be either of the following:
107
-     *      ? to represent a single character of any type
108
-     *      * to represent one or more characters of any type
109
-     * returns true if a match is found or false if not
110
-     *
111
-     * @param string $pattern
112
-     * @return false|int
113
-     */
114
-    public function matches($pattern);
104
+	/**
105
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
106
+	 * wildcards can be either of the following:
107
+	 *      ? to represent a single character of any type
108
+	 *      * to represent one or more characters of any type
109
+	 * returns true if a match is found or false if not
110
+	 *
111
+	 * @param string $pattern
112
+	 * @return false|int
113
+	 */
114
+	public function matches($pattern);
115 115
 
116 116
 
117
-    /**
118
-     * remove param
119
-     *
120
-     * @param string $key
121
-     * @param bool   $unset_from_global_too
122
-     */
123
-    public function unSetRequestParam($key, $unset_from_global_too = false);
117
+	/**
118
+	 * remove param
119
+	 *
120
+	 * @param string $key
121
+	 * @param bool   $unset_from_global_too
122
+	 */
123
+	public function unSetRequestParam($key, $unset_from_global_too = false);
124 124
 
125 125
 
126
-    /**
127
-     * remove params
128
-     *
129
-     * @param array $keys
130
-     * @param bool   $unset_from_global_too
131
-     */
132
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false);
126
+	/**
127
+	 * remove params
128
+	 *
129
+	 * @param array $keys
130
+	 * @param bool   $unset_from_global_too
131
+	 */
132
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false);
133 133
 
134 134
 
135
-    /**
136
-     * @return string
137
-     */
138
-    public function ipAddress();
135
+	/**
136
+	 * @return string
137
+	 */
138
+	public function ipAddress();
139 139
 
140 140
 
141
-    /**
142
-     * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
143
-     * @return string
144
-     */
145
-    public function requestUri($relativeToWpRoot = false);
146
-
147
-
148
-    /**
149
-     * @return string
150
-     */
151
-    public function userAgent();
152
-
153
-
154
-    /**
155
-     * @param string $user_agent
156
-     */
157
-    public function setUserAgent($user_agent = '');
158
-
159
-
160
-    /**
161
-     * @return bool
162
-     */
163
-    public function isBot();
164
-
165
-
166
-    /**
167
-     * @param bool $is_bot
168
-     */
169
-    public function setIsBot($is_bot);
141
+	/**
142
+	 * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
143
+	 * @return string
144
+	 */
145
+	public function requestUri($relativeToWpRoot = false);
146
+
147
+
148
+	/**
149
+	 * @return string
150
+	 */
151
+	public function userAgent();
152
+
153
+
154
+	/**
155
+	 * @param string $user_agent
156
+	 */
157
+	public function setUserAgent($user_agent = '');
158
+
159
+
160
+	/**
161
+	 * @return bool
162
+	 */
163
+	public function isBot();
164
+
165
+
166
+	/**
167
+	 * @param bool $is_bot
168
+	 */
169
+	public function setIsBot($is_bot);
170 170
 }
Please login to merge, or discard this patch.
core/services/request/Request.php 2 patches
Indentation   +652 added lines, -652 removed lines patch added patch discarded remove patch
@@ -17,656 +17,656 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_GET parameters
22
-     *
23
-     * @var array $get
24
-     */
25
-    private $get;
26
-
27
-    /**
28
-     * $_POST parameters
29
-     *
30
-     * @var array $post
31
-     */
32
-    private $post;
33
-
34
-    /**
35
-     * $_COOKIE parameters
36
-     *
37
-     * @var array $cookie
38
-     */
39
-    private $cookie;
40
-
41
-    /**
42
-     * $_SERVER parameters
43
-     *
44
-     * @var array $server
45
-     */
46
-    private $server;
47
-
48
-    /**
49
-     * $_FILES parameters
50
-     *
51
-     * @var array $files
52
-     */
53
-    private $files;
54
-
55
-    /**
56
-     * $_REQUEST parameters
57
-     *
58
-     * @var array $request
59
-     */
60
-    private $request;
61
-
62
-    /**
63
-     * @var RequestTypeContextCheckerInterface
64
-     */
65
-    private $request_type;
66
-
67
-    /**
68
-     * IP address for request
69
-     *
70
-     * @var string $ip_address
71
-     */
72
-    private $ip_address;
73
-
74
-    /**
75
-     * @var string $user_agent
76
-     */
77
-    private $user_agent;
78
-
79
-    /**
80
-     * true if current user appears to be some kind of bot
81
-     *
82
-     * @var bool $is_bot
83
-     */
84
-    private $is_bot;
85
-
86
-
87
-    /**
88
-     * @param array $get
89
-     * @param array $post
90
-     * @param array $cookie
91
-     * @param array $server
92
-     * @param array $files
93
-     */
94
-    public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
-    {
96
-        // grab request vars
97
-        $this->get = $get;
98
-        $this->post = $post;
99
-        $this->cookie = $cookie;
100
-        $this->server = $server;
101
-        $this->files = $files;
102
-        $this->request = array_merge($this->get, $this->post);
103
-        $this->ip_address = $this->visitorIp();
104
-    }
105
-
106
-
107
-    /**
108
-     * @param RequestTypeContextCheckerInterface $type
109
-     */
110
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
-    {
112
-        $this->request_type = $type;
113
-    }
114
-
115
-
116
-    /**
117
-     * @return array
118
-     */
119
-    public function getParams()
120
-    {
121
-        return $this->get;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return array
127
-     */
128
-    public function postParams()
129
-    {
130
-        return $this->post;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return array
136
-     */
137
-    public function cookieParams()
138
-    {
139
-        return $this->cookie;
140
-    }
141
-
142
-
143
-    /**
144
-     * @return array
145
-     */
146
-    public function serverParams()
147
-    {
148
-        return $this->server;
149
-    }
150
-
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    public function filesParams()
156
-    {
157
-        return $this->files;
158
-    }
159
-
160
-
161
-    /**
162
-     * returns contents of $_REQUEST
163
-     *
164
-     * @return array
165
-     */
166
-    public function requestParams()
167
-    {
168
-        return $this->request;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param      $key
174
-     * @param      $value
175
-     * @param bool $override_ee
176
-     * @return    void
177
-     */
178
-    public function setRequestParam($key, $value, $override_ee = false)
179
-    {
180
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
181
-        if ($key !== 'ee'
182
-            || ($key === 'ee' && empty($this->request['ee']))
183
-            || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
-        ) {
185
-            $this->request[ $key ] = $value;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * returns   the value for a request param if the given key exists
192
-     *
193
-     * @param       $key
194
-     * @param null  $default
195
-     * @return mixed
196
-     */
197
-    public function getRequestParam($key, $default = null)
198
-    {
199
-        return $this->requestParameterDrillDown($key, $default, 'get');
200
-    }
201
-
202
-
203
-    /**
204
-     * check if param exists
205
-     *
206
-     * @param       $key
207
-     * @return bool
208
-     */
209
-    public function requestParamIsSet($key)
210
-    {
211
-        return $this->requestParameterDrillDown($key);
212
-    }
213
-
214
-
215
-    /**
216
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
-     * and return the value for the first match found
218
-     * wildcards can be either of the following:
219
-     *      ? to represent a single character of any type
220
-     *      * to represent one or more characters of any type
221
-     *
222
-     * @param string     $pattern
223
-     * @param null|mixed $default
224
-     * @return mixed
225
-     */
226
-    public function getMatch($pattern, $default = null)
227
-    {
228
-        return $this->requestParameterDrillDown($pattern, $default, 'match');
229
-    }
230
-
231
-
232
-    /**
233
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
234
-     * wildcards can be either of the following:
235
-     *      ? to represent a single character of any type
236
-     *      * to represent one or more characters of any type
237
-     * returns true if a match is found or false if not
238
-     *
239
-     * @param string $pattern
240
-     * @return bool
241
-     */
242
-    public function matches($pattern)
243
-    {
244
-        return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
-    }
246
-
247
-
248
-    /**
249
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
-     *                                      and used to search through the current request's parameter keys
252
-     * @param array  $request_params        The array of request parameters to search through
253
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
254
-     *                                      Default is null
255
-     * @param string $return                [optional] Controls what kind of value is returned.
256
-     *                                      Options are:
257
-     *                                      'bool' will return true or false if match is found or not
258
-     *                                      'key' will return the first key found that matches the supplied pattern
259
-     *                                      'value' will return the value for the first request parameter
260
-     *                                      whose key matches the supplied pattern
261
-     *                                      Default is 'value'
262
-     * @return boolean|string
263
-     */
264
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
265
-    {
266
-        $return = in_array($return, array('bool', 'key', 'value'), true)
267
-            ? $return
268
-            : 'is_set';
269
-        // replace wildcard chars with regex chars
270
-        $pattern = str_replace(
271
-            array("\*", "\?"),
272
-            array('.*', '.'),
273
-            preg_quote($pattern, '/')
274
-        );
275
-        foreach ($request_params as $key => $request_param) {
276
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
277
-                // return value for request param
278
-                if ($return === 'value') {
279
-                    return $request_params[ $key ];
280
-                }
281
-                // or actual key or true just to indicate it was found
282
-                return $return === 'key' ? $key : true;
283
-            }
284
-        }
285
-        // match not found so return default value or false
286
-        return $return === 'value' ? $default : false;
287
-    }
288
-
289
-
290
-    /**
291
-     * the supplied key can be a simple string to represent a "top-level" request parameter
292
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
-     * by using square brackets to surround keys for deeper array elements.
294
-     * For example :
295
-     * if the supplied $key was: "first[second][third]"
296
-     * then this will attempt to drill down into the request parameter array to find a value.
297
-     * Given the following request parameters:
298
-     *  array(
299
-     *      'first' => array(
300
-     *          'second' => array(
301
-     *              'third' => 'has a value'
302
-     *          )
303
-     *      )
304
-     *  )
305
-     * would return true if default parameters were set
306
-     *
307
-     * @param string $callback
308
-     * @param        $key
309
-     * @param null   $default
310
-     * @param array  $request_params
311
-     * @return bool|mixed|null
312
-     */
313
-    private function requestParameterDrillDown(
314
-        $key,
315
-        $default = null,
316
-        $callback = 'is_set',
317
-        array $request_params = array()
318
-    ) {
319
-        $callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
-            ? $callback
321
-            : 'is_set';
322
-        $request_params = ! empty($request_params)
323
-            ? $request_params
324
-            : $this->request;
325
-        // does incoming key represent an array like 'first[second][third]'  ?
326
-        if (strpos($key, '[') !== false) {
327
-            // turn it into an actual array
328
-            $key = str_replace(']', '', $key);
329
-            $keys = explode('[', $key);
330
-            $key = array_shift($keys);
331
-            if ($callback === 'match') {
332
-                $real_key = $this->match($key, $request_params, $default, 'key');
333
-                $key = $real_key ? $real_key : $key;
334
-            }
335
-            // check if top level key exists
336
-            if (isset($request_params[ $key ])) {
337
-                // build a new key to pass along like: 'second[third]'
338
-                // or just 'second' depending on depth of keys
339
-                $key_string = array_shift($keys);
340
-                if (! empty($keys)) {
341
-                    $key_string .= '[' . implode('][', $keys) . ']';
342
-                }
343
-                return $this->requestParameterDrillDown(
344
-                    $key_string,
345
-                    $default,
346
-                    $callback,
347
-                    $request_params[ $key ]
348
-                );
349
-            }
350
-        }
351
-        if ($callback === 'is_set') {
352
-            return isset($request_params[ $key ]);
353
-        }
354
-        if ($callback === 'match') {
355
-            return $this->match($key, $request_params, $default);
356
-        }
357
-        return isset($request_params[ $key ])
358
-            ? $request_params[ $key ]
359
-            : $default;
360
-    }
361
-
362
-
363
-    /**
364
-     * remove param
365
-     *
366
-     * @param      $key
367
-     * @param bool $unset_from_global_too
368
-     */
369
-    public function unSetRequestParam($key, $unset_from_global_too = false)
370
-    {
371
-        // because unset may not actually remove var
372
-        $this->request[ $key ] = null;
373
-        unset($this->request[ $key ]);
374
-        if ($unset_from_global_too) {
375
-            unset($_REQUEST[ $key ]);
376
-        }
377
-    }
378
-
379
-
380
-    /**
381
-     * remove params
382
-     *
383
-     * @param array $keys
384
-     * @param bool  $unset_from_global_too
385
-     */
386
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
387
-    {
388
-        foreach ($keys as $key) {
389
-            $this->unSetRequestParam($key, $unset_from_global_too);
390
-        }
391
-    }
392
-
393
-
394
-    /**
395
-     * @return string
396
-     */
397
-    public function ipAddress()
398
-    {
399
-        return $this->ip_address;
400
-    }
401
-
402
-
403
-    /**
404
-     * attempt to get IP address of current visitor from server
405
-     * plz see: http://stackoverflow.com/a/2031935/1475279
406
-     *
407
-     * @access public
408
-     * @return string
409
-     */
410
-    private function visitorIp()
411
-    {
412
-        $visitor_ip = '0.0.0.0';
413
-        $server_keys = array(
414
-            'HTTP_CLIENT_IP',
415
-            'HTTP_X_FORWARDED_FOR',
416
-            'HTTP_X_FORWARDED',
417
-            'HTTP_X_CLUSTER_CLIENT_IP',
418
-            'HTTP_FORWARDED_FOR',
419
-            'HTTP_FORWARDED',
420
-            'REMOTE_ADDR',
421
-        );
422
-        foreach ($server_keys as $key) {
423
-            if (isset($this->server[ $key ])) {
424
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
425
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
426
-                        $visitor_ip = $ip;
427
-                    }
428
-                }
429
-            }
430
-        }
431
-        return $visitor_ip;
432
-    }
433
-
434
-
435
-    /**
436
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
437
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
438
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
439
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
440
-     * @return string
441
-     */
442
-    public function requestUri($relativeToWpRoot = false)
443
-    {
444
-        $request_uri = filter_input(
445
-            INPUT_SERVER,
446
-            'REQUEST_URI',
447
-            FILTER_SANITIZE_URL,
448
-            FILTER_NULL_ON_FAILURE
449
-        );
450
-        if (empty($request_uri)) {
451
-            // fallback sanitization if the above fails
452
-            $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
453
-        }
454
-        if ($relativeToWpRoot) {
455
-            $home_path = untrailingslashit(
456
-                parse_url(
457
-                    home_url(),
458
-                    PHP_URL_PATH
459
-                )
460
-            );
461
-            $request_uri = str_replace(
462
-                $home_path,
463
-                '',
464
-                $request_uri
465
-            );
466
-        }
467
-        return $request_uri;
468
-    }
469
-
470
-    /**
471
-     * @return string
472
-     */
473
-    public function userAgent()
474
-    {
475
-        return $this->user_agent;
476
-    }
477
-
478
-
479
-    /**
480
-     * @param string $user_agent
481
-     */
482
-    public function setUserAgent($user_agent = '')
483
-    {
484
-        if ($user_agent === '' || ! is_string($user_agent)) {
485
-            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
486
-        }
487
-        $this->user_agent = $user_agent;
488
-    }
489
-
490
-
491
-    /**
492
-     * @return bool
493
-     */
494
-    public function isBot()
495
-    {
496
-        return $this->is_bot;
497
-    }
498
-
499
-
500
-    /**
501
-     * @param bool $is_bot
502
-     */
503
-    public function setIsBot($is_bot)
504
-    {
505
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
506
-    }
507
-
508
-
509
-    /**
510
-     * @return bool
511
-     */
512
-    public function isActivation()
513
-    {
514
-        return $this->request_type->isActivation();
515
-    }
516
-
517
-
518
-    /**
519
-     * @param $is_activation
520
-     * @return bool
521
-     */
522
-    public function setIsActivation($is_activation)
523
-    {
524
-        return $this->request_type->setIsActivation($is_activation);
525
-    }
526
-
527
-
528
-    /**
529
-     * @return bool
530
-     */
531
-    public function isAdmin()
532
-    {
533
-        return $this->request_type->isAdmin();
534
-    }
535
-
536
-
537
-    /**
538
-     * @return bool
539
-     */
540
-    public function isAdminAjax()
541
-    {
542
-        return $this->request_type->isAdminAjax();
543
-    }
544
-
545
-
546
-    /**
547
-     * @return bool
548
-     */
549
-    public function isAjax()
550
-    {
551
-        return $this->request_type->isAjax();
552
-    }
553
-
554
-
555
-    /**
556
-     * @return bool
557
-     */
558
-    public function isEeAjax()
559
-    {
560
-        return $this->request_type->isEeAjax();
561
-    }
562
-
563
-
564
-    /**
565
-     * @return bool
566
-     */
567
-    public function isOtherAjax()
568
-    {
569
-        return $this->request_type->isOtherAjax();
570
-    }
571
-
572
-
573
-    /**
574
-     * @return bool
575
-     */
576
-    public function isApi()
577
-    {
578
-        return $this->request_type->isApi();
579
-    }
580
-
581
-
582
-    /**
583
-     * @return bool
584
-     */
585
-    public function isCli()
586
-    {
587
-        return $this->request_type->isCli();
588
-    }
589
-
590
-
591
-    /**
592
-     * @return bool
593
-     */
594
-    public function isCron()
595
-    {
596
-        return $this->request_type->isCron();
597
-    }
598
-
599
-
600
-    /**
601
-     * @return bool
602
-     */
603
-    public function isFeed()
604
-    {
605
-        return $this->request_type->isFeed();
606
-    }
607
-
608
-
609
-    /**
610
-     * @return bool
611
-     */
612
-    public function isFrontend()
613
-    {
614
-        return $this->request_type->isFrontend();
615
-    }
616
-
617
-
618
-    /**
619
-     * @return bool
620
-     */
621
-    public function isFrontAjax()
622
-    {
623
-        return $this->request_type->isFrontAjax();
624
-    }
625
-
626
-
627
-    /**
628
-     * @return bool
629
-     */
630
-    public function isIframe()
631
-    {
632
-        return $this->request_type->isIframe();
633
-    }
634
-
635
-
636
-    /**
637
-     * @return bool
638
-     */
639
-    public function isWordPressApi()
640
-    {
641
-        return $this->request_type->isWordPressApi();
642
-    }
643
-
644
-
645
-
646
-    /**
647
-     * @return bool
648
-     */
649
-    public function isWordPressHeartbeat()
650
-    {
651
-        return $this->request_type->isWordPressHeartbeat();
652
-    }
653
-
654
-
655
-
656
-    /**
657
-     * @return bool
658
-     */
659
-    public function isWordPressScrape()
660
-    {
661
-        return $this->request_type->isWordPressScrape();
662
-    }
663
-
664
-
665
-    /**
666
-     * @return string
667
-     */
668
-    public function slug()
669
-    {
670
-        return $this->request_type->slug();
671
-    }
20
+	/**
21
+	 * $_GET parameters
22
+	 *
23
+	 * @var array $get
24
+	 */
25
+	private $get;
26
+
27
+	/**
28
+	 * $_POST parameters
29
+	 *
30
+	 * @var array $post
31
+	 */
32
+	private $post;
33
+
34
+	/**
35
+	 * $_COOKIE parameters
36
+	 *
37
+	 * @var array $cookie
38
+	 */
39
+	private $cookie;
40
+
41
+	/**
42
+	 * $_SERVER parameters
43
+	 *
44
+	 * @var array $server
45
+	 */
46
+	private $server;
47
+
48
+	/**
49
+	 * $_FILES parameters
50
+	 *
51
+	 * @var array $files
52
+	 */
53
+	private $files;
54
+
55
+	/**
56
+	 * $_REQUEST parameters
57
+	 *
58
+	 * @var array $request
59
+	 */
60
+	private $request;
61
+
62
+	/**
63
+	 * @var RequestTypeContextCheckerInterface
64
+	 */
65
+	private $request_type;
66
+
67
+	/**
68
+	 * IP address for request
69
+	 *
70
+	 * @var string $ip_address
71
+	 */
72
+	private $ip_address;
73
+
74
+	/**
75
+	 * @var string $user_agent
76
+	 */
77
+	private $user_agent;
78
+
79
+	/**
80
+	 * true if current user appears to be some kind of bot
81
+	 *
82
+	 * @var bool $is_bot
83
+	 */
84
+	private $is_bot;
85
+
86
+
87
+	/**
88
+	 * @param array $get
89
+	 * @param array $post
90
+	 * @param array $cookie
91
+	 * @param array $server
92
+	 * @param array $files
93
+	 */
94
+	public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
+	{
96
+		// grab request vars
97
+		$this->get = $get;
98
+		$this->post = $post;
99
+		$this->cookie = $cookie;
100
+		$this->server = $server;
101
+		$this->files = $files;
102
+		$this->request = array_merge($this->get, $this->post);
103
+		$this->ip_address = $this->visitorIp();
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param RequestTypeContextCheckerInterface $type
109
+	 */
110
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
+	{
112
+		$this->request_type = $type;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return array
118
+	 */
119
+	public function getParams()
120
+	{
121
+		return $this->get;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return array
127
+	 */
128
+	public function postParams()
129
+	{
130
+		return $this->post;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return array
136
+	 */
137
+	public function cookieParams()
138
+	{
139
+		return $this->cookie;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @return array
145
+	 */
146
+	public function serverParams()
147
+	{
148
+		return $this->server;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public function filesParams()
156
+	{
157
+		return $this->files;
158
+	}
159
+
160
+
161
+	/**
162
+	 * returns contents of $_REQUEST
163
+	 *
164
+	 * @return array
165
+	 */
166
+	public function requestParams()
167
+	{
168
+		return $this->request;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param      $key
174
+	 * @param      $value
175
+	 * @param bool $override_ee
176
+	 * @return    void
177
+	 */
178
+	public function setRequestParam($key, $value, $override_ee = false)
179
+	{
180
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
181
+		if ($key !== 'ee'
182
+			|| ($key === 'ee' && empty($this->request['ee']))
183
+			|| ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
+		) {
185
+			$this->request[ $key ] = $value;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * returns   the value for a request param if the given key exists
192
+	 *
193
+	 * @param       $key
194
+	 * @param null  $default
195
+	 * @return mixed
196
+	 */
197
+	public function getRequestParam($key, $default = null)
198
+	{
199
+		return $this->requestParameterDrillDown($key, $default, 'get');
200
+	}
201
+
202
+
203
+	/**
204
+	 * check if param exists
205
+	 *
206
+	 * @param       $key
207
+	 * @return bool
208
+	 */
209
+	public function requestParamIsSet($key)
210
+	{
211
+		return $this->requestParameterDrillDown($key);
212
+	}
213
+
214
+
215
+	/**
216
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
+	 * and return the value for the first match found
218
+	 * wildcards can be either of the following:
219
+	 *      ? to represent a single character of any type
220
+	 *      * to represent one or more characters of any type
221
+	 *
222
+	 * @param string     $pattern
223
+	 * @param null|mixed $default
224
+	 * @return mixed
225
+	 */
226
+	public function getMatch($pattern, $default = null)
227
+	{
228
+		return $this->requestParameterDrillDown($pattern, $default, 'match');
229
+	}
230
+
231
+
232
+	/**
233
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
234
+	 * wildcards can be either of the following:
235
+	 *      ? to represent a single character of any type
236
+	 *      * to represent one or more characters of any type
237
+	 * returns true if a match is found or false if not
238
+	 *
239
+	 * @param string $pattern
240
+	 * @return bool
241
+	 */
242
+	public function matches($pattern)
243
+	{
244
+		return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
+	}
246
+
247
+
248
+	/**
249
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
+	 *                                      and used to search through the current request's parameter keys
252
+	 * @param array  $request_params        The array of request parameters to search through
253
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
254
+	 *                                      Default is null
255
+	 * @param string $return                [optional] Controls what kind of value is returned.
256
+	 *                                      Options are:
257
+	 *                                      'bool' will return true or false if match is found or not
258
+	 *                                      'key' will return the first key found that matches the supplied pattern
259
+	 *                                      'value' will return the value for the first request parameter
260
+	 *                                      whose key matches the supplied pattern
261
+	 *                                      Default is 'value'
262
+	 * @return boolean|string
263
+	 */
264
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
265
+	{
266
+		$return = in_array($return, array('bool', 'key', 'value'), true)
267
+			? $return
268
+			: 'is_set';
269
+		// replace wildcard chars with regex chars
270
+		$pattern = str_replace(
271
+			array("\*", "\?"),
272
+			array('.*', '.'),
273
+			preg_quote($pattern, '/')
274
+		);
275
+		foreach ($request_params as $key => $request_param) {
276
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
277
+				// return value for request param
278
+				if ($return === 'value') {
279
+					return $request_params[ $key ];
280
+				}
281
+				// or actual key or true just to indicate it was found
282
+				return $return === 'key' ? $key : true;
283
+			}
284
+		}
285
+		// match not found so return default value or false
286
+		return $return === 'value' ? $default : false;
287
+	}
288
+
289
+
290
+	/**
291
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
292
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
+	 * by using square brackets to surround keys for deeper array elements.
294
+	 * For example :
295
+	 * if the supplied $key was: "first[second][third]"
296
+	 * then this will attempt to drill down into the request parameter array to find a value.
297
+	 * Given the following request parameters:
298
+	 *  array(
299
+	 *      'first' => array(
300
+	 *          'second' => array(
301
+	 *              'third' => 'has a value'
302
+	 *          )
303
+	 *      )
304
+	 *  )
305
+	 * would return true if default parameters were set
306
+	 *
307
+	 * @param string $callback
308
+	 * @param        $key
309
+	 * @param null   $default
310
+	 * @param array  $request_params
311
+	 * @return bool|mixed|null
312
+	 */
313
+	private function requestParameterDrillDown(
314
+		$key,
315
+		$default = null,
316
+		$callback = 'is_set',
317
+		array $request_params = array()
318
+	) {
319
+		$callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
+			? $callback
321
+			: 'is_set';
322
+		$request_params = ! empty($request_params)
323
+			? $request_params
324
+			: $this->request;
325
+		// does incoming key represent an array like 'first[second][third]'  ?
326
+		if (strpos($key, '[') !== false) {
327
+			// turn it into an actual array
328
+			$key = str_replace(']', '', $key);
329
+			$keys = explode('[', $key);
330
+			$key = array_shift($keys);
331
+			if ($callback === 'match') {
332
+				$real_key = $this->match($key, $request_params, $default, 'key');
333
+				$key = $real_key ? $real_key : $key;
334
+			}
335
+			// check if top level key exists
336
+			if (isset($request_params[ $key ])) {
337
+				// build a new key to pass along like: 'second[third]'
338
+				// or just 'second' depending on depth of keys
339
+				$key_string = array_shift($keys);
340
+				if (! empty($keys)) {
341
+					$key_string .= '[' . implode('][', $keys) . ']';
342
+				}
343
+				return $this->requestParameterDrillDown(
344
+					$key_string,
345
+					$default,
346
+					$callback,
347
+					$request_params[ $key ]
348
+				);
349
+			}
350
+		}
351
+		if ($callback === 'is_set') {
352
+			return isset($request_params[ $key ]);
353
+		}
354
+		if ($callback === 'match') {
355
+			return $this->match($key, $request_params, $default);
356
+		}
357
+		return isset($request_params[ $key ])
358
+			? $request_params[ $key ]
359
+			: $default;
360
+	}
361
+
362
+
363
+	/**
364
+	 * remove param
365
+	 *
366
+	 * @param      $key
367
+	 * @param bool $unset_from_global_too
368
+	 */
369
+	public function unSetRequestParam($key, $unset_from_global_too = false)
370
+	{
371
+		// because unset may not actually remove var
372
+		$this->request[ $key ] = null;
373
+		unset($this->request[ $key ]);
374
+		if ($unset_from_global_too) {
375
+			unset($_REQUEST[ $key ]);
376
+		}
377
+	}
378
+
379
+
380
+	/**
381
+	 * remove params
382
+	 *
383
+	 * @param array $keys
384
+	 * @param bool  $unset_from_global_too
385
+	 */
386
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
387
+	{
388
+		foreach ($keys as $key) {
389
+			$this->unSetRequestParam($key, $unset_from_global_too);
390
+		}
391
+	}
392
+
393
+
394
+	/**
395
+	 * @return string
396
+	 */
397
+	public function ipAddress()
398
+	{
399
+		return $this->ip_address;
400
+	}
401
+
402
+
403
+	/**
404
+	 * attempt to get IP address of current visitor from server
405
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
406
+	 *
407
+	 * @access public
408
+	 * @return string
409
+	 */
410
+	private function visitorIp()
411
+	{
412
+		$visitor_ip = '0.0.0.0';
413
+		$server_keys = array(
414
+			'HTTP_CLIENT_IP',
415
+			'HTTP_X_FORWARDED_FOR',
416
+			'HTTP_X_FORWARDED',
417
+			'HTTP_X_CLUSTER_CLIENT_IP',
418
+			'HTTP_FORWARDED_FOR',
419
+			'HTTP_FORWARDED',
420
+			'REMOTE_ADDR',
421
+		);
422
+		foreach ($server_keys as $key) {
423
+			if (isset($this->server[ $key ])) {
424
+				foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
425
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
426
+						$visitor_ip = $ip;
427
+					}
428
+				}
429
+			}
430
+		}
431
+		return $visitor_ip;
432
+	}
433
+
434
+
435
+	/**
436
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
437
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
438
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
439
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
440
+	 * @return string
441
+	 */
442
+	public function requestUri($relativeToWpRoot = false)
443
+	{
444
+		$request_uri = filter_input(
445
+			INPUT_SERVER,
446
+			'REQUEST_URI',
447
+			FILTER_SANITIZE_URL,
448
+			FILTER_NULL_ON_FAILURE
449
+		);
450
+		if (empty($request_uri)) {
451
+			// fallback sanitization if the above fails
452
+			$request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
453
+		}
454
+		if ($relativeToWpRoot) {
455
+			$home_path = untrailingslashit(
456
+				parse_url(
457
+					home_url(),
458
+					PHP_URL_PATH
459
+				)
460
+			);
461
+			$request_uri = str_replace(
462
+				$home_path,
463
+				'',
464
+				$request_uri
465
+			);
466
+		}
467
+		return $request_uri;
468
+	}
469
+
470
+	/**
471
+	 * @return string
472
+	 */
473
+	public function userAgent()
474
+	{
475
+		return $this->user_agent;
476
+	}
477
+
478
+
479
+	/**
480
+	 * @param string $user_agent
481
+	 */
482
+	public function setUserAgent($user_agent = '')
483
+	{
484
+		if ($user_agent === '' || ! is_string($user_agent)) {
485
+			$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
486
+		}
487
+		$this->user_agent = $user_agent;
488
+	}
489
+
490
+
491
+	/**
492
+	 * @return bool
493
+	 */
494
+	public function isBot()
495
+	{
496
+		return $this->is_bot;
497
+	}
498
+
499
+
500
+	/**
501
+	 * @param bool $is_bot
502
+	 */
503
+	public function setIsBot($is_bot)
504
+	{
505
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
506
+	}
507
+
508
+
509
+	/**
510
+	 * @return bool
511
+	 */
512
+	public function isActivation()
513
+	{
514
+		return $this->request_type->isActivation();
515
+	}
516
+
517
+
518
+	/**
519
+	 * @param $is_activation
520
+	 * @return bool
521
+	 */
522
+	public function setIsActivation($is_activation)
523
+	{
524
+		return $this->request_type->setIsActivation($is_activation);
525
+	}
526
+
527
+
528
+	/**
529
+	 * @return bool
530
+	 */
531
+	public function isAdmin()
532
+	{
533
+		return $this->request_type->isAdmin();
534
+	}
535
+
536
+
537
+	/**
538
+	 * @return bool
539
+	 */
540
+	public function isAdminAjax()
541
+	{
542
+		return $this->request_type->isAdminAjax();
543
+	}
544
+
545
+
546
+	/**
547
+	 * @return bool
548
+	 */
549
+	public function isAjax()
550
+	{
551
+		return $this->request_type->isAjax();
552
+	}
553
+
554
+
555
+	/**
556
+	 * @return bool
557
+	 */
558
+	public function isEeAjax()
559
+	{
560
+		return $this->request_type->isEeAjax();
561
+	}
562
+
563
+
564
+	/**
565
+	 * @return bool
566
+	 */
567
+	public function isOtherAjax()
568
+	{
569
+		return $this->request_type->isOtherAjax();
570
+	}
571
+
572
+
573
+	/**
574
+	 * @return bool
575
+	 */
576
+	public function isApi()
577
+	{
578
+		return $this->request_type->isApi();
579
+	}
580
+
581
+
582
+	/**
583
+	 * @return bool
584
+	 */
585
+	public function isCli()
586
+	{
587
+		return $this->request_type->isCli();
588
+	}
589
+
590
+
591
+	/**
592
+	 * @return bool
593
+	 */
594
+	public function isCron()
595
+	{
596
+		return $this->request_type->isCron();
597
+	}
598
+
599
+
600
+	/**
601
+	 * @return bool
602
+	 */
603
+	public function isFeed()
604
+	{
605
+		return $this->request_type->isFeed();
606
+	}
607
+
608
+
609
+	/**
610
+	 * @return bool
611
+	 */
612
+	public function isFrontend()
613
+	{
614
+		return $this->request_type->isFrontend();
615
+	}
616
+
617
+
618
+	/**
619
+	 * @return bool
620
+	 */
621
+	public function isFrontAjax()
622
+	{
623
+		return $this->request_type->isFrontAjax();
624
+	}
625
+
626
+
627
+	/**
628
+	 * @return bool
629
+	 */
630
+	public function isIframe()
631
+	{
632
+		return $this->request_type->isIframe();
633
+	}
634
+
635
+
636
+	/**
637
+	 * @return bool
638
+	 */
639
+	public function isWordPressApi()
640
+	{
641
+		return $this->request_type->isWordPressApi();
642
+	}
643
+
644
+
645
+
646
+	/**
647
+	 * @return bool
648
+	 */
649
+	public function isWordPressHeartbeat()
650
+	{
651
+		return $this->request_type->isWordPressHeartbeat();
652
+	}
653
+
654
+
655
+
656
+	/**
657
+	 * @return bool
658
+	 */
659
+	public function isWordPressScrape()
660
+	{
661
+		return $this->request_type->isWordPressScrape();
662
+	}
663
+
664
+
665
+	/**
666
+	 * @return string
667
+	 */
668
+	public function slug()
669
+	{
670
+		return $this->request_type->slug();
671
+	}
672 672
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             || ($key === 'ee' && empty($this->request['ee']))
183 183
             || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184 184
         ) {
185
-            $this->request[ $key ] = $value;
185
+            $this->request[$key] = $value;
186 186
         }
187 187
     }
188 188
 
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
             preg_quote($pattern, '/')
274 274
         );
275 275
         foreach ($request_params as $key => $request_param) {
276
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
276
+            if (preg_match('/^'.$pattern.'$/is', $key)) {
277 277
                 // return value for request param
278 278
                 if ($return === 'value') {
279
-                    return $request_params[ $key ];
279
+                    return $request_params[$key];
280 280
                 }
281 281
                 // or actual key or true just to indicate it was found
282 282
                 return $return === 'key' ? $key : true;
@@ -333,29 +333,29 @@  discard block
 block discarded – undo
333 333
                 $key = $real_key ? $real_key : $key;
334 334
             }
335 335
             // check if top level key exists
336
-            if (isset($request_params[ $key ])) {
336
+            if (isset($request_params[$key])) {
337 337
                 // build a new key to pass along like: 'second[third]'
338 338
                 // or just 'second' depending on depth of keys
339 339
                 $key_string = array_shift($keys);
340
-                if (! empty($keys)) {
341
-                    $key_string .= '[' . implode('][', $keys) . ']';
340
+                if ( ! empty($keys)) {
341
+                    $key_string .= '['.implode('][', $keys).']';
342 342
                 }
343 343
                 return $this->requestParameterDrillDown(
344 344
                     $key_string,
345 345
                     $default,
346 346
                     $callback,
347
-                    $request_params[ $key ]
347
+                    $request_params[$key]
348 348
                 );
349 349
             }
350 350
         }
351 351
         if ($callback === 'is_set') {
352
-            return isset($request_params[ $key ]);
352
+            return isset($request_params[$key]);
353 353
         }
354 354
         if ($callback === 'match') {
355 355
             return $this->match($key, $request_params, $default);
356 356
         }
357
-        return isset($request_params[ $key ])
358
-            ? $request_params[ $key ]
357
+        return isset($request_params[$key])
358
+            ? $request_params[$key]
359 359
             : $default;
360 360
     }
361 361
 
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
     public function unSetRequestParam($key, $unset_from_global_too = false)
370 370
     {
371 371
         // because unset may not actually remove var
372
-        $this->request[ $key ] = null;
373
-        unset($this->request[ $key ]);
372
+        $this->request[$key] = null;
373
+        unset($this->request[$key]);
374 374
         if ($unset_from_global_too) {
375
-            unset($_REQUEST[ $key ]);
375
+            unset($_REQUEST[$key]);
376 376
         }
377 377
     }
378 378
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
             'REMOTE_ADDR',
421 421
         );
422 422
         foreach ($server_keys as $key) {
423
-            if (isset($this->server[ $key ])) {
424
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
423
+            if (isset($this->server[$key])) {
424
+                foreach (array_map('trim', explode(',', $this->server[$key])) as $ip) {
425 425
                     if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
426 426
                         $visitor_ip = $ip;
427 427
                     }
Please login to merge, or discard this patch.