Completed
Branch EDTR/refactor-tkt-reg-count (88344e)
by
unknown
34:40 queued 26:27
created
core/db_models/EEM_Price.model.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     /**
81 81
      * instantiate a new price object with blank/empty properties
82 82
      *
83
-     * @return mixed array on success, FALSE on fail
83
+     * @return EE_Base_Class|null array on success, FALSE on fail
84 84
      */
85 85
     public function get_new_price()
86 86
     {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * retrieve all active prices for a particular event
106 106
      *
107 107
      * @param int $EVT_ID
108
-     * @return array on success
108
+     * @return EE_Base_Class[] on success
109 109
      * @throws EE_Error
110 110
      */
111 111
     public function get_all_event_prices($EVT_ID = 0)
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      *
219 219
      * @param EE_Price $price_a
220 220
      * @param EE_Price $price_b
221
-     * @return bool false on fail
221
+     * @return integer false on fail
222 222
      */
223 223
     public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
224 224
     {
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      *
235 235
      * @param EE_Price $price_a
236 236
      * @param EE_Price $price_b
237
-     * @return bool false on fail
237
+     * @return integer false on fail
238 238
      */
239 239
     public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
240 240
     {
Please login to merge, or discard this patch.
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -13,333 +13,333 @@
 block discarded – undo
13 13
 class EEM_Price extends EEM_Soft_Delete_Base
14 14
 {
15 15
 
16
-    // private instance of the EEM_Price object
17
-    protected static $_instance;
16
+	// private instance of the EEM_Price object
17
+	protected static $_instance;
18 18
 
19 19
 
20
-    /**
21
-     * private constructor to prevent direct creation
22
-     *
23
-     * @Constructor
24
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
25
-     *                         (and any incoming timezone data that gets saved).
26
-     *                         Note this just sends the timezone info to the date time model field objects.
27
-     *                         Default is NULL
28
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
-     */
30
-    protected function __construct($timezone)
31
-    {
32
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
33
-        $this->singular_item = __('Price', 'event_espresso');
34
-        $this->plural_item = __('Prices', 'event_espresso');
20
+	/**
21
+	 * private constructor to prevent direct creation
22
+	 *
23
+	 * @Constructor
24
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
25
+	 *                         (and any incoming timezone data that gets saved).
26
+	 *                         Note this just sends the timezone info to the date time model field objects.
27
+	 *                         Default is NULL
28
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
+	 */
30
+	protected function __construct($timezone)
31
+	{
32
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
33
+		$this->singular_item = __('Price', 'event_espresso');
34
+		$this->plural_item = __('Prices', 'event_espresso');
35 35
 
36
-        $this->_tables = array(
37
-            'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
38
-        );
39
-        $this->_fields = array(
40
-            'Price' => array(
41
-                'PRC_ID'         => new EE_Primary_Key_Int_Field(
42
-                    'PRC_ID',
43
-                    'Price ID'
44
-                ),
45
-                'PRT_ID'         => new EE_Foreign_Key_Int_Field(
46
-                    'PRT_ID',
47
-                    esc_html__('Price type Id', 'event_espresso'),
48
-                    false,
49
-                    null,
50
-                    'Price_Type'
51
-                ),
52
-                'PRC_amount'     => new EE_Money_Field(
53
-                    'PRC_amount',
54
-                    esc_html__('Price Amount', 'event_espresso'),
55
-                    false,
56
-                    0
57
-                ),
58
-                'PRC_name'       => new EE_Plain_Text_Field(
59
-                    'PRC_name',
60
-                    esc_html__('Name of Price', 'event_espresso'),
61
-                    false,
62
-                    ''
63
-                ),
64
-                'PRC_desc'       => new EE_Post_Content_Field(
65
-                    'PRC_desc',
66
-                    esc_html__('Price Description', 'event_espresso'),
67
-                    false,
68
-                    ''
69
-                ),
70
-                'PRC_is_default' => new EE_Boolean_Field(
71
-                    'PRC_is_default',
72
-                    esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
73
-                    false,
74
-                    false
75
-                ),
76
-                'PRC_overrides'  => new EE_Integer_Field(
77
-                    'PRC_overrides',
78
-                    esc_html__(
79
-                        'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
80
-                        'event_espresso'
81
-                    ),
82
-                    true,
83
-                    0
84
-                ),
85
-                'PRC_order'      => new EE_Integer_Field(
86
-                    'PRC_order',
87
-                    esc_html__(
88
-                        'Order of Application of Price (lower numbers apply first?)',
89
-                        'event_espresso'
90
-                    ),
91
-                    false,
92
-                    1
93
-                ),
94
-                'PRC_deleted'    => new EE_Trashed_Flag_Field(
95
-                    'PRC_deleted',
96
-                    esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
97
-                    false,
98
-                    false
99
-                ),
100
-                'PRC_parent'     => new EE_Integer_Field(
101
-                    'PRC_parent',
102
-                    esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
103
-                    true,
104
-                    0
105
-                ),
106
-                'PRC_wp_user'    => new EE_WP_User_Field(
107
-                    'PRC_wp_user',
108
-                    esc_html__('Price Creator ID', 'event_espresso'),
109
-                    false
110
-                ),
111
-            ),
112
-        );
113
-        $this->_model_relations = array(
114
-            'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
115
-            'Price_Type' => new EE_Belongs_To_Relation(),
116
-            'WP_User'    => new EE_Belongs_To_Relation(),
117
-        );
118
-        // this model is generally available for reading
119
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] =
120
-            new EE_Restriction_Generator_Default_Public(
121
-                'PRC_is_default',
122
-                'Ticket.Datetime.Event'
123
-            );
124
-        // account for default tickets in the caps
125
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
126
-            new EE_Restriction_Generator_Default_Protected(
127
-                'PRC_is_default',
128
-                'Ticket.Datetime.Event'
129
-            );
130
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] =
131
-            new EE_Restriction_Generator_Default_Protected(
132
-                'PRC_is_default',
133
-                'Ticket.Datetime.Event'
134
-            );
135
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] =
136
-            new EE_Restriction_Generator_Default_Protected(
137
-                'PRC_is_default',
138
-                'Ticket.Datetime.Event'
139
-            );
140
-        parent::__construct($timezone);
141
-    }
36
+		$this->_tables = array(
37
+			'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
38
+		);
39
+		$this->_fields = array(
40
+			'Price' => array(
41
+				'PRC_ID'         => new EE_Primary_Key_Int_Field(
42
+					'PRC_ID',
43
+					'Price ID'
44
+				),
45
+				'PRT_ID'         => new EE_Foreign_Key_Int_Field(
46
+					'PRT_ID',
47
+					esc_html__('Price type Id', 'event_espresso'),
48
+					false,
49
+					null,
50
+					'Price_Type'
51
+				),
52
+				'PRC_amount'     => new EE_Money_Field(
53
+					'PRC_amount',
54
+					esc_html__('Price Amount', 'event_espresso'),
55
+					false,
56
+					0
57
+				),
58
+				'PRC_name'       => new EE_Plain_Text_Field(
59
+					'PRC_name',
60
+					esc_html__('Name of Price', 'event_espresso'),
61
+					false,
62
+					''
63
+				),
64
+				'PRC_desc'       => new EE_Post_Content_Field(
65
+					'PRC_desc',
66
+					esc_html__('Price Description', 'event_espresso'),
67
+					false,
68
+					''
69
+				),
70
+				'PRC_is_default' => new EE_Boolean_Field(
71
+					'PRC_is_default',
72
+					esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
73
+					false,
74
+					false
75
+				),
76
+				'PRC_overrides'  => new EE_Integer_Field(
77
+					'PRC_overrides',
78
+					esc_html__(
79
+						'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
80
+						'event_espresso'
81
+					),
82
+					true,
83
+					0
84
+				),
85
+				'PRC_order'      => new EE_Integer_Field(
86
+					'PRC_order',
87
+					esc_html__(
88
+						'Order of Application of Price (lower numbers apply first?)',
89
+						'event_espresso'
90
+					),
91
+					false,
92
+					1
93
+				),
94
+				'PRC_deleted'    => new EE_Trashed_Flag_Field(
95
+					'PRC_deleted',
96
+					esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
97
+					false,
98
+					false
99
+				),
100
+				'PRC_parent'     => new EE_Integer_Field(
101
+					'PRC_parent',
102
+					esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
103
+					true,
104
+					0
105
+				),
106
+				'PRC_wp_user'    => new EE_WP_User_Field(
107
+					'PRC_wp_user',
108
+					esc_html__('Price Creator ID', 'event_espresso'),
109
+					false
110
+				),
111
+			),
112
+		);
113
+		$this->_model_relations = array(
114
+			'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
115
+			'Price_Type' => new EE_Belongs_To_Relation(),
116
+			'WP_User'    => new EE_Belongs_To_Relation(),
117
+		);
118
+		// this model is generally available for reading
119
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] =
120
+			new EE_Restriction_Generator_Default_Public(
121
+				'PRC_is_default',
122
+				'Ticket.Datetime.Event'
123
+			);
124
+		// account for default tickets in the caps
125
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
126
+			new EE_Restriction_Generator_Default_Protected(
127
+				'PRC_is_default',
128
+				'Ticket.Datetime.Event'
129
+			);
130
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] =
131
+			new EE_Restriction_Generator_Default_Protected(
132
+				'PRC_is_default',
133
+				'Ticket.Datetime.Event'
134
+			);
135
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] =
136
+			new EE_Restriction_Generator_Default_Protected(
137
+				'PRC_is_default',
138
+				'Ticket.Datetime.Event'
139
+			);
140
+		parent::__construct($timezone);
141
+	}
142 142
 
143 143
 
144
-    /**
145
-     * instantiate a new price object with blank/empty properties
146
-     *
147
-     * @return mixed array on success, FALSE on fail
148
-     */
149
-    public function get_new_price()
150
-    {
151
-        return $this->create_default_object();
152
-    }
144
+	/**
145
+	 * instantiate a new price object with blank/empty properties
146
+	 *
147
+	 * @return mixed array on success, FALSE on fail
148
+	 */
149
+	public function get_new_price()
150
+	{
151
+		return $this->create_default_object();
152
+	}
153 153
 
154 154
 
155
-    /**
156
-     * retrieve  ALL prices from db
157
-     *
158
-     * @return EE_Base_Class[]|EE_PRice[]
159
-     * @throws EE_Error
160
-     */
161
-    public function get_all_prices()
162
-    {
163
-        // retrieve all prices
164
-        return $this->get_all(array('order_by' => array('PRC_amount' => 'ASC')));
165
-    }
155
+	/**
156
+	 * retrieve  ALL prices from db
157
+	 *
158
+	 * @return EE_Base_Class[]|EE_PRice[]
159
+	 * @throws EE_Error
160
+	 */
161
+	public function get_all_prices()
162
+	{
163
+		// retrieve all prices
164
+		return $this->get_all(array('order_by' => array('PRC_amount' => 'ASC')));
165
+	}
166 166
 
167 167
 
168
-    /**
169
-     * retrieve all active prices for a particular event
170
-     *
171
-     * @param int $EVT_ID
172
-     * @return array on success
173
-     * @throws EE_Error
174
-     */
175
-    public function get_all_event_prices($EVT_ID = 0)
176
-    {
177
-        return $this->get_all(array(
178
-            array(
179
-                'EVT_ID'            => $EVT_ID,
180
-                'Price_Type.PBT_ID' => array('!=', EEM_Price_Type::base_type_tax),
181
-            ),
182
-            'order_by' => $this->_order_by_array_for_get_all_method(),
183
-        ));
184
-    }
168
+	/**
169
+	 * retrieve all active prices for a particular event
170
+	 *
171
+	 * @param int $EVT_ID
172
+	 * @return array on success
173
+	 * @throws EE_Error
174
+	 */
175
+	public function get_all_event_prices($EVT_ID = 0)
176
+	{
177
+		return $this->get_all(array(
178
+			array(
179
+				'EVT_ID'            => $EVT_ID,
180
+				'Price_Type.PBT_ID' => array('!=', EEM_Price_Type::base_type_tax),
181
+			),
182
+			'order_by' => $this->_order_by_array_for_get_all_method(),
183
+		));
184
+	}
185 185
 
186 186
 
187
-    /**
188
-     * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
189
-     *
190
-     * @param boolean $count return count
191
-     * @return bool|EE_Base_Class[]|EE_PRice[]
192
-     * @throws EE_Error
193
-     */
194
-    public function get_all_default_prices($count = false)
195
-    {
196
-        $_where = array(
197
-            'Price_Type.PBT_ID' => array('!=', 4),
198
-            'PRC_deleted'       => 0,
199
-            'PRC_is_default'    => 1,
200
-        );
201
-        $_query_params = array(
202
-            $_where,
203
-            'order_by' => $this->_order_by_array_for_get_all_method(),
204
-        );
205
-        return $count ? $this->count(array($_where)) : $this->get_all($_query_params);
206
-    }
187
+	/**
188
+	 * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
189
+	 *
190
+	 * @param boolean $count return count
191
+	 * @return bool|EE_Base_Class[]|EE_PRice[]
192
+	 * @throws EE_Error
193
+	 */
194
+	public function get_all_default_prices($count = false)
195
+	{
196
+		$_where = array(
197
+			'Price_Type.PBT_ID' => array('!=', 4),
198
+			'PRC_deleted'       => 0,
199
+			'PRC_is_default'    => 1,
200
+		);
201
+		$_query_params = array(
202
+			$_where,
203
+			'order_by' => $this->_order_by_array_for_get_all_method(),
204
+		);
205
+		return $count ? $this->count(array($_where)) : $this->get_all($_query_params);
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * retrieve all prices that are taxes
211
-     *
212
-     * @return EE_Base_Class[]|EE_PRice[]
213
-     * @throws EE_Error
214
-     * @throws InvalidArgumentException
215
-     * @throws ReflectionException
216
-     * @throws InvalidDataTypeException
217
-     * @throws InvalidInterfaceException
218
-     */
219
-    public function get_all_prices_that_are_taxes()
220
-    {
221
-        $taxes = array();
222
-        $all_taxes = $this->get_all(array(
223
-            array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax),
224
-            'order_by' => array('Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'),
225
-        ));
226
-        foreach ($all_taxes as $tax) {
227
-            if ($tax instanceof EE_Price) {
228
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
229
-            }
230
-        }
231
-        return $taxes;
232
-    }
209
+	/**
210
+	 * retrieve all prices that are taxes
211
+	 *
212
+	 * @return EE_Base_Class[]|EE_PRice[]
213
+	 * @throws EE_Error
214
+	 * @throws InvalidArgumentException
215
+	 * @throws ReflectionException
216
+	 * @throws InvalidDataTypeException
217
+	 * @throws InvalidInterfaceException
218
+	 */
219
+	public function get_all_prices_that_are_taxes()
220
+	{
221
+		$taxes = array();
222
+		$all_taxes = $this->get_all(array(
223
+			array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax),
224
+			'order_by' => array('Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'),
225
+		));
226
+		foreach ($all_taxes as $tax) {
227
+			if ($tax instanceof EE_Price) {
228
+				$taxes[ $tax->order() ][ $tax->ID() ] = $tax;
229
+			}
230
+		}
231
+		return $taxes;
232
+	}
233 233
 
234 234
 
235
-    /**
236
-     * retrieve all prices for an ticket plus default global prices, but not taxes
237
-     *
238
-     * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
239
-     * @return EE_Base_Class[]|EE_PRice[]|boolean
240
-     * @throws EE_Error
241
-     */
242
-    public function get_all_ticket_prices_for_admin($TKT_ID = 0)
243
-    {
244
-        $array_of_price_objects = array();
245
-        if (empty($TKT_ID)) {
246
-            // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
247
-            // return that list
248
-            $default_prices = $this->get_all_default_prices();
235
+	/**
236
+	 * retrieve all prices for an ticket plus default global prices, but not taxes
237
+	 *
238
+	 * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
239
+	 * @return EE_Base_Class[]|EE_PRice[]|boolean
240
+	 * @throws EE_Error
241
+	 */
242
+	public function get_all_ticket_prices_for_admin($TKT_ID = 0)
243
+	{
244
+		$array_of_price_objects = array();
245
+		if (empty($TKT_ID)) {
246
+			// if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
247
+			// return that list
248
+			$default_prices = $this->get_all_default_prices();
249 249
 
250
-            if ($default_prices) {
251
-                foreach ($default_prices as $price) {
252
-                    if ($price instanceof EE_Price) {
253
-                        $array_of_price_objects[ $price->type() ][] = $price;
254
-                    }
255
-                }
256
-                return $array_of_price_objects;
257
-            }
258
-            return array();
259
-        }
260
-        $ticket_prices = $this->get_all(array(
261
-            array(
262
-                'TKT_ID'      => $TKT_ID,
263
-                'PRC_deleted' => 0,
264
-            ),
265
-            'order_by' => array('PRC_order' => 'ASC'),
266
-        ));
250
+			if ($default_prices) {
251
+				foreach ($default_prices as $price) {
252
+					if ($price instanceof EE_Price) {
253
+						$array_of_price_objects[ $price->type() ][] = $price;
254
+					}
255
+				}
256
+				return $array_of_price_objects;
257
+			}
258
+			return array();
259
+		}
260
+		$ticket_prices = $this->get_all(array(
261
+			array(
262
+				'TKT_ID'      => $TKT_ID,
263
+				'PRC_deleted' => 0,
264
+			),
265
+			'order_by' => array('PRC_order' => 'ASC'),
266
+		));
267 267
 
268
-        if (! empty($ticket_prices)) {
269
-            foreach ($ticket_prices as $price) {
270
-                if ($price instanceof EE_Price) {
271
-                    $array_of_price_objects[ $price->type() ][] = $price;
272
-                }
273
-            }
274
-            return $array_of_price_objects;
275
-        }
276
-        return false;
277
-    }
268
+		if (! empty($ticket_prices)) {
269
+			foreach ($ticket_prices as $price) {
270
+				if ($price instanceof EE_Price) {
271
+					$array_of_price_objects[ $price->type() ][] = $price;
272
+				}
273
+			}
274
+			return $array_of_price_objects;
275
+		}
276
+		return false;
277
+	}
278 278
 
279 279
 
280
-    /**
281
-     * _sort_event_prices_by_type
282
-     *
283
-     * @param EE_Price $price_a
284
-     * @param EE_Price $price_b
285
-     * @return bool false on fail
286
-     */
287
-    public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
288
-    {
289
-        if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
290
-            return $this->_sort_event_prices_by_order($price_a, $price_b);
291
-        }
292
-        return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
293
-    }
280
+	/**
281
+	 * _sort_event_prices_by_type
282
+	 *
283
+	 * @param EE_Price $price_a
284
+	 * @param EE_Price $price_b
285
+	 * @return bool false on fail
286
+	 */
287
+	public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
288
+	{
289
+		if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
290
+			return $this->_sort_event_prices_by_order($price_a, $price_b);
291
+		}
292
+		return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
293
+	}
294 294
 
295 295
 
296
-    /**
297
-     *        _sort_event_prices_by_order
298
-     *
299
-     * @param EE_Price $price_a
300
-     * @param EE_Price $price_b
301
-     * @return bool false on fail
302
-     */
303
-    public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
304
-    {
305
-        if ($price_a->order() === $price_b->order()) {
306
-            return 0;
307
-        }
308
-        return $price_a->order() < $price_b->order() ? -1 : 1;
309
-    }
296
+	/**
297
+	 *        _sort_event_prices_by_order
298
+	 *
299
+	 * @param EE_Price $price_a
300
+	 * @param EE_Price $price_b
301
+	 * @return bool false on fail
302
+	 */
303
+	public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
304
+	{
305
+		if ($price_a->order() === $price_b->order()) {
306
+			return 0;
307
+		}
308
+		return $price_a->order() < $price_b->order() ? -1 : 1;
309
+	}
310 310
 
311 311
 
312
-    /**
313
-     * get all prices of a specific type
314
-     *
315
-     * @param int $type - PRT_ID
316
-     * @return EE_Base_Class[]|EE_PRice[]
317
-     * @throws EE_Error
318
-     */
319
-    public function get_all_prices_that_are_type($type = 0)
320
-    {
321
-        return $this->get_all(array(
322
-            array(
323
-                'PRT_ID' => $type,
324
-            ),
325
-            'order_by' => $this->_order_by_array_for_get_all_method(),
326
-        ));
327
-    }
312
+	/**
313
+	 * get all prices of a specific type
314
+	 *
315
+	 * @param int $type - PRT_ID
316
+	 * @return EE_Base_Class[]|EE_PRice[]
317
+	 * @throws EE_Error
318
+	 */
319
+	public function get_all_prices_that_are_type($type = 0)
320
+	{
321
+		return $this->get_all(array(
322
+			array(
323
+				'PRT_ID' => $type,
324
+			),
325
+			'order_by' => $this->_order_by_array_for_get_all_method(),
326
+		));
327
+	}
328 328
 
329 329
 
330
-    /**
331
-     * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
332
-     * Of course you don't have to use it, but this is the order we usually want to sort prices by
333
-     *
334
-     * @return array which can be used like so: $this->get_all(array(array(...where
335
-     *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
336
-     */
337
-    public function _order_by_array_for_get_all_method()
338
-    {
339
-        return array(
340
-            'PRC_order'            => 'ASC',
341
-            'Price_Type.PRT_order' => 'ASC',
342
-            'PRC_ID'               => 'ASC',
343
-        );
344
-    }
330
+	/**
331
+	 * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
332
+	 * Of course you don't have to use it, but this is the order we usually want to sort prices by
333
+	 *
334
+	 * @return array which can be used like so: $this->get_all(array(array(...where
335
+	 *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
336
+	 */
337
+	public function _order_by_array_for_get_all_method()
338
+	{
339
+		return array(
340
+			'PRC_order'            => 'ASC',
341
+			'Price_Type.PRT_order' => 'ASC',
342
+			'PRC_ID'               => 'ASC',
343
+		);
344
+	}
345 345
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     protected function __construct($timezone)
31 31
     {
32
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
32
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
33 33
         $this->singular_item = __('Price', 'event_espresso');
34 34
         $this->plural_item = __('Prices', 'event_espresso');
35 35
 
@@ -116,23 +116,23 @@  discard block
 block discarded – undo
116 116
             'WP_User'    => new EE_Belongs_To_Relation(),
117 117
         );
118 118
         // this model is generally available for reading
119
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] =
119
+        $this->_cap_restriction_generators[EEM_Base::caps_read] =
120 120
             new EE_Restriction_Generator_Default_Public(
121 121
                 'PRC_is_default',
122 122
                 'Ticket.Datetime.Event'
123 123
             );
124 124
         // account for default tickets in the caps
125
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
125
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] =
126 126
             new EE_Restriction_Generator_Default_Protected(
127 127
                 'PRC_is_default',
128 128
                 'Ticket.Datetime.Event'
129 129
             );
130
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] =
130
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] =
131 131
             new EE_Restriction_Generator_Default_Protected(
132 132
                 'PRC_is_default',
133 133
                 'Ticket.Datetime.Event'
134 134
             );
135
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] =
135
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] =
136 136
             new EE_Restriction_Generator_Default_Protected(
137 137
                 'PRC_is_default',
138 138
                 'Ticket.Datetime.Event'
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         ));
226 226
         foreach ($all_taxes as $tax) {
227 227
             if ($tax instanceof EE_Price) {
228
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
228
+                $taxes[$tax->order()][$tax->ID()] = $tax;
229 229
             }
230 230
         }
231 231
         return $taxes;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             if ($default_prices) {
251 251
                 foreach ($default_prices as $price) {
252 252
                     if ($price instanceof EE_Price) {
253
-                        $array_of_price_objects[ $price->type() ][] = $price;
253
+                        $array_of_price_objects[$price->type()][] = $price;
254 254
                     }
255 255
                 }
256 256
                 return $array_of_price_objects;
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
             'order_by' => array('PRC_order' => 'ASC'),
266 266
         ));
267 267
 
268
-        if (! empty($ticket_prices)) {
268
+        if ( ! empty($ticket_prices)) {
269 269
             foreach ($ticket_prices as $price) {
270 270
                 if ($price instanceof EE_Price) {
271
-                    $array_of_price_objects[ $price->type() ][] = $price;
271
+                    $array_of_price_objects[$price->type()][] = $price;
272 272
                 }
273 273
             }
274 274
             return $array_of_price_objects;
Please login to merge, or discard this patch.
core/domain/services/admin/events/editor/AdvancedEditorEntityData.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 use EE_Datetime;
8 8
 use EE_Error;
9 9
 use EE_Event;
10
-use EEH_DTT_Helper;
11 10
 use EEM_Datetime;
12 11
 use EEM_Event;
13 12
 use EEM_Price;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     {
139 139
         if ($this->admin_config->useAdvancedEditor()) {
140 140
             $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
141
-            if (! $eventId) {
141
+            if ( ! $eventId) {
142 142
                 global $post;
143 143
                 $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
144 144
                 $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                 $data = wp_json_encode($data);
151 151
                 add_action(
152 152
                     'admin_footer',
153
-                    static function () use ($data) {
153
+                    static function() use ($data) {
154 154
                         wp_add_inline_script(
155 155
                             EspressoEditorAssetManager::JS_HANDLE_EDITOR,
156 156
                             "var eeEditorEventData={$data};",
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
             $this->event_model,
254 254
             [['EVT_ID' => $eventId]]
255 255
         );
256
-        if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
256
+        if ( ! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
257 257
             return [];
258 258
         }
259 259
         $eventDates = $this->getEventDates($eventId);
260
-        if ((! is_array($eventDates) || empty($eventDates))
260
+        if (( ! is_array($eventDates) || empty($eventDates))
261 261
             || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')
262 262
         ) {
263 263
             $this->addDefaultEntities($eventId);
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
             foreach ($eventDates as $eventDate) {
283 283
                 if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
284 284
                     $DTT_ID = $eventDate['DTT_ID'];
285
-                    $datetimes[ $DTT_ID ] = $eventDate;
286
-                    $relations['event'][ $eventId ]['datetime'][] = $DTT_ID;
287
-                    $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults(
285
+                    $datetimes[$DTT_ID] = $eventDate;
286
+                    $relations['event'][$eventId]['datetime'][] = $DTT_ID;
287
+                    $eventDateTickets[$DTT_ID] = $this->spoofer->getApiResults(
288 288
                         $this->ticket_model,
289 289
                         [[
290 290
                             'Datetime.DTT_ID' => $DTT_ID,
@@ -300,22 +300,22 @@  discard block
 block discarded – undo
300 300
         if (is_array($eventDateTickets)) {
301 301
             foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
302 302
                 if (is_array($dateTickets)) {
303
-                    $relations['datetime'][ $DTT_ID ]['ticket'] = [];
303
+                    $relations['datetime'][$DTT_ID]['ticket'] = [];
304 304
                     foreach ($dateTickets as $ticket) {
305 305
                         if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
306 306
                             $TKT_ID = $ticket['TKT_ID'];
307
-                            $tickets[ $TKT_ID ] = $ticket;
308
-                            $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID;
309
-                            $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults(
307
+                            $tickets[$TKT_ID] = $ticket;
308
+                            $relations['datetime'][$DTT_ID]['ticket'][] = $TKT_ID;
309
+                            $ticketPrices[$TKT_ID] = $this->spoofer->getApiResults(
310 310
                                 $this->price_model,
311 311
                                 [['Ticket.TKT_ID' => $TKT_ID]]
312 312
                             );
313
-                            if (is_array($ticketPrices[ $TKT_ID ])) {
314
-                                $relations['ticket'][ $TKT_ID ]['price'] = [];
315
-                                foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
313
+                            if (is_array($ticketPrices[$TKT_ID])) {
314
+                                $relations['ticket'][$TKT_ID]['price'] = [];
315
+                                foreach ($ticketPrices[$TKT_ID] as $ticketPrice) {
316 316
                                     $PRC_ID = $ticketPrice['PRC_ID'];
317
-                                    $prices[ $PRC_ID ] = $ticketPrice;
318
-                                    $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
317
+                                    $prices[$PRC_ID] = $ticketPrice;
318
+                                    $relations['ticket'][$TKT_ID]['price'][] = $PRC_ID;
319 319
                                 }
320 320
                             }
321 321
                         }
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
         );
330 330
         $price_types = [];
331 331
         foreach ($price_type_results as $price_type) {
332
-            $price_types[ $price_type['PRT_ID'] ] = $price_type;
332
+            $price_types[$price_type['PRT_ID']] = $price_type;
333 333
         }
334 334
         $venue = $this->spoofer->getOneApiResult(
335 335
             $this->venue_model,
336 336
             [['Event.EVT_ID' => $eventId]]
337 337
         );
338 338
         if (is_array($venue) && isset($venue['VNU_ID'])) {
339
-            $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
339
+            $relations['event'][$eventId]['venue'] = [$venue['VNU_ID']];
340 340
             $venue = [$venue['VNU_ID'] => $venue];
341 341
         }
342 342
 
Please login to merge, or discard this patch.
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -39,337 +39,337 @@
 block discarded – undo
39 39
 class AdvancedEditorEntityData
40 40
 {
41 41
 
42
-    /**
43
-     * @var EE_Event
44
-     */
45
-    protected $event;
42
+	/**
43
+	 * @var EE_Event
44
+	 */
45
+	protected $event;
46 46
 
47
-    /**
48
-     * @var RestApiSpoofer
49
-     */
50
-    protected $spoofer;
47
+	/**
48
+	 * @var RestApiSpoofer
49
+	 */
50
+	protected $spoofer;
51 51
 
52
-    /**
53
-     * @var EE_Admin_Config
54
-     */
55
-    protected $admin_config;
52
+	/**
53
+	 * @var EE_Admin_Config
54
+	 */
55
+	protected $admin_config;
56 56
 
57
-    /**
58
-     * @var EEM_Datetime $datetime_model
59
-     */
60
-    protected $datetime_model;
57
+	/**
58
+	 * @var EEM_Datetime $datetime_model
59
+	 */
60
+	protected $datetime_model;
61 61
 
62
-    /**
63
-     * @var EEM_Event $event_model
64
-     */
65
-    protected $event_model;
62
+	/**
63
+	 * @var EEM_Event $event_model
64
+	 */
65
+	protected $event_model;
66 66
 
67
-    /**
68
-     * @var EEM_Price $price_model
69
-     */
70
-    protected $price_model;
67
+	/**
68
+	 * @var EEM_Price $price_model
69
+	 */
70
+	protected $price_model;
71 71
 
72
-    /**
73
-     * @var EEM_Price_Type $price_type_model
74
-     */
75
-    protected $price_type_model;
72
+	/**
73
+	 * @var EEM_Price_Type $price_type_model
74
+	 */
75
+	protected $price_type_model;
76 76
 
77
-    /**
78
-     * @var EEM_Ticket $ticket_model
79
-     */
80
-    protected $ticket_model;
81
-    /**
82
-     * @var EEM_Venue $venue_model
83
-     */
84
-    protected $venue_model;
77
+	/**
78
+	 * @var EEM_Ticket $ticket_model
79
+	 */
80
+	protected $ticket_model;
81
+	/**
82
+	 * @var EEM_Venue $venue_model
83
+	 */
84
+	protected $venue_model;
85 85
 
86 86
 
87
-    /**
88
-     * AdvancedEditorAdminForm constructor.
89
-     *
90
-     * @param EE_Event        $event
91
-     * @param RestApiSpoofer  $spoofer
92
-     * @param EE_Admin_Config $admin_config
93
-     * @param EEM_Datetime    $datetime_model
94
-     * @param EEM_Event       $event_model
95
-     * @param EEM_Price       $price_model
96
-     * @param EEM_Price_Type  $price_type_model
97
-     * @param EEM_Ticket      $ticket_model
98
-     * @param EEM_Venue       $venue_model
99
-     */
100
-    public function __construct(
101
-        EE_Event $event,
102
-        RestApiSpoofer $spoofer,
103
-        EE_Admin_Config $admin_config,
104
-        EEM_Datetime $datetime_model,
105
-        EEM_Event $event_model,
106
-        EEM_Price $price_model,
107
-        EEM_Price_Type $price_type_model,
108
-        EEM_Ticket $ticket_model,
109
-        EEM_Venue $venue_model
110
-    ) {
111
-        $this->event = $event;
112
-        $this->admin_config = $admin_config;
113
-        $this->spoofer = $spoofer;
114
-        $this->datetime_model = $datetime_model;
115
-        $this->event_model = $event_model;
116
-        $this->price_model = $price_model;
117
-        $this->price_type_model = $price_type_model;
118
-        $this->ticket_model = $ticket_model;
119
-        $this->venue_model = $venue_model;
120
-        add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
121
-    }
87
+	/**
88
+	 * AdvancedEditorAdminForm constructor.
89
+	 *
90
+	 * @param EE_Event        $event
91
+	 * @param RestApiSpoofer  $spoofer
92
+	 * @param EE_Admin_Config $admin_config
93
+	 * @param EEM_Datetime    $datetime_model
94
+	 * @param EEM_Event       $event_model
95
+	 * @param EEM_Price       $price_model
96
+	 * @param EEM_Price_Type  $price_type_model
97
+	 * @param EEM_Ticket      $ticket_model
98
+	 * @param EEM_Venue       $venue_model
99
+	 */
100
+	public function __construct(
101
+		EE_Event $event,
102
+		RestApiSpoofer $spoofer,
103
+		EE_Admin_Config $admin_config,
104
+		EEM_Datetime $datetime_model,
105
+		EEM_Event $event_model,
106
+		EEM_Price $price_model,
107
+		EEM_Price_Type $price_type_model,
108
+		EEM_Ticket $ticket_model,
109
+		EEM_Venue $venue_model
110
+	) {
111
+		$this->event = $event;
112
+		$this->admin_config = $admin_config;
113
+		$this->spoofer = $spoofer;
114
+		$this->datetime_model = $datetime_model;
115
+		$this->event_model = $event_model;
116
+		$this->price_model = $price_model;
117
+		$this->price_type_model = $price_type_model;
118
+		$this->ticket_model = $ticket_model;
119
+		$this->venue_model = $venue_model;
120
+		add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
121
+	}
122 122
 
123 123
 
124
-    /**
125
-     * @throws EE_Error
126
-     * @throws InvalidArgumentException
127
-     * @throws InvalidDataTypeException
128
-     * @throws InvalidInterfaceException
129
-     * @throws ModelConfigurationException
130
-     * @throws ReflectionException
131
-     * @throws RestException
132
-     * @throws RestPasswordIncorrectException
133
-     * @throws RestPasswordRequiredException
134
-     * @throws UnexpectedEntityException
135
-     * @throws DomainException
136
-     * @since $VID:$
137
-     */
138
-    public function loadScriptsStyles()
139
-    {
140
-        if ($this->admin_config->useAdvancedEditor()) {
141
-            $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
142
-            if (! $eventId) {
143
-                global $post;
144
-                $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
145
-                $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
146
-                    ? $post->ID
147
-                    : $eventId;
148
-            }
149
-            if ($eventId) {
150
-                $data = $this->getAllEventData($eventId);
151
-                $data = wp_json_encode($data);
152
-                add_action(
153
-                    'admin_footer',
154
-                    static function () use ($data) {
155
-                        wp_add_inline_script(
156
-                            EspressoEditorAssetManager::JS_HANDLE_EDITOR,
157
-                            "var eeEditorEventData={$data};",
158
-                            'before'
159
-                        );
160
-                    }
161
-                );
162
-            }
163
-        }
164
-    }
124
+	/**
125
+	 * @throws EE_Error
126
+	 * @throws InvalidArgumentException
127
+	 * @throws InvalidDataTypeException
128
+	 * @throws InvalidInterfaceException
129
+	 * @throws ModelConfigurationException
130
+	 * @throws ReflectionException
131
+	 * @throws RestException
132
+	 * @throws RestPasswordIncorrectException
133
+	 * @throws RestPasswordRequiredException
134
+	 * @throws UnexpectedEntityException
135
+	 * @throws DomainException
136
+	 * @since $VID:$
137
+	 */
138
+	public function loadScriptsStyles()
139
+	{
140
+		if ($this->admin_config->useAdvancedEditor()) {
141
+			$eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
142
+			if (! $eventId) {
143
+				global $post;
144
+				$eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
145
+				$eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
146
+					? $post->ID
147
+					: $eventId;
148
+			}
149
+			if ($eventId) {
150
+				$data = $this->getAllEventData($eventId);
151
+				$data = wp_json_encode($data);
152
+				add_action(
153
+					'admin_footer',
154
+					static function () use ($data) {
155
+						wp_add_inline_script(
156
+							EspressoEditorAssetManager::JS_HANDLE_EDITOR,
157
+							"var eeEditorEventData={$data};",
158
+							'before'
159
+						);
160
+					}
161
+				);
162
+			}
163
+		}
164
+	}
165 165
 
166 166
 
167
-    /**
168
-     * @param int $eventId
169
-     * @return array
170
-     * @throws DomainException
171
-     * @throws EE_Error
172
-     * @throws InvalidArgumentException
173
-     * @throws InvalidDataTypeException
174
-     * @throws InvalidInterfaceException
175
-     * @throws ModelConfigurationException
176
-     * @throws ReflectionException
177
-     * @throws RestException
178
-     * @throws RestPasswordIncorrectException
179
-     * @throws RestPasswordRequiredException
180
-     * @throws UnexpectedEntityException
181
-     * @since $VID:$
182
-     */
183
-    protected function getEventDates($eventId)
184
-    {
185
-        return $this->spoofer->getApiResults(
186
-            $this->datetime_model,
187
-            [
188
-                [
189
-                    'EVT_ID'      => $eventId,
190
-                    'DTT_deleted' => ['IN', [true, false]]
191
-                ]
192
-            ]
193
-        );
194
-    }
167
+	/**
168
+	 * @param int $eventId
169
+	 * @return array
170
+	 * @throws DomainException
171
+	 * @throws EE_Error
172
+	 * @throws InvalidArgumentException
173
+	 * @throws InvalidDataTypeException
174
+	 * @throws InvalidInterfaceException
175
+	 * @throws ModelConfigurationException
176
+	 * @throws ReflectionException
177
+	 * @throws RestException
178
+	 * @throws RestPasswordIncorrectException
179
+	 * @throws RestPasswordRequiredException
180
+	 * @throws UnexpectedEntityException
181
+	 * @since $VID:$
182
+	 */
183
+	protected function getEventDates($eventId)
184
+	{
185
+		return $this->spoofer->getApiResults(
186
+			$this->datetime_model,
187
+			[
188
+				[
189
+					'EVT_ID'      => $eventId,
190
+					'DTT_deleted' => ['IN', [true, false]]
191
+				]
192
+			]
193
+		);
194
+	}
195 195
 
196 196
 
197
-    /**
198
-     * @param int $eventId
199
-     * @param array $eventDates
200
-     * @throws DomainException
201
-     * @throws EE_Error
202
-     * @throws InvalidArgumentException
203
-     * @throws InvalidDataTypeException
204
-     * @throws InvalidInterfaceException
205
-     * @throws ModelConfigurationException
206
-     * @throws ReflectionException
207
-     * @throws RestException
208
-     * @throws RestPasswordIncorrectException
209
-     * @throws RestPasswordRequiredException
210
-     * @throws UnexpectedEntityException
211
-     * @since $VID:$
212
-     */
213
-    protected function addDefaultEntities($eventId, array $eventDates = [])
214
-    {
215
-        $default_dates = $this->datetime_model->create_new_blank_datetime();
216
-        if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) {
217
-            $default_date = $default_dates[0];
218
-            $default_date->save();
219
-            $default_date->_add_relation_to($eventId, 'Event');
220
-            $default_tickets = $this->ticket_model->get_all_default_tickets();
221
-            $default_prices = $this->price_model->get_all_default_prices();
222
-            foreach ($default_tickets as $default_ticket) {
223
-                $default_ticket->save();
224
-                $default_ticket->_add_relation_to($default_date, 'Datetime');
225
-                foreach ($default_prices as $default_price) {
226
-                    $default_price->save();
227
-                    $default_price->_add_relation_to($default_ticket, 'Ticket');
228
-                }
229
-            }
230
-        }
231
-    }
197
+	/**
198
+	 * @param int $eventId
199
+	 * @param array $eventDates
200
+	 * @throws DomainException
201
+	 * @throws EE_Error
202
+	 * @throws InvalidArgumentException
203
+	 * @throws InvalidDataTypeException
204
+	 * @throws InvalidInterfaceException
205
+	 * @throws ModelConfigurationException
206
+	 * @throws ReflectionException
207
+	 * @throws RestException
208
+	 * @throws RestPasswordIncorrectException
209
+	 * @throws RestPasswordRequiredException
210
+	 * @throws UnexpectedEntityException
211
+	 * @since $VID:$
212
+	 */
213
+	protected function addDefaultEntities($eventId, array $eventDates = [])
214
+	{
215
+		$default_dates = $this->datetime_model->create_new_blank_datetime();
216
+		if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) {
217
+			$default_date = $default_dates[0];
218
+			$default_date->save();
219
+			$default_date->_add_relation_to($eventId, 'Event');
220
+			$default_tickets = $this->ticket_model->get_all_default_tickets();
221
+			$default_prices = $this->price_model->get_all_default_prices();
222
+			foreach ($default_tickets as $default_ticket) {
223
+				$default_ticket->save();
224
+				$default_ticket->_add_relation_to($default_date, 'Datetime');
225
+				foreach ($default_prices as $default_price) {
226
+					$default_price->save();
227
+					$default_price->_add_relation_to($default_ticket, 'Ticket');
228
+				}
229
+			}
230
+		}
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * @param int $eventId
236
-     * @return array
237
-     * @throws EE_Error
238
-     * @throws InvalidDataTypeException
239
-     * @throws InvalidInterfaceException
240
-     * @throws ModelConfigurationException
241
-     * @throws RestPasswordIncorrectException
242
-     * @throws RestPasswordRequiredException
243
-     * @throws UnexpectedEntityException
244
-     * @throws RestException
245
-     * @throws InvalidArgumentException
246
-     * @throws ReflectionException
247
-     * @throws DomainException
248
-     * @since $VID:$
249
-     */
250
-    protected function getAllEventData($eventId)
251
-    {
252
-        // these should ultimately be extracted out into their own classes (one per model)
253
-        $event = $this->spoofer->getOneApiResult(
254
-            $this->event_model,
255
-            [['EVT_ID' => $eventId]]
256
-        );
257
-        if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
258
-            return [];
259
-        }
260
-        $eventDates = $this->getEventDates($eventId);
261
-        if ((! is_array($eventDates) || empty($eventDates))
262
-            || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')
263
-        ) {
264
-            $this->addDefaultEntities($eventId);
265
-            $eventDates = $this->getEventDates($eventId);
266
-        }
234
+	/**
235
+	 * @param int $eventId
236
+	 * @return array
237
+	 * @throws EE_Error
238
+	 * @throws InvalidDataTypeException
239
+	 * @throws InvalidInterfaceException
240
+	 * @throws ModelConfigurationException
241
+	 * @throws RestPasswordIncorrectException
242
+	 * @throws RestPasswordRequiredException
243
+	 * @throws UnexpectedEntityException
244
+	 * @throws RestException
245
+	 * @throws InvalidArgumentException
246
+	 * @throws ReflectionException
247
+	 * @throws DomainException
248
+	 * @since $VID:$
249
+	 */
250
+	protected function getAllEventData($eventId)
251
+	{
252
+		// these should ultimately be extracted out into their own classes (one per model)
253
+		$event = $this->spoofer->getOneApiResult(
254
+			$this->event_model,
255
+			[['EVT_ID' => $eventId]]
256
+		);
257
+		if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
258
+			return [];
259
+		}
260
+		$eventDates = $this->getEventDates($eventId);
261
+		if ((! is_array($eventDates) || empty($eventDates))
262
+			|| (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')
263
+		) {
264
+			$this->addDefaultEntities($eventId);
265
+			$eventDates = $this->getEventDates($eventId);
266
+		}
267 267
 
268
-        $event = [$eventId => $event];
269
-        $relations = [
270
-            'event'    => [
271
-                $eventId => [
272
-                    'datetime' => []
273
-                ]
274
-            ],
275
-            'datetime' => [],
276
-            'ticket'   => [],
277
-            'price'    => [],
278
-        ];
268
+		$event = [$eventId => $event];
269
+		$relations = [
270
+			'event'    => [
271
+				$eventId => [
272
+					'datetime' => []
273
+				]
274
+			],
275
+			'datetime' => [],
276
+			'ticket'   => [],
277
+			'price'    => [],
278
+		];
279 279
 
280
-        $datetimes = [];
281
-        $eventDateTickets = [];
282
-        if (is_array($eventDates)) {
283
-            foreach ($eventDates as $eventDate) {
284
-                if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
285
-                    $DTT_ID = $eventDate['DTT_ID'];
286
-                    $datetimes[ $DTT_ID ] = $eventDate;
287
-                    $relations['event'][ $eventId ]['datetime'][] = $DTT_ID;
288
-                    $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults(
289
-                        $this->ticket_model,
290
-                        [[
291
-                            'Datetime.DTT_ID' => $DTT_ID,
292
-                            'TKT_deleted' => ['IN', [true, false]]
293
-                        ]]
294
-                    );
295
-                }
296
-            }
297
-        }
280
+		$datetimes = [];
281
+		$eventDateTickets = [];
282
+		if (is_array($eventDates)) {
283
+			foreach ($eventDates as $eventDate) {
284
+				if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
285
+					$DTT_ID = $eventDate['DTT_ID'];
286
+					$datetimes[ $DTT_ID ] = $eventDate;
287
+					$relations['event'][ $eventId ]['datetime'][] = $DTT_ID;
288
+					$eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults(
289
+						$this->ticket_model,
290
+						[[
291
+							'Datetime.DTT_ID' => $DTT_ID,
292
+							'TKT_deleted' => ['IN', [true, false]]
293
+						]]
294
+					);
295
+				}
296
+			}
297
+		}
298 298
 
299
-        $prices = [];
300
-        $tickets = [];
301
-        if (is_array($eventDateTickets)) {
302
-            foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
303
-                if (is_array($dateTickets)) {
304
-                    $relations['datetime'][ $DTT_ID ]['ticket'] = [];
305
-                    foreach ($dateTickets as $ticket) {
306
-                        if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
307
-                            $TKT_ID = $ticket['TKT_ID'];
308
-                            $tickets[ $TKT_ID ] = $ticket;
309
-                            $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID;
310
-                            $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults(
311
-                                $this->price_model,
312
-                                [['Ticket.TKT_ID' => $TKT_ID]]
313
-                            );
314
-                            if (is_array($ticketPrices[ $TKT_ID ])) {
315
-                                $relations['ticket'][ $TKT_ID ]['price'] = [];
316
-                                foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
317
-                                    $PRC_ID = $ticketPrice['PRC_ID'];
318
-                                    $prices[ $PRC_ID ] = $ticketPrice;
319
-                                    $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
320
-                                }
321
-                            }
322
-                        }
323
-                    }
324
-                }
325
-            }
326
-        }
327
-        $price_type_results = $this->spoofer->getApiResults(
328
-            $this->price_type_model,
329
-            [['PRT_deleted' => false]]
330
-        );
331
-        $price_types = [];
332
-        foreach ($price_type_results as $price_type) {
333
-            $price_types[ $price_type['PRT_ID'] ] = $price_type;
334
-        }
335
-        $venue = $this->spoofer->getOneApiResult(
336
-            $this->venue_model,
337
-            [['Event.EVT_ID' => $eventId]]
338
-        );
339
-        if (is_array($venue) && isset($venue['VNU_ID'])) {
340
-            $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
341
-            $venue = [$venue['VNU_ID'] => $venue];
342
-        }
299
+		$prices = [];
300
+		$tickets = [];
301
+		if (is_array($eventDateTickets)) {
302
+			foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
303
+				if (is_array($dateTickets)) {
304
+					$relations['datetime'][ $DTT_ID ]['ticket'] = [];
305
+					foreach ($dateTickets as $ticket) {
306
+						if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
307
+							$TKT_ID = $ticket['TKT_ID'];
308
+							$tickets[ $TKT_ID ] = $ticket;
309
+							$relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID;
310
+							$ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults(
311
+								$this->price_model,
312
+								[['Ticket.TKT_ID' => $TKT_ID]]
313
+							);
314
+							if (is_array($ticketPrices[ $TKT_ID ])) {
315
+								$relations['ticket'][ $TKT_ID ]['price'] = [];
316
+								foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
317
+									$PRC_ID = $ticketPrice['PRC_ID'];
318
+									$prices[ $PRC_ID ] = $ticketPrice;
319
+									$relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
320
+								}
321
+							}
322
+						}
323
+					}
324
+				}
325
+			}
326
+		}
327
+		$price_type_results = $this->spoofer->getApiResults(
328
+			$this->price_type_model,
329
+			[['PRT_deleted' => false]]
330
+		);
331
+		$price_types = [];
332
+		foreach ($price_type_results as $price_type) {
333
+			$price_types[ $price_type['PRT_ID'] ] = $price_type;
334
+		}
335
+		$venue = $this->spoofer->getOneApiResult(
336
+			$this->venue_model,
337
+			[['Event.EVT_ID' => $eventId]]
338
+		);
339
+		if (is_array($venue) && isset($venue['VNU_ID'])) {
340
+			$relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
341
+			$venue = [$venue['VNU_ID'] => $venue];
342
+		}
343 343
 
344
-        $schemas = [
345
-            'event'      => $this->spoofer->getModelSchema('events'),
346
-            'datetime'   => $this->spoofer->getModelSchema('datetimes'),
347
-            'ticket'     => $this->spoofer->getModelSchema('tickets'),
348
-            'price'      => $this->spoofer->getModelSchema('prices'),
349
-            'price_type' => $this->spoofer->getModelSchema('price_types'),
350
-            'venue'      => $this->spoofer->getModelSchema('venues'),
351
-        ];
344
+		$schemas = [
345
+			'event'      => $this->spoofer->getModelSchema('events'),
346
+			'datetime'   => $this->spoofer->getModelSchema('datetimes'),
347
+			'ticket'     => $this->spoofer->getModelSchema('tickets'),
348
+			'price'      => $this->spoofer->getModelSchema('prices'),
349
+			'price_type' => $this->spoofer->getModelSchema('price_types'),
350
+			'venue'      => $this->spoofer->getModelSchema('venues'),
351
+		];
352 352
 
353
-        $tktRegCount = [];
354
-        foreach ($tickets as $ticket) {
355
-            $tkt_instance = $this->ticket_model->get_one_by_ID($ticket['TKT_ID']);
353
+		$tktRegCount = [];
354
+		foreach ($tickets as $ticket) {
355
+			$tkt_instance = $this->ticket_model->get_one_by_ID($ticket['TKT_ID']);
356 356
 
357
-            $tktRegCount[$ticket['TKT_ID']] = $tkt_instance instanceof EE_Ticket ?
358
-            $tkt_instance->count_registrations()
359
-            : 0;
360
-        }
357
+			$tktRegCount[$ticket['TKT_ID']] = $tkt_instance instanceof EE_Ticket ?
358
+			$tkt_instance->count_registrations()
359
+			: 0;
360
+		}
361 361
 
362
-        return [
363
-            'eventId'     => $eventId,
364
-            'event'       => $event,
365
-            'datetime'    => $datetimes,
366
-            'ticket'      => $tickets,
367
-            'price'       => $prices,
368
-            'price_type'  => $price_types,
369
-            'venue'       => $venue,
370
-            'schemas'     => $schemas,
371
-            'relations'   => $relations,
372
-            'tktRegCount' => $tktRegCount,
373
-        ];
374
-    }
362
+		return [
363
+			'eventId'     => $eventId,
364
+			'event'       => $event,
365
+			'datetime'    => $datetimes,
366
+			'ticket'      => $tickets,
367
+			'price'       => $prices,
368
+			'price_type'  => $price_types,
369
+			'venue'       => $venue,
370
+			'schemas'     => $schemas,
371
+			'relations'   => $relations,
372
+			'tktRegCount' => $tktRegCount,
373
+		];
374
+	}
375 375
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +3690 added lines, -3690 removed lines patch added patch discarded remove patch
@@ -18,2227 +18,2227 @@  discard block
 block discarded – undo
18 18
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
19 19
 {
20 20
 
21
-    /**
22
-     * @var EE_Registration
23
-     */
24
-    private $_registration;
25
-
26
-    /**
27
-     * @var EE_Event
28
-     */
29
-    private $_reg_event;
30
-
31
-    /**
32
-     * @var EE_Session
33
-     */
34
-    private $_session;
35
-
36
-    private static $_reg_status;
37
-
38
-    /**
39
-     * Form for displaying the custom questions for this registration.
40
-     * This gets used a few times throughout the request so its best to cache it
41
-     *
42
-     * @var EE_Registration_Custom_Questions_Form
43
-     */
44
-    protected $_reg_custom_questions_form;
45
-
46
-    /**
47
-     * @var EEM_Registration $registration_model
48
-     */
49
-    private $registration_model;
50
-
51
-    /**
52
-     * @var EEM_Attendee $attendee_model
53
-     */
54
-    private $attendee_model;
55
-
56
-    /**
57
-     * @var EEM_Event $event_model
58
-     */
59
-    private $event_model;
60
-
61
-    /**
62
-     * @var EEM_Status $status_model
63
-     */
64
-    private $status_model;
65
-
66
-
67
-    /**
68
-     * @param bool $routing
69
-     * @throws EE_Error
70
-     * @throws InvalidArgumentException
71
-     * @throws InvalidDataTypeException
72
-     * @throws InvalidInterfaceException
73
-     * @throws ReflectionException
74
-     */
75
-    public function __construct($routing = true)
76
-    {
77
-        parent::__construct($routing);
78
-        add_action('wp_loaded', array($this, 'wp_loaded'));
79
-    }
80
-
81
-    /**
82
-     * @return EEM_Registration
83
-     * @throws InvalidArgumentException
84
-     * @throws InvalidDataTypeException
85
-     * @throws InvalidInterfaceException
86
-     * @since 4.10.2.p
87
-     */
88
-    protected function getRegistrationModel()
89
-    {
90
-        if (! $this->registration_model instanceof EEM_Registration) {
91
-            $this->registration_model = $this->loader->getShared('EEM_Registration');
92
-        }
93
-        return $this->registration_model;
94
-    }
95
-
96
-    /**
97
-     * @return EEM_Attendee
98
-     * @throws InvalidArgumentException
99
-     * @throws InvalidDataTypeException
100
-     * @throws InvalidInterfaceException
101
-     * @since 4.10.2.p
102
-     */
103
-    protected function getAttendeeModel()
104
-    {
105
-        if (! $this->attendee_model instanceof EEM_Attendee) {
106
-            $this->attendee_model = $this->loader->getShared('EEM_Attendee');
107
-        }
108
-        return $this->attendee_model;
109
-    }
110
-
111
-
112
-    /**
113
-     * @return EEM_Event
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidInterfaceException
117
-     * @since 4.10.2.p
118
-     */
119
-    protected function getEventModel()
120
-    {
121
-        if (! $this->event_model instanceof EEM_Event) {
122
-            $this->event_model = $this->loader->getShared('EEM_Event');
123
-        }
124
-        return $this->event_model;
125
-    }
126
-
127
-    /**
128
-     * @return EEM_Status
129
-     * @throws InvalidArgumentException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidInterfaceException
132
-     * @since 4.10.2.p
133
-     */
134
-    protected function getStatusModel()
135
-    {
136
-        if (! $this->status_model instanceof EEM_Status) {
137
-            $this->status_model = $this->loader->getShared('EEM_Status');
138
-        }
139
-        return $this->status_model;
140
-    }
141
-
142
-
143
-    public function wp_loaded()
144
-    {
145
-        // when adding a new registration...
146
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
147
-            EE_System::do_not_cache();
148
-            if (! isset($this->_req_data['processing_registration'])
149
-                || absint($this->_req_data['processing_registration']) !== 1
150
-            ) {
151
-                // and it's NOT the attendee information reg step
152
-                // force cookie expiration by setting time to last week
153
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
154
-                // and update the global
155
-                $_COOKIE['ee_registration_added'] = 0;
156
-            }
157
-        }
158
-    }
159
-
160
-
161
-    protected function _init_page_props()
162
-    {
163
-        $this->page_slug = REG_PG_SLUG;
164
-        $this->_admin_base_url = REG_ADMIN_URL;
165
-        $this->_admin_base_path = REG_ADMIN;
166
-        $this->page_label = esc_html__('Registrations', 'event_espresso');
167
-        $this->_cpt_routes = array(
168
-            'add_new_attendee' => 'espresso_attendees',
169
-            'edit_attendee'    => 'espresso_attendees',
170
-            'insert_attendee'  => 'espresso_attendees',
171
-            'update_attendee'  => 'espresso_attendees',
172
-        );
173
-        $this->_cpt_model_names = array(
174
-            'add_new_attendee' => 'EEM_Attendee',
175
-            'edit_attendee'    => 'EEM_Attendee',
176
-        );
177
-        $this->_cpt_edit_routes = array(
178
-            'espresso_attendees' => 'edit_attendee',
179
-        );
180
-        $this->_pagenow_map = array(
181
-            'add_new_attendee' => 'post-new.php',
182
-            'edit_attendee'    => 'post.php',
183
-            'trash'            => 'post.php',
184
-        );
185
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
186
-        // add filters so that the comment urls don't take users to a confusing 404 page
187
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
188
-    }
189
-
190
-
191
-    public function clear_comment_link($link, $comment, $args)
192
-    {
193
-        // gotta make sure this only happens on this route
194
-        $post_type = get_post_type($comment->comment_post_ID);
195
-        if ($post_type === 'espresso_attendees') {
196
-            return '#commentsdiv';
197
-        }
198
-        return $link;
199
-    }
200
-
201
-
202
-    protected function _ajax_hooks()
203
-    {
204
-        // todo: all hooks for registrations ajax goes in here
205
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
206
-    }
207
-
208
-
209
-    protected function _define_page_props()
210
-    {
211
-        $this->_admin_page_title = $this->page_label;
212
-        $this->_labels = array(
213
-            'buttons'                      => array(
214
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
215
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
216
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
217
-                'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
218
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
219
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
220
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
221
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
222
-            ),
223
-            'publishbox'                   => array(
224
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
225
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
226
-            ),
227
-            'hide_add_button_on_cpt_route' => array(
228
-                'edit_attendee' => true,
229
-            ),
230
-        );
231
-    }
232
-
233
-
234
-    /**
235
-     *        grab url requests and route them
236
-     *
237
-     * @access private
238
-     * @return void
239
-     * @throws EE_Error
240
-     */
241
-    public function _set_page_routes()
242
-    {
243
-        $this->_get_registration_status_array();
244
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
245
-            ? $this->_req_data['_REG_ID'] : 0;
246
-        $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
247
-            ? $this->_req_data['reg_status_change_form']['REG_ID']
248
-            : $reg_id;
249
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
250
-            ? $this->_req_data['ATT_ID'] : 0;
251
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
252
-            ? $this->_req_data['post']
253
-            : $att_id;
254
-        $this->_page_routes = array(
255
-            'default'                             => array(
256
-                'func'       => '_registrations_overview_list_table',
257
-                'capability' => 'ee_read_registrations',
258
-            ),
259
-            'view_registration'                   => array(
260
-                'func'       => '_registration_details',
261
-                'capability' => 'ee_read_registration',
262
-                'obj_id'     => $reg_id,
263
-            ),
264
-            'edit_registration'                   => array(
265
-                'func'               => '_update_attendee_registration_form',
266
-                'noheader'           => true,
267
-                'headers_sent_route' => 'view_registration',
268
-                'capability'         => 'ee_edit_registration',
269
-                'obj_id'             => $reg_id,
270
-                '_REG_ID'            => $reg_id,
271
-            ),
272
-            'trash_registrations'                 => array(
273
-                'func'       => '_trash_or_restore_registrations',
274
-                'args'       => array('trash' => true),
275
-                'noheader'   => true,
276
-                'capability' => 'ee_delete_registrations',
277
-            ),
278
-            'restore_registrations'               => array(
279
-                'func'       => '_trash_or_restore_registrations',
280
-                'args'       => array('trash' => false),
281
-                'noheader'   => true,
282
-                'capability' => 'ee_delete_registrations',
283
-            ),
284
-            'delete_registrations'                => array(
285
-                'func'       => '_delete_registrations',
286
-                'noheader'   => true,
287
-                'capability' => 'ee_delete_registrations',
288
-            ),
289
-            'new_registration'                    => array(
290
-                'func'       => 'new_registration',
291
-                'capability' => 'ee_edit_registrations',
292
-            ),
293
-            'process_reg_step'                    => array(
294
-                'func'       => 'process_reg_step',
295
-                'noheader'   => true,
296
-                'capability' => 'ee_edit_registrations',
297
-            ),
298
-            'redirect_to_txn'                     => array(
299
-                'func'       => 'redirect_to_txn',
300
-                'noheader'   => true,
301
-                'capability' => 'ee_edit_registrations',
302
-            ),
303
-            'change_reg_status'                   => array(
304
-                'func'       => '_change_reg_status',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registration',
307
-                'obj_id'     => $reg_id,
308
-            ),
309
-            'approve_registration'                => array(
310
-                'func'       => 'approve_registration',
311
-                'noheader'   => true,
312
-                'capability' => 'ee_edit_registration',
313
-                'obj_id'     => $reg_id,
314
-            ),
315
-            'approve_and_notify_registration'     => array(
316
-                'func'       => 'approve_registration',
317
-                'noheader'   => true,
318
-                'args'       => array(true),
319
-                'capability' => 'ee_edit_registration',
320
-                'obj_id'     => $reg_id,
321
-            ),
322
-            'approve_registrations'               => array(
323
-                'func'       => 'bulk_action_on_registrations',
324
-                'noheader'   => true,
325
-                'capability' => 'ee_edit_registrations',
326
-                'args'       => array('approve'),
327
-            ),
328
-            'approve_and_notify_registrations'    => array(
329
-                'func'       => 'bulk_action_on_registrations',
330
-                'noheader'   => true,
331
-                'capability' => 'ee_edit_registrations',
332
-                'args'       => array('approve', true),
333
-            ),
334
-            'decline_registration'                => array(
335
-                'func'       => 'decline_registration',
336
-                'noheader'   => true,
337
-                'capability' => 'ee_edit_registration',
338
-                'obj_id'     => $reg_id,
339
-            ),
340
-            'decline_and_notify_registration'     => array(
341
-                'func'       => 'decline_registration',
342
-                'noheader'   => true,
343
-                'args'       => array(true),
344
-                'capability' => 'ee_edit_registration',
345
-                'obj_id'     => $reg_id,
346
-            ),
347
-            'decline_registrations'               => array(
348
-                'func'       => 'bulk_action_on_registrations',
349
-                'noheader'   => true,
350
-                'capability' => 'ee_edit_registrations',
351
-                'args'       => array('decline'),
352
-            ),
353
-            'decline_and_notify_registrations'    => array(
354
-                'func'       => 'bulk_action_on_registrations',
355
-                'noheader'   => true,
356
-                'capability' => 'ee_edit_registrations',
357
-                'args'       => array('decline', true),
358
-            ),
359
-            'pending_registration'                => array(
360
-                'func'       => 'pending_registration',
361
-                'noheader'   => true,
362
-                'capability' => 'ee_edit_registration',
363
-                'obj_id'     => $reg_id,
364
-            ),
365
-            'pending_and_notify_registration'     => array(
366
-                'func'       => 'pending_registration',
367
-                'noheader'   => true,
368
-                'args'       => array(true),
369
-                'capability' => 'ee_edit_registration',
370
-                'obj_id'     => $reg_id,
371
-            ),
372
-            'pending_registrations'               => array(
373
-                'func'       => 'bulk_action_on_registrations',
374
-                'noheader'   => true,
375
-                'capability' => 'ee_edit_registrations',
376
-                'args'       => array('pending'),
377
-            ),
378
-            'pending_and_notify_registrations'    => array(
379
-                'func'       => 'bulk_action_on_registrations',
380
-                'noheader'   => true,
381
-                'capability' => 'ee_edit_registrations',
382
-                'args'       => array('pending', true),
383
-            ),
384
-            'no_approve_registration'             => array(
385
-                'func'       => 'not_approve_registration',
386
-                'noheader'   => true,
387
-                'capability' => 'ee_edit_registration',
388
-                'obj_id'     => $reg_id,
389
-            ),
390
-            'no_approve_and_notify_registration'  => array(
391
-                'func'       => 'not_approve_registration',
392
-                'noheader'   => true,
393
-                'args'       => array(true),
394
-                'capability' => 'ee_edit_registration',
395
-                'obj_id'     => $reg_id,
396
-            ),
397
-            'no_approve_registrations'            => array(
398
-                'func'       => 'bulk_action_on_registrations',
399
-                'noheader'   => true,
400
-                'capability' => 'ee_edit_registrations',
401
-                'args'       => array('not_approve'),
402
-            ),
403
-            'no_approve_and_notify_registrations' => array(
404
-                'func'       => 'bulk_action_on_registrations',
405
-                'noheader'   => true,
406
-                'capability' => 'ee_edit_registrations',
407
-                'args'       => array('not_approve', true),
408
-            ),
409
-            'cancel_registration'                 => array(
410
-                'func'       => 'cancel_registration',
411
-                'noheader'   => true,
412
-                'capability' => 'ee_edit_registration',
413
-                'obj_id'     => $reg_id,
414
-            ),
415
-            'cancel_and_notify_registration'      => array(
416
-                'func'       => 'cancel_registration',
417
-                'noheader'   => true,
418
-                'args'       => array(true),
419
-                'capability' => 'ee_edit_registration',
420
-                'obj_id'     => $reg_id,
421
-            ),
422
-            'cancel_registrations'                => array(
423
-                'func'       => 'bulk_action_on_registrations',
424
-                'noheader'   => true,
425
-                'capability' => 'ee_edit_registrations',
426
-                'args'       => array('cancel'),
427
-            ),
428
-            'cancel_and_notify_registrations'     => array(
429
-                'func'       => 'bulk_action_on_registrations',
430
-                'noheader'   => true,
431
-                'capability' => 'ee_edit_registrations',
432
-                'args'       => array('cancel', true),
433
-            ),
434
-            'wait_list_registration'              => array(
435
-                'func'       => 'wait_list_registration',
436
-                'noheader'   => true,
437
-                'capability' => 'ee_edit_registration',
438
-                'obj_id'     => $reg_id,
439
-            ),
440
-            'wait_list_and_notify_registration'   => array(
441
-                'func'       => 'wait_list_registration',
442
-                'noheader'   => true,
443
-                'args'       => array(true),
444
-                'capability' => 'ee_edit_registration',
445
-                'obj_id'     => $reg_id,
446
-            ),
447
-            'contact_list'                        => array(
448
-                'func'       => '_attendee_contact_list_table',
449
-                'capability' => 'ee_read_contacts',
450
-            ),
451
-            'add_new_attendee'                    => array(
452
-                'func' => '_create_new_cpt_item',
453
-                'args' => array(
454
-                    'new_attendee' => true,
455
-                    'capability'   => 'ee_edit_contacts',
456
-                ),
457
-            ),
458
-            'edit_attendee'                       => array(
459
-                'func'       => '_edit_cpt_item',
460
-                'capability' => 'ee_edit_contacts',
461
-                'obj_id'     => $att_id,
462
-            ),
463
-            'duplicate_attendee'                  => array(
464
-                'func'       => '_duplicate_attendee',
465
-                'noheader'   => true,
466
-                'capability' => 'ee_edit_contacts',
467
-                'obj_id'     => $att_id,
468
-            ),
469
-            'insert_attendee'                     => array(
470
-                'func'       => '_insert_or_update_attendee',
471
-                'args'       => array(
472
-                    'new_attendee' => true,
473
-                ),
474
-                'noheader'   => true,
475
-                'capability' => 'ee_edit_contacts',
476
-            ),
477
-            'update_attendee'                     => array(
478
-                'func'       => '_insert_or_update_attendee',
479
-                'args'       => array(
480
-                    'new_attendee' => false,
481
-                ),
482
-                'noheader'   => true,
483
-                'capability' => 'ee_edit_contacts',
484
-                'obj_id'     => $att_id,
485
-            ),
486
-            'trash_attendees'                     => array(
487
-                'func'       => '_trash_or_restore_attendees',
488
-                'args'       => array(
489
-                    'trash' => 'true',
490
-                ),
491
-                'noheader'   => true,
492
-                'capability' => 'ee_delete_contacts',
493
-            ),
494
-            'trash_attendee'                      => array(
495
-                'func'       => '_trash_or_restore_attendees',
496
-                'args'       => array(
497
-                    'trash' => true,
498
-                ),
499
-                'noheader'   => true,
500
-                'capability' => 'ee_delete_contacts',
501
-                'obj_id'     => $att_id,
502
-            ),
503
-            'restore_attendees'                   => array(
504
-                'func'       => '_trash_or_restore_attendees',
505
-                'args'       => array(
506
-                    'trash' => false,
507
-                ),
508
-                'noheader'   => true,
509
-                'capability' => 'ee_delete_contacts',
510
-                'obj_id'     => $att_id,
511
-            ),
512
-            'resend_registration'                 => array(
513
-                'func'       => '_resend_registration',
514
-                'noheader'   => true,
515
-                'capability' => 'ee_send_message',
516
-            ),
517
-            'registrations_report'                => array(
518
-                'func'       => '_registrations_report',
519
-                'noheader'   => true,
520
-                'capability' => 'ee_read_registrations',
521
-            ),
522
-            'contact_list_export'                 => array(
523
-                'func'       => '_contact_list_export',
524
-                'noheader'   => true,
525
-                'capability' => 'export',
526
-            ),
527
-            'contact_list_report'                 => array(
528
-                'func'       => '_contact_list_report',
529
-                'noheader'   => true,
530
-                'capability' => 'ee_read_contacts',
531
-            ),
532
-        );
533
-    }
534
-
535
-
536
-    protected function _set_page_config()
537
-    {
538
-        $this->_page_config = array(
539
-            'default'           => array(
540
-                'nav'           => array(
541
-                    'label' => esc_html__('Overview', 'event_espresso'),
542
-                    'order' => 5,
543
-                ),
544
-                'help_tabs'     => array(
545
-                    'registrations_overview_help_tab'                       => array(
546
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
547
-                        'filename' => 'registrations_overview',
548
-                    ),
549
-                    'registrations_overview_table_column_headings_help_tab' => array(
550
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
551
-                        'filename' => 'registrations_overview_table_column_headings',
552
-                    ),
553
-                    'registrations_overview_filters_help_tab'               => array(
554
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
555
-                        'filename' => 'registrations_overview_filters',
556
-                    ),
557
-                    'registrations_overview_views_help_tab'                 => array(
558
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
559
-                        'filename' => 'registrations_overview_views',
560
-                    ),
561
-                    'registrations_regoverview_other_help_tab'              => array(
562
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
563
-                        'filename' => 'registrations_overview_other',
564
-                    ),
565
-                ),
566
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
567
-                'qtips'         => array('Registration_List_Table_Tips'),
568
-                'list_table'    => 'EE_Registrations_List_Table',
569
-                'require_nonce' => false,
570
-            ),
571
-            'view_registration' => array(
572
-                'nav'           => array(
573
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
574
-                    'order'      => 15,
575
-                    'url'        => isset($this->_req_data['_REG_ID'])
576
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
577
-                        : $this->_admin_base_url,
578
-                    'persistent' => false,
579
-                ),
580
-                'help_tabs'     => array(
581
-                    'registrations_details_help_tab'                    => array(
582
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
583
-                        'filename' => 'registrations_details',
584
-                    ),
585
-                    'registrations_details_table_help_tab'              => array(
586
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
587
-                        'filename' => 'registrations_details_table',
588
-                    ),
589
-                    'registrations_details_form_answers_help_tab'       => array(
590
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
591
-                        'filename' => 'registrations_details_form_answers',
592
-                    ),
593
-                    'registrations_details_registrant_details_help_tab' => array(
594
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
595
-                        'filename' => 'registrations_details_registrant_details',
596
-                    ),
597
-                ),
598
-                'help_tour'     => array('Registration_Details_Help_Tour'),
599
-                'metaboxes'     => array_merge(
600
-                    $this->_default_espresso_metaboxes,
601
-                    array('_registration_details_metaboxes')
602
-                ),
603
-                'require_nonce' => false,
604
-            ),
605
-            'new_registration'  => array(
606
-                'nav'           => array(
607
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
608
-                    'url'        => '#',
609
-                    'order'      => 15,
610
-                    'persistent' => false,
611
-                ),
612
-                'metaboxes'     => $this->_default_espresso_metaboxes,
613
-                'labels'        => array(
614
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
615
-                ),
616
-                'require_nonce' => false,
617
-            ),
618
-            'add_new_attendee'  => array(
619
-                'nav'           => array(
620
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
621
-                    'order'      => 15,
622
-                    'persistent' => false,
623
-                ),
624
-                'metaboxes'     => array_merge(
625
-                    $this->_default_espresso_metaboxes,
626
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
627
-                ),
628
-                'require_nonce' => false,
629
-            ),
630
-            'edit_attendee'     => array(
631
-                'nav'           => array(
632
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
633
-                    'order'      => 15,
634
-                    'persistent' => false,
635
-                    'url'        => isset($this->_req_data['ATT_ID'])
636
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
637
-                        : $this->_admin_base_url,
638
-                ),
639
-                'metaboxes'     => array('attendee_editor_metaboxes'),
640
-                'require_nonce' => false,
641
-            ),
642
-            'contact_list'      => array(
643
-                'nav'           => array(
644
-                    'label' => esc_html__('Contact List', 'event_espresso'),
645
-                    'order' => 20,
646
-                ),
647
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
648
-                'help_tabs'     => array(
649
-                    'registrations_contact_list_help_tab'                       => array(
650
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
651
-                        'filename' => 'registrations_contact_list',
652
-                    ),
653
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
654
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
655
-                        'filename' => 'registrations_contact_list_table_column_headings',
656
-                    ),
657
-                    'registrations_contact_list_views_help_tab'                 => array(
658
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
659
-                        'filename' => 'registrations_contact_list_views',
660
-                    ),
661
-                    'registrations_contact_list_other_help_tab'                 => array(
662
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
663
-                        'filename' => 'registrations_contact_list_other',
664
-                    ),
665
-                ),
666
-                'help_tour'     => array('Contact_List_Help_Tour'),
667
-                'metaboxes'     => array(),
668
-                'require_nonce' => false,
669
-            ),
670
-            // override default cpt routes
671
-            'create_new'        => '',
672
-            'edit'              => '',
673
-        );
674
-    }
675
-
676
-
677
-    /**
678
-     * The below methods aren't used by this class currently
679
-     */
680
-    protected function _add_screen_options()
681
-    {
682
-    }
683
-
684
-
685
-    protected function _add_feature_pointers()
686
-    {
687
-    }
688
-
689
-
690
-    public function admin_init()
691
-    {
692
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
693
-            'click "Update Registration Questions" to save your changes',
694
-            'event_espresso'
695
-        );
696
-    }
697
-
698
-
699
-    public function admin_notices()
700
-    {
701
-    }
702
-
703
-
704
-    public function admin_footer_scripts()
705
-    {
706
-    }
707
-
708
-
709
-    /**
710
-     *        get list of registration statuses
711
-     *
712
-     * @access private
713
-     * @return void
714
-     * @throws EE_Error
715
-     */
716
-    private function _get_registration_status_array()
717
-    {
718
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
719
-    }
720
-
721
-
722
-    /**
723
-     * @throws InvalidArgumentException
724
-     * @throws InvalidDataTypeException
725
-     * @throws InvalidInterfaceException
726
-     * @since 4.10.2.p
727
-     */
728
-    protected function _add_screen_options_default()
729
-    {
730
-        $this->_per_page_screen_option();
731
-    }
732
-
733
-
734
-    /**
735
-     * @throws InvalidArgumentException
736
-     * @throws InvalidDataTypeException
737
-     * @throws InvalidInterfaceException
738
-     * @since 4.10.2.p
739
-     */
740
-    protected function _add_screen_options_contact_list()
741
-    {
742
-        $page_title = $this->_admin_page_title;
743
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
744
-        $this->_per_page_screen_option();
745
-        $this->_admin_page_title = $page_title;
746
-    }
747
-
748
-
749
-    public function load_scripts_styles()
750
-    {
751
-        // style
752
-        wp_register_style(
753
-            'espresso_reg',
754
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
755
-            array('ee-admin-css'),
756
-            EVENT_ESPRESSO_VERSION
757
-        );
758
-        wp_enqueue_style('espresso_reg');
759
-        // script
760
-        wp_register_script(
761
-            'espresso_reg',
762
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
763
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
764
-            EVENT_ESPRESSO_VERSION,
765
-            true
766
-        );
767
-        wp_enqueue_script('espresso_reg');
768
-    }
769
-
770
-
771
-    /**
772
-     * @throws EE_Error
773
-     * @throws InvalidArgumentException
774
-     * @throws InvalidDataTypeException
775
-     * @throws InvalidInterfaceException
776
-     * @throws ReflectionException
777
-     * @since 4.10.2.p
778
-     */
779
-    public function load_scripts_styles_edit_attendee()
780
-    {
781
-        // stuff to only show up on our attendee edit details page.
782
-        $attendee_details_translations = array(
783
-            'att_publish_text' => sprintf(
784
-                /* translators: The date and time */
785
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
786
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
787
-            ),
788
-        );
789
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
790
-        wp_enqueue_script('jquery-validate');
791
-    }
792
-
793
-
794
-    /**
795
-     * @throws EE_Error
796
-     * @throws InvalidArgumentException
797
-     * @throws InvalidDataTypeException
798
-     * @throws InvalidInterfaceException
799
-     * @throws ReflectionException
800
-     * @since 4.10.2.p
801
-     */
802
-    public function load_scripts_styles_view_registration()
803
-    {
804
-        // styles
805
-        wp_enqueue_style('espresso-ui-theme');
806
-        // scripts
807
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
808
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
809
-    }
810
-
811
-
812
-    public function load_scripts_styles_contact_list()
813
-    {
814
-        wp_dequeue_style('espresso_reg');
815
-        wp_register_style(
816
-            'espresso_att',
817
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
818
-            array('ee-admin-css'),
819
-            EVENT_ESPRESSO_VERSION
820
-        );
821
-        wp_enqueue_style('espresso_att');
822
-    }
823
-
824
-
825
-    public function load_scripts_styles_new_registration()
826
-    {
827
-        wp_register_script(
828
-            'ee-spco-for-admin',
829
-            REG_ASSETS_URL . 'spco_for_admin.js',
830
-            array('underscore', 'jquery'),
831
-            EVENT_ESPRESSO_VERSION,
832
-            true
833
-        );
834
-        wp_enqueue_script('ee-spco-for-admin');
835
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
836
-        EE_Form_Section_Proper::wp_enqueue_scripts();
837
-        EED_Ticket_Selector::load_tckt_slctr_assets();
838
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
839
-    }
840
-
841
-
842
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
843
-    {
844
-        add_filter('FHEE_load_EE_messages', '__return_true');
845
-    }
846
-
847
-
848
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
849
-    {
850
-        add_filter('FHEE_load_EE_messages', '__return_true');
851
-    }
852
-
853
-
854
-    /**
855
-     * @throws EE_Error
856
-     * @throws InvalidArgumentException
857
-     * @throws InvalidDataTypeException
858
-     * @throws InvalidInterfaceException
859
-     * @throws ReflectionException
860
-     * @since 4.10.2.p
861
-     */
862
-    protected function _set_list_table_views_default()
863
-    {
864
-        // for notification related bulk actions we need to make sure only active messengers have an option.
865
-        EED_Messages::set_autoloaders();
866
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
867
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
868
-        $active_mts = $message_resource_manager->list_of_active_message_types();
869
-        // key= bulk_action_slug, value= message type.
870
-        $match_array = array(
871
-            'approve_registrations'    => 'registration',
872
-            'decline_registrations'    => 'declined_registration',
873
-            'pending_registrations'    => 'pending_approval',
874
-            'no_approve_registrations' => 'not_approved_registration',
875
-            'cancel_registrations'     => 'cancelled_registration',
876
-        );
877
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
878
-            'ee_send_message',
879
-            'batch_send_messages'
880
-        );
881
-        /** setup reg status bulk actions **/
882
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
883
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
884
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
885
-                'Approve and Notify Registrations',
886
-                'event_espresso'
887
-            );
888
-        }
889
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
890
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
891
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
892
-                'Decline and Notify Registrations',
893
-                'event_espresso'
894
-            );
895
-        }
896
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
897
-            'Set Registrations to Pending Payment',
898
-            'event_espresso'
899
-        );
900
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
901
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
902
-                'Set Registrations to Pending Payment and Notify',
903
-                'event_espresso'
904
-            );
905
-        }
906
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
907
-            'Set Registrations to Not Approved',
908
-            'event_espresso'
909
-        );
910
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
911
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
912
-                'Set Registrations to Not Approved and Notify',
913
-                'event_espresso'
914
-            );
915
-        }
916
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
917
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
918
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
919
-                'Cancel Registrations and Notify',
920
-                'event_espresso'
921
-            );
922
-        }
923
-        $def_reg_status_actions = apply_filters(
924
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
925
-            $def_reg_status_actions,
926
-            $active_mts,
927
-            $can_send
928
-        );
929
-
930
-        $this->_views = array(
931
-            'all'   => array(
932
-                'slug'        => 'all',
933
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
934
-                'count'       => 0,
935
-                'bulk_action' => array_merge(
936
-                    $def_reg_status_actions,
937
-                    array(
938
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
939
-                    )
940
-                ),
941
-            ),
942
-            'month' => array(
943
-                'slug'        => 'month',
944
-                'label'       => esc_html__('This Month', 'event_espresso'),
945
-                'count'       => 0,
946
-                'bulk_action' => array_merge(
947
-                    $def_reg_status_actions,
948
-                    array(
949
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
950
-                    )
951
-                ),
952
-            ),
953
-            'today' => array(
954
-                'slug'        => 'today',
955
-                'label'       => sprintf(
956
-                    esc_html__('Today - %s', 'event_espresso'),
957
-                    date('M d, Y', current_time('timestamp'))
958
-                ),
959
-                'count'       => 0,
960
-                'bulk_action' => array_merge(
961
-                    $def_reg_status_actions,
962
-                    array(
963
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
964
-                    )
965
-                ),
966
-            ),
967
-        );
968
-        if (EE_Registry::instance()->CAP->current_user_can(
969
-            'ee_delete_registrations',
970
-            'espresso_registrations_delete_registration'
971
-        )) {
972
-            $this->_views['incomplete'] = array(
973
-                'slug'        => 'incomplete',
974
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
975
-                'count'       => 0,
976
-                'bulk_action' => array(
977
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
978
-                ),
979
-            );
980
-            $this->_views['trash'] = array(
981
-                'slug'        => 'trash',
982
-                'label'       => esc_html__('Trash', 'event_espresso'),
983
-                'count'       => 0,
984
-                'bulk_action' => array(
985
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
986
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
987
-                ),
988
-            );
989
-        }
990
-    }
991
-
992
-
993
-    protected function _set_list_table_views_contact_list()
994
-    {
995
-        $this->_views = array(
996
-            'in_use' => array(
997
-                'slug'        => 'in_use',
998
-                'label'       => esc_html__('In Use', 'event_espresso'),
999
-                'count'       => 0,
1000
-                'bulk_action' => array(
1001
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1002
-                ),
1003
-            ),
1004
-        );
1005
-        if (EE_Registry::instance()->CAP->current_user_can(
1006
-            'ee_delete_contacts',
1007
-            'espresso_registrations_trash_attendees'
1008
-        )
1009
-        ) {
1010
-            $this->_views['trash'] = array(
1011
-                'slug'        => 'trash',
1012
-                'label'       => esc_html__('Trash', 'event_espresso'),
1013
-                'count'       => 0,
1014
-                'bulk_action' => array(
1015
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1016
-                ),
1017
-            );
1018
-        }
1019
-    }
1020
-
1021
-
1022
-    protected function _registration_legend_items()
1023
-    {
1024
-        $fc_items = array(
1025
-            'star-icon'        => array(
1026
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1027
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1028
-            ),
1029
-            'view_details'     => array(
1030
-                'class' => 'dashicons dashicons-clipboard',
1031
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1032
-            ),
1033
-            'edit_attendee'    => array(
1034
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1035
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1036
-            ),
1037
-            'view_transaction' => array(
1038
-                'class' => 'dashicons dashicons-cart',
1039
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1040
-            ),
1041
-            'view_invoice'     => array(
1042
-                'class' => 'dashicons dashicons-media-spreadsheet',
1043
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1044
-            ),
1045
-        );
1046
-        if (EE_Registry::instance()->CAP->current_user_can(
1047
-            'ee_send_message',
1048
-            'espresso_registrations_resend_registration'
1049
-        )) {
1050
-            $fc_items['resend_registration'] = array(
1051
-                'class' => 'dashicons dashicons-email-alt',
1052
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1053
-            );
1054
-        } else {
1055
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
1056
-        }
1057
-        if (EE_Registry::instance()->CAP->current_user_can(
1058
-            'ee_read_global_messages',
1059
-            'view_filtered_messages'
1060
-        )) {
1061
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1062
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1063
-                $fc_items['view_related_messages'] = array(
1064
-                    'class' => $related_for_icon['css_class'],
1065
-                    'desc'  => $related_for_icon['label'],
1066
-                );
1067
-            }
1068
-        }
1069
-        $sc_items = array(
1070
-            'approved_status'   => array(
1071
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1072
-                'desc'  => EEH_Template::pretty_status(
1073
-                    EEM_Registration::status_id_approved,
1074
-                    false,
1075
-                    'sentence'
1076
-                ),
1077
-            ),
1078
-            'pending_status'    => array(
1079
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1080
-                'desc'  => EEH_Template::pretty_status(
1081
-                    EEM_Registration::status_id_pending_payment,
1082
-                    false,
1083
-                    'sentence'
1084
-                ),
1085
-            ),
1086
-            'wait_list'         => array(
1087
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1088
-                'desc'  => EEH_Template::pretty_status(
1089
-                    EEM_Registration::status_id_wait_list,
1090
-                    false,
1091
-                    'sentence'
1092
-                ),
1093
-            ),
1094
-            'incomplete_status' => array(
1095
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1096
-                'desc'  => EEH_Template::pretty_status(
1097
-                    EEM_Registration::status_id_incomplete,
1098
-                    false,
1099
-                    'sentence'
1100
-                ),
1101
-            ),
1102
-            'not_approved'      => array(
1103
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1104
-                'desc'  => EEH_Template::pretty_status(
1105
-                    EEM_Registration::status_id_not_approved,
1106
-                    false,
1107
-                    'sentence'
1108
-                ),
1109
-            ),
1110
-            'declined_status'   => array(
1111
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1112
-                'desc'  => EEH_Template::pretty_status(
1113
-                    EEM_Registration::status_id_declined,
1114
-                    false,
1115
-                    'sentence'
1116
-                ),
1117
-            ),
1118
-            'cancelled_status'  => array(
1119
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1120
-                'desc'  => EEH_Template::pretty_status(
1121
-                    EEM_Registration::status_id_cancelled,
1122
-                    false,
1123
-                    'sentence'
1124
-                ),
1125
-            ),
1126
-        );
1127
-        return array_merge($fc_items, $sc_items);
1128
-    }
1129
-
1130
-
1131
-
1132
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1133
-
1134
-
1135
-
1136
-    /**
1137
-     * @throws DomainException
1138
-     * @throws EE_Error
1139
-     * @throws InvalidArgumentException
1140
-     * @throws InvalidDataTypeException
1141
-     * @throws InvalidInterfaceException
1142
-     * @throws ReflectionException
1143
-     */
1144
-    protected function _registrations_overview_list_table()
1145
-    {
1146
-        $this->appendAddNewRegistrationButtonToPageTitle();
1147
-        $header_text = '';
1148
-        $admin_page_header_decorators = [
1149
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1150
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1151
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1152
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1153
-        ];
1154
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1155
-            $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1156
-            $header_text = $filter_header_decorator->getHeaderText($header_text);
1157
-        }
1158
-        $this->_template_args['admin_page_header'] = $header_text;
1159
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1160
-        $this->display_admin_list_table_page_with_no_sidebar();
1161
-    }
1162
-
1163
-
1164
-    /**
1165
-     * @throws EE_Error
1166
-     * @throws InvalidArgumentException
1167
-     * @throws InvalidDataTypeException
1168
-     * @throws InvalidInterfaceException
1169
-     */
1170
-    private function appendAddNewRegistrationButtonToPageTitle()
1171
-    {
1172
-        $EVT_ID = ! empty($this->_req_data['event_id'])
1173
-            ? absint($this->_req_data['event_id'])
1174
-            : 0;
1175
-        if ($EVT_ID
1176
-            && EE_Registry::instance()->CAP->current_user_can(
1177
-                'ee_edit_registrations',
1178
-                'espresso_registrations_new_registration',
1179
-                $EVT_ID
1180
-            )
1181
-        ) {
1182
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1183
-                'new_registration',
1184
-                'add-registrant',
1185
-                array('event_id' => $EVT_ID),
1186
-                'add-new-h2'
1187
-            );
1188
-        }
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * This sets the _registration property for the registration details screen
1194
-     *
1195
-     * @access private
1196
-     * @return bool
1197
-     * @throws EE_Error
1198
-     * @throws InvalidArgumentException
1199
-     * @throws InvalidDataTypeException
1200
-     * @throws InvalidInterfaceException
1201
-     */
1202
-    private function _set_registration_object()
1203
-    {
1204
-        // get out if we've already set the object
1205
-        if ($this->_registration instanceof EE_Registration) {
1206
-            return true;
1207
-        }
1208
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1209
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1210
-            return true;
1211
-        }
1212
-        $error_msg = sprintf(
1213
-            esc_html__(
1214
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1215
-                'event_espresso'
1216
-            ),
1217
-            $REG_ID
1218
-        );
1219
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1220
-        $this->_registration = null;
1221
-        return false;
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * Used to retrieve registrations for the list table.
1227
-     *
1228
-     * @param int  $per_page
1229
-     * @param bool $count
1230
-     * @param bool $this_month
1231
-     * @param bool $today
1232
-     * @return EE_Registration[]|int
1233
-     * @throws EE_Error
1234
-     * @throws InvalidArgumentException
1235
-     * @throws InvalidDataTypeException
1236
-     * @throws InvalidInterfaceException
1237
-     */
1238
-    public function get_registrations(
1239
-        $per_page = 10,
1240
-        $count = false,
1241
-        $this_month = false,
1242
-        $today = false
1243
-    ) {
1244
-        if ($this_month) {
1245
-            $this->_req_data['status'] = 'month';
1246
-        }
1247
-        if ($today) {
1248
-            $this->_req_data['status'] = 'today';
1249
-        }
1250
-        $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1251
-        /**
1252
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1253
-         *
1254
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1255
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1256
-         *                             or if you have the development copy of EE you can view this at the path:
1257
-         *                             /docs/G--Model-System/model-query-params.md
1258
-         */
1259
-        $query_params['group_by'] = '';
1260
-
1261
-        return $count
1262
-            ? $this->getRegistrationModel()->count($query_params)
1263
-            /** @type EE_Registration[] */
1264
-            : $this->getRegistrationModel()->get_all($query_params);
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1270
-     * Note: this listens to values on the request for some of the query parameters.
1271
-     *
1272
-     * @param array $request
1273
-     * @param int   $per_page
1274
-     * @param bool  $count
1275
-     * @return array
1276
-     * @throws EE_Error
1277
-     * @throws InvalidArgumentException
1278
-     * @throws InvalidDataTypeException
1279
-     * @throws InvalidInterfaceException
1280
-     */
1281
-    protected function _get_registration_query_parameters(
1282
-        $request = array(),
1283
-        $per_page = 10,
1284
-        $count = false
1285
-    ) {
1286
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1287
-        $list_table_query_builder = $this->loader->getNew(
1288
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1289
-            [ $request ]
1290
-        );
1291
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1292
-    }
1293
-
1294
-
1295
-    public function get_registration_status_array()
1296
-    {
1297
-        return self::$_reg_status;
1298
-    }
1299
-
1300
-
1301
-
1302
-
1303
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1304
-    /**
1305
-     *        generates HTML for the View Registration Details Admin page
1306
-     *
1307
-     * @access protected
1308
-     * @return void
1309
-     * @throws DomainException
1310
-     * @throws EE_Error
1311
-     * @throws InvalidArgumentException
1312
-     * @throws InvalidDataTypeException
1313
-     * @throws InvalidInterfaceException
1314
-     * @throws EntityNotFoundException
1315
-     * @throws ReflectionException
1316
-     */
1317
-    protected function _registration_details()
1318
-    {
1319
-        $this->_template_args = array();
1320
-        $this->_set_registration_object();
1321
-        if (is_object($this->_registration)) {
1322
-            $transaction = $this->_registration->transaction()
1323
-                ? $this->_registration->transaction()
1324
-                : EE_Transaction::new_instance();
1325
-            $this->_session = $transaction->session_data();
1326
-            $event_id = $this->_registration->event_ID();
1327
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1328
-            $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1329
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1330
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1331
-            $this->_template_args['grand_total'] = $transaction->total();
1332
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1333
-            // link back to overview
1334
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1335
-            $this->_template_args['registration'] = $this->_registration;
1336
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1337
-                array(
1338
-                    'action'   => 'default',
1339
-                    'event_id' => $event_id,
1340
-                ),
1341
-                REG_ADMIN_URL
1342
-            );
1343
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1344
-                array(
1345
-                    'action' => 'default',
1346
-                    'EVT_ID' => $event_id,
1347
-                    'page'   => 'espresso_transactions',
1348
-                ),
1349
-                admin_url('admin.php')
1350
-            );
1351
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1352
-                array(
1353
-                    'page'   => 'espresso_events',
1354
-                    'action' => 'edit',
1355
-                    'post'   => $event_id,
1356
-                ),
1357
-                admin_url('admin.php')
1358
-            );
1359
-            // next and previous links
1360
-            $next_reg = $this->_registration->next(
1361
-                null,
1362
-                array(),
1363
-                'REG_ID'
1364
-            );
1365
-            $this->_template_args['next_registration'] = $next_reg
1366
-                ? $this->_next_link(
1367
-                    EE_Admin_Page::add_query_args_and_nonce(
1368
-                        array(
1369
-                            'action'  => 'view_registration',
1370
-                            '_REG_ID' => $next_reg['REG_ID'],
1371
-                        ),
1372
-                        REG_ADMIN_URL
1373
-                    ),
1374
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1375
-                )
1376
-                : '';
1377
-            $previous_reg = $this->_registration->previous(
1378
-                null,
1379
-                array(),
1380
-                'REG_ID'
1381
-            );
1382
-            $this->_template_args['previous_registration'] = $previous_reg
1383
-                ? $this->_previous_link(
1384
-                    EE_Admin_Page::add_query_args_and_nonce(
1385
-                        array(
1386
-                            'action'  => 'view_registration',
1387
-                            '_REG_ID' => $previous_reg['REG_ID'],
1388
-                        ),
1389
-                        REG_ADMIN_URL
1390
-                    ),
1391
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1392
-                )
1393
-                : '';
1394
-            // grab header
1395
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1396
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1397
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1398
-                $template_path,
1399
-                $this->_template_args,
1400
-                true
1401
-            );
1402
-        } else {
1403
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1404
-        }
1405
-        // the details template wrapper
1406
-        $this->display_admin_page_with_sidebar();
1407
-    }
1408
-
1409
-
1410
-    /**
1411
-     * @throws EE_Error
1412
-     * @throws InvalidArgumentException
1413
-     * @throws InvalidDataTypeException
1414
-     * @throws InvalidInterfaceException
1415
-     * @throws ReflectionException
1416
-     * @since 4.10.2.p
1417
-     */
1418
-    protected function _registration_details_metaboxes()
1419
-    {
1420
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1421
-        $this->_set_registration_object();
1422
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1423
-        add_meta_box(
1424
-            'edit-reg-status-mbox',
1425
-            esc_html__('Registration Status', 'event_espresso'),
1426
-            array($this, 'set_reg_status_buttons_metabox'),
1427
-            $this->wp_page_slug,
1428
-            'normal',
1429
-            'high'
1430
-        );
1431
-        add_meta_box(
1432
-            'edit-reg-details-mbox',
1433
-            esc_html__('Registration Details', 'event_espresso'),
1434
-            array($this, '_reg_details_meta_box'),
1435
-            $this->wp_page_slug,
1436
-            'normal',
1437
-            'high'
1438
-        );
1439
-        if ($attendee instanceof EE_Attendee
1440
-            && EE_Registry::instance()->CAP->current_user_can(
1441
-                'ee_read_registration',
1442
-                'edit-reg-questions-mbox',
1443
-                $this->_registration->ID()
1444
-            )
1445
-        ) {
1446
-            add_meta_box(
1447
-                'edit-reg-questions-mbox',
1448
-                esc_html__('Registration Form Answers', 'event_espresso'),
1449
-                array($this, '_reg_questions_meta_box'),
1450
-                $this->wp_page_slug,
1451
-                'normal',
1452
-                'high'
1453
-            );
1454
-        }
1455
-        add_meta_box(
1456
-            'edit-reg-registrant-mbox',
1457
-            esc_html__('Contact Details', 'event_espresso'),
1458
-            array($this, '_reg_registrant_side_meta_box'),
1459
-            $this->wp_page_slug,
1460
-            'side',
1461
-            'high'
1462
-        );
1463
-        if ($this->_registration->group_size() > 1) {
1464
-            add_meta_box(
1465
-                'edit-reg-attendees-mbox',
1466
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1467
-                array($this, '_reg_attendees_meta_box'),
1468
-                $this->wp_page_slug,
1469
-                'normal',
1470
-                'high'
1471
-            );
1472
-        }
1473
-    }
1474
-
1475
-
1476
-    /**
1477
-     * set_reg_status_buttons_metabox
1478
-     *
1479
-     * @access protected
1480
-     * @return string
1481
-     * @throws EE_Error
1482
-     * @throws EntityNotFoundException
1483
-     * @throws InvalidArgumentException
1484
-     * @throws InvalidDataTypeException
1485
-     * @throws InvalidInterfaceException
1486
-     * @throws ReflectionException
1487
-     */
1488
-    public function set_reg_status_buttons_metabox()
1489
-    {
1490
-        $this->_set_registration_object();
1491
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1492
-        echo $change_reg_status_form->form_open(
1493
-            self::add_query_args_and_nonce(
1494
-                array(
1495
-                    'action' => 'change_reg_status',
1496
-                ),
1497
-                REG_ADMIN_URL
1498
-            )
1499
-        );
1500
-        echo $change_reg_status_form->get_html();
1501
-        echo $change_reg_status_form->form_close();
1502
-    }
1503
-
1504
-
1505
-    /**
1506
-     * @return EE_Form_Section_Proper
1507
-     * @throws EE_Error
1508
-     * @throws InvalidArgumentException
1509
-     * @throws InvalidDataTypeException
1510
-     * @throws InvalidInterfaceException
1511
-     * @throws EntityNotFoundException
1512
-     * @throws ReflectionException
1513
-     */
1514
-    protected function _generate_reg_status_change_form()
1515
-    {
1516
-        $reg_status_change_form_array = array(
1517
-            'name'            => 'reg_status_change_form',
1518
-            'html_id'         => 'reg-status-change-form',
1519
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1520
-            'subsections'     => array(
1521
-                'return'             => new EE_Hidden_Input(
1522
-                    array(
1523
-                        'name'    => 'return',
1524
-                        'default' => 'view_registration',
1525
-                    )
1526
-                ),
1527
-                'REG_ID'             => new EE_Hidden_Input(
1528
-                    array(
1529
-                        'name'    => 'REG_ID',
1530
-                        'default' => $this->_registration->ID(),
1531
-                    )
1532
-                ),
1533
-                'current_status'     => new EE_Form_Section_HTML(
1534
-                    EEH_HTML::table(
1535
-                        EEH_HTML::tr(
1536
-                            EEH_HTML::th(
1537
-                                EEH_HTML::label(
1538
-                                    EEH_HTML::strong(
1539
-                                        esc_html__('Current Registration Status', 'event_espresso')
1540
-                                    )
1541
-                                )
1542
-                            )
1543
-                            . EEH_HTML::td(
1544
-                                EEH_HTML::strong(
1545
-                                    $this->_registration->pretty_status(),
1546
-                                    '',
1547
-                                    'status-' . $this->_registration->status_ID(),
1548
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1549
-                                )
1550
-                            )
1551
-                        )
1552
-                    )
1553
-                )
1554
-            )
1555
-        );
1556
-        if (EE_Registry::instance()->CAP->current_user_can(
1557
-            'ee_edit_registration',
1558
-            'toggle_registration_status',
1559
-            $this->_registration->ID()
1560
-        )) {
1561
-            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1562
-                $this->_get_reg_statuses(),
1563
-                array(
1564
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1565
-                    'default'         => $this->_registration->status_ID(),
1566
-                )
1567
-            );
1568
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1569
-                array(
1570
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1571
-                    'default'         => false,
1572
-                    'html_help_text'  => esc_html__(
1573
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1574
-                        'event_espresso'
1575
-                    )
1576
-                )
1577
-            );
1578
-            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1579
-                array(
1580
-                    'html_class'      => 'button-primary',
1581
-                    'html_label_text' => '&nbsp;',
1582
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1583
-                )
1584
-            );
1585
-        }
1586
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1587
-    }
1588
-
1589
-
1590
-    /**
1591
-     * Returns an array of all the buttons for the various statuses and switch status actions
1592
-     *
1593
-     * @return array
1594
-     * @throws EE_Error
1595
-     * @throws InvalidArgumentException
1596
-     * @throws InvalidDataTypeException
1597
-     * @throws InvalidInterfaceException
1598
-     * @throws EntityNotFoundException
1599
-     */
1600
-    protected function _get_reg_statuses()
1601
-    {
1602
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1603
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1604
-        // get current reg status
1605
-        $current_status = $this->_registration->status_ID();
1606
-        // is registration for free event? This will determine whether to display the pending payment option
1607
-        if ($current_status !== EEM_Registration::status_id_pending_payment
1608
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1609
-        ) {
1610
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1611
-        }
1612
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1613
-    }
1614
-
1615
-
1616
-    /**
1617
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1618
-     *
1619
-     * @param bool $status REG status given for changing registrations to.
1620
-     * @param bool $notify Whether to send messages notifications or not.
1621
-     * @return array (array with reg_id(s) updated and whether update was successful.
1622
-     * @throws DomainException
1623
-     * @throws EE_Error
1624
-     * @throws EntityNotFoundException
1625
-     * @throws InvalidArgumentException
1626
-     * @throws InvalidDataTypeException
1627
-     * @throws InvalidInterfaceException
1628
-     * @throws ReflectionException
1629
-     * @throws RuntimeException
1630
-     */
1631
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1632
-    {
1633
-        if (isset($this->_req_data['reg_status_change_form'])) {
1634
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1635
-                ? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1636
-                : array();
1637
-        } else {
1638
-            $REG_IDs = isset($this->_req_data['_REG_ID'])
1639
-                ? (array) $this->_req_data['_REG_ID']
1640
-                : array();
1641
-        }
1642
-        // sanitize $REG_IDs
1643
-        $REG_IDs = array_map('absint', $REG_IDs);
1644
-        // and remove empty entries
1645
-        $REG_IDs = array_filter($REG_IDs);
1646
-
1647
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1648
-
1649
-        /**
1650
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1651
-         * Currently this value is used downstream by the _process_resend_registration method.
1652
-         *
1653
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1654
-         * @param bool                     $status           The status registrations were changed to.
1655
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1656
-         * @param Registrations_Admin_Page $admin_page_object
1657
-         */
1658
-        $this->_req_data['_REG_ID'] = apply_filters(
1659
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1660
-            $result['REG_ID'],
1661
-            $status,
1662
-            $result['success'],
1663
-            $this
1664
-        );
1665
-
1666
-        // notify?
1667
-        if ($notify
1668
-            && $result['success']
1669
-            && ! empty($this->_req_data['_REG_ID'])
1670
-            && EE_Registry::instance()->CAP->current_user_can(
1671
-                'ee_send_message',
1672
-                'espresso_registrations_resend_registration'
1673
-            )
1674
-        ) {
1675
-            $this->_process_resend_registration();
1676
-        }
1677
-        return $result;
1678
-    }
1679
-
1680
-
1681
-    /**
1682
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1683
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1684
-     *
1685
-     * @param array  $REG_IDs
1686
-     * @param string $status
1687
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1688
-     *                        slug sent with setting the registration status.
1689
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1690
-     * @throws EE_Error
1691
-     * @throws InvalidArgumentException
1692
-     * @throws InvalidDataTypeException
1693
-     * @throws InvalidInterfaceException
1694
-     * @throws ReflectionException
1695
-     * @throws RuntimeException
1696
-     * @throws EntityNotFoundException
1697
-     * @throws DomainException
1698
-     */
1699
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1700
-    {
1701
-        $success = false;
1702
-        // typecast $REG_IDs
1703
-        $REG_IDs = (array) $REG_IDs;
1704
-        if (! empty($REG_IDs)) {
1705
-            $success = true;
1706
-            // set default status if none is passed
1707
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1708
-            $status_context = $notify
1709
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1710
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1711
-            // loop through REG_ID's and change status
1712
-            foreach ($REG_IDs as $REG_ID) {
1713
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1714
-                if ($registration instanceof EE_Registration) {
1715
-                    $registration->set_status(
1716
-                        $status,
1717
-                        false,
1718
-                        new Context(
1719
-                            $status_context,
1720
-                            esc_html__(
1721
-                                'Manually triggered status change on a Registration Admin Page route.',
1722
-                                'event_espresso'
1723
-                            )
1724
-                        )
1725
-                    );
1726
-                    $result = $registration->save();
1727
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1728
-                    $success = $result !== false ? $success : false;
1729
-                }
1730
-            }
1731
-        }
1732
-
1733
-        // return $success and processed registrations
1734
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1735
-    }
1736
-
1737
-
1738
-    /**
1739
-     * Common logic for setting up success message and redirecting to appropriate route
1740
-     *
1741
-     * @param string $STS_ID status id for the registration changed to
1742
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1743
-     * @return void
1744
-     * @throws DomainException
1745
-     * @throws EE_Error
1746
-     * @throws EntityNotFoundException
1747
-     * @throws InvalidArgumentException
1748
-     * @throws InvalidDataTypeException
1749
-     * @throws InvalidInterfaceException
1750
-     * @throws ReflectionException
1751
-     * @throws RuntimeException
1752
-     */
1753
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1754
-    {
1755
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1756
-            : array('success' => false);
1757
-        $success = isset($result['success']) && $result['success'];
1758
-        // setup success message
1759
-        if ($success) {
1760
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1761
-                $msg = sprintf(
1762
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1763
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1764
-                );
1765
-            } else {
1766
-                $msg = sprintf(
1767
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1768
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1769
-                );
1770
-            }
1771
-            EE_Error::add_success($msg);
1772
-        } else {
1773
-            EE_Error::add_error(
1774
-                esc_html__(
1775
-                    'Something went wrong, and the status was not changed',
1776
-                    'event_espresso'
1777
-                ),
1778
-                __FILE__,
1779
-                __LINE__,
1780
-                __FUNCTION__
1781
-            );
1782
-        }
1783
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] === 'view_registration') {
1784
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1785
-        } else {
1786
-            $route = array('action' => 'default');
1787
-        }
1788
-        $route = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1789
-        $this->_redirect_after_action($success, '', '', $route, true);
1790
-    }
1791
-
1792
-
1793
-    /**
1794
-     * incoming reg status change from reg details page.
1795
-     *
1796
-     * @return void
1797
-     * @throws EE_Error
1798
-     * @throws EntityNotFoundException
1799
-     * @throws InvalidArgumentException
1800
-     * @throws InvalidDataTypeException
1801
-     * @throws InvalidInterfaceException
1802
-     * @throws ReflectionException
1803
-     * @throws RuntimeException
1804
-     * @throws DomainException
1805
-     */
1806
-    protected function _change_reg_status()
1807
-    {
1808
-        $this->_req_data['return'] = 'view_registration';
1809
-        // set notify based on whether the send notifications toggle is set or not
1810
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1811
-        // $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1812
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
1813
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
1814
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1815
-            case EEM_Registration::status_id_approved:
1816
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1817
-                $this->approve_registration($notify);
1818
-                break;
1819
-            case EEM_Registration::status_id_pending_payment:
1820
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1821
-                $this->pending_registration($notify);
1822
-                break;
1823
-            case EEM_Registration::status_id_not_approved:
1824
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1825
-                $this->not_approve_registration($notify);
1826
-                break;
1827
-            case EEM_Registration::status_id_declined:
1828
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1829
-                $this->decline_registration($notify);
1830
-                break;
1831
-            case EEM_Registration::status_id_cancelled:
1832
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1833
-                $this->cancel_registration($notify);
1834
-                break;
1835
-            case EEM_Registration::status_id_wait_list:
1836
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1837
-                $this->wait_list_registration($notify);
1838
-                break;
1839
-            case EEM_Registration::status_id_incomplete:
1840
-            default:
1841
-                $result['success'] = false;
1842
-                unset($this->_req_data['return']);
1843
-                $this->_reg_status_change_return('', false);
1844
-                break;
1845
-        }
1846
-    }
1847
-
1848
-
1849
-    /**
1850
-     * Callback for bulk action routes.
1851
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1852
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1853
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1854
-     * when an action is happening on just a single registration).
1855
-     *
1856
-     * @param      $action
1857
-     * @param bool $notify
1858
-     */
1859
-    protected function bulk_action_on_registrations($action, $notify = false)
1860
-    {
1861
-        do_action(
1862
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1863
-            $this,
1864
-            $action,
1865
-            $notify
1866
-        );
1867
-        $method = $action . '_registration';
1868
-        if (method_exists($this, $method)) {
1869
-            $this->$method($notify);
1870
-        }
1871
-    }
1872
-
1873
-
1874
-    /**
1875
-     * approve_registration
1876
-     *
1877
-     * @access protected
1878
-     * @param bool $notify whether or not to notify the registrant about their approval.
1879
-     * @return void
1880
-     * @throws EE_Error
1881
-     * @throws EntityNotFoundException
1882
-     * @throws InvalidArgumentException
1883
-     * @throws InvalidDataTypeException
1884
-     * @throws InvalidInterfaceException
1885
-     * @throws ReflectionException
1886
-     * @throws RuntimeException
1887
-     * @throws DomainException
1888
-     */
1889
-    protected function approve_registration($notify = false)
1890
-    {
1891
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1892
-    }
1893
-
1894
-
1895
-    /**
1896
-     *        decline_registration
1897
-     *
1898
-     * @access protected
1899
-     * @param bool $notify whether or not to notify the registrant about their status change.
1900
-     * @return void
1901
-     * @throws EE_Error
1902
-     * @throws EntityNotFoundException
1903
-     * @throws InvalidArgumentException
1904
-     * @throws InvalidDataTypeException
1905
-     * @throws InvalidInterfaceException
1906
-     * @throws ReflectionException
1907
-     * @throws RuntimeException
1908
-     * @throws DomainException
1909
-     */
1910
-    protected function decline_registration($notify = false)
1911
-    {
1912
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1913
-    }
1914
-
1915
-
1916
-    /**
1917
-     *        cancel_registration
1918
-     *
1919
-     * @access protected
1920
-     * @param bool $notify whether or not to notify the registrant about their status change.
1921
-     * @return void
1922
-     * @throws EE_Error
1923
-     * @throws EntityNotFoundException
1924
-     * @throws InvalidArgumentException
1925
-     * @throws InvalidDataTypeException
1926
-     * @throws InvalidInterfaceException
1927
-     * @throws ReflectionException
1928
-     * @throws RuntimeException
1929
-     * @throws DomainException
1930
-     */
1931
-    protected function cancel_registration($notify = false)
1932
-    {
1933
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1934
-    }
1935
-
1936
-
1937
-    /**
1938
-     *        not_approve_registration
1939
-     *
1940
-     * @access protected
1941
-     * @param bool $notify whether or not to notify the registrant about their status change.
1942
-     * @return void
1943
-     * @throws EE_Error
1944
-     * @throws EntityNotFoundException
1945
-     * @throws InvalidArgumentException
1946
-     * @throws InvalidDataTypeException
1947
-     * @throws InvalidInterfaceException
1948
-     * @throws ReflectionException
1949
-     * @throws RuntimeException
1950
-     * @throws DomainException
1951
-     */
1952
-    protected function not_approve_registration($notify = false)
1953
-    {
1954
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1955
-    }
1956
-
1957
-
1958
-    /**
1959
-     *        decline_registration
1960
-     *
1961
-     * @access protected
1962
-     * @param bool $notify whether or not to notify the registrant about their status change.
1963
-     * @return void
1964
-     * @throws EE_Error
1965
-     * @throws EntityNotFoundException
1966
-     * @throws InvalidArgumentException
1967
-     * @throws InvalidDataTypeException
1968
-     * @throws InvalidInterfaceException
1969
-     * @throws ReflectionException
1970
-     * @throws RuntimeException
1971
-     * @throws DomainException
1972
-     */
1973
-    protected function pending_registration($notify = false)
1974
-    {
1975
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1976
-    }
1977
-
1978
-
1979
-    /**
1980
-     * waitlist_registration
1981
-     *
1982
-     * @access protected
1983
-     * @param bool $notify whether or not to notify the registrant about their status change.
1984
-     * @return void
1985
-     * @throws EE_Error
1986
-     * @throws EntityNotFoundException
1987
-     * @throws InvalidArgumentException
1988
-     * @throws InvalidDataTypeException
1989
-     * @throws InvalidInterfaceException
1990
-     * @throws ReflectionException
1991
-     * @throws RuntimeException
1992
-     * @throws DomainException
1993
-     */
1994
-    protected function wait_list_registration($notify = false)
1995
-    {
1996
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1997
-    }
1998
-
1999
-
2000
-    /**
2001
-     *        generates HTML for the Registration main meta box
2002
-     *
2003
-     * @access public
2004
-     * @return void
2005
-     * @throws DomainException
2006
-     * @throws EE_Error
2007
-     * @throws InvalidArgumentException
2008
-     * @throws InvalidDataTypeException
2009
-     * @throws InvalidInterfaceException
2010
-     * @throws ReflectionException
2011
-     * @throws EntityNotFoundException
2012
-     */
2013
-    public function _reg_details_meta_box()
2014
-    {
2015
-        EEH_Autoloader::register_line_item_display_autoloaders();
2016
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2017
-        EE_Registry::instance()->load_helper('Line_Item');
2018
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2019
-            : EE_Transaction::new_instance();
2020
-        $this->_session = $transaction->session_data();
2021
-        $filters = new EE_Line_Item_Filter_Collection();
2022
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2023
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2024
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2025
-            $filters,
2026
-            $transaction->total_line_item()
2027
-        );
2028
-        $filtered_line_item_tree = $line_item_filter_processor->process();
2029
-        $line_item_display = new EE_Line_Item_Display(
2030
-            'reg_admin_table',
2031
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2032
-        );
2033
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2034
-            $filtered_line_item_tree,
2035
-            array('EE_Registration' => $this->_registration)
2036
-        );
2037
-        $attendee = $this->_registration->attendee();
2038
-        if (EE_Registry::instance()->CAP->current_user_can(
2039
-            'ee_read_transaction',
2040
-            'espresso_transactions_view_transaction'
2041
-        )) {
2042
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2043
-                EE_Admin_Page::add_query_args_and_nonce(
2044
-                    array(
2045
-                        'action' => 'view_transaction',
2046
-                        'TXN_ID' => $transaction->ID(),
2047
-                    ),
2048
-                    TXN_ADMIN_URL
2049
-                ),
2050
-                esc_html__(' View Transaction', 'event_espresso'),
2051
-                'button secondary-button right',
2052
-                'dashicons dashicons-cart'
2053
-            );
2054
-        } else {
2055
-            $this->_template_args['view_transaction_button'] = '';
2056
-        }
2057
-        if ($attendee instanceof EE_Attendee
2058
-            && EE_Registry::instance()->CAP->current_user_can(
2059
-                'ee_send_message',
2060
-                'espresso_registrations_resend_registration'
2061
-            )
2062
-        ) {
2063
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2064
-                EE_Admin_Page::add_query_args_and_nonce(
2065
-                    array(
2066
-                        'action'      => 'resend_registration',
2067
-                        '_REG_ID'     => $this->_registration->ID(),
2068
-                        'redirect_to' => 'view_registration',
2069
-                    ),
2070
-                    REG_ADMIN_URL
2071
-                ),
2072
-                esc_html__(' Resend Registration', 'event_espresso'),
2073
-                'button secondary-button right',
2074
-                'dashicons dashicons-email-alt'
2075
-            );
2076
-        } else {
2077
-            $this->_template_args['resend_registration_button'] = '';
2078
-        }
2079
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2080
-        $payment = $transaction->get_first_related('Payment');
2081
-        $payment = ! $payment instanceof EE_Payment
2082
-            ? EE_Payment::new_instance()
2083
-            : $payment;
2084
-        $payment_method = $payment->get_first_related('Payment_Method');
2085
-        $payment_method = ! $payment_method instanceof EE_Payment_Method
2086
-            ? EE_Payment_Method::new_instance()
2087
-            : $payment_method;
2088
-        $reg_details = array(
2089
-            'payment_method'       => $payment_method->name(),
2090
-            'response_msg'         => $payment->gateway_response(),
2091
-            'registration_id'      => $this->_registration->get('REG_code'),
2092
-            'registration_session' => $this->_registration->session_ID(),
2093
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2094
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2095
-        );
2096
-        if (isset($reg_details['registration_id'])) {
2097
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2098
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2099
-                'Registration ID',
2100
-                'event_espresso'
2101
-            );
2102
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2103
-        }
2104
-        if (isset($reg_details['payment_method'])) {
2105
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2106
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2107
-                'Most Recent Payment Method',
2108
-                'event_espresso'
2109
-            );
2110
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2111
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2112
-            $this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2113
-                'Payment method response',
2114
-                'event_espresso'
2115
-            );
2116
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2117
-        }
2118
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2119
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2120
-            'Registration Session',
2121
-            'event_espresso'
2122
-        );
2123
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2124
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2125
-        $this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2126
-            'Registration placed from IP',
2127
-            'event_espresso'
2128
-        );
2129
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2130
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2131
-        $this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2132
-            'Registrant User Agent',
2133
-            'event_espresso'
2134
-        );
2135
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2136
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2137
-            array(
2138
-                'action'   => 'default',
2139
-                'event_id' => $this->_registration->event_ID(),
2140
-            ),
2141
-            REG_ADMIN_URL
2142
-        );
2143
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2144
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2145
-        $template_path =
2146
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2147
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2148
-    }
2149
-
2150
-
2151
-    /**
2152
-     * generates HTML for the Registration Questions meta box.
2153
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2154
-     * otherwise uses new forms system
2155
-     *
2156
-     * @access public
2157
-     * @return void
2158
-     * @throws DomainException
2159
-     * @throws EE_Error
2160
-     * @throws InvalidArgumentException
2161
-     * @throws InvalidDataTypeException
2162
-     * @throws InvalidInterfaceException
2163
-     * @throws ReflectionException
2164
-     */
2165
-    public function _reg_questions_meta_box()
2166
-    {
2167
-        // allow someone to override this method entirely
2168
-        if (apply_filters(
2169
-            'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2170
-            true,
2171
-            $this,
2172
-            $this->_registration
2173
-        )) {
2174
-            $form = $this->_get_reg_custom_questions_form(
2175
-                $this->_registration->ID()
2176
-            );
2177
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2178
-                ? $form->get_html_and_js()
2179
-                : '';
2180
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2181
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2182
-            $template_path =
2183
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2184
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
2185
-        }
2186
-    }
2187
-
2188
-
2189
-    /**
2190
-     * form_before_question_group
2191
-     *
2192
-     * @deprecated    as of 4.8.32.rc.000
2193
-     * @access        public
2194
-     * @param        string $output
2195
-     * @return        string
2196
-     */
2197
-    public function form_before_question_group($output)
2198
-    {
2199
-        EE_Error::doing_it_wrong(
2200
-            __CLASS__ . '::' . __FUNCTION__,
2201
-            esc_html__(
2202
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2203
-                'event_espresso'
2204
-            ),
2205
-            '4.8.32.rc.000'
2206
-        );
2207
-        return '
21
+	/**
22
+	 * @var EE_Registration
23
+	 */
24
+	private $_registration;
25
+
26
+	/**
27
+	 * @var EE_Event
28
+	 */
29
+	private $_reg_event;
30
+
31
+	/**
32
+	 * @var EE_Session
33
+	 */
34
+	private $_session;
35
+
36
+	private static $_reg_status;
37
+
38
+	/**
39
+	 * Form for displaying the custom questions for this registration.
40
+	 * This gets used a few times throughout the request so its best to cache it
41
+	 *
42
+	 * @var EE_Registration_Custom_Questions_Form
43
+	 */
44
+	protected $_reg_custom_questions_form;
45
+
46
+	/**
47
+	 * @var EEM_Registration $registration_model
48
+	 */
49
+	private $registration_model;
50
+
51
+	/**
52
+	 * @var EEM_Attendee $attendee_model
53
+	 */
54
+	private $attendee_model;
55
+
56
+	/**
57
+	 * @var EEM_Event $event_model
58
+	 */
59
+	private $event_model;
60
+
61
+	/**
62
+	 * @var EEM_Status $status_model
63
+	 */
64
+	private $status_model;
65
+
66
+
67
+	/**
68
+	 * @param bool $routing
69
+	 * @throws EE_Error
70
+	 * @throws InvalidArgumentException
71
+	 * @throws InvalidDataTypeException
72
+	 * @throws InvalidInterfaceException
73
+	 * @throws ReflectionException
74
+	 */
75
+	public function __construct($routing = true)
76
+	{
77
+		parent::__construct($routing);
78
+		add_action('wp_loaded', array($this, 'wp_loaded'));
79
+	}
80
+
81
+	/**
82
+	 * @return EEM_Registration
83
+	 * @throws InvalidArgumentException
84
+	 * @throws InvalidDataTypeException
85
+	 * @throws InvalidInterfaceException
86
+	 * @since 4.10.2.p
87
+	 */
88
+	protected function getRegistrationModel()
89
+	{
90
+		if (! $this->registration_model instanceof EEM_Registration) {
91
+			$this->registration_model = $this->loader->getShared('EEM_Registration');
92
+		}
93
+		return $this->registration_model;
94
+	}
95
+
96
+	/**
97
+	 * @return EEM_Attendee
98
+	 * @throws InvalidArgumentException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws InvalidInterfaceException
101
+	 * @since 4.10.2.p
102
+	 */
103
+	protected function getAttendeeModel()
104
+	{
105
+		if (! $this->attendee_model instanceof EEM_Attendee) {
106
+			$this->attendee_model = $this->loader->getShared('EEM_Attendee');
107
+		}
108
+		return $this->attendee_model;
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return EEM_Event
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidInterfaceException
117
+	 * @since 4.10.2.p
118
+	 */
119
+	protected function getEventModel()
120
+	{
121
+		if (! $this->event_model instanceof EEM_Event) {
122
+			$this->event_model = $this->loader->getShared('EEM_Event');
123
+		}
124
+		return $this->event_model;
125
+	}
126
+
127
+	/**
128
+	 * @return EEM_Status
129
+	 * @throws InvalidArgumentException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidInterfaceException
132
+	 * @since 4.10.2.p
133
+	 */
134
+	protected function getStatusModel()
135
+	{
136
+		if (! $this->status_model instanceof EEM_Status) {
137
+			$this->status_model = $this->loader->getShared('EEM_Status');
138
+		}
139
+		return $this->status_model;
140
+	}
141
+
142
+
143
+	public function wp_loaded()
144
+	{
145
+		// when adding a new registration...
146
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
147
+			EE_System::do_not_cache();
148
+			if (! isset($this->_req_data['processing_registration'])
149
+				|| absint($this->_req_data['processing_registration']) !== 1
150
+			) {
151
+				// and it's NOT the attendee information reg step
152
+				// force cookie expiration by setting time to last week
153
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
154
+				// and update the global
155
+				$_COOKIE['ee_registration_added'] = 0;
156
+			}
157
+		}
158
+	}
159
+
160
+
161
+	protected function _init_page_props()
162
+	{
163
+		$this->page_slug = REG_PG_SLUG;
164
+		$this->_admin_base_url = REG_ADMIN_URL;
165
+		$this->_admin_base_path = REG_ADMIN;
166
+		$this->page_label = esc_html__('Registrations', 'event_espresso');
167
+		$this->_cpt_routes = array(
168
+			'add_new_attendee' => 'espresso_attendees',
169
+			'edit_attendee'    => 'espresso_attendees',
170
+			'insert_attendee'  => 'espresso_attendees',
171
+			'update_attendee'  => 'espresso_attendees',
172
+		);
173
+		$this->_cpt_model_names = array(
174
+			'add_new_attendee' => 'EEM_Attendee',
175
+			'edit_attendee'    => 'EEM_Attendee',
176
+		);
177
+		$this->_cpt_edit_routes = array(
178
+			'espresso_attendees' => 'edit_attendee',
179
+		);
180
+		$this->_pagenow_map = array(
181
+			'add_new_attendee' => 'post-new.php',
182
+			'edit_attendee'    => 'post.php',
183
+			'trash'            => 'post.php',
184
+		);
185
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
186
+		// add filters so that the comment urls don't take users to a confusing 404 page
187
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
188
+	}
189
+
190
+
191
+	public function clear_comment_link($link, $comment, $args)
192
+	{
193
+		// gotta make sure this only happens on this route
194
+		$post_type = get_post_type($comment->comment_post_ID);
195
+		if ($post_type === 'espresso_attendees') {
196
+			return '#commentsdiv';
197
+		}
198
+		return $link;
199
+	}
200
+
201
+
202
+	protected function _ajax_hooks()
203
+	{
204
+		// todo: all hooks for registrations ajax goes in here
205
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
206
+	}
207
+
208
+
209
+	protected function _define_page_props()
210
+	{
211
+		$this->_admin_page_title = $this->page_label;
212
+		$this->_labels = array(
213
+			'buttons'                      => array(
214
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
215
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
216
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
217
+				'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
218
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
219
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
220
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
221
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
222
+			),
223
+			'publishbox'                   => array(
224
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
225
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
226
+			),
227
+			'hide_add_button_on_cpt_route' => array(
228
+				'edit_attendee' => true,
229
+			),
230
+		);
231
+	}
232
+
233
+
234
+	/**
235
+	 *        grab url requests and route them
236
+	 *
237
+	 * @access private
238
+	 * @return void
239
+	 * @throws EE_Error
240
+	 */
241
+	public function _set_page_routes()
242
+	{
243
+		$this->_get_registration_status_array();
244
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
245
+			? $this->_req_data['_REG_ID'] : 0;
246
+		$reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
247
+			? $this->_req_data['reg_status_change_form']['REG_ID']
248
+			: $reg_id;
249
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
250
+			? $this->_req_data['ATT_ID'] : 0;
251
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
252
+			? $this->_req_data['post']
253
+			: $att_id;
254
+		$this->_page_routes = array(
255
+			'default'                             => array(
256
+				'func'       => '_registrations_overview_list_table',
257
+				'capability' => 'ee_read_registrations',
258
+			),
259
+			'view_registration'                   => array(
260
+				'func'       => '_registration_details',
261
+				'capability' => 'ee_read_registration',
262
+				'obj_id'     => $reg_id,
263
+			),
264
+			'edit_registration'                   => array(
265
+				'func'               => '_update_attendee_registration_form',
266
+				'noheader'           => true,
267
+				'headers_sent_route' => 'view_registration',
268
+				'capability'         => 'ee_edit_registration',
269
+				'obj_id'             => $reg_id,
270
+				'_REG_ID'            => $reg_id,
271
+			),
272
+			'trash_registrations'                 => array(
273
+				'func'       => '_trash_or_restore_registrations',
274
+				'args'       => array('trash' => true),
275
+				'noheader'   => true,
276
+				'capability' => 'ee_delete_registrations',
277
+			),
278
+			'restore_registrations'               => array(
279
+				'func'       => '_trash_or_restore_registrations',
280
+				'args'       => array('trash' => false),
281
+				'noheader'   => true,
282
+				'capability' => 'ee_delete_registrations',
283
+			),
284
+			'delete_registrations'                => array(
285
+				'func'       => '_delete_registrations',
286
+				'noheader'   => true,
287
+				'capability' => 'ee_delete_registrations',
288
+			),
289
+			'new_registration'                    => array(
290
+				'func'       => 'new_registration',
291
+				'capability' => 'ee_edit_registrations',
292
+			),
293
+			'process_reg_step'                    => array(
294
+				'func'       => 'process_reg_step',
295
+				'noheader'   => true,
296
+				'capability' => 'ee_edit_registrations',
297
+			),
298
+			'redirect_to_txn'                     => array(
299
+				'func'       => 'redirect_to_txn',
300
+				'noheader'   => true,
301
+				'capability' => 'ee_edit_registrations',
302
+			),
303
+			'change_reg_status'                   => array(
304
+				'func'       => '_change_reg_status',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registration',
307
+				'obj_id'     => $reg_id,
308
+			),
309
+			'approve_registration'                => array(
310
+				'func'       => 'approve_registration',
311
+				'noheader'   => true,
312
+				'capability' => 'ee_edit_registration',
313
+				'obj_id'     => $reg_id,
314
+			),
315
+			'approve_and_notify_registration'     => array(
316
+				'func'       => 'approve_registration',
317
+				'noheader'   => true,
318
+				'args'       => array(true),
319
+				'capability' => 'ee_edit_registration',
320
+				'obj_id'     => $reg_id,
321
+			),
322
+			'approve_registrations'               => array(
323
+				'func'       => 'bulk_action_on_registrations',
324
+				'noheader'   => true,
325
+				'capability' => 'ee_edit_registrations',
326
+				'args'       => array('approve'),
327
+			),
328
+			'approve_and_notify_registrations'    => array(
329
+				'func'       => 'bulk_action_on_registrations',
330
+				'noheader'   => true,
331
+				'capability' => 'ee_edit_registrations',
332
+				'args'       => array('approve', true),
333
+			),
334
+			'decline_registration'                => array(
335
+				'func'       => 'decline_registration',
336
+				'noheader'   => true,
337
+				'capability' => 'ee_edit_registration',
338
+				'obj_id'     => $reg_id,
339
+			),
340
+			'decline_and_notify_registration'     => array(
341
+				'func'       => 'decline_registration',
342
+				'noheader'   => true,
343
+				'args'       => array(true),
344
+				'capability' => 'ee_edit_registration',
345
+				'obj_id'     => $reg_id,
346
+			),
347
+			'decline_registrations'               => array(
348
+				'func'       => 'bulk_action_on_registrations',
349
+				'noheader'   => true,
350
+				'capability' => 'ee_edit_registrations',
351
+				'args'       => array('decline'),
352
+			),
353
+			'decline_and_notify_registrations'    => array(
354
+				'func'       => 'bulk_action_on_registrations',
355
+				'noheader'   => true,
356
+				'capability' => 'ee_edit_registrations',
357
+				'args'       => array('decline', true),
358
+			),
359
+			'pending_registration'                => array(
360
+				'func'       => 'pending_registration',
361
+				'noheader'   => true,
362
+				'capability' => 'ee_edit_registration',
363
+				'obj_id'     => $reg_id,
364
+			),
365
+			'pending_and_notify_registration'     => array(
366
+				'func'       => 'pending_registration',
367
+				'noheader'   => true,
368
+				'args'       => array(true),
369
+				'capability' => 'ee_edit_registration',
370
+				'obj_id'     => $reg_id,
371
+			),
372
+			'pending_registrations'               => array(
373
+				'func'       => 'bulk_action_on_registrations',
374
+				'noheader'   => true,
375
+				'capability' => 'ee_edit_registrations',
376
+				'args'       => array('pending'),
377
+			),
378
+			'pending_and_notify_registrations'    => array(
379
+				'func'       => 'bulk_action_on_registrations',
380
+				'noheader'   => true,
381
+				'capability' => 'ee_edit_registrations',
382
+				'args'       => array('pending', true),
383
+			),
384
+			'no_approve_registration'             => array(
385
+				'func'       => 'not_approve_registration',
386
+				'noheader'   => true,
387
+				'capability' => 'ee_edit_registration',
388
+				'obj_id'     => $reg_id,
389
+			),
390
+			'no_approve_and_notify_registration'  => array(
391
+				'func'       => 'not_approve_registration',
392
+				'noheader'   => true,
393
+				'args'       => array(true),
394
+				'capability' => 'ee_edit_registration',
395
+				'obj_id'     => $reg_id,
396
+			),
397
+			'no_approve_registrations'            => array(
398
+				'func'       => 'bulk_action_on_registrations',
399
+				'noheader'   => true,
400
+				'capability' => 'ee_edit_registrations',
401
+				'args'       => array('not_approve'),
402
+			),
403
+			'no_approve_and_notify_registrations' => array(
404
+				'func'       => 'bulk_action_on_registrations',
405
+				'noheader'   => true,
406
+				'capability' => 'ee_edit_registrations',
407
+				'args'       => array('not_approve', true),
408
+			),
409
+			'cancel_registration'                 => array(
410
+				'func'       => 'cancel_registration',
411
+				'noheader'   => true,
412
+				'capability' => 'ee_edit_registration',
413
+				'obj_id'     => $reg_id,
414
+			),
415
+			'cancel_and_notify_registration'      => array(
416
+				'func'       => 'cancel_registration',
417
+				'noheader'   => true,
418
+				'args'       => array(true),
419
+				'capability' => 'ee_edit_registration',
420
+				'obj_id'     => $reg_id,
421
+			),
422
+			'cancel_registrations'                => array(
423
+				'func'       => 'bulk_action_on_registrations',
424
+				'noheader'   => true,
425
+				'capability' => 'ee_edit_registrations',
426
+				'args'       => array('cancel'),
427
+			),
428
+			'cancel_and_notify_registrations'     => array(
429
+				'func'       => 'bulk_action_on_registrations',
430
+				'noheader'   => true,
431
+				'capability' => 'ee_edit_registrations',
432
+				'args'       => array('cancel', true),
433
+			),
434
+			'wait_list_registration'              => array(
435
+				'func'       => 'wait_list_registration',
436
+				'noheader'   => true,
437
+				'capability' => 'ee_edit_registration',
438
+				'obj_id'     => $reg_id,
439
+			),
440
+			'wait_list_and_notify_registration'   => array(
441
+				'func'       => 'wait_list_registration',
442
+				'noheader'   => true,
443
+				'args'       => array(true),
444
+				'capability' => 'ee_edit_registration',
445
+				'obj_id'     => $reg_id,
446
+			),
447
+			'contact_list'                        => array(
448
+				'func'       => '_attendee_contact_list_table',
449
+				'capability' => 'ee_read_contacts',
450
+			),
451
+			'add_new_attendee'                    => array(
452
+				'func' => '_create_new_cpt_item',
453
+				'args' => array(
454
+					'new_attendee' => true,
455
+					'capability'   => 'ee_edit_contacts',
456
+				),
457
+			),
458
+			'edit_attendee'                       => array(
459
+				'func'       => '_edit_cpt_item',
460
+				'capability' => 'ee_edit_contacts',
461
+				'obj_id'     => $att_id,
462
+			),
463
+			'duplicate_attendee'                  => array(
464
+				'func'       => '_duplicate_attendee',
465
+				'noheader'   => true,
466
+				'capability' => 'ee_edit_contacts',
467
+				'obj_id'     => $att_id,
468
+			),
469
+			'insert_attendee'                     => array(
470
+				'func'       => '_insert_or_update_attendee',
471
+				'args'       => array(
472
+					'new_attendee' => true,
473
+				),
474
+				'noheader'   => true,
475
+				'capability' => 'ee_edit_contacts',
476
+			),
477
+			'update_attendee'                     => array(
478
+				'func'       => '_insert_or_update_attendee',
479
+				'args'       => array(
480
+					'new_attendee' => false,
481
+				),
482
+				'noheader'   => true,
483
+				'capability' => 'ee_edit_contacts',
484
+				'obj_id'     => $att_id,
485
+			),
486
+			'trash_attendees'                     => array(
487
+				'func'       => '_trash_or_restore_attendees',
488
+				'args'       => array(
489
+					'trash' => 'true',
490
+				),
491
+				'noheader'   => true,
492
+				'capability' => 'ee_delete_contacts',
493
+			),
494
+			'trash_attendee'                      => array(
495
+				'func'       => '_trash_or_restore_attendees',
496
+				'args'       => array(
497
+					'trash' => true,
498
+				),
499
+				'noheader'   => true,
500
+				'capability' => 'ee_delete_contacts',
501
+				'obj_id'     => $att_id,
502
+			),
503
+			'restore_attendees'                   => array(
504
+				'func'       => '_trash_or_restore_attendees',
505
+				'args'       => array(
506
+					'trash' => false,
507
+				),
508
+				'noheader'   => true,
509
+				'capability' => 'ee_delete_contacts',
510
+				'obj_id'     => $att_id,
511
+			),
512
+			'resend_registration'                 => array(
513
+				'func'       => '_resend_registration',
514
+				'noheader'   => true,
515
+				'capability' => 'ee_send_message',
516
+			),
517
+			'registrations_report'                => array(
518
+				'func'       => '_registrations_report',
519
+				'noheader'   => true,
520
+				'capability' => 'ee_read_registrations',
521
+			),
522
+			'contact_list_export'                 => array(
523
+				'func'       => '_contact_list_export',
524
+				'noheader'   => true,
525
+				'capability' => 'export',
526
+			),
527
+			'contact_list_report'                 => array(
528
+				'func'       => '_contact_list_report',
529
+				'noheader'   => true,
530
+				'capability' => 'ee_read_contacts',
531
+			),
532
+		);
533
+	}
534
+
535
+
536
+	protected function _set_page_config()
537
+	{
538
+		$this->_page_config = array(
539
+			'default'           => array(
540
+				'nav'           => array(
541
+					'label' => esc_html__('Overview', 'event_espresso'),
542
+					'order' => 5,
543
+				),
544
+				'help_tabs'     => array(
545
+					'registrations_overview_help_tab'                       => array(
546
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
547
+						'filename' => 'registrations_overview',
548
+					),
549
+					'registrations_overview_table_column_headings_help_tab' => array(
550
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
551
+						'filename' => 'registrations_overview_table_column_headings',
552
+					),
553
+					'registrations_overview_filters_help_tab'               => array(
554
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
555
+						'filename' => 'registrations_overview_filters',
556
+					),
557
+					'registrations_overview_views_help_tab'                 => array(
558
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
559
+						'filename' => 'registrations_overview_views',
560
+					),
561
+					'registrations_regoverview_other_help_tab'              => array(
562
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
563
+						'filename' => 'registrations_overview_other',
564
+					),
565
+				),
566
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
567
+				'qtips'         => array('Registration_List_Table_Tips'),
568
+				'list_table'    => 'EE_Registrations_List_Table',
569
+				'require_nonce' => false,
570
+			),
571
+			'view_registration' => array(
572
+				'nav'           => array(
573
+					'label'      => esc_html__('REG Details', 'event_espresso'),
574
+					'order'      => 15,
575
+					'url'        => isset($this->_req_data['_REG_ID'])
576
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
577
+						: $this->_admin_base_url,
578
+					'persistent' => false,
579
+				),
580
+				'help_tabs'     => array(
581
+					'registrations_details_help_tab'                    => array(
582
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
583
+						'filename' => 'registrations_details',
584
+					),
585
+					'registrations_details_table_help_tab'              => array(
586
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
587
+						'filename' => 'registrations_details_table',
588
+					),
589
+					'registrations_details_form_answers_help_tab'       => array(
590
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
591
+						'filename' => 'registrations_details_form_answers',
592
+					),
593
+					'registrations_details_registrant_details_help_tab' => array(
594
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
595
+						'filename' => 'registrations_details_registrant_details',
596
+					),
597
+				),
598
+				'help_tour'     => array('Registration_Details_Help_Tour'),
599
+				'metaboxes'     => array_merge(
600
+					$this->_default_espresso_metaboxes,
601
+					array('_registration_details_metaboxes')
602
+				),
603
+				'require_nonce' => false,
604
+			),
605
+			'new_registration'  => array(
606
+				'nav'           => array(
607
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
608
+					'url'        => '#',
609
+					'order'      => 15,
610
+					'persistent' => false,
611
+				),
612
+				'metaboxes'     => $this->_default_espresso_metaboxes,
613
+				'labels'        => array(
614
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
615
+				),
616
+				'require_nonce' => false,
617
+			),
618
+			'add_new_attendee'  => array(
619
+				'nav'           => array(
620
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
621
+					'order'      => 15,
622
+					'persistent' => false,
623
+				),
624
+				'metaboxes'     => array_merge(
625
+					$this->_default_espresso_metaboxes,
626
+					array('_publish_post_box', 'attendee_editor_metaboxes')
627
+				),
628
+				'require_nonce' => false,
629
+			),
630
+			'edit_attendee'     => array(
631
+				'nav'           => array(
632
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
633
+					'order'      => 15,
634
+					'persistent' => false,
635
+					'url'        => isset($this->_req_data['ATT_ID'])
636
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
637
+						: $this->_admin_base_url,
638
+				),
639
+				'metaboxes'     => array('attendee_editor_metaboxes'),
640
+				'require_nonce' => false,
641
+			),
642
+			'contact_list'      => array(
643
+				'nav'           => array(
644
+					'label' => esc_html__('Contact List', 'event_espresso'),
645
+					'order' => 20,
646
+				),
647
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
648
+				'help_tabs'     => array(
649
+					'registrations_contact_list_help_tab'                       => array(
650
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
651
+						'filename' => 'registrations_contact_list',
652
+					),
653
+					'registrations_contact-list_table_column_headings_help_tab' => array(
654
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
655
+						'filename' => 'registrations_contact_list_table_column_headings',
656
+					),
657
+					'registrations_contact_list_views_help_tab'                 => array(
658
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
659
+						'filename' => 'registrations_contact_list_views',
660
+					),
661
+					'registrations_contact_list_other_help_tab'                 => array(
662
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
663
+						'filename' => 'registrations_contact_list_other',
664
+					),
665
+				),
666
+				'help_tour'     => array('Contact_List_Help_Tour'),
667
+				'metaboxes'     => array(),
668
+				'require_nonce' => false,
669
+			),
670
+			// override default cpt routes
671
+			'create_new'        => '',
672
+			'edit'              => '',
673
+		);
674
+	}
675
+
676
+
677
+	/**
678
+	 * The below methods aren't used by this class currently
679
+	 */
680
+	protected function _add_screen_options()
681
+	{
682
+	}
683
+
684
+
685
+	protected function _add_feature_pointers()
686
+	{
687
+	}
688
+
689
+
690
+	public function admin_init()
691
+	{
692
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
693
+			'click "Update Registration Questions" to save your changes',
694
+			'event_espresso'
695
+		);
696
+	}
697
+
698
+
699
+	public function admin_notices()
700
+	{
701
+	}
702
+
703
+
704
+	public function admin_footer_scripts()
705
+	{
706
+	}
707
+
708
+
709
+	/**
710
+	 *        get list of registration statuses
711
+	 *
712
+	 * @access private
713
+	 * @return void
714
+	 * @throws EE_Error
715
+	 */
716
+	private function _get_registration_status_array()
717
+	{
718
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
719
+	}
720
+
721
+
722
+	/**
723
+	 * @throws InvalidArgumentException
724
+	 * @throws InvalidDataTypeException
725
+	 * @throws InvalidInterfaceException
726
+	 * @since 4.10.2.p
727
+	 */
728
+	protected function _add_screen_options_default()
729
+	{
730
+		$this->_per_page_screen_option();
731
+	}
732
+
733
+
734
+	/**
735
+	 * @throws InvalidArgumentException
736
+	 * @throws InvalidDataTypeException
737
+	 * @throws InvalidInterfaceException
738
+	 * @since 4.10.2.p
739
+	 */
740
+	protected function _add_screen_options_contact_list()
741
+	{
742
+		$page_title = $this->_admin_page_title;
743
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
744
+		$this->_per_page_screen_option();
745
+		$this->_admin_page_title = $page_title;
746
+	}
747
+
748
+
749
+	public function load_scripts_styles()
750
+	{
751
+		// style
752
+		wp_register_style(
753
+			'espresso_reg',
754
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
755
+			array('ee-admin-css'),
756
+			EVENT_ESPRESSO_VERSION
757
+		);
758
+		wp_enqueue_style('espresso_reg');
759
+		// script
760
+		wp_register_script(
761
+			'espresso_reg',
762
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
763
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
764
+			EVENT_ESPRESSO_VERSION,
765
+			true
766
+		);
767
+		wp_enqueue_script('espresso_reg');
768
+	}
769
+
770
+
771
+	/**
772
+	 * @throws EE_Error
773
+	 * @throws InvalidArgumentException
774
+	 * @throws InvalidDataTypeException
775
+	 * @throws InvalidInterfaceException
776
+	 * @throws ReflectionException
777
+	 * @since 4.10.2.p
778
+	 */
779
+	public function load_scripts_styles_edit_attendee()
780
+	{
781
+		// stuff to only show up on our attendee edit details page.
782
+		$attendee_details_translations = array(
783
+			'att_publish_text' => sprintf(
784
+				/* translators: The date and time */
785
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
786
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
787
+			),
788
+		);
789
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
790
+		wp_enqueue_script('jquery-validate');
791
+	}
792
+
793
+
794
+	/**
795
+	 * @throws EE_Error
796
+	 * @throws InvalidArgumentException
797
+	 * @throws InvalidDataTypeException
798
+	 * @throws InvalidInterfaceException
799
+	 * @throws ReflectionException
800
+	 * @since 4.10.2.p
801
+	 */
802
+	public function load_scripts_styles_view_registration()
803
+	{
804
+		// styles
805
+		wp_enqueue_style('espresso-ui-theme');
806
+		// scripts
807
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
808
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
809
+	}
810
+
811
+
812
+	public function load_scripts_styles_contact_list()
813
+	{
814
+		wp_dequeue_style('espresso_reg');
815
+		wp_register_style(
816
+			'espresso_att',
817
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
818
+			array('ee-admin-css'),
819
+			EVENT_ESPRESSO_VERSION
820
+		);
821
+		wp_enqueue_style('espresso_att');
822
+	}
823
+
824
+
825
+	public function load_scripts_styles_new_registration()
826
+	{
827
+		wp_register_script(
828
+			'ee-spco-for-admin',
829
+			REG_ASSETS_URL . 'spco_for_admin.js',
830
+			array('underscore', 'jquery'),
831
+			EVENT_ESPRESSO_VERSION,
832
+			true
833
+		);
834
+		wp_enqueue_script('ee-spco-for-admin');
835
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
836
+		EE_Form_Section_Proper::wp_enqueue_scripts();
837
+		EED_Ticket_Selector::load_tckt_slctr_assets();
838
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
839
+	}
840
+
841
+
842
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
843
+	{
844
+		add_filter('FHEE_load_EE_messages', '__return_true');
845
+	}
846
+
847
+
848
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
849
+	{
850
+		add_filter('FHEE_load_EE_messages', '__return_true');
851
+	}
852
+
853
+
854
+	/**
855
+	 * @throws EE_Error
856
+	 * @throws InvalidArgumentException
857
+	 * @throws InvalidDataTypeException
858
+	 * @throws InvalidInterfaceException
859
+	 * @throws ReflectionException
860
+	 * @since 4.10.2.p
861
+	 */
862
+	protected function _set_list_table_views_default()
863
+	{
864
+		// for notification related bulk actions we need to make sure only active messengers have an option.
865
+		EED_Messages::set_autoloaders();
866
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
867
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
868
+		$active_mts = $message_resource_manager->list_of_active_message_types();
869
+		// key= bulk_action_slug, value= message type.
870
+		$match_array = array(
871
+			'approve_registrations'    => 'registration',
872
+			'decline_registrations'    => 'declined_registration',
873
+			'pending_registrations'    => 'pending_approval',
874
+			'no_approve_registrations' => 'not_approved_registration',
875
+			'cancel_registrations'     => 'cancelled_registration',
876
+		);
877
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
878
+			'ee_send_message',
879
+			'batch_send_messages'
880
+		);
881
+		/** setup reg status bulk actions **/
882
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
883
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
884
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
885
+				'Approve and Notify Registrations',
886
+				'event_espresso'
887
+			);
888
+		}
889
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
890
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
891
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
892
+				'Decline and Notify Registrations',
893
+				'event_espresso'
894
+			);
895
+		}
896
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
897
+			'Set Registrations to Pending Payment',
898
+			'event_espresso'
899
+		);
900
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
901
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
902
+				'Set Registrations to Pending Payment and Notify',
903
+				'event_espresso'
904
+			);
905
+		}
906
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
907
+			'Set Registrations to Not Approved',
908
+			'event_espresso'
909
+		);
910
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
911
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
912
+				'Set Registrations to Not Approved and Notify',
913
+				'event_espresso'
914
+			);
915
+		}
916
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
917
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
918
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
919
+				'Cancel Registrations and Notify',
920
+				'event_espresso'
921
+			);
922
+		}
923
+		$def_reg_status_actions = apply_filters(
924
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
925
+			$def_reg_status_actions,
926
+			$active_mts,
927
+			$can_send
928
+		);
929
+
930
+		$this->_views = array(
931
+			'all'   => array(
932
+				'slug'        => 'all',
933
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
934
+				'count'       => 0,
935
+				'bulk_action' => array_merge(
936
+					$def_reg_status_actions,
937
+					array(
938
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
939
+					)
940
+				),
941
+			),
942
+			'month' => array(
943
+				'slug'        => 'month',
944
+				'label'       => esc_html__('This Month', 'event_espresso'),
945
+				'count'       => 0,
946
+				'bulk_action' => array_merge(
947
+					$def_reg_status_actions,
948
+					array(
949
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
950
+					)
951
+				),
952
+			),
953
+			'today' => array(
954
+				'slug'        => 'today',
955
+				'label'       => sprintf(
956
+					esc_html__('Today - %s', 'event_espresso'),
957
+					date('M d, Y', current_time('timestamp'))
958
+				),
959
+				'count'       => 0,
960
+				'bulk_action' => array_merge(
961
+					$def_reg_status_actions,
962
+					array(
963
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
964
+					)
965
+				),
966
+			),
967
+		);
968
+		if (EE_Registry::instance()->CAP->current_user_can(
969
+			'ee_delete_registrations',
970
+			'espresso_registrations_delete_registration'
971
+		)) {
972
+			$this->_views['incomplete'] = array(
973
+				'slug'        => 'incomplete',
974
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
975
+				'count'       => 0,
976
+				'bulk_action' => array(
977
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
978
+				),
979
+			);
980
+			$this->_views['trash'] = array(
981
+				'slug'        => 'trash',
982
+				'label'       => esc_html__('Trash', 'event_espresso'),
983
+				'count'       => 0,
984
+				'bulk_action' => array(
985
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
986
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
987
+				),
988
+			);
989
+		}
990
+	}
991
+
992
+
993
+	protected function _set_list_table_views_contact_list()
994
+	{
995
+		$this->_views = array(
996
+			'in_use' => array(
997
+				'slug'        => 'in_use',
998
+				'label'       => esc_html__('In Use', 'event_espresso'),
999
+				'count'       => 0,
1000
+				'bulk_action' => array(
1001
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1002
+				),
1003
+			),
1004
+		);
1005
+		if (EE_Registry::instance()->CAP->current_user_can(
1006
+			'ee_delete_contacts',
1007
+			'espresso_registrations_trash_attendees'
1008
+		)
1009
+		) {
1010
+			$this->_views['trash'] = array(
1011
+				'slug'        => 'trash',
1012
+				'label'       => esc_html__('Trash', 'event_espresso'),
1013
+				'count'       => 0,
1014
+				'bulk_action' => array(
1015
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1016
+				),
1017
+			);
1018
+		}
1019
+	}
1020
+
1021
+
1022
+	protected function _registration_legend_items()
1023
+	{
1024
+		$fc_items = array(
1025
+			'star-icon'        => array(
1026
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1027
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1028
+			),
1029
+			'view_details'     => array(
1030
+				'class' => 'dashicons dashicons-clipboard',
1031
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1032
+			),
1033
+			'edit_attendee'    => array(
1034
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1035
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1036
+			),
1037
+			'view_transaction' => array(
1038
+				'class' => 'dashicons dashicons-cart',
1039
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1040
+			),
1041
+			'view_invoice'     => array(
1042
+				'class' => 'dashicons dashicons-media-spreadsheet',
1043
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1044
+			),
1045
+		);
1046
+		if (EE_Registry::instance()->CAP->current_user_can(
1047
+			'ee_send_message',
1048
+			'espresso_registrations_resend_registration'
1049
+		)) {
1050
+			$fc_items['resend_registration'] = array(
1051
+				'class' => 'dashicons dashicons-email-alt',
1052
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1053
+			);
1054
+		} else {
1055
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
1056
+		}
1057
+		if (EE_Registry::instance()->CAP->current_user_can(
1058
+			'ee_read_global_messages',
1059
+			'view_filtered_messages'
1060
+		)) {
1061
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1062
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1063
+				$fc_items['view_related_messages'] = array(
1064
+					'class' => $related_for_icon['css_class'],
1065
+					'desc'  => $related_for_icon['label'],
1066
+				);
1067
+			}
1068
+		}
1069
+		$sc_items = array(
1070
+			'approved_status'   => array(
1071
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1072
+				'desc'  => EEH_Template::pretty_status(
1073
+					EEM_Registration::status_id_approved,
1074
+					false,
1075
+					'sentence'
1076
+				),
1077
+			),
1078
+			'pending_status'    => array(
1079
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1080
+				'desc'  => EEH_Template::pretty_status(
1081
+					EEM_Registration::status_id_pending_payment,
1082
+					false,
1083
+					'sentence'
1084
+				),
1085
+			),
1086
+			'wait_list'         => array(
1087
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1088
+				'desc'  => EEH_Template::pretty_status(
1089
+					EEM_Registration::status_id_wait_list,
1090
+					false,
1091
+					'sentence'
1092
+				),
1093
+			),
1094
+			'incomplete_status' => array(
1095
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1096
+				'desc'  => EEH_Template::pretty_status(
1097
+					EEM_Registration::status_id_incomplete,
1098
+					false,
1099
+					'sentence'
1100
+				),
1101
+			),
1102
+			'not_approved'      => array(
1103
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1104
+				'desc'  => EEH_Template::pretty_status(
1105
+					EEM_Registration::status_id_not_approved,
1106
+					false,
1107
+					'sentence'
1108
+				),
1109
+			),
1110
+			'declined_status'   => array(
1111
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1112
+				'desc'  => EEH_Template::pretty_status(
1113
+					EEM_Registration::status_id_declined,
1114
+					false,
1115
+					'sentence'
1116
+				),
1117
+			),
1118
+			'cancelled_status'  => array(
1119
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1120
+				'desc'  => EEH_Template::pretty_status(
1121
+					EEM_Registration::status_id_cancelled,
1122
+					false,
1123
+					'sentence'
1124
+				),
1125
+			),
1126
+		);
1127
+		return array_merge($fc_items, $sc_items);
1128
+	}
1129
+
1130
+
1131
+
1132
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1133
+
1134
+
1135
+
1136
+	/**
1137
+	 * @throws DomainException
1138
+	 * @throws EE_Error
1139
+	 * @throws InvalidArgumentException
1140
+	 * @throws InvalidDataTypeException
1141
+	 * @throws InvalidInterfaceException
1142
+	 * @throws ReflectionException
1143
+	 */
1144
+	protected function _registrations_overview_list_table()
1145
+	{
1146
+		$this->appendAddNewRegistrationButtonToPageTitle();
1147
+		$header_text = '';
1148
+		$admin_page_header_decorators = [
1149
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1150
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1151
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1152
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1153
+		];
1154
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1155
+			$filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1156
+			$header_text = $filter_header_decorator->getHeaderText($header_text);
1157
+		}
1158
+		$this->_template_args['admin_page_header'] = $header_text;
1159
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1160
+		$this->display_admin_list_table_page_with_no_sidebar();
1161
+	}
1162
+
1163
+
1164
+	/**
1165
+	 * @throws EE_Error
1166
+	 * @throws InvalidArgumentException
1167
+	 * @throws InvalidDataTypeException
1168
+	 * @throws InvalidInterfaceException
1169
+	 */
1170
+	private function appendAddNewRegistrationButtonToPageTitle()
1171
+	{
1172
+		$EVT_ID = ! empty($this->_req_data['event_id'])
1173
+			? absint($this->_req_data['event_id'])
1174
+			: 0;
1175
+		if ($EVT_ID
1176
+			&& EE_Registry::instance()->CAP->current_user_can(
1177
+				'ee_edit_registrations',
1178
+				'espresso_registrations_new_registration',
1179
+				$EVT_ID
1180
+			)
1181
+		) {
1182
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1183
+				'new_registration',
1184
+				'add-registrant',
1185
+				array('event_id' => $EVT_ID),
1186
+				'add-new-h2'
1187
+			);
1188
+		}
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * This sets the _registration property for the registration details screen
1194
+	 *
1195
+	 * @access private
1196
+	 * @return bool
1197
+	 * @throws EE_Error
1198
+	 * @throws InvalidArgumentException
1199
+	 * @throws InvalidDataTypeException
1200
+	 * @throws InvalidInterfaceException
1201
+	 */
1202
+	private function _set_registration_object()
1203
+	{
1204
+		// get out if we've already set the object
1205
+		if ($this->_registration instanceof EE_Registration) {
1206
+			return true;
1207
+		}
1208
+		$REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1209
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1210
+			return true;
1211
+		}
1212
+		$error_msg = sprintf(
1213
+			esc_html__(
1214
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1215
+				'event_espresso'
1216
+			),
1217
+			$REG_ID
1218
+		);
1219
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1220
+		$this->_registration = null;
1221
+		return false;
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * Used to retrieve registrations for the list table.
1227
+	 *
1228
+	 * @param int  $per_page
1229
+	 * @param bool $count
1230
+	 * @param bool $this_month
1231
+	 * @param bool $today
1232
+	 * @return EE_Registration[]|int
1233
+	 * @throws EE_Error
1234
+	 * @throws InvalidArgumentException
1235
+	 * @throws InvalidDataTypeException
1236
+	 * @throws InvalidInterfaceException
1237
+	 */
1238
+	public function get_registrations(
1239
+		$per_page = 10,
1240
+		$count = false,
1241
+		$this_month = false,
1242
+		$today = false
1243
+	) {
1244
+		if ($this_month) {
1245
+			$this->_req_data['status'] = 'month';
1246
+		}
1247
+		if ($today) {
1248
+			$this->_req_data['status'] = 'today';
1249
+		}
1250
+		$query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1251
+		/**
1252
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1253
+		 *
1254
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1255
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1256
+		 *                             or if you have the development copy of EE you can view this at the path:
1257
+		 *                             /docs/G--Model-System/model-query-params.md
1258
+		 */
1259
+		$query_params['group_by'] = '';
1260
+
1261
+		return $count
1262
+			? $this->getRegistrationModel()->count($query_params)
1263
+			/** @type EE_Registration[] */
1264
+			: $this->getRegistrationModel()->get_all($query_params);
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1270
+	 * Note: this listens to values on the request for some of the query parameters.
1271
+	 *
1272
+	 * @param array $request
1273
+	 * @param int   $per_page
1274
+	 * @param bool  $count
1275
+	 * @return array
1276
+	 * @throws EE_Error
1277
+	 * @throws InvalidArgumentException
1278
+	 * @throws InvalidDataTypeException
1279
+	 * @throws InvalidInterfaceException
1280
+	 */
1281
+	protected function _get_registration_query_parameters(
1282
+		$request = array(),
1283
+		$per_page = 10,
1284
+		$count = false
1285
+	) {
1286
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1287
+		$list_table_query_builder = $this->loader->getNew(
1288
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1289
+			[ $request ]
1290
+		);
1291
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1292
+	}
1293
+
1294
+
1295
+	public function get_registration_status_array()
1296
+	{
1297
+		return self::$_reg_status;
1298
+	}
1299
+
1300
+
1301
+
1302
+
1303
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1304
+	/**
1305
+	 *        generates HTML for the View Registration Details Admin page
1306
+	 *
1307
+	 * @access protected
1308
+	 * @return void
1309
+	 * @throws DomainException
1310
+	 * @throws EE_Error
1311
+	 * @throws InvalidArgumentException
1312
+	 * @throws InvalidDataTypeException
1313
+	 * @throws InvalidInterfaceException
1314
+	 * @throws EntityNotFoundException
1315
+	 * @throws ReflectionException
1316
+	 */
1317
+	protected function _registration_details()
1318
+	{
1319
+		$this->_template_args = array();
1320
+		$this->_set_registration_object();
1321
+		if (is_object($this->_registration)) {
1322
+			$transaction = $this->_registration->transaction()
1323
+				? $this->_registration->transaction()
1324
+				: EE_Transaction::new_instance();
1325
+			$this->_session = $transaction->session_data();
1326
+			$event_id = $this->_registration->event_ID();
1327
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1328
+			$this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1329
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1330
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1331
+			$this->_template_args['grand_total'] = $transaction->total();
1332
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1333
+			// link back to overview
1334
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1335
+			$this->_template_args['registration'] = $this->_registration;
1336
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1337
+				array(
1338
+					'action'   => 'default',
1339
+					'event_id' => $event_id,
1340
+				),
1341
+				REG_ADMIN_URL
1342
+			);
1343
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1344
+				array(
1345
+					'action' => 'default',
1346
+					'EVT_ID' => $event_id,
1347
+					'page'   => 'espresso_transactions',
1348
+				),
1349
+				admin_url('admin.php')
1350
+			);
1351
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1352
+				array(
1353
+					'page'   => 'espresso_events',
1354
+					'action' => 'edit',
1355
+					'post'   => $event_id,
1356
+				),
1357
+				admin_url('admin.php')
1358
+			);
1359
+			// next and previous links
1360
+			$next_reg = $this->_registration->next(
1361
+				null,
1362
+				array(),
1363
+				'REG_ID'
1364
+			);
1365
+			$this->_template_args['next_registration'] = $next_reg
1366
+				? $this->_next_link(
1367
+					EE_Admin_Page::add_query_args_and_nonce(
1368
+						array(
1369
+							'action'  => 'view_registration',
1370
+							'_REG_ID' => $next_reg['REG_ID'],
1371
+						),
1372
+						REG_ADMIN_URL
1373
+					),
1374
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1375
+				)
1376
+				: '';
1377
+			$previous_reg = $this->_registration->previous(
1378
+				null,
1379
+				array(),
1380
+				'REG_ID'
1381
+			);
1382
+			$this->_template_args['previous_registration'] = $previous_reg
1383
+				? $this->_previous_link(
1384
+					EE_Admin_Page::add_query_args_and_nonce(
1385
+						array(
1386
+							'action'  => 'view_registration',
1387
+							'_REG_ID' => $previous_reg['REG_ID'],
1388
+						),
1389
+						REG_ADMIN_URL
1390
+					),
1391
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1392
+				)
1393
+				: '';
1394
+			// grab header
1395
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1396
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1397
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1398
+				$template_path,
1399
+				$this->_template_args,
1400
+				true
1401
+			);
1402
+		} else {
1403
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1404
+		}
1405
+		// the details template wrapper
1406
+		$this->display_admin_page_with_sidebar();
1407
+	}
1408
+
1409
+
1410
+	/**
1411
+	 * @throws EE_Error
1412
+	 * @throws InvalidArgumentException
1413
+	 * @throws InvalidDataTypeException
1414
+	 * @throws InvalidInterfaceException
1415
+	 * @throws ReflectionException
1416
+	 * @since 4.10.2.p
1417
+	 */
1418
+	protected function _registration_details_metaboxes()
1419
+	{
1420
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1421
+		$this->_set_registration_object();
1422
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1423
+		add_meta_box(
1424
+			'edit-reg-status-mbox',
1425
+			esc_html__('Registration Status', 'event_espresso'),
1426
+			array($this, 'set_reg_status_buttons_metabox'),
1427
+			$this->wp_page_slug,
1428
+			'normal',
1429
+			'high'
1430
+		);
1431
+		add_meta_box(
1432
+			'edit-reg-details-mbox',
1433
+			esc_html__('Registration Details', 'event_espresso'),
1434
+			array($this, '_reg_details_meta_box'),
1435
+			$this->wp_page_slug,
1436
+			'normal',
1437
+			'high'
1438
+		);
1439
+		if ($attendee instanceof EE_Attendee
1440
+			&& EE_Registry::instance()->CAP->current_user_can(
1441
+				'ee_read_registration',
1442
+				'edit-reg-questions-mbox',
1443
+				$this->_registration->ID()
1444
+			)
1445
+		) {
1446
+			add_meta_box(
1447
+				'edit-reg-questions-mbox',
1448
+				esc_html__('Registration Form Answers', 'event_espresso'),
1449
+				array($this, '_reg_questions_meta_box'),
1450
+				$this->wp_page_slug,
1451
+				'normal',
1452
+				'high'
1453
+			);
1454
+		}
1455
+		add_meta_box(
1456
+			'edit-reg-registrant-mbox',
1457
+			esc_html__('Contact Details', 'event_espresso'),
1458
+			array($this, '_reg_registrant_side_meta_box'),
1459
+			$this->wp_page_slug,
1460
+			'side',
1461
+			'high'
1462
+		);
1463
+		if ($this->_registration->group_size() > 1) {
1464
+			add_meta_box(
1465
+				'edit-reg-attendees-mbox',
1466
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1467
+				array($this, '_reg_attendees_meta_box'),
1468
+				$this->wp_page_slug,
1469
+				'normal',
1470
+				'high'
1471
+			);
1472
+		}
1473
+	}
1474
+
1475
+
1476
+	/**
1477
+	 * set_reg_status_buttons_metabox
1478
+	 *
1479
+	 * @access protected
1480
+	 * @return string
1481
+	 * @throws EE_Error
1482
+	 * @throws EntityNotFoundException
1483
+	 * @throws InvalidArgumentException
1484
+	 * @throws InvalidDataTypeException
1485
+	 * @throws InvalidInterfaceException
1486
+	 * @throws ReflectionException
1487
+	 */
1488
+	public function set_reg_status_buttons_metabox()
1489
+	{
1490
+		$this->_set_registration_object();
1491
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1492
+		echo $change_reg_status_form->form_open(
1493
+			self::add_query_args_and_nonce(
1494
+				array(
1495
+					'action' => 'change_reg_status',
1496
+				),
1497
+				REG_ADMIN_URL
1498
+			)
1499
+		);
1500
+		echo $change_reg_status_form->get_html();
1501
+		echo $change_reg_status_form->form_close();
1502
+	}
1503
+
1504
+
1505
+	/**
1506
+	 * @return EE_Form_Section_Proper
1507
+	 * @throws EE_Error
1508
+	 * @throws InvalidArgumentException
1509
+	 * @throws InvalidDataTypeException
1510
+	 * @throws InvalidInterfaceException
1511
+	 * @throws EntityNotFoundException
1512
+	 * @throws ReflectionException
1513
+	 */
1514
+	protected function _generate_reg_status_change_form()
1515
+	{
1516
+		$reg_status_change_form_array = array(
1517
+			'name'            => 'reg_status_change_form',
1518
+			'html_id'         => 'reg-status-change-form',
1519
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1520
+			'subsections'     => array(
1521
+				'return'             => new EE_Hidden_Input(
1522
+					array(
1523
+						'name'    => 'return',
1524
+						'default' => 'view_registration',
1525
+					)
1526
+				),
1527
+				'REG_ID'             => new EE_Hidden_Input(
1528
+					array(
1529
+						'name'    => 'REG_ID',
1530
+						'default' => $this->_registration->ID(),
1531
+					)
1532
+				),
1533
+				'current_status'     => new EE_Form_Section_HTML(
1534
+					EEH_HTML::table(
1535
+						EEH_HTML::tr(
1536
+							EEH_HTML::th(
1537
+								EEH_HTML::label(
1538
+									EEH_HTML::strong(
1539
+										esc_html__('Current Registration Status', 'event_espresso')
1540
+									)
1541
+								)
1542
+							)
1543
+							. EEH_HTML::td(
1544
+								EEH_HTML::strong(
1545
+									$this->_registration->pretty_status(),
1546
+									'',
1547
+									'status-' . $this->_registration->status_ID(),
1548
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1549
+								)
1550
+							)
1551
+						)
1552
+					)
1553
+				)
1554
+			)
1555
+		);
1556
+		if (EE_Registry::instance()->CAP->current_user_can(
1557
+			'ee_edit_registration',
1558
+			'toggle_registration_status',
1559
+			$this->_registration->ID()
1560
+		)) {
1561
+			$reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1562
+				$this->_get_reg_statuses(),
1563
+				array(
1564
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1565
+					'default'         => $this->_registration->status_ID(),
1566
+				)
1567
+			);
1568
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1569
+				array(
1570
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1571
+					'default'         => false,
1572
+					'html_help_text'  => esc_html__(
1573
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1574
+						'event_espresso'
1575
+					)
1576
+				)
1577
+			);
1578
+			$reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1579
+				array(
1580
+					'html_class'      => 'button-primary',
1581
+					'html_label_text' => '&nbsp;',
1582
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1583
+				)
1584
+			);
1585
+		}
1586
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1587
+	}
1588
+
1589
+
1590
+	/**
1591
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1592
+	 *
1593
+	 * @return array
1594
+	 * @throws EE_Error
1595
+	 * @throws InvalidArgumentException
1596
+	 * @throws InvalidDataTypeException
1597
+	 * @throws InvalidInterfaceException
1598
+	 * @throws EntityNotFoundException
1599
+	 */
1600
+	protected function _get_reg_statuses()
1601
+	{
1602
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1603
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1604
+		// get current reg status
1605
+		$current_status = $this->_registration->status_ID();
1606
+		// is registration for free event? This will determine whether to display the pending payment option
1607
+		if ($current_status !== EEM_Registration::status_id_pending_payment
1608
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1609
+		) {
1610
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1611
+		}
1612
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1613
+	}
1614
+
1615
+
1616
+	/**
1617
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1618
+	 *
1619
+	 * @param bool $status REG status given for changing registrations to.
1620
+	 * @param bool $notify Whether to send messages notifications or not.
1621
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1622
+	 * @throws DomainException
1623
+	 * @throws EE_Error
1624
+	 * @throws EntityNotFoundException
1625
+	 * @throws InvalidArgumentException
1626
+	 * @throws InvalidDataTypeException
1627
+	 * @throws InvalidInterfaceException
1628
+	 * @throws ReflectionException
1629
+	 * @throws RuntimeException
1630
+	 */
1631
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1632
+	{
1633
+		if (isset($this->_req_data['reg_status_change_form'])) {
1634
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1635
+				? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1636
+				: array();
1637
+		} else {
1638
+			$REG_IDs = isset($this->_req_data['_REG_ID'])
1639
+				? (array) $this->_req_data['_REG_ID']
1640
+				: array();
1641
+		}
1642
+		// sanitize $REG_IDs
1643
+		$REG_IDs = array_map('absint', $REG_IDs);
1644
+		// and remove empty entries
1645
+		$REG_IDs = array_filter($REG_IDs);
1646
+
1647
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1648
+
1649
+		/**
1650
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1651
+		 * Currently this value is used downstream by the _process_resend_registration method.
1652
+		 *
1653
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1654
+		 * @param bool                     $status           The status registrations were changed to.
1655
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1656
+		 * @param Registrations_Admin_Page $admin_page_object
1657
+		 */
1658
+		$this->_req_data['_REG_ID'] = apply_filters(
1659
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1660
+			$result['REG_ID'],
1661
+			$status,
1662
+			$result['success'],
1663
+			$this
1664
+		);
1665
+
1666
+		// notify?
1667
+		if ($notify
1668
+			&& $result['success']
1669
+			&& ! empty($this->_req_data['_REG_ID'])
1670
+			&& EE_Registry::instance()->CAP->current_user_can(
1671
+				'ee_send_message',
1672
+				'espresso_registrations_resend_registration'
1673
+			)
1674
+		) {
1675
+			$this->_process_resend_registration();
1676
+		}
1677
+		return $result;
1678
+	}
1679
+
1680
+
1681
+	/**
1682
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1683
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1684
+	 *
1685
+	 * @param array  $REG_IDs
1686
+	 * @param string $status
1687
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1688
+	 *                        slug sent with setting the registration status.
1689
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1690
+	 * @throws EE_Error
1691
+	 * @throws InvalidArgumentException
1692
+	 * @throws InvalidDataTypeException
1693
+	 * @throws InvalidInterfaceException
1694
+	 * @throws ReflectionException
1695
+	 * @throws RuntimeException
1696
+	 * @throws EntityNotFoundException
1697
+	 * @throws DomainException
1698
+	 */
1699
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1700
+	{
1701
+		$success = false;
1702
+		// typecast $REG_IDs
1703
+		$REG_IDs = (array) $REG_IDs;
1704
+		if (! empty($REG_IDs)) {
1705
+			$success = true;
1706
+			// set default status if none is passed
1707
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1708
+			$status_context = $notify
1709
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1710
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1711
+			// loop through REG_ID's and change status
1712
+			foreach ($REG_IDs as $REG_ID) {
1713
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1714
+				if ($registration instanceof EE_Registration) {
1715
+					$registration->set_status(
1716
+						$status,
1717
+						false,
1718
+						new Context(
1719
+							$status_context,
1720
+							esc_html__(
1721
+								'Manually triggered status change on a Registration Admin Page route.',
1722
+								'event_espresso'
1723
+							)
1724
+						)
1725
+					);
1726
+					$result = $registration->save();
1727
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1728
+					$success = $result !== false ? $success : false;
1729
+				}
1730
+			}
1731
+		}
1732
+
1733
+		// return $success and processed registrations
1734
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1735
+	}
1736
+
1737
+
1738
+	/**
1739
+	 * Common logic for setting up success message and redirecting to appropriate route
1740
+	 *
1741
+	 * @param string $STS_ID status id for the registration changed to
1742
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1743
+	 * @return void
1744
+	 * @throws DomainException
1745
+	 * @throws EE_Error
1746
+	 * @throws EntityNotFoundException
1747
+	 * @throws InvalidArgumentException
1748
+	 * @throws InvalidDataTypeException
1749
+	 * @throws InvalidInterfaceException
1750
+	 * @throws ReflectionException
1751
+	 * @throws RuntimeException
1752
+	 */
1753
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1754
+	{
1755
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1756
+			: array('success' => false);
1757
+		$success = isset($result['success']) && $result['success'];
1758
+		// setup success message
1759
+		if ($success) {
1760
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1761
+				$msg = sprintf(
1762
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1763
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1764
+				);
1765
+			} else {
1766
+				$msg = sprintf(
1767
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1768
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1769
+				);
1770
+			}
1771
+			EE_Error::add_success($msg);
1772
+		} else {
1773
+			EE_Error::add_error(
1774
+				esc_html__(
1775
+					'Something went wrong, and the status was not changed',
1776
+					'event_espresso'
1777
+				),
1778
+				__FILE__,
1779
+				__LINE__,
1780
+				__FUNCTION__
1781
+			);
1782
+		}
1783
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] === 'view_registration') {
1784
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1785
+		} else {
1786
+			$route = array('action' => 'default');
1787
+		}
1788
+		$route = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1789
+		$this->_redirect_after_action($success, '', '', $route, true);
1790
+	}
1791
+
1792
+
1793
+	/**
1794
+	 * incoming reg status change from reg details page.
1795
+	 *
1796
+	 * @return void
1797
+	 * @throws EE_Error
1798
+	 * @throws EntityNotFoundException
1799
+	 * @throws InvalidArgumentException
1800
+	 * @throws InvalidDataTypeException
1801
+	 * @throws InvalidInterfaceException
1802
+	 * @throws ReflectionException
1803
+	 * @throws RuntimeException
1804
+	 * @throws DomainException
1805
+	 */
1806
+	protected function _change_reg_status()
1807
+	{
1808
+		$this->_req_data['return'] = 'view_registration';
1809
+		// set notify based on whether the send notifications toggle is set or not
1810
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1811
+		// $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1812
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
1813
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
1814
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1815
+			case EEM_Registration::status_id_approved:
1816
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1817
+				$this->approve_registration($notify);
1818
+				break;
1819
+			case EEM_Registration::status_id_pending_payment:
1820
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1821
+				$this->pending_registration($notify);
1822
+				break;
1823
+			case EEM_Registration::status_id_not_approved:
1824
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1825
+				$this->not_approve_registration($notify);
1826
+				break;
1827
+			case EEM_Registration::status_id_declined:
1828
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1829
+				$this->decline_registration($notify);
1830
+				break;
1831
+			case EEM_Registration::status_id_cancelled:
1832
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1833
+				$this->cancel_registration($notify);
1834
+				break;
1835
+			case EEM_Registration::status_id_wait_list:
1836
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1837
+				$this->wait_list_registration($notify);
1838
+				break;
1839
+			case EEM_Registration::status_id_incomplete:
1840
+			default:
1841
+				$result['success'] = false;
1842
+				unset($this->_req_data['return']);
1843
+				$this->_reg_status_change_return('', false);
1844
+				break;
1845
+		}
1846
+	}
1847
+
1848
+
1849
+	/**
1850
+	 * Callback for bulk action routes.
1851
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1852
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1853
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1854
+	 * when an action is happening on just a single registration).
1855
+	 *
1856
+	 * @param      $action
1857
+	 * @param bool $notify
1858
+	 */
1859
+	protected function bulk_action_on_registrations($action, $notify = false)
1860
+	{
1861
+		do_action(
1862
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1863
+			$this,
1864
+			$action,
1865
+			$notify
1866
+		);
1867
+		$method = $action . '_registration';
1868
+		if (method_exists($this, $method)) {
1869
+			$this->$method($notify);
1870
+		}
1871
+	}
1872
+
1873
+
1874
+	/**
1875
+	 * approve_registration
1876
+	 *
1877
+	 * @access protected
1878
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1879
+	 * @return void
1880
+	 * @throws EE_Error
1881
+	 * @throws EntityNotFoundException
1882
+	 * @throws InvalidArgumentException
1883
+	 * @throws InvalidDataTypeException
1884
+	 * @throws InvalidInterfaceException
1885
+	 * @throws ReflectionException
1886
+	 * @throws RuntimeException
1887
+	 * @throws DomainException
1888
+	 */
1889
+	protected function approve_registration($notify = false)
1890
+	{
1891
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1892
+	}
1893
+
1894
+
1895
+	/**
1896
+	 *        decline_registration
1897
+	 *
1898
+	 * @access protected
1899
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1900
+	 * @return void
1901
+	 * @throws EE_Error
1902
+	 * @throws EntityNotFoundException
1903
+	 * @throws InvalidArgumentException
1904
+	 * @throws InvalidDataTypeException
1905
+	 * @throws InvalidInterfaceException
1906
+	 * @throws ReflectionException
1907
+	 * @throws RuntimeException
1908
+	 * @throws DomainException
1909
+	 */
1910
+	protected function decline_registration($notify = false)
1911
+	{
1912
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1913
+	}
1914
+
1915
+
1916
+	/**
1917
+	 *        cancel_registration
1918
+	 *
1919
+	 * @access protected
1920
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1921
+	 * @return void
1922
+	 * @throws EE_Error
1923
+	 * @throws EntityNotFoundException
1924
+	 * @throws InvalidArgumentException
1925
+	 * @throws InvalidDataTypeException
1926
+	 * @throws InvalidInterfaceException
1927
+	 * @throws ReflectionException
1928
+	 * @throws RuntimeException
1929
+	 * @throws DomainException
1930
+	 */
1931
+	protected function cancel_registration($notify = false)
1932
+	{
1933
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1934
+	}
1935
+
1936
+
1937
+	/**
1938
+	 *        not_approve_registration
1939
+	 *
1940
+	 * @access protected
1941
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1942
+	 * @return void
1943
+	 * @throws EE_Error
1944
+	 * @throws EntityNotFoundException
1945
+	 * @throws InvalidArgumentException
1946
+	 * @throws InvalidDataTypeException
1947
+	 * @throws InvalidInterfaceException
1948
+	 * @throws ReflectionException
1949
+	 * @throws RuntimeException
1950
+	 * @throws DomainException
1951
+	 */
1952
+	protected function not_approve_registration($notify = false)
1953
+	{
1954
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1955
+	}
1956
+
1957
+
1958
+	/**
1959
+	 *        decline_registration
1960
+	 *
1961
+	 * @access protected
1962
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1963
+	 * @return void
1964
+	 * @throws EE_Error
1965
+	 * @throws EntityNotFoundException
1966
+	 * @throws InvalidArgumentException
1967
+	 * @throws InvalidDataTypeException
1968
+	 * @throws InvalidInterfaceException
1969
+	 * @throws ReflectionException
1970
+	 * @throws RuntimeException
1971
+	 * @throws DomainException
1972
+	 */
1973
+	protected function pending_registration($notify = false)
1974
+	{
1975
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1976
+	}
1977
+
1978
+
1979
+	/**
1980
+	 * waitlist_registration
1981
+	 *
1982
+	 * @access protected
1983
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1984
+	 * @return void
1985
+	 * @throws EE_Error
1986
+	 * @throws EntityNotFoundException
1987
+	 * @throws InvalidArgumentException
1988
+	 * @throws InvalidDataTypeException
1989
+	 * @throws InvalidInterfaceException
1990
+	 * @throws ReflectionException
1991
+	 * @throws RuntimeException
1992
+	 * @throws DomainException
1993
+	 */
1994
+	protected function wait_list_registration($notify = false)
1995
+	{
1996
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1997
+	}
1998
+
1999
+
2000
+	/**
2001
+	 *        generates HTML for the Registration main meta box
2002
+	 *
2003
+	 * @access public
2004
+	 * @return void
2005
+	 * @throws DomainException
2006
+	 * @throws EE_Error
2007
+	 * @throws InvalidArgumentException
2008
+	 * @throws InvalidDataTypeException
2009
+	 * @throws InvalidInterfaceException
2010
+	 * @throws ReflectionException
2011
+	 * @throws EntityNotFoundException
2012
+	 */
2013
+	public function _reg_details_meta_box()
2014
+	{
2015
+		EEH_Autoloader::register_line_item_display_autoloaders();
2016
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2017
+		EE_Registry::instance()->load_helper('Line_Item');
2018
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2019
+			: EE_Transaction::new_instance();
2020
+		$this->_session = $transaction->session_data();
2021
+		$filters = new EE_Line_Item_Filter_Collection();
2022
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2023
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2024
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2025
+			$filters,
2026
+			$transaction->total_line_item()
2027
+		);
2028
+		$filtered_line_item_tree = $line_item_filter_processor->process();
2029
+		$line_item_display = new EE_Line_Item_Display(
2030
+			'reg_admin_table',
2031
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2032
+		);
2033
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2034
+			$filtered_line_item_tree,
2035
+			array('EE_Registration' => $this->_registration)
2036
+		);
2037
+		$attendee = $this->_registration->attendee();
2038
+		if (EE_Registry::instance()->CAP->current_user_can(
2039
+			'ee_read_transaction',
2040
+			'espresso_transactions_view_transaction'
2041
+		)) {
2042
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2043
+				EE_Admin_Page::add_query_args_and_nonce(
2044
+					array(
2045
+						'action' => 'view_transaction',
2046
+						'TXN_ID' => $transaction->ID(),
2047
+					),
2048
+					TXN_ADMIN_URL
2049
+				),
2050
+				esc_html__(' View Transaction', 'event_espresso'),
2051
+				'button secondary-button right',
2052
+				'dashicons dashicons-cart'
2053
+			);
2054
+		} else {
2055
+			$this->_template_args['view_transaction_button'] = '';
2056
+		}
2057
+		if ($attendee instanceof EE_Attendee
2058
+			&& EE_Registry::instance()->CAP->current_user_can(
2059
+				'ee_send_message',
2060
+				'espresso_registrations_resend_registration'
2061
+			)
2062
+		) {
2063
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2064
+				EE_Admin_Page::add_query_args_and_nonce(
2065
+					array(
2066
+						'action'      => 'resend_registration',
2067
+						'_REG_ID'     => $this->_registration->ID(),
2068
+						'redirect_to' => 'view_registration',
2069
+					),
2070
+					REG_ADMIN_URL
2071
+				),
2072
+				esc_html__(' Resend Registration', 'event_espresso'),
2073
+				'button secondary-button right',
2074
+				'dashicons dashicons-email-alt'
2075
+			);
2076
+		} else {
2077
+			$this->_template_args['resend_registration_button'] = '';
2078
+		}
2079
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2080
+		$payment = $transaction->get_first_related('Payment');
2081
+		$payment = ! $payment instanceof EE_Payment
2082
+			? EE_Payment::new_instance()
2083
+			: $payment;
2084
+		$payment_method = $payment->get_first_related('Payment_Method');
2085
+		$payment_method = ! $payment_method instanceof EE_Payment_Method
2086
+			? EE_Payment_Method::new_instance()
2087
+			: $payment_method;
2088
+		$reg_details = array(
2089
+			'payment_method'       => $payment_method->name(),
2090
+			'response_msg'         => $payment->gateway_response(),
2091
+			'registration_id'      => $this->_registration->get('REG_code'),
2092
+			'registration_session' => $this->_registration->session_ID(),
2093
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2094
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2095
+		);
2096
+		if (isset($reg_details['registration_id'])) {
2097
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2098
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2099
+				'Registration ID',
2100
+				'event_espresso'
2101
+			);
2102
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2103
+		}
2104
+		if (isset($reg_details['payment_method'])) {
2105
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2106
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2107
+				'Most Recent Payment Method',
2108
+				'event_espresso'
2109
+			);
2110
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2111
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2112
+			$this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2113
+				'Payment method response',
2114
+				'event_espresso'
2115
+			);
2116
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2117
+		}
2118
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2119
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2120
+			'Registration Session',
2121
+			'event_espresso'
2122
+		);
2123
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2124
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2125
+		$this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2126
+			'Registration placed from IP',
2127
+			'event_espresso'
2128
+		);
2129
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2130
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2131
+		$this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2132
+			'Registrant User Agent',
2133
+			'event_espresso'
2134
+		);
2135
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2136
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2137
+			array(
2138
+				'action'   => 'default',
2139
+				'event_id' => $this->_registration->event_ID(),
2140
+			),
2141
+			REG_ADMIN_URL
2142
+		);
2143
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2144
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2145
+		$template_path =
2146
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2147
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2148
+	}
2149
+
2150
+
2151
+	/**
2152
+	 * generates HTML for the Registration Questions meta box.
2153
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2154
+	 * otherwise uses new forms system
2155
+	 *
2156
+	 * @access public
2157
+	 * @return void
2158
+	 * @throws DomainException
2159
+	 * @throws EE_Error
2160
+	 * @throws InvalidArgumentException
2161
+	 * @throws InvalidDataTypeException
2162
+	 * @throws InvalidInterfaceException
2163
+	 * @throws ReflectionException
2164
+	 */
2165
+	public function _reg_questions_meta_box()
2166
+	{
2167
+		// allow someone to override this method entirely
2168
+		if (apply_filters(
2169
+			'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2170
+			true,
2171
+			$this,
2172
+			$this->_registration
2173
+		)) {
2174
+			$form = $this->_get_reg_custom_questions_form(
2175
+				$this->_registration->ID()
2176
+			);
2177
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2178
+				? $form->get_html_and_js()
2179
+				: '';
2180
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2181
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2182
+			$template_path =
2183
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2184
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
2185
+		}
2186
+	}
2187
+
2188
+
2189
+	/**
2190
+	 * form_before_question_group
2191
+	 *
2192
+	 * @deprecated    as of 4.8.32.rc.000
2193
+	 * @access        public
2194
+	 * @param        string $output
2195
+	 * @return        string
2196
+	 */
2197
+	public function form_before_question_group($output)
2198
+	{
2199
+		EE_Error::doing_it_wrong(
2200
+			__CLASS__ . '::' . __FUNCTION__,
2201
+			esc_html__(
2202
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2203
+				'event_espresso'
2204
+			),
2205
+			'4.8.32.rc.000'
2206
+		);
2207
+		return '
2208 2208
 	<table class="form-table ee-width-100">
2209 2209
 		<tbody>
2210 2210
 			';
2211
-    }
2212
-
2213
-
2214
-    /**
2215
-     * form_after_question_group
2216
-     *
2217
-     * @deprecated    as of 4.8.32.rc.000
2218
-     * @access        public
2219
-     * @param        string $output
2220
-     * @return        string
2221
-     */
2222
-    public function form_after_question_group($output)
2223
-    {
2224
-        EE_Error::doing_it_wrong(
2225
-            __CLASS__ . '::' . __FUNCTION__,
2226
-            esc_html__(
2227
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2228
-                'event_espresso'
2229
-            ),
2230
-            '4.8.32.rc.000'
2231
-        );
2232
-        return '
2211
+	}
2212
+
2213
+
2214
+	/**
2215
+	 * form_after_question_group
2216
+	 *
2217
+	 * @deprecated    as of 4.8.32.rc.000
2218
+	 * @access        public
2219
+	 * @param        string $output
2220
+	 * @return        string
2221
+	 */
2222
+	public function form_after_question_group($output)
2223
+	{
2224
+		EE_Error::doing_it_wrong(
2225
+			__CLASS__ . '::' . __FUNCTION__,
2226
+			esc_html__(
2227
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2228
+				'event_espresso'
2229
+			),
2230
+			'4.8.32.rc.000'
2231
+		);
2232
+		return '
2233 2233
 			<tr class="hide-if-no-js">
2234 2234
 				<th> </th>
2235 2235
 				<td class="reg-admin-edit-attendee-question-td">
2236 2236
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2237
-               . esc_attr__('click to edit question', 'event_espresso')
2238
-               . '">
2237
+			   . esc_attr__('click to edit question', 'event_espresso')
2238
+			   . '">
2239 2239
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2240
-               . esc_html__('edit the above question group', 'event_espresso')
2241
-               . '</span>
2240
+			   . esc_html__('edit the above question group', 'event_espresso')
2241
+			   . '</span>
2242 2242
 						<div class="dashicons dashicons-edit"></div>
2243 2243
 					</a>
2244 2244
 				</td>
@@ -2246,627 +2246,627 @@  discard block
 block discarded – undo
2246 2246
 		</tbody>
2247 2247
 	</table>
2248 2248
 ';
2249
-    }
2250
-
2251
-
2252
-    /**
2253
-     * form_form_field_label_wrap
2254
-     *
2255
-     * @deprecated    as of 4.8.32.rc.000
2256
-     * @access        public
2257
-     * @param        string $label
2258
-     * @return        string
2259
-     */
2260
-    public function form_form_field_label_wrap($label)
2261
-    {
2262
-        EE_Error::doing_it_wrong(
2263
-            __CLASS__ . '::' . __FUNCTION__,
2264
-            esc_html__(
2265
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266
-                'event_espresso'
2267
-            ),
2268
-            '4.8.32.rc.000'
2269
-        );
2270
-        return '
2249
+	}
2250
+
2251
+
2252
+	/**
2253
+	 * form_form_field_label_wrap
2254
+	 *
2255
+	 * @deprecated    as of 4.8.32.rc.000
2256
+	 * @access        public
2257
+	 * @param        string $label
2258
+	 * @return        string
2259
+	 */
2260
+	public function form_form_field_label_wrap($label)
2261
+	{
2262
+		EE_Error::doing_it_wrong(
2263
+			__CLASS__ . '::' . __FUNCTION__,
2264
+			esc_html__(
2265
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266
+				'event_espresso'
2267
+			),
2268
+			'4.8.32.rc.000'
2269
+		);
2270
+		return '
2271 2271
 			<tr>
2272 2272
 				<th>
2273 2273
 					' . $label . '
2274 2274
 				</th>';
2275
-    }
2276
-
2277
-
2278
-    /**
2279
-     * form_form_field_input__wrap
2280
-     *
2281
-     * @deprecated    as of 4.8.32.rc.000
2282
-     * @access        public
2283
-     * @param        string $input
2284
-     * @return        string
2285
-     */
2286
-    public function form_form_field_input__wrap($input)
2287
-    {
2288
-        EE_Error::doing_it_wrong(
2289
-            __CLASS__ . '::' . __FUNCTION__,
2290
-            esc_html__(
2291
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2292
-                'event_espresso'
2293
-            ),
2294
-            '4.8.32.rc.000'
2295
-        );
2296
-        return '
2275
+	}
2276
+
2277
+
2278
+	/**
2279
+	 * form_form_field_input__wrap
2280
+	 *
2281
+	 * @deprecated    as of 4.8.32.rc.000
2282
+	 * @access        public
2283
+	 * @param        string $input
2284
+	 * @return        string
2285
+	 */
2286
+	public function form_form_field_input__wrap($input)
2287
+	{
2288
+		EE_Error::doing_it_wrong(
2289
+			__CLASS__ . '::' . __FUNCTION__,
2290
+			esc_html__(
2291
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2292
+				'event_espresso'
2293
+			),
2294
+			'4.8.32.rc.000'
2295
+		);
2296
+		return '
2297 2297
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2298 2298
 					' . $input . '
2299 2299
 				</td>
2300 2300
 			</tr>';
2301
-    }
2302
-
2303
-
2304
-    /**
2305
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2306
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2307
-     * to display the page
2308
-     *
2309
-     * @access protected
2310
-     * @return void
2311
-     * @throws EE_Error
2312
-     * @throws InvalidArgumentException
2313
-     * @throws InvalidDataTypeException
2314
-     * @throws InvalidInterfaceException
2315
-     * @throws ReflectionException
2316
-     */
2317
-    protected function _update_attendee_registration_form()
2318
-    {
2319
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2320
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2321
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2322
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2323
-            if ($success) {
2324
-                $what = esc_html__('Registration Form', 'event_espresso');
2325
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2326
-                    : array('action' => 'default');
2327
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2328
-            }
2329
-        }
2330
-    }
2331
-
2332
-
2333
-    /**
2334
-     * Gets the form for saving registrations custom questions (if done
2335
-     * previously retrieves the cached form object, which may have validation errors in it)
2336
-     *
2337
-     * @param int $REG_ID
2338
-     * @return EE_Registration_Custom_Questions_Form
2339
-     * @throws EE_Error
2340
-     * @throws InvalidArgumentException
2341
-     * @throws InvalidDataTypeException
2342
-     * @throws InvalidInterfaceException
2343
-     */
2344
-    protected function _get_reg_custom_questions_form($REG_ID)
2345
-    {
2346
-        if (! $this->_reg_custom_questions_form) {
2347
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350
-            );
2351
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2352
-        }
2353
-        return $this->_reg_custom_questions_form;
2354
-    }
2355
-
2356
-
2357
-    /**
2358
-     * Saves
2359
-     *
2360
-     * @access private
2361
-     * @param bool $REG_ID
2362
-     * @return bool
2363
-     * @throws EE_Error
2364
-     * @throws InvalidArgumentException
2365
-     * @throws InvalidDataTypeException
2366
-     * @throws InvalidInterfaceException
2367
-     * @throws ReflectionException
2368
-     */
2369
-    private function _save_reg_custom_questions_form($REG_ID = false)
2370
-    {
2371
-        if (! $REG_ID) {
2372
-            EE_Error::add_error(
2373
-                esc_html__(
2374
-                    'An error occurred. No registration ID was received.',
2375
-                    'event_espresso'
2376
-                ),
2377
-                __FILE__,
2378
-                __FUNCTION__,
2379
-                __LINE__
2380
-            );
2381
-        }
2382
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2383
-        $form->receive_form_submission($this->_req_data);
2384
-        $success = false;
2385
-        if ($form->is_valid()) {
2386
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
2387
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2388
-                    $where_conditions = array(
2389
-                        'QST_ID' => $question_id,
2390
-                        'REG_ID' => $REG_ID,
2391
-                    );
2392
-                    $possibly_new_values = array(
2393
-                        'ANS_value' => $input->normalized_value(),
2394
-                    );
2395
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
2396
-                    if ($answer instanceof EE_Answer) {
2397
-                        $success = $answer->save($possibly_new_values);
2398
-                    } else {
2399
-                        // insert it then
2400
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2401
-                        $answer = EE_Answer::new_instance($cols_n_vals);
2402
-                        $success = $answer->save();
2403
-                    }
2404
-                }
2405
-            }
2406
-        } else {
2407
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2408
-        }
2409
-        return $success;
2410
-    }
2411
-
2412
-
2413
-    /**
2414
-     *        generates HTML for the Registration main meta box
2415
-     *
2416
-     * @access public
2417
-     * @return void
2418
-     * @throws DomainException
2419
-     * @throws EE_Error
2420
-     * @throws InvalidArgumentException
2421
-     * @throws InvalidDataTypeException
2422
-     * @throws InvalidInterfaceException
2423
-     * @throws ReflectionException
2424
-     */
2425
-    public function _reg_attendees_meta_box()
2426
-    {
2427
-        $REG = $this->getRegistrationModel();
2428
-        // get all other registrations on this transaction, and cache
2429
-        // the attendees for them so we don't have to run another query using force_join
2430
-        $registrations = $REG->get_all(
2431
-            array(
2432
-                array(
2433
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2434
-                    'REG_ID' => array('!=', $this->_registration->ID()),
2435
-                ),
2436
-                'force_join' => array('Attendee'),
2437
-                'default_where_conditions' => 'other_models_only',
2438
-            )
2439
-        );
2440
-        $this->_template_args['attendees'] = array();
2441
-        $this->_template_args['attendee_notice'] = '';
2442
-        if (empty($registrations)
2443
-            || (is_array($registrations)
2444
-                && ! EEH_Array::get_one_item_from_array($registrations))
2445
-        ) {
2446
-            EE_Error::add_error(
2447
-                esc_html__(
2448
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2449
-                    'event_espresso'
2450
-                ),
2451
-                __FILE__,
2452
-                __FUNCTION__,
2453
-                __LINE__
2454
-            );
2455
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2456
-        } else {
2457
-            $att_nmbr = 1;
2458
-            foreach ($registrations as $registration) {
2459
-                /* @var $registration EE_Registration */
2460
-                $attendee = $registration->attendee()
2461
-                    ? $registration->attendee()
2462
-                    : $this->getAttendeeModel()->create_default_object();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2467
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2468
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2469
-                    ', ',
2470
-                    $attendee->full_address_as_array()
2471
-                );
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2473
-                    array(
2474
-                        'action' => 'edit_attendee',
2475
-                        'post'   => $attendee->ID(),
2476
-                    ),
2477
-                    REG_ADMIN_URL
2478
-                );
2479
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2480
-                    ? $registration->event_obj()->name()
2481
-                    : '';
2482
-                $att_nmbr++;
2483
-            }
2484
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485
-        }
2486
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2487
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2488
-    }
2489
-
2490
-
2491
-    /**
2492
-     *        generates HTML for the Edit Registration side meta box
2493
-     *
2494
-     * @access public
2495
-     * @return void
2496
-     * @throws DomainException
2497
-     * @throws EE_Error
2498
-     * @throws InvalidArgumentException
2499
-     * @throws InvalidDataTypeException
2500
-     * @throws InvalidInterfaceException
2501
-     * @throws ReflectionException
2502
-     */
2503
-    public function _reg_registrant_side_meta_box()
2504
-    {
2505
-        /*@var $attendee EE_Attendee */
2506
-        $att_check = $this->_registration->attendee();
2507
-        $attendee = $att_check instanceof EE_Attendee
2508
-            ? $att_check
2509
-            : $this->getAttendeeModel()->create_default_object();
2510
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2511
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2512
-        // primary registration object (that way we know if we need to show create button or not)
2513
-        if (! $this->_registration->is_primary_registrant()) {
2514
-            $primary_registration = $this->_registration->get_primary_registration();
2515
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2516
-                : null;
2517
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2518
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2519
-                // custom attendee object so let's not worry about the primary reg.
2520
-                $primary_registration = null;
2521
-            }
2522
-        } else {
2523
-            $primary_registration = null;
2524
-        }
2525
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2526
-        $this->_template_args['fname'] = $attendee->fname();
2527
-        $this->_template_args['lname'] = $attendee->lname();
2528
-        $this->_template_args['email'] = $attendee->email();
2529
-        $this->_template_args['phone'] = $attendee->phone();
2530
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2531
-        // edit link
2532
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2533
-            array(
2534
-                'action' => 'edit_attendee',
2535
-                'post'   => $attendee->ID(),
2536
-            ),
2537
-            REG_ADMIN_URL
2538
-        );
2539
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2540
-        // create link
2541
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2542
-            ? EE_Admin_Page::add_query_args_and_nonce(
2543
-                array(
2544
-                    'action'  => 'duplicate_attendee',
2545
-                    '_REG_ID' => $this->_registration->ID(),
2546
-                ),
2547
-                REG_ADMIN_URL
2548
-            ) : '';
2549
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2550
-        $this->_template_args['att_check'] = $att_check;
2551
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2552
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2553
-    }
2554
-
2555
-
2556
-    /**
2557
-     * trash or restore registrations
2558
-     *
2559
-     * @param  boolean $trash whether to archive or restore
2560
-     * @return void
2561
-     * @throws EE_Error
2562
-     * @throws InvalidArgumentException
2563
-     * @throws InvalidDataTypeException
2564
-     * @throws InvalidInterfaceException
2565
-     * @throws RuntimeException
2566
-     * @access protected
2567
-     */
2568
-    protected function _trash_or_restore_registrations($trash = true)
2569
-    {
2570
-        // if empty _REG_ID then get out because there's nothing to do
2571
-        if (empty($this->_req_data['_REG_ID'])) {
2572
-            EE_Error::add_error(
2573
-                sprintf(
2574
-                    esc_html__(
2575
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2576
-                        'event_espresso'
2577
-                    ),
2578
-                    $trash ? 'trash' : 'restore'
2579
-                ),
2580
-                __FILE__,
2581
-                __LINE__,
2582
-                __FUNCTION__
2583
-            );
2584
-            $this->_redirect_after_action(false, '', '', array(), true);
2585
-        }
2586
-        $success = 0;
2587
-        $overwrite_msgs = false;
2588
-        // Checkboxes
2589
-        if (! is_array($this->_req_data['_REG_ID'])) {
2590
-            $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2591
-        }
2592
-        $reg_count = count($this->_req_data['_REG_ID']);
2593
-        // cycle thru checkboxes
2594
-        foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2595
-            /** @var EE_Registration $REG */
2596
-            $REG = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2597
-            $payments = $REG->registration_payments();
2598
-            if (! empty($payments)) {
2599
-                $name = $REG->attendee() instanceof EE_Attendee
2600
-                    ? $REG->attendee()->full_name()
2601
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2602
-                $overwrite_msgs = true;
2603
-                EE_Error::add_error(
2604
-                    sprintf(
2605
-                        esc_html__(
2606
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2607
-                            'event_espresso'
2608
-                        ),
2609
-                        $name
2610
-                    ),
2611
-                    __FILE__,
2612
-                    __FUNCTION__,
2613
-                    __LINE__
2614
-                );
2615
-                // can't trash this registration because it has payments.
2616
-                continue;
2617
-            }
2618
-            $updated = $trash ? $REG->delete() : $REG->restore();
2619
-            if ($updated) {
2620
-                $success++;
2621
-            }
2622
-        }
2623
-        $this->_redirect_after_action(
2624
-            $success === $reg_count, // were ALL registrations affected?
2625
-            $success > 1
2626
-                ? esc_html__('Registrations', 'event_espresso')
2627
-                : esc_html__('Registration', 'event_espresso'),
2628
-            $trash
2629
-                ? esc_html__('moved to the trash', 'event_espresso')
2630
-                : esc_html__('restored', 'event_espresso'),
2631
-            $this->mergeExistingRequestParamsWithRedirectArgs(array('action' => 'default')),
2632
-            $overwrite_msgs
2633
-        );
2634
-    }
2635
-
2636
-
2637
-    /**
2638
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2639
-     * registration but also.
2640
-     * 1. Removing relations to EE_Attendee
2641
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2642
-     * ALSO trashed.
2643
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2644
-     * 4. Removing relationships between all tickets and the related registrations
2645
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2646
-     * 6. Deleting permanently any related Checkins.
2647
-     *
2648
-     * @return void
2649
-     * @throws EE_Error
2650
-     * @throws InvalidArgumentException
2651
-     * @throws InvalidDataTypeException
2652
-     * @throws InvalidInterfaceException
2653
-     * @throws ReflectionException
2654
-     */
2655
-    protected function _delete_registrations()
2656
-    {
2657
-        $REG_MDL = $this->getRegistrationModel();
2658
-        $success = 1;
2659
-        // Checkboxes
2660
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2661
-            // if array has more than one element than success message should be plural
2662
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2663
-            // cycle thru checkboxes
2664
-            foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2665
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2666
-                if (! $REG instanceof EE_Registration) {
2667
-                    continue;
2668
-                }
2669
-                $deleted = $this->_delete_registration($REG);
2670
-                if (! $deleted) {
2671
-                    $success = 0;
2672
-                }
2673
-            }
2674
-        } else {
2675
-            // grab single id and delete
2676
-            $REG_ID = $this->_req_data['_REG_ID'];
2677
-            /** @var EE_Registration $REG */
2678
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2679
-            $deleted = $this->_delete_registration($REG);
2680
-            if (! $deleted) {
2681
-                $success = 0;
2682
-            }
2683
-        }
2684
-        $what = $success > 1
2685
-            ? esc_html__('Registrations', 'event_espresso')
2686
-            : esc_html__('Registration', 'event_espresso');
2687
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2688
-        $this->_redirect_after_action(
2689
-            $success,
2690
-            $what,
2691
-            $action_desc,
2692
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2693
-            true
2694
-        );
2695
-    }
2696
-
2697
-
2698
-    /**
2699
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2700
-     * models get affected.
2701
-     *
2702
-     * @param EE_Registration $REG registration to be deleted permanently
2703
-     * @return bool true = successful deletion, false = fail.
2704
-     * @throws EE_Error
2705
-     * @throws InvalidArgumentException
2706
-     * @throws InvalidDataTypeException
2707
-     * @throws InvalidInterfaceException
2708
-     * @throws ReflectionException
2709
-     */
2710
-    protected function _delete_registration(EE_Registration $REG)
2711
-    {
2712
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2713
-        // registrations on the transaction that are NOT trashed.
2714
-        $TXN = $REG->get_first_related('Transaction');
2715
-        $REGS = $TXN->get_many_related('Registration');
2716
-        $all_trashed = true;
2717
-        foreach ($REGS as $registration) {
2718
-            if (! $registration->get('REG_deleted')) {
2719
-                $all_trashed = false;
2720
-            }
2721
-        }
2722
-        if (! $all_trashed) {
2723
-            EE_Error::add_error(
2724
-                esc_html__(
2725
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2726
-                    'event_espresso'
2727
-                ),
2728
-                __FILE__,
2729
-                __FUNCTION__,
2730
-                __LINE__
2731
-            );
2732
-            return false;
2733
-        }
2734
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2735
-        // separately from THIS one).
2736
-        foreach ($REGS as $registration) {
2737
-            // delete related answers
2738
-            $registration->delete_related_permanently('Answer');
2739
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2740
-            $attendee = $registration->get_first_related('Attendee');
2741
-            if ($attendee instanceof EE_Attendee) {
2742
-                $registration->_remove_relation_to($attendee, 'Attendee');
2743
-            }
2744
-            // now remove relationships to tickets on this registration.
2745
-            $registration->_remove_relations('Ticket');
2746
-            // now delete permanently the checkins related to this registration.
2747
-            $registration->delete_related_permanently('Checkin');
2748
-            if ($registration->ID() === $REG->ID()) {
2749
-                continue;
2750
-            } //we don't want to delete permanently the existing registration just yet.
2751
-            // remove relation to transaction for these registrations if NOT the existing registrations
2752
-            $registration->_remove_relations('Transaction');
2753
-            // delete permanently any related messages.
2754
-            $registration->delete_related_permanently('Message');
2755
-            // now delete this registration permanently
2756
-            $registration->delete_permanently();
2757
-        }
2758
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2759
-        // (the transaction and line items should be all that's left).
2760
-        // delete the line items related to the transaction for this registration.
2761
-        $TXN->delete_related_permanently('Line_Item');
2762
-        // we need to remove all the relationships on the transaction
2763
-        $TXN->delete_related_permanently('Payment');
2764
-        $TXN->delete_related_permanently('Extra_Meta');
2765
-        $TXN->delete_related_permanently('Message');
2766
-        // now we can delete this REG permanently (and the transaction of course)
2767
-        $REG->delete_related_permanently('Transaction');
2768
-        return $REG->delete_permanently();
2769
-    }
2770
-
2771
-
2772
-    /**
2773
-     *    generates HTML for the Register New Attendee Admin page
2774
-     *
2775
-     * @access private
2776
-     * @throws DomainException
2777
-     * @throws EE_Error
2778
-     * @throws InvalidArgumentException
2779
-     * @throws InvalidDataTypeException
2780
-     * @throws InvalidInterfaceException
2781
-     * @throws ReflectionException
2782
-     */
2783
-    public function new_registration()
2784
-    {
2785
-        if (! $this->_set_reg_event()) {
2786
-            throw new EE_Error(
2787
-                esc_html__(
2788
-                    'Unable to continue with registering because there is no Event ID in the request',
2789
-                    'event_espresso'
2790
-                )
2791
-            );
2792
-        }
2793
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2794
-        // gotta start with a clean slate if we're not coming here via ajax
2795
-        if (! defined('DOING_AJAX')
2796
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2797
-        ) {
2798
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2799
-        }
2800
-        $this->_template_args['event_name'] = '';
2801
-        // event name
2802
-        if ($this->_reg_event) {
2803
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2804
-            $edit_event_url = self::add_query_args_and_nonce(
2805
-                array(
2806
-                    'action' => 'edit',
2807
-                    'post'   => $this->_reg_event->ID(),
2808
-                ),
2809
-                EVENTS_ADMIN_URL
2810
-            );
2811
-            $edit_event_lnk = '<a href="'
2812
-                              . $edit_event_url
2813
-                              . '" title="'
2814
-                              . esc_attr__('Edit ', 'event_espresso')
2815
-                              . $this->_reg_event->name()
2816
-                              . '">'
2817
-                              . esc_html__('Edit Event', 'event_espresso')
2818
-                              . '</a>';
2819
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2820
-                                                   . $edit_event_lnk
2821
-                                                   . '</span>';
2822
-        }
2823
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2824
-        if (defined('DOING_AJAX')) {
2825
-            $this->_return_json();
2826
-        }
2827
-        // grab header
2828
-        $template_path =
2829
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2830
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
-            $template_path,
2832
-            $this->_template_args,
2833
-            true
2834
-        );
2835
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2836
-        // the details template wrapper
2837
-        $this->display_admin_page_with_sidebar();
2838
-    }
2839
-
2840
-
2841
-    /**
2842
-     * This returns the content for a registration step
2843
-     *
2844
-     * @access protected
2845
-     * @return string html
2846
-     * @throws DomainException
2847
-     * @throws EE_Error
2848
-     * @throws InvalidArgumentException
2849
-     * @throws InvalidDataTypeException
2850
-     * @throws InvalidInterfaceException
2851
-     */
2852
-    protected function _get_registration_step_content()
2853
-    {
2854
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2855
-            $warning_msg = sprintf(
2856
-                esc_html__(
2857
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2858
-                    'event_espresso'
2859
-                ),
2860
-                '<br />',
2861
-                '<h3 class="important-notice">',
2862
-                '</h3>',
2863
-                '<div class="float-right">',
2864
-                '<span id="redirect_timer" class="important-notice">30</span>',
2865
-                '</div>',
2866
-                '<b>',
2867
-                '</b>'
2868
-            );
2869
-            return '
2301
+	}
2302
+
2303
+
2304
+	/**
2305
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2306
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2307
+	 * to display the page
2308
+	 *
2309
+	 * @access protected
2310
+	 * @return void
2311
+	 * @throws EE_Error
2312
+	 * @throws InvalidArgumentException
2313
+	 * @throws InvalidDataTypeException
2314
+	 * @throws InvalidInterfaceException
2315
+	 * @throws ReflectionException
2316
+	 */
2317
+	protected function _update_attendee_registration_form()
2318
+	{
2319
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2320
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2321
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2322
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2323
+			if ($success) {
2324
+				$what = esc_html__('Registration Form', 'event_espresso');
2325
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2326
+					: array('action' => 'default');
2327
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2328
+			}
2329
+		}
2330
+	}
2331
+
2332
+
2333
+	/**
2334
+	 * Gets the form for saving registrations custom questions (if done
2335
+	 * previously retrieves the cached form object, which may have validation errors in it)
2336
+	 *
2337
+	 * @param int $REG_ID
2338
+	 * @return EE_Registration_Custom_Questions_Form
2339
+	 * @throws EE_Error
2340
+	 * @throws InvalidArgumentException
2341
+	 * @throws InvalidDataTypeException
2342
+	 * @throws InvalidInterfaceException
2343
+	 */
2344
+	protected function _get_reg_custom_questions_form($REG_ID)
2345
+	{
2346
+		if (! $this->_reg_custom_questions_form) {
2347
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350
+			);
2351
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2352
+		}
2353
+		return $this->_reg_custom_questions_form;
2354
+	}
2355
+
2356
+
2357
+	/**
2358
+	 * Saves
2359
+	 *
2360
+	 * @access private
2361
+	 * @param bool $REG_ID
2362
+	 * @return bool
2363
+	 * @throws EE_Error
2364
+	 * @throws InvalidArgumentException
2365
+	 * @throws InvalidDataTypeException
2366
+	 * @throws InvalidInterfaceException
2367
+	 * @throws ReflectionException
2368
+	 */
2369
+	private function _save_reg_custom_questions_form($REG_ID = false)
2370
+	{
2371
+		if (! $REG_ID) {
2372
+			EE_Error::add_error(
2373
+				esc_html__(
2374
+					'An error occurred. No registration ID was received.',
2375
+					'event_espresso'
2376
+				),
2377
+				__FILE__,
2378
+				__FUNCTION__,
2379
+				__LINE__
2380
+			);
2381
+		}
2382
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2383
+		$form->receive_form_submission($this->_req_data);
2384
+		$success = false;
2385
+		if ($form->is_valid()) {
2386
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
2387
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2388
+					$where_conditions = array(
2389
+						'QST_ID' => $question_id,
2390
+						'REG_ID' => $REG_ID,
2391
+					);
2392
+					$possibly_new_values = array(
2393
+						'ANS_value' => $input->normalized_value(),
2394
+					);
2395
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
2396
+					if ($answer instanceof EE_Answer) {
2397
+						$success = $answer->save($possibly_new_values);
2398
+					} else {
2399
+						// insert it then
2400
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2401
+						$answer = EE_Answer::new_instance($cols_n_vals);
2402
+						$success = $answer->save();
2403
+					}
2404
+				}
2405
+			}
2406
+		} else {
2407
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2408
+		}
2409
+		return $success;
2410
+	}
2411
+
2412
+
2413
+	/**
2414
+	 *        generates HTML for the Registration main meta box
2415
+	 *
2416
+	 * @access public
2417
+	 * @return void
2418
+	 * @throws DomainException
2419
+	 * @throws EE_Error
2420
+	 * @throws InvalidArgumentException
2421
+	 * @throws InvalidDataTypeException
2422
+	 * @throws InvalidInterfaceException
2423
+	 * @throws ReflectionException
2424
+	 */
2425
+	public function _reg_attendees_meta_box()
2426
+	{
2427
+		$REG = $this->getRegistrationModel();
2428
+		// get all other registrations on this transaction, and cache
2429
+		// the attendees for them so we don't have to run another query using force_join
2430
+		$registrations = $REG->get_all(
2431
+			array(
2432
+				array(
2433
+					'TXN_ID' => $this->_registration->transaction_ID(),
2434
+					'REG_ID' => array('!=', $this->_registration->ID()),
2435
+				),
2436
+				'force_join' => array('Attendee'),
2437
+				'default_where_conditions' => 'other_models_only',
2438
+			)
2439
+		);
2440
+		$this->_template_args['attendees'] = array();
2441
+		$this->_template_args['attendee_notice'] = '';
2442
+		if (empty($registrations)
2443
+			|| (is_array($registrations)
2444
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2445
+		) {
2446
+			EE_Error::add_error(
2447
+				esc_html__(
2448
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2449
+					'event_espresso'
2450
+				),
2451
+				__FILE__,
2452
+				__FUNCTION__,
2453
+				__LINE__
2454
+			);
2455
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2456
+		} else {
2457
+			$att_nmbr = 1;
2458
+			foreach ($registrations as $registration) {
2459
+				/* @var $registration EE_Registration */
2460
+				$attendee = $registration->attendee()
2461
+					? $registration->attendee()
2462
+					: $this->getAttendeeModel()->create_default_object();
2463
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2464
+				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2465
+				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2466
+				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2467
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2468
+				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2469
+					', ',
2470
+					$attendee->full_address_as_array()
2471
+				);
2472
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2473
+					array(
2474
+						'action' => 'edit_attendee',
2475
+						'post'   => $attendee->ID(),
2476
+					),
2477
+					REG_ADMIN_URL
2478
+				);
2479
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2480
+					? $registration->event_obj()->name()
2481
+					: '';
2482
+				$att_nmbr++;
2483
+			}
2484
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485
+		}
2486
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2487
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2488
+	}
2489
+
2490
+
2491
+	/**
2492
+	 *        generates HTML for the Edit Registration side meta box
2493
+	 *
2494
+	 * @access public
2495
+	 * @return void
2496
+	 * @throws DomainException
2497
+	 * @throws EE_Error
2498
+	 * @throws InvalidArgumentException
2499
+	 * @throws InvalidDataTypeException
2500
+	 * @throws InvalidInterfaceException
2501
+	 * @throws ReflectionException
2502
+	 */
2503
+	public function _reg_registrant_side_meta_box()
2504
+	{
2505
+		/*@var $attendee EE_Attendee */
2506
+		$att_check = $this->_registration->attendee();
2507
+		$attendee = $att_check instanceof EE_Attendee
2508
+			? $att_check
2509
+			: $this->getAttendeeModel()->create_default_object();
2510
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2511
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2512
+		// primary registration object (that way we know if we need to show create button or not)
2513
+		if (! $this->_registration->is_primary_registrant()) {
2514
+			$primary_registration = $this->_registration->get_primary_registration();
2515
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2516
+				: null;
2517
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2518
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2519
+				// custom attendee object so let's not worry about the primary reg.
2520
+				$primary_registration = null;
2521
+			}
2522
+		} else {
2523
+			$primary_registration = null;
2524
+		}
2525
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2526
+		$this->_template_args['fname'] = $attendee->fname();
2527
+		$this->_template_args['lname'] = $attendee->lname();
2528
+		$this->_template_args['email'] = $attendee->email();
2529
+		$this->_template_args['phone'] = $attendee->phone();
2530
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2531
+		// edit link
2532
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2533
+			array(
2534
+				'action' => 'edit_attendee',
2535
+				'post'   => $attendee->ID(),
2536
+			),
2537
+			REG_ADMIN_URL
2538
+		);
2539
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2540
+		// create link
2541
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2542
+			? EE_Admin_Page::add_query_args_and_nonce(
2543
+				array(
2544
+					'action'  => 'duplicate_attendee',
2545
+					'_REG_ID' => $this->_registration->ID(),
2546
+				),
2547
+				REG_ADMIN_URL
2548
+			) : '';
2549
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2550
+		$this->_template_args['att_check'] = $att_check;
2551
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2552
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2553
+	}
2554
+
2555
+
2556
+	/**
2557
+	 * trash or restore registrations
2558
+	 *
2559
+	 * @param  boolean $trash whether to archive or restore
2560
+	 * @return void
2561
+	 * @throws EE_Error
2562
+	 * @throws InvalidArgumentException
2563
+	 * @throws InvalidDataTypeException
2564
+	 * @throws InvalidInterfaceException
2565
+	 * @throws RuntimeException
2566
+	 * @access protected
2567
+	 */
2568
+	protected function _trash_or_restore_registrations($trash = true)
2569
+	{
2570
+		// if empty _REG_ID then get out because there's nothing to do
2571
+		if (empty($this->_req_data['_REG_ID'])) {
2572
+			EE_Error::add_error(
2573
+				sprintf(
2574
+					esc_html__(
2575
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2576
+						'event_espresso'
2577
+					),
2578
+					$trash ? 'trash' : 'restore'
2579
+				),
2580
+				__FILE__,
2581
+				__LINE__,
2582
+				__FUNCTION__
2583
+			);
2584
+			$this->_redirect_after_action(false, '', '', array(), true);
2585
+		}
2586
+		$success = 0;
2587
+		$overwrite_msgs = false;
2588
+		// Checkboxes
2589
+		if (! is_array($this->_req_data['_REG_ID'])) {
2590
+			$this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2591
+		}
2592
+		$reg_count = count($this->_req_data['_REG_ID']);
2593
+		// cycle thru checkboxes
2594
+		foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2595
+			/** @var EE_Registration $REG */
2596
+			$REG = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2597
+			$payments = $REG->registration_payments();
2598
+			if (! empty($payments)) {
2599
+				$name = $REG->attendee() instanceof EE_Attendee
2600
+					? $REG->attendee()->full_name()
2601
+					: esc_html__('Unknown Attendee', 'event_espresso');
2602
+				$overwrite_msgs = true;
2603
+				EE_Error::add_error(
2604
+					sprintf(
2605
+						esc_html__(
2606
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2607
+							'event_espresso'
2608
+						),
2609
+						$name
2610
+					),
2611
+					__FILE__,
2612
+					__FUNCTION__,
2613
+					__LINE__
2614
+				);
2615
+				// can't trash this registration because it has payments.
2616
+				continue;
2617
+			}
2618
+			$updated = $trash ? $REG->delete() : $REG->restore();
2619
+			if ($updated) {
2620
+				$success++;
2621
+			}
2622
+		}
2623
+		$this->_redirect_after_action(
2624
+			$success === $reg_count, // were ALL registrations affected?
2625
+			$success > 1
2626
+				? esc_html__('Registrations', 'event_espresso')
2627
+				: esc_html__('Registration', 'event_espresso'),
2628
+			$trash
2629
+				? esc_html__('moved to the trash', 'event_espresso')
2630
+				: esc_html__('restored', 'event_espresso'),
2631
+			$this->mergeExistingRequestParamsWithRedirectArgs(array('action' => 'default')),
2632
+			$overwrite_msgs
2633
+		);
2634
+	}
2635
+
2636
+
2637
+	/**
2638
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2639
+	 * registration but also.
2640
+	 * 1. Removing relations to EE_Attendee
2641
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2642
+	 * ALSO trashed.
2643
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2644
+	 * 4. Removing relationships between all tickets and the related registrations
2645
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2646
+	 * 6. Deleting permanently any related Checkins.
2647
+	 *
2648
+	 * @return void
2649
+	 * @throws EE_Error
2650
+	 * @throws InvalidArgumentException
2651
+	 * @throws InvalidDataTypeException
2652
+	 * @throws InvalidInterfaceException
2653
+	 * @throws ReflectionException
2654
+	 */
2655
+	protected function _delete_registrations()
2656
+	{
2657
+		$REG_MDL = $this->getRegistrationModel();
2658
+		$success = 1;
2659
+		// Checkboxes
2660
+		if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2661
+			// if array has more than one element than success message should be plural
2662
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2663
+			// cycle thru checkboxes
2664
+			foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2665
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2666
+				if (! $REG instanceof EE_Registration) {
2667
+					continue;
2668
+				}
2669
+				$deleted = $this->_delete_registration($REG);
2670
+				if (! $deleted) {
2671
+					$success = 0;
2672
+				}
2673
+			}
2674
+		} else {
2675
+			// grab single id and delete
2676
+			$REG_ID = $this->_req_data['_REG_ID'];
2677
+			/** @var EE_Registration $REG */
2678
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2679
+			$deleted = $this->_delete_registration($REG);
2680
+			if (! $deleted) {
2681
+				$success = 0;
2682
+			}
2683
+		}
2684
+		$what = $success > 1
2685
+			? esc_html__('Registrations', 'event_espresso')
2686
+			: esc_html__('Registration', 'event_espresso');
2687
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2688
+		$this->_redirect_after_action(
2689
+			$success,
2690
+			$what,
2691
+			$action_desc,
2692
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2693
+			true
2694
+		);
2695
+	}
2696
+
2697
+
2698
+	/**
2699
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2700
+	 * models get affected.
2701
+	 *
2702
+	 * @param EE_Registration $REG registration to be deleted permanently
2703
+	 * @return bool true = successful deletion, false = fail.
2704
+	 * @throws EE_Error
2705
+	 * @throws InvalidArgumentException
2706
+	 * @throws InvalidDataTypeException
2707
+	 * @throws InvalidInterfaceException
2708
+	 * @throws ReflectionException
2709
+	 */
2710
+	protected function _delete_registration(EE_Registration $REG)
2711
+	{
2712
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2713
+		// registrations on the transaction that are NOT trashed.
2714
+		$TXN = $REG->get_first_related('Transaction');
2715
+		$REGS = $TXN->get_many_related('Registration');
2716
+		$all_trashed = true;
2717
+		foreach ($REGS as $registration) {
2718
+			if (! $registration->get('REG_deleted')) {
2719
+				$all_trashed = false;
2720
+			}
2721
+		}
2722
+		if (! $all_trashed) {
2723
+			EE_Error::add_error(
2724
+				esc_html__(
2725
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2726
+					'event_espresso'
2727
+				),
2728
+				__FILE__,
2729
+				__FUNCTION__,
2730
+				__LINE__
2731
+			);
2732
+			return false;
2733
+		}
2734
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2735
+		// separately from THIS one).
2736
+		foreach ($REGS as $registration) {
2737
+			// delete related answers
2738
+			$registration->delete_related_permanently('Answer');
2739
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2740
+			$attendee = $registration->get_first_related('Attendee');
2741
+			if ($attendee instanceof EE_Attendee) {
2742
+				$registration->_remove_relation_to($attendee, 'Attendee');
2743
+			}
2744
+			// now remove relationships to tickets on this registration.
2745
+			$registration->_remove_relations('Ticket');
2746
+			// now delete permanently the checkins related to this registration.
2747
+			$registration->delete_related_permanently('Checkin');
2748
+			if ($registration->ID() === $REG->ID()) {
2749
+				continue;
2750
+			} //we don't want to delete permanently the existing registration just yet.
2751
+			// remove relation to transaction for these registrations if NOT the existing registrations
2752
+			$registration->_remove_relations('Transaction');
2753
+			// delete permanently any related messages.
2754
+			$registration->delete_related_permanently('Message');
2755
+			// now delete this registration permanently
2756
+			$registration->delete_permanently();
2757
+		}
2758
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2759
+		// (the transaction and line items should be all that's left).
2760
+		// delete the line items related to the transaction for this registration.
2761
+		$TXN->delete_related_permanently('Line_Item');
2762
+		// we need to remove all the relationships on the transaction
2763
+		$TXN->delete_related_permanently('Payment');
2764
+		$TXN->delete_related_permanently('Extra_Meta');
2765
+		$TXN->delete_related_permanently('Message');
2766
+		// now we can delete this REG permanently (and the transaction of course)
2767
+		$REG->delete_related_permanently('Transaction');
2768
+		return $REG->delete_permanently();
2769
+	}
2770
+
2771
+
2772
+	/**
2773
+	 *    generates HTML for the Register New Attendee Admin page
2774
+	 *
2775
+	 * @access private
2776
+	 * @throws DomainException
2777
+	 * @throws EE_Error
2778
+	 * @throws InvalidArgumentException
2779
+	 * @throws InvalidDataTypeException
2780
+	 * @throws InvalidInterfaceException
2781
+	 * @throws ReflectionException
2782
+	 */
2783
+	public function new_registration()
2784
+	{
2785
+		if (! $this->_set_reg_event()) {
2786
+			throw new EE_Error(
2787
+				esc_html__(
2788
+					'Unable to continue with registering because there is no Event ID in the request',
2789
+					'event_espresso'
2790
+				)
2791
+			);
2792
+		}
2793
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2794
+		// gotta start with a clean slate if we're not coming here via ajax
2795
+		if (! defined('DOING_AJAX')
2796
+			&& (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2797
+		) {
2798
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2799
+		}
2800
+		$this->_template_args['event_name'] = '';
2801
+		// event name
2802
+		if ($this->_reg_event) {
2803
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2804
+			$edit_event_url = self::add_query_args_and_nonce(
2805
+				array(
2806
+					'action' => 'edit',
2807
+					'post'   => $this->_reg_event->ID(),
2808
+				),
2809
+				EVENTS_ADMIN_URL
2810
+			);
2811
+			$edit_event_lnk = '<a href="'
2812
+							  . $edit_event_url
2813
+							  . '" title="'
2814
+							  . esc_attr__('Edit ', 'event_espresso')
2815
+							  . $this->_reg_event->name()
2816
+							  . '">'
2817
+							  . esc_html__('Edit Event', 'event_espresso')
2818
+							  . '</a>';
2819
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2820
+												   . $edit_event_lnk
2821
+												   . '</span>';
2822
+		}
2823
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2824
+		if (defined('DOING_AJAX')) {
2825
+			$this->_return_json();
2826
+		}
2827
+		// grab header
2828
+		$template_path =
2829
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2830
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
+			$template_path,
2832
+			$this->_template_args,
2833
+			true
2834
+		);
2835
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2836
+		// the details template wrapper
2837
+		$this->display_admin_page_with_sidebar();
2838
+	}
2839
+
2840
+
2841
+	/**
2842
+	 * This returns the content for a registration step
2843
+	 *
2844
+	 * @access protected
2845
+	 * @return string html
2846
+	 * @throws DomainException
2847
+	 * @throws EE_Error
2848
+	 * @throws InvalidArgumentException
2849
+	 * @throws InvalidDataTypeException
2850
+	 * @throws InvalidInterfaceException
2851
+	 */
2852
+	protected function _get_registration_step_content()
2853
+	{
2854
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2855
+			$warning_msg = sprintf(
2856
+				esc_html__(
2857
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2858
+					'event_espresso'
2859
+				),
2860
+				'<br />',
2861
+				'<h3 class="important-notice">',
2862
+				'</h3>',
2863
+				'<div class="float-right">',
2864
+				'<span id="redirect_timer" class="important-notice">30</span>',
2865
+				'</div>',
2866
+				'<b>',
2867
+				'</b>'
2868
+			);
2869
+			return '
2870 2870
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2871 2871
 	<script >
2872 2872
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2879,868 +2879,868 @@  discard block
 block discarded – undo
2879 2879
 	        }
2880 2880
 	    }, 800 );
2881 2881
 	</script >';
2882
-        }
2883
-        $template_args = array(
2884
-            'title'                    => '',
2885
-            'content'                  => '',
2886
-            'step_button_text'         => '',
2887
-            'show_notification_toggle' => false,
2888
-        );
2889
-        // to indicate we're processing a new registration
2890
-        $hidden_fields = array(
2891
-            'processing_registration' => array(
2892
-                'type'  => 'hidden',
2893
-                'value' => 0,
2894
-            ),
2895
-            'event_id'                => array(
2896
-                'type'  => 'hidden',
2897
-                'value' => $this->_reg_event->ID(),
2898
-            ),
2899
-        );
2900
-        // if the cart is empty then we know we're at step one so we'll display ticket selector
2901
-        $cart = EE_Registry::instance()->SSN->cart();
2902
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2903
-        switch ($step) {
2904
-            case 'ticket':
2905
-                $hidden_fields['processing_registration']['value'] = 1;
2906
-                $template_args['title'] = esc_html__(
2907
-                    'Step One: Select the Ticket for this registration',
2908
-                    'event_espresso'
2909
-                );
2910
-                $template_args['content'] =
2911
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2912
-                $template_args['content'] .= '</div>';
2913
-                $template_args['step_button_text'] = esc_html__(
2914
-                    'Add Tickets and Continue to Registrant Details',
2915
-                    'event_espresso'
2916
-                );
2917
-                $template_args['show_notification_toggle'] = false;
2918
-                break;
2919
-            case 'questions':
2920
-                $hidden_fields['processing_registration']['value'] = 2;
2921
-                $template_args['title'] = esc_html__(
2922
-                    'Step Two: Add Registrant Details for this Registration',
2923
-                    'event_espresso'
2924
-                );
2925
-                // in theory we should be able to run EED_SPCO at this point because the cart should have been setup
2926
-                // properly by the first process_reg_step run.
2927
-                $template_args['content'] =
2928
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2929
-                $template_args['step_button_text'] = esc_html__(
2930
-                    'Save Registration and Continue to Details',
2931
-                    'event_espresso'
2932
-                );
2933
-                $template_args['show_notification_toggle'] = true;
2934
-                break;
2935
-        }
2936
-        // we come back to the process_registration_step route.
2937
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2938
-        return EEH_Template::display_template(
2939
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2940
-            $template_args,
2941
-            true
2942
-        );
2943
-    }
2944
-
2945
-
2946
-    /**
2947
-     *        set_reg_event
2948
-     *
2949
-     * @access private
2950
-     * @return bool
2951
-     * @throws EE_Error
2952
-     * @throws InvalidArgumentException
2953
-     * @throws InvalidDataTypeException
2954
-     * @throws InvalidInterfaceException
2955
-     */
2956
-    private function _set_reg_event()
2957
-    {
2958
-        if (is_object($this->_reg_event)) {
2959
-            return true;
2960
-        }
2961
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
2962
-        if (! $EVT_ID) {
2963
-            return false;
2964
-        }
2965
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2966
-        return true;
2967
-    }
2968
-
2969
-
2970
-    /**
2971
-     * process_reg_step
2972
-     *
2973
-     * @access        public
2974
-     * @return string
2975
-     * @throws DomainException
2976
-     * @throws EE_Error
2977
-     * @throws InvalidArgumentException
2978
-     * @throws InvalidDataTypeException
2979
-     * @throws InvalidInterfaceException
2980
-     * @throws ReflectionException
2981
-     * @throws RuntimeException
2982
-     */
2983
-    public function process_reg_step()
2984
-    {
2985
-        EE_System::do_not_cache();
2986
-        $this->_set_reg_event();
2987
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2988
-        EE_Registry::instance()->REQ->set('uts', time());
2989
-        // what step are we on?
2990
-        $cart = EE_Registry::instance()->SSN->cart();
2991
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2992
-        // if doing ajax then we need to verify the nonce
2993
-        if (defined('DOING_AJAX')) {
2994
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
2995
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
2996
-            $this->_verify_nonce($nonce, $this->_req_nonce);
2997
-        }
2998
-        switch ($step) {
2999
-            case 'ticket':
3000
-                // process ticket selection
3001
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3002
-                if ($success) {
3003
-                    EE_Error::add_success(
3004
-                        esc_html__(
3005
-                            'Tickets Selected. Now complete the registration.',
3006
-                            'event_espresso'
3007
-                        )
3008
-                    );
3009
-                } else {
3010
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
3011
-                }
3012
-                if (defined('DOING_AJAX')) {
3013
-                    $this->new_registration(); // display next step
3014
-                } else {
3015
-                    $query_args = array(
3016
-                        'action'                  => 'new_registration',
3017
-                        'processing_registration' => 1,
3018
-                        'event_id'                => $this->_reg_event->ID(),
3019
-                        'uts'                     => time(),
3020
-                    );
3021
-                    $this->_redirect_after_action(
3022
-                        false,
3023
-                        '',
3024
-                        '',
3025
-                        $query_args,
3026
-                        true
3027
-                    );
3028
-                }
3029
-                break;
3030
-            case 'questions':
3031
-                if (! isset(
3032
-                    $this->_req_data['txn_reg_status_change'],
3033
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
3034
-                )
3035
-                ) {
3036
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3037
-                }
3038
-                // process registration
3039
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3040
-                if ($cart instanceof EE_Cart) {
3041
-                    $grand_total = $cart->get_cart_grand_total();
3042
-                    if ($grand_total instanceof EE_Line_Item) {
3043
-                        $grand_total->save_this_and_descendants_to_txn();
3044
-                    }
3045
-                }
3046
-                if (! $transaction instanceof EE_Transaction) {
3047
-                    $query_args = array(
3048
-                        'action'                  => 'new_registration',
3049
-                        'processing_registration' => 2,
3050
-                        'event_id'                => $this->_reg_event->ID(),
3051
-                        'uts'                     => time(),
3052
-                    );
3053
-                    if (defined('DOING_AJAX')) {
3054
-                        // display registration form again because there are errors (maybe validation?)
3055
-                        $this->new_registration();
3056
-                        return;
3057
-                    }
3058
-                    $this->_redirect_after_action(
3059
-                        false,
3060
-                        '',
3061
-                        '',
3062
-                        $query_args,
3063
-                        true
3064
-                    );
3065
-                    return;
3066
-                }
3067
-                // maybe update status, and make sure to save transaction if not done already
3068
-                if (! $transaction->update_status_based_on_total_paid()) {
3069
-                    $transaction->save();
3070
-                }
3071
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3072
-                $this->_req_data = array();
3073
-                $query_args = array(
3074
-                    'action'        => 'redirect_to_txn',
3075
-                    'TXN_ID'        => $transaction->ID(),
3076
-                    'EVT_ID'        => $this->_reg_event->ID(),
3077
-                    'event_name'    => urlencode($this->_reg_event->name()),
3078
-                    'redirect_from' => 'new_registration',
3079
-                );
3080
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3081
-                break;
3082
-        }
3083
-        // what are you looking here for?  Should be nothing to do at this point.
3084
-    }
3085
-
3086
-
3087
-    /**
3088
-     * redirect_to_txn
3089
-     *
3090
-     * @access public
3091
-     * @return void
3092
-     * @throws EE_Error
3093
-     * @throws InvalidArgumentException
3094
-     * @throws InvalidDataTypeException
3095
-     * @throws InvalidInterfaceException
3096
-     * @throws ReflectionException
3097
-     */
3098
-    public function redirect_to_txn()
3099
-    {
3100
-        EE_System::do_not_cache();
3101
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3102
-        $query_args = array(
3103
-            'action' => 'view_transaction',
3104
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3105
-            'page'   => 'espresso_transactions',
3106
-        );
3107
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3108
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3109
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
3110
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
3111
-        }
3112
-        EE_Error::add_success(
3113
-            esc_html__(
3114
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3115
-                'event_espresso'
3116
-            )
3117
-        );
3118
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3119
-    }
3120
-
3121
-
3122
-    /**
3123
-     *        generates HTML for the Attendee Contact List
3124
-     *
3125
-     * @access protected
3126
-     * @return void
3127
-     * @throws DomainException
3128
-     * @throws EE_Error
3129
-     */
3130
-    protected function _attendee_contact_list_table()
3131
-    {
3132
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3133
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3134
-        $this->display_admin_list_table_page_with_no_sidebar();
3135
-    }
3136
-
3137
-
3138
-    /**
3139
-     *        get_attendees
3140
-     *
3141
-     * @param      $per_page
3142
-     * @param bool $count whether to return count or data.
3143
-     * @param bool $trash
3144
-     * @return array
3145
-     * @throws EE_Error
3146
-     * @throws InvalidArgumentException
3147
-     * @throws InvalidDataTypeException
3148
-     * @throws InvalidInterfaceException
3149
-     * @access public
3150
-     */
3151
-    public function get_attendees($per_page, $count = false, $trash = false)
3152
-    {
3153
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3154
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3155
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3156
-        switch ($this->_req_data['orderby']) {
3157
-            case 'ATT_ID':
3158
-                $orderby = 'ATT_ID';
3159
-                break;
3160
-            case 'ATT_fname':
3161
-                $orderby = 'ATT_fname';
3162
-                break;
3163
-            case 'ATT_email':
3164
-                $orderby = 'ATT_email';
3165
-                break;
3166
-            case 'ATT_city':
3167
-                $orderby = 'ATT_city';
3168
-                break;
3169
-            case 'STA_ID':
3170
-                $orderby = 'STA_ID';
3171
-                break;
3172
-            case 'CNT_ID':
3173
-                $orderby = 'CNT_ID';
3174
-                break;
3175
-            case 'Registration_Count':
3176
-                $orderby = 'Registration_Count';
3177
-                break;
3178
-            default:
3179
-                $orderby = 'ATT_lname';
3180
-        }
3181
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3182
-            ? $this->_req_data['order']
3183
-            : 'ASC';
3184
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3185
-            ? $this->_req_data['paged']
3186
-            : 1;
3187
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3188
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3189
-            ? $this->_req_data['perpage']
3190
-            : $per_page;
3191
-        $_where = array();
3192
-        if (! empty($this->_req_data['s'])) {
3193
-            $sstr = '%' . $this->_req_data['s'] . '%';
3194
-            $_where['OR'] = array(
3195
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3196
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3197
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3198
-                'ATT_fname'                         => array('LIKE', $sstr),
3199
-                'ATT_lname'                         => array('LIKE', $sstr),
3200
-                'ATT_short_bio'                     => array('LIKE', $sstr),
3201
-                'ATT_email'                         => array('LIKE', $sstr),
3202
-                'ATT_address'                       => array('LIKE', $sstr),
3203
-                'ATT_address2'                      => array('LIKE', $sstr),
3204
-                'ATT_city'                          => array('LIKE', $sstr),
3205
-                'Country.CNT_name'                  => array('LIKE', $sstr),
3206
-                'State.STA_name'                    => array('LIKE', $sstr),
3207
-                'ATT_phone'                         => array('LIKE', $sstr),
3208
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
3209
-                'Registration.REG_code'             => array('LIKE', $sstr),
3210
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
3211
-            );
3212
-        }
3213
-        $offset = ($current_page - 1) * $per_page;
3214
-        $limit = $count ? null : array($offset, $per_page);
3215
-        $query_args = array(
3216
-            $_where,
3217
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3218
-            'limit'         => $limit,
3219
-        );
3220
-        if (! $count) {
3221
-            $query_args['order_by'] = array($orderby => $sort);
3222
-        }
3223
-        if ($trash) {
3224
-            $query_args[0]['status'] = array('!=', 'publish');
3225
-            $all_attendees = $count
3226
-                ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3227
-                : $this->getAttendeeModel()->get_all($query_args);
3228
-        } else {
3229
-            $query_args[0]['status'] = array('IN', array('publish'));
3230
-            $all_attendees = $count
3231
-                ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3232
-                : $this->getAttendeeModel()->get_all($query_args);
3233
-        }
3234
-        return $all_attendees;
3235
-    }
3236
-
3237
-
3238
-    /**
3239
-     * This is just taking care of resending the registration confirmation
3240
-     *
3241
-     * @access protected
3242
-     * @return void
3243
-     * @throws EE_Error
3244
-     * @throws InvalidArgumentException
3245
-     * @throws InvalidDataTypeException
3246
-     * @throws InvalidInterfaceException
3247
-     * @throws ReflectionException
3248
-     */
3249
-    protected function _resend_registration()
3250
-    {
3251
-        $this->_process_resend_registration();
3252
-        $query_args = isset($this->_req_data['redirect_to'])
3253
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3254
-            : array('action' => 'default');
3255
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3256
-    }
3257
-
3258
-    /**
3259
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3260
-     * to use when selecting registrations
3261
-     *
3262
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3263
-     *                                                     the query parameters from the request
3264
-     * @return void ends the request with a redirect or download
3265
-     */
3266
-    public function _registrations_report_base($method_name_for_getting_query_params)
3267
-    {
3268
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3269
-            wp_redirect(
3270
-                EE_Admin_Page::add_query_args_and_nonce(
3271
-                    array(
3272
-                        'page'        => 'espresso_batch',
3273
-                        'batch'       => 'file',
3274
-                        'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3275
-                        'filters'     => urlencode(
3276
-                            serialize(
3277
-                                $this->$method_name_for_getting_query_params(
3278
-                                    EEH_Array::is_set(
3279
-                                        $this->_req_data,
3280
-                                        'filters',
3281
-                                        array()
3282
-                                    )
3283
-                                )
3284
-                            )
3285
-                        ),
3286
-                        'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3287
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3288
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3289
-                    )
3290
-                )
3291
-            );
3292
-        } else {
3293
-            $new_request_args = array(
3294
-                'export' => 'report',
3295
-                'action' => 'registrations_report_for_event',
3296
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3297
-            );
3298
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
3299
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3300
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3301
-                $EE_Export = EE_Export::instance($this->_req_data);
3302
-                $EE_Export->export();
3303
-            }
3304
-        }
3305
-    }
3306
-
3307
-
3308
-    /**
3309
-     * Creates a registration report using only query parameters in the request
3310
-     *
3311
-     * @return void
3312
-     */
3313
-    public function _registrations_report()
3314
-    {
3315
-        $this->_registrations_report_base('_get_registration_query_parameters');
3316
-    }
3317
-
3318
-
3319
-    public function _contact_list_export()
3320
-    {
3321
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3322
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3323
-            $EE_Export = EE_Export::instance($this->_req_data);
3324
-            $EE_Export->export_attendees();
3325
-        }
3326
-    }
3327
-
3328
-
3329
-    public function _contact_list_report()
3330
-    {
3331
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3332
-            wp_redirect(
3333
-                EE_Admin_Page::add_query_args_and_nonce(
3334
-                    array(
3335
-                        'page'        => 'espresso_batch',
3336
-                        'batch'       => 'file',
3337
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3338
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3339
-                    )
3340
-                )
3341
-            );
3342
-        } else {
3343
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3344
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3345
-                $EE_Export = EE_Export::instance($this->_req_data);
3346
-                $EE_Export->report_attendees();
3347
-            }
3348
-        }
3349
-    }
3350
-
3351
-
3352
-
3353
-
3354
-
3355
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3356
-    /**
3357
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3358
-     *
3359
-     * @return void
3360
-     * @throws EE_Error
3361
-     * @throws InvalidArgumentException
3362
-     * @throws InvalidDataTypeException
3363
-     * @throws InvalidInterfaceException
3364
-     * @throws ReflectionException
3365
-     */
3366
-    protected function _duplicate_attendee()
3367
-    {
3368
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3369
-        // verify we have necessary info
3370
-        if (empty($this->_req_data['_REG_ID'])) {
3371
-            EE_Error::add_error(
3372
-                esc_html__(
3373
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3374
-                    'event_espresso'
3375
-                ),
3376
-                __FILE__,
3377
-                __LINE__,
3378
-                __FUNCTION__
3379
-            );
3380
-            $query_args = array('action' => $action);
3381
-            $this->_redirect_after_action('', '', '', $query_args, true);
3382
-        }
3383
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3384
-        $registration = $this->getRegistrationModel()->get_one_by_ID($this->_req_data['_REG_ID']);
3385
-        $attendee = $registration->attendee();
3386
-        // remove relation of existing attendee on registration
3387
-        $registration->_remove_relation_to($attendee, 'Attendee');
3388
-        // new attendee
3389
-        $new_attendee = clone $attendee;
3390
-        $new_attendee->set('ATT_ID', 0);
3391
-        $new_attendee->save();
3392
-        // add new attendee to reg
3393
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3394
-        EE_Error::add_success(
3395
-            esc_html__(
3396
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3397
-                'event_espresso'
3398
-            )
3399
-        );
3400
-        // redirect to edit page for attendee
3401
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3402
-        $this->_redirect_after_action('', '', '', $query_args, true);
3403
-    }
3404
-
3405
-
3406
-    /**
3407
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3408
-     *
3409
-     * @param int     $post_id
3410
-     * @param WP_POST $post
3411
-     * @throws DomainException
3412
-     * @throws EE_Error
3413
-     * @throws InvalidArgumentException
3414
-     * @throws InvalidDataTypeException
3415
-     * @throws InvalidInterfaceException
3416
-     * @throws LogicException
3417
-     * @throws InvalidFormSubmissionException
3418
-     * @throws ReflectionException
3419
-     */
3420
-    protected function _insert_update_cpt_item($post_id, $post)
3421
-    {
3422
-        $success = true;
3423
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3424
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3425
-            : null;
3426
-        // for attendee updates
3427
-        if ($attendee instanceof EE_Attendee) {
3428
-            // note we should only be UPDATING attendees at this point.
3429
-            $updated_fields = array(
3430
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
3431
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
3432
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3433
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3434
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3435
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3436
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3437
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3438
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3439
-            );
3440
-            foreach ($updated_fields as $field => $value) {
3441
-                $attendee->set($field, $value);
3442
-            }
3443
-
3444
-            // process contact details metabox form handler (which will also save the attendee)
3445
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3446
-            $success = $contact_details_form->process($this->_req_data);
3447
-
3448
-            $attendee_update_callbacks = apply_filters(
3449
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3450
-                array()
3451
-            );
3452
-            foreach ($attendee_update_callbacks as $a_callback) {
3453
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3454
-                    throw new EE_Error(
3455
-                        sprintf(
3456
-                            esc_html__(
3457
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3458
-                                'event_espresso'
3459
-                            ),
3460
-                            $a_callback
3461
-                        )
3462
-                    );
3463
-                }
3464
-            }
3465
-        }
3466
-
3467
-        if ($success === false) {
3468
-            EE_Error::add_error(
3469
-                esc_html__(
3470
-                    'Something went wrong with updating the meta table data for the registration.',
3471
-                    'event_espresso'
3472
-                ),
3473
-                __FILE__,
3474
-                __FUNCTION__,
3475
-                __LINE__
3476
-            );
3477
-        }
3478
-    }
3479
-
3480
-
3481
-    public function trash_cpt_item($post_id)
3482
-    {
3483
-    }
3484
-
3485
-
3486
-    public function delete_cpt_item($post_id)
3487
-    {
3488
-    }
3489
-
3490
-
3491
-    public function restore_cpt_item($post_id)
3492
-    {
3493
-    }
3494
-
3495
-
3496
-    protected function _restore_cpt_item($post_id, $revision_id)
3497
-    {
3498
-    }
3499
-
3500
-
3501
-    /**
3502
-     * @throws EE_Error
3503
-     * @since 4.10.2.p
3504
-     */
3505
-    public function attendee_editor_metaboxes()
3506
-    {
3507
-        $this->verify_cpt_object();
3508
-        remove_meta_box(
3509
-            'postexcerpt',
3510
-            $this->_cpt_routes[ $this->_req_action ],
3511
-            'normal'
3512
-        );
3513
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3514
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3515
-            add_meta_box(
3516
-                'postexcerpt',
3517
-                esc_html__('Short Biography', 'event_espresso'),
3518
-                'post_excerpt_meta_box',
3519
-                $this->_cpt_routes[ $this->_req_action ],
3520
-                'normal'
3521
-            );
3522
-        }
3523
-        if (post_type_supports('espresso_attendees', 'comments')) {
3524
-            add_meta_box(
3525
-                'commentsdiv',
3526
-                esc_html__('Notes on the Contact', 'event_espresso'),
3527
-                'post_comment_meta_box',
3528
-                $this->_cpt_routes[ $this->_req_action ],
3529
-                'normal',
3530
-                'core'
3531
-            );
3532
-        }
3533
-        add_meta_box(
3534
-            'attendee_contact_info',
3535
-            esc_html__('Contact Info', 'event_espresso'),
3536
-            array($this, 'attendee_contact_info'),
3537
-            $this->_cpt_routes[ $this->_req_action ],
3538
-            'side',
3539
-            'core'
3540
-        );
3541
-        add_meta_box(
3542
-            'attendee_details_address',
3543
-            esc_html__('Address Details', 'event_espresso'),
3544
-            array($this, 'attendee_address_details'),
3545
-            $this->_cpt_routes[ $this->_req_action ],
3546
-            'normal',
3547
-            'core'
3548
-        );
3549
-        add_meta_box(
3550
-            'attendee_registrations',
3551
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3552
-            array($this, 'attendee_registrations_meta_box'),
3553
-            $this->_cpt_routes[ $this->_req_action ],
3554
-            'normal',
3555
-            'high'
3556
-        );
3557
-    }
3558
-
3559
-
3560
-    /**
3561
-     * Metabox for attendee contact info
3562
-     *
3563
-     * @param  WP_Post $post wp post object
3564
-     * @return string attendee contact info ( and form )
3565
-     * @throws EE_Error
3566
-     * @throws InvalidArgumentException
3567
-     * @throws InvalidDataTypeException
3568
-     * @throws InvalidInterfaceException
3569
-     * @throws LogicException
3570
-     * @throws DomainException
3571
-     */
3572
-    public function attendee_contact_info($post)
3573
-    {
3574
-        // get attendee object ( should already have it )
3575
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3576
-        $form->enqueueStylesAndScripts();
3577
-        echo $form->display();
3578
-    }
3579
-
3580
-
3581
-    /**
3582
-     * Return form handler for the contact details metabox
3583
-     *
3584
-     * @param EE_Attendee $attendee
3585
-     * @return AttendeeContactDetailsMetaboxFormHandler
3586
-     * @throws DomainException
3587
-     * @throws InvalidArgumentException
3588
-     * @throws InvalidDataTypeException
3589
-     * @throws InvalidInterfaceException
3590
-     */
3591
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3592
-    {
3593
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3594
-    }
3595
-
3596
-
3597
-    /**
3598
-     * Metabox for attendee details
3599
-     *
3600
-     * @param  WP_Post $post wp post object
3601
-     * @throws DomainException
3602
-     */
3603
-    public function attendee_address_details($post)
3604
-    {
3605
-        // get attendee object (should already have it)
3606
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3607
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3608
-            new EE_Question_Form_Input(
3609
-                EE_Question::new_instance(
3610
-                    array(
3611
-                        'QST_ID'           => 0,
3612
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3613
-                        'QST_system'       => 'admin-state',
3614
-                    )
3615
-                ),
3616
-                EE_Answer::new_instance(
3617
-                    array(
3618
-                        'ANS_ID'    => 0,
3619
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3620
-                    )
3621
-                ),
3622
-                array(
3623
-                    'input_id'       => 'STA_ID',
3624
-                    'input_name'     => 'STA_ID',
3625
-                    'input_prefix'   => '',
3626
-                    'append_qstn_id' => false,
3627
-                )
3628
-            )
3629
-        );
3630
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3631
-            new EE_Question_Form_Input(
3632
-                EE_Question::new_instance(
3633
-                    array(
3634
-                        'QST_ID'           => 0,
3635
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3636
-                        'QST_system'       => 'admin-country',
3637
-                    )
3638
-                ),
3639
-                EE_Answer::new_instance(
3640
-                    array(
3641
-                        'ANS_ID'    => 0,
3642
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3643
-                    )
3644
-                ),
3645
-                array(
3646
-                    'input_id'       => 'CNT_ISO',
3647
-                    'input_name'     => 'CNT_ISO',
3648
-                    'input_prefix'   => '',
3649
-                    'append_qstn_id' => false,
3650
-                )
3651
-            )
3652
-        );
3653
-        $template =
3654
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3655
-        EEH_Template::display_template($template, $this->_template_args);
3656
-    }
3657
-
3658
-
3659
-    /**
3660
-     *        _attendee_details
3661
-     *
3662
-     * @access protected
3663
-     * @param $post
3664
-     * @return void
3665
-     * @throws DomainException
3666
-     * @throws EE_Error
3667
-     * @throws InvalidArgumentException
3668
-     * @throws InvalidDataTypeException
3669
-     * @throws InvalidInterfaceException
3670
-     * @throws ReflectionException
3671
-     */
3672
-    public function attendee_registrations_meta_box($post)
3673
-    {
3674
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3675
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3676
-        $template =
3677
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3678
-        EEH_Template::display_template($template, $this->_template_args);
3679
-    }
3680
-
3681
-
3682
-    /**
3683
-     * add in the form fields for the attendee edit
3684
-     *
3685
-     * @param  WP_Post $post wp post object
3686
-     * @return string html for new form.
3687
-     * @throws DomainException
3688
-     */
3689
-    public function after_title_form_fields($post)
3690
-    {
3691
-        if ($post->post_type === 'espresso_attendees') {
3692
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3693
-            $template_args['attendee'] = $this->_cpt_model_obj;
3694
-            EEH_Template::display_template($template, $template_args);
3695
-        }
3696
-    }
3697
-
3698
-
3699
-    /**
3700
-     *        _trash_or_restore_attendee
3701
-     *
3702
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3703
-     * @return void
3704
-     * @throws EE_Error
3705
-     * @throws InvalidArgumentException
3706
-     * @throws InvalidDataTypeException
3707
-     * @throws InvalidInterfaceException
3708
-     * @throws ReflectionException
3709
-     * @access protected
3710
-     */
3711
-    protected function _trash_or_restore_attendees($trash = true)
3712
-    {
3713
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3714
-        $success = 1;
3715
-        // Checkboxes
3716
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3717
-            // if array has more than one element than success message should be plural
3718
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3719
-            // cycle thru checkboxes
3720
-            foreach ($this->_req_data['checkbox'] as $ATT_ID) {
3721
-                $updated = $trash ? $this->getAttendeeModel()->update_by_ID(array('status' => 'trash'), $ATT_ID)
3722
-                    : $this->getAttendeeModel()->update_by_ID(array('status' => 'publish'), $ATT_ID);
3723
-                if (! $updated) {
3724
-                    $success = 0;
3725
-                }
3726
-            }
3727
-        } else {
3728
-            // grab single id and delete
3729
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
3730
-            // get attendee
3731
-            $att = $this->getAttendeeModel()->get_one_by_ID($ATT_ID);
3732
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3733
-            $updated = $att->save() && $updated;
3734
-            if (! $updated) {
3735
-                $success = 0;
3736
-            }
3737
-        }
3738
-        $what = $success > 1
3739
-            ? esc_html__('Contacts', 'event_espresso')
3740
-            : esc_html__('Contact', 'event_espresso');
3741
-        $action_desc = $trash
3742
-            ? esc_html__('moved to the trash', 'event_espresso')
3743
-            : esc_html__('restored', 'event_espresso');
3744
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3745
-    }
2882
+		}
2883
+		$template_args = array(
2884
+			'title'                    => '',
2885
+			'content'                  => '',
2886
+			'step_button_text'         => '',
2887
+			'show_notification_toggle' => false,
2888
+		);
2889
+		// to indicate we're processing a new registration
2890
+		$hidden_fields = array(
2891
+			'processing_registration' => array(
2892
+				'type'  => 'hidden',
2893
+				'value' => 0,
2894
+			),
2895
+			'event_id'                => array(
2896
+				'type'  => 'hidden',
2897
+				'value' => $this->_reg_event->ID(),
2898
+			),
2899
+		);
2900
+		// if the cart is empty then we know we're at step one so we'll display ticket selector
2901
+		$cart = EE_Registry::instance()->SSN->cart();
2902
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2903
+		switch ($step) {
2904
+			case 'ticket':
2905
+				$hidden_fields['processing_registration']['value'] = 1;
2906
+				$template_args['title'] = esc_html__(
2907
+					'Step One: Select the Ticket for this registration',
2908
+					'event_espresso'
2909
+				);
2910
+				$template_args['content'] =
2911
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2912
+				$template_args['content'] .= '</div>';
2913
+				$template_args['step_button_text'] = esc_html__(
2914
+					'Add Tickets and Continue to Registrant Details',
2915
+					'event_espresso'
2916
+				);
2917
+				$template_args['show_notification_toggle'] = false;
2918
+				break;
2919
+			case 'questions':
2920
+				$hidden_fields['processing_registration']['value'] = 2;
2921
+				$template_args['title'] = esc_html__(
2922
+					'Step Two: Add Registrant Details for this Registration',
2923
+					'event_espresso'
2924
+				);
2925
+				// in theory we should be able to run EED_SPCO at this point because the cart should have been setup
2926
+				// properly by the first process_reg_step run.
2927
+				$template_args['content'] =
2928
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2929
+				$template_args['step_button_text'] = esc_html__(
2930
+					'Save Registration and Continue to Details',
2931
+					'event_espresso'
2932
+				);
2933
+				$template_args['show_notification_toggle'] = true;
2934
+				break;
2935
+		}
2936
+		// we come back to the process_registration_step route.
2937
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2938
+		return EEH_Template::display_template(
2939
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2940
+			$template_args,
2941
+			true
2942
+		);
2943
+	}
2944
+
2945
+
2946
+	/**
2947
+	 *        set_reg_event
2948
+	 *
2949
+	 * @access private
2950
+	 * @return bool
2951
+	 * @throws EE_Error
2952
+	 * @throws InvalidArgumentException
2953
+	 * @throws InvalidDataTypeException
2954
+	 * @throws InvalidInterfaceException
2955
+	 */
2956
+	private function _set_reg_event()
2957
+	{
2958
+		if (is_object($this->_reg_event)) {
2959
+			return true;
2960
+		}
2961
+		$EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
2962
+		if (! $EVT_ID) {
2963
+			return false;
2964
+		}
2965
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2966
+		return true;
2967
+	}
2968
+
2969
+
2970
+	/**
2971
+	 * process_reg_step
2972
+	 *
2973
+	 * @access        public
2974
+	 * @return string
2975
+	 * @throws DomainException
2976
+	 * @throws EE_Error
2977
+	 * @throws InvalidArgumentException
2978
+	 * @throws InvalidDataTypeException
2979
+	 * @throws InvalidInterfaceException
2980
+	 * @throws ReflectionException
2981
+	 * @throws RuntimeException
2982
+	 */
2983
+	public function process_reg_step()
2984
+	{
2985
+		EE_System::do_not_cache();
2986
+		$this->_set_reg_event();
2987
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2988
+		EE_Registry::instance()->REQ->set('uts', time());
2989
+		// what step are we on?
2990
+		$cart = EE_Registry::instance()->SSN->cart();
2991
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2992
+		// if doing ajax then we need to verify the nonce
2993
+		if (defined('DOING_AJAX')) {
2994
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
2995
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
2996
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2997
+		}
2998
+		switch ($step) {
2999
+			case 'ticket':
3000
+				// process ticket selection
3001
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3002
+				if ($success) {
3003
+					EE_Error::add_success(
3004
+						esc_html__(
3005
+							'Tickets Selected. Now complete the registration.',
3006
+							'event_espresso'
3007
+						)
3008
+					);
3009
+				} else {
3010
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
3011
+				}
3012
+				if (defined('DOING_AJAX')) {
3013
+					$this->new_registration(); // display next step
3014
+				} else {
3015
+					$query_args = array(
3016
+						'action'                  => 'new_registration',
3017
+						'processing_registration' => 1,
3018
+						'event_id'                => $this->_reg_event->ID(),
3019
+						'uts'                     => time(),
3020
+					);
3021
+					$this->_redirect_after_action(
3022
+						false,
3023
+						'',
3024
+						'',
3025
+						$query_args,
3026
+						true
3027
+					);
3028
+				}
3029
+				break;
3030
+			case 'questions':
3031
+				if (! isset(
3032
+					$this->_req_data['txn_reg_status_change'],
3033
+					$this->_req_data['txn_reg_status_change']['send_notifications']
3034
+				)
3035
+				) {
3036
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3037
+				}
3038
+				// process registration
3039
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3040
+				if ($cart instanceof EE_Cart) {
3041
+					$grand_total = $cart->get_cart_grand_total();
3042
+					if ($grand_total instanceof EE_Line_Item) {
3043
+						$grand_total->save_this_and_descendants_to_txn();
3044
+					}
3045
+				}
3046
+				if (! $transaction instanceof EE_Transaction) {
3047
+					$query_args = array(
3048
+						'action'                  => 'new_registration',
3049
+						'processing_registration' => 2,
3050
+						'event_id'                => $this->_reg_event->ID(),
3051
+						'uts'                     => time(),
3052
+					);
3053
+					if (defined('DOING_AJAX')) {
3054
+						// display registration form again because there are errors (maybe validation?)
3055
+						$this->new_registration();
3056
+						return;
3057
+					}
3058
+					$this->_redirect_after_action(
3059
+						false,
3060
+						'',
3061
+						'',
3062
+						$query_args,
3063
+						true
3064
+					);
3065
+					return;
3066
+				}
3067
+				// maybe update status, and make sure to save transaction if not done already
3068
+				if (! $transaction->update_status_based_on_total_paid()) {
3069
+					$transaction->save();
3070
+				}
3071
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3072
+				$this->_req_data = array();
3073
+				$query_args = array(
3074
+					'action'        => 'redirect_to_txn',
3075
+					'TXN_ID'        => $transaction->ID(),
3076
+					'EVT_ID'        => $this->_reg_event->ID(),
3077
+					'event_name'    => urlencode($this->_reg_event->name()),
3078
+					'redirect_from' => 'new_registration',
3079
+				);
3080
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3081
+				break;
3082
+		}
3083
+		// what are you looking here for?  Should be nothing to do at this point.
3084
+	}
3085
+
3086
+
3087
+	/**
3088
+	 * redirect_to_txn
3089
+	 *
3090
+	 * @access public
3091
+	 * @return void
3092
+	 * @throws EE_Error
3093
+	 * @throws InvalidArgumentException
3094
+	 * @throws InvalidDataTypeException
3095
+	 * @throws InvalidInterfaceException
3096
+	 * @throws ReflectionException
3097
+	 */
3098
+	public function redirect_to_txn()
3099
+	{
3100
+		EE_System::do_not_cache();
3101
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3102
+		$query_args = array(
3103
+			'action' => 'view_transaction',
3104
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3105
+			'page'   => 'espresso_transactions',
3106
+		);
3107
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3108
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3109
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
3110
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
3111
+		}
3112
+		EE_Error::add_success(
3113
+			esc_html__(
3114
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3115
+				'event_espresso'
3116
+			)
3117
+		);
3118
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3119
+	}
3120
+
3121
+
3122
+	/**
3123
+	 *        generates HTML for the Attendee Contact List
3124
+	 *
3125
+	 * @access protected
3126
+	 * @return void
3127
+	 * @throws DomainException
3128
+	 * @throws EE_Error
3129
+	 */
3130
+	protected function _attendee_contact_list_table()
3131
+	{
3132
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3133
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3134
+		$this->display_admin_list_table_page_with_no_sidebar();
3135
+	}
3136
+
3137
+
3138
+	/**
3139
+	 *        get_attendees
3140
+	 *
3141
+	 * @param      $per_page
3142
+	 * @param bool $count whether to return count or data.
3143
+	 * @param bool $trash
3144
+	 * @return array
3145
+	 * @throws EE_Error
3146
+	 * @throws InvalidArgumentException
3147
+	 * @throws InvalidDataTypeException
3148
+	 * @throws InvalidInterfaceException
3149
+	 * @access public
3150
+	 */
3151
+	public function get_attendees($per_page, $count = false, $trash = false)
3152
+	{
3153
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3154
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3155
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3156
+		switch ($this->_req_data['orderby']) {
3157
+			case 'ATT_ID':
3158
+				$orderby = 'ATT_ID';
3159
+				break;
3160
+			case 'ATT_fname':
3161
+				$orderby = 'ATT_fname';
3162
+				break;
3163
+			case 'ATT_email':
3164
+				$orderby = 'ATT_email';
3165
+				break;
3166
+			case 'ATT_city':
3167
+				$orderby = 'ATT_city';
3168
+				break;
3169
+			case 'STA_ID':
3170
+				$orderby = 'STA_ID';
3171
+				break;
3172
+			case 'CNT_ID':
3173
+				$orderby = 'CNT_ID';
3174
+				break;
3175
+			case 'Registration_Count':
3176
+				$orderby = 'Registration_Count';
3177
+				break;
3178
+			default:
3179
+				$orderby = 'ATT_lname';
3180
+		}
3181
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3182
+			? $this->_req_data['order']
3183
+			: 'ASC';
3184
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3185
+			? $this->_req_data['paged']
3186
+			: 1;
3187
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3188
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3189
+			? $this->_req_data['perpage']
3190
+			: $per_page;
3191
+		$_where = array();
3192
+		if (! empty($this->_req_data['s'])) {
3193
+			$sstr = '%' . $this->_req_data['s'] . '%';
3194
+			$_where['OR'] = array(
3195
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3196
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3197
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3198
+				'ATT_fname'                         => array('LIKE', $sstr),
3199
+				'ATT_lname'                         => array('LIKE', $sstr),
3200
+				'ATT_short_bio'                     => array('LIKE', $sstr),
3201
+				'ATT_email'                         => array('LIKE', $sstr),
3202
+				'ATT_address'                       => array('LIKE', $sstr),
3203
+				'ATT_address2'                      => array('LIKE', $sstr),
3204
+				'ATT_city'                          => array('LIKE', $sstr),
3205
+				'Country.CNT_name'                  => array('LIKE', $sstr),
3206
+				'State.STA_name'                    => array('LIKE', $sstr),
3207
+				'ATT_phone'                         => array('LIKE', $sstr),
3208
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
3209
+				'Registration.REG_code'             => array('LIKE', $sstr),
3210
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
3211
+			);
3212
+		}
3213
+		$offset = ($current_page - 1) * $per_page;
3214
+		$limit = $count ? null : array($offset, $per_page);
3215
+		$query_args = array(
3216
+			$_where,
3217
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3218
+			'limit'         => $limit,
3219
+		);
3220
+		if (! $count) {
3221
+			$query_args['order_by'] = array($orderby => $sort);
3222
+		}
3223
+		if ($trash) {
3224
+			$query_args[0]['status'] = array('!=', 'publish');
3225
+			$all_attendees = $count
3226
+				? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3227
+				: $this->getAttendeeModel()->get_all($query_args);
3228
+		} else {
3229
+			$query_args[0]['status'] = array('IN', array('publish'));
3230
+			$all_attendees = $count
3231
+				? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3232
+				: $this->getAttendeeModel()->get_all($query_args);
3233
+		}
3234
+		return $all_attendees;
3235
+	}
3236
+
3237
+
3238
+	/**
3239
+	 * This is just taking care of resending the registration confirmation
3240
+	 *
3241
+	 * @access protected
3242
+	 * @return void
3243
+	 * @throws EE_Error
3244
+	 * @throws InvalidArgumentException
3245
+	 * @throws InvalidDataTypeException
3246
+	 * @throws InvalidInterfaceException
3247
+	 * @throws ReflectionException
3248
+	 */
3249
+	protected function _resend_registration()
3250
+	{
3251
+		$this->_process_resend_registration();
3252
+		$query_args = isset($this->_req_data['redirect_to'])
3253
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3254
+			: array('action' => 'default');
3255
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3256
+	}
3257
+
3258
+	/**
3259
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3260
+	 * to use when selecting registrations
3261
+	 *
3262
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3263
+	 *                                                     the query parameters from the request
3264
+	 * @return void ends the request with a redirect or download
3265
+	 */
3266
+	public function _registrations_report_base($method_name_for_getting_query_params)
3267
+	{
3268
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3269
+			wp_redirect(
3270
+				EE_Admin_Page::add_query_args_and_nonce(
3271
+					array(
3272
+						'page'        => 'espresso_batch',
3273
+						'batch'       => 'file',
3274
+						'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3275
+						'filters'     => urlencode(
3276
+							serialize(
3277
+								$this->$method_name_for_getting_query_params(
3278
+									EEH_Array::is_set(
3279
+										$this->_req_data,
3280
+										'filters',
3281
+										array()
3282
+									)
3283
+								)
3284
+							)
3285
+						),
3286
+						'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3287
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3288
+						'return_url'  => urlencode($this->_req_data['return_url']),
3289
+					)
3290
+				)
3291
+			);
3292
+		} else {
3293
+			$new_request_args = array(
3294
+				'export' => 'report',
3295
+				'action' => 'registrations_report_for_event',
3296
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3297
+			);
3298
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
3299
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3300
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3301
+				$EE_Export = EE_Export::instance($this->_req_data);
3302
+				$EE_Export->export();
3303
+			}
3304
+		}
3305
+	}
3306
+
3307
+
3308
+	/**
3309
+	 * Creates a registration report using only query parameters in the request
3310
+	 *
3311
+	 * @return void
3312
+	 */
3313
+	public function _registrations_report()
3314
+	{
3315
+		$this->_registrations_report_base('_get_registration_query_parameters');
3316
+	}
3317
+
3318
+
3319
+	public function _contact_list_export()
3320
+	{
3321
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3322
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3323
+			$EE_Export = EE_Export::instance($this->_req_data);
3324
+			$EE_Export->export_attendees();
3325
+		}
3326
+	}
3327
+
3328
+
3329
+	public function _contact_list_report()
3330
+	{
3331
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3332
+			wp_redirect(
3333
+				EE_Admin_Page::add_query_args_and_nonce(
3334
+					array(
3335
+						'page'        => 'espresso_batch',
3336
+						'batch'       => 'file',
3337
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3338
+						'return_url'  => urlencode($this->_req_data['return_url']),
3339
+					)
3340
+				)
3341
+			);
3342
+		} else {
3343
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3344
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3345
+				$EE_Export = EE_Export::instance($this->_req_data);
3346
+				$EE_Export->report_attendees();
3347
+			}
3348
+		}
3349
+	}
3350
+
3351
+
3352
+
3353
+
3354
+
3355
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3356
+	/**
3357
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3358
+	 *
3359
+	 * @return void
3360
+	 * @throws EE_Error
3361
+	 * @throws InvalidArgumentException
3362
+	 * @throws InvalidDataTypeException
3363
+	 * @throws InvalidInterfaceException
3364
+	 * @throws ReflectionException
3365
+	 */
3366
+	protected function _duplicate_attendee()
3367
+	{
3368
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3369
+		// verify we have necessary info
3370
+		if (empty($this->_req_data['_REG_ID'])) {
3371
+			EE_Error::add_error(
3372
+				esc_html__(
3373
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3374
+					'event_espresso'
3375
+				),
3376
+				__FILE__,
3377
+				__LINE__,
3378
+				__FUNCTION__
3379
+			);
3380
+			$query_args = array('action' => $action);
3381
+			$this->_redirect_after_action('', '', '', $query_args, true);
3382
+		}
3383
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3384
+		$registration = $this->getRegistrationModel()->get_one_by_ID($this->_req_data['_REG_ID']);
3385
+		$attendee = $registration->attendee();
3386
+		// remove relation of existing attendee on registration
3387
+		$registration->_remove_relation_to($attendee, 'Attendee');
3388
+		// new attendee
3389
+		$new_attendee = clone $attendee;
3390
+		$new_attendee->set('ATT_ID', 0);
3391
+		$new_attendee->save();
3392
+		// add new attendee to reg
3393
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3394
+		EE_Error::add_success(
3395
+			esc_html__(
3396
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3397
+				'event_espresso'
3398
+			)
3399
+		);
3400
+		// redirect to edit page for attendee
3401
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3402
+		$this->_redirect_after_action('', '', '', $query_args, true);
3403
+	}
3404
+
3405
+
3406
+	/**
3407
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3408
+	 *
3409
+	 * @param int     $post_id
3410
+	 * @param WP_POST $post
3411
+	 * @throws DomainException
3412
+	 * @throws EE_Error
3413
+	 * @throws InvalidArgumentException
3414
+	 * @throws InvalidDataTypeException
3415
+	 * @throws InvalidInterfaceException
3416
+	 * @throws LogicException
3417
+	 * @throws InvalidFormSubmissionException
3418
+	 * @throws ReflectionException
3419
+	 */
3420
+	protected function _insert_update_cpt_item($post_id, $post)
3421
+	{
3422
+		$success = true;
3423
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3424
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3425
+			: null;
3426
+		// for attendee updates
3427
+		if ($attendee instanceof EE_Attendee) {
3428
+			// note we should only be UPDATING attendees at this point.
3429
+			$updated_fields = array(
3430
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
3431
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
3432
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3433
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3434
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3435
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3436
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3437
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3438
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3439
+			);
3440
+			foreach ($updated_fields as $field => $value) {
3441
+				$attendee->set($field, $value);
3442
+			}
3443
+
3444
+			// process contact details metabox form handler (which will also save the attendee)
3445
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3446
+			$success = $contact_details_form->process($this->_req_data);
3447
+
3448
+			$attendee_update_callbacks = apply_filters(
3449
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3450
+				array()
3451
+			);
3452
+			foreach ($attendee_update_callbacks as $a_callback) {
3453
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3454
+					throw new EE_Error(
3455
+						sprintf(
3456
+							esc_html__(
3457
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3458
+								'event_espresso'
3459
+							),
3460
+							$a_callback
3461
+						)
3462
+					);
3463
+				}
3464
+			}
3465
+		}
3466
+
3467
+		if ($success === false) {
3468
+			EE_Error::add_error(
3469
+				esc_html__(
3470
+					'Something went wrong with updating the meta table data for the registration.',
3471
+					'event_espresso'
3472
+				),
3473
+				__FILE__,
3474
+				__FUNCTION__,
3475
+				__LINE__
3476
+			);
3477
+		}
3478
+	}
3479
+
3480
+
3481
+	public function trash_cpt_item($post_id)
3482
+	{
3483
+	}
3484
+
3485
+
3486
+	public function delete_cpt_item($post_id)
3487
+	{
3488
+	}
3489
+
3490
+
3491
+	public function restore_cpt_item($post_id)
3492
+	{
3493
+	}
3494
+
3495
+
3496
+	protected function _restore_cpt_item($post_id, $revision_id)
3497
+	{
3498
+	}
3499
+
3500
+
3501
+	/**
3502
+	 * @throws EE_Error
3503
+	 * @since 4.10.2.p
3504
+	 */
3505
+	public function attendee_editor_metaboxes()
3506
+	{
3507
+		$this->verify_cpt_object();
3508
+		remove_meta_box(
3509
+			'postexcerpt',
3510
+			$this->_cpt_routes[ $this->_req_action ],
3511
+			'normal'
3512
+		);
3513
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3514
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3515
+			add_meta_box(
3516
+				'postexcerpt',
3517
+				esc_html__('Short Biography', 'event_espresso'),
3518
+				'post_excerpt_meta_box',
3519
+				$this->_cpt_routes[ $this->_req_action ],
3520
+				'normal'
3521
+			);
3522
+		}
3523
+		if (post_type_supports('espresso_attendees', 'comments')) {
3524
+			add_meta_box(
3525
+				'commentsdiv',
3526
+				esc_html__('Notes on the Contact', 'event_espresso'),
3527
+				'post_comment_meta_box',
3528
+				$this->_cpt_routes[ $this->_req_action ],
3529
+				'normal',
3530
+				'core'
3531
+			);
3532
+		}
3533
+		add_meta_box(
3534
+			'attendee_contact_info',
3535
+			esc_html__('Contact Info', 'event_espresso'),
3536
+			array($this, 'attendee_contact_info'),
3537
+			$this->_cpt_routes[ $this->_req_action ],
3538
+			'side',
3539
+			'core'
3540
+		);
3541
+		add_meta_box(
3542
+			'attendee_details_address',
3543
+			esc_html__('Address Details', 'event_espresso'),
3544
+			array($this, 'attendee_address_details'),
3545
+			$this->_cpt_routes[ $this->_req_action ],
3546
+			'normal',
3547
+			'core'
3548
+		);
3549
+		add_meta_box(
3550
+			'attendee_registrations',
3551
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3552
+			array($this, 'attendee_registrations_meta_box'),
3553
+			$this->_cpt_routes[ $this->_req_action ],
3554
+			'normal',
3555
+			'high'
3556
+		);
3557
+	}
3558
+
3559
+
3560
+	/**
3561
+	 * Metabox for attendee contact info
3562
+	 *
3563
+	 * @param  WP_Post $post wp post object
3564
+	 * @return string attendee contact info ( and form )
3565
+	 * @throws EE_Error
3566
+	 * @throws InvalidArgumentException
3567
+	 * @throws InvalidDataTypeException
3568
+	 * @throws InvalidInterfaceException
3569
+	 * @throws LogicException
3570
+	 * @throws DomainException
3571
+	 */
3572
+	public function attendee_contact_info($post)
3573
+	{
3574
+		// get attendee object ( should already have it )
3575
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3576
+		$form->enqueueStylesAndScripts();
3577
+		echo $form->display();
3578
+	}
3579
+
3580
+
3581
+	/**
3582
+	 * Return form handler for the contact details metabox
3583
+	 *
3584
+	 * @param EE_Attendee $attendee
3585
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3586
+	 * @throws DomainException
3587
+	 * @throws InvalidArgumentException
3588
+	 * @throws InvalidDataTypeException
3589
+	 * @throws InvalidInterfaceException
3590
+	 */
3591
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3592
+	{
3593
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3594
+	}
3595
+
3596
+
3597
+	/**
3598
+	 * Metabox for attendee details
3599
+	 *
3600
+	 * @param  WP_Post $post wp post object
3601
+	 * @throws DomainException
3602
+	 */
3603
+	public function attendee_address_details($post)
3604
+	{
3605
+		// get attendee object (should already have it)
3606
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3607
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3608
+			new EE_Question_Form_Input(
3609
+				EE_Question::new_instance(
3610
+					array(
3611
+						'QST_ID'           => 0,
3612
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3613
+						'QST_system'       => 'admin-state',
3614
+					)
3615
+				),
3616
+				EE_Answer::new_instance(
3617
+					array(
3618
+						'ANS_ID'    => 0,
3619
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3620
+					)
3621
+				),
3622
+				array(
3623
+					'input_id'       => 'STA_ID',
3624
+					'input_name'     => 'STA_ID',
3625
+					'input_prefix'   => '',
3626
+					'append_qstn_id' => false,
3627
+				)
3628
+			)
3629
+		);
3630
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3631
+			new EE_Question_Form_Input(
3632
+				EE_Question::new_instance(
3633
+					array(
3634
+						'QST_ID'           => 0,
3635
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3636
+						'QST_system'       => 'admin-country',
3637
+					)
3638
+				),
3639
+				EE_Answer::new_instance(
3640
+					array(
3641
+						'ANS_ID'    => 0,
3642
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3643
+					)
3644
+				),
3645
+				array(
3646
+					'input_id'       => 'CNT_ISO',
3647
+					'input_name'     => 'CNT_ISO',
3648
+					'input_prefix'   => '',
3649
+					'append_qstn_id' => false,
3650
+				)
3651
+			)
3652
+		);
3653
+		$template =
3654
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3655
+		EEH_Template::display_template($template, $this->_template_args);
3656
+	}
3657
+
3658
+
3659
+	/**
3660
+	 *        _attendee_details
3661
+	 *
3662
+	 * @access protected
3663
+	 * @param $post
3664
+	 * @return void
3665
+	 * @throws DomainException
3666
+	 * @throws EE_Error
3667
+	 * @throws InvalidArgumentException
3668
+	 * @throws InvalidDataTypeException
3669
+	 * @throws InvalidInterfaceException
3670
+	 * @throws ReflectionException
3671
+	 */
3672
+	public function attendee_registrations_meta_box($post)
3673
+	{
3674
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3675
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3676
+		$template =
3677
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3678
+		EEH_Template::display_template($template, $this->_template_args);
3679
+	}
3680
+
3681
+
3682
+	/**
3683
+	 * add in the form fields for the attendee edit
3684
+	 *
3685
+	 * @param  WP_Post $post wp post object
3686
+	 * @return string html for new form.
3687
+	 * @throws DomainException
3688
+	 */
3689
+	public function after_title_form_fields($post)
3690
+	{
3691
+		if ($post->post_type === 'espresso_attendees') {
3692
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3693
+			$template_args['attendee'] = $this->_cpt_model_obj;
3694
+			EEH_Template::display_template($template, $template_args);
3695
+		}
3696
+	}
3697
+
3698
+
3699
+	/**
3700
+	 *        _trash_or_restore_attendee
3701
+	 *
3702
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3703
+	 * @return void
3704
+	 * @throws EE_Error
3705
+	 * @throws InvalidArgumentException
3706
+	 * @throws InvalidDataTypeException
3707
+	 * @throws InvalidInterfaceException
3708
+	 * @throws ReflectionException
3709
+	 * @access protected
3710
+	 */
3711
+	protected function _trash_or_restore_attendees($trash = true)
3712
+	{
3713
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3714
+		$success = 1;
3715
+		// Checkboxes
3716
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3717
+			// if array has more than one element than success message should be plural
3718
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3719
+			// cycle thru checkboxes
3720
+			foreach ($this->_req_data['checkbox'] as $ATT_ID) {
3721
+				$updated = $trash ? $this->getAttendeeModel()->update_by_ID(array('status' => 'trash'), $ATT_ID)
3722
+					: $this->getAttendeeModel()->update_by_ID(array('status' => 'publish'), $ATT_ID);
3723
+				if (! $updated) {
3724
+					$success = 0;
3725
+				}
3726
+			}
3727
+		} else {
3728
+			// grab single id and delete
3729
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
3730
+			// get attendee
3731
+			$att = $this->getAttendeeModel()->get_one_by_ID($ATT_ID);
3732
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3733
+			$updated = $att->save() && $updated;
3734
+			if (! $updated) {
3735
+				$success = 0;
3736
+			}
3737
+		}
3738
+		$what = $success > 1
3739
+			? esc_html__('Contacts', 'event_espresso')
3740
+			: esc_html__('Contact', 'event_espresso');
3741
+		$action_desc = $trash
3742
+			? esc_html__('moved to the trash', 'event_espresso')
3743
+			: esc_html__('restored', 'event_espresso');
3744
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3745
+	}
3746 3746
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 1 patch
Indentation   +774 added lines, -774 removed lines patch added patch discarded remove patch
@@ -26,785 +26,785 @@
 block discarded – undo
26 26
 class Registry
27 27
 {
28 28
 
29
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
30
-
31
-    /**
32
-     * @var AssetCollection $assets
33
-     */
34
-    protected $assets;
35
-
36
-    /**
37
-     * @var I18nRegistry
38
-     */
39
-    private $i18n_registry;
40
-
41
-    /**
42
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $jsdata = array();
47
-
48
-    /**
49
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
50
-     * page source.
51
-     *
52
-     * @var array
53
-     */
54
-    private $script_handles_with_data = array();
55
-
56
-
57
-    /**
58
-     * Holds the manifest data obtained from registered manifest files.
59
-     * Manifests are maps of asset chunk name to actual built asset file names.
60
-     * Shape of this array is:
61
-     * array(
62
-     *  'some_namespace_slug' => array(
63
-     *      'some_chunk_name' => array(
64
-     *          'js' => 'filename.js'
65
-     *          'css' => 'filename.js'
66
-     *      ),
67
-     *      'url_base' => 'https://baseurl.com/to/assets
68
-     *  )
69
-     * )
70
-     *
71
-     * @var array
72
-     */
73
-    private $manifest_data = array();
74
-
75
-
76
-    /**
77
-     * Holds any dependency data obtained from registered dependency map json.
78
-     * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
79
-     * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
80
-     *
81
-     * @var array
82
-     */
83
-    private $dependencies_data = [];
84
-
85
-
86
-    /**
87
-     * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
88
-     * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
89
-     * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
90
-     * are used for both js and css.
91
-     * @var array
92
-     */
93
-    private $wp_css_handle_dependencies = [
94
-        'wp-components',
95
-        'wp-block-editor',
96
-        'wp-block-library',
97
-        'wp-edit-post',
98
-        'wp-edit-widgets',
99
-        'wp-editor',
100
-        'wp-format-library',
101
-        'wp-list-reusable-blocks',
102
-        'wp-nux',
103
-    ];
104
-
105
-
106
-    /**
107
-     * Registry constructor.
108
-     * Hooking into WP actions for script registry.
109
-     *
110
-     * @param AssetCollection      $assets
111
-     * @param I18nRegistry         $i18n_registry
112
-     * @throws InvalidArgumentException
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     */
116
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
117
-    {
118
-        $this->assets = $assets;
119
-        $this->i18n_registry = $i18n_registry;
120
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
121
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
123
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
124
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
125
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
126
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
127
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
128
-    }
129
-
130
-
131
-    /**
132
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
133
-     * translation handling.
134
-     *
135
-     * @return I18nRegistry
136
-     */
137
-    public function getI18nRegistry()
138
-    {
139
-        return $this->i18n_registry;
140
-    }
141
-
142
-
143
-    /**
144
-     * Callback for the wp_enqueue_scripts actions used to register assets.
145
-     *
146
-     * @since 4.9.62.p
147
-     * @throws Exception
148
-     */
149
-    public function registerScriptsAndStyles()
150
-    {
151
-        try {
152
-            $this->registerScripts($this->assets->getJavascriptAssets());
153
-            $this->registerStyles($this->assets->getStylesheetAssets());
154
-        } catch (Exception $exception) {
155
-            new ExceptionStackTraceDisplay($exception);
156
-        }
157
-    }
158
-
159
-
160
-    /**
161
-     * Registers JS assets with WP core
162
-     *
163
-     * @param JavascriptAsset[] $scripts
164
-     * @throws AssetRegistrationException
165
-     * @throws InvalidDataTypeException
166
-     * @throws DomainException
167
-     * @since 4.9.62.p
168
-     */
169
-    public function registerScripts(array $scripts)
170
-    {
171
-        foreach ($scripts as $script) {
172
-            // skip to next script if this has already been done
173
-            if ($script->isRegistered()) {
174
-                continue;
175
-            }
176
-            do_action(
177
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
-                $script
179
-            );
180
-            $registered = wp_register_script(
181
-                $script->handle(),
182
-                $script->source(),
183
-                $script->dependencies(),
184
-                $script->version(),
185
-                $script->loadInFooter()
186
-            );
187
-            if (! $registered && $this->debug()) {
188
-                throw new AssetRegistrationException($script->handle());
189
-            }
190
-            $script->setRegistered($registered);
191
-            if ($script->requiresTranslation()) {
192
-                $this->registerTranslation($script->handle());
193
-            }
194
-            do_action(
195
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
-                $script
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * Registers CSS assets with WP core
204
-     *
205
-     * @param StylesheetAsset[] $styles
206
-     * @throws InvalidDataTypeException
207
-     * @throws DomainException
208
-     * @since 4.9.62.p
209
-     */
210
-    public function registerStyles(array $styles)
211
-    {
212
-        foreach ($styles as $style) {
213
-            // skip to next style if this has already been done
214
-            if ($style->isRegistered()) {
215
-                continue;
216
-            }
217
-            do_action(
218
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
219
-                $style
220
-            );
221
-            wp_register_style(
222
-                $style->handle(),
223
-                $style->source(),
224
-                $style->dependencies(),
225
-                $style->version(),
226
-                $style->media()
227
-            );
228
-            $style->setRegistered();
229
-            do_action(
230
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
231
-                $style
232
-            );
233
-        }
234
-    }
235
-
236
-
237
-    /**
238
-     * Call back for the script print in frontend and backend.
239
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
240
-     *
241
-     * @since 4.9.31.rc.015
242
-     */
243
-    public function enqueueData()
244
-    {
245
-        $this->removeAlreadyRegisteredDataForScriptHandles();
246
-        wp_add_inline_script(
247
-            'eejs-core',
248
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
249
-            'before'
250
-        );
251
-        $scripts = $this->assets->getJavascriptAssetsWithData();
252
-        foreach ($scripts as $script) {
253
-            $this->addRegisteredScriptHandlesWithData($script->handle());
254
-            if ($script->hasInlineDataCallback()) {
255
-                $localize = $script->inlineDataCallback();
256
-                $localize();
257
-            }
258
-        }
259
-    }
260
-
261
-
262
-    /**
263
-     * Used to add data to eejs.data object.
264
-     * Note:  Overriding existing data is not allowed.
265
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
266
-     * If the data you add is something like this:
267
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
268
-     * It will be exposed in the page source as:
269
-     *  eejs.data.my_plugin_data.foo == gar
270
-     *
271
-     * @param string       $key   Key used to access your data
272
-     * @param string|array $value Value to attach to key
273
-     * @throws InvalidArgumentException
274
-     */
275
-    public function addData($key, $value)
276
-    {
277
-        if ($this->verifyDataNotExisting($key)) {
278
-            $this->jsdata[ $key ] = $value;
279
-        }
280
-    }
281
-
282
-
283
-    /**
284
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
285
-     * elements in an array.
286
-     *
287
-     * When you use this method, the value you include will be merged with the array on $key.
288
-     * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
289
-     * object like this, eejs.data.test = [ my_data,
290
-     * ]
291
-     * If there has already been a scalar value attached to the data object given key (via addData for instance), then
292
-     * this will throw an exception.
293
-     *
294
-     * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
295
-     * key potentially overriding the existing data on merge (specifically with associative arrays).
296
-     *
297
-     * @param string       $key   Key to attach data to.
298
-     * @param string|array $value Value being registered.
299
-     * @throws InvalidArgumentException
300
-     */
301
-    public function pushData($key, $value)
302
-    {
303
-        if (isset($this->jsdata[ $key ])
304
-            && ! is_array($this->jsdata[ $key ])
305
-        ) {
306
-            if (! $this->debug()) {
307
-                return;
308
-            }
309
-            throw new InvalidArgumentException(
310
-                sprintf(
311
-                    __(
312
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
29
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
30
+
31
+	/**
32
+	 * @var AssetCollection $assets
33
+	 */
34
+	protected $assets;
35
+
36
+	/**
37
+	 * @var I18nRegistry
38
+	 */
39
+	private $i18n_registry;
40
+
41
+	/**
42
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $jsdata = array();
47
+
48
+	/**
49
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
50
+	 * page source.
51
+	 *
52
+	 * @var array
53
+	 */
54
+	private $script_handles_with_data = array();
55
+
56
+
57
+	/**
58
+	 * Holds the manifest data obtained from registered manifest files.
59
+	 * Manifests are maps of asset chunk name to actual built asset file names.
60
+	 * Shape of this array is:
61
+	 * array(
62
+	 *  'some_namespace_slug' => array(
63
+	 *      'some_chunk_name' => array(
64
+	 *          'js' => 'filename.js'
65
+	 *          'css' => 'filename.js'
66
+	 *      ),
67
+	 *      'url_base' => 'https://baseurl.com/to/assets
68
+	 *  )
69
+	 * )
70
+	 *
71
+	 * @var array
72
+	 */
73
+	private $manifest_data = array();
74
+
75
+
76
+	/**
77
+	 * Holds any dependency data obtained from registered dependency map json.
78
+	 * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
79
+	 * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
80
+	 *
81
+	 * @var array
82
+	 */
83
+	private $dependencies_data = [];
84
+
85
+
86
+	/**
87
+	 * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
88
+	 * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
89
+	 * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
90
+	 * are used for both js and css.
91
+	 * @var array
92
+	 */
93
+	private $wp_css_handle_dependencies = [
94
+		'wp-components',
95
+		'wp-block-editor',
96
+		'wp-block-library',
97
+		'wp-edit-post',
98
+		'wp-edit-widgets',
99
+		'wp-editor',
100
+		'wp-format-library',
101
+		'wp-list-reusable-blocks',
102
+		'wp-nux',
103
+	];
104
+
105
+
106
+	/**
107
+	 * Registry constructor.
108
+	 * Hooking into WP actions for script registry.
109
+	 *
110
+	 * @param AssetCollection      $assets
111
+	 * @param I18nRegistry         $i18n_registry
112
+	 * @throws InvalidArgumentException
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 */
116
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
117
+	{
118
+		$this->assets = $assets;
119
+		$this->i18n_registry = $i18n_registry;
120
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
121
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
123
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
124
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
125
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
126
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
127
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
128
+	}
129
+
130
+
131
+	/**
132
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
133
+	 * translation handling.
134
+	 *
135
+	 * @return I18nRegistry
136
+	 */
137
+	public function getI18nRegistry()
138
+	{
139
+		return $this->i18n_registry;
140
+	}
141
+
142
+
143
+	/**
144
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
145
+	 *
146
+	 * @since 4.9.62.p
147
+	 * @throws Exception
148
+	 */
149
+	public function registerScriptsAndStyles()
150
+	{
151
+		try {
152
+			$this->registerScripts($this->assets->getJavascriptAssets());
153
+			$this->registerStyles($this->assets->getStylesheetAssets());
154
+		} catch (Exception $exception) {
155
+			new ExceptionStackTraceDisplay($exception);
156
+		}
157
+	}
158
+
159
+
160
+	/**
161
+	 * Registers JS assets with WP core
162
+	 *
163
+	 * @param JavascriptAsset[] $scripts
164
+	 * @throws AssetRegistrationException
165
+	 * @throws InvalidDataTypeException
166
+	 * @throws DomainException
167
+	 * @since 4.9.62.p
168
+	 */
169
+	public function registerScripts(array $scripts)
170
+	{
171
+		foreach ($scripts as $script) {
172
+			// skip to next script if this has already been done
173
+			if ($script->isRegistered()) {
174
+				continue;
175
+			}
176
+			do_action(
177
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
+				$script
179
+			);
180
+			$registered = wp_register_script(
181
+				$script->handle(),
182
+				$script->source(),
183
+				$script->dependencies(),
184
+				$script->version(),
185
+				$script->loadInFooter()
186
+			);
187
+			if (! $registered && $this->debug()) {
188
+				throw new AssetRegistrationException($script->handle());
189
+			}
190
+			$script->setRegistered($registered);
191
+			if ($script->requiresTranslation()) {
192
+				$this->registerTranslation($script->handle());
193
+			}
194
+			do_action(
195
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
+				$script
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * Registers CSS assets with WP core
204
+	 *
205
+	 * @param StylesheetAsset[] $styles
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws DomainException
208
+	 * @since 4.9.62.p
209
+	 */
210
+	public function registerStyles(array $styles)
211
+	{
212
+		foreach ($styles as $style) {
213
+			// skip to next style if this has already been done
214
+			if ($style->isRegistered()) {
215
+				continue;
216
+			}
217
+			do_action(
218
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
219
+				$style
220
+			);
221
+			wp_register_style(
222
+				$style->handle(),
223
+				$style->source(),
224
+				$style->dependencies(),
225
+				$style->version(),
226
+				$style->media()
227
+			);
228
+			$style->setRegistered();
229
+			do_action(
230
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
231
+				$style
232
+			);
233
+		}
234
+	}
235
+
236
+
237
+	/**
238
+	 * Call back for the script print in frontend and backend.
239
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
240
+	 *
241
+	 * @since 4.9.31.rc.015
242
+	 */
243
+	public function enqueueData()
244
+	{
245
+		$this->removeAlreadyRegisteredDataForScriptHandles();
246
+		wp_add_inline_script(
247
+			'eejs-core',
248
+			'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
249
+			'before'
250
+		);
251
+		$scripts = $this->assets->getJavascriptAssetsWithData();
252
+		foreach ($scripts as $script) {
253
+			$this->addRegisteredScriptHandlesWithData($script->handle());
254
+			if ($script->hasInlineDataCallback()) {
255
+				$localize = $script->inlineDataCallback();
256
+				$localize();
257
+			}
258
+		}
259
+	}
260
+
261
+
262
+	/**
263
+	 * Used to add data to eejs.data object.
264
+	 * Note:  Overriding existing data is not allowed.
265
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
266
+	 * If the data you add is something like this:
267
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
268
+	 * It will be exposed in the page source as:
269
+	 *  eejs.data.my_plugin_data.foo == gar
270
+	 *
271
+	 * @param string       $key   Key used to access your data
272
+	 * @param string|array $value Value to attach to key
273
+	 * @throws InvalidArgumentException
274
+	 */
275
+	public function addData($key, $value)
276
+	{
277
+		if ($this->verifyDataNotExisting($key)) {
278
+			$this->jsdata[ $key ] = $value;
279
+		}
280
+	}
281
+
282
+
283
+	/**
284
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
285
+	 * elements in an array.
286
+	 *
287
+	 * When you use this method, the value you include will be merged with the array on $key.
288
+	 * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
289
+	 * object like this, eejs.data.test = [ my_data,
290
+	 * ]
291
+	 * If there has already been a scalar value attached to the data object given key (via addData for instance), then
292
+	 * this will throw an exception.
293
+	 *
294
+	 * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
295
+	 * key potentially overriding the existing data on merge (specifically with associative arrays).
296
+	 *
297
+	 * @param string       $key   Key to attach data to.
298
+	 * @param string|array $value Value being registered.
299
+	 * @throws InvalidArgumentException
300
+	 */
301
+	public function pushData($key, $value)
302
+	{
303
+		if (isset($this->jsdata[ $key ])
304
+			&& ! is_array($this->jsdata[ $key ])
305
+		) {
306
+			if (! $this->debug()) {
307
+				return;
308
+			}
309
+			throw new InvalidArgumentException(
310
+				sprintf(
311
+					__(
312
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
313 313
                          push values to this data element when it is an array.',
314
-                        'event_espresso'
315
-                    ),
316
-                    $key,
317
-                    __METHOD__
318
-                )
319
-            );
320
-        }
321
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
322
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
323
-        } else {
324
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
325
-        }
326
-    }
327
-
328
-
329
-    /**
330
-     * Used to set content used by javascript for a template.
331
-     * Note: Overrides of existing registered templates are not allowed.
332
-     *
333
-     * @param string $template_reference
334
-     * @param string $template_content
335
-     * @throws InvalidArgumentException
336
-     */
337
-    public function addTemplate($template_reference, $template_content)
338
-    {
339
-        if (! isset($this->jsdata['templates'])) {
340
-            $this->jsdata['templates'] = array();
341
-        }
342
-        //no overrides allowed.
343
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
344
-            if (! $this->debug()) {
345
-                return;
346
-            }
347
-            throw new InvalidArgumentException(
348
-                sprintf(
349
-                    __(
350
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
351
-                        'event_espresso'
352
-                    ),
353
-                    $template_reference
354
-                )
355
-            );
356
-        }
357
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
358
-    }
359
-
360
-
361
-    /**
362
-     * Retrieve the template content already registered for the given reference.
363
-     *
364
-     * @param string $template_reference
365
-     * @return string
366
-     */
367
-    public function getTemplate($template_reference)
368
-    {
369
-        return isset($this->jsdata['templates'][ $template_reference ])
370
-            ? $this->jsdata['templates'][ $template_reference ]
371
-            : '';
372
-    }
373
-
374
-
375
-    /**
376
-     * Retrieve registered data.
377
-     *
378
-     * @param string $key Name of key to attach data to.
379
-     * @return mixed                If there is no for the given key, then false is returned.
380
-     */
381
-    public function getData($key)
382
-    {
383
-        return isset($this->jsdata[ $key ])
384
-            ? $this->jsdata[ $key ]
385
-            : false;
386
-    }
387
-
388
-
389
-    /**
390
-     * Verifies whether the given data exists already on the jsdata array.
391
-     * Overriding data is not allowed.
392
-     *
393
-     * @param string $key Index for data.
394
-     * @return bool        If valid then return true.
395
-     * @throws InvalidArgumentException if data already exists.
396
-     */
397
-    protected function verifyDataNotExisting($key)
398
-    {
399
-        if (isset($this->jsdata[ $key ])) {
400
-            if (! $this->debug()) {
401
-                return false;
402
-            }
403
-            if (is_array($this->jsdata[ $key ])) {
404
-                throw new InvalidArgumentException(
405
-                    sprintf(
406
-                        __(
407
-                            'The value for %1$s already exists in the Registry::eejs object.
314
+						'event_espresso'
315
+					),
316
+					$key,
317
+					__METHOD__
318
+				)
319
+			);
320
+		}
321
+		if ( ! isset( $this->jsdata[ $key ] ) ) {
322
+			$this->jsdata[ $key ] = is_array($value) ? $value : [$value];
323
+		} else {
324
+			$this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
325
+		}
326
+	}
327
+
328
+
329
+	/**
330
+	 * Used to set content used by javascript for a template.
331
+	 * Note: Overrides of existing registered templates are not allowed.
332
+	 *
333
+	 * @param string $template_reference
334
+	 * @param string $template_content
335
+	 * @throws InvalidArgumentException
336
+	 */
337
+	public function addTemplate($template_reference, $template_content)
338
+	{
339
+		if (! isset($this->jsdata['templates'])) {
340
+			$this->jsdata['templates'] = array();
341
+		}
342
+		//no overrides allowed.
343
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
344
+			if (! $this->debug()) {
345
+				return;
346
+			}
347
+			throw new InvalidArgumentException(
348
+				sprintf(
349
+					__(
350
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
351
+						'event_espresso'
352
+					),
353
+					$template_reference
354
+				)
355
+			);
356
+		}
357
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
358
+	}
359
+
360
+
361
+	/**
362
+	 * Retrieve the template content already registered for the given reference.
363
+	 *
364
+	 * @param string $template_reference
365
+	 * @return string
366
+	 */
367
+	public function getTemplate($template_reference)
368
+	{
369
+		return isset($this->jsdata['templates'][ $template_reference ])
370
+			? $this->jsdata['templates'][ $template_reference ]
371
+			: '';
372
+	}
373
+
374
+
375
+	/**
376
+	 * Retrieve registered data.
377
+	 *
378
+	 * @param string $key Name of key to attach data to.
379
+	 * @return mixed                If there is no for the given key, then false is returned.
380
+	 */
381
+	public function getData($key)
382
+	{
383
+		return isset($this->jsdata[ $key ])
384
+			? $this->jsdata[ $key ]
385
+			: false;
386
+	}
387
+
388
+
389
+	/**
390
+	 * Verifies whether the given data exists already on the jsdata array.
391
+	 * Overriding data is not allowed.
392
+	 *
393
+	 * @param string $key Index for data.
394
+	 * @return bool        If valid then return true.
395
+	 * @throws InvalidArgumentException if data already exists.
396
+	 */
397
+	protected function verifyDataNotExisting($key)
398
+	{
399
+		if (isset($this->jsdata[ $key ])) {
400
+			if (! $this->debug()) {
401
+				return false;
402
+			}
403
+			if (is_array($this->jsdata[ $key ])) {
404
+				throw new InvalidArgumentException(
405
+					sprintf(
406
+						__(
407
+							'The value for %1$s already exists in the Registry::eejs object.
408 408
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
409 409
                             %2$s method to push your value to the array.',
410
-                            'event_espresso'
411
-                        ),
412
-                        $key,
413
-                        'pushData()'
414
-                    )
415
-                );
416
-            }
417
-            throw new InvalidArgumentException(
418
-                sprintf(
419
-                    __(
420
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
410
+							'event_espresso'
411
+						),
412
+						$key,
413
+						'pushData()'
414
+					)
415
+				);
416
+			}
417
+			throw new InvalidArgumentException(
418
+				sprintf(
419
+					__(
420
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
421 421
                         allowed.  Consider attaching your value to a different key',
422
-                        'event_espresso'
423
-                    ),
424
-                    $key
425
-                )
426
-            );
427
-        }
428
-        return true;
429
-    }
430
-
431
-
432
-    /**
433
-     * Get the actual asset path for asset manifests.
434
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
435
-     *
436
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
437
-     *                           asset file location.
438
-     * @param string $chunk_name
439
-     * @param string $asset_type
440
-     * @return string
441
-     * @since 4.9.59.p
442
-     */
443
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
444
-    {
445
-        $url = isset(
446
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
447
-            $this->manifest_data[ $namespace ]['url_base']
448
-        )
449
-            ? $this->manifest_data[ $namespace ]['url_base']
450
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
451
-            : $chunk_name;
452
-
453
-        return apply_filters(
454
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
455
-            $url,
456
-            $namespace,
457
-            $chunk_name,
458
-            $asset_type
459
-        );
460
-    }
461
-
462
-
463
-
464
-    /**
465
-     * Return the url to a js file for the given namespace and chunk name.
466
-     *
467
-     * @param string $namespace
468
-     * @param string $chunk_name
469
-     * @return string
470
-     */
471
-    public function getJsUrl($namespace, $chunk_name)
472
-    {
473
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
474
-    }
475
-
476
-
477
-    /**
478
-     * Return the url to a css file for the given namespace and chunk name.
479
-     *
480
-     * @param string $namespace
481
-     * @param string $chunk_name
482
-     * @return string
483
-     */
484
-    public function getCssUrl($namespace, $chunk_name)
485
-    {
486
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
487
-    }
488
-
489
-
490
-    /**
491
-     * Return the dependencies array and version string for a given asset $chunk_name
492
-     *
493
-     * @param string $namespace
494
-     * @param string $chunk_name
495
-     * @param string $asset_type
496
-     * @return array
497
-     * @since 4.9.82.p
498
-     */
499
-    private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
500
-    {
501
-        $asset_index = $chunk_name . '.' . $asset_type;
502
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
503
-            $path = isset($this->manifest_data[ $namespace ]['path'])
504
-                ? $this->manifest_data[ $namespace ]['path']
505
-                : '';
506
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
507
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
508
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
509
-                :
510
-                '';
511
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
512
-                ? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
513
-                : [];
514
-        }
515
-        $details = $this->dependencies_data[ $namespace ][ $asset_index ];
516
-        return $details;
517
-    }
518
-
519
-
520
-    /**
521
-     * Return dependencies array and version string according to asset type.
522
-     * For css assets, this filters the auto generated dependencies by css type.
523
-     *
524
-     * @param string $namespace
525
-     * @param string $asset_type
526
-     * @param string $file_path
527
-     * @param string $chunk_name
528
-     * @return array
529
-     * @since 4.9.82.p
530
-     */
531
-    private function getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
532
-    {
533
-        // $asset_dependencies = json_decode(file_get_contents($file_path), true);
534
-        $asset_details = require($file_path);
535
-        $asset_details['dependencies'] = isset($asset_details['dependencies'])
536
-            ? $asset_details['dependencies']
537
-            : [];
538
-        $asset_details['version'] = isset($asset_details['version'])
539
-            ? $asset_details['version']
540
-            : '';
541
-        if ($asset_type === Asset::TYPE_JS) {
542
-            $asset_details['dependencies'] =  $chunk_name === 'eejs-core'
543
-                ? $asset_details['dependencies']
544
-                : $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
545
-            return $asset_details;
546
-        }
547
-        // for css we need to make sure there is actually a css file related to this chunk.
548
-        if (isset($this->manifest_data[ $namespace ])) {
549
-            // array of css chunk files for ee.
550
-            $css_chunks = array_map(
551
-                static function ($value) {
552
-                    return str_replace('.css', '', $value);
553
-                },
554
-                array_filter(
555
-                    array_keys($this->manifest_data[ $namespace ]),
556
-                    static function ($value) {
557
-                        return strpos($value, '.css') !== false;
558
-                    }
559
-                )
560
-            );
561
-            // add known wp chunks with css
562
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
563
-            // flip for easier search
564
-            $css_chunks = array_flip($css_chunks);
565
-
566
-            // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
567
-            $asset_details['dependencies'] = array_filter(
568
-                $asset_details['dependencies'],
569
-                static function ($chunk_name) use ($css_chunks) {
570
-                    return isset($css_chunks[ $chunk_name ]);
571
-                }
572
-            );
573
-            return $asset_details;
574
-        }
575
-        return ['dependencies' => [], 'version' => ''];
576
-    }
577
-
578
-
579
-    /**
580
-     * Get the dependencies array and version string for the given js asset chunk name
581
-     *
582
-     * @param string $namespace
583
-     * @param string $chunk_name
584
-     * @return array
585
-     * @since 4.10.2.p
586
-     */
587
-    public function getJsAssetDetails($namespace, $chunk_name)
588
-    {
589
-        return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_JS);
590
-    }
591
-
592
-
593
-    /**
594
-     * Get the dependencies array and version string for the given css asset chunk name
595
-     *
596
-     * @param string $namespace
597
-     * @param string $chunk_name
598
-     * @return array
599
-     * @since 4.10.2.p
600
-     */
601
-    public function getCssAssetDetails($namespace, $chunk_name)
602
-    {
603
-        return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
604
-    }
605
-
606
-
607
-    /**
608
-     * @since 4.9.62.p
609
-     * @throws InvalidArgumentException
610
-     * @throws InvalidFilePathException
611
-     */
612
-    public function registerManifestFiles()
613
-    {
614
-        $manifest_files = $this->assets->getManifestFiles();
615
-        foreach ($manifest_files as $manifest_file) {
616
-            $this->registerManifestFile(
617
-                $manifest_file->assetNamespace(),
618
-                $manifest_file->urlBase(),
619
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
620
-                $manifest_file->filepath()
621
-            );
622
-        }
623
-    }
624
-
625
-
626
-    /**
627
-     * Used to register a js/css manifest file with the registered_manifest_files property.
628
-     *
629
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
630
-     * @param string $url_base      The url base for the manifest file location.
631
-     * @param string $manifest_file The absolute path to the manifest file.
632
-     * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
633
-     *                                    default to `plugin_root/assets/dist`.
634
-     * @throws InvalidArgumentException
635
-     * @throws InvalidFilePathException
636
-     * @since 4.9.59.p
637
-     */
638
-    public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
639
-    {
640
-        if (isset($this->manifest_data[ $namespace ])) {
641
-            if (! $this->debug()) {
642
-                return;
643
-            }
644
-            throw new InvalidArgumentException(
645
-                sprintf(
646
-                    esc_html__(
647
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
648
-                        'event_espresso'
649
-                    ),
650
-                    $namespace
651
-                )
652
-            );
653
-        }
654
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
655
-            if (is_admin()) {
656
-                EE_Error::add_error(
657
-                    sprintf(
658
-                        esc_html__(
659
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
660
-                            'event_espresso'
661
-                        ),
662
-                        'Event Espresso',
663
-                        $url_base,
664
-                        'plugins_url',
665
-                        'WP_PLUGIN_URL'
666
-                    ),
667
-                    __FILE__,
668
-                    __FUNCTION__,
669
-                    __LINE__
670
-                );
671
-            }
672
-            return;
673
-        }
674
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
675
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
676
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
677
-        }
678
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
679
-            $this->manifest_data[ $namespace ]['path'] = $manifest_file_path;
680
-        }
681
-    }
682
-
683
-
684
-    /**
685
-     * Decodes json from the provided manifest file.
686
-     *
687
-     * @since 4.9.59.p
688
-     * @param string $manifest_file Path to manifest file.
689
-     * @return array
690
-     * @throws InvalidFilePathException
691
-     */
692
-    private function decodeManifestFile($manifest_file)
693
-    {
694
-        if (! file_exists($manifest_file)) {
695
-            throw new InvalidFilePathException($manifest_file);
696
-        }
697
-        return json_decode(file_get_contents($manifest_file), true);
698
-    }
699
-
700
-
701
-    /**
702
-     * This is used to set registered script handles that have data.
703
-     *
704
-     * @param string $script_handle
705
-     */
706
-    private function addRegisteredScriptHandlesWithData($script_handle)
707
-    {
708
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
709
-    }
710
-
711
-
712
-    /**i
422
+						'event_espresso'
423
+					),
424
+					$key
425
+				)
426
+			);
427
+		}
428
+		return true;
429
+	}
430
+
431
+
432
+	/**
433
+	 * Get the actual asset path for asset manifests.
434
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
435
+	 *
436
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
437
+	 *                           asset file location.
438
+	 * @param string $chunk_name
439
+	 * @param string $asset_type
440
+	 * @return string
441
+	 * @since 4.9.59.p
442
+	 */
443
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
444
+	{
445
+		$url = isset(
446
+			$this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
447
+			$this->manifest_data[ $namespace ]['url_base']
448
+		)
449
+			? $this->manifest_data[ $namespace ]['url_base']
450
+			  . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
451
+			: $chunk_name;
452
+
453
+		return apply_filters(
454
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
455
+			$url,
456
+			$namespace,
457
+			$chunk_name,
458
+			$asset_type
459
+		);
460
+	}
461
+
462
+
463
+
464
+	/**
465
+	 * Return the url to a js file for the given namespace and chunk name.
466
+	 *
467
+	 * @param string $namespace
468
+	 * @param string $chunk_name
469
+	 * @return string
470
+	 */
471
+	public function getJsUrl($namespace, $chunk_name)
472
+	{
473
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
474
+	}
475
+
476
+
477
+	/**
478
+	 * Return the url to a css file for the given namespace and chunk name.
479
+	 *
480
+	 * @param string $namespace
481
+	 * @param string $chunk_name
482
+	 * @return string
483
+	 */
484
+	public function getCssUrl($namespace, $chunk_name)
485
+	{
486
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
487
+	}
488
+
489
+
490
+	/**
491
+	 * Return the dependencies array and version string for a given asset $chunk_name
492
+	 *
493
+	 * @param string $namespace
494
+	 * @param string $chunk_name
495
+	 * @param string $asset_type
496
+	 * @return array
497
+	 * @since 4.9.82.p
498
+	 */
499
+	private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
500
+	{
501
+		$asset_index = $chunk_name . '.' . $asset_type;
502
+		if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
503
+			$path = isset($this->manifest_data[ $namespace ]['path'])
504
+				? $this->manifest_data[ $namespace ]['path']
505
+				: '';
506
+			$dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
507
+			$file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
508
+				? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
509
+				:
510
+				'';
511
+			$this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
512
+				? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
513
+				: [];
514
+		}
515
+		$details = $this->dependencies_data[ $namespace ][ $asset_index ];
516
+		return $details;
517
+	}
518
+
519
+
520
+	/**
521
+	 * Return dependencies array and version string according to asset type.
522
+	 * For css assets, this filters the auto generated dependencies by css type.
523
+	 *
524
+	 * @param string $namespace
525
+	 * @param string $asset_type
526
+	 * @param string $file_path
527
+	 * @param string $chunk_name
528
+	 * @return array
529
+	 * @since 4.9.82.p
530
+	 */
531
+	private function getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
532
+	{
533
+		// $asset_dependencies = json_decode(file_get_contents($file_path), true);
534
+		$asset_details = require($file_path);
535
+		$asset_details['dependencies'] = isset($asset_details['dependencies'])
536
+			? $asset_details['dependencies']
537
+			: [];
538
+		$asset_details['version'] = isset($asset_details['version'])
539
+			? $asset_details['version']
540
+			: '';
541
+		if ($asset_type === Asset::TYPE_JS) {
542
+			$asset_details['dependencies'] =  $chunk_name === 'eejs-core'
543
+				? $asset_details['dependencies']
544
+				: $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
545
+			return $asset_details;
546
+		}
547
+		// for css we need to make sure there is actually a css file related to this chunk.
548
+		if (isset($this->manifest_data[ $namespace ])) {
549
+			// array of css chunk files for ee.
550
+			$css_chunks = array_map(
551
+				static function ($value) {
552
+					return str_replace('.css', '', $value);
553
+				},
554
+				array_filter(
555
+					array_keys($this->manifest_data[ $namespace ]),
556
+					static function ($value) {
557
+						return strpos($value, '.css') !== false;
558
+					}
559
+				)
560
+			);
561
+			// add known wp chunks with css
562
+			$css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
563
+			// flip for easier search
564
+			$css_chunks = array_flip($css_chunks);
565
+
566
+			// now let's filter the dependencies for the incoming chunk to actual chunks that have styles
567
+			$asset_details['dependencies'] = array_filter(
568
+				$asset_details['dependencies'],
569
+				static function ($chunk_name) use ($css_chunks) {
570
+					return isset($css_chunks[ $chunk_name ]);
571
+				}
572
+			);
573
+			return $asset_details;
574
+		}
575
+		return ['dependencies' => [], 'version' => ''];
576
+	}
577
+
578
+
579
+	/**
580
+	 * Get the dependencies array and version string for the given js asset chunk name
581
+	 *
582
+	 * @param string $namespace
583
+	 * @param string $chunk_name
584
+	 * @return array
585
+	 * @since 4.10.2.p
586
+	 */
587
+	public function getJsAssetDetails($namespace, $chunk_name)
588
+	{
589
+		return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_JS);
590
+	}
591
+
592
+
593
+	/**
594
+	 * Get the dependencies array and version string for the given css asset chunk name
595
+	 *
596
+	 * @param string $namespace
597
+	 * @param string $chunk_name
598
+	 * @return array
599
+	 * @since 4.10.2.p
600
+	 */
601
+	public function getCssAssetDetails($namespace, $chunk_name)
602
+	{
603
+		return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
604
+	}
605
+
606
+
607
+	/**
608
+	 * @since 4.9.62.p
609
+	 * @throws InvalidArgumentException
610
+	 * @throws InvalidFilePathException
611
+	 */
612
+	public function registerManifestFiles()
613
+	{
614
+		$manifest_files = $this->assets->getManifestFiles();
615
+		foreach ($manifest_files as $manifest_file) {
616
+			$this->registerManifestFile(
617
+				$manifest_file->assetNamespace(),
618
+				$manifest_file->urlBase(),
619
+				$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
620
+				$manifest_file->filepath()
621
+			);
622
+		}
623
+	}
624
+
625
+
626
+	/**
627
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
628
+	 *
629
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
630
+	 * @param string $url_base      The url base for the manifest file location.
631
+	 * @param string $manifest_file The absolute path to the manifest file.
632
+	 * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
633
+	 *                                    default to `plugin_root/assets/dist`.
634
+	 * @throws InvalidArgumentException
635
+	 * @throws InvalidFilePathException
636
+	 * @since 4.9.59.p
637
+	 */
638
+	public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
639
+	{
640
+		if (isset($this->manifest_data[ $namespace ])) {
641
+			if (! $this->debug()) {
642
+				return;
643
+			}
644
+			throw new InvalidArgumentException(
645
+				sprintf(
646
+					esc_html__(
647
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
648
+						'event_espresso'
649
+					),
650
+					$namespace
651
+				)
652
+			);
653
+		}
654
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
655
+			if (is_admin()) {
656
+				EE_Error::add_error(
657
+					sprintf(
658
+						esc_html__(
659
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
660
+							'event_espresso'
661
+						),
662
+						'Event Espresso',
663
+						$url_base,
664
+						'plugins_url',
665
+						'WP_PLUGIN_URL'
666
+					),
667
+					__FILE__,
668
+					__FUNCTION__,
669
+					__LINE__
670
+				);
671
+			}
672
+			return;
673
+		}
674
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
675
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
676
+			$this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
677
+		}
678
+		if (! isset($this->manifest_data[ $namespace ]['path'])) {
679
+			$this->manifest_data[ $namespace ]['path'] = $manifest_file_path;
680
+		}
681
+	}
682
+
683
+
684
+	/**
685
+	 * Decodes json from the provided manifest file.
686
+	 *
687
+	 * @since 4.9.59.p
688
+	 * @param string $manifest_file Path to manifest file.
689
+	 * @return array
690
+	 * @throws InvalidFilePathException
691
+	 */
692
+	private function decodeManifestFile($manifest_file)
693
+	{
694
+		if (! file_exists($manifest_file)) {
695
+			throw new InvalidFilePathException($manifest_file);
696
+		}
697
+		return json_decode(file_get_contents($manifest_file), true);
698
+	}
699
+
700
+
701
+	/**
702
+	 * This is used to set registered script handles that have data.
703
+	 *
704
+	 * @param string $script_handle
705
+	 */
706
+	private function addRegisteredScriptHandlesWithData($script_handle)
707
+	{
708
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
709
+	}
710
+
711
+
712
+	/**i
713 713
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
714 714
      * Dependency stored in WP_Scripts if its set.
715 715
      */
716
-    private function removeAlreadyRegisteredDataForScriptHandles()
717
-    {
718
-        if (empty($this->script_handles_with_data)) {
719
-            return;
720
-        }
721
-        foreach ($this->script_handles_with_data as $script_handle) {
722
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
723
-        }
724
-    }
725
-
726
-
727
-    /**
728
-     * Removes any data dependency registered in WP_Scripts if its set.
729
-     *
730
-     * @param string $script_handle
731
-     */
732
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
733
-    {
734
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
735
-            global $wp_scripts;
736
-            $unset_handle = false;
737
-            if ($wp_scripts->get_data($script_handle, 'data')) {
738
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
739
-                $unset_handle = true;
740
-            }
741
-            //deal with inline_scripts
742
-            if ($wp_scripts->get_data($script_handle, 'before')) {
743
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
744
-                $unset_handle = true;
745
-            }
746
-            if ($wp_scripts->get_data($script_handle, 'after')) {
747
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
748
-            }
749
-            if ($unset_handle) {
750
-                unset($this->script_handles_with_data[ $script_handle ]);
751
-            }
752
-        }
753
-    }
754
-
755
-
756
-    /**
757
-     * register translations for a registered script
758
-     *
759
-     * @param string $handle
760
-     */
761
-    public function registerTranslation($handle)
762
-    {
763
-        $this->i18n_registry->registerScriptI18n($handle);
764
-    }
765
-
766
-
767
-    /**
768
-     * @since 4.9.63.p
769
-     * @return bool
770
-     */
771
-    private function debug()
772
-    {
773
-        return apply_filters(
774
-            'FHEE__EventEspresso_core_services_assets_Registry__debug',
775
-            defined('EE_DEBUG') && EE_DEBUG
776
-        );
777
-    }
778
-
779
-
780
-    /**
781
-     * Get the dependencies array for the given js asset chunk name
782
-     *
783
-     * @param string $namespace
784
-     * @param string $chunk_name
785
-     * @return array
786
-     * @deprecated 4.10.2.p
787
-     * @since 4.9.82.p
788
-     */
789
-    public function getJsDependencies($namespace, $chunk_name)
790
-    {
791
-        $details = $this->getJsAssetDetails($namespace, $chunk_name);
792
-        return isset($details['dependencies']) ? $details['dependencies'] : [];
793
-    }
794
-
795
-
796
-    /**
797
-     * Get the dependencies array for the given css asset chunk name
798
-     *
799
-     * @param string $namespace
800
-     * @param string $chunk_name
801
-     * @return array
802
-     * @deprecated 4.10.2.p
803
-     * @since      4.9.82.p
804
-     */
805
-    public function getCssDependencies($namespace, $chunk_name)
806
-    {
807
-        $details = $this->getCssAssetDetails($namespace, $chunk_name);
808
-        return isset($details['dependencies']) ? $details['dependencies'] : [];
809
-    }
716
+	private function removeAlreadyRegisteredDataForScriptHandles()
717
+	{
718
+		if (empty($this->script_handles_with_data)) {
719
+			return;
720
+		}
721
+		foreach ($this->script_handles_with_data as $script_handle) {
722
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
723
+		}
724
+	}
725
+
726
+
727
+	/**
728
+	 * Removes any data dependency registered in WP_Scripts if its set.
729
+	 *
730
+	 * @param string $script_handle
731
+	 */
732
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
733
+	{
734
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
735
+			global $wp_scripts;
736
+			$unset_handle = false;
737
+			if ($wp_scripts->get_data($script_handle, 'data')) {
738
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
739
+				$unset_handle = true;
740
+			}
741
+			//deal with inline_scripts
742
+			if ($wp_scripts->get_data($script_handle, 'before')) {
743
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
744
+				$unset_handle = true;
745
+			}
746
+			if ($wp_scripts->get_data($script_handle, 'after')) {
747
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
748
+			}
749
+			if ($unset_handle) {
750
+				unset($this->script_handles_with_data[ $script_handle ]);
751
+			}
752
+		}
753
+	}
754
+
755
+
756
+	/**
757
+	 * register translations for a registered script
758
+	 *
759
+	 * @param string $handle
760
+	 */
761
+	public function registerTranslation($handle)
762
+	{
763
+		$this->i18n_registry->registerScriptI18n($handle);
764
+	}
765
+
766
+
767
+	/**
768
+	 * @since 4.9.63.p
769
+	 * @return bool
770
+	 */
771
+	private function debug()
772
+	{
773
+		return apply_filters(
774
+			'FHEE__EventEspresso_core_services_assets_Registry__debug',
775
+			defined('EE_DEBUG') && EE_DEBUG
776
+		);
777
+	}
778
+
779
+
780
+	/**
781
+	 * Get the dependencies array for the given js asset chunk name
782
+	 *
783
+	 * @param string $namespace
784
+	 * @param string $chunk_name
785
+	 * @return array
786
+	 * @deprecated 4.10.2.p
787
+	 * @since 4.9.82.p
788
+	 */
789
+	public function getJsDependencies($namespace, $chunk_name)
790
+	{
791
+		$details = $this->getJsAssetDetails($namespace, $chunk_name);
792
+		return isset($details['dependencies']) ? $details['dependencies'] : [];
793
+	}
794
+
795
+
796
+	/**
797
+	 * Get the dependencies array for the given css asset chunk name
798
+	 *
799
+	 * @param string $namespace
800
+	 * @param string $chunk_name
801
+	 * @return array
802
+	 * @deprecated 4.10.2.p
803
+	 * @since      4.9.82.p
804
+	 */
805
+	public function getCssDependencies($namespace, $chunk_name)
806
+	{
807
+		$details = $this->getCssAssetDetails($namespace, $chunk_name);
808
+		return isset($details['dependencies']) ? $details['dependencies'] : [];
809
+	}
810 810
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1150 added lines, -1150 removed lines patch added patch discarded remove patch
@@ -20,1154 +20,1154 @@
 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
-            'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [
889
-                'WP_REST_Server' => EE_Dependency_Map::load_from_cache,
890
-                'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache,
891
-                'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
892
-                null
893
-            ],
894
-            'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'  => [
895
-                'EE_Admin_Config' => EE_Dependency_Map::load_from_cache
896
-            ],
897
-            'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'  => [
898
-                'EE_Event'        => EE_Dependency_Map::not_registered,
899
-                'EventEspresso\core\domain\services\converters\RestApiSpoofer' => EE_Dependency_Map::load_from_cache,
900
-                'EE_Admin_Config' => EE_Dependency_Map::load_from_cache,
901
-                'EEM_Datetime'    => EE_Dependency_Map::load_from_cache,
902
-                'EEM_Event'       => EE_Dependency_Map::load_from_cache,
903
-                'EEM_Price'       => EE_Dependency_Map::load_from_cache,
904
-                'EEM_Price_Type'  => EE_Dependency_Map::load_from_cache,
905
-                'EEM_Ticket'      => EE_Dependency_Map::load_from_cache,
906
-                'EEM_Venue'       => EE_Dependency_Map::load_from_cache,
907
-            ],
908
-        );
909
-    }
910
-
911
-
912
-    /**
913
-     * Registers how core classes are loaded.
914
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
915
-     *        'EE_Request_Handler' => 'load_core'
916
-     *        'EE_Messages_Queue'  => 'load_lib'
917
-     *        'EEH_Debug_Tools'    => 'load_helper'
918
-     * or, if greater control is required, by providing a custom closure. For example:
919
-     *        'Some_Class' => function () {
920
-     *            return new Some_Class();
921
-     *        },
922
-     * This is required for instantiating dependencies
923
-     * where an interface has been type hinted in a class constructor. For example:
924
-     *        'Required_Interface' => function () {
925
-     *            return new A_Class_That_Implements_Required_Interface();
926
-     *        },
927
-     */
928
-    protected function _register_core_class_loaders()
929
-    {
930
-        $this->_class_loaders = array(
931
-            // load_core
932
-            'EE_Dependency_Map'                            => function () {
933
-                return $this;
934
-            },
935
-            'EE_Capabilities'                              => 'load_core',
936
-            'EE_Encryption'                                => 'load_core',
937
-            'EE_Front_Controller'                          => 'load_core',
938
-            'EE_Module_Request_Router'                     => 'load_core',
939
-            'EE_Registry'                                  => 'load_core',
940
-            'EE_Request'                                   => function () {
941
-                return $this->legacy_request;
942
-            },
943
-            'EventEspresso\core\services\request\Request'  => function () {
944
-                return $this->request;
945
-            },
946
-            'EventEspresso\core\services\request\Response' => function () {
947
-                return $this->response;
948
-            },
949
-            'EE_Base'                                      => 'load_core',
950
-            'EE_Request_Handler'                           => 'load_core',
951
-            'EE_Session'                                   => 'load_core',
952
-            'EE_Cron_Tasks'                                => 'load_core',
953
-            'EE_System'                                    => 'load_core',
954
-            'EE_Maintenance_Mode'                          => 'load_core',
955
-            'EE_Register_CPTs'                             => 'load_core',
956
-            'EE_Admin'                                     => 'load_core',
957
-            'EE_CPT_Strategy'                              => 'load_core',
958
-            // load_class
959
-            'EE_Registration_Processor'                    => 'load_class',
960
-            // load_lib
961
-            'EE_Message_Resource_Manager'                  => 'load_lib',
962
-            'EE_Message_Type_Collection'                   => 'load_lib',
963
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
964
-            'EE_Messenger_Collection'                      => 'load_lib',
965
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
966
-            'EE_Messages_Processor'                        => 'load_lib',
967
-            'EE_Message_Repository'                        => 'load_lib',
968
-            'EE_Messages_Queue'                            => 'load_lib',
969
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
970
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
971
-            'EE_Payment_Method_Manager'                    => 'load_lib',
972
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
973
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
974
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
975
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
976
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
977
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
978
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
979
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
980
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
981
-            'EE_Messages_Generator'                        => function () {
982
-                return EE_Registry::instance()->load_lib(
983
-                    'Messages_Generator',
984
-                    array(),
985
-                    false,
986
-                    false
987
-                );
988
-            },
989
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
990
-                return EE_Registry::instance()->load_lib(
991
-                    'Messages_Template_Defaults',
992
-                    $arguments,
993
-                    false,
994
-                    false
995
-                );
996
-            },
997
-            // load_helper
998
-            'EEH_Parse_Shortcodes'                         => function () {
999
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1000
-                    return new EEH_Parse_Shortcodes();
1001
-                }
1002
-                return null;
1003
-            },
1004
-            'EE_Template_Config'                           => function () {
1005
-                return EE_Config::instance()->template_settings;
1006
-            },
1007
-            'EE_Currency_Config'                           => function () {
1008
-                return EE_Config::instance()->currency;
1009
-            },
1010
-            'EE_Registration_Config'                       => function () {
1011
-                return EE_Config::instance()->registration;
1012
-            },
1013
-            'EE_Core_Config'                               => function () {
1014
-                return EE_Config::instance()->core;
1015
-            },
1016
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1017
-                return LoaderFactory::getLoader();
1018
-            },
1019
-            'EE_Network_Config'                            => function () {
1020
-                return EE_Network_Config::instance();
1021
-            },
1022
-            'EE_Config'                                    => function () {
1023
-                return EE_Config::instance();
1024
-            },
1025
-            'EventEspresso\core\domain\Domain'             => function () {
1026
-                return DomainFactory::getEventEspressoCoreDomain();
1027
-            },
1028
-            'EE_Admin_Config'                              => function () {
1029
-                return EE_Config::instance()->admin;
1030
-            },
1031
-            'EE_Organization_Config'                       => function () {
1032
-                return EE_Config::instance()->organization;
1033
-            },
1034
-            'EE_Network_Core_Config'                       => function () {
1035
-                return EE_Network_Config::instance()->core;
1036
-            },
1037
-            'EE_Environment_Config'                        => function () {
1038
-                return EE_Config::instance()->environment;
1039
-            },
1040
-            'EED_Core_Rest_Api'                            => static function () {
1041
-                return EED_Core_Rest_Api::instance();
1042
-            },
1043
-            'WP_REST_Server'                            => static function () {
1044
-                return rest_get_server();
1045
-            },
1046
-        );
1047
-    }
1048
-
1049
-
1050
-    /**
1051
-     * can be used for supplying alternate names for classes,
1052
-     * or for connecting interface names to instantiable classes
1053
-     */
1054
-    protected function _register_core_aliases()
1055
-    {
1056
-        $aliases = array(
1057
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1058
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1059
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1060
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1061
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1062
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1063
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1064
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1065
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1066
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1067
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1068
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1069
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1070
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1071
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1072
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1073
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1074
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1075
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1076
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1077
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1078
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1079
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1080
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1081
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1082
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1083
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1084
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1085
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1086
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1087
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1088
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1089
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1090
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1091
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1092
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1093
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1094
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1095
-        );
1096
-        foreach ($aliases as $alias => $fqn) {
1097
-            if (is_array($fqn)) {
1098
-                foreach ($fqn as $class => $for_class) {
1099
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1100
-                }
1101
-                continue;
1102
-            }
1103
-            $this->class_cache->addAlias($fqn, $alias);
1104
-        }
1105
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1106
-            $this->class_cache->addAlias(
1107
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1108
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1109
-            );
1110
-        }
1111
-    }
1112
-
1113
-
1114
-    /**
1115
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1116
-     * request Primarily used by unit tests.
1117
-     */
1118
-    public function reset()
1119
-    {
1120
-        $this->_register_core_class_loaders();
1121
-        $this->_register_core_dependencies();
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     * PLZ NOTE: a better name for this method would be is_alias()
1127
-     * because it returns TRUE if the provided fully qualified name IS an alias
1128
-     * WHY?
1129
-     * Because if a class is type hinting for a concretion,
1130
-     * then why would we need to find another class to supply it?
1131
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1132
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1133
-     * Don't go looking for some substitute.
1134
-     * Whereas if a class is type hinting for an interface...
1135
-     * then we need to find an actual class to use.
1136
-     * So the interface IS the alias for some other FQN,
1137
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1138
-     * represents some other class.
1139
-     *
1140
-     * @deprecated 4.9.62.p
1141
-     * @param string $fqn
1142
-     * @param string $for_class
1143
-     * @return bool
1144
-     */
1145
-    public function has_alias($fqn = '', $for_class = '')
1146
-    {
1147
-        return $this->isAlias($fqn, $for_class);
1148
-    }
1149
-
1150
-
1151
-    /**
1152
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1153
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1154
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1155
-     *  for example:
1156
-     *      if the following two entries were added to the _aliases array:
1157
-     *          array(
1158
-     *              'interface_alias'           => 'some\namespace\interface'
1159
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1160
-     *          )
1161
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1162
-     *      to load an instance of 'some\namespace\classname'
1163
-     *
1164
-     * @deprecated 4.9.62.p
1165
-     * @param string $alias
1166
-     * @param string $for_class
1167
-     * @return string
1168
-     */
1169
-    public function get_alias($alias = '', $for_class = '')
1170
-    {
1171
-        return $this->getFqnForAlias($alias, $for_class);
1172
-    }
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
+			'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [
889
+				'WP_REST_Server' => EE_Dependency_Map::load_from_cache,
890
+				'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache,
891
+				'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
892
+				null
893
+			],
894
+			'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'  => [
895
+				'EE_Admin_Config' => EE_Dependency_Map::load_from_cache
896
+			],
897
+			'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'  => [
898
+				'EE_Event'        => EE_Dependency_Map::not_registered,
899
+				'EventEspresso\core\domain\services\converters\RestApiSpoofer' => EE_Dependency_Map::load_from_cache,
900
+				'EE_Admin_Config' => EE_Dependency_Map::load_from_cache,
901
+				'EEM_Datetime'    => EE_Dependency_Map::load_from_cache,
902
+				'EEM_Event'       => EE_Dependency_Map::load_from_cache,
903
+				'EEM_Price'       => EE_Dependency_Map::load_from_cache,
904
+				'EEM_Price_Type'  => EE_Dependency_Map::load_from_cache,
905
+				'EEM_Ticket'      => EE_Dependency_Map::load_from_cache,
906
+				'EEM_Venue'       => EE_Dependency_Map::load_from_cache,
907
+			],
908
+		);
909
+	}
910
+
911
+
912
+	/**
913
+	 * Registers how core classes are loaded.
914
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
915
+	 *        'EE_Request_Handler' => 'load_core'
916
+	 *        'EE_Messages_Queue'  => 'load_lib'
917
+	 *        'EEH_Debug_Tools'    => 'load_helper'
918
+	 * or, if greater control is required, by providing a custom closure. For example:
919
+	 *        'Some_Class' => function () {
920
+	 *            return new Some_Class();
921
+	 *        },
922
+	 * This is required for instantiating dependencies
923
+	 * where an interface has been type hinted in a class constructor. For example:
924
+	 *        'Required_Interface' => function () {
925
+	 *            return new A_Class_That_Implements_Required_Interface();
926
+	 *        },
927
+	 */
928
+	protected function _register_core_class_loaders()
929
+	{
930
+		$this->_class_loaders = array(
931
+			// load_core
932
+			'EE_Dependency_Map'                            => function () {
933
+				return $this;
934
+			},
935
+			'EE_Capabilities'                              => 'load_core',
936
+			'EE_Encryption'                                => 'load_core',
937
+			'EE_Front_Controller'                          => 'load_core',
938
+			'EE_Module_Request_Router'                     => 'load_core',
939
+			'EE_Registry'                                  => 'load_core',
940
+			'EE_Request'                                   => function () {
941
+				return $this->legacy_request;
942
+			},
943
+			'EventEspresso\core\services\request\Request'  => function () {
944
+				return $this->request;
945
+			},
946
+			'EventEspresso\core\services\request\Response' => function () {
947
+				return $this->response;
948
+			},
949
+			'EE_Base'                                      => 'load_core',
950
+			'EE_Request_Handler'                           => 'load_core',
951
+			'EE_Session'                                   => 'load_core',
952
+			'EE_Cron_Tasks'                                => 'load_core',
953
+			'EE_System'                                    => 'load_core',
954
+			'EE_Maintenance_Mode'                          => 'load_core',
955
+			'EE_Register_CPTs'                             => 'load_core',
956
+			'EE_Admin'                                     => 'load_core',
957
+			'EE_CPT_Strategy'                              => 'load_core',
958
+			// load_class
959
+			'EE_Registration_Processor'                    => 'load_class',
960
+			// load_lib
961
+			'EE_Message_Resource_Manager'                  => 'load_lib',
962
+			'EE_Message_Type_Collection'                   => 'load_lib',
963
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
964
+			'EE_Messenger_Collection'                      => 'load_lib',
965
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
966
+			'EE_Messages_Processor'                        => 'load_lib',
967
+			'EE_Message_Repository'                        => 'load_lib',
968
+			'EE_Messages_Queue'                            => 'load_lib',
969
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
970
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
971
+			'EE_Payment_Method_Manager'                    => 'load_lib',
972
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
973
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
974
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
975
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
976
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
977
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
978
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
979
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
980
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
981
+			'EE_Messages_Generator'                        => function () {
982
+				return EE_Registry::instance()->load_lib(
983
+					'Messages_Generator',
984
+					array(),
985
+					false,
986
+					false
987
+				);
988
+			},
989
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
990
+				return EE_Registry::instance()->load_lib(
991
+					'Messages_Template_Defaults',
992
+					$arguments,
993
+					false,
994
+					false
995
+				);
996
+			},
997
+			// load_helper
998
+			'EEH_Parse_Shortcodes'                         => function () {
999
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1000
+					return new EEH_Parse_Shortcodes();
1001
+				}
1002
+				return null;
1003
+			},
1004
+			'EE_Template_Config'                           => function () {
1005
+				return EE_Config::instance()->template_settings;
1006
+			},
1007
+			'EE_Currency_Config'                           => function () {
1008
+				return EE_Config::instance()->currency;
1009
+			},
1010
+			'EE_Registration_Config'                       => function () {
1011
+				return EE_Config::instance()->registration;
1012
+			},
1013
+			'EE_Core_Config'                               => function () {
1014
+				return EE_Config::instance()->core;
1015
+			},
1016
+			'EventEspresso\core\services\loaders\Loader'   => function () {
1017
+				return LoaderFactory::getLoader();
1018
+			},
1019
+			'EE_Network_Config'                            => function () {
1020
+				return EE_Network_Config::instance();
1021
+			},
1022
+			'EE_Config'                                    => function () {
1023
+				return EE_Config::instance();
1024
+			},
1025
+			'EventEspresso\core\domain\Domain'             => function () {
1026
+				return DomainFactory::getEventEspressoCoreDomain();
1027
+			},
1028
+			'EE_Admin_Config'                              => function () {
1029
+				return EE_Config::instance()->admin;
1030
+			},
1031
+			'EE_Organization_Config'                       => function () {
1032
+				return EE_Config::instance()->organization;
1033
+			},
1034
+			'EE_Network_Core_Config'                       => function () {
1035
+				return EE_Network_Config::instance()->core;
1036
+			},
1037
+			'EE_Environment_Config'                        => function () {
1038
+				return EE_Config::instance()->environment;
1039
+			},
1040
+			'EED_Core_Rest_Api'                            => static function () {
1041
+				return EED_Core_Rest_Api::instance();
1042
+			},
1043
+			'WP_REST_Server'                            => static function () {
1044
+				return rest_get_server();
1045
+			},
1046
+		);
1047
+	}
1048
+
1049
+
1050
+	/**
1051
+	 * can be used for supplying alternate names for classes,
1052
+	 * or for connecting interface names to instantiable classes
1053
+	 */
1054
+	protected function _register_core_aliases()
1055
+	{
1056
+		$aliases = array(
1057
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1058
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1059
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1060
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1061
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1062
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1063
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1064
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1065
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1066
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1067
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1068
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1069
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1070
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1071
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1072
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1073
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1074
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1075
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1076
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1077
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1078
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1079
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1080
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1081
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1082
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1083
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1084
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1085
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1086
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1087
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1088
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1089
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1090
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1091
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1092
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1093
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1094
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1095
+		);
1096
+		foreach ($aliases as $alias => $fqn) {
1097
+			if (is_array($fqn)) {
1098
+				foreach ($fqn as $class => $for_class) {
1099
+					$this->class_cache->addAlias($class, $alias, $for_class);
1100
+				}
1101
+				continue;
1102
+			}
1103
+			$this->class_cache->addAlias($fqn, $alias);
1104
+		}
1105
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1106
+			$this->class_cache->addAlias(
1107
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1108
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1109
+			);
1110
+		}
1111
+	}
1112
+
1113
+
1114
+	/**
1115
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1116
+	 * request Primarily used by unit tests.
1117
+	 */
1118
+	public function reset()
1119
+	{
1120
+		$this->_register_core_class_loaders();
1121
+		$this->_register_core_dependencies();
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 * PLZ NOTE: a better name for this method would be is_alias()
1127
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1128
+	 * WHY?
1129
+	 * Because if a class is type hinting for a concretion,
1130
+	 * then why would we need to find another class to supply it?
1131
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1132
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1133
+	 * Don't go looking for some substitute.
1134
+	 * Whereas if a class is type hinting for an interface...
1135
+	 * then we need to find an actual class to use.
1136
+	 * So the interface IS the alias for some other FQN,
1137
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1138
+	 * represents some other class.
1139
+	 *
1140
+	 * @deprecated 4.9.62.p
1141
+	 * @param string $fqn
1142
+	 * @param string $for_class
1143
+	 * @return bool
1144
+	 */
1145
+	public function has_alias($fqn = '', $for_class = '')
1146
+	{
1147
+		return $this->isAlias($fqn, $for_class);
1148
+	}
1149
+
1150
+
1151
+	/**
1152
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1153
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1154
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1155
+	 *  for example:
1156
+	 *      if the following two entries were added to the _aliases array:
1157
+	 *          array(
1158
+	 *              'interface_alias'           => 'some\namespace\interface'
1159
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1160
+	 *          )
1161
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1162
+	 *      to load an instance of 'some\namespace\classname'
1163
+	 *
1164
+	 * @deprecated 4.9.62.p
1165
+	 * @param string $alias
1166
+	 * @param string $for_class
1167
+	 * @return string
1168
+	 */
1169
+	public function get_alias($alias = '', $for_class = '')
1170
+	{
1171
+		return $this->getFqnForAlias($alias, $for_class);
1172
+	}
1173 1173
 }
Please login to merge, or discard this patch.
core/domain/services/converters/RestApiSpoofer.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -49,137 +49,137 @@
 block discarded – undo
49 49
 class RestApiSpoofer
50 50
 {
51 51
 
52
-    /**
53
-     * @var WP_REST_Server $wp_rest_server
54
-     */
55
-    protected $wp_rest_server;
52
+	/**
53
+	 * @var WP_REST_Server $wp_rest_server
54
+	 */
55
+	protected $wp_rest_server;
56 56
 
57
-    /**
58
-     * @var Read
59
-     */
60
-    protected $rest_controller;
57
+	/**
58
+	 * @var Read
59
+	 */
60
+	protected $rest_controller;
61 61
 
62
-    /**
63
-     * @var EED_Core_Rest_Api $rest_module
64
-     */
65
-    protected $rest_module;
62
+	/**
63
+	 * @var EED_Core_Rest_Api $rest_module
64
+	 */
65
+	protected $rest_module;
66 66
 
67 67
 
68
-    /**
69
-     * RestApiSpoofer constructor.
70
-     *
71
-     * @param WP_REST_Server        $wp_rest_server
72
-     * @param EED_Core_Rest_Api $rest_module
73
-     * @param Read                  $rest_api
74
-     * @param string                $api_version
75
-     */
76
-    public function __construct(
77
-        WP_REST_Server $wp_rest_server,
78
-        EED_Core_Rest_Api $rest_module,
79
-        Read $rest_api,
80
-        $api_version = '4.8.36'
81
-    ) {
82
-        $this->wp_rest_server = $wp_rest_server;
83
-        $this->rest_module = $rest_module;
84
-        $this->rest_controller = $rest_api;
85
-        $this->rest_controller->setRequestedVersion($api_version);
86
-        $this->setUpRestServer();
87
-    }
68
+	/**
69
+	 * RestApiSpoofer constructor.
70
+	 *
71
+	 * @param WP_REST_Server        $wp_rest_server
72
+	 * @param EED_Core_Rest_Api $rest_module
73
+	 * @param Read                  $rest_api
74
+	 * @param string                $api_version
75
+	 */
76
+	public function __construct(
77
+		WP_REST_Server $wp_rest_server,
78
+		EED_Core_Rest_Api $rest_module,
79
+		Read $rest_api,
80
+		$api_version = '4.8.36'
81
+	) {
82
+		$this->wp_rest_server = $wp_rest_server;
83
+		$this->rest_module = $rest_module;
84
+		$this->rest_controller = $rest_api;
85
+		$this->rest_controller->setRequestedVersion($api_version);
86
+		$this->setUpRestServer();
87
+	}
88 88
 
89 89
 
90
-    private function setUpRestServer()
91
-    {
92
-        /* @var WP_REST_Server $wp_rest_server */
93
-        global $wp_rest_server;
94
-        $wp_rest_server = $this->wp_rest_server;
95
-        EED_Core_Rest_Api::set_hooks_both();
96
-        do_action('rest_api_init', $this->wp_rest_server);
97
-    }
90
+	private function setUpRestServer()
91
+	{
92
+		/* @var WP_REST_Server $wp_rest_server */
93
+		global $wp_rest_server;
94
+		$wp_rest_server = $this->wp_rest_server;
95
+		EED_Core_Rest_Api::set_hooks_both();
96
+		do_action('rest_api_init', $this->wp_rest_server);
97
+	}
98 98
 
99
-    /**
100
-     * @param EEM_Base $model
101
-     * @param array    $query_params
102
-     * @param string   $include
103
-     * @return array
104
-     * @throws EE_Error
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     * @throws ModelConfigurationException
109
-     * @throws ReflectionException
110
-     * @throws RestException
111
-     * @throws RestPasswordIncorrectException
112
-     * @throws RestPasswordRequiredException
113
-     * @throws UnexpectedEntityException
114
-     * @throws DomainException
115
-     * @since $VID:$
116
-     */
117
-    public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118
-    {
119
-        if (! array_key_exists('limit', $query_params)) {
120
-            $query_params['limit'] = 1;
121
-        }
122
-        $result = $this->getApiResults($model, $query_params, $include);
123
-        return is_array($result) && isset($result[0]) ? $result[0] : [];
124
-    }
99
+	/**
100
+	 * @param EEM_Base $model
101
+	 * @param array    $query_params
102
+	 * @param string   $include
103
+	 * @return array
104
+	 * @throws EE_Error
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 * @throws ModelConfigurationException
109
+	 * @throws ReflectionException
110
+	 * @throws RestException
111
+	 * @throws RestPasswordIncorrectException
112
+	 * @throws RestPasswordRequiredException
113
+	 * @throws UnexpectedEntityException
114
+	 * @throws DomainException
115
+	 * @since $VID:$
116
+	 */
117
+	public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118
+	{
119
+		if (! array_key_exists('limit', $query_params)) {
120
+			$query_params['limit'] = 1;
121
+		}
122
+		$result = $this->getApiResults($model, $query_params, $include);
123
+		return is_array($result) && isset($result[0]) ? $result[0] : [];
124
+	}
125 125
 
126
-    /**
127
-     * @param EEM_Base $model
128
-     * @param array    $query_params
129
-     * @param string   $include
130
-     * @return array
131
-     * @throws EE_Error
132
-     * @throws InvalidArgumentException
133
-     * @throws InvalidDataTypeException
134
-     * @throws InvalidInterfaceException
135
-     * @throws ModelConfigurationException
136
-     * @throws ReflectionException
137
-     * @throws RestException
138
-     * @throws RestPasswordIncorrectException
139
-     * @throws RestPasswordRequiredException
140
-     * @throws UnexpectedEntityException
141
-     * @throws DomainException
142
-     * @since $VID:$
143
-     */
144
-    public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145
-    {
146
-        if (! array_key_exists('caps', $query_params)) {
147
-            $query_params['caps'] = EEM_Base::caps_read_admin;
148
-        }
149
-        if (! array_key_exists('default_where_conditions', $query_params)) {
150
-            $query_params['default_where_conditions'] = 'none';
151
-        }
152
-        /** @type array $results */
153
-        $results = $model->get_all_wpdb_results($query_params);
154
-        $rest_request = new WP_REST_Request();
155
-        $rest_request->set_param('include', $include);
156
-        $rest_request->set_param('caps', 'edit');
157
-        $nice_results = array();
158
-        foreach ($results as $result) {
159
-            $nice_results[] = $this->rest_controller->createEntityFromWpdbResult(
160
-                $model,
161
-                $result,
162
-                $rest_request
163
-            );
164
-        }
165
-        return $nice_results;
166
-    }
126
+	/**
127
+	 * @param EEM_Base $model
128
+	 * @param array    $query_params
129
+	 * @param string   $include
130
+	 * @return array
131
+	 * @throws EE_Error
132
+	 * @throws InvalidArgumentException
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws InvalidInterfaceException
135
+	 * @throws ModelConfigurationException
136
+	 * @throws ReflectionException
137
+	 * @throws RestException
138
+	 * @throws RestPasswordIncorrectException
139
+	 * @throws RestPasswordRequiredException
140
+	 * @throws UnexpectedEntityException
141
+	 * @throws DomainException
142
+	 * @since $VID:$
143
+	 */
144
+	public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145
+	{
146
+		if (! array_key_exists('caps', $query_params)) {
147
+			$query_params['caps'] = EEM_Base::caps_read_admin;
148
+		}
149
+		if (! array_key_exists('default_where_conditions', $query_params)) {
150
+			$query_params['default_where_conditions'] = 'none';
151
+		}
152
+		/** @type array $results */
153
+		$results = $model->get_all_wpdb_results($query_params);
154
+		$rest_request = new WP_REST_Request();
155
+		$rest_request->set_param('include', $include);
156
+		$rest_request->set_param('caps', 'edit');
157
+		$nice_results = array();
158
+		foreach ($results as $result) {
159
+			$nice_results[] = $this->rest_controller->createEntityFromWpdbResult(
160
+				$model,
161
+				$result,
162
+				$rest_request
163
+			);
164
+		}
165
+		return $nice_results;
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * @param string $endpoint
171
-     * @return array
172
-     * @throws EE_Error
173
-     * @since $VID:$
174
-     */
175
-    public function getModelSchema($endpoint)
176
-    {
177
-        $response = $this->wp_rest_server->dispatch(
178
-            new WP_REST_Request(
179
-                'OPTIONS',
180
-                "/ee/v4.8.36/{$endpoint}"
181
-            )
182
-        );
183
-        return $response->get_data();
184
-    }
169
+	/**
170
+	 * @param string $endpoint
171
+	 * @return array
172
+	 * @throws EE_Error
173
+	 * @since $VID:$
174
+	 */
175
+	public function getModelSchema($endpoint)
176
+	{
177
+		$response = $this->wp_rest_server->dispatch(
178
+			new WP_REST_Request(
179
+				'OPTIONS',
180
+				"/ee/v4.8.36/{$endpoint}"
181
+			)
182
+		);
183
+		return $response->get_data();
184
+	}
185 185
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118 118
     {
119
-        if (! array_key_exists('limit', $query_params)) {
119
+        if ( ! array_key_exists('limit', $query_params)) {
120 120
             $query_params['limit'] = 1;
121 121
         }
122 122
         $result = $this->getApiResults($model, $query_params, $include);
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145 145
     {
146
-        if (! array_key_exists('caps', $query_params)) {
146
+        if ( ! array_key_exists('caps', $query_params)) {
147 147
             $query_params['caps'] = EEM_Base::caps_read_admin;
148 148
         }
149
-        if (! array_key_exists('default_where_conditions', $query_params)) {
149
+        if ( ! array_key_exists('default_where_conditions', $query_params)) {
150 150
             $query_params['default_where_conditions'] = 'none';
151 151
         }
152 152
         /** @type array $results */
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 2 patches
Indentation   +1384 added lines, -1384 removed lines patch added patch discarded remove patch
@@ -17,1388 +17,1388 @@
 block discarded – undo
17 17
 class Extend_Events_Admin_Page extends Events_Admin_Page
18 18
 {
19 19
 
20
-    /**
21
-     * @var AdvancedEditorAdminFormSection
22
-     */
23
-    protected $advanced_editor_admin_form;
24
-    /**
25
-     * @var AdvancedEditorEntityData
26
-     */
27
-    protected $advanced_editor_data;
28
-
29
-
30
-    /**
31
-     * Extend_Events_Admin_Page constructor.
32
-     *
33
-     * @param bool $routing
34
-     * @throws EE_Error
35
-     * @throws InvalidArgumentException
36
-     * @throws InvalidDataTypeException
37
-     * @throws InvalidInterfaceException
38
-     * @throws ReflectionException
39
-     */
40
-    public function __construct($routing = true)
41
-    {
42
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
44
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
45
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
46
-        }
47
-        parent::__construct($routing);
48
-    }
49
-
50
-
51
-    /**
52
-     * Sets routes.
53
-     *
54
-     * @throws EE_Error
55
-     * @throws InvalidArgumentException
56
-     * @throws InvalidDataTypeException
57
-     * @throws InvalidInterfaceException
58
-     * @since $VID:$
59
-     */
60
-    protected function _extend_page_config()
61
-    {
62
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
63
-        // is there a evt_id in the request?
64
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
65
-            ? $this->_req_data['EVT_ID']
66
-            : 0;
67
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
68
-        // tkt_id?
69
-        $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
70
-            ? $this->_req_data['TKT_ID']
71
-            : 0;
72
-        $new_page_routes = array(
73
-            'duplicate_event'          => array(
74
-                'func'       => '_duplicate_event',
75
-                'capability' => 'ee_edit_event',
76
-                'obj_id'     => $evt_id,
77
-                'noheader'   => true,
78
-            ),
79
-            'ticket_list_table'        => array(
80
-                'func'       => '_tickets_overview_list_table',
81
-                'capability' => 'ee_read_default_tickets',
82
-            ),
83
-            'trash_ticket'             => array(
84
-                'func'       => '_trash_or_restore_ticket',
85
-                'capability' => 'ee_delete_default_ticket',
86
-                'obj_id'     => $tkt_id,
87
-                'noheader'   => true,
88
-                'args'       => array('trash' => true),
89
-            ),
90
-            'trash_tickets'            => array(
91
-                'func'       => '_trash_or_restore_ticket',
92
-                'capability' => 'ee_delete_default_tickets',
93
-                'noheader'   => true,
94
-                'args'       => array('trash' => true),
95
-            ),
96
-            'restore_ticket'           => array(
97
-                'func'       => '_trash_or_restore_ticket',
98
-                'capability' => 'ee_delete_default_ticket',
99
-                'obj_id'     => $tkt_id,
100
-                'noheader'   => true,
101
-            ),
102
-            'restore_tickets'          => array(
103
-                'func'       => '_trash_or_restore_ticket',
104
-                'capability' => 'ee_delete_default_tickets',
105
-                'noheader'   => true,
106
-            ),
107
-            'delete_ticket'            => array(
108
-                'func'       => '_delete_ticket',
109
-                'capability' => 'ee_delete_default_ticket',
110
-                'obj_id'     => $tkt_id,
111
-                'noheader'   => true,
112
-            ),
113
-            'delete_tickets'           => array(
114
-                'func'       => '_delete_ticket',
115
-                'capability' => 'ee_delete_default_tickets',
116
-                'noheader'   => true,
117
-            ),
118
-            'import_page'              => array(
119
-                'func'       => '_import_page',
120
-                'capability' => 'import',
121
-            ),
122
-            'import'                   => array(
123
-                'func'       => '_import_events',
124
-                'capability' => 'import',
125
-                'noheader'   => true,
126
-            ),
127
-            'import_events'            => array(
128
-                'func'       => '_import_events',
129
-                'capability' => 'import',
130
-                'noheader'   => true,
131
-            ),
132
-            'export_events'            => array(
133
-                'func'       => '_events_export',
134
-                'capability' => 'export',
135
-                'noheader'   => true,
136
-            ),
137
-            'export_categories'        => array(
138
-                'func'       => '_categories_export',
139
-                'capability' => 'export',
140
-                'noheader'   => true,
141
-            ),
142
-            'sample_export_file'       => array(
143
-                'func'       => '_sample_export_file',
144
-                'capability' => 'export',
145
-                'noheader'   => true,
146
-            ),
147
-            'update_template_settings' => array(
148
-                'func'       => '_update_template_settings',
149
-                'capability' => 'manage_options',
150
-                'noheader'   => true,
151
-            ),
152
-        );
153
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
154
-        // partial route/config override
155
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
156
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
157
-        $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
158
-        $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
159
-        $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
160
-        $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
161
-        // add tickets tab but only if there are more than one default ticket!
162
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
163
-            array(array('TKT_is_default' => 1)),
164
-            'TKT_ID',
165
-            true
166
-        );
167
-        if ($tkt_count > 1) {
168
-            $new_page_config = array(
169
-                'ticket_list_table' => array(
170
-                    'nav'           => array(
171
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
172
-                        'order' => 60,
173
-                    ),
174
-                    'list_table'    => 'Tickets_List_Table',
175
-                    'require_nonce' => false,
176
-                ),
177
-            );
178
-        }
179
-        // template settings
180
-        $new_page_config['template_settings'] = array(
181
-            'nav'           => array(
182
-                'label' => esc_html__('Templates', 'event_espresso'),
183
-                'order' => 30,
184
-            ),
185
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
186
-            'help_tabs'     => array(
187
-                'general_settings_templates_help_tab' => array(
188
-                    'title'    => esc_html__('Templates', 'event_espresso'),
189
-                    'filename' => 'general_settings_templates',
190
-                ),
191
-            ),
192
-            'help_tour'     => array('Templates_Help_Tour'),
193
-            'require_nonce' => false,
194
-        );
195
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
196
-        // add filters and actions
197
-        // modifying _views
198
-        add_filter(
199
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
200
-            array($this, 'add_additional_datetime_button'),
201
-            10,
202
-            2
203
-        );
204
-        add_filter(
205
-            'FHEE_event_datetime_metabox_clone_button_template',
206
-            array($this, 'add_datetime_clone_button'),
207
-            10,
208
-            2
209
-        );
210
-        add_filter(
211
-            'FHEE_event_datetime_metabox_timezones_template',
212
-            array($this, 'datetime_timezones_template'),
213
-            10,
214
-            2
215
-        );
216
-        // filters for event list table
217
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
218
-        add_filter(
219
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
220
-            array($this, 'extra_list_table_actions'),
221
-            10,
222
-            2
223
-        );
224
-        // legend item
225
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
226
-        add_action('admin_init', array($this, 'admin_init'));
227
-    }
228
-
229
-
230
-    /**
231
-     * admin_init
232
-     */
233
-    public function admin_init()
234
-    {
235
-        if (isset($this->_req_data['action'])
236
-            && (
237
-                $this->_req_data['action'] === 'default_event_settings'
238
-                || $this->_req_data['action'] === 'update_default_event_settings'
239
-            )
240
-        ) {
241
-            $this->advanced_editor_admin_form = $this->loader->getShared(
242
-                'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
243
-            );
244
-        }
245
-        if (isset($this->_req_data['action'])
246
-            && ( $this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
247
-        ) {
248
-            $this->advanced_editor_data = $this->loader->getShared(
249
-                'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData',
250
-                [$this->_cpt_model_obj]
251
-            );
252
-        }
253
-        EE_Registry::$i18n_js_strings = array_merge(
254
-            EE_Registry::$i18n_js_strings,
255
-            array(
256
-                'image_confirm'          => esc_html__(
257
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
258
-                    'event_espresso'
259
-                ),
260
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
261
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
262
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
263
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
264
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
265
-            )
266
-        );
267
-    }
268
-
269
-
270
-    /**
271
-     * Add per page screen options to the default ticket list table view.
272
-     *
273
-     * @throws InvalidArgumentException
274
-     * @throws InvalidDataTypeException
275
-     * @throws InvalidInterfaceException
276
-     */
277
-    protected function _add_screen_options_ticket_list_table()
278
-    {
279
-        $this->_per_page_screen_option();
280
-    }
281
-
282
-
283
-    /**
284
-     * @param string $return
285
-     * @param int    $id
286
-     * @param string $new_title
287
-     * @param string $new_slug
288
-     * @return string
289
-     */
290
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
291
-    {
292
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
293
-        // make sure this is only when editing
294
-        if (! empty($id)) {
295
-            $href = EE_Admin_Page::add_query_args_and_nonce(
296
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
297
-                $this->_admin_base_url
298
-            );
299
-            $title = esc_attr__('Duplicate Event', 'event_espresso');
300
-            $return .= '<a href="'
301
-                       . $href
302
-                       . '" title="'
303
-                       . $title
304
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
305
-                       . $title
306
-                       . '</a>';
307
-        }
308
-        return $return;
309
-    }
310
-
311
-
312
-    /**
313
-     * Set the list table views for the default ticket list table view.
314
-     */
315
-    public function _set_list_table_views_ticket_list_table()
316
-    {
317
-        $this->_views = array(
318
-            'all'     => array(
319
-                'slug'        => 'all',
320
-                'label'       => esc_html__('All', 'event_espresso'),
321
-                'count'       => 0,
322
-                'bulk_action' => array(
323
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
324
-                ),
325
-            ),
326
-            'trashed' => array(
327
-                'slug'        => 'trashed',
328
-                'label'       => esc_html__('Trash', 'event_espresso'),
329
-                'count'       => 0,
330
-                'bulk_action' => array(
331
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
332
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
333
-                ),
334
-            ),
335
-        );
336
-    }
337
-
338
-
339
-    /**
340
-     * Enqueue scripts and styles for the event editor.
341
-     */
342
-    public function load_scripts_styles_edit()
343
-    {
344
-        wp_register_script(
345
-            'ee-event-editor-heartbeat',
346
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
347
-            array('ee_admin_js', 'heartbeat'),
348
-            EVENT_ESPRESSO_VERSION,
349
-            true
350
-        );
351
-        wp_enqueue_script('ee-accounting');
352
-        // styles
353
-        wp_enqueue_style('espresso-ui-theme');
354
-        wp_enqueue_script('event_editor_js');
355
-        wp_enqueue_script('ee-event-editor-heartbeat');
356
-    }
357
-
358
-
359
-    /**
360
-     * Returns template for the additional datetime.
361
-     *
362
-     * @param $template
363
-     * @param $template_args
364
-     * @return mixed
365
-     * @throws DomainException
366
-     */
367
-    public function add_additional_datetime_button($template, $template_args)
368
-    {
369
-        return EEH_Template::display_template(
370
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
371
-            $template_args,
372
-            true
373
-        );
374
-    }
375
-
376
-
377
-    /**
378
-     * Returns the template for cloning a datetime.
379
-     *
380
-     * @param $template
381
-     * @param $template_args
382
-     * @return mixed
383
-     * @throws DomainException
384
-     */
385
-    public function add_datetime_clone_button($template, $template_args)
386
-    {
387
-        return EEH_Template::display_template(
388
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
389
-            $template_args,
390
-            true
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     * Returns the template for datetime timezones.
397
-     *
398
-     * @param $template
399
-     * @param $template_args
400
-     * @return mixed
401
-     * @throws DomainException
402
-     */
403
-    public function datetime_timezones_template($template, $template_args)
404
-    {
405
-        return EEH_Template::display_template(
406
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
407
-            $template_args,
408
-            true
409
-        );
410
-    }
411
-
412
-
413
-    /**
414
-     * Sets the views for the default list table view.
415
-     */
416
-    protected function _set_list_table_views_default()
417
-    {
418
-        parent::_set_list_table_views_default();
419
-        $new_views = array(
420
-            'today' => array(
421
-                'slug'        => 'today',
422
-                'label'       => esc_html__('Today', 'event_espresso'),
423
-                'count'       => $this->total_events_today(),
424
-                'bulk_action' => array(
425
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
426
-                ),
427
-            ),
428
-            'month' => array(
429
-                'slug'        => 'month',
430
-                'label'       => esc_html__('This Month', 'event_espresso'),
431
-                'count'       => $this->total_events_this_month(),
432
-                'bulk_action' => array(
433
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
434
-                ),
435
-            ),
436
-        );
437
-        $this->_views = array_merge($this->_views, $new_views);
438
-    }
439
-
440
-
441
-    /**
442
-     * Returns the extra action links for the default list table view.
443
-     *
444
-     * @param array    $action_links
445
-     * @param EE_Event $event
446
-     * @return array
447
-     * @throws EE_Error
448
-     * @throws InvalidArgumentException
449
-     * @throws InvalidDataTypeException
450
-     * @throws InvalidInterfaceException
451
-     * @throws ReflectionException
452
-     */
453
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
454
-    {
455
-        if (EE_Registry::instance()->CAP->current_user_can(
456
-            'ee_read_registrations',
457
-            'espresso_registrations_reports',
458
-            $event->ID()
459
-        )
460
-        ) {
461
-            $reports_query_args = array(
462
-                'action' => 'reports',
463
-                'EVT_ID' => $event->ID(),
464
-            );
465
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
466
-            $action_links[] = '<a href="'
467
-                              . $reports_link
468
-                              . '" title="'
469
-                              . esc_attr__('View Report', 'event_espresso')
470
-                              . '"><div class="dashicons dashicons-chart-bar"></div></a>'
471
-                              . "\n\t";
472
-        }
473
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
474
-            EE_Registry::instance()->load_helper('MSG_Template');
475
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
476
-                'see_notifications_for',
477
-                null,
478
-                array('EVT_ID' => $event->ID())
479
-            );
480
-        }
481
-        return $action_links;
482
-    }
483
-
484
-
485
-    /**
486
-     * @param $items
487
-     * @return mixed
488
-     */
489
-    public function additional_legend_items($items)
490
-    {
491
-        if (EE_Registry::instance()->CAP->current_user_can(
492
-            'ee_read_registrations',
493
-            'espresso_registrations_reports'
494
-        )
495
-        ) {
496
-            $items['reports'] = array(
497
-                'class' => 'dashicons dashicons-chart-bar',
498
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
499
-            );
500
-        }
501
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
502
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
503
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
504
-            // (can only use numeric offsets when treating strings as arrays)
505
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
506
-                $items['view_related_messages'] = array(
507
-                    'class' => $related_for_icon['css_class'],
508
-                    'desc'  => $related_for_icon['label'],
509
-                );
510
-            }
511
-        }
512
-        return $items;
513
-    }
514
-
515
-
516
-    /**
517
-     * This is the callback method for the duplicate event route
518
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
519
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
520
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
521
-     * After duplication the redirect is to the new event edit page.
522
-     *
523
-     * @return void
524
-     * @throws EE_Error If EE_Event is not available with given ID
525
-     * @throws InvalidArgumentException
526
-     * @throws InvalidDataTypeException
527
-     * @throws InvalidInterfaceException
528
-     * @throws ReflectionException
529
-     * @access protected
530
-     */
531
-    protected function _duplicate_event()
532
-    {
533
-        // first make sure the ID for the event is in the request.
534
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
535
-        if (! isset($this->_req_data['EVT_ID'])) {
536
-            EE_Error::add_error(
537
-                esc_html__(
538
-                    'In order to duplicate an event an Event ID is required.  None was given.',
539
-                    'event_espresso'
540
-                ),
541
-                __FILE__,
542
-                __FUNCTION__,
543
-                __LINE__
544
-            );
545
-            $this->_redirect_after_action(false, '', '', array(), true);
546
-            return;
547
-        }
548
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
549
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
550
-        if (! $orig_event instanceof EE_Event) {
551
-            throw new EE_Error(
552
-                sprintf(
553
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
554
-                    $this->_req_data['EVT_ID']
555
-                )
556
-            );
557
-        }
558
-        // k now let's clone the $orig_event before getting relations
559
-        $new_event = clone $orig_event;
560
-        // original datetimes
561
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
562
-        // other original relations
563
-        $orig_ven = $orig_event->get_many_related('Venue');
564
-        // reset the ID and modify other details to make it clear this is a dupe
565
-        $new_event->set('EVT_ID', 0);
566
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
567
-        $new_event->set('EVT_name', $new_name);
568
-        $new_event->set(
569
-            'EVT_slug',
570
-            wp_unique_post_slug(
571
-                sanitize_title($orig_event->name()),
572
-                0,
573
-                'publish',
574
-                'espresso_events',
575
-                0
576
-            )
577
-        );
578
-        $new_event->set('status', 'draft');
579
-        // duplicate discussion settings
580
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
581
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
582
-        // save the new event
583
-        $new_event->save();
584
-        // venues
585
-        foreach ($orig_ven as $ven) {
586
-            $new_event->_add_relation_to($ven, 'Venue');
587
-        }
588
-        $new_event->save();
589
-        // now we need to get the question group relations and handle that
590
-        // first primary question groups
591
-        $orig_primary_qgs = $orig_event->get_many_related(
592
-            'Question_Group',
593
-            [['Event_Question_Group.EQG_primary' => true]]
594
-        );
595
-        if (! empty($orig_primary_qgs)) {
596
-            foreach ($orig_primary_qgs as $id => $obj) {
597
-                if ($obj instanceof EE_Question_Group) {
598
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
599
-                }
600
-            }
601
-        }
602
-        // next additional attendee question groups
603
-        $orig_additional_qgs = $orig_event->get_many_related(
604
-            'Question_Group',
605
-            [['Event_Question_Group.EQG_additional' => true]]
606
-        );
607
-        if (! empty($orig_additional_qgs)) {
608
-            foreach ($orig_additional_qgs as $id => $obj) {
609
-                if ($obj instanceof EE_Question_Group) {
610
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
611
-                }
612
-            }
613
-        }
614
-
615
-        $new_event->save();
616
-
617
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
618
-        $cloned_tickets = array();
619
-        foreach ($orig_datetimes as $orig_dtt) {
620
-            if (! $orig_dtt instanceof EE_Datetime) {
621
-                continue;
622
-            }
623
-            $new_dtt = clone $orig_dtt;
624
-            $orig_tkts = $orig_dtt->tickets();
625
-            // save new dtt then add to event
626
-            $new_dtt->set('DTT_ID', 0);
627
-            $new_dtt->set('DTT_sold', 0);
628
-            $new_dtt->set_reserved(0);
629
-            $new_dtt->save();
630
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
631
-            $new_event->save();
632
-            // now let's get the ticket relations setup.
633
-            foreach ((array) $orig_tkts as $orig_tkt) {
634
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
635
-                if (! $orig_tkt instanceof EE_Ticket) {
636
-                    continue;
637
-                }
638
-                // is this ticket archived?  If it is then let's skip
639
-                if ($orig_tkt->get('TKT_deleted')) {
640
-                    continue;
641
-                }
642
-                // does this original ticket already exist in the clone_tickets cache?
643
-                //  If so we'll just use the new ticket from it.
644
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
645
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
646
-                } else {
647
-                    $new_tkt = clone $orig_tkt;
648
-                    // get relations on the $orig_tkt that we need to setup.
649
-                    $orig_prices = $orig_tkt->prices();
650
-                    $new_tkt->set('TKT_ID', 0);
651
-                    $new_tkt->set('TKT_sold', 0);
652
-                    $new_tkt->set('TKT_reserved', 0);
653
-                    $new_tkt->save(); // make sure new ticket has ID.
654
-                    // price relations on new ticket need to be setup.
655
-                    foreach ($orig_prices as $orig_price) {
656
-                        $new_price = clone $orig_price;
657
-                        $new_price->set('PRC_ID', 0);
658
-                        $new_price->save();
659
-                        $new_tkt->_add_relation_to($new_price, 'Price');
660
-                        $new_tkt->save();
661
-                    }
662
-
663
-                    do_action(
664
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
665
-                        $orig_tkt,
666
-                        $new_tkt,
667
-                        $orig_prices,
668
-                        $orig_event,
669
-                        $orig_dtt,
670
-                        $new_dtt
671
-                    );
672
-                }
673
-                // k now we can add the new ticket as a relation to the new datetime
674
-                // and make sure its added to our cached $cloned_tickets array
675
-                // for use with later datetimes that have the same ticket.
676
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
677
-                $new_dtt->save();
678
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
679
-            }
680
-        }
681
-        // clone taxonomy information
682
-        $taxonomies_to_clone_with = apply_filters(
683
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
684
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
685
-        );
686
-        // get terms for original event (notice)
687
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
688
-        // loop through terms and add them to new event.
689
-        foreach ($orig_terms as $term) {
690
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
691
-        }
692
-
693
-        // duplicate other core WP_Post items for this event.
694
-        // post thumbnail (feature image).
695
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
696
-        if ($feature_image_id) {
697
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
698
-        }
699
-
700
-        // duplicate page_template setting
701
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
702
-        if ($page_template) {
703
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
704
-        }
705
-
706
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
707
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
708
-        if ($new_event->ID()) {
709
-            $redirect_args = array(
710
-                'post'   => $new_event->ID(),
711
-                'action' => 'edit',
712
-            );
713
-            EE_Error::add_success(
714
-                esc_html__(
715
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
716
-                    'event_espresso'
717
-                )
718
-            );
719
-        } else {
720
-            $redirect_args = array(
721
-                'action' => 'default',
722
-            );
723
-            EE_Error::add_error(
724
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
725
-                __FILE__,
726
-                __FUNCTION__,
727
-                __LINE__
728
-            );
729
-        }
730
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
731
-    }
732
-
733
-
734
-    /**
735
-     * Generates output for the import page.
736
-     *
737
-     * @throws DomainException
738
-     * @throws EE_Error
739
-     * @throws InvalidArgumentException
740
-     * @throws InvalidDataTypeException
741
-     * @throws InvalidInterfaceException
742
-     */
743
-    protected function _import_page()
744
-    {
745
-        $title = esc_html__('Import', 'event_espresso');
746
-        $intro = esc_html__(
747
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
748
-            'event_espresso'
749
-        );
750
-        $form_url = EVENTS_ADMIN_URL;
751
-        $action = 'import_events';
752
-        $type = 'csv';
753
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
754
-            $title,
755
-            $intro,
756
-            $form_url,
757
-            $action,
758
-            $type
759
-        );
760
-        $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
761
-            array('action' => 'sample_export_file'),
762
-            $this->_admin_base_url
763
-        );
764
-        $content = EEH_Template::display_template(
765
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
766
-            $this->_template_args,
767
-            true
768
-        );
769
-        $this->_template_args['admin_page_content'] = $content;
770
-        $this->display_admin_page_with_sidebar();
771
-    }
772
-
773
-
774
-    /**
775
-     * _import_events
776
-     * This handles displaying the screen and running imports for importing events.
777
-     *
778
-     * @return void
779
-     * @throws EE_Error
780
-     * @throws InvalidArgumentException
781
-     * @throws InvalidDataTypeException
782
-     * @throws InvalidInterfaceException
783
-     */
784
-    protected function _import_events()
785
-    {
786
-        require_once(EE_CLASSES . 'EE_Import.class.php');
787
-        $success = EE_Import::instance()->import();
788
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
789
-    }
790
-
791
-
792
-    /**
793
-     * _events_export
794
-     * Will export all (or just the given event) to a Excel compatible file.
795
-     *
796
-     * @access protected
797
-     * @return void
798
-     */
799
-    protected function _events_export()
800
-    {
801
-        if (isset($this->_req_data['EVT_ID'])) {
802
-            $event_ids = $this->_req_data['EVT_ID'];
803
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
804
-            $event_ids = $this->_req_data['EVT_IDs'];
805
-        } else {
806
-            $event_ids = null;
807
-        }
808
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
809
-        $new_request_args = array(
810
-            'export' => 'report',
811
-            'action' => 'all_event_data',
812
-            'EVT_ID' => $event_ids,
813
-        );
814
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
815
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
816
-            require_once(EE_CLASSES . 'EE_Export.class.php');
817
-            $EE_Export = EE_Export::instance($this->_req_data);
818
-            $EE_Export->export();
819
-        }
820
-    }
821
-
822
-
823
-    /**
824
-     * handle category exports()
825
-     *
826
-     * @return void
827
-     */
828
-    protected function _categories_export()
829
-    {
830
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
831
-        $new_request_args = array(
832
-            'export'       => 'report',
833
-            'action'       => 'categories',
834
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
835
-        );
836
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
837
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
838
-            require_once(EE_CLASSES . 'EE_Export.class.php');
839
-            $EE_Export = EE_Export::instance($this->_req_data);
840
-            $EE_Export->export();
841
-        }
842
-    }
843
-
844
-
845
-    /**
846
-     * Creates a sample CSV file for importing
847
-     */
848
-    protected function _sample_export_file()
849
-    {
850
-        // require_once(EE_CLASSES . 'EE_Export.class.php');
851
-        EE_Export::instance()->export_sample();
852
-    }
853
-
854
-
855
-    /*************        Template Settings        *************/
856
-    /**
857
-     * Generates template settings page output
858
-     *
859
-     * @throws DomainException
860
-     * @throws EE_Error
861
-     * @throws InvalidArgumentException
862
-     * @throws InvalidDataTypeException
863
-     * @throws InvalidInterfaceException
864
-     */
865
-    protected function _template_settings()
866
-    {
867
-        $this->_template_args['values'] = $this->_yes_no_values;
868
-        /**
869
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
870
-         * from General_Settings_Admin_Page to here.
871
-         */
872
-        $this->_template_args = apply_filters(
873
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
874
-            $this->_template_args
875
-        );
876
-        $this->_set_add_edit_form_tags('update_template_settings');
877
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
878
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
879
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
880
-            $this->_template_args,
881
-            true
882
-        );
883
-        $this->display_admin_page_with_sidebar();
884
-    }
885
-
886
-
887
-    /**
888
-     * Handler for updating template settings.
889
-     *
890
-     * @throws EE_Error
891
-     * @throws InvalidArgumentException
892
-     * @throws InvalidDataTypeException
893
-     * @throws InvalidInterfaceException
894
-     */
895
-    protected function _update_template_settings()
896
-    {
897
-        /**
898
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
899
-         * from General_Settings_Admin_Page to here.
900
-         */
901
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
902
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
903
-            EE_Registry::instance()->CFG->template_settings,
904
-            $this->_req_data
905
-        );
906
-        // update custom post type slugs and detect if we need to flush rewrite rules
907
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
908
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
909
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
910
-            : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
911
-        $what = 'Template Settings';
912
-        $success = $this->_update_espresso_configuration(
913
-            $what,
914
-            EE_Registry::instance()->CFG->template_settings,
915
-            __FILE__,
916
-            __FUNCTION__,
917
-            __LINE__
918
-        );
919
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
920
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
921
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
922
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
923
-            );
924
-            $rewrite_rules->flush();
925
-        }
926
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
927
-    }
928
-
929
-
930
-    /**
931
-     * _premium_event_editor_meta_boxes
932
-     * add all metaboxes related to the event_editor
933
-     *
934
-     * @access protected
935
-     * @return void
936
-     * @throws EE_Error
937
-     * @throws InvalidArgumentException
938
-     * @throws InvalidDataTypeException
939
-     * @throws InvalidInterfaceException
940
-     * @throws ReflectionException
941
-     */
942
-    protected function _premium_event_editor_meta_boxes()
943
-    {
944
-        $this->verify_cpt_object();
945
-        add_meta_box(
946
-            'espresso_event_editor_event_options',
947
-            esc_html__('Event Registration Options', 'event_espresso'),
948
-            array($this, 'registration_options_meta_box'),
949
-            $this->page_slug,
950
-            'side',
951
-            'core'
952
-        );
953
-    }
954
-
955
-
956
-    /**
957
-     * override caf metabox
958
-     *
959
-     * @return void
960
-     * @throws DomainException
961
-     * @throws EE_Error
962
-     */
963
-    public function registration_options_meta_box()
964
-    {
965
-        $yes_no_values = array(
966
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
967
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
968
-        );
969
-        $default_reg_status_values = EEM_Registration::reg_status_array(
970
-            array(
971
-                EEM_Registration::status_id_cancelled,
972
-                EEM_Registration::status_id_declined,
973
-                EEM_Registration::status_id_incomplete,
974
-                EEM_Registration::status_id_wait_list,
975
-            ),
976
-            true
977
-        );
978
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
979
-        $template_args['_event'] = $this->_cpt_model_obj;
980
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
981
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
982
-            'default_reg_status',
983
-            $default_reg_status_values,
984
-            $this->_cpt_model_obj->default_registration_status()
985
-        );
986
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
987
-            'display_desc',
988
-            $yes_no_values,
989
-            $this->_cpt_model_obj->display_description()
990
-        );
991
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
992
-            'display_ticket_selector',
993
-            $yes_no_values,
994
-            $this->_cpt_model_obj->display_ticket_selector(),
995
-            '',
996
-            '',
997
-            false
998
-        );
999
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1000
-            'EVT_default_registration_status',
1001
-            $default_reg_status_values,
1002
-            $this->_cpt_model_obj->default_registration_status()
1003
-        );
1004
-        $template_args['additional_registration_options'] = apply_filters(
1005
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1006
-            '',
1007
-            $template_args,
1008
-            $yes_no_values,
1009
-            $default_reg_status_values
1010
-        );
1011
-        EEH_Template::display_template(
1012
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1013
-            $template_args
1014
-        );
1015
-    }
1016
-
1017
-
1018
-
1019
-    /**
1020
-     * wp_list_table_mods for caf
1021
-     * ============================
1022
-     */
1023
-    /**
1024
-     * hook into list table filters and provide filters for caffeinated list table
1025
-     *
1026
-     * @param array $old_filters    any existing filters present
1027
-     * @param array $list_table_obj the list table object
1028
-     * @return array                  new filters
1029
-     * @throws EE_Error
1030
-     * @throws InvalidArgumentException
1031
-     * @throws InvalidDataTypeException
1032
-     * @throws InvalidInterfaceException
1033
-     * @throws ReflectionException
1034
-     */
1035
-    public function list_table_filters($old_filters, $list_table_obj)
1036
-    {
1037
-        $filters = array();
1038
-        // first month/year filters
1039
-        $filters[] = $this->espresso_event_months_dropdown();
1040
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1041
-        // active status dropdown
1042
-        if ($status !== 'draft') {
1043
-            $filters[] = $this->active_status_dropdown(
1044
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1045
-            );
1046
-            $filters[] = $this->venuesDropdown(
1047
-                isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1048
-            );
1049
-        }
1050
-        // category filter
1051
-        $filters[] = $this->category_dropdown();
1052
-        return array_merge($old_filters, $filters);
1053
-    }
1054
-
1055
-
1056
-    /**
1057
-     * espresso_event_months_dropdown
1058
-     *
1059
-     * @access public
1060
-     * @return string                dropdown listing month/year selections for events.
1061
-     */
1062
-    public function espresso_event_months_dropdown()
1063
-    {
1064
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1065
-        // Note we need to include any other filters that are set!
1066
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1067
-        // categories?
1068
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1069
-            ? $this->_req_data['EVT_CAT']
1070
-            : null;
1071
-        // active status?
1072
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1073
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1074
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1075
-    }
1076
-
1077
-
1078
-    /**
1079
-     * returns a list of "active" statuses on the event
1080
-     *
1081
-     * @param  string $current_value whatever the current active status is
1082
-     * @return string
1083
-     */
1084
-    public function active_status_dropdown($current_value = '')
1085
-    {
1086
-        $select_name = 'active_status';
1087
-        $values = array(
1088
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1089
-            'active'   => esc_html__('Active', 'event_espresso'),
1090
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1091
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1092
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1093
-        );
1094
-
1095
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1096
-    }
1097
-
1098
-
1099
-    /**
1100
-     * returns a list of "venues"
1101
-     *
1102
-     * @param string $current_value whatever the current active status is
1103
-     * @return string
1104
-     * @throws EE_Error
1105
-     * @throws InvalidArgumentException
1106
-     * @throws InvalidDataTypeException
1107
-     * @throws InvalidInterfaceException
1108
-     * @throws ReflectionException
1109
-     */
1110
-    protected function venuesDropdown($current_value = '')
1111
-    {
1112
-        $select_name = 'venue';
1113
-        $values = array(
1114
-            '' => esc_html__('All Venues', 'event_espresso'),
1115
-        );
1116
-        // populate the list of venues.
1117
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1118
-        $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1119
-
1120
-        foreach ($venues as $venue) {
1121
-            $values[ $venue->ID() ] = $venue->name();
1122
-        }
1123
-
1124
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1125
-    }
1126
-
1127
-
1128
-    /**
1129
-     * output a dropdown of the categories for the category filter on the event admin list table
1130
-     *
1131
-     * @access  public
1132
-     * @return string html
1133
-     */
1134
-    public function category_dropdown()
1135
-    {
1136
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1137
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1138
-    }
1139
-
1140
-
1141
-    /**
1142
-     * get total number of events today
1143
-     *
1144
-     * @access public
1145
-     * @return int
1146
-     * @throws EE_Error
1147
-     * @throws InvalidArgumentException
1148
-     * @throws InvalidDataTypeException
1149
-     * @throws InvalidInterfaceException
1150
-     */
1151
-    public function total_events_today()
1152
-    {
1153
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1154
-            'DTT_EVT_start',
1155
-            date('Y-m-d') . ' 00:00:00',
1156
-            'Y-m-d H:i:s',
1157
-            'UTC'
1158
-        );
1159
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1160
-            'DTT_EVT_start',
1161
-            date('Y-m-d') . ' 23:59:59',
1162
-            'Y-m-d H:i:s',
1163
-            'UTC'
1164
-        );
1165
-        $where = array(
1166
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1167
-        );
1168
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1169
-        return $count;
1170
-    }
1171
-
1172
-
1173
-    /**
1174
-     * get total number of events this month
1175
-     *
1176
-     * @access public
1177
-     * @return int
1178
-     * @throws EE_Error
1179
-     * @throws InvalidArgumentException
1180
-     * @throws InvalidDataTypeException
1181
-     * @throws InvalidInterfaceException
1182
-     */
1183
-    public function total_events_this_month()
1184
-    {
1185
-        // Dates
1186
-        $this_year_r = date('Y');
1187
-        $this_month_r = date('m');
1188
-        $days_this_month = date('t');
1189
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1190
-            'DTT_EVT_start',
1191
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1192
-            'Y-m-d H:i:s',
1193
-            'UTC'
1194
-        );
1195
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1196
-            'DTT_EVT_start',
1197
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1198
-            'Y-m-d H:i:s',
1199
-            'UTC'
1200
-        );
1201
-        $where = array(
1202
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1203
-        );
1204
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1205
-        return $count;
1206
-    }
1207
-
1208
-
1209
-    /** DEFAULT TICKETS STUFF **/
1210
-
1211
-    /**
1212
-     * Output default tickets list table view.
1213
-     *
1214
-     * @throws DomainException
1215
-     * @throws EE_Error
1216
-     * @throws InvalidArgumentException
1217
-     * @throws InvalidDataTypeException
1218
-     * @throws InvalidInterfaceException
1219
-     */
1220
-    public function _tickets_overview_list_table()
1221
-    {
1222
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1223
-        $this->display_admin_list_table_page_with_no_sidebar();
1224
-    }
1225
-
1226
-
1227
-    /**
1228
-     * @param int  $per_page
1229
-     * @param bool $count
1230
-     * @param bool $trashed
1231
-     * @return EE_Soft_Delete_Base_Class[]|int
1232
-     * @throws EE_Error
1233
-     * @throws InvalidArgumentException
1234
-     * @throws InvalidDataTypeException
1235
-     * @throws InvalidInterfaceException
1236
-     */
1237
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1238
-    {
1239
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1240
-        $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1241
-        switch ($orderby) {
1242
-            case 'TKT_name':
1243
-                $orderby = array('TKT_name' => $order);
1244
-                break;
1245
-            case 'TKT_price':
1246
-                $orderby = array('TKT_price' => $order);
1247
-                break;
1248
-            case 'TKT_uses':
1249
-                $orderby = array('TKT_uses' => $order);
1250
-                break;
1251
-            case 'TKT_min':
1252
-                $orderby = array('TKT_min' => $order);
1253
-                break;
1254
-            case 'TKT_max':
1255
-                $orderby = array('TKT_max' => $order);
1256
-                break;
1257
-            case 'TKT_qty':
1258
-                $orderby = array('TKT_qty' => $order);
1259
-                break;
1260
-        }
1261
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1262
-            ? $this->_req_data['paged']
1263
-            : 1;
1264
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1265
-            ? $this->_req_data['perpage']
1266
-            : $per_page;
1267
-        $_where = array(
1268
-            'TKT_is_default' => 1,
1269
-            'TKT_deleted'    => $trashed,
1270
-        );
1271
-        $offset = ($current_page - 1) * $per_page;
1272
-        $limit = array($offset, $per_page);
1273
-        if (isset($this->_req_data['s'])) {
1274
-            $sstr = '%' . $this->_req_data['s'] . '%';
1275
-            $_where['OR'] = array(
1276
-                'TKT_name'        => array('LIKE', $sstr),
1277
-                'TKT_description' => array('LIKE', $sstr),
1278
-            );
1279
-        }
1280
-        $query_params = array(
1281
-            $_where,
1282
-            'order_by' => $orderby,
1283
-            'limit'    => $limit,
1284
-            'group_by' => 'TKT_ID',
1285
-        );
1286
-        if ($count) {
1287
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1288
-        } else {
1289
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1290
-        }
1291
-    }
1292
-
1293
-
1294
-    /**
1295
-     * @param bool $trash
1296
-     * @throws EE_Error
1297
-     * @throws InvalidArgumentException
1298
-     * @throws InvalidDataTypeException
1299
-     * @throws InvalidInterfaceException
1300
-     */
1301
-    protected function _trash_or_restore_ticket($trash = false)
1302
-    {
1303
-        $success = 1;
1304
-        $TKT = EEM_Ticket::instance();
1305
-        // checkboxes?
1306
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1307
-            // if array has more than one element then success message should be plural
1308
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1309
-            // cycle thru the boxes
1310
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1311
-                if ($trash) {
1312
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1313
-                        $success = 0;
1314
-                    }
1315
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1316
-                    $success = 0;
1317
-                }
1318
-            }
1319
-        } else {
1320
-            // grab single id and trash
1321
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1322
-            if ($trash) {
1323
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1324
-                    $success = 0;
1325
-                }
1326
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1327
-                $success = 0;
1328
-            }
1329
-        }
1330
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1331
-        $query_args = array(
1332
-            'action' => 'ticket_list_table',
1333
-            'status' => $trash ? '' : 'trashed',
1334
-        );
1335
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * Handles trashing default ticket.
1341
-     *
1342
-     * @throws EE_Error
1343
-     * @throws InvalidArgumentException
1344
-     * @throws InvalidDataTypeException
1345
-     * @throws InvalidInterfaceException
1346
-     * @throws ReflectionException
1347
-     */
1348
-    protected function _delete_ticket()
1349
-    {
1350
-        $success = 1;
1351
-        // checkboxes?
1352
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1353
-            // if array has more than one element then success message should be plural
1354
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1355
-            // cycle thru the boxes
1356
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1357
-                // delete
1358
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1359
-                    $success = 0;
1360
-                }
1361
-            }
1362
-        } else {
1363
-            // grab single id and trash
1364
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1365
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1366
-                $success = 0;
1367
-            }
1368
-        }
1369
-        $action_desc = 'deleted';
1370
-        $query_args = array(
1371
-            'action' => 'ticket_list_table',
1372
-            'status' => 'trashed',
1373
-        );
1374
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1375
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1376
-            array(array('TKT_is_default' => 1)),
1377
-            'TKT_ID',
1378
-            true
1379
-        )
1380
-        ) {
1381
-            $query_args = array();
1382
-        }
1383
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1384
-    }
1385
-
1386
-
1387
-    /**
1388
-     * @param int $TKT_ID
1389
-     * @return bool|int
1390
-     * @throws EE_Error
1391
-     * @throws InvalidArgumentException
1392
-     * @throws InvalidDataTypeException
1393
-     * @throws InvalidInterfaceException
1394
-     * @throws ReflectionException
1395
-     */
1396
-    protected function _delete_the_ticket($TKT_ID)
1397
-    {
1398
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1399
-        $tkt->_remove_relations('Datetime');
1400
-        // delete all related prices first
1401
-        $tkt->delete_related_permanently('Price');
1402
-        return $tkt->delete_permanently();
1403
-    }
20
+	/**
21
+	 * @var AdvancedEditorAdminFormSection
22
+	 */
23
+	protected $advanced_editor_admin_form;
24
+	/**
25
+	 * @var AdvancedEditorEntityData
26
+	 */
27
+	protected $advanced_editor_data;
28
+
29
+
30
+	/**
31
+	 * Extend_Events_Admin_Page constructor.
32
+	 *
33
+	 * @param bool $routing
34
+	 * @throws EE_Error
35
+	 * @throws InvalidArgumentException
36
+	 * @throws InvalidDataTypeException
37
+	 * @throws InvalidInterfaceException
38
+	 * @throws ReflectionException
39
+	 */
40
+	public function __construct($routing = true)
41
+	{
42
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
44
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
45
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
46
+		}
47
+		parent::__construct($routing);
48
+	}
49
+
50
+
51
+	/**
52
+	 * Sets routes.
53
+	 *
54
+	 * @throws EE_Error
55
+	 * @throws InvalidArgumentException
56
+	 * @throws InvalidDataTypeException
57
+	 * @throws InvalidInterfaceException
58
+	 * @since $VID:$
59
+	 */
60
+	protected function _extend_page_config()
61
+	{
62
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
63
+		// is there a evt_id in the request?
64
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
65
+			? $this->_req_data['EVT_ID']
66
+			: 0;
67
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
68
+		// tkt_id?
69
+		$tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
70
+			? $this->_req_data['TKT_ID']
71
+			: 0;
72
+		$new_page_routes = array(
73
+			'duplicate_event'          => array(
74
+				'func'       => '_duplicate_event',
75
+				'capability' => 'ee_edit_event',
76
+				'obj_id'     => $evt_id,
77
+				'noheader'   => true,
78
+			),
79
+			'ticket_list_table'        => array(
80
+				'func'       => '_tickets_overview_list_table',
81
+				'capability' => 'ee_read_default_tickets',
82
+			),
83
+			'trash_ticket'             => array(
84
+				'func'       => '_trash_or_restore_ticket',
85
+				'capability' => 'ee_delete_default_ticket',
86
+				'obj_id'     => $tkt_id,
87
+				'noheader'   => true,
88
+				'args'       => array('trash' => true),
89
+			),
90
+			'trash_tickets'            => array(
91
+				'func'       => '_trash_or_restore_ticket',
92
+				'capability' => 'ee_delete_default_tickets',
93
+				'noheader'   => true,
94
+				'args'       => array('trash' => true),
95
+			),
96
+			'restore_ticket'           => array(
97
+				'func'       => '_trash_or_restore_ticket',
98
+				'capability' => 'ee_delete_default_ticket',
99
+				'obj_id'     => $tkt_id,
100
+				'noheader'   => true,
101
+			),
102
+			'restore_tickets'          => array(
103
+				'func'       => '_trash_or_restore_ticket',
104
+				'capability' => 'ee_delete_default_tickets',
105
+				'noheader'   => true,
106
+			),
107
+			'delete_ticket'            => array(
108
+				'func'       => '_delete_ticket',
109
+				'capability' => 'ee_delete_default_ticket',
110
+				'obj_id'     => $tkt_id,
111
+				'noheader'   => true,
112
+			),
113
+			'delete_tickets'           => array(
114
+				'func'       => '_delete_ticket',
115
+				'capability' => 'ee_delete_default_tickets',
116
+				'noheader'   => true,
117
+			),
118
+			'import_page'              => array(
119
+				'func'       => '_import_page',
120
+				'capability' => 'import',
121
+			),
122
+			'import'                   => array(
123
+				'func'       => '_import_events',
124
+				'capability' => 'import',
125
+				'noheader'   => true,
126
+			),
127
+			'import_events'            => array(
128
+				'func'       => '_import_events',
129
+				'capability' => 'import',
130
+				'noheader'   => true,
131
+			),
132
+			'export_events'            => array(
133
+				'func'       => '_events_export',
134
+				'capability' => 'export',
135
+				'noheader'   => true,
136
+			),
137
+			'export_categories'        => array(
138
+				'func'       => '_categories_export',
139
+				'capability' => 'export',
140
+				'noheader'   => true,
141
+			),
142
+			'sample_export_file'       => array(
143
+				'func'       => '_sample_export_file',
144
+				'capability' => 'export',
145
+				'noheader'   => true,
146
+			),
147
+			'update_template_settings' => array(
148
+				'func'       => '_update_template_settings',
149
+				'capability' => 'manage_options',
150
+				'noheader'   => true,
151
+			),
152
+		);
153
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
154
+		// partial route/config override
155
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
156
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
157
+		$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
158
+		$this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
159
+		$this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
160
+		$this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
161
+		// add tickets tab but only if there are more than one default ticket!
162
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
163
+			array(array('TKT_is_default' => 1)),
164
+			'TKT_ID',
165
+			true
166
+		);
167
+		if ($tkt_count > 1) {
168
+			$new_page_config = array(
169
+				'ticket_list_table' => array(
170
+					'nav'           => array(
171
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
172
+						'order' => 60,
173
+					),
174
+					'list_table'    => 'Tickets_List_Table',
175
+					'require_nonce' => false,
176
+				),
177
+			);
178
+		}
179
+		// template settings
180
+		$new_page_config['template_settings'] = array(
181
+			'nav'           => array(
182
+				'label' => esc_html__('Templates', 'event_espresso'),
183
+				'order' => 30,
184
+			),
185
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
186
+			'help_tabs'     => array(
187
+				'general_settings_templates_help_tab' => array(
188
+					'title'    => esc_html__('Templates', 'event_espresso'),
189
+					'filename' => 'general_settings_templates',
190
+				),
191
+			),
192
+			'help_tour'     => array('Templates_Help_Tour'),
193
+			'require_nonce' => false,
194
+		);
195
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
196
+		// add filters and actions
197
+		// modifying _views
198
+		add_filter(
199
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
200
+			array($this, 'add_additional_datetime_button'),
201
+			10,
202
+			2
203
+		);
204
+		add_filter(
205
+			'FHEE_event_datetime_metabox_clone_button_template',
206
+			array($this, 'add_datetime_clone_button'),
207
+			10,
208
+			2
209
+		);
210
+		add_filter(
211
+			'FHEE_event_datetime_metabox_timezones_template',
212
+			array($this, 'datetime_timezones_template'),
213
+			10,
214
+			2
215
+		);
216
+		// filters for event list table
217
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
218
+		add_filter(
219
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
220
+			array($this, 'extra_list_table_actions'),
221
+			10,
222
+			2
223
+		);
224
+		// legend item
225
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
226
+		add_action('admin_init', array($this, 'admin_init'));
227
+	}
228
+
229
+
230
+	/**
231
+	 * admin_init
232
+	 */
233
+	public function admin_init()
234
+	{
235
+		if (isset($this->_req_data['action'])
236
+			&& (
237
+				$this->_req_data['action'] === 'default_event_settings'
238
+				|| $this->_req_data['action'] === 'update_default_event_settings'
239
+			)
240
+		) {
241
+			$this->advanced_editor_admin_form = $this->loader->getShared(
242
+				'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
243
+			);
244
+		}
245
+		if (isset($this->_req_data['action'])
246
+			&& ( $this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
247
+		) {
248
+			$this->advanced_editor_data = $this->loader->getShared(
249
+				'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData',
250
+				[$this->_cpt_model_obj]
251
+			);
252
+		}
253
+		EE_Registry::$i18n_js_strings = array_merge(
254
+			EE_Registry::$i18n_js_strings,
255
+			array(
256
+				'image_confirm'          => esc_html__(
257
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
258
+					'event_espresso'
259
+				),
260
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
261
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
262
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
263
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
264
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
265
+			)
266
+		);
267
+	}
268
+
269
+
270
+	/**
271
+	 * Add per page screen options to the default ticket list table view.
272
+	 *
273
+	 * @throws InvalidArgumentException
274
+	 * @throws InvalidDataTypeException
275
+	 * @throws InvalidInterfaceException
276
+	 */
277
+	protected function _add_screen_options_ticket_list_table()
278
+	{
279
+		$this->_per_page_screen_option();
280
+	}
281
+
282
+
283
+	/**
284
+	 * @param string $return
285
+	 * @param int    $id
286
+	 * @param string $new_title
287
+	 * @param string $new_slug
288
+	 * @return string
289
+	 */
290
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
291
+	{
292
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
293
+		// make sure this is only when editing
294
+		if (! empty($id)) {
295
+			$href = EE_Admin_Page::add_query_args_and_nonce(
296
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
297
+				$this->_admin_base_url
298
+			);
299
+			$title = esc_attr__('Duplicate Event', 'event_espresso');
300
+			$return .= '<a href="'
301
+					   . $href
302
+					   . '" title="'
303
+					   . $title
304
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
305
+					   . $title
306
+					   . '</a>';
307
+		}
308
+		return $return;
309
+	}
310
+
311
+
312
+	/**
313
+	 * Set the list table views for the default ticket list table view.
314
+	 */
315
+	public function _set_list_table_views_ticket_list_table()
316
+	{
317
+		$this->_views = array(
318
+			'all'     => array(
319
+				'slug'        => 'all',
320
+				'label'       => esc_html__('All', 'event_espresso'),
321
+				'count'       => 0,
322
+				'bulk_action' => array(
323
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
324
+				),
325
+			),
326
+			'trashed' => array(
327
+				'slug'        => 'trashed',
328
+				'label'       => esc_html__('Trash', 'event_espresso'),
329
+				'count'       => 0,
330
+				'bulk_action' => array(
331
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
332
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
333
+				),
334
+			),
335
+		);
336
+	}
337
+
338
+
339
+	/**
340
+	 * Enqueue scripts and styles for the event editor.
341
+	 */
342
+	public function load_scripts_styles_edit()
343
+	{
344
+		wp_register_script(
345
+			'ee-event-editor-heartbeat',
346
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
347
+			array('ee_admin_js', 'heartbeat'),
348
+			EVENT_ESPRESSO_VERSION,
349
+			true
350
+		);
351
+		wp_enqueue_script('ee-accounting');
352
+		// styles
353
+		wp_enqueue_style('espresso-ui-theme');
354
+		wp_enqueue_script('event_editor_js');
355
+		wp_enqueue_script('ee-event-editor-heartbeat');
356
+	}
357
+
358
+
359
+	/**
360
+	 * Returns template for the additional datetime.
361
+	 *
362
+	 * @param $template
363
+	 * @param $template_args
364
+	 * @return mixed
365
+	 * @throws DomainException
366
+	 */
367
+	public function add_additional_datetime_button($template, $template_args)
368
+	{
369
+		return EEH_Template::display_template(
370
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
371
+			$template_args,
372
+			true
373
+		);
374
+	}
375
+
376
+
377
+	/**
378
+	 * Returns the template for cloning a datetime.
379
+	 *
380
+	 * @param $template
381
+	 * @param $template_args
382
+	 * @return mixed
383
+	 * @throws DomainException
384
+	 */
385
+	public function add_datetime_clone_button($template, $template_args)
386
+	{
387
+		return EEH_Template::display_template(
388
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
389
+			$template_args,
390
+			true
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 * Returns the template for datetime timezones.
397
+	 *
398
+	 * @param $template
399
+	 * @param $template_args
400
+	 * @return mixed
401
+	 * @throws DomainException
402
+	 */
403
+	public function datetime_timezones_template($template, $template_args)
404
+	{
405
+		return EEH_Template::display_template(
406
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
407
+			$template_args,
408
+			true
409
+		);
410
+	}
411
+
412
+
413
+	/**
414
+	 * Sets the views for the default list table view.
415
+	 */
416
+	protected function _set_list_table_views_default()
417
+	{
418
+		parent::_set_list_table_views_default();
419
+		$new_views = array(
420
+			'today' => array(
421
+				'slug'        => 'today',
422
+				'label'       => esc_html__('Today', 'event_espresso'),
423
+				'count'       => $this->total_events_today(),
424
+				'bulk_action' => array(
425
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
426
+				),
427
+			),
428
+			'month' => array(
429
+				'slug'        => 'month',
430
+				'label'       => esc_html__('This Month', 'event_espresso'),
431
+				'count'       => $this->total_events_this_month(),
432
+				'bulk_action' => array(
433
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
434
+				),
435
+			),
436
+		);
437
+		$this->_views = array_merge($this->_views, $new_views);
438
+	}
439
+
440
+
441
+	/**
442
+	 * Returns the extra action links for the default list table view.
443
+	 *
444
+	 * @param array    $action_links
445
+	 * @param EE_Event $event
446
+	 * @return array
447
+	 * @throws EE_Error
448
+	 * @throws InvalidArgumentException
449
+	 * @throws InvalidDataTypeException
450
+	 * @throws InvalidInterfaceException
451
+	 * @throws ReflectionException
452
+	 */
453
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
454
+	{
455
+		if (EE_Registry::instance()->CAP->current_user_can(
456
+			'ee_read_registrations',
457
+			'espresso_registrations_reports',
458
+			$event->ID()
459
+		)
460
+		) {
461
+			$reports_query_args = array(
462
+				'action' => 'reports',
463
+				'EVT_ID' => $event->ID(),
464
+			);
465
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
466
+			$action_links[] = '<a href="'
467
+							  . $reports_link
468
+							  . '" title="'
469
+							  . esc_attr__('View Report', 'event_espresso')
470
+							  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
471
+							  . "\n\t";
472
+		}
473
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
474
+			EE_Registry::instance()->load_helper('MSG_Template');
475
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
476
+				'see_notifications_for',
477
+				null,
478
+				array('EVT_ID' => $event->ID())
479
+			);
480
+		}
481
+		return $action_links;
482
+	}
483
+
484
+
485
+	/**
486
+	 * @param $items
487
+	 * @return mixed
488
+	 */
489
+	public function additional_legend_items($items)
490
+	{
491
+		if (EE_Registry::instance()->CAP->current_user_can(
492
+			'ee_read_registrations',
493
+			'espresso_registrations_reports'
494
+		)
495
+		) {
496
+			$items['reports'] = array(
497
+				'class' => 'dashicons dashicons-chart-bar',
498
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
499
+			);
500
+		}
501
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
502
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
503
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
504
+			// (can only use numeric offsets when treating strings as arrays)
505
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
506
+				$items['view_related_messages'] = array(
507
+					'class' => $related_for_icon['css_class'],
508
+					'desc'  => $related_for_icon['label'],
509
+				);
510
+			}
511
+		}
512
+		return $items;
513
+	}
514
+
515
+
516
+	/**
517
+	 * This is the callback method for the duplicate event route
518
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
519
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
520
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
521
+	 * After duplication the redirect is to the new event edit page.
522
+	 *
523
+	 * @return void
524
+	 * @throws EE_Error If EE_Event is not available with given ID
525
+	 * @throws InvalidArgumentException
526
+	 * @throws InvalidDataTypeException
527
+	 * @throws InvalidInterfaceException
528
+	 * @throws ReflectionException
529
+	 * @access protected
530
+	 */
531
+	protected function _duplicate_event()
532
+	{
533
+		// first make sure the ID for the event is in the request.
534
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
535
+		if (! isset($this->_req_data['EVT_ID'])) {
536
+			EE_Error::add_error(
537
+				esc_html__(
538
+					'In order to duplicate an event an Event ID is required.  None was given.',
539
+					'event_espresso'
540
+				),
541
+				__FILE__,
542
+				__FUNCTION__,
543
+				__LINE__
544
+			);
545
+			$this->_redirect_after_action(false, '', '', array(), true);
546
+			return;
547
+		}
548
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
549
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
550
+		if (! $orig_event instanceof EE_Event) {
551
+			throw new EE_Error(
552
+				sprintf(
553
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
554
+					$this->_req_data['EVT_ID']
555
+				)
556
+			);
557
+		}
558
+		// k now let's clone the $orig_event before getting relations
559
+		$new_event = clone $orig_event;
560
+		// original datetimes
561
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
562
+		// other original relations
563
+		$orig_ven = $orig_event->get_many_related('Venue');
564
+		// reset the ID and modify other details to make it clear this is a dupe
565
+		$new_event->set('EVT_ID', 0);
566
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
567
+		$new_event->set('EVT_name', $new_name);
568
+		$new_event->set(
569
+			'EVT_slug',
570
+			wp_unique_post_slug(
571
+				sanitize_title($orig_event->name()),
572
+				0,
573
+				'publish',
574
+				'espresso_events',
575
+				0
576
+			)
577
+		);
578
+		$new_event->set('status', 'draft');
579
+		// duplicate discussion settings
580
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
581
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
582
+		// save the new event
583
+		$new_event->save();
584
+		// venues
585
+		foreach ($orig_ven as $ven) {
586
+			$new_event->_add_relation_to($ven, 'Venue');
587
+		}
588
+		$new_event->save();
589
+		// now we need to get the question group relations and handle that
590
+		// first primary question groups
591
+		$orig_primary_qgs = $orig_event->get_many_related(
592
+			'Question_Group',
593
+			[['Event_Question_Group.EQG_primary' => true]]
594
+		);
595
+		if (! empty($orig_primary_qgs)) {
596
+			foreach ($orig_primary_qgs as $id => $obj) {
597
+				if ($obj instanceof EE_Question_Group) {
598
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
599
+				}
600
+			}
601
+		}
602
+		// next additional attendee question groups
603
+		$orig_additional_qgs = $orig_event->get_many_related(
604
+			'Question_Group',
605
+			[['Event_Question_Group.EQG_additional' => true]]
606
+		);
607
+		if (! empty($orig_additional_qgs)) {
608
+			foreach ($orig_additional_qgs as $id => $obj) {
609
+				if ($obj instanceof EE_Question_Group) {
610
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
611
+				}
612
+			}
613
+		}
614
+
615
+		$new_event->save();
616
+
617
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
618
+		$cloned_tickets = array();
619
+		foreach ($orig_datetimes as $orig_dtt) {
620
+			if (! $orig_dtt instanceof EE_Datetime) {
621
+				continue;
622
+			}
623
+			$new_dtt = clone $orig_dtt;
624
+			$orig_tkts = $orig_dtt->tickets();
625
+			// save new dtt then add to event
626
+			$new_dtt->set('DTT_ID', 0);
627
+			$new_dtt->set('DTT_sold', 0);
628
+			$new_dtt->set_reserved(0);
629
+			$new_dtt->save();
630
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
631
+			$new_event->save();
632
+			// now let's get the ticket relations setup.
633
+			foreach ((array) $orig_tkts as $orig_tkt) {
634
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
635
+				if (! $orig_tkt instanceof EE_Ticket) {
636
+					continue;
637
+				}
638
+				// is this ticket archived?  If it is then let's skip
639
+				if ($orig_tkt->get('TKT_deleted')) {
640
+					continue;
641
+				}
642
+				// does this original ticket already exist in the clone_tickets cache?
643
+				//  If so we'll just use the new ticket from it.
644
+				if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
645
+					$new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
646
+				} else {
647
+					$new_tkt = clone $orig_tkt;
648
+					// get relations on the $orig_tkt that we need to setup.
649
+					$orig_prices = $orig_tkt->prices();
650
+					$new_tkt->set('TKT_ID', 0);
651
+					$new_tkt->set('TKT_sold', 0);
652
+					$new_tkt->set('TKT_reserved', 0);
653
+					$new_tkt->save(); // make sure new ticket has ID.
654
+					// price relations on new ticket need to be setup.
655
+					foreach ($orig_prices as $orig_price) {
656
+						$new_price = clone $orig_price;
657
+						$new_price->set('PRC_ID', 0);
658
+						$new_price->save();
659
+						$new_tkt->_add_relation_to($new_price, 'Price');
660
+						$new_tkt->save();
661
+					}
662
+
663
+					do_action(
664
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
665
+						$orig_tkt,
666
+						$new_tkt,
667
+						$orig_prices,
668
+						$orig_event,
669
+						$orig_dtt,
670
+						$new_dtt
671
+					);
672
+				}
673
+				// k now we can add the new ticket as a relation to the new datetime
674
+				// and make sure its added to our cached $cloned_tickets array
675
+				// for use with later datetimes that have the same ticket.
676
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
677
+				$new_dtt->save();
678
+				$cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
679
+			}
680
+		}
681
+		// clone taxonomy information
682
+		$taxonomies_to_clone_with = apply_filters(
683
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
684
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
685
+		);
686
+		// get terms for original event (notice)
687
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
688
+		// loop through terms and add them to new event.
689
+		foreach ($orig_terms as $term) {
690
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
691
+		}
692
+
693
+		// duplicate other core WP_Post items for this event.
694
+		// post thumbnail (feature image).
695
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
696
+		if ($feature_image_id) {
697
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
698
+		}
699
+
700
+		// duplicate page_template setting
701
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
702
+		if ($page_template) {
703
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
704
+		}
705
+
706
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
707
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
708
+		if ($new_event->ID()) {
709
+			$redirect_args = array(
710
+				'post'   => $new_event->ID(),
711
+				'action' => 'edit',
712
+			);
713
+			EE_Error::add_success(
714
+				esc_html__(
715
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
716
+					'event_espresso'
717
+				)
718
+			);
719
+		} else {
720
+			$redirect_args = array(
721
+				'action' => 'default',
722
+			);
723
+			EE_Error::add_error(
724
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
725
+				__FILE__,
726
+				__FUNCTION__,
727
+				__LINE__
728
+			);
729
+		}
730
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
731
+	}
732
+
733
+
734
+	/**
735
+	 * Generates output for the import page.
736
+	 *
737
+	 * @throws DomainException
738
+	 * @throws EE_Error
739
+	 * @throws InvalidArgumentException
740
+	 * @throws InvalidDataTypeException
741
+	 * @throws InvalidInterfaceException
742
+	 */
743
+	protected function _import_page()
744
+	{
745
+		$title = esc_html__('Import', 'event_espresso');
746
+		$intro = esc_html__(
747
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
748
+			'event_espresso'
749
+		);
750
+		$form_url = EVENTS_ADMIN_URL;
751
+		$action = 'import_events';
752
+		$type = 'csv';
753
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
754
+			$title,
755
+			$intro,
756
+			$form_url,
757
+			$action,
758
+			$type
759
+		);
760
+		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
761
+			array('action' => 'sample_export_file'),
762
+			$this->_admin_base_url
763
+		);
764
+		$content = EEH_Template::display_template(
765
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
766
+			$this->_template_args,
767
+			true
768
+		);
769
+		$this->_template_args['admin_page_content'] = $content;
770
+		$this->display_admin_page_with_sidebar();
771
+	}
772
+
773
+
774
+	/**
775
+	 * _import_events
776
+	 * This handles displaying the screen and running imports for importing events.
777
+	 *
778
+	 * @return void
779
+	 * @throws EE_Error
780
+	 * @throws InvalidArgumentException
781
+	 * @throws InvalidDataTypeException
782
+	 * @throws InvalidInterfaceException
783
+	 */
784
+	protected function _import_events()
785
+	{
786
+		require_once(EE_CLASSES . 'EE_Import.class.php');
787
+		$success = EE_Import::instance()->import();
788
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
789
+	}
790
+
791
+
792
+	/**
793
+	 * _events_export
794
+	 * Will export all (or just the given event) to a Excel compatible file.
795
+	 *
796
+	 * @access protected
797
+	 * @return void
798
+	 */
799
+	protected function _events_export()
800
+	{
801
+		if (isset($this->_req_data['EVT_ID'])) {
802
+			$event_ids = $this->_req_data['EVT_ID'];
803
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
804
+			$event_ids = $this->_req_data['EVT_IDs'];
805
+		} else {
806
+			$event_ids = null;
807
+		}
808
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
809
+		$new_request_args = array(
810
+			'export' => 'report',
811
+			'action' => 'all_event_data',
812
+			'EVT_ID' => $event_ids,
813
+		);
814
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
815
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
816
+			require_once(EE_CLASSES . 'EE_Export.class.php');
817
+			$EE_Export = EE_Export::instance($this->_req_data);
818
+			$EE_Export->export();
819
+		}
820
+	}
821
+
822
+
823
+	/**
824
+	 * handle category exports()
825
+	 *
826
+	 * @return void
827
+	 */
828
+	protected function _categories_export()
829
+	{
830
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
831
+		$new_request_args = array(
832
+			'export'       => 'report',
833
+			'action'       => 'categories',
834
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
835
+		);
836
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
837
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
838
+			require_once(EE_CLASSES . 'EE_Export.class.php');
839
+			$EE_Export = EE_Export::instance($this->_req_data);
840
+			$EE_Export->export();
841
+		}
842
+	}
843
+
844
+
845
+	/**
846
+	 * Creates a sample CSV file for importing
847
+	 */
848
+	protected function _sample_export_file()
849
+	{
850
+		// require_once(EE_CLASSES . 'EE_Export.class.php');
851
+		EE_Export::instance()->export_sample();
852
+	}
853
+
854
+
855
+	/*************        Template Settings        *************/
856
+	/**
857
+	 * Generates template settings page output
858
+	 *
859
+	 * @throws DomainException
860
+	 * @throws EE_Error
861
+	 * @throws InvalidArgumentException
862
+	 * @throws InvalidDataTypeException
863
+	 * @throws InvalidInterfaceException
864
+	 */
865
+	protected function _template_settings()
866
+	{
867
+		$this->_template_args['values'] = $this->_yes_no_values;
868
+		/**
869
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
870
+		 * from General_Settings_Admin_Page to here.
871
+		 */
872
+		$this->_template_args = apply_filters(
873
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
874
+			$this->_template_args
875
+		);
876
+		$this->_set_add_edit_form_tags('update_template_settings');
877
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
878
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
879
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
880
+			$this->_template_args,
881
+			true
882
+		);
883
+		$this->display_admin_page_with_sidebar();
884
+	}
885
+
886
+
887
+	/**
888
+	 * Handler for updating template settings.
889
+	 *
890
+	 * @throws EE_Error
891
+	 * @throws InvalidArgumentException
892
+	 * @throws InvalidDataTypeException
893
+	 * @throws InvalidInterfaceException
894
+	 */
895
+	protected function _update_template_settings()
896
+	{
897
+		/**
898
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
899
+		 * from General_Settings_Admin_Page to here.
900
+		 */
901
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
902
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
903
+			EE_Registry::instance()->CFG->template_settings,
904
+			$this->_req_data
905
+		);
906
+		// update custom post type slugs and detect if we need to flush rewrite rules
907
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
908
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
909
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
910
+			: EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
911
+		$what = 'Template Settings';
912
+		$success = $this->_update_espresso_configuration(
913
+			$what,
914
+			EE_Registry::instance()->CFG->template_settings,
915
+			__FILE__,
916
+			__FUNCTION__,
917
+			__LINE__
918
+		);
919
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
920
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
921
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
922
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
923
+			);
924
+			$rewrite_rules->flush();
925
+		}
926
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
927
+	}
928
+
929
+
930
+	/**
931
+	 * _premium_event_editor_meta_boxes
932
+	 * add all metaboxes related to the event_editor
933
+	 *
934
+	 * @access protected
935
+	 * @return void
936
+	 * @throws EE_Error
937
+	 * @throws InvalidArgumentException
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws InvalidInterfaceException
940
+	 * @throws ReflectionException
941
+	 */
942
+	protected function _premium_event_editor_meta_boxes()
943
+	{
944
+		$this->verify_cpt_object();
945
+		add_meta_box(
946
+			'espresso_event_editor_event_options',
947
+			esc_html__('Event Registration Options', 'event_espresso'),
948
+			array($this, 'registration_options_meta_box'),
949
+			$this->page_slug,
950
+			'side',
951
+			'core'
952
+		);
953
+	}
954
+
955
+
956
+	/**
957
+	 * override caf metabox
958
+	 *
959
+	 * @return void
960
+	 * @throws DomainException
961
+	 * @throws EE_Error
962
+	 */
963
+	public function registration_options_meta_box()
964
+	{
965
+		$yes_no_values = array(
966
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
967
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
968
+		);
969
+		$default_reg_status_values = EEM_Registration::reg_status_array(
970
+			array(
971
+				EEM_Registration::status_id_cancelled,
972
+				EEM_Registration::status_id_declined,
973
+				EEM_Registration::status_id_incomplete,
974
+				EEM_Registration::status_id_wait_list,
975
+			),
976
+			true
977
+		);
978
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
979
+		$template_args['_event'] = $this->_cpt_model_obj;
980
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
981
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
982
+			'default_reg_status',
983
+			$default_reg_status_values,
984
+			$this->_cpt_model_obj->default_registration_status()
985
+		);
986
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
987
+			'display_desc',
988
+			$yes_no_values,
989
+			$this->_cpt_model_obj->display_description()
990
+		);
991
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
992
+			'display_ticket_selector',
993
+			$yes_no_values,
994
+			$this->_cpt_model_obj->display_ticket_selector(),
995
+			'',
996
+			'',
997
+			false
998
+		);
999
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1000
+			'EVT_default_registration_status',
1001
+			$default_reg_status_values,
1002
+			$this->_cpt_model_obj->default_registration_status()
1003
+		);
1004
+		$template_args['additional_registration_options'] = apply_filters(
1005
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1006
+			'',
1007
+			$template_args,
1008
+			$yes_no_values,
1009
+			$default_reg_status_values
1010
+		);
1011
+		EEH_Template::display_template(
1012
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1013
+			$template_args
1014
+		);
1015
+	}
1016
+
1017
+
1018
+
1019
+	/**
1020
+	 * wp_list_table_mods for caf
1021
+	 * ============================
1022
+	 */
1023
+	/**
1024
+	 * hook into list table filters and provide filters for caffeinated list table
1025
+	 *
1026
+	 * @param array $old_filters    any existing filters present
1027
+	 * @param array $list_table_obj the list table object
1028
+	 * @return array                  new filters
1029
+	 * @throws EE_Error
1030
+	 * @throws InvalidArgumentException
1031
+	 * @throws InvalidDataTypeException
1032
+	 * @throws InvalidInterfaceException
1033
+	 * @throws ReflectionException
1034
+	 */
1035
+	public function list_table_filters($old_filters, $list_table_obj)
1036
+	{
1037
+		$filters = array();
1038
+		// first month/year filters
1039
+		$filters[] = $this->espresso_event_months_dropdown();
1040
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1041
+		// active status dropdown
1042
+		if ($status !== 'draft') {
1043
+			$filters[] = $this->active_status_dropdown(
1044
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1045
+			);
1046
+			$filters[] = $this->venuesDropdown(
1047
+				isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1048
+			);
1049
+		}
1050
+		// category filter
1051
+		$filters[] = $this->category_dropdown();
1052
+		return array_merge($old_filters, $filters);
1053
+	}
1054
+
1055
+
1056
+	/**
1057
+	 * espresso_event_months_dropdown
1058
+	 *
1059
+	 * @access public
1060
+	 * @return string                dropdown listing month/year selections for events.
1061
+	 */
1062
+	public function espresso_event_months_dropdown()
1063
+	{
1064
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1065
+		// Note we need to include any other filters that are set!
1066
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1067
+		// categories?
1068
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1069
+			? $this->_req_data['EVT_CAT']
1070
+			: null;
1071
+		// active status?
1072
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1073
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1074
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1075
+	}
1076
+
1077
+
1078
+	/**
1079
+	 * returns a list of "active" statuses on the event
1080
+	 *
1081
+	 * @param  string $current_value whatever the current active status is
1082
+	 * @return string
1083
+	 */
1084
+	public function active_status_dropdown($current_value = '')
1085
+	{
1086
+		$select_name = 'active_status';
1087
+		$values = array(
1088
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1089
+			'active'   => esc_html__('Active', 'event_espresso'),
1090
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1091
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1092
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1093
+		);
1094
+
1095
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1096
+	}
1097
+
1098
+
1099
+	/**
1100
+	 * returns a list of "venues"
1101
+	 *
1102
+	 * @param string $current_value whatever the current active status is
1103
+	 * @return string
1104
+	 * @throws EE_Error
1105
+	 * @throws InvalidArgumentException
1106
+	 * @throws InvalidDataTypeException
1107
+	 * @throws InvalidInterfaceException
1108
+	 * @throws ReflectionException
1109
+	 */
1110
+	protected function venuesDropdown($current_value = '')
1111
+	{
1112
+		$select_name = 'venue';
1113
+		$values = array(
1114
+			'' => esc_html__('All Venues', 'event_espresso'),
1115
+		);
1116
+		// populate the list of venues.
1117
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1118
+		$venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1119
+
1120
+		foreach ($venues as $venue) {
1121
+			$values[ $venue->ID() ] = $venue->name();
1122
+		}
1123
+
1124
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1125
+	}
1126
+
1127
+
1128
+	/**
1129
+	 * output a dropdown of the categories for the category filter on the event admin list table
1130
+	 *
1131
+	 * @access  public
1132
+	 * @return string html
1133
+	 */
1134
+	public function category_dropdown()
1135
+	{
1136
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1137
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1138
+	}
1139
+
1140
+
1141
+	/**
1142
+	 * get total number of events today
1143
+	 *
1144
+	 * @access public
1145
+	 * @return int
1146
+	 * @throws EE_Error
1147
+	 * @throws InvalidArgumentException
1148
+	 * @throws InvalidDataTypeException
1149
+	 * @throws InvalidInterfaceException
1150
+	 */
1151
+	public function total_events_today()
1152
+	{
1153
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1154
+			'DTT_EVT_start',
1155
+			date('Y-m-d') . ' 00:00:00',
1156
+			'Y-m-d H:i:s',
1157
+			'UTC'
1158
+		);
1159
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1160
+			'DTT_EVT_start',
1161
+			date('Y-m-d') . ' 23:59:59',
1162
+			'Y-m-d H:i:s',
1163
+			'UTC'
1164
+		);
1165
+		$where = array(
1166
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1167
+		);
1168
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1169
+		return $count;
1170
+	}
1171
+
1172
+
1173
+	/**
1174
+	 * get total number of events this month
1175
+	 *
1176
+	 * @access public
1177
+	 * @return int
1178
+	 * @throws EE_Error
1179
+	 * @throws InvalidArgumentException
1180
+	 * @throws InvalidDataTypeException
1181
+	 * @throws InvalidInterfaceException
1182
+	 */
1183
+	public function total_events_this_month()
1184
+	{
1185
+		// Dates
1186
+		$this_year_r = date('Y');
1187
+		$this_month_r = date('m');
1188
+		$days_this_month = date('t');
1189
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1190
+			'DTT_EVT_start',
1191
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1192
+			'Y-m-d H:i:s',
1193
+			'UTC'
1194
+		);
1195
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1196
+			'DTT_EVT_start',
1197
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1198
+			'Y-m-d H:i:s',
1199
+			'UTC'
1200
+		);
1201
+		$where = array(
1202
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1203
+		);
1204
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1205
+		return $count;
1206
+	}
1207
+
1208
+
1209
+	/** DEFAULT TICKETS STUFF **/
1210
+
1211
+	/**
1212
+	 * Output default tickets list table view.
1213
+	 *
1214
+	 * @throws DomainException
1215
+	 * @throws EE_Error
1216
+	 * @throws InvalidArgumentException
1217
+	 * @throws InvalidDataTypeException
1218
+	 * @throws InvalidInterfaceException
1219
+	 */
1220
+	public function _tickets_overview_list_table()
1221
+	{
1222
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1223
+		$this->display_admin_list_table_page_with_no_sidebar();
1224
+	}
1225
+
1226
+
1227
+	/**
1228
+	 * @param int  $per_page
1229
+	 * @param bool $count
1230
+	 * @param bool $trashed
1231
+	 * @return EE_Soft_Delete_Base_Class[]|int
1232
+	 * @throws EE_Error
1233
+	 * @throws InvalidArgumentException
1234
+	 * @throws InvalidDataTypeException
1235
+	 * @throws InvalidInterfaceException
1236
+	 */
1237
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1238
+	{
1239
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1240
+		$order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1241
+		switch ($orderby) {
1242
+			case 'TKT_name':
1243
+				$orderby = array('TKT_name' => $order);
1244
+				break;
1245
+			case 'TKT_price':
1246
+				$orderby = array('TKT_price' => $order);
1247
+				break;
1248
+			case 'TKT_uses':
1249
+				$orderby = array('TKT_uses' => $order);
1250
+				break;
1251
+			case 'TKT_min':
1252
+				$orderby = array('TKT_min' => $order);
1253
+				break;
1254
+			case 'TKT_max':
1255
+				$orderby = array('TKT_max' => $order);
1256
+				break;
1257
+			case 'TKT_qty':
1258
+				$orderby = array('TKT_qty' => $order);
1259
+				break;
1260
+		}
1261
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1262
+			? $this->_req_data['paged']
1263
+			: 1;
1264
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1265
+			? $this->_req_data['perpage']
1266
+			: $per_page;
1267
+		$_where = array(
1268
+			'TKT_is_default' => 1,
1269
+			'TKT_deleted'    => $trashed,
1270
+		);
1271
+		$offset = ($current_page - 1) * $per_page;
1272
+		$limit = array($offset, $per_page);
1273
+		if (isset($this->_req_data['s'])) {
1274
+			$sstr = '%' . $this->_req_data['s'] . '%';
1275
+			$_where['OR'] = array(
1276
+				'TKT_name'        => array('LIKE', $sstr),
1277
+				'TKT_description' => array('LIKE', $sstr),
1278
+			);
1279
+		}
1280
+		$query_params = array(
1281
+			$_where,
1282
+			'order_by' => $orderby,
1283
+			'limit'    => $limit,
1284
+			'group_by' => 'TKT_ID',
1285
+		);
1286
+		if ($count) {
1287
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1288
+		} else {
1289
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1290
+		}
1291
+	}
1292
+
1293
+
1294
+	/**
1295
+	 * @param bool $trash
1296
+	 * @throws EE_Error
1297
+	 * @throws InvalidArgumentException
1298
+	 * @throws InvalidDataTypeException
1299
+	 * @throws InvalidInterfaceException
1300
+	 */
1301
+	protected function _trash_or_restore_ticket($trash = false)
1302
+	{
1303
+		$success = 1;
1304
+		$TKT = EEM_Ticket::instance();
1305
+		// checkboxes?
1306
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1307
+			// if array has more than one element then success message should be plural
1308
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1309
+			// cycle thru the boxes
1310
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1311
+				if ($trash) {
1312
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1313
+						$success = 0;
1314
+					}
1315
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1316
+					$success = 0;
1317
+				}
1318
+			}
1319
+		} else {
1320
+			// grab single id and trash
1321
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1322
+			if ($trash) {
1323
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1324
+					$success = 0;
1325
+				}
1326
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1327
+				$success = 0;
1328
+			}
1329
+		}
1330
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1331
+		$query_args = array(
1332
+			'action' => 'ticket_list_table',
1333
+			'status' => $trash ? '' : 'trashed',
1334
+		);
1335
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * Handles trashing default ticket.
1341
+	 *
1342
+	 * @throws EE_Error
1343
+	 * @throws InvalidArgumentException
1344
+	 * @throws InvalidDataTypeException
1345
+	 * @throws InvalidInterfaceException
1346
+	 * @throws ReflectionException
1347
+	 */
1348
+	protected function _delete_ticket()
1349
+	{
1350
+		$success = 1;
1351
+		// checkboxes?
1352
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1353
+			// if array has more than one element then success message should be plural
1354
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1355
+			// cycle thru the boxes
1356
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1357
+				// delete
1358
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1359
+					$success = 0;
1360
+				}
1361
+			}
1362
+		} else {
1363
+			// grab single id and trash
1364
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1365
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1366
+				$success = 0;
1367
+			}
1368
+		}
1369
+		$action_desc = 'deleted';
1370
+		$query_args = array(
1371
+			'action' => 'ticket_list_table',
1372
+			'status' => 'trashed',
1373
+		);
1374
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1375
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1376
+			array(array('TKT_is_default' => 1)),
1377
+			'TKT_ID',
1378
+			true
1379
+		)
1380
+		) {
1381
+			$query_args = array();
1382
+		}
1383
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1384
+	}
1385
+
1386
+
1387
+	/**
1388
+	 * @param int $TKT_ID
1389
+	 * @return bool|int
1390
+	 * @throws EE_Error
1391
+	 * @throws InvalidArgumentException
1392
+	 * @throws InvalidDataTypeException
1393
+	 * @throws InvalidInterfaceException
1394
+	 * @throws ReflectionException
1395
+	 */
1396
+	protected function _delete_the_ticket($TKT_ID)
1397
+	{
1398
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1399
+		$tkt->_remove_relations('Datetime');
1400
+		// delete all related prices first
1401
+		$tkt->delete_related_permanently('Price');
1402
+		return $tkt->delete_permanently();
1403
+	}
1404 1404
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function __construct($routing = true)
41 41
     {
42
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
44
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
45
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
42
+        if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
+            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
44
+            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
45
+            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
46 46
         }
47 47
         parent::__construct($routing);
48 48
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     protected function _extend_page_config()
61 61
     {
62
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
62
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
63 63
         // is there a evt_id in the request?
64 64
         $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
65 65
             ? $this->_req_data['EVT_ID']
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             );
244 244
         }
245 245
         if (isset($this->_req_data['action'])
246
-            && ( $this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
246
+            && ($this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
247 247
         ) {
248 248
             $this->advanced_editor_data = $this->loader->getShared(
249 249
                 'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData',
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     {
292 292
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
293 293
         // make sure this is only when editing
294
-        if (! empty($id)) {
294
+        if ( ! empty($id)) {
295 295
             $href = EE_Admin_Page::add_query_args_and_nonce(
296 296
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
297 297
                 $this->_admin_base_url
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     {
344 344
         wp_register_script(
345 345
             'ee-event-editor-heartbeat',
346
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
346
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
347 347
             array('ee_admin_js', 'heartbeat'),
348 348
             EVENT_ESPRESSO_VERSION,
349 349
             true
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     public function add_additional_datetime_button($template, $template_args)
368 368
     {
369 369
         return EEH_Template::display_template(
370
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
370
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
371 371
             $template_args,
372 372
             true
373 373
         );
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     public function add_datetime_clone_button($template, $template_args)
386 386
     {
387 387
         return EEH_Template::display_template(
388
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
388
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
389 389
             $template_args,
390 390
             true
391 391
         );
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     public function datetime_timezones_template($template, $template_args)
404 404
     {
405 405
         return EEH_Template::display_template(
406
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
406
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
407 407
             $template_args,
408 408
             true
409 409
         );
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     {
533 533
         // first make sure the ID for the event is in the request.
534 534
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
535
-        if (! isset($this->_req_data['EVT_ID'])) {
535
+        if ( ! isset($this->_req_data['EVT_ID'])) {
536 536
             EE_Error::add_error(
537 537
                 esc_html__(
538 538
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
         }
548 548
         // k we've got EVT_ID so let's use that to get the event we'll duplicate
549 549
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
550
-        if (! $orig_event instanceof EE_Event) {
550
+        if ( ! $orig_event instanceof EE_Event) {
551 551
             throw new EE_Error(
552 552
                 sprintf(
553 553
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
         $orig_ven = $orig_event->get_many_related('Venue');
564 564
         // reset the ID and modify other details to make it clear this is a dupe
565 565
         $new_event->set('EVT_ID', 0);
566
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
566
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
567 567
         $new_event->set('EVT_name', $new_name);
568 568
         $new_event->set(
569 569
             'EVT_slug',
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
             'Question_Group',
593 593
             [['Event_Question_Group.EQG_primary' => true]]
594 594
         );
595
-        if (! empty($orig_primary_qgs)) {
595
+        if ( ! empty($orig_primary_qgs)) {
596 596
             foreach ($orig_primary_qgs as $id => $obj) {
597 597
                 if ($obj instanceof EE_Question_Group) {
598 598
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
             'Question_Group',
605 605
             [['Event_Question_Group.EQG_additional' => true]]
606 606
         );
607
-        if (! empty($orig_additional_qgs)) {
607
+        if ( ! empty($orig_additional_qgs)) {
608 608
             foreach ($orig_additional_qgs as $id => $obj) {
609 609
                 if ($obj instanceof EE_Question_Group) {
610 610
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
         // k now that we have the new event saved we can loop through the datetimes and start adding relations.
618 618
         $cloned_tickets = array();
619 619
         foreach ($orig_datetimes as $orig_dtt) {
620
-            if (! $orig_dtt instanceof EE_Datetime) {
620
+            if ( ! $orig_dtt instanceof EE_Datetime) {
621 621
                 continue;
622 622
             }
623 623
             $new_dtt = clone $orig_dtt;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             // now let's get the ticket relations setup.
633 633
             foreach ((array) $orig_tkts as $orig_tkt) {
634 634
                 // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
635
-                if (! $orig_tkt instanceof EE_Ticket) {
635
+                if ( ! $orig_tkt instanceof EE_Ticket) {
636 636
                     continue;
637 637
                 }
638 638
                 // is this ticket archived?  If it is then let's skip
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
                 }
642 642
                 // does this original ticket already exist in the clone_tickets cache?
643 643
                 //  If so we'll just use the new ticket from it.
644
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
645
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
644
+                if (isset($cloned_tickets[$orig_tkt->ID()])) {
645
+                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
646 646
                 } else {
647 647
                     $new_tkt = clone $orig_tkt;
648 648
                     // get relations on the $orig_tkt that we need to setup.
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
                 // for use with later datetimes that have the same ticket.
676 676
                 $new_dtt->_add_relation_to($new_tkt, 'Ticket');
677 677
                 $new_dtt->save();
678
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
678
+                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
679 679
             }
680 680
         }
681 681
         // clone taxonomy information
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
             $this->_admin_base_url
763 763
         );
764 764
         $content = EEH_Template::display_template(
765
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
765
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
766 766
             $this->_template_args,
767 767
             true
768 768
         );
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
      */
784 784
     protected function _import_events()
785 785
     {
786
-        require_once(EE_CLASSES . 'EE_Import.class.php');
786
+        require_once(EE_CLASSES.'EE_Import.class.php');
787 787
         $success = EE_Import::instance()->import();
788 788
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
789 789
     }
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
             'EVT_ID' => $event_ids,
813 813
         );
814 814
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
815
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
816
-            require_once(EE_CLASSES . 'EE_Export.class.php');
815
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
816
+            require_once(EE_CLASSES.'EE_Export.class.php');
817 817
             $EE_Export = EE_Export::instance($this->_req_data);
818 818
             $EE_Export->export();
819 819
         }
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
835 835
         );
836 836
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
837
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
838
-            require_once(EE_CLASSES . 'EE_Export.class.php');
837
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
838
+            require_once(EE_CLASSES.'EE_Export.class.php');
839 839
             $EE_Export = EE_Export::instance($this->_req_data);
840 840
             $EE_Export->export();
841 841
         }
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
         $this->_set_add_edit_form_tags('update_template_settings');
877 877
         $this->_set_publish_post_box_vars(null, false, false, null, false);
878 878
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
879
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
879
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
880 880
             $this->_template_args,
881 881
             true
882 882
         );
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
             $default_reg_status_values
1010 1010
         );
1011 1011
         EEH_Template::display_template(
1012
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1012
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
1013 1013
             $template_args
1014 1014
         );
1015 1015
     }
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
         $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1119 1119
 
1120 1120
         foreach ($venues as $venue) {
1121
-            $values[ $venue->ID() ] = $venue->name();
1121
+            $values[$venue->ID()] = $venue->name();
1122 1122
         }
1123 1123
 
1124 1124
         return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
@@ -1152,13 +1152,13 @@  discard block
 block discarded – undo
1152 1152
     {
1153 1153
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1154 1154
             'DTT_EVT_start',
1155
-            date('Y-m-d') . ' 00:00:00',
1155
+            date('Y-m-d').' 00:00:00',
1156 1156
             'Y-m-d H:i:s',
1157 1157
             'UTC'
1158 1158
         );
1159 1159
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1160 1160
             'DTT_EVT_start',
1161
-            date('Y-m-d') . ' 23:59:59',
1161
+            date('Y-m-d').' 23:59:59',
1162 1162
             'Y-m-d H:i:s',
1163 1163
             'UTC'
1164 1164
         );
@@ -1188,13 +1188,13 @@  discard block
 block discarded – undo
1188 1188
         $days_this_month = date('t');
1189 1189
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1190 1190
             'DTT_EVT_start',
1191
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1191
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1192 1192
             'Y-m-d H:i:s',
1193 1193
             'UTC'
1194 1194
         );
1195 1195
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1196 1196
             'DTT_EVT_start',
1197
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1197
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1198 1198
             'Y-m-d H:i:s',
1199 1199
             'UTC'
1200 1200
         );
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
         $offset = ($current_page - 1) * $per_page;
1272 1272
         $limit = array($offset, $per_page);
1273 1273
         if (isset($this->_req_data['s'])) {
1274
-            $sstr = '%' . $this->_req_data['s'] . '%';
1274
+            $sstr = '%'.$this->_req_data['s'].'%';
1275 1275
             $_where['OR'] = array(
1276 1276
                 'TKT_name'        => array('LIKE', $sstr),
1277 1277
                 'TKT_description' => array('LIKE', $sstr),
@@ -1303,16 +1303,16 @@  discard block
 block discarded – undo
1303 1303
         $success = 1;
1304 1304
         $TKT = EEM_Ticket::instance();
1305 1305
         // checkboxes?
1306
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1306
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1307 1307
             // if array has more than one element then success message should be plural
1308 1308
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1309 1309
             // cycle thru the boxes
1310 1310
             foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1311 1311
                 if ($trash) {
1312
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1312
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1313 1313
                         $success = 0;
1314 1314
                     }
1315
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1315
+                } elseif ( ! $TKT->restore_by_ID($TKT_ID)) {
1316 1316
                     $success = 0;
1317 1317
                 }
1318 1318
             }
@@ -1320,10 +1320,10 @@  discard block
 block discarded – undo
1320 1320
             // grab single id and trash
1321 1321
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1322 1322
             if ($trash) {
1323
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1323
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1324 1324
                     $success = 0;
1325 1325
                 }
1326
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1326
+            } elseif ( ! $TKT->restore_by_ID($TKT_ID)) {
1327 1327
                 $success = 0;
1328 1328
             }
1329 1329
         }
@@ -1349,20 +1349,20 @@  discard block
 block discarded – undo
1349 1349
     {
1350 1350
         $success = 1;
1351 1351
         // checkboxes?
1352
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1352
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1353 1353
             // if array has more than one element then success message should be plural
1354 1354
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1355 1355
             // cycle thru the boxes
1356 1356
             foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1357 1357
                 // delete
1358
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1358
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1359 1359
                     $success = 0;
1360 1360
                 }
1361 1361
             }
1362 1362
         } else {
1363 1363
             // grab single id and trash
1364 1364
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1365
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1365
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1366 1366
                 $success = 0;
1367 1367
             }
1368 1368
         }
Please login to merge, or discard this patch.