Completed
Branch EDTR/refactor-master (ea8df4)
by
unknown
26:23 queued 18:16
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.
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -38,327 +38,327 @@
 block discarded – undo
38 38
 class AdvancedEditorEntityData
39 39
 {
40 40
 
41
-    /**
42
-     * @var EE_Event
43
-     */
44
-    protected $event;
41
+	/**
42
+	 * @var EE_Event
43
+	 */
44
+	protected $event;
45 45
 
46
-    /**
47
-     * @var RestApiSpoofer
48
-     */
49
-    protected $spoofer;
46
+	/**
47
+	 * @var RestApiSpoofer
48
+	 */
49
+	protected $spoofer;
50 50
 
51
-    /**
52
-     * @var EE_Admin_Config
53
-     */
54
-    protected $admin_config;
51
+	/**
52
+	 * @var EE_Admin_Config
53
+	 */
54
+	protected $admin_config;
55 55
 
56
-    /**
57
-     * @var EEM_Datetime $datetime_model
58
-     */
59
-    protected $datetime_model;
56
+	/**
57
+	 * @var EEM_Datetime $datetime_model
58
+	 */
59
+	protected $datetime_model;
60 60
 
61
-    /**
62
-     * @var EEM_Event $event_model
63
-     */
64
-    protected $event_model;
61
+	/**
62
+	 * @var EEM_Event $event_model
63
+	 */
64
+	protected $event_model;
65 65
 
66
-    /**
67
-     * @var EEM_Price $price_model
68
-     */
69
-    protected $price_model;
66
+	/**
67
+	 * @var EEM_Price $price_model
68
+	 */
69
+	protected $price_model;
70 70
 
71
-    /**
72
-     * @var EEM_Price_Type $price_type_model
73
-     */
74
-    protected $price_type_model;
71
+	/**
72
+	 * @var EEM_Price_Type $price_type_model
73
+	 */
74
+	protected $price_type_model;
75 75
 
76
-    /**
77
-     * @var EEM_Ticket $ticket_model
78
-     */
79
-    protected $ticket_model;
80
-    /**
81
-     * @var EEM_Venue $venue_model
82
-     */
83
-    protected $venue_model;
76
+	/**
77
+	 * @var EEM_Ticket $ticket_model
78
+	 */
79
+	protected $ticket_model;
80
+	/**
81
+	 * @var EEM_Venue $venue_model
82
+	 */
83
+	protected $venue_model;
84 84
 
85 85
 
86
-    /**
87
-     * AdvancedEditorAdminForm constructor.
88
-     *
89
-     * @param EE_Event        $event
90
-     * @param RestApiSpoofer  $spoofer
91
-     * @param EE_Admin_Config $admin_config
92
-     * @param EEM_Datetime    $datetime_model
93
-     * @param EEM_Event       $event_model
94
-     * @param EEM_Price       $price_model
95
-     * @param EEM_Price_Type  $price_type_model
96
-     * @param EEM_Ticket      $ticket_model
97
-     * @param EEM_Venue       $venue_model
98
-     */
99
-    public function __construct(
100
-        EE_Event $event,
101
-        RestApiSpoofer $spoofer,
102
-        EE_Admin_Config $admin_config,
103
-        EEM_Datetime $datetime_model,
104
-        EEM_Event $event_model,
105
-        EEM_Price $price_model,
106
-        EEM_Price_Type $price_type_model,
107
-        EEM_Ticket $ticket_model,
108
-        EEM_Venue $venue_model
109
-    ) {
110
-        $this->event = $event;
111
-        $this->admin_config = $admin_config;
112
-        $this->spoofer = $spoofer;
113
-        $this->datetime_model = $datetime_model;
114
-        $this->event_model = $event_model;
115
-        $this->price_model = $price_model;
116
-        $this->price_type_model = $price_type_model;
117
-        $this->ticket_model = $ticket_model;
118
-        $this->venue_model = $venue_model;
119
-        add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
120
-    }
86
+	/**
87
+	 * AdvancedEditorAdminForm constructor.
88
+	 *
89
+	 * @param EE_Event        $event
90
+	 * @param RestApiSpoofer  $spoofer
91
+	 * @param EE_Admin_Config $admin_config
92
+	 * @param EEM_Datetime    $datetime_model
93
+	 * @param EEM_Event       $event_model
94
+	 * @param EEM_Price       $price_model
95
+	 * @param EEM_Price_Type  $price_type_model
96
+	 * @param EEM_Ticket      $ticket_model
97
+	 * @param EEM_Venue       $venue_model
98
+	 */
99
+	public function __construct(
100
+		EE_Event $event,
101
+		RestApiSpoofer $spoofer,
102
+		EE_Admin_Config $admin_config,
103
+		EEM_Datetime $datetime_model,
104
+		EEM_Event $event_model,
105
+		EEM_Price $price_model,
106
+		EEM_Price_Type $price_type_model,
107
+		EEM_Ticket $ticket_model,
108
+		EEM_Venue $venue_model
109
+	) {
110
+		$this->event = $event;
111
+		$this->admin_config = $admin_config;
112
+		$this->spoofer = $spoofer;
113
+		$this->datetime_model = $datetime_model;
114
+		$this->event_model = $event_model;
115
+		$this->price_model = $price_model;
116
+		$this->price_type_model = $price_type_model;
117
+		$this->ticket_model = $ticket_model;
118
+		$this->venue_model = $venue_model;
119
+		add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * @throws EE_Error
125
-     * @throws InvalidArgumentException
126
-     * @throws InvalidDataTypeException
127
-     * @throws InvalidInterfaceException
128
-     * @throws ModelConfigurationException
129
-     * @throws ReflectionException
130
-     * @throws RestException
131
-     * @throws RestPasswordIncorrectException
132
-     * @throws RestPasswordRequiredException
133
-     * @throws UnexpectedEntityException
134
-     * @throws DomainException
135
-     * @since $VID:$
136
-     */
137
-    public function loadScriptsStyles()
138
-    {
139
-        if ($this->admin_config->useAdvancedEditor()) {
140
-            $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
141
-            if (! $eventId) {
142
-                global $post;
143
-                $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
144
-                $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
145
-                    ? $post->ID
146
-                    : $eventId;
147
-            }
148
-            if ($eventId) {
149
-                $data = $this->getAllEventData($eventId);
150
-                $data = wp_json_encode($data);
151
-                add_action(
152
-                    'admin_footer',
153
-                    static function () use ($data) {
154
-                        wp_add_inline_script(
155
-                            EspressoEditorAssetManager::JS_HANDLE_EDITOR,
156
-                            "var eeEditorEventData={$data};",
157
-                            'before'
158
-                        );
159
-                    }
160
-                );
161
-            }
162
-        }
163
-    }
123
+	/**
124
+	 * @throws EE_Error
125
+	 * @throws InvalidArgumentException
126
+	 * @throws InvalidDataTypeException
127
+	 * @throws InvalidInterfaceException
128
+	 * @throws ModelConfigurationException
129
+	 * @throws ReflectionException
130
+	 * @throws RestException
131
+	 * @throws RestPasswordIncorrectException
132
+	 * @throws RestPasswordRequiredException
133
+	 * @throws UnexpectedEntityException
134
+	 * @throws DomainException
135
+	 * @since $VID:$
136
+	 */
137
+	public function loadScriptsStyles()
138
+	{
139
+		if ($this->admin_config->useAdvancedEditor()) {
140
+			$eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
141
+			if (! $eventId) {
142
+				global $post;
143
+				$eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
144
+				$eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
145
+					? $post->ID
146
+					: $eventId;
147
+			}
148
+			if ($eventId) {
149
+				$data = $this->getAllEventData($eventId);
150
+				$data = wp_json_encode($data);
151
+				add_action(
152
+					'admin_footer',
153
+					static function () use ($data) {
154
+						wp_add_inline_script(
155
+							EspressoEditorAssetManager::JS_HANDLE_EDITOR,
156
+							"var eeEditorEventData={$data};",
157
+							'before'
158
+						);
159
+					}
160
+				);
161
+			}
162
+		}
163
+	}
164 164
 
165 165
 
166
-    /**
167
-     * @param int $eventId
168
-     * @return array
169
-     * @throws DomainException
170
-     * @throws EE_Error
171
-     * @throws InvalidArgumentException
172
-     * @throws InvalidDataTypeException
173
-     * @throws InvalidInterfaceException
174
-     * @throws ModelConfigurationException
175
-     * @throws ReflectionException
176
-     * @throws RestException
177
-     * @throws RestPasswordIncorrectException
178
-     * @throws RestPasswordRequiredException
179
-     * @throws UnexpectedEntityException
180
-     * @since $VID:$
181
-     */
182
-    protected function getEventDates($eventId)
183
-    {
184
-        return $this->spoofer->getApiResults(
185
-            $this->datetime_model,
186
-            [
187
-                [
188
-                    'EVT_ID'      => $eventId,
189
-                    'DTT_deleted' => ['IN', [true, false]]
190
-                ]
191
-            ]
192
-        );
193
-    }
166
+	/**
167
+	 * @param int $eventId
168
+	 * @return array
169
+	 * @throws DomainException
170
+	 * @throws EE_Error
171
+	 * @throws InvalidArgumentException
172
+	 * @throws InvalidDataTypeException
173
+	 * @throws InvalidInterfaceException
174
+	 * @throws ModelConfigurationException
175
+	 * @throws ReflectionException
176
+	 * @throws RestException
177
+	 * @throws RestPasswordIncorrectException
178
+	 * @throws RestPasswordRequiredException
179
+	 * @throws UnexpectedEntityException
180
+	 * @since $VID:$
181
+	 */
182
+	protected function getEventDates($eventId)
183
+	{
184
+		return $this->spoofer->getApiResults(
185
+			$this->datetime_model,
186
+			[
187
+				[
188
+					'EVT_ID'      => $eventId,
189
+					'DTT_deleted' => ['IN', [true, false]]
190
+				]
191
+			]
192
+		);
193
+	}
194 194
 
195 195
 
196
-    /**
197
-     * @param int $eventId
198
-     * @param array $eventDates
199
-     * @throws DomainException
200
-     * @throws EE_Error
201
-     * @throws InvalidArgumentException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     * @throws ModelConfigurationException
205
-     * @throws ReflectionException
206
-     * @throws RestException
207
-     * @throws RestPasswordIncorrectException
208
-     * @throws RestPasswordRequiredException
209
-     * @throws UnexpectedEntityException
210
-     * @since $VID:$
211
-     */
212
-    protected function addDefaultEntities($eventId, array $eventDates = [])
213
-    {
214
-        $default_dates = $this->datetime_model->create_new_blank_datetime();
215
-        if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) {
216
-            $default_date = $default_dates[0];
217
-            $default_date->save();
218
-            $default_date->_add_relation_to($eventId, 'Event');
219
-            $default_tickets = $this->ticket_model->get_all_default_tickets();
220
-            $default_prices = $this->price_model->get_all_default_prices();
221
-            foreach ($default_tickets as $default_ticket) {
222
-                $default_ticket->save();
223
-                $default_ticket->_add_relation_to($default_date, 'Datetime');
224
-                foreach ($default_prices as $default_price) {
225
-                    $default_price->save();
226
-                    $default_price->_add_relation_to($default_ticket, 'Ticket');
227
-                }
228
-            }
229
-        }
230
-    }
196
+	/**
197
+	 * @param int $eventId
198
+	 * @param array $eventDates
199
+	 * @throws DomainException
200
+	 * @throws EE_Error
201
+	 * @throws InvalidArgumentException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 * @throws ModelConfigurationException
205
+	 * @throws ReflectionException
206
+	 * @throws RestException
207
+	 * @throws RestPasswordIncorrectException
208
+	 * @throws RestPasswordRequiredException
209
+	 * @throws UnexpectedEntityException
210
+	 * @since $VID:$
211
+	 */
212
+	protected function addDefaultEntities($eventId, array $eventDates = [])
213
+	{
214
+		$default_dates = $this->datetime_model->create_new_blank_datetime();
215
+		if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) {
216
+			$default_date = $default_dates[0];
217
+			$default_date->save();
218
+			$default_date->_add_relation_to($eventId, 'Event');
219
+			$default_tickets = $this->ticket_model->get_all_default_tickets();
220
+			$default_prices = $this->price_model->get_all_default_prices();
221
+			foreach ($default_tickets as $default_ticket) {
222
+				$default_ticket->save();
223
+				$default_ticket->_add_relation_to($default_date, 'Datetime');
224
+				foreach ($default_prices as $default_price) {
225
+					$default_price->save();
226
+					$default_price->_add_relation_to($default_ticket, 'Ticket');
227
+				}
228
+			}
229
+		}
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * @param int $eventId
235
-     * @return array
236
-     * @throws EE_Error
237
-     * @throws InvalidDataTypeException
238
-     * @throws InvalidInterfaceException
239
-     * @throws ModelConfigurationException
240
-     * @throws RestPasswordIncorrectException
241
-     * @throws RestPasswordRequiredException
242
-     * @throws UnexpectedEntityException
243
-     * @throws RestException
244
-     * @throws InvalidArgumentException
245
-     * @throws ReflectionException
246
-     * @throws DomainException
247
-     * @since $VID:$
248
-     */
249
-    protected function getAllEventData($eventId)
250
-    {
251
-        // these should ultimately be extracted out into their own classes (one per model)
252
-        $event = $this->spoofer->getOneApiResult(
253
-            $this->event_model,
254
-            [['EVT_ID' => $eventId]]
255
-        );
256
-        if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
257
-            return [];
258
-        }
259
-        $eventDates = $this->getEventDates($eventId);
260
-        if ((! is_array($eventDates) || empty($eventDates))
261
-            || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')
262
-        ) {
263
-            $this->addDefaultEntities($eventId);
264
-            $eventDates = $this->getEventDates($eventId);
265
-        }
233
+	/**
234
+	 * @param int $eventId
235
+	 * @return array
236
+	 * @throws EE_Error
237
+	 * @throws InvalidDataTypeException
238
+	 * @throws InvalidInterfaceException
239
+	 * @throws ModelConfigurationException
240
+	 * @throws RestPasswordIncorrectException
241
+	 * @throws RestPasswordRequiredException
242
+	 * @throws UnexpectedEntityException
243
+	 * @throws RestException
244
+	 * @throws InvalidArgumentException
245
+	 * @throws ReflectionException
246
+	 * @throws DomainException
247
+	 * @since $VID:$
248
+	 */
249
+	protected function getAllEventData($eventId)
250
+	{
251
+		// these should ultimately be extracted out into their own classes (one per model)
252
+		$event = $this->spoofer->getOneApiResult(
253
+			$this->event_model,
254
+			[['EVT_ID' => $eventId]]
255
+		);
256
+		if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
257
+			return [];
258
+		}
259
+		$eventDates = $this->getEventDates($eventId);
260
+		if ((! is_array($eventDates) || empty($eventDates))
261
+			|| (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')
262
+		) {
263
+			$this->addDefaultEntities($eventId);
264
+			$eventDates = $this->getEventDates($eventId);
265
+		}
266 266
 
267
-        $event = [$eventId => $event];
268
-        $relations = [
269
-            'event'    => [
270
-                $eventId => [
271
-                    'datetime' => []
272
-                ]
273
-            ],
274
-            'datetime' => [],
275
-            'ticket'   => [],
276
-            'price'    => [],
277
-        ];
267
+		$event = [$eventId => $event];
268
+		$relations = [
269
+			'event'    => [
270
+				$eventId => [
271
+					'datetime' => []
272
+				]
273
+			],
274
+			'datetime' => [],
275
+			'ticket'   => [],
276
+			'price'    => [],
277
+		];
278 278
 
279
-        $datetimes = [];
280
-        $eventDateTickets = [];
281
-        if (is_array($eventDates)) {
282
-            foreach ($eventDates as $eventDate) {
283
-                if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
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(
288
-                        $this->ticket_model,
289
-                        [[
290
-                            'Datetime.DTT_ID' => $DTT_ID,
291
-                            'TKT_deleted' => ['IN', [true, false]]
292
-                        ]]
293
-                    );
294
-                }
295
-            }
296
-        }
279
+		$datetimes = [];
280
+		$eventDateTickets = [];
281
+		if (is_array($eventDates)) {
282
+			foreach ($eventDates as $eventDate) {
283
+				if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
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(
288
+						$this->ticket_model,
289
+						[[
290
+							'Datetime.DTT_ID' => $DTT_ID,
291
+							'TKT_deleted' => ['IN', [true, false]]
292
+						]]
293
+					);
294
+				}
295
+			}
296
+		}
297 297
 
298
-        $prices = [];
299
-        $tickets = [];
300
-        if (is_array($eventDateTickets)) {
301
-            foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
302
-                if (is_array($dateTickets)) {
303
-                    $relations['datetime'][ $DTT_ID ]['ticket'] = [];
304
-                    foreach ($dateTickets as $ticket) {
305
-                        if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
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(
310
-                                $this->price_model,
311
-                                [['Ticket.TKT_ID' => $TKT_ID]]
312
-                            );
313
-                            if (is_array($ticketPrices[ $TKT_ID ])) {
314
-                                $relations['ticket'][ $TKT_ID ]['price'] = [];
315
-                                foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
316
-                                    $PRC_ID = $ticketPrice['PRC_ID'];
317
-                                    $prices[ $PRC_ID ] = $ticketPrice;
318
-                                    $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
319
-                                }
320
-                            }
321
-                        }
322
-                    }
323
-                }
324
-            }
325
-        }
326
-        $price_type_results = $this->spoofer->getApiResults(
327
-            $this->price_type_model,
328
-            [['PRT_deleted' => false]]
329
-        );
330
-        $price_types = [];
331
-        foreach ($price_type_results as $price_type) {
332
-            $price_types[ $price_type['PRT_ID'] ] = $price_type;
333
-        }
334
-        $venue = $this->spoofer->getOneApiResult(
335
-            $this->venue_model,
336
-            [['Event.EVT_ID' => $eventId]]
337
-        );
338
-        if (is_array($venue) && isset($venue['VNU_ID'])) {
339
-            $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
340
-            $venue = [$venue['VNU_ID'] => $venue];
341
-        }
298
+		$prices = [];
299
+		$tickets = [];
300
+		if (is_array($eventDateTickets)) {
301
+			foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
302
+				if (is_array($dateTickets)) {
303
+					$relations['datetime'][ $DTT_ID ]['ticket'] = [];
304
+					foreach ($dateTickets as $ticket) {
305
+						if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
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(
310
+								$this->price_model,
311
+								[['Ticket.TKT_ID' => $TKT_ID]]
312
+							);
313
+							if (is_array($ticketPrices[ $TKT_ID ])) {
314
+								$relations['ticket'][ $TKT_ID ]['price'] = [];
315
+								foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
316
+									$PRC_ID = $ticketPrice['PRC_ID'];
317
+									$prices[ $PRC_ID ] = $ticketPrice;
318
+									$relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
319
+								}
320
+							}
321
+						}
322
+					}
323
+				}
324
+			}
325
+		}
326
+		$price_type_results = $this->spoofer->getApiResults(
327
+			$this->price_type_model,
328
+			[['PRT_deleted' => false]]
329
+		);
330
+		$price_types = [];
331
+		foreach ($price_type_results as $price_type) {
332
+			$price_types[ $price_type['PRT_ID'] ] = $price_type;
333
+		}
334
+		$venue = $this->spoofer->getOneApiResult(
335
+			$this->venue_model,
336
+			[['Event.EVT_ID' => $eventId]]
337
+		);
338
+		if (is_array($venue) && isset($venue['VNU_ID'])) {
339
+			$relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
340
+			$venue = [$venue['VNU_ID'] => $venue];
341
+		}
342 342
 
343
-        $schemas = [
344
-            'event'      => $this->spoofer->getModelSchema('events'),
345
-            'datetime'   => $this->spoofer->getModelSchema('datetimes'),
346
-            'ticket'     => $this->spoofer->getModelSchema('tickets'),
347
-            'price'      => $this->spoofer->getModelSchema('prices'),
348
-            'price_type' => $this->spoofer->getModelSchema('price_types'),
349
-            'venue'      => $this->spoofer->getModelSchema('venues'),
350
-        ];
343
+		$schemas = [
344
+			'event'      => $this->spoofer->getModelSchema('events'),
345
+			'datetime'   => $this->spoofer->getModelSchema('datetimes'),
346
+			'ticket'     => $this->spoofer->getModelSchema('tickets'),
347
+			'price'      => $this->spoofer->getModelSchema('prices'),
348
+			'price_type' => $this->spoofer->getModelSchema('price_types'),
349
+			'venue'      => $this->spoofer->getModelSchema('venues'),
350
+		];
351 351
 
352
-        return [
353
-            'eventId'    => $eventId,
354
-            'event'      => $event,
355
-            'datetime'   => $datetimes,
356
-            'ticket'     => $tickets,
357
-            'price'      => $prices,
358
-            'price_type' => $price_types,
359
-            'venue'      => $venue,
360
-            'schemas'    => $schemas,
361
-            'relations'  => $relations,
362
-        ];
363
-    }
352
+		return [
353
+			'eventId'    => $eventId,
354
+			'event'      => $event,
355
+			'datetime'   => $datetimes,
356
+			'ticket'     => $tickets,
357
+			'price'      => $prices,
358
+			'price_type' => $price_types,
359
+			'venue'      => $venue,
360
+			'schemas'    => $schemas,
361
+			'relations'  => $relations,
362
+		];
363
+	}
364 364
 }
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.
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   +1385 added lines, -1385 removed lines patch added patch discarded remove patch
@@ -17,1389 +17,1389 @@
 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
-        // setup Advanced Editor ???
228
-        if (isset($this->_req_data['action'])
229
-            && (
230
-                $this->_req_data['action'] === 'default_event_settings'
231
-                || $this->_req_data['action'] === 'update_default_event_settings'
232
-            )
233
-        ) {
234
-            $this->advanced_editor_admin_form = $this->loader->getShared(
235
-                'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
236
-            );
237
-        }
238
-        if (isset($this->_req_data['action'])
239
-            && ($this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
240
-        ) {
241
-            $this->advanced_editor_data = $this->loader->getShared(
242
-                'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData',
243
-                [$this->_cpt_model_obj]
244
-            );
245
-        }
246
-    }
247
-
248
-
249
-    /**
250
-     * admin_init
251
-     */
252
-    public function admin_init()
253
-    {
254
-        EE_Registry::$i18n_js_strings = array_merge(
255
-            EE_Registry::$i18n_js_strings,
256
-            array(
257
-                'image_confirm'          => esc_html__(
258
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
259
-                    'event_espresso'
260
-                ),
261
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
262
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
263
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
264
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
265
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
266
-            )
267
-        );
268
-    }
269
-
270
-
271
-    /**
272
-     * Add per page screen options to the default ticket list table view.
273
-     *
274
-     * @throws InvalidArgumentException
275
-     * @throws InvalidDataTypeException
276
-     * @throws InvalidInterfaceException
277
-     */
278
-    protected function _add_screen_options_ticket_list_table()
279
-    {
280
-        $this->_per_page_screen_option();
281
-    }
282
-
283
-
284
-    /**
285
-     * @param string $return
286
-     * @param int    $id
287
-     * @param string $new_title
288
-     * @param string $new_slug
289
-     * @return string
290
-     */
291
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
292
-    {
293
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
294
-        // make sure this is only when editing
295
-        if (! empty($id)) {
296
-            $href = EE_Admin_Page::add_query_args_and_nonce(
297
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
298
-                $this->_admin_base_url
299
-            );
300
-            $title = esc_attr__('Duplicate Event', 'event_espresso');
301
-            $return .= '<a href="'
302
-                       . $href
303
-                       . '" title="'
304
-                       . $title
305
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
306
-                       . $title
307
-                       . '</a>';
308
-        }
309
-        return $return;
310
-    }
311
-
312
-
313
-    /**
314
-     * Set the list table views for the default ticket list table view.
315
-     */
316
-    public function _set_list_table_views_ticket_list_table()
317
-    {
318
-        $this->_views = array(
319
-            'all'     => array(
320
-                'slug'        => 'all',
321
-                'label'       => esc_html__('All', 'event_espresso'),
322
-                'count'       => 0,
323
-                'bulk_action' => array(
324
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
325
-                ),
326
-            ),
327
-            'trashed' => array(
328
-                'slug'        => 'trashed',
329
-                'label'       => esc_html__('Trash', 'event_espresso'),
330
-                'count'       => 0,
331
-                'bulk_action' => array(
332
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
333
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
334
-                ),
335
-            ),
336
-        );
337
-    }
338
-
339
-
340
-    /**
341
-     * Enqueue scripts and styles for the event editor.
342
-     */
343
-    public function load_scripts_styles_edit()
344
-    {
345
-        wp_register_script(
346
-            'ee-event-editor-heartbeat',
347
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
348
-            array('ee_admin_js', 'heartbeat'),
349
-            EVENT_ESPRESSO_VERSION,
350
-            true
351
-        );
352
-        wp_enqueue_script('ee-accounting');
353
-        // styles
354
-        wp_enqueue_style('espresso-ui-theme');
355
-        wp_enqueue_script('event_editor_js');
356
-        wp_enqueue_script('ee-event-editor-heartbeat');
357
-    }
358
-
359
-
360
-    /**
361
-     * Returns template for the additional datetime.
362
-     *
363
-     * @param $template
364
-     * @param $template_args
365
-     * @return mixed
366
-     * @throws DomainException
367
-     */
368
-    public function add_additional_datetime_button($template, $template_args)
369
-    {
370
-        return EEH_Template::display_template(
371
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
372
-            $template_args,
373
-            true
374
-        );
375
-    }
376
-
377
-
378
-    /**
379
-     * Returns the template for cloning a datetime.
380
-     *
381
-     * @param $template
382
-     * @param $template_args
383
-     * @return mixed
384
-     * @throws DomainException
385
-     */
386
-    public function add_datetime_clone_button($template, $template_args)
387
-    {
388
-        return EEH_Template::display_template(
389
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
390
-            $template_args,
391
-            true
392
-        );
393
-    }
394
-
395
-
396
-    /**
397
-     * Returns the template for datetime timezones.
398
-     *
399
-     * @param $template
400
-     * @param $template_args
401
-     * @return mixed
402
-     * @throws DomainException
403
-     */
404
-    public function datetime_timezones_template($template, $template_args)
405
-    {
406
-        return EEH_Template::display_template(
407
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
408
-            $template_args,
409
-            true
410
-        );
411
-    }
412
-
413
-
414
-    /**
415
-     * Sets the views for the default list table view.
416
-     */
417
-    protected function _set_list_table_views_default()
418
-    {
419
-        parent::_set_list_table_views_default();
420
-        $new_views = array(
421
-            'today' => array(
422
-                'slug'        => 'today',
423
-                'label'       => esc_html__('Today', 'event_espresso'),
424
-                'count'       => $this->total_events_today(),
425
-                'bulk_action' => array(
426
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
427
-                ),
428
-            ),
429
-            'month' => array(
430
-                'slug'        => 'month',
431
-                'label'       => esc_html__('This Month', 'event_espresso'),
432
-                'count'       => $this->total_events_this_month(),
433
-                'bulk_action' => array(
434
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
435
-                ),
436
-            ),
437
-        );
438
-        $this->_views = array_merge($this->_views, $new_views);
439
-    }
440
-
441
-
442
-    /**
443
-     * Returns the extra action links for the default list table view.
444
-     *
445
-     * @param array    $action_links
446
-     * @param EE_Event $event
447
-     * @return array
448
-     * @throws EE_Error
449
-     * @throws InvalidArgumentException
450
-     * @throws InvalidDataTypeException
451
-     * @throws InvalidInterfaceException
452
-     * @throws ReflectionException
453
-     */
454
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
455
-    {
456
-        if (EE_Registry::instance()->CAP->current_user_can(
457
-            'ee_read_registrations',
458
-            'espresso_registrations_reports',
459
-            $event->ID()
460
-        )
461
-        ) {
462
-            $reports_query_args = array(
463
-                'action' => 'reports',
464
-                'EVT_ID' => $event->ID(),
465
-            );
466
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
467
-            $action_links[] = '<a href="'
468
-                              . $reports_link
469
-                              . '" title="'
470
-                              . esc_attr__('View Report', 'event_espresso')
471
-                              . '"><div class="dashicons dashicons-chart-bar"></div></a>'
472
-                              . "\n\t";
473
-        }
474
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
475
-            EE_Registry::instance()->load_helper('MSG_Template');
476
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
477
-                'see_notifications_for',
478
-                null,
479
-                array('EVT_ID' => $event->ID())
480
-            );
481
-        }
482
-        return $action_links;
483
-    }
484
-
485
-
486
-    /**
487
-     * @param $items
488
-     * @return mixed
489
-     */
490
-    public function additional_legend_items($items)
491
-    {
492
-        if (EE_Registry::instance()->CAP->current_user_can(
493
-            'ee_read_registrations',
494
-            'espresso_registrations_reports'
495
-        )
496
-        ) {
497
-            $items['reports'] = array(
498
-                'class' => 'dashicons dashicons-chart-bar',
499
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
500
-            );
501
-        }
502
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
503
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
504
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
505
-            // (can only use numeric offsets when treating strings as arrays)
506
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
507
-                $items['view_related_messages'] = array(
508
-                    'class' => $related_for_icon['css_class'],
509
-                    'desc'  => $related_for_icon['label'],
510
-                );
511
-            }
512
-        }
513
-        return $items;
514
-    }
515
-
516
-
517
-    /**
518
-     * This is the callback method for the duplicate event route
519
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
520
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
521
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
522
-     * After duplication the redirect is to the new event edit page.
523
-     *
524
-     * @return void
525
-     * @throws EE_Error If EE_Event is not available with given ID
526
-     * @throws InvalidArgumentException
527
-     * @throws InvalidDataTypeException
528
-     * @throws InvalidInterfaceException
529
-     * @throws ReflectionException
530
-     * @access protected
531
-     */
532
-    protected function _duplicate_event()
533
-    {
534
-        // first make sure the ID for the event is in the request.
535
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
536
-        if (! isset($this->_req_data['EVT_ID'])) {
537
-            EE_Error::add_error(
538
-                esc_html__(
539
-                    'In order to duplicate an event an Event ID is required.  None was given.',
540
-                    'event_espresso'
541
-                ),
542
-                __FILE__,
543
-                __FUNCTION__,
544
-                __LINE__
545
-            );
546
-            $this->_redirect_after_action(false, '', '', array(), true);
547
-            return;
548
-        }
549
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
550
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
551
-        if (! $orig_event instanceof EE_Event) {
552
-            throw new EE_Error(
553
-                sprintf(
554
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
555
-                    $this->_req_data['EVT_ID']
556
-                )
557
-            );
558
-        }
559
-        // k now let's clone the $orig_event before getting relations
560
-        $new_event = clone $orig_event;
561
-        // original datetimes
562
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
563
-        // other original relations
564
-        $orig_ven = $orig_event->get_many_related('Venue');
565
-        // reset the ID and modify other details to make it clear this is a dupe
566
-        $new_event->set('EVT_ID', 0);
567
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
568
-        $new_event->set('EVT_name', $new_name);
569
-        $new_event->set(
570
-            'EVT_slug',
571
-            wp_unique_post_slug(
572
-                sanitize_title($orig_event->name()),
573
-                0,
574
-                'publish',
575
-                'espresso_events',
576
-                0
577
-            )
578
-        );
579
-        $new_event->set('status', 'draft');
580
-        // duplicate discussion settings
581
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
582
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
583
-        // save the new event
584
-        $new_event->save();
585
-        // venues
586
-        foreach ($orig_ven as $ven) {
587
-            $new_event->_add_relation_to($ven, 'Venue');
588
-        }
589
-        $new_event->save();
590
-        // now we need to get the question group relations and handle that
591
-        // first primary question groups
592
-        $orig_primary_qgs = $orig_event->get_many_related(
593
-            'Question_Group',
594
-            [['Event_Question_Group.EQG_primary' => true]]
595
-        );
596
-        if (! empty($orig_primary_qgs)) {
597
-            foreach ($orig_primary_qgs as $id => $obj) {
598
-                if ($obj instanceof EE_Question_Group) {
599
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
600
-                }
601
-            }
602
-        }
603
-        // next additional attendee question groups
604
-        $orig_additional_qgs = $orig_event->get_many_related(
605
-            'Question_Group',
606
-            [['Event_Question_Group.EQG_additional' => true]]
607
-        );
608
-        if (! empty($orig_additional_qgs)) {
609
-            foreach ($orig_additional_qgs as $id => $obj) {
610
-                if ($obj instanceof EE_Question_Group) {
611
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
612
-                }
613
-            }
614
-        }
615
-
616
-        $new_event->save();
617
-
618
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
619
-        $cloned_tickets = array();
620
-        foreach ($orig_datetimes as $orig_dtt) {
621
-            if (! $orig_dtt instanceof EE_Datetime) {
622
-                continue;
623
-            }
624
-            $new_dtt = clone $orig_dtt;
625
-            $orig_tkts = $orig_dtt->tickets();
626
-            // save new dtt then add to event
627
-            $new_dtt->set('DTT_ID', 0);
628
-            $new_dtt->set('DTT_sold', 0);
629
-            $new_dtt->set_reserved(0);
630
-            $new_dtt->save();
631
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
632
-            $new_event->save();
633
-            // now let's get the ticket relations setup.
634
-            foreach ((array) $orig_tkts as $orig_tkt) {
635
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
636
-                if (! $orig_tkt instanceof EE_Ticket) {
637
-                    continue;
638
-                }
639
-                // is this ticket archived?  If it is then let's skip
640
-                if ($orig_tkt->get('TKT_deleted')) {
641
-                    continue;
642
-                }
643
-                // does this original ticket already exist in the clone_tickets cache?
644
-                //  If so we'll just use the new ticket from it.
645
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
646
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
647
-                } else {
648
-                    $new_tkt = clone $orig_tkt;
649
-                    // get relations on the $orig_tkt that we need to setup.
650
-                    $orig_prices = $orig_tkt->prices();
651
-                    $new_tkt->set('TKT_ID', 0);
652
-                    $new_tkt->set('TKT_sold', 0);
653
-                    $new_tkt->set('TKT_reserved', 0);
654
-                    $new_tkt->save(); // make sure new ticket has ID.
655
-                    // price relations on new ticket need to be setup.
656
-                    foreach ($orig_prices as $orig_price) {
657
-                        $new_price = clone $orig_price;
658
-                        $new_price->set('PRC_ID', 0);
659
-                        $new_price->save();
660
-                        $new_tkt->_add_relation_to($new_price, 'Price');
661
-                        $new_tkt->save();
662
-                    }
663
-
664
-                    do_action(
665
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
666
-                        $orig_tkt,
667
-                        $new_tkt,
668
-                        $orig_prices,
669
-                        $orig_event,
670
-                        $orig_dtt,
671
-                        $new_dtt
672
-                    );
673
-                }
674
-                // k now we can add the new ticket as a relation to the new datetime
675
-                // and make sure its added to our cached $cloned_tickets array
676
-                // for use with later datetimes that have the same ticket.
677
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
678
-                $new_dtt->save();
679
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
680
-            }
681
-        }
682
-        // clone taxonomy information
683
-        $taxonomies_to_clone_with = apply_filters(
684
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
685
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
686
-        );
687
-        // get terms for original event (notice)
688
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
689
-        // loop through terms and add them to new event.
690
-        foreach ($orig_terms as $term) {
691
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
692
-        }
693
-
694
-        // duplicate other core WP_Post items for this event.
695
-        // post thumbnail (feature image).
696
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
697
-        if ($feature_image_id) {
698
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
699
-        }
700
-
701
-        // duplicate page_template setting
702
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
703
-        if ($page_template) {
704
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
705
-        }
706
-
707
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
708
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
709
-        if ($new_event->ID()) {
710
-            $redirect_args = array(
711
-                'post'   => $new_event->ID(),
712
-                'action' => 'edit',
713
-            );
714
-            EE_Error::add_success(
715
-                esc_html__(
716
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
717
-                    'event_espresso'
718
-                )
719
-            );
720
-        } else {
721
-            $redirect_args = array(
722
-                'action' => 'default',
723
-            );
724
-            EE_Error::add_error(
725
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
726
-                __FILE__,
727
-                __FUNCTION__,
728
-                __LINE__
729
-            );
730
-        }
731
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
732
-    }
733
-
734
-
735
-    /**
736
-     * Generates output for the import page.
737
-     *
738
-     * @throws DomainException
739
-     * @throws EE_Error
740
-     * @throws InvalidArgumentException
741
-     * @throws InvalidDataTypeException
742
-     * @throws InvalidInterfaceException
743
-     */
744
-    protected function _import_page()
745
-    {
746
-        $title = esc_html__('Import', 'event_espresso');
747
-        $intro = esc_html__(
748
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
749
-            'event_espresso'
750
-        );
751
-        $form_url = EVENTS_ADMIN_URL;
752
-        $action = 'import_events';
753
-        $type = 'csv';
754
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
755
-            $title,
756
-            $intro,
757
-            $form_url,
758
-            $action,
759
-            $type
760
-        );
761
-        $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
762
-            array('action' => 'sample_export_file'),
763
-            $this->_admin_base_url
764
-        );
765
-        $content = EEH_Template::display_template(
766
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
767
-            $this->_template_args,
768
-            true
769
-        );
770
-        $this->_template_args['admin_page_content'] = $content;
771
-        $this->display_admin_page_with_sidebar();
772
-    }
773
-
774
-
775
-    /**
776
-     * _import_events
777
-     * This handles displaying the screen and running imports for importing events.
778
-     *
779
-     * @return void
780
-     * @throws EE_Error
781
-     * @throws InvalidArgumentException
782
-     * @throws InvalidDataTypeException
783
-     * @throws InvalidInterfaceException
784
-     */
785
-    protected function _import_events()
786
-    {
787
-        require_once(EE_CLASSES . 'EE_Import.class.php');
788
-        $success = EE_Import::instance()->import();
789
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
790
-    }
791
-
792
-
793
-    /**
794
-     * _events_export
795
-     * Will export all (or just the given event) to a Excel compatible file.
796
-     *
797
-     * @access protected
798
-     * @return void
799
-     */
800
-    protected function _events_export()
801
-    {
802
-        if (isset($this->_req_data['EVT_ID'])) {
803
-            $event_ids = $this->_req_data['EVT_ID'];
804
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
805
-            $event_ids = $this->_req_data['EVT_IDs'];
806
-        } else {
807
-            $event_ids = null;
808
-        }
809
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
810
-        $new_request_args = array(
811
-            'export' => 'report',
812
-            'action' => 'all_event_data',
813
-            'EVT_ID' => $event_ids,
814
-        );
815
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
816
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
817
-            require_once(EE_CLASSES . 'EE_Export.class.php');
818
-            $EE_Export = EE_Export::instance($this->_req_data);
819
-            $EE_Export->export();
820
-        }
821
-    }
822
-
823
-
824
-    /**
825
-     * handle category exports()
826
-     *
827
-     * @return void
828
-     */
829
-    protected function _categories_export()
830
-    {
831
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
832
-        $new_request_args = array(
833
-            'export'       => 'report',
834
-            'action'       => 'categories',
835
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
836
-        );
837
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
838
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
839
-            require_once(EE_CLASSES . 'EE_Export.class.php');
840
-            $EE_Export = EE_Export::instance($this->_req_data);
841
-            $EE_Export->export();
842
-        }
843
-    }
844
-
845
-
846
-    /**
847
-     * Creates a sample CSV file for importing
848
-     */
849
-    protected function _sample_export_file()
850
-    {
851
-        // require_once(EE_CLASSES . 'EE_Export.class.php');
852
-        EE_Export::instance()->export_sample();
853
-    }
854
-
855
-
856
-    /*************        Template Settings        *************/
857
-    /**
858
-     * Generates template settings page output
859
-     *
860
-     * @throws DomainException
861
-     * @throws EE_Error
862
-     * @throws InvalidArgumentException
863
-     * @throws InvalidDataTypeException
864
-     * @throws InvalidInterfaceException
865
-     */
866
-    protected function _template_settings()
867
-    {
868
-        $this->_template_args['values'] = $this->_yes_no_values;
869
-        /**
870
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
871
-         * from General_Settings_Admin_Page to here.
872
-         */
873
-        $this->_template_args = apply_filters(
874
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
875
-            $this->_template_args
876
-        );
877
-        $this->_set_add_edit_form_tags('update_template_settings');
878
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
879
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
880
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
881
-            $this->_template_args,
882
-            true
883
-        );
884
-        $this->display_admin_page_with_sidebar();
885
-    }
886
-
887
-
888
-    /**
889
-     * Handler for updating template settings.
890
-     *
891
-     * @throws EE_Error
892
-     * @throws InvalidArgumentException
893
-     * @throws InvalidDataTypeException
894
-     * @throws InvalidInterfaceException
895
-     */
896
-    protected function _update_template_settings()
897
-    {
898
-        /**
899
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
900
-         * from General_Settings_Admin_Page to here.
901
-         */
902
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
903
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
904
-            EE_Registry::instance()->CFG->template_settings,
905
-            $this->_req_data
906
-        );
907
-        // update custom post type slugs and detect if we need to flush rewrite rules
908
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
909
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
910
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
911
-            : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
912
-        $what = 'Template Settings';
913
-        $success = $this->_update_espresso_configuration(
914
-            $what,
915
-            EE_Registry::instance()->CFG->template_settings,
916
-            __FILE__,
917
-            __FUNCTION__,
918
-            __LINE__
919
-        );
920
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
921
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
922
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
923
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
924
-            );
925
-            $rewrite_rules->flush();
926
-        }
927
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
928
-    }
929
-
930
-
931
-    /**
932
-     * _premium_event_editor_meta_boxes
933
-     * add all metaboxes related to the event_editor
934
-     *
935
-     * @access protected
936
-     * @return void
937
-     * @throws EE_Error
938
-     * @throws InvalidArgumentException
939
-     * @throws InvalidDataTypeException
940
-     * @throws InvalidInterfaceException
941
-     * @throws ReflectionException
942
-     */
943
-    protected function _premium_event_editor_meta_boxes()
944
-    {
945
-        $this->verify_cpt_object();
946
-        add_meta_box(
947
-            'espresso_event_editor_event_options',
948
-            esc_html__('Event Registration Options', 'event_espresso'),
949
-            array($this, 'registration_options_meta_box'),
950
-            $this->page_slug,
951
-            'side',
952
-            'core'
953
-        );
954
-    }
955
-
956
-
957
-    /**
958
-     * override caf metabox
959
-     *
960
-     * @return void
961
-     * @throws DomainException
962
-     * @throws EE_Error
963
-     */
964
-    public function registration_options_meta_box()
965
-    {
966
-        $yes_no_values = array(
967
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
968
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
969
-        );
970
-        $default_reg_status_values = EEM_Registration::reg_status_array(
971
-            array(
972
-                EEM_Registration::status_id_cancelled,
973
-                EEM_Registration::status_id_declined,
974
-                EEM_Registration::status_id_incomplete,
975
-                EEM_Registration::status_id_wait_list,
976
-            ),
977
-            true
978
-        );
979
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
980
-        $template_args['_event'] = $this->_cpt_model_obj;
981
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
982
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
983
-            'default_reg_status',
984
-            $default_reg_status_values,
985
-            $this->_cpt_model_obj->default_registration_status()
986
-        );
987
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
988
-            'display_desc',
989
-            $yes_no_values,
990
-            $this->_cpt_model_obj->display_description()
991
-        );
992
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
993
-            'display_ticket_selector',
994
-            $yes_no_values,
995
-            $this->_cpt_model_obj->display_ticket_selector(),
996
-            '',
997
-            '',
998
-            false
999
-        );
1000
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1001
-            'EVT_default_registration_status',
1002
-            $default_reg_status_values,
1003
-            $this->_cpt_model_obj->default_registration_status()
1004
-        );
1005
-        $template_args['additional_registration_options'] = apply_filters(
1006
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1007
-            '',
1008
-            $template_args,
1009
-            $yes_no_values,
1010
-            $default_reg_status_values
1011
-        );
1012
-        EEH_Template::display_template(
1013
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1014
-            $template_args
1015
-        );
1016
-    }
1017
-
1018
-
1019
-
1020
-    /**
1021
-     * wp_list_table_mods for caf
1022
-     * ============================
1023
-     */
1024
-    /**
1025
-     * hook into list table filters and provide filters for caffeinated list table
1026
-     *
1027
-     * @param array $old_filters    any existing filters present
1028
-     * @param array $list_table_obj the list table object
1029
-     * @return array                  new filters
1030
-     * @throws EE_Error
1031
-     * @throws InvalidArgumentException
1032
-     * @throws InvalidDataTypeException
1033
-     * @throws InvalidInterfaceException
1034
-     * @throws ReflectionException
1035
-     */
1036
-    public function list_table_filters($old_filters, $list_table_obj)
1037
-    {
1038
-        $filters = array();
1039
-        // first month/year filters
1040
-        $filters[] = $this->espresso_event_months_dropdown();
1041
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1042
-        // active status dropdown
1043
-        if ($status !== 'draft') {
1044
-            $filters[] = $this->active_status_dropdown(
1045
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1046
-            );
1047
-            $filters[] = $this->venuesDropdown(
1048
-                isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1049
-            );
1050
-        }
1051
-        // category filter
1052
-        $filters[] = $this->category_dropdown();
1053
-        return array_merge($old_filters, $filters);
1054
-    }
1055
-
1056
-
1057
-    /**
1058
-     * espresso_event_months_dropdown
1059
-     *
1060
-     * @access public
1061
-     * @return string                dropdown listing month/year selections for events.
1062
-     */
1063
-    public function espresso_event_months_dropdown()
1064
-    {
1065
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1066
-        // Note we need to include any other filters that are set!
1067
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1068
-        // categories?
1069
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1070
-            ? $this->_req_data['EVT_CAT']
1071
-            : null;
1072
-        // active status?
1073
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1074
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1075
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1076
-    }
1077
-
1078
-
1079
-    /**
1080
-     * returns a list of "active" statuses on the event
1081
-     *
1082
-     * @param  string $current_value whatever the current active status is
1083
-     * @return string
1084
-     */
1085
-    public function active_status_dropdown($current_value = '')
1086
-    {
1087
-        $select_name = 'active_status';
1088
-        $values = array(
1089
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1090
-            'active'   => esc_html__('Active', 'event_espresso'),
1091
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1092
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1093
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1094
-        );
1095
-
1096
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1097
-    }
1098
-
1099
-
1100
-    /**
1101
-     * returns a list of "venues"
1102
-     *
1103
-     * @param string $current_value whatever the current active status is
1104
-     * @return string
1105
-     * @throws EE_Error
1106
-     * @throws InvalidArgumentException
1107
-     * @throws InvalidDataTypeException
1108
-     * @throws InvalidInterfaceException
1109
-     * @throws ReflectionException
1110
-     */
1111
-    protected function venuesDropdown($current_value = '')
1112
-    {
1113
-        $select_name = 'venue';
1114
-        $values = array(
1115
-            '' => esc_html__('All Venues', 'event_espresso'),
1116
-        );
1117
-        // populate the list of venues.
1118
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1119
-        $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1120
-
1121
-        foreach ($venues as $venue) {
1122
-            $values[ $venue->ID() ] = $venue->name();
1123
-        }
1124
-
1125
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1126
-    }
1127
-
1128
-
1129
-    /**
1130
-     * output a dropdown of the categories for the category filter on the event admin list table
1131
-     *
1132
-     * @access  public
1133
-     * @return string html
1134
-     */
1135
-    public function category_dropdown()
1136
-    {
1137
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1138
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1139
-    }
1140
-
1141
-
1142
-    /**
1143
-     * get total number of events today
1144
-     *
1145
-     * @access public
1146
-     * @return int
1147
-     * @throws EE_Error
1148
-     * @throws InvalidArgumentException
1149
-     * @throws InvalidDataTypeException
1150
-     * @throws InvalidInterfaceException
1151
-     */
1152
-    public function total_events_today()
1153
-    {
1154
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1155
-            'DTT_EVT_start',
1156
-            date('Y-m-d') . ' 00:00:00',
1157
-            'Y-m-d H:i:s',
1158
-            'UTC'
1159
-        );
1160
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1161
-            'DTT_EVT_start',
1162
-            date('Y-m-d') . ' 23:59:59',
1163
-            'Y-m-d H:i:s',
1164
-            'UTC'
1165
-        );
1166
-        $where = array(
1167
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1168
-        );
1169
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1170
-        return $count;
1171
-    }
1172
-
1173
-
1174
-    /**
1175
-     * get total number of events this month
1176
-     *
1177
-     * @access public
1178
-     * @return int
1179
-     * @throws EE_Error
1180
-     * @throws InvalidArgumentException
1181
-     * @throws InvalidDataTypeException
1182
-     * @throws InvalidInterfaceException
1183
-     */
1184
-    public function total_events_this_month()
1185
-    {
1186
-        // Dates
1187
-        $this_year_r = date('Y');
1188
-        $this_month_r = date('m');
1189
-        $days_this_month = date('t');
1190
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1191
-            'DTT_EVT_start',
1192
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1193
-            'Y-m-d H:i:s',
1194
-            'UTC'
1195
-        );
1196
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1197
-            'DTT_EVT_start',
1198
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1199
-            'Y-m-d H:i:s',
1200
-            'UTC'
1201
-        );
1202
-        $where = array(
1203
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1204
-        );
1205
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1206
-        return $count;
1207
-    }
1208
-
1209
-
1210
-    /** DEFAULT TICKETS STUFF **/
1211
-
1212
-    /**
1213
-     * Output default tickets list table view.
1214
-     *
1215
-     * @throws DomainException
1216
-     * @throws EE_Error
1217
-     * @throws InvalidArgumentException
1218
-     * @throws InvalidDataTypeException
1219
-     * @throws InvalidInterfaceException
1220
-     */
1221
-    public function _tickets_overview_list_table()
1222
-    {
1223
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1224
-        $this->display_admin_list_table_page_with_no_sidebar();
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * @param int  $per_page
1230
-     * @param bool $count
1231
-     * @param bool $trashed
1232
-     * @return EE_Soft_Delete_Base_Class[]|int
1233
-     * @throws EE_Error
1234
-     * @throws InvalidArgumentException
1235
-     * @throws InvalidDataTypeException
1236
-     * @throws InvalidInterfaceException
1237
-     */
1238
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1239
-    {
1240
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1241
-        $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1242
-        switch ($orderby) {
1243
-            case 'TKT_name':
1244
-                $orderby = array('TKT_name' => $order);
1245
-                break;
1246
-            case 'TKT_price':
1247
-                $orderby = array('TKT_price' => $order);
1248
-                break;
1249
-            case 'TKT_uses':
1250
-                $orderby = array('TKT_uses' => $order);
1251
-                break;
1252
-            case 'TKT_min':
1253
-                $orderby = array('TKT_min' => $order);
1254
-                break;
1255
-            case 'TKT_max':
1256
-                $orderby = array('TKT_max' => $order);
1257
-                break;
1258
-            case 'TKT_qty':
1259
-                $orderby = array('TKT_qty' => $order);
1260
-                break;
1261
-        }
1262
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1263
-            ? $this->_req_data['paged']
1264
-            : 1;
1265
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1266
-            ? $this->_req_data['perpage']
1267
-            : $per_page;
1268
-        $_where = array(
1269
-            'TKT_is_default' => 1,
1270
-            'TKT_deleted'    => $trashed,
1271
-        );
1272
-        $offset = ($current_page - 1) * $per_page;
1273
-        $limit = array($offset, $per_page);
1274
-        if (isset($this->_req_data['s'])) {
1275
-            $sstr = '%' . $this->_req_data['s'] . '%';
1276
-            $_where['OR'] = array(
1277
-                'TKT_name'        => array('LIKE', $sstr),
1278
-                'TKT_description' => array('LIKE', $sstr),
1279
-            );
1280
-        }
1281
-        $query_params = array(
1282
-            $_where,
1283
-            'order_by' => $orderby,
1284
-            'limit'    => $limit,
1285
-            'group_by' => 'TKT_ID',
1286
-        );
1287
-        if ($count) {
1288
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1289
-        } else {
1290
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1291
-        }
1292
-    }
1293
-
1294
-
1295
-    /**
1296
-     * @param bool $trash
1297
-     * @throws EE_Error
1298
-     * @throws InvalidArgumentException
1299
-     * @throws InvalidDataTypeException
1300
-     * @throws InvalidInterfaceException
1301
-     */
1302
-    protected function _trash_or_restore_ticket($trash = false)
1303
-    {
1304
-        $success = 1;
1305
-        $TKT = EEM_Ticket::instance();
1306
-        // checkboxes?
1307
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1308
-            // if array has more than one element then success message should be plural
1309
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1310
-            // cycle thru the boxes
1311
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1312
-                if ($trash) {
1313
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1314
-                        $success = 0;
1315
-                    }
1316
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1317
-                    $success = 0;
1318
-                }
1319
-            }
1320
-        } else {
1321
-            // grab single id and trash
1322
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1323
-            if ($trash) {
1324
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1325
-                    $success = 0;
1326
-                }
1327
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1328
-                $success = 0;
1329
-            }
1330
-        }
1331
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1332
-        $query_args = array(
1333
-            'action' => 'ticket_list_table',
1334
-            'status' => $trash ? '' : 'trashed',
1335
-        );
1336
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1337
-    }
1338
-
1339
-
1340
-    /**
1341
-     * Handles trashing default ticket.
1342
-     *
1343
-     * @throws EE_Error
1344
-     * @throws InvalidArgumentException
1345
-     * @throws InvalidDataTypeException
1346
-     * @throws InvalidInterfaceException
1347
-     * @throws ReflectionException
1348
-     */
1349
-    protected function _delete_ticket()
1350
-    {
1351
-        $success = 1;
1352
-        // checkboxes?
1353
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1354
-            // if array has more than one element then success message should be plural
1355
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1356
-            // cycle thru the boxes
1357
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1358
-                // delete
1359
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1360
-                    $success = 0;
1361
-                }
1362
-            }
1363
-        } else {
1364
-            // grab single id and trash
1365
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1366
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1367
-                $success = 0;
1368
-            }
1369
-        }
1370
-        $action_desc = 'deleted';
1371
-        $query_args = array(
1372
-            'action' => 'ticket_list_table',
1373
-            'status' => 'trashed',
1374
-        );
1375
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1376
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1377
-            array(array('TKT_is_default' => 1)),
1378
-            'TKT_ID',
1379
-            true
1380
-        )
1381
-        ) {
1382
-            $query_args = array();
1383
-        }
1384
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1385
-    }
1386
-
1387
-
1388
-    /**
1389
-     * @param int $TKT_ID
1390
-     * @return bool|int
1391
-     * @throws EE_Error
1392
-     * @throws InvalidArgumentException
1393
-     * @throws InvalidDataTypeException
1394
-     * @throws InvalidInterfaceException
1395
-     * @throws ReflectionException
1396
-     */
1397
-    protected function _delete_the_ticket($TKT_ID)
1398
-    {
1399
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1400
-        $tkt->_remove_relations('Datetime');
1401
-        // delete all related prices first
1402
-        $tkt->delete_related_permanently('Price');
1403
-        return $tkt->delete_permanently();
1404
-    }
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
+		// setup Advanced Editor ???
228
+		if (isset($this->_req_data['action'])
229
+			&& (
230
+				$this->_req_data['action'] === 'default_event_settings'
231
+				|| $this->_req_data['action'] === 'update_default_event_settings'
232
+			)
233
+		) {
234
+			$this->advanced_editor_admin_form = $this->loader->getShared(
235
+				'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
236
+			);
237
+		}
238
+		if (isset($this->_req_data['action'])
239
+			&& ($this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
240
+		) {
241
+			$this->advanced_editor_data = $this->loader->getShared(
242
+				'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData',
243
+				[$this->_cpt_model_obj]
244
+			);
245
+		}
246
+	}
247
+
248
+
249
+	/**
250
+	 * admin_init
251
+	 */
252
+	public function admin_init()
253
+	{
254
+		EE_Registry::$i18n_js_strings = array_merge(
255
+			EE_Registry::$i18n_js_strings,
256
+			array(
257
+				'image_confirm'          => esc_html__(
258
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
259
+					'event_espresso'
260
+				),
261
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
262
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
263
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
264
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
265
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
266
+			)
267
+		);
268
+	}
269
+
270
+
271
+	/**
272
+	 * Add per page screen options to the default ticket list table view.
273
+	 *
274
+	 * @throws InvalidArgumentException
275
+	 * @throws InvalidDataTypeException
276
+	 * @throws InvalidInterfaceException
277
+	 */
278
+	protected function _add_screen_options_ticket_list_table()
279
+	{
280
+		$this->_per_page_screen_option();
281
+	}
282
+
283
+
284
+	/**
285
+	 * @param string $return
286
+	 * @param int    $id
287
+	 * @param string $new_title
288
+	 * @param string $new_slug
289
+	 * @return string
290
+	 */
291
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
292
+	{
293
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
294
+		// make sure this is only when editing
295
+		if (! empty($id)) {
296
+			$href = EE_Admin_Page::add_query_args_and_nonce(
297
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
298
+				$this->_admin_base_url
299
+			);
300
+			$title = esc_attr__('Duplicate Event', 'event_espresso');
301
+			$return .= '<a href="'
302
+					   . $href
303
+					   . '" title="'
304
+					   . $title
305
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
306
+					   . $title
307
+					   . '</a>';
308
+		}
309
+		return $return;
310
+	}
311
+
312
+
313
+	/**
314
+	 * Set the list table views for the default ticket list table view.
315
+	 */
316
+	public function _set_list_table_views_ticket_list_table()
317
+	{
318
+		$this->_views = array(
319
+			'all'     => array(
320
+				'slug'        => 'all',
321
+				'label'       => esc_html__('All', 'event_espresso'),
322
+				'count'       => 0,
323
+				'bulk_action' => array(
324
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
325
+				),
326
+			),
327
+			'trashed' => array(
328
+				'slug'        => 'trashed',
329
+				'label'       => esc_html__('Trash', 'event_espresso'),
330
+				'count'       => 0,
331
+				'bulk_action' => array(
332
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
333
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
334
+				),
335
+			),
336
+		);
337
+	}
338
+
339
+
340
+	/**
341
+	 * Enqueue scripts and styles for the event editor.
342
+	 */
343
+	public function load_scripts_styles_edit()
344
+	{
345
+		wp_register_script(
346
+			'ee-event-editor-heartbeat',
347
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
348
+			array('ee_admin_js', 'heartbeat'),
349
+			EVENT_ESPRESSO_VERSION,
350
+			true
351
+		);
352
+		wp_enqueue_script('ee-accounting');
353
+		// styles
354
+		wp_enqueue_style('espresso-ui-theme');
355
+		wp_enqueue_script('event_editor_js');
356
+		wp_enqueue_script('ee-event-editor-heartbeat');
357
+	}
358
+
359
+
360
+	/**
361
+	 * Returns template for the additional datetime.
362
+	 *
363
+	 * @param $template
364
+	 * @param $template_args
365
+	 * @return mixed
366
+	 * @throws DomainException
367
+	 */
368
+	public function add_additional_datetime_button($template, $template_args)
369
+	{
370
+		return EEH_Template::display_template(
371
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
372
+			$template_args,
373
+			true
374
+		);
375
+	}
376
+
377
+
378
+	/**
379
+	 * Returns the template for cloning a datetime.
380
+	 *
381
+	 * @param $template
382
+	 * @param $template_args
383
+	 * @return mixed
384
+	 * @throws DomainException
385
+	 */
386
+	public function add_datetime_clone_button($template, $template_args)
387
+	{
388
+		return EEH_Template::display_template(
389
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
390
+			$template_args,
391
+			true
392
+		);
393
+	}
394
+
395
+
396
+	/**
397
+	 * Returns the template for datetime timezones.
398
+	 *
399
+	 * @param $template
400
+	 * @param $template_args
401
+	 * @return mixed
402
+	 * @throws DomainException
403
+	 */
404
+	public function datetime_timezones_template($template, $template_args)
405
+	{
406
+		return EEH_Template::display_template(
407
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
408
+			$template_args,
409
+			true
410
+		);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Sets the views for the default list table view.
416
+	 */
417
+	protected function _set_list_table_views_default()
418
+	{
419
+		parent::_set_list_table_views_default();
420
+		$new_views = array(
421
+			'today' => array(
422
+				'slug'        => 'today',
423
+				'label'       => esc_html__('Today', 'event_espresso'),
424
+				'count'       => $this->total_events_today(),
425
+				'bulk_action' => array(
426
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
427
+				),
428
+			),
429
+			'month' => array(
430
+				'slug'        => 'month',
431
+				'label'       => esc_html__('This Month', 'event_espresso'),
432
+				'count'       => $this->total_events_this_month(),
433
+				'bulk_action' => array(
434
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
435
+				),
436
+			),
437
+		);
438
+		$this->_views = array_merge($this->_views, $new_views);
439
+	}
440
+
441
+
442
+	/**
443
+	 * Returns the extra action links for the default list table view.
444
+	 *
445
+	 * @param array    $action_links
446
+	 * @param EE_Event $event
447
+	 * @return array
448
+	 * @throws EE_Error
449
+	 * @throws InvalidArgumentException
450
+	 * @throws InvalidDataTypeException
451
+	 * @throws InvalidInterfaceException
452
+	 * @throws ReflectionException
453
+	 */
454
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
455
+	{
456
+		if (EE_Registry::instance()->CAP->current_user_can(
457
+			'ee_read_registrations',
458
+			'espresso_registrations_reports',
459
+			$event->ID()
460
+		)
461
+		) {
462
+			$reports_query_args = array(
463
+				'action' => 'reports',
464
+				'EVT_ID' => $event->ID(),
465
+			);
466
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
467
+			$action_links[] = '<a href="'
468
+							  . $reports_link
469
+							  . '" title="'
470
+							  . esc_attr__('View Report', 'event_espresso')
471
+							  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
472
+							  . "\n\t";
473
+		}
474
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
475
+			EE_Registry::instance()->load_helper('MSG_Template');
476
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
477
+				'see_notifications_for',
478
+				null,
479
+				array('EVT_ID' => $event->ID())
480
+			);
481
+		}
482
+		return $action_links;
483
+	}
484
+
485
+
486
+	/**
487
+	 * @param $items
488
+	 * @return mixed
489
+	 */
490
+	public function additional_legend_items($items)
491
+	{
492
+		if (EE_Registry::instance()->CAP->current_user_can(
493
+			'ee_read_registrations',
494
+			'espresso_registrations_reports'
495
+		)
496
+		) {
497
+			$items['reports'] = array(
498
+				'class' => 'dashicons dashicons-chart-bar',
499
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
500
+			);
501
+		}
502
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
503
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
504
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
505
+			// (can only use numeric offsets when treating strings as arrays)
506
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
507
+				$items['view_related_messages'] = array(
508
+					'class' => $related_for_icon['css_class'],
509
+					'desc'  => $related_for_icon['label'],
510
+				);
511
+			}
512
+		}
513
+		return $items;
514
+	}
515
+
516
+
517
+	/**
518
+	 * This is the callback method for the duplicate event route
519
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
520
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
521
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
522
+	 * After duplication the redirect is to the new event edit page.
523
+	 *
524
+	 * @return void
525
+	 * @throws EE_Error If EE_Event is not available with given ID
526
+	 * @throws InvalidArgumentException
527
+	 * @throws InvalidDataTypeException
528
+	 * @throws InvalidInterfaceException
529
+	 * @throws ReflectionException
530
+	 * @access protected
531
+	 */
532
+	protected function _duplicate_event()
533
+	{
534
+		// first make sure the ID for the event is in the request.
535
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
536
+		if (! isset($this->_req_data['EVT_ID'])) {
537
+			EE_Error::add_error(
538
+				esc_html__(
539
+					'In order to duplicate an event an Event ID is required.  None was given.',
540
+					'event_espresso'
541
+				),
542
+				__FILE__,
543
+				__FUNCTION__,
544
+				__LINE__
545
+			);
546
+			$this->_redirect_after_action(false, '', '', array(), true);
547
+			return;
548
+		}
549
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
550
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
551
+		if (! $orig_event instanceof EE_Event) {
552
+			throw new EE_Error(
553
+				sprintf(
554
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
555
+					$this->_req_data['EVT_ID']
556
+				)
557
+			);
558
+		}
559
+		// k now let's clone the $orig_event before getting relations
560
+		$new_event = clone $orig_event;
561
+		// original datetimes
562
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
563
+		// other original relations
564
+		$orig_ven = $orig_event->get_many_related('Venue');
565
+		// reset the ID and modify other details to make it clear this is a dupe
566
+		$new_event->set('EVT_ID', 0);
567
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
568
+		$new_event->set('EVT_name', $new_name);
569
+		$new_event->set(
570
+			'EVT_slug',
571
+			wp_unique_post_slug(
572
+				sanitize_title($orig_event->name()),
573
+				0,
574
+				'publish',
575
+				'espresso_events',
576
+				0
577
+			)
578
+		);
579
+		$new_event->set('status', 'draft');
580
+		// duplicate discussion settings
581
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
582
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
583
+		// save the new event
584
+		$new_event->save();
585
+		// venues
586
+		foreach ($orig_ven as $ven) {
587
+			$new_event->_add_relation_to($ven, 'Venue');
588
+		}
589
+		$new_event->save();
590
+		// now we need to get the question group relations and handle that
591
+		// first primary question groups
592
+		$orig_primary_qgs = $orig_event->get_many_related(
593
+			'Question_Group',
594
+			[['Event_Question_Group.EQG_primary' => true]]
595
+		);
596
+		if (! empty($orig_primary_qgs)) {
597
+			foreach ($orig_primary_qgs as $id => $obj) {
598
+				if ($obj instanceof EE_Question_Group) {
599
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
600
+				}
601
+			}
602
+		}
603
+		// next additional attendee question groups
604
+		$orig_additional_qgs = $orig_event->get_many_related(
605
+			'Question_Group',
606
+			[['Event_Question_Group.EQG_additional' => true]]
607
+		);
608
+		if (! empty($orig_additional_qgs)) {
609
+			foreach ($orig_additional_qgs as $id => $obj) {
610
+				if ($obj instanceof EE_Question_Group) {
611
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
612
+				}
613
+			}
614
+		}
615
+
616
+		$new_event->save();
617
+
618
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
619
+		$cloned_tickets = array();
620
+		foreach ($orig_datetimes as $orig_dtt) {
621
+			if (! $orig_dtt instanceof EE_Datetime) {
622
+				continue;
623
+			}
624
+			$new_dtt = clone $orig_dtt;
625
+			$orig_tkts = $orig_dtt->tickets();
626
+			// save new dtt then add to event
627
+			$new_dtt->set('DTT_ID', 0);
628
+			$new_dtt->set('DTT_sold', 0);
629
+			$new_dtt->set_reserved(0);
630
+			$new_dtt->save();
631
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
632
+			$new_event->save();
633
+			// now let's get the ticket relations setup.
634
+			foreach ((array) $orig_tkts as $orig_tkt) {
635
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
636
+				if (! $orig_tkt instanceof EE_Ticket) {
637
+					continue;
638
+				}
639
+				// is this ticket archived?  If it is then let's skip
640
+				if ($orig_tkt->get('TKT_deleted')) {
641
+					continue;
642
+				}
643
+				// does this original ticket already exist in the clone_tickets cache?
644
+				//  If so we'll just use the new ticket from it.
645
+				if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
646
+					$new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
647
+				} else {
648
+					$new_tkt = clone $orig_tkt;
649
+					// get relations on the $orig_tkt that we need to setup.
650
+					$orig_prices = $orig_tkt->prices();
651
+					$new_tkt->set('TKT_ID', 0);
652
+					$new_tkt->set('TKT_sold', 0);
653
+					$new_tkt->set('TKT_reserved', 0);
654
+					$new_tkt->save(); // make sure new ticket has ID.
655
+					// price relations on new ticket need to be setup.
656
+					foreach ($orig_prices as $orig_price) {
657
+						$new_price = clone $orig_price;
658
+						$new_price->set('PRC_ID', 0);
659
+						$new_price->save();
660
+						$new_tkt->_add_relation_to($new_price, 'Price');
661
+						$new_tkt->save();
662
+					}
663
+
664
+					do_action(
665
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
666
+						$orig_tkt,
667
+						$new_tkt,
668
+						$orig_prices,
669
+						$orig_event,
670
+						$orig_dtt,
671
+						$new_dtt
672
+					);
673
+				}
674
+				// k now we can add the new ticket as a relation to the new datetime
675
+				// and make sure its added to our cached $cloned_tickets array
676
+				// for use with later datetimes that have the same ticket.
677
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
678
+				$new_dtt->save();
679
+				$cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
680
+			}
681
+		}
682
+		// clone taxonomy information
683
+		$taxonomies_to_clone_with = apply_filters(
684
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
685
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
686
+		);
687
+		// get terms for original event (notice)
688
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
689
+		// loop through terms and add them to new event.
690
+		foreach ($orig_terms as $term) {
691
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
692
+		}
693
+
694
+		// duplicate other core WP_Post items for this event.
695
+		// post thumbnail (feature image).
696
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
697
+		if ($feature_image_id) {
698
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
699
+		}
700
+
701
+		// duplicate page_template setting
702
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
703
+		if ($page_template) {
704
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
705
+		}
706
+
707
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
708
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
709
+		if ($new_event->ID()) {
710
+			$redirect_args = array(
711
+				'post'   => $new_event->ID(),
712
+				'action' => 'edit',
713
+			);
714
+			EE_Error::add_success(
715
+				esc_html__(
716
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
717
+					'event_espresso'
718
+				)
719
+			);
720
+		} else {
721
+			$redirect_args = array(
722
+				'action' => 'default',
723
+			);
724
+			EE_Error::add_error(
725
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
726
+				__FILE__,
727
+				__FUNCTION__,
728
+				__LINE__
729
+			);
730
+		}
731
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
732
+	}
733
+
734
+
735
+	/**
736
+	 * Generates output for the import page.
737
+	 *
738
+	 * @throws DomainException
739
+	 * @throws EE_Error
740
+	 * @throws InvalidArgumentException
741
+	 * @throws InvalidDataTypeException
742
+	 * @throws InvalidInterfaceException
743
+	 */
744
+	protected function _import_page()
745
+	{
746
+		$title = esc_html__('Import', 'event_espresso');
747
+		$intro = esc_html__(
748
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
749
+			'event_espresso'
750
+		);
751
+		$form_url = EVENTS_ADMIN_URL;
752
+		$action = 'import_events';
753
+		$type = 'csv';
754
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
755
+			$title,
756
+			$intro,
757
+			$form_url,
758
+			$action,
759
+			$type
760
+		);
761
+		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
762
+			array('action' => 'sample_export_file'),
763
+			$this->_admin_base_url
764
+		);
765
+		$content = EEH_Template::display_template(
766
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
767
+			$this->_template_args,
768
+			true
769
+		);
770
+		$this->_template_args['admin_page_content'] = $content;
771
+		$this->display_admin_page_with_sidebar();
772
+	}
773
+
774
+
775
+	/**
776
+	 * _import_events
777
+	 * This handles displaying the screen and running imports for importing events.
778
+	 *
779
+	 * @return void
780
+	 * @throws EE_Error
781
+	 * @throws InvalidArgumentException
782
+	 * @throws InvalidDataTypeException
783
+	 * @throws InvalidInterfaceException
784
+	 */
785
+	protected function _import_events()
786
+	{
787
+		require_once(EE_CLASSES . 'EE_Import.class.php');
788
+		$success = EE_Import::instance()->import();
789
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
790
+	}
791
+
792
+
793
+	/**
794
+	 * _events_export
795
+	 * Will export all (or just the given event) to a Excel compatible file.
796
+	 *
797
+	 * @access protected
798
+	 * @return void
799
+	 */
800
+	protected function _events_export()
801
+	{
802
+		if (isset($this->_req_data['EVT_ID'])) {
803
+			$event_ids = $this->_req_data['EVT_ID'];
804
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
805
+			$event_ids = $this->_req_data['EVT_IDs'];
806
+		} else {
807
+			$event_ids = null;
808
+		}
809
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
810
+		$new_request_args = array(
811
+			'export' => 'report',
812
+			'action' => 'all_event_data',
813
+			'EVT_ID' => $event_ids,
814
+		);
815
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
816
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
817
+			require_once(EE_CLASSES . 'EE_Export.class.php');
818
+			$EE_Export = EE_Export::instance($this->_req_data);
819
+			$EE_Export->export();
820
+		}
821
+	}
822
+
823
+
824
+	/**
825
+	 * handle category exports()
826
+	 *
827
+	 * @return void
828
+	 */
829
+	protected function _categories_export()
830
+	{
831
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
832
+		$new_request_args = array(
833
+			'export'       => 'report',
834
+			'action'       => 'categories',
835
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
836
+		);
837
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
838
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
839
+			require_once(EE_CLASSES . 'EE_Export.class.php');
840
+			$EE_Export = EE_Export::instance($this->_req_data);
841
+			$EE_Export->export();
842
+		}
843
+	}
844
+
845
+
846
+	/**
847
+	 * Creates a sample CSV file for importing
848
+	 */
849
+	protected function _sample_export_file()
850
+	{
851
+		// require_once(EE_CLASSES . 'EE_Export.class.php');
852
+		EE_Export::instance()->export_sample();
853
+	}
854
+
855
+
856
+	/*************        Template Settings        *************/
857
+	/**
858
+	 * Generates template settings page output
859
+	 *
860
+	 * @throws DomainException
861
+	 * @throws EE_Error
862
+	 * @throws InvalidArgumentException
863
+	 * @throws InvalidDataTypeException
864
+	 * @throws InvalidInterfaceException
865
+	 */
866
+	protected function _template_settings()
867
+	{
868
+		$this->_template_args['values'] = $this->_yes_no_values;
869
+		/**
870
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
871
+		 * from General_Settings_Admin_Page to here.
872
+		 */
873
+		$this->_template_args = apply_filters(
874
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
875
+			$this->_template_args
876
+		);
877
+		$this->_set_add_edit_form_tags('update_template_settings');
878
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
879
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
880
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
881
+			$this->_template_args,
882
+			true
883
+		);
884
+		$this->display_admin_page_with_sidebar();
885
+	}
886
+
887
+
888
+	/**
889
+	 * Handler for updating template settings.
890
+	 *
891
+	 * @throws EE_Error
892
+	 * @throws InvalidArgumentException
893
+	 * @throws InvalidDataTypeException
894
+	 * @throws InvalidInterfaceException
895
+	 */
896
+	protected function _update_template_settings()
897
+	{
898
+		/**
899
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
900
+		 * from General_Settings_Admin_Page to here.
901
+		 */
902
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
903
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
904
+			EE_Registry::instance()->CFG->template_settings,
905
+			$this->_req_data
906
+		);
907
+		// update custom post type slugs and detect if we need to flush rewrite rules
908
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
909
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
910
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
911
+			: EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
912
+		$what = 'Template Settings';
913
+		$success = $this->_update_espresso_configuration(
914
+			$what,
915
+			EE_Registry::instance()->CFG->template_settings,
916
+			__FILE__,
917
+			__FUNCTION__,
918
+			__LINE__
919
+		);
920
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
921
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
922
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
923
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
924
+			);
925
+			$rewrite_rules->flush();
926
+		}
927
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
928
+	}
929
+
930
+
931
+	/**
932
+	 * _premium_event_editor_meta_boxes
933
+	 * add all metaboxes related to the event_editor
934
+	 *
935
+	 * @access protected
936
+	 * @return void
937
+	 * @throws EE_Error
938
+	 * @throws InvalidArgumentException
939
+	 * @throws InvalidDataTypeException
940
+	 * @throws InvalidInterfaceException
941
+	 * @throws ReflectionException
942
+	 */
943
+	protected function _premium_event_editor_meta_boxes()
944
+	{
945
+		$this->verify_cpt_object();
946
+		add_meta_box(
947
+			'espresso_event_editor_event_options',
948
+			esc_html__('Event Registration Options', 'event_espresso'),
949
+			array($this, 'registration_options_meta_box'),
950
+			$this->page_slug,
951
+			'side',
952
+			'core'
953
+		);
954
+	}
955
+
956
+
957
+	/**
958
+	 * override caf metabox
959
+	 *
960
+	 * @return void
961
+	 * @throws DomainException
962
+	 * @throws EE_Error
963
+	 */
964
+	public function registration_options_meta_box()
965
+	{
966
+		$yes_no_values = array(
967
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
968
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
969
+		);
970
+		$default_reg_status_values = EEM_Registration::reg_status_array(
971
+			array(
972
+				EEM_Registration::status_id_cancelled,
973
+				EEM_Registration::status_id_declined,
974
+				EEM_Registration::status_id_incomplete,
975
+				EEM_Registration::status_id_wait_list,
976
+			),
977
+			true
978
+		);
979
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
980
+		$template_args['_event'] = $this->_cpt_model_obj;
981
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
982
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
983
+			'default_reg_status',
984
+			$default_reg_status_values,
985
+			$this->_cpt_model_obj->default_registration_status()
986
+		);
987
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
988
+			'display_desc',
989
+			$yes_no_values,
990
+			$this->_cpt_model_obj->display_description()
991
+		);
992
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
993
+			'display_ticket_selector',
994
+			$yes_no_values,
995
+			$this->_cpt_model_obj->display_ticket_selector(),
996
+			'',
997
+			'',
998
+			false
999
+		);
1000
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1001
+			'EVT_default_registration_status',
1002
+			$default_reg_status_values,
1003
+			$this->_cpt_model_obj->default_registration_status()
1004
+		);
1005
+		$template_args['additional_registration_options'] = apply_filters(
1006
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1007
+			'',
1008
+			$template_args,
1009
+			$yes_no_values,
1010
+			$default_reg_status_values
1011
+		);
1012
+		EEH_Template::display_template(
1013
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1014
+			$template_args
1015
+		);
1016
+	}
1017
+
1018
+
1019
+
1020
+	/**
1021
+	 * wp_list_table_mods for caf
1022
+	 * ============================
1023
+	 */
1024
+	/**
1025
+	 * hook into list table filters and provide filters for caffeinated list table
1026
+	 *
1027
+	 * @param array $old_filters    any existing filters present
1028
+	 * @param array $list_table_obj the list table object
1029
+	 * @return array                  new filters
1030
+	 * @throws EE_Error
1031
+	 * @throws InvalidArgumentException
1032
+	 * @throws InvalidDataTypeException
1033
+	 * @throws InvalidInterfaceException
1034
+	 * @throws ReflectionException
1035
+	 */
1036
+	public function list_table_filters($old_filters, $list_table_obj)
1037
+	{
1038
+		$filters = array();
1039
+		// first month/year filters
1040
+		$filters[] = $this->espresso_event_months_dropdown();
1041
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1042
+		// active status dropdown
1043
+		if ($status !== 'draft') {
1044
+			$filters[] = $this->active_status_dropdown(
1045
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1046
+			);
1047
+			$filters[] = $this->venuesDropdown(
1048
+				isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1049
+			);
1050
+		}
1051
+		// category filter
1052
+		$filters[] = $this->category_dropdown();
1053
+		return array_merge($old_filters, $filters);
1054
+	}
1055
+
1056
+
1057
+	/**
1058
+	 * espresso_event_months_dropdown
1059
+	 *
1060
+	 * @access public
1061
+	 * @return string                dropdown listing month/year selections for events.
1062
+	 */
1063
+	public function espresso_event_months_dropdown()
1064
+	{
1065
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1066
+		// Note we need to include any other filters that are set!
1067
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1068
+		// categories?
1069
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1070
+			? $this->_req_data['EVT_CAT']
1071
+			: null;
1072
+		// active status?
1073
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1074
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1075
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1076
+	}
1077
+
1078
+
1079
+	/**
1080
+	 * returns a list of "active" statuses on the event
1081
+	 *
1082
+	 * @param  string $current_value whatever the current active status is
1083
+	 * @return string
1084
+	 */
1085
+	public function active_status_dropdown($current_value = '')
1086
+	{
1087
+		$select_name = 'active_status';
1088
+		$values = array(
1089
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1090
+			'active'   => esc_html__('Active', 'event_espresso'),
1091
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1092
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1093
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1094
+		);
1095
+
1096
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1097
+	}
1098
+
1099
+
1100
+	/**
1101
+	 * returns a list of "venues"
1102
+	 *
1103
+	 * @param string $current_value whatever the current active status is
1104
+	 * @return string
1105
+	 * @throws EE_Error
1106
+	 * @throws InvalidArgumentException
1107
+	 * @throws InvalidDataTypeException
1108
+	 * @throws InvalidInterfaceException
1109
+	 * @throws ReflectionException
1110
+	 */
1111
+	protected function venuesDropdown($current_value = '')
1112
+	{
1113
+		$select_name = 'venue';
1114
+		$values = array(
1115
+			'' => esc_html__('All Venues', 'event_espresso'),
1116
+		);
1117
+		// populate the list of venues.
1118
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1119
+		$venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1120
+
1121
+		foreach ($venues as $venue) {
1122
+			$values[ $venue->ID() ] = $venue->name();
1123
+		}
1124
+
1125
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1126
+	}
1127
+
1128
+
1129
+	/**
1130
+	 * output a dropdown of the categories for the category filter on the event admin list table
1131
+	 *
1132
+	 * @access  public
1133
+	 * @return string html
1134
+	 */
1135
+	public function category_dropdown()
1136
+	{
1137
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1138
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1139
+	}
1140
+
1141
+
1142
+	/**
1143
+	 * get total number of events today
1144
+	 *
1145
+	 * @access public
1146
+	 * @return int
1147
+	 * @throws EE_Error
1148
+	 * @throws InvalidArgumentException
1149
+	 * @throws InvalidDataTypeException
1150
+	 * @throws InvalidInterfaceException
1151
+	 */
1152
+	public function total_events_today()
1153
+	{
1154
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1155
+			'DTT_EVT_start',
1156
+			date('Y-m-d') . ' 00:00:00',
1157
+			'Y-m-d H:i:s',
1158
+			'UTC'
1159
+		);
1160
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1161
+			'DTT_EVT_start',
1162
+			date('Y-m-d') . ' 23:59:59',
1163
+			'Y-m-d H:i:s',
1164
+			'UTC'
1165
+		);
1166
+		$where = array(
1167
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1168
+		);
1169
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1170
+		return $count;
1171
+	}
1172
+
1173
+
1174
+	/**
1175
+	 * get total number of events this month
1176
+	 *
1177
+	 * @access public
1178
+	 * @return int
1179
+	 * @throws EE_Error
1180
+	 * @throws InvalidArgumentException
1181
+	 * @throws InvalidDataTypeException
1182
+	 * @throws InvalidInterfaceException
1183
+	 */
1184
+	public function total_events_this_month()
1185
+	{
1186
+		// Dates
1187
+		$this_year_r = date('Y');
1188
+		$this_month_r = date('m');
1189
+		$days_this_month = date('t');
1190
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1191
+			'DTT_EVT_start',
1192
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1193
+			'Y-m-d H:i:s',
1194
+			'UTC'
1195
+		);
1196
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1197
+			'DTT_EVT_start',
1198
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1199
+			'Y-m-d H:i:s',
1200
+			'UTC'
1201
+		);
1202
+		$where = array(
1203
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1204
+		);
1205
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1206
+		return $count;
1207
+	}
1208
+
1209
+
1210
+	/** DEFAULT TICKETS STUFF **/
1211
+
1212
+	/**
1213
+	 * Output default tickets list table view.
1214
+	 *
1215
+	 * @throws DomainException
1216
+	 * @throws EE_Error
1217
+	 * @throws InvalidArgumentException
1218
+	 * @throws InvalidDataTypeException
1219
+	 * @throws InvalidInterfaceException
1220
+	 */
1221
+	public function _tickets_overview_list_table()
1222
+	{
1223
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1224
+		$this->display_admin_list_table_page_with_no_sidebar();
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * @param int  $per_page
1230
+	 * @param bool $count
1231
+	 * @param bool $trashed
1232
+	 * @return EE_Soft_Delete_Base_Class[]|int
1233
+	 * @throws EE_Error
1234
+	 * @throws InvalidArgumentException
1235
+	 * @throws InvalidDataTypeException
1236
+	 * @throws InvalidInterfaceException
1237
+	 */
1238
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1239
+	{
1240
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1241
+		$order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1242
+		switch ($orderby) {
1243
+			case 'TKT_name':
1244
+				$orderby = array('TKT_name' => $order);
1245
+				break;
1246
+			case 'TKT_price':
1247
+				$orderby = array('TKT_price' => $order);
1248
+				break;
1249
+			case 'TKT_uses':
1250
+				$orderby = array('TKT_uses' => $order);
1251
+				break;
1252
+			case 'TKT_min':
1253
+				$orderby = array('TKT_min' => $order);
1254
+				break;
1255
+			case 'TKT_max':
1256
+				$orderby = array('TKT_max' => $order);
1257
+				break;
1258
+			case 'TKT_qty':
1259
+				$orderby = array('TKT_qty' => $order);
1260
+				break;
1261
+		}
1262
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1263
+			? $this->_req_data['paged']
1264
+			: 1;
1265
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1266
+			? $this->_req_data['perpage']
1267
+			: $per_page;
1268
+		$_where = array(
1269
+			'TKT_is_default' => 1,
1270
+			'TKT_deleted'    => $trashed,
1271
+		);
1272
+		$offset = ($current_page - 1) * $per_page;
1273
+		$limit = array($offset, $per_page);
1274
+		if (isset($this->_req_data['s'])) {
1275
+			$sstr = '%' . $this->_req_data['s'] . '%';
1276
+			$_where['OR'] = array(
1277
+				'TKT_name'        => array('LIKE', $sstr),
1278
+				'TKT_description' => array('LIKE', $sstr),
1279
+			);
1280
+		}
1281
+		$query_params = array(
1282
+			$_where,
1283
+			'order_by' => $orderby,
1284
+			'limit'    => $limit,
1285
+			'group_by' => 'TKT_ID',
1286
+		);
1287
+		if ($count) {
1288
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1289
+		} else {
1290
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1291
+		}
1292
+	}
1293
+
1294
+
1295
+	/**
1296
+	 * @param bool $trash
1297
+	 * @throws EE_Error
1298
+	 * @throws InvalidArgumentException
1299
+	 * @throws InvalidDataTypeException
1300
+	 * @throws InvalidInterfaceException
1301
+	 */
1302
+	protected function _trash_or_restore_ticket($trash = false)
1303
+	{
1304
+		$success = 1;
1305
+		$TKT = EEM_Ticket::instance();
1306
+		// checkboxes?
1307
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1308
+			// if array has more than one element then success message should be plural
1309
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1310
+			// cycle thru the boxes
1311
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1312
+				if ($trash) {
1313
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1314
+						$success = 0;
1315
+					}
1316
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1317
+					$success = 0;
1318
+				}
1319
+			}
1320
+		} else {
1321
+			// grab single id and trash
1322
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1323
+			if ($trash) {
1324
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1325
+					$success = 0;
1326
+				}
1327
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1328
+				$success = 0;
1329
+			}
1330
+		}
1331
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1332
+		$query_args = array(
1333
+			'action' => 'ticket_list_table',
1334
+			'status' => $trash ? '' : 'trashed',
1335
+		);
1336
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1337
+	}
1338
+
1339
+
1340
+	/**
1341
+	 * Handles trashing default ticket.
1342
+	 *
1343
+	 * @throws EE_Error
1344
+	 * @throws InvalidArgumentException
1345
+	 * @throws InvalidDataTypeException
1346
+	 * @throws InvalidInterfaceException
1347
+	 * @throws ReflectionException
1348
+	 */
1349
+	protected function _delete_ticket()
1350
+	{
1351
+		$success = 1;
1352
+		// checkboxes?
1353
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1354
+			// if array has more than one element then success message should be plural
1355
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1356
+			// cycle thru the boxes
1357
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1358
+				// delete
1359
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1360
+					$success = 0;
1361
+				}
1362
+			}
1363
+		} else {
1364
+			// grab single id and trash
1365
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1366
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1367
+				$success = 0;
1368
+			}
1369
+		}
1370
+		$action_desc = 'deleted';
1371
+		$query_args = array(
1372
+			'action' => 'ticket_list_table',
1373
+			'status' => 'trashed',
1374
+		);
1375
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1376
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1377
+			array(array('TKT_is_default' => 1)),
1378
+			'TKT_ID',
1379
+			true
1380
+		)
1381
+		) {
1382
+			$query_args = array();
1383
+		}
1384
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1385
+	}
1386
+
1387
+
1388
+	/**
1389
+	 * @param int $TKT_ID
1390
+	 * @return bool|int
1391
+	 * @throws EE_Error
1392
+	 * @throws InvalidArgumentException
1393
+	 * @throws InvalidDataTypeException
1394
+	 * @throws InvalidInterfaceException
1395
+	 * @throws ReflectionException
1396
+	 */
1397
+	protected function _delete_the_ticket($TKT_ID)
1398
+	{
1399
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1400
+		$tkt->_remove_relations('Datetime');
1401
+		// delete all related prices first
1402
+		$tkt->delete_related_permanently('Price');
1403
+		return $tkt->delete_permanently();
1404
+	}
1405 1405
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 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']
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     {
293 293
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
294 294
         // make sure this is only when editing
295
-        if (! empty($id)) {
295
+        if ( ! empty($id)) {
296 296
             $href = EE_Admin_Page::add_query_args_and_nonce(
297 297
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
298 298
                 $this->_admin_base_url
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
     {
345 345
         wp_register_script(
346 346
             'ee-event-editor-heartbeat',
347
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
347
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
348 348
             array('ee_admin_js', 'heartbeat'),
349 349
             EVENT_ESPRESSO_VERSION,
350 350
             true
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     public function add_additional_datetime_button($template, $template_args)
369 369
     {
370 370
         return EEH_Template::display_template(
371
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
371
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
372 372
             $template_args,
373 373
             true
374 374
         );
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     public function add_datetime_clone_button($template, $template_args)
387 387
     {
388 388
         return EEH_Template::display_template(
389
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
389
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
390 390
             $template_args,
391 391
             true
392 392
         );
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     public function datetime_timezones_template($template, $template_args)
405 405
     {
406 406
         return EEH_Template::display_template(
407
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
407
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
408 408
             $template_args,
409 409
             true
410 410
         );
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
     {
534 534
         // first make sure the ID for the event is in the request.
535 535
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
536
-        if (! isset($this->_req_data['EVT_ID'])) {
536
+        if ( ! isset($this->_req_data['EVT_ID'])) {
537 537
             EE_Error::add_error(
538 538
                 esc_html__(
539 539
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         }
549 549
         // k we've got EVT_ID so let's use that to get the event we'll duplicate
550 550
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
551
-        if (! $orig_event instanceof EE_Event) {
551
+        if ( ! $orig_event instanceof EE_Event) {
552 552
             throw new EE_Error(
553 553
                 sprintf(
554 554
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         $orig_ven = $orig_event->get_many_related('Venue');
565 565
         // reset the ID and modify other details to make it clear this is a dupe
566 566
         $new_event->set('EVT_ID', 0);
567
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
567
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
568 568
         $new_event->set('EVT_name', $new_name);
569 569
         $new_event->set(
570 570
             'EVT_slug',
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
             'Question_Group',
594 594
             [['Event_Question_Group.EQG_primary' => true]]
595 595
         );
596
-        if (! empty($orig_primary_qgs)) {
596
+        if ( ! empty($orig_primary_qgs)) {
597 597
             foreach ($orig_primary_qgs as $id => $obj) {
598 598
                 if ($obj instanceof EE_Question_Group) {
599 599
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
             'Question_Group',
606 606
             [['Event_Question_Group.EQG_additional' => true]]
607 607
         );
608
-        if (! empty($orig_additional_qgs)) {
608
+        if ( ! empty($orig_additional_qgs)) {
609 609
             foreach ($orig_additional_qgs as $id => $obj) {
610 610
                 if ($obj instanceof EE_Question_Group) {
611 611
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
         // k now that we have the new event saved we can loop through the datetimes and start adding relations.
619 619
         $cloned_tickets = array();
620 620
         foreach ($orig_datetimes as $orig_dtt) {
621
-            if (! $orig_dtt instanceof EE_Datetime) {
621
+            if ( ! $orig_dtt instanceof EE_Datetime) {
622 622
                 continue;
623 623
             }
624 624
             $new_dtt = clone $orig_dtt;
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
             // now let's get the ticket relations setup.
634 634
             foreach ((array) $orig_tkts as $orig_tkt) {
635 635
                 // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
636
-                if (! $orig_tkt instanceof EE_Ticket) {
636
+                if ( ! $orig_tkt instanceof EE_Ticket) {
637 637
                     continue;
638 638
                 }
639 639
                 // is this ticket archived?  If it is then let's skip
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
                 }
643 643
                 // does this original ticket already exist in the clone_tickets cache?
644 644
                 //  If so we'll just use the new ticket from it.
645
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
646
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
645
+                if (isset($cloned_tickets[$orig_tkt->ID()])) {
646
+                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
647 647
                 } else {
648 648
                     $new_tkt = clone $orig_tkt;
649 649
                     // get relations on the $orig_tkt that we need to setup.
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                 // for use with later datetimes that have the same ticket.
677 677
                 $new_dtt->_add_relation_to($new_tkt, 'Ticket');
678 678
                 $new_dtt->save();
679
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
679
+                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
680 680
             }
681 681
         }
682 682
         // clone taxonomy information
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
             $this->_admin_base_url
764 764
         );
765 765
         $content = EEH_Template::display_template(
766
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
766
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
767 767
             $this->_template_args,
768 768
             true
769 769
         );
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
      */
785 785
     protected function _import_events()
786 786
     {
787
-        require_once(EE_CLASSES . 'EE_Import.class.php');
787
+        require_once(EE_CLASSES.'EE_Import.class.php');
788 788
         $success = EE_Import::instance()->import();
789 789
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
790 790
     }
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
             'EVT_ID' => $event_ids,
814 814
         );
815 815
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
816
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
817
-            require_once(EE_CLASSES . 'EE_Export.class.php');
816
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
817
+            require_once(EE_CLASSES.'EE_Export.class.php');
818 818
             $EE_Export = EE_Export::instance($this->_req_data);
819 819
             $EE_Export->export();
820 820
         }
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
836 836
         );
837 837
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
838
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
839
-            require_once(EE_CLASSES . 'EE_Export.class.php');
838
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
839
+            require_once(EE_CLASSES.'EE_Export.class.php');
840 840
             $EE_Export = EE_Export::instance($this->_req_data);
841 841
             $EE_Export->export();
842 842
         }
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
         $this->_set_add_edit_form_tags('update_template_settings');
878 878
         $this->_set_publish_post_box_vars(null, false, false, null, false);
879 879
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
880
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
880
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
881 881
             $this->_template_args,
882 882
             true
883 883
         );
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
             $default_reg_status_values
1011 1011
         );
1012 1012
         EEH_Template::display_template(
1013
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1013
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
1014 1014
             $template_args
1015 1015
         );
1016 1016
     }
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
         $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1120 1120
 
1121 1121
         foreach ($venues as $venue) {
1122
-            $values[ $venue->ID() ] = $venue->name();
1122
+            $values[$venue->ID()] = $venue->name();
1123 1123
         }
1124 1124
 
1125 1125
         return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
@@ -1153,13 +1153,13 @@  discard block
 block discarded – undo
1153 1153
     {
1154 1154
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1155 1155
             'DTT_EVT_start',
1156
-            date('Y-m-d') . ' 00:00:00',
1156
+            date('Y-m-d').' 00:00:00',
1157 1157
             'Y-m-d H:i:s',
1158 1158
             'UTC'
1159 1159
         );
1160 1160
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1161 1161
             'DTT_EVT_start',
1162
-            date('Y-m-d') . ' 23:59:59',
1162
+            date('Y-m-d').' 23:59:59',
1163 1163
             'Y-m-d H:i:s',
1164 1164
             'UTC'
1165 1165
         );
@@ -1189,13 +1189,13 @@  discard block
 block discarded – undo
1189 1189
         $days_this_month = date('t');
1190 1190
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1191 1191
             'DTT_EVT_start',
1192
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1192
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1193 1193
             'Y-m-d H:i:s',
1194 1194
             'UTC'
1195 1195
         );
1196 1196
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1197 1197
             'DTT_EVT_start',
1198
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1198
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1199 1199
             'Y-m-d H:i:s',
1200 1200
             'UTC'
1201 1201
         );
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
         $offset = ($current_page - 1) * $per_page;
1273 1273
         $limit = array($offset, $per_page);
1274 1274
         if (isset($this->_req_data['s'])) {
1275
-            $sstr = '%' . $this->_req_data['s'] . '%';
1275
+            $sstr = '%'.$this->_req_data['s'].'%';
1276 1276
             $_where['OR'] = array(
1277 1277
                 'TKT_name'        => array('LIKE', $sstr),
1278 1278
                 'TKT_description' => array('LIKE', $sstr),
@@ -1304,16 +1304,16 @@  discard block
 block discarded – undo
1304 1304
         $success = 1;
1305 1305
         $TKT = EEM_Ticket::instance();
1306 1306
         // checkboxes?
1307
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1307
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1308 1308
             // if array has more than one element then success message should be plural
1309 1309
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1310 1310
             // cycle thru the boxes
1311 1311
             foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1312 1312
                 if ($trash) {
1313
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1313
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1314 1314
                         $success = 0;
1315 1315
                     }
1316
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1316
+                } elseif ( ! $TKT->restore_by_ID($TKT_ID)) {
1317 1317
                     $success = 0;
1318 1318
                 }
1319 1319
             }
@@ -1321,10 +1321,10 @@  discard block
 block discarded – undo
1321 1321
             // grab single id and trash
1322 1322
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1323 1323
             if ($trash) {
1324
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1324
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1325 1325
                     $success = 0;
1326 1326
                 }
1327
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1327
+            } elseif ( ! $TKT->restore_by_ID($TKT_ID)) {
1328 1328
                 $success = 0;
1329 1329
             }
1330 1330
         }
@@ -1350,20 +1350,20 @@  discard block
 block discarded – undo
1350 1350
     {
1351 1351
         $success = 1;
1352 1352
         // checkboxes?
1353
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1353
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1354 1354
             // if array has more than one element then success message should be plural
1355 1355
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1356 1356
             // cycle thru the boxes
1357 1357
             foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1358 1358
                 // delete
1359
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1359
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1360 1360
                     $success = 0;
1361 1361
                 }
1362 1362
             }
1363 1363
         } else {
1364 1364
             // grab single id and trash
1365 1365
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1366
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1366
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1367 1367
                 $success = 0;
1368 1368
             }
1369 1369
         }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4126 added lines, -4126 removed lines patch added patch discarded remove patch
@@ -17,4194 +17,4194 @@
 block discarded – undo
17 17
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    protected $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	protected $loader;
24 24
 
25
-    // set in _init_page_props()
26
-    public $page_slug;
25
+	// set in _init_page_props()
26
+	public $page_slug;
27 27
 
28
-    public $page_label;
28
+	public $page_label;
29 29
 
30
-    public $page_folder;
30
+	public $page_folder;
31 31
 
32
-    // set in define_page_props()
33
-    protected $_admin_base_url;
32
+	// set in define_page_props()
33
+	protected $_admin_base_url;
34 34
 
35
-    protected $_admin_base_path;
35
+	protected $_admin_base_path;
36 36
 
37
-    protected $_admin_page_title;
37
+	protected $_admin_page_title;
38 38
 
39
-    protected $_labels;
39
+	protected $_labels;
40 40
 
41 41
 
42
-    // set early within EE_Admin_Init
43
-    protected $_wp_page_slug;
42
+	// set early within EE_Admin_Init
43
+	protected $_wp_page_slug;
44 44
 
45
-    // nav tabs
46
-    protected $_nav_tabs;
45
+	// nav tabs
46
+	protected $_nav_tabs;
47 47
 
48
-    protected $_default_nav_tab_name;
48
+	protected $_default_nav_tab_name;
49 49
 
50
-    /**
51
-     * @var array $_help_tour
52
-     */
53
-    protected $_help_tour = array();
50
+	/**
51
+	 * @var array $_help_tour
52
+	 */
53
+	protected $_help_tour = array();
54 54
 
55 55
 
56
-    // template variables (used by templates)
57
-    protected $_template_path;
56
+	// template variables (used by templates)
57
+	protected $_template_path;
58 58
 
59
-    protected $_column_template_path;
59
+	protected $_column_template_path;
60 60
 
61
-    /**
62
-     * @var array $_template_args
63
-     */
64
-    protected $_template_args = array();
61
+	/**
62
+	 * @var array $_template_args
63
+	 */
64
+	protected $_template_args = array();
65 65
 
66
-    /**
67
-     * this will hold the list table object for a given view.
68
-     *
69
-     * @var EE_Admin_List_Table $_list_table_object
70
-     */
71
-    protected $_list_table_object;
66
+	/**
67
+	 * this will hold the list table object for a given view.
68
+	 *
69
+	 * @var EE_Admin_List_Table $_list_table_object
70
+	 */
71
+	protected $_list_table_object;
72 72
 
73
-    // boolean
74
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
73
+	// boolean
74
+	protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
75 75
 
76
-    protected $_routing;
76
+	protected $_routing;
77 77
 
78
-    // list table args
79
-    protected $_view;
78
+	// list table args
79
+	protected $_view;
80 80
 
81
-    protected $_views;
81
+	protected $_views;
82 82
 
83 83
 
84
-    // action => method pairs used for routing incoming requests
85
-    protected $_page_routes;
84
+	// action => method pairs used for routing incoming requests
85
+	protected $_page_routes;
86 86
 
87
-    /**
88
-     * @var array $_page_config
89
-     */
90
-    protected $_page_config;
87
+	/**
88
+	 * @var array $_page_config
89
+	 */
90
+	protected $_page_config;
91 91
 
92
-    /**
93
-     * the current page route and route config
94
-     *
95
-     * @var string $_route
96
-     */
97
-    protected $_route;
92
+	/**
93
+	 * the current page route and route config
94
+	 *
95
+	 * @var string $_route
96
+	 */
97
+	protected $_route;
98 98
 
99
-    /**
100
-     * @var string $_cpt_route
101
-     */
102
-    protected $_cpt_route;
99
+	/**
100
+	 * @var string $_cpt_route
101
+	 */
102
+	protected $_cpt_route;
103 103
 
104
-    /**
105
-     * @var array $_route_config
106
-     */
107
-    protected $_route_config;
104
+	/**
105
+	 * @var array $_route_config
106
+	 */
107
+	protected $_route_config;
108 108
 
109
-    /**
110
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
-     * actions.
112
-     *
113
-     * @since 4.6.x
114
-     * @var array.
115
-     */
116
-    protected $_default_route_query_args;
117
-
118
-    // set via request page and action args.
119
-    protected $_current_page;
120
-
121
-    protected $_current_view;
122
-
123
-    protected $_current_page_view_url;
124
-
125
-    // sanitized request action (and nonce)
126
-
127
-    /**
128
-     * @var string $_req_action
129
-     */
130
-    protected $_req_action;
131
-
132
-    /**
133
-     * @var string $_req_nonce
134
-     */
135
-    protected $_req_nonce;
136
-
137
-    // search related
138
-    protected $_search_btn_label;
139
-
140
-    protected $_search_box_callback;
141
-
142
-    /**
143
-     * WP Current Screen object
144
-     *
145
-     * @var WP_Screen
146
-     */
147
-    protected $_current_screen;
148
-
149
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
-    protected $_hook_obj;
151
-
152
-    // for holding incoming request data
153
-    protected $_req_data;
154
-
155
-    // yes / no array for admin form fields
156
-    protected $_yes_no_values = array();
157
-
158
-    // some default things shared by all child classes
159
-    protected $_default_espresso_metaboxes;
160
-
161
-    /**
162
-     *    EE_Registry Object
163
-     *
164
-     * @var    EE_Registry
165
-     */
166
-    protected $EE;
167
-
168
-
169
-    /**
170
-     * This is just a property that flags whether the given route is a caffeinated route or not.
171
-     *
172
-     * @var boolean
173
-     */
174
-    protected $_is_caf = false;
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws ReflectionException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function __construct($routing = true)
187
-    {
188
-        $this->loader = LoaderFactory::getLoader();
189
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
-            $this->_is_caf = true;
191
-        }
192
-        $this->_yes_no_values = array(
193
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
-        );
196
-        // set the _req_data property.
197
-        $this->_req_data = array_merge($_GET, $_POST);
198
-        // routing enabled?
199
-        $this->_routing = $routing;
200
-    }
201
-
202
-
203
-    /**
204
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
205
-     * for child classes that needed to set properties prior to these methods getting called,
206
-     * but also needed the parent class to have its construction completed as well.
207
-     * Bottom line is that constructors should ONLY be used for setting initial properties
208
-     * and any complex initialization logic should only run after instantiation is complete.
209
-     *
210
-     * This method gets called immediately after construction from within
211
-     *      EE_Admin_Page_Init::_initialize_admin_page()
212
-     *
213
-     * @throws EE_Error
214
-     * @throws InvalidArgumentException
215
-     * @throws InvalidDataTypeException
216
-     * @throws InvalidInterfaceException
217
-     * @throws ReflectionException
218
-     * @since $VID:$
219
-     */
220
-    public function initializePage()
221
-    {
222
-        // set initial page props (child method)
223
-        $this->_init_page_props();
224
-        // set global defaults
225
-        $this->_set_defaults();
226
-        // set early because incoming requests could be ajax related and we need to register those hooks.
227
-        $this->_global_ajax_hooks();
228
-        $this->_ajax_hooks();
229
-        // other_page_hooks have to be early too.
230
-        $this->_do_other_page_hooks();
231
-        // This just allows us to have extending classes do something specific
232
-        // before the parent constructor runs _page_setup().
233
-        if (method_exists($this, '_before_page_setup')) {
234
-            $this->_before_page_setup();
235
-        }
236
-        // set up page dependencies
237
-        $this->_page_setup();
238
-    }
239
-
240
-
241
-    /**
242
-     * _init_page_props
243
-     * Child classes use to set at least the following properties:
244
-     * $page_slug.
245
-     * $page_label.
246
-     *
247
-     * @abstract
248
-     * @return void
249
-     */
250
-    abstract protected function _init_page_props();
251
-
252
-
253
-    /**
254
-     * _ajax_hooks
255
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
256
-     * Note: within the ajax callback methods.
257
-     *
258
-     * @abstract
259
-     * @return void
260
-     */
261
-    abstract protected function _ajax_hooks();
262
-
263
-
264
-    /**
265
-     * _define_page_props
266
-     * child classes define page properties in here.  Must include at least:
267
-     * $_admin_base_url = base_url for all admin pages
268
-     * $_admin_page_title = default admin_page_title for admin pages
269
-     * $_labels = array of default labels for various automatically generated elements:
270
-     *    array(
271
-     *        'buttons' => array(
272
-     *            'add' => esc_html__('label for add new button'),
273
-     *            'edit' => esc_html__('label for edit button'),
274
-     *            'delete' => esc_html__('label for delete button')
275
-     *            )
276
-     *        )
277
-     *
278
-     * @abstract
279
-     * @return void
280
-     */
281
-    abstract protected function _define_page_props();
282
-
283
-
284
-    /**
285
-     * _set_page_routes
286
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
287
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
288
-     * have a 'default' route. Here's the format
289
-     * $this->_page_routes = array(
290
-     *        'default' => array(
291
-     *            'func' => '_default_method_handling_route',
292
-     *            'args' => array('array','of','args'),
293
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
294
-     *            ajax request, backend processing)
295
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
296
-     *            headers route after.  The string you enter here should match the defined route reference for a
297
-     *            headers sent route.
298
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
299
-     *            this route.
300
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
301
-     *            checks).
302
-     *        ),
303
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
304
-     *        handling method.
305
-     *        )
306
-     * )
307
-     *
308
-     * @abstract
309
-     * @return void
310
-     */
311
-    abstract protected function _set_page_routes();
312
-
313
-
314
-    /**
315
-     * _set_page_config
316
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
317
-     * array corresponds to the page_route for the loaded page. Format:
318
-     * $this->_page_config = array(
319
-     *        'default' => array(
320
-     *            'labels' => array(
321
-     *                'buttons' => array(
322
-     *                    'add' => esc_html__('label for adding item'),
323
-     *                    'edit' => esc_html__('label for editing item'),
324
-     *                    'delete' => esc_html__('label for deleting item')
325
-     *                ),
326
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
327
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
328
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
329
-     *            _define_page_props() method
330
-     *            'nav' => array(
331
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
332
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
333
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
334
-     *                'order' => 10, //required to indicate tab position.
335
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
336
-     *                displayed then add this parameter.
337
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
338
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
339
-     *            metaboxes set for eventespresso admin pages.
340
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
341
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
342
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
343
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
344
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
345
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
346
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
347
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
348
-     *            want to display.
349
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
350
-     *                'tab_id' => array(
351
-     *                    'title' => 'tab_title',
352
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
353
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
354
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
355
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
356
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
357
-     *                    attempt to use the callback which should match the name of a method in the class
358
-     *                    ),
359
-     *                'tab2_id' => array(
360
-     *                    'title' => 'tab2 title',
361
-     *                    'filename' => 'file_name_2'
362
-     *                    'callback' => 'callback_method_for_content',
363
-     *                 ),
364
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
365
-     *            help tab area on an admin page. @link
366
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
367
-     *            'help_tour' => array(
368
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
369
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
370
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
371
-     *            ),
372
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
373
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
374
-     *            just set
375
-     *            'require_nonce' to FALSE
376
-     *            )
377
-     * )
378
-     *
379
-     * @abstract
380
-     * @return void
381
-     */
382
-    abstract protected function _set_page_config();
383
-
384
-
385
-
386
-
387
-
388
-    /** end sample help_tour methods **/
389
-    /**
390
-     * _add_screen_options
391
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
-     * to a particular view.
394
-     *
395
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
-     *         see also WP_Screen object documents...
397
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
-     * @abstract
399
-     * @return void
400
-     */
401
-    abstract protected function _add_screen_options();
402
-
403
-
404
-    /**
405
-     * _add_feature_pointers
406
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
-     * extended) also see:
411
-     *
412
-     * @link   http://eamann.com/tech/wordpress-portland/
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract protected function _add_feature_pointers();
417
-
418
-
419
-    /**
420
-     * load_scripts_styles
421
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
-     * scripts/styles per view by putting them in a dynamic function in this format
424
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function load_scripts_styles();
430
-
431
-
432
-    /**
433
-     * admin_init
434
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
-     * all pages/views loaded by child class.
436
-     *
437
-     * @abstract
438
-     * @return void
439
-     */
440
-    abstract public function admin_init();
441
-
442
-
443
-    /**
444
-     * admin_notices
445
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
-     * all pages/views loaded by child class.
447
-     *
448
-     * @abstract
449
-     * @return void
450
-     */
451
-    abstract public function admin_notices();
452
-
453
-
454
-    /**
455
-     * admin_footer_scripts
456
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
-     * will apply to all pages/views loaded by child class.
458
-     *
459
-     * @return void
460
-     */
461
-    abstract public function admin_footer_scripts();
462
-
463
-
464
-    /**
465
-     * admin_footer
466
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
-     * apply to all pages/views loaded by child class.
468
-     *
469
-     * @return void
470
-     */
471
-    public function admin_footer()
472
-    {
473
-    }
474
-
475
-
476
-    /**
477
-     * _global_ajax_hooks
478
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
-     * Note: within the ajax callback methods.
480
-     *
481
-     * @abstract
482
-     * @return void
483
-     */
484
-    protected function _global_ajax_hooks()
485
-    {
486
-        // for lazy loading of metabox content
487
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
488
-    }
489
-
490
-
491
-    public function ajax_metabox_content()
492
-    {
493
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
494
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
495
-        self::cached_rss_display($contentid, $url);
496
-        wp_die();
497
-    }
498
-
499
-
500
-    /**
501
-     * _page_setup
502
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
503
-     * doesn't match the object.
504
-     *
505
-     * @final
506
-     * @return void
507
-     * @throws EE_Error
508
-     * @throws InvalidArgumentException
509
-     * @throws ReflectionException
510
-     * @throws InvalidDataTypeException
511
-     * @throws InvalidInterfaceException
512
-     */
513
-    final protected function _page_setup()
514
-    {
515
-        // requires?
516
-        // admin_init stuff - global - we're setting this REALLY early
517
-        // so if EE_Admin pages have to hook into other WP pages they can.
518
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
519
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
520
-        // next verify if we need to load anything...
521
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
522
-        $this->page_folder = strtolower(
523
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
524
-        );
525
-        global $ee_menu_slugs;
526
-        $ee_menu_slugs = (array) $ee_menu_slugs;
527
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
528
-            return;
529
-        }
530
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
531
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
532
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
533
-                ? $this->_req_data['action2']
534
-                : $this->_req_data['action'];
535
-        }
536
-        // then set blank or -1 action values to 'default'
537
-        $this->_req_action = isset($this->_req_data['action'])
538
-                             && ! empty($this->_req_data['action'])
539
-                             && $this->_req_data['action'] !== '-1'
540
-            ? sanitize_key($this->_req_data['action'])
541
-            : 'default';
542
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
543
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
544
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
545
-            ? $this->_req_data['route'] : $this->_req_action;
546
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
547
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
548
-            ? $this->_req_data['route']
549
-            : $this->_req_action;
550
-        $this->_current_view = $this->_req_action;
551
-        $this->_req_nonce = $this->_req_action . '_nonce';
552
-        $this->_define_page_props();
553
-        $this->_current_page_view_url = add_query_arg(
554
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
555
-            $this->_admin_base_url
556
-        );
557
-        // default things
558
-        $this->_default_espresso_metaboxes = array(
559
-            '_espresso_news_post_box',
560
-            '_espresso_links_post_box',
561
-            '_espresso_ratings_request',
562
-            '_espresso_sponsors_post_box',
563
-        );
564
-        // set page configs
565
-        $this->_set_page_routes();
566
-        $this->_set_page_config();
567
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
568
-        if (isset($this->_req_data['wp_referer'])) {
569
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
570
-        }
571
-        // for caffeinated and other extended functionality.
572
-        //  If there is a _extend_page_config method
573
-        // then let's run that to modify the all the various page configuration arrays
574
-        if (method_exists($this, '_extend_page_config')) {
575
-            $this->_extend_page_config();
576
-        }
577
-        // for CPT and other extended functionality.
578
-        // If there is an _extend_page_config_for_cpt
579
-        // then let's run that to modify all the various page configuration arrays.
580
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
581
-            $this->_extend_page_config_for_cpt();
582
-        }
583
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
584
-        $this->_page_routes = apply_filters(
585
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
586
-            $this->_page_routes,
587
-            $this
588
-        );
589
-        $this->_page_config = apply_filters(
590
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
591
-            $this->_page_config,
592
-            $this
593
-        );
594
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
595
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
596
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
597
-            add_action(
598
-                'AHEE__EE_Admin_Page__route_admin_request',
599
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
600
-                10,
601
-                2
602
-            );
603
-        }
604
-        // next route only if routing enabled
605
-        if ($this->_routing && ! defined('DOING_AJAX')) {
606
-            $this->_verify_routes();
607
-            // next let's just check user_access and kill if no access
608
-            $this->check_user_access();
609
-            if ($this->_is_UI_request) {
610
-                // admin_init stuff - global, all views for this page class, specific view
611
-                add_action('admin_init', array($this, 'admin_init'), 10);
612
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
613
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
614
-                }
615
-            } else {
616
-                // hijack regular WP loading and route admin request immediately
617
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
618
-                $this->route_admin_request();
619
-            }
620
-        }
621
-    }
622
-
623
-
624
-    /**
625
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
626
-     *
627
-     * @return void
628
-     * @throws ReflectionException
629
-     * @throws EE_Error
630
-     */
631
-    private function _do_other_page_hooks()
632
-    {
633
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
634
-        foreach ($registered_pages as $page) {
635
-            // now let's setup the file name and class that should be present
636
-            $classname = str_replace('.class.php', '', $page);
637
-            // autoloaders should take care of loading file
638
-            if (! class_exists($classname)) {
639
-                $error_msg[] = sprintf(
640
-                    esc_html__(
641
-                        'Something went wrong with loading the %s admin hooks page.',
642
-                        'event_espresso'
643
-                    ),
644
-                    $page
645
-                );
646
-                $error_msg[] = $error_msg[0]
647
-                               . "\r\n"
648
-                               . sprintf(
649
-                                   esc_html__(
650
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
651
-                                       'event_espresso'
652
-                                   ),
653
-                                   $page,
654
-                                   '<br />',
655
-                                   '<strong>' . $classname . '</strong>'
656
-                               );
657
-                throw new EE_Error(implode('||', $error_msg));
658
-            }
659
-            // // notice we are passing the instance of this class to the hook object.
660
-            $this->loader->getShared($classname, [$this]);
661
-        }
662
-    }
663
-
664
-
665
-    /**
666
-     * @throws DomainException
667
-     * @throws EE_Error
668
-     * @throws InvalidArgumentException
669
-     * @throws InvalidDataTypeException
670
-     * @throws InvalidInterfaceException
671
-     * @throws ReflectionException
672
-     * @since $VID:$
673
-     */
674
-    public function load_page_dependencies()
675
-    {
676
-        try {
677
-            $this->_load_page_dependencies();
678
-        } catch (EE_Error $e) {
679
-            $e->get_error();
680
-        }
681
-    }
682
-
683
-
684
-    /**
685
-     * load_page_dependencies
686
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
687
-     *
688
-     * @return void
689
-     * @throws DomainException
690
-     * @throws EE_Error
691
-     * @throws InvalidArgumentException
692
-     * @throws InvalidDataTypeException
693
-     * @throws InvalidInterfaceException
694
-     * @throws ReflectionException
695
-     */
696
-    protected function _load_page_dependencies()
697
-    {
698
-        // let's set the current_screen and screen options to override what WP set
699
-        $this->_current_screen = get_current_screen();
700
-        // load admin_notices - global, page class, and view specific
701
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
702
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
703
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
704
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
705
-        }
706
-        // load network admin_notices - global, page class, and view specific
707
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
708
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
709
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
710
-        }
711
-        // this will save any per_page screen options if they are present
712
-        $this->_set_per_page_screen_options();
713
-        // setup list table properties
714
-        $this->_set_list_table();
715
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
716
-        // However in some cases the metaboxes will need to be added within a route handling callback.
717
-        $this->_add_registered_meta_boxes();
718
-        $this->_add_screen_columns();
719
-        // add screen options - global, page child class, and view specific
720
-        $this->_add_global_screen_options();
721
-        $this->_add_screen_options();
722
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
723
-        if (method_exists($this, $add_screen_options)) {
724
-            $this->{$add_screen_options}();
725
-        }
726
-        // add help tab(s) and tours- set via page_config and qtips.
727
-        $this->_add_help_tour();
728
-        $this->_add_help_tabs();
729
-        $this->_add_qtips();
730
-        // add feature_pointers - global, page child class, and view specific
731
-        $this->_add_feature_pointers();
732
-        $this->_add_global_feature_pointers();
733
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
734
-        if (method_exists($this, $add_feature_pointer)) {
735
-            $this->{$add_feature_pointer}();
736
-        }
737
-        // enqueue scripts/styles - global, page class, and view specific
738
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
739
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
740
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
741
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
742
-        }
743
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
744
-        // admin_print_footer_scripts - global, page child class, and view specific.
745
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
746
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
747
-        // is a good use case. Notice the late priority we're giving these
748
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
749
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
750
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
751
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
752
-        }
753
-        // admin footer scripts
754
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
755
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
756
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
757
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
758
-        }
759
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
760
-        // targeted hook
761
-        do_action(
762
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
763
-        );
764
-    }
765
-
766
-
767
-    /**
768
-     * _set_defaults
769
-     * This sets some global defaults for class properties.
770
-     */
771
-    private function _set_defaults()
772
-    {
773
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
774
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
775
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
776
-        $this->_page_config = $this->_default_route_query_args = array();
777
-        $this->_default_nav_tab_name = 'overview';
778
-        // init template args
779
-        $this->_template_args = array(
780
-            'admin_page_header'  => '',
781
-            'admin_page_content' => '',
782
-            'post_body_content'  => '',
783
-            'before_list_table'  => '',
784
-            'after_list_table'   => '',
785
-        );
786
-    }
787
-
788
-
789
-    /**
790
-     * route_admin_request
791
-     *
792
-     * @see    _route_admin_request()
793
-     * @return exception|void error
794
-     * @throws InvalidArgumentException
795
-     * @throws InvalidInterfaceException
796
-     * @throws InvalidDataTypeException
797
-     * @throws EE_Error
798
-     * @throws ReflectionException
799
-     */
800
-    public function route_admin_request()
801
-    {
802
-        try {
803
-            $this->_route_admin_request();
804
-        } catch (EE_Error $e) {
805
-            $e->get_error();
806
-        }
807
-    }
808
-
809
-
810
-    public function set_wp_page_slug($wp_page_slug)
811
-    {
812
-        $this->_wp_page_slug = $wp_page_slug;
813
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
814
-        if (is_network_admin()) {
815
-            $this->_wp_page_slug .= '-network';
816
-        }
817
-    }
818
-
819
-
820
-    /**
821
-     * _verify_routes
822
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
823
-     * we know if we need to drop out.
824
-     *
825
-     * @return bool
826
-     * @throws EE_Error
827
-     */
828
-    protected function _verify_routes()
829
-    {
830
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
831
-            return false;
832
-        }
833
-        $this->_route = false;
834
-        // check that the page_routes array is not empty
835
-        if (empty($this->_page_routes)) {
836
-            // user error msg
837
-            $error_msg = sprintf(
838
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
839
-                $this->_admin_page_title
840
-            );
841
-            // developer error msg
842
-            $error_msg .= '||' . $error_msg
843
-                          . esc_html__(
844
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
845
-                              'event_espresso'
846
-                          );
847
-            throw new EE_Error($error_msg);
848
-        }
849
-        // and that the requested page route exists
850
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
851
-            $this->_route = $this->_page_routes[ $this->_req_action ];
852
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
853
-                ? $this->_page_config[ $this->_req_action ] : array();
854
-        } else {
855
-            // user error msg
856
-            $error_msg = sprintf(
857
-                esc_html__(
858
-                    'The requested page route does not exist for the %s admin page.',
859
-                    'event_espresso'
860
-                ),
861
-                $this->_admin_page_title
862
-            );
863
-            // developer error msg
864
-            $error_msg .= '||' . $error_msg
865
-                          . sprintf(
866
-                              esc_html__(
867
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
868
-                                  'event_espresso'
869
-                              ),
870
-                              $this->_req_action
871
-                          );
872
-            throw new EE_Error($error_msg);
873
-        }
874
-        // and that a default route exists
875
-        if (! array_key_exists('default', $this->_page_routes)) {
876
-            // user error msg
877
-            $error_msg = sprintf(
878
-                esc_html__(
879
-                    'A default page route has not been set for the % admin page.',
880
-                    'event_espresso'
881
-                ),
882
-                $this->_admin_page_title
883
-            );
884
-            // developer error msg
885
-            $error_msg .= '||' . $error_msg
886
-                          . esc_html__(
887
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
888
-                              'event_espresso'
889
-                          );
890
-            throw new EE_Error($error_msg);
891
-        }
892
-
893
-        // first lets' catch if the UI request has EVER been set.
894
-        if ($this->_is_UI_request === null) {
895
-            // lets set if this is a UI request or not.
896
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
897
-            // wait a minute... we might have a noheader in the route array
898
-            $this->_is_UI_request = is_array($this->_route)
899
-                                    && isset($this->_route['noheader'])
900
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
901
-        }
902
-        $this->_set_current_labels();
903
-        return true;
904
-    }
905
-
906
-
907
-    /**
908
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
909
-     *
910
-     * @param  string $route the route name we're verifying
911
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
912
-     * @throws EE_Error
913
-     */
914
-    protected function _verify_route($route)
915
-    {
916
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
917
-            return true;
918
-        }
919
-        // user error msg
920
-        $error_msg = sprintf(
921
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
922
-            $this->_admin_page_title
923
-        );
924
-        // developer error msg
925
-        $error_msg .= '||' . $error_msg
926
-                      . sprintf(
927
-                          esc_html__(
928
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
929
-                              'event_espresso'
930
-                          ),
931
-                          $route
932
-                      );
933
-        throw new EE_Error($error_msg);
934
-    }
935
-
936
-
937
-    /**
938
-     * perform nonce verification
939
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
940
-     * using this method (and save retyping!)
941
-     *
942
-     * @param string $nonce     The nonce sent
943
-     * @param string $nonce_ref The nonce reference string (name0)
944
-     * @return void
945
-     * @throws EE_Error
946
-     * @throws InvalidArgumentException
947
-     * @throws InvalidDataTypeException
948
-     * @throws InvalidInterfaceException
949
-     */
950
-    protected function _verify_nonce($nonce, $nonce_ref)
951
-    {
952
-        // verify nonce against expected value
953
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
954
-            // these are not the droids you are looking for !!!
955
-            $msg = sprintf(
956
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
957
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
958
-                '</a>'
959
-            );
960
-            if (WP_DEBUG) {
961
-                $msg .= "\n  "
962
-                        . sprintf(
963
-                            esc_html__(
964
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
965
-                                'event_espresso'
966
-                            ),
967
-                            __CLASS__
968
-                        );
969
-            }
970
-            if (! defined('DOING_AJAX')) {
971
-                wp_die($msg);
972
-            } else {
973
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
974
-                $this->_return_json();
975
-            }
976
-        }
977
-    }
978
-
979
-
980
-    /**
981
-     * _route_admin_request()
982
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
983
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
984
-     * in the page routes and then will try to load the corresponding method.
985
-     *
986
-     * @return void
987
-     * @throws EE_Error
988
-     * @throws InvalidArgumentException
989
-     * @throws InvalidDataTypeException
990
-     * @throws InvalidInterfaceException
991
-     * @throws ReflectionException
992
-     */
993
-    protected function _route_admin_request()
994
-    {
995
-        if (! $this->_is_UI_request) {
996
-            $this->_verify_routes();
997
-        }
998
-        $nonce_check = isset($this->_route_config['require_nonce'])
999
-            ? $this->_route_config['require_nonce']
1000
-            : true;
1001
-        if ($this->_req_action !== 'default' && $nonce_check) {
1002
-            // set nonce from post data
1003
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
1004
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1005
-                : '';
1006
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1007
-        }
1008
-        // set the nav_tabs array but ONLY if this is  UI_request
1009
-        if ($this->_is_UI_request) {
1010
-            $this->_set_nav_tabs();
1011
-        }
1012
-        // grab callback function
1013
-        $func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1014
-        // check if callback has args
1015
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1016
-        $error_msg = '';
1017
-        // action right before calling route
1018
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1019
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1020
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1021
-        }
1022
-        // right before calling the route, let's remove _wp_http_referer from the
1023
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1024
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
1025
-            '_wp_http_referer',
1026
-            wp_unslash($_SERVER['REQUEST_URI'])
1027
-        );
1028
-        if (! empty($func)) {
1029
-            if (is_array($func)) {
1030
-                list($class, $method) = $func;
1031
-            } elseif (strpos($func, '::') !== false) {
1032
-                list($class, $method) = explode('::', $func);
1033
-            } else {
1034
-                $class = $this;
1035
-                $method = $func;
1036
-            }
1037
-            if (! (is_object($class) && $class === $this)) {
1038
-                // send along this admin page object for access by addons.
1039
-                $args['admin_page_object'] = $this;
1040
-            }
1041
-            // is it a method on a class that doesn't work?
1042
-            if (((method_exists($class, $method)
1043
-                  && call_user_func_array(array($class, $method), $args) === false)
1044
-                 && (// is it a standalone function that doesn't work?
1045
-                     function_exists($method)
1046
-                     && call_user_func_array(
1047
-                         $func,
1048
-                         array_merge(array('admin_page_object' => $this), $args)
1049
-                     ) === false
1050
-                 )) || (// is it neither a class method NOR a standalone function?
1051
-                    ! function_exists($method)
1052
-                    && ! method_exists($class, $method)
1053
-                )
1054
-            ) {
1055
-                // user error msg
1056
-                $error_msg = esc_html__(
1057
-                    'An error occurred. The  requested page route could not be found.',
1058
-                    'event_espresso'
1059
-                );
1060
-                // developer error msg
1061
-                $error_msg .= '||';
1062
-                $error_msg .= sprintf(
1063
-                    esc_html__(
1064
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1065
-                        'event_espresso'
1066
-                    ),
1067
-                    $method
1068
-                );
1069
-            }
1070
-            if (! empty($error_msg)) {
1071
-                throw new EE_Error($error_msg);
1072
-            }
1073
-        }
1074
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1075
-        // then we need to reset the routing properties to the new route.
1076
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1077
-        if ($this->_is_UI_request === false
1078
-            && is_array($this->_route)
1079
-            && ! empty($this->_route['headers_sent_route'])
1080
-        ) {
1081
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1082
-        }
1083
-    }
1084
-
1085
-
1086
-    /**
1087
-     * This method just allows the resetting of page properties in the case where a no headers
1088
-     * route redirects to a headers route in its route config.
1089
-     *
1090
-     * @since   4.3.0
1091
-     * @param  string $new_route New (non header) route to redirect to.
1092
-     * @return   void
1093
-     * @throws ReflectionException
1094
-     * @throws InvalidArgumentException
1095
-     * @throws InvalidInterfaceException
1096
-     * @throws InvalidDataTypeException
1097
-     * @throws EE_Error
1098
-     */
1099
-    protected function _reset_routing_properties($new_route)
1100
-    {
1101
-        $this->_is_UI_request = true;
1102
-        // now we set the current route to whatever the headers_sent_route is set at
1103
-        $this->_req_data['action'] = $new_route;
1104
-        // rerun page setup
1105
-        $this->_page_setup();
1106
-    }
1107
-
1108
-
1109
-    /**
1110
-     * _add_query_arg
1111
-     * adds nonce to array of arguments then calls WP add_query_arg function
1112
-     *(internally just uses EEH_URL's function with the same name)
1113
-     *
1114
-     * @param array  $args
1115
-     * @param string $url
1116
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1117
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1118
-     *                                        Example usage: If the current page is:
1119
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1120
-     *                                        &action=default&event_id=20&month_range=March%202015
1121
-     *                                        &_wpnonce=5467821
1122
-     *                                        and you call:
1123
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1124
-     *                                        array(
1125
-     *                                        'action' => 'resend_something',
1126
-     *                                        'page=>espresso_registrations'
1127
-     *                                        ),
1128
-     *                                        $some_url,
1129
-     *                                        true
1130
-     *                                        );
1131
-     *                                        It will produce a url in this structure:
1132
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1133
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1134
-     *                                        month_range]=March%202015
1135
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1136
-     * @return string
1137
-     */
1138
-    public static function add_query_args_and_nonce(
1139
-        $args = array(),
1140
-        $url = '',
1141
-        $sticky = false,
1142
-        $exclude_nonce = false
1143
-    ) {
1144
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1145
-        if ($sticky) {
1146
-            $request = $_REQUEST;
1147
-            unset($request['_wp_http_referer'], $request['wp_referer']);
1148
-            foreach ($request as $key => $value) {
1149
-                // do not add nonces
1150
-                if (strpos($key, 'nonce') !== false) {
1151
-                    continue;
1152
-                }
1153
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1154
-            }
1155
-        }
1156
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1157
-    }
1158
-
1159
-
1160
-    /**
1161
-     * This returns a generated link that will load the related help tab.
1162
-     *
1163
-     * @param  string $help_tab_id the id for the connected help tab
1164
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1165
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1166
-     * @uses EEH_Template::get_help_tab_link()
1167
-     * @return string              generated link
1168
-     */
1169
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1170
-    {
1171
-        return EEH_Template::get_help_tab_link(
1172
-            $help_tab_id,
1173
-            $this->page_slug,
1174
-            $this->_req_action,
1175
-            $icon_style,
1176
-            $help_text
1177
-        );
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * _add_help_tabs
1183
-     * Note child classes define their help tabs within the page_config array.
1184
-     *
1185
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1186
-     * @return void
1187
-     * @throws DomainException
1188
-     * @throws EE_Error
1189
-     */
1190
-    protected function _add_help_tabs()
1191
-    {
1192
-        $tour_buttons = '';
1193
-        if (isset($this->_page_config[ $this->_req_action ])) {
1194
-            $config = $this->_page_config[ $this->_req_action ];
1195
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1196
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1197
-                $tb = array();
1198
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1199
-                foreach ($this->_help_tour['tours'] as $tour) {
1200
-                    // if this is the end tour then we don't need to setup a button
1201
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1202
-                        continue;
1203
-                    }
1204
-                    $tb[] = '<button id="trigger-tour-'
1205
-                            . $tour->get_slug()
1206
-                            . '" class="button-primary trigger-ee-help-tour">'
1207
-                            . $tour->get_label()
1208
-                            . '</button>';
1209
-                }
1210
-                $tour_buttons .= implode('<br />', $tb);
1211
-                $tour_buttons .= '</div></div>';
1212
-            }
1213
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1214
-            if (is_array($config) && isset($config['help_sidebar'])) {
1215
-                // check that the callback given is valid
1216
-                if (! method_exists($this, $config['help_sidebar'])) {
1217
-                    throw new EE_Error(
1218
-                        sprintf(
1219
-                            esc_html__(
1220
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1221
-                                'event_espresso'
1222
-                            ),
1223
-                            $config['help_sidebar'],
1224
-                            get_class($this)
1225
-                        )
1226
-                    );
1227
-                }
1228
-                $content = apply_filters(
1229
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1230
-                    $this->{$config['help_sidebar']}()
1231
-                );
1232
-                $content .= $tour_buttons; // add help tour buttons.
1233
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1234
-                $this->_current_screen->set_help_sidebar($content);
1235
-            }
1236
-            // if there ARE tour buttons...
1237
-            if (! empty($tour_buttons)) {
1238
-                // if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1239
-                if (! isset($config['help_sidebar'])) {
1240
-                    $this->_current_screen->set_help_sidebar($tour_buttons);
1241
-                }
1242
-                // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1243
-                if (! isset($config['help_tabs'])) {
1244
-                    $_ht['id'] = $this->page_slug;
1245
-                    $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1246
-                    $_ht['content'] = '<p>'
1247
-                                      . esc_html__(
1248
-                                          'The buttons to the right allow you to start/restart any help tours available for this page',
1249
-                                          'event_espresso'
1250
-                                      ) . '</p>';
1251
-                    $this->_current_screen->add_help_tab($_ht);
1252
-                }
1253
-            }
1254
-            if (! isset($config['help_tabs'])) {
1255
-                return;
1256
-            } //no help tabs for this route
1257
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1258
-                // we're here so there ARE help tabs!
1259
-                // make sure we've got what we need
1260
-                if (! isset($cfg['title'])) {
1261
-                    throw new EE_Error(
1262
-                        esc_html__(
1263
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1264
-                            'event_espresso'
1265
-                        )
1266
-                    );
1267
-                }
1268
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1269
-                    throw new EE_Error(
1270
-                        esc_html__(
1271
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1272
-                            'event_espresso'
1273
-                        )
1274
-                    );
1275
-                }
1276
-                // first priority goes to content.
1277
-                if (! empty($cfg['content'])) {
1278
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1279
-                    // second priority goes to filename
1280
-                } elseif (! empty($cfg['filename'])) {
1281
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1282
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1283
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1284
-                                                             . basename($this->_get_dir())
1285
-                                                             . '/help_tabs/'
1286
-                                                             . $cfg['filename']
1287
-                                                             . '.help_tab.php' : $file_path;
1288
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1289
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1290
-                        EE_Error::add_error(
1291
-                            sprintf(
1292
-                                esc_html__(
1293
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1294
-                                    'event_espresso'
1295
-                                ),
1296
-                                $tab_id,
1297
-                                key($config),
1298
-                                $file_path
1299
-                            ),
1300
-                            __FILE__,
1301
-                            __FUNCTION__,
1302
-                            __LINE__
1303
-                        );
1304
-                        return;
1305
-                    }
1306
-                    $template_args['admin_page_obj'] = $this;
1307
-                    $content = EEH_Template::display_template(
1308
-                        $file_path,
1309
-                        $template_args,
1310
-                        true
1311
-                    );
1312
-                } else {
1313
-                    $content = '';
1314
-                }
1315
-                // check if callback is valid
1316
-                if (empty($content) && (
1317
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1318
-                    )
1319
-                ) {
1320
-                    EE_Error::add_error(
1321
-                        sprintf(
1322
-                            esc_html__(
1323
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1324
-                                'event_espresso'
1325
-                            ),
1326
-                            $cfg['title']
1327
-                        ),
1328
-                        __FILE__,
1329
-                        __FUNCTION__,
1330
-                        __LINE__
1331
-                    );
1332
-                    return;
1333
-                }
1334
-                // setup config array for help tab method
1335
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1336
-                $_ht = array(
1337
-                    'id'       => $id,
1338
-                    'title'    => $cfg['title'],
1339
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1340
-                    'content'  => $content,
1341
-                );
1342
-                $this->_current_screen->add_help_tab($_ht);
1343
-            }
1344
-        }
1345
-    }
1346
-
1347
-
1348
-    /**
1349
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1350
-     * an array with properties for setting up usage of the joyride plugin
1351
-     *
1352
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1353
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1354
-     *         _set_page_config() comments
1355
-     * @return void
1356
-     * @throws EE_Error
1357
-     * @throws InvalidArgumentException
1358
-     * @throws InvalidDataTypeException
1359
-     * @throws InvalidInterfaceException
1360
-     */
1361
-    protected function _add_help_tour()
1362
-    {
1363
-        $tours = array();
1364
-        $this->_help_tour = array();
1365
-        // exit early if help tours are turned off globally
1366
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1367
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1368
-        ) {
1369
-            return;
1370
-        }
1371
-        // loop through _page_config to find any help_tour defined
1372
-        foreach ($this->_page_config as $route => $config) {
1373
-            // we're only going to set things up for this route
1374
-            if ($route !== $this->_req_action) {
1375
-                continue;
1376
-            }
1377
-            if (isset($config['help_tour'])) {
1378
-                foreach ($config['help_tour'] as $tour) {
1379
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1380
-                    // let's see if we can get that file...
1381
-                    // if not its possible this is a decaf route not set in caffeinated
1382
-                    // so lets try and get the caffeinated equivalent
1383
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1384
-                                                             . basename($this->_get_dir())
1385
-                                                             . '/help_tours/'
1386
-                                                             . $tour
1387
-                                                             . '.class.php' : $file_path;
1388
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1389
-                    if (! is_readable($file_path)) {
1390
-                        EE_Error::add_error(
1391
-                            sprintf(
1392
-                                esc_html__(
1393
-                                    'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1394
-                                    'event_espresso'
1395
-                                ),
1396
-                                $file_path,
1397
-                                $tour
1398
-                            ),
1399
-                            __FILE__,
1400
-                            __FUNCTION__,
1401
-                            __LINE__
1402
-                        );
1403
-                        return;
1404
-                    }
1405
-                    require_once $file_path;
1406
-                    if (! class_exists($tour)) {
1407
-                        $error_msg[] = sprintf(
1408
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1409
-                            $tour
1410
-                        );
1411
-                        $error_msg[] = $error_msg[0] . "\r\n"
1412
-                                       . sprintf(
1413
-                                           esc_html__(
1414
-                                               'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1415
-                                               'event_espresso'
1416
-                                           ),
1417
-                                           $tour,
1418
-                                           '<br />',
1419
-                                           $tour,
1420
-                                           $this->_req_action,
1421
-                                           get_class($this)
1422
-                                       );
1423
-                        throw new EE_Error(implode('||', $error_msg));
1424
-                    }
1425
-                    $tour_obj = new $tour($this->_is_caf);
1426
-                    $tours[] = $tour_obj;
1427
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1428
-                }
1429
-                // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1430
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1431
-                $tours[] = $end_stop_tour;
1432
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1433
-            }
1434
-        }
1435
-
1436
-        if (! empty($tours)) {
1437
-            $this->_help_tour['tours'] = $tours;
1438
-        }
1439
-        // that's it!  Now that the $_help_tours property is set (or not)
1440
-        // the scripts and html should be taken care of automatically.
1441
-
1442
-        /**
1443
-         * Allow extending the help tours variable.
1444
-         *
1445
-         * @param Array $_help_tour The array containing all help tour information to be displayed.
1446
-         */
1447
-        $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1448
-    }
1449
-
1450
-
1451
-    /**
1452
-     * This simply sets up any qtips that have been defined in the page config
1453
-     *
1454
-     * @return void
1455
-     */
1456
-    protected function _add_qtips()
1457
-    {
1458
-        if (isset($this->_route_config['qtips'])) {
1459
-            $qtips = (array) $this->_route_config['qtips'];
1460
-            // load qtip loader
1461
-            $path = array(
1462
-                $this->_get_dir() . '/qtips/',
1463
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1464
-            );
1465
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1466
-        }
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * _set_nav_tabs
1472
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1473
-     * wish to add additional tabs or modify accordingly.
1474
-     *
1475
-     * @return void
1476
-     * @throws InvalidArgumentException
1477
-     * @throws InvalidInterfaceException
1478
-     * @throws InvalidDataTypeException
1479
-     */
1480
-    protected function _set_nav_tabs()
1481
-    {
1482
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1483
-        $i = 0;
1484
-        foreach ($this->_page_config as $slug => $config) {
1485
-            if (! is_array($config)
1486
-                || (
1487
-                    is_array($config)
1488
-                    && (
1489
-                        (isset($config['nav']) && ! $config['nav'])
1490
-                        || ! isset($config['nav'])
1491
-                    )
1492
-                )
1493
-            ) {
1494
-                continue;
1495
-            }
1496
-            // no nav tab for this config
1497
-            // check for persistent flag
1498
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1499
-                // nav tab is only to appear when route requested.
1500
-                continue;
1501
-            }
1502
-            if (! $this->check_user_access($slug, true)) {
1503
-                // no nav tab because current user does not have access.
1504
-                continue;
1505
-            }
1506
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1507
-            $this->_nav_tabs[ $slug ] = array(
1508
-                'url'       => isset($config['nav']['url'])
1509
-                    ? $config['nav']['url']
1510
-                    : self::add_query_args_and_nonce(
1511
-                        array('action' => $slug),
1512
-                        $this->_admin_base_url
1513
-                    ),
1514
-                'link_text' => isset($config['nav']['label'])
1515
-                    ? $config['nav']['label']
1516
-                    : ucwords(
1517
-                        str_replace('_', ' ', $slug)
1518
-                    ),
1519
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1520
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1521
-            );
1522
-            $i++;
1523
-        }
1524
-        // if $this->_nav_tabs is empty then lets set the default
1525
-        if (empty($this->_nav_tabs)) {
1526
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1527
-                'url'       => $this->_admin_base_url,
1528
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1529
-                'css_class' => 'nav-tab-active',
1530
-                'order'     => 10,
1531
-            );
1532
-        }
1533
-        // now let's sort the tabs according to order
1534
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1535
-    }
1536
-
1537
-
1538
-    /**
1539
-     * _set_current_labels
1540
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1541
-     * property array
1542
-     *
1543
-     * @return void
1544
-     */
1545
-    private function _set_current_labels()
1546
-    {
1547
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1548
-            foreach ($this->_route_config['labels'] as $label => $text) {
1549
-                if (is_array($text)) {
1550
-                    foreach ($text as $sublabel => $subtext) {
1551
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1552
-                    }
1553
-                } else {
1554
-                    $this->_labels[ $label ] = $text;
1555
-                }
1556
-            }
1557
-        }
1558
-    }
1559
-
1560
-
1561
-    /**
1562
-     *        verifies user access for this admin page
1563
-     *
1564
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1565
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1566
-     *                               return false if verify fail.
1567
-     * @return bool
1568
-     * @throws InvalidArgumentException
1569
-     * @throws InvalidDataTypeException
1570
-     * @throws InvalidInterfaceException
1571
-     */
1572
-    public function check_user_access($route_to_check = '', $verify_only = false)
1573
-    {
1574
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1575
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1576
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1577
-                      && is_array(
1578
-                          $this->_page_routes[ $route_to_check ]
1579
-                      )
1580
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1581
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1582
-        if (empty($capability) && empty($route_to_check)) {
1583
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1584
-                : $this->_route['capability'];
1585
-        } else {
1586
-            $capability = empty($capability) ? 'manage_options' : $capability;
1587
-        }
1588
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1589
-        if (! defined('DOING_AJAX')
1590
-            && (
1591
-                ! function_exists('is_admin')
1592
-                || ! EE_Registry::instance()->CAP->current_user_can(
1593
-                    $capability,
1594
-                    $this->page_slug
1595
-                    . '_'
1596
-                    . $route_to_check,
1597
-                    $id
1598
-                )
1599
-            )
1600
-        ) {
1601
-            if ($verify_only) {
1602
-                return false;
1603
-            }
1604
-            if (is_user_logged_in()) {
1605
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1606
-            } else {
1607
-                return false;
1608
-            }
1609
-        }
1610
-        return true;
1611
-    }
1612
-
1613
-
1614
-    /**
1615
-     * admin_init_global
1616
-     * This runs all the code that we want executed within the WP admin_init hook.
1617
-     * This method executes for ALL EE Admin pages.
1618
-     *
1619
-     * @return void
1620
-     */
1621
-    public function admin_init_global()
1622
-    {
1623
-    }
1624
-
1625
-
1626
-    /**
1627
-     * wp_loaded_global
1628
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1629
-     * EE_Admin page and will execute on every EE Admin Page load
1630
-     *
1631
-     * @return void
1632
-     */
1633
-    public function wp_loaded()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-    /**
1639
-     * admin_notices
1640
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1641
-     * ALL EE_Admin pages.
1642
-     *
1643
-     * @return void
1644
-     */
1645
-    public function admin_notices_global()
1646
-    {
1647
-        $this->_display_no_javascript_warning();
1648
-        $this->_display_espresso_notices();
1649
-    }
1650
-
1651
-
1652
-    public function network_admin_notices_global()
1653
-    {
1654
-        $this->_display_no_javascript_warning();
1655
-        $this->_display_espresso_notices();
1656
-    }
1657
-
1658
-
1659
-    /**
1660
-     * admin_footer_scripts_global
1661
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1662
-     * will apply on ALL EE_Admin pages.
1663
-     *
1664
-     * @return void
1665
-     */
1666
-    public function admin_footer_scripts_global()
1667
-    {
1668
-        $this->_add_admin_page_ajax_loading_img();
1669
-        $this->_add_admin_page_overlay();
1670
-        // if metaboxes are present we need to add the nonce field
1671
-        if (isset($this->_route_config['metaboxes'])
1672
-            || isset($this->_route_config['list_table'])
1673
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1674
-        ) {
1675
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1676
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1677
-        }
1678
-    }
1679
-
1680
-
1681
-    /**
1682
-     * admin_footer_global
1683
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1684
-     * This particular method will apply on ALL EE_Admin Pages.
1685
-     *
1686
-     * @return void
1687
-     * @throws InvalidArgumentException
1688
-     * @throws InvalidDataTypeException
1689
-     * @throws InvalidInterfaceException
1690
-     */
1691
-    public function admin_footer_global()
1692
-    {
1693
-        // dialog container for dialog helper
1694
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1695
-        $d_cont .= '<div class="ee-notices"></div>';
1696
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1697
-        $d_cont .= '</div>';
1698
-        echo $d_cont;
1699
-        // help tour stuff?
1700
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1701
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1702
-        }
1703
-        // current set timezone for timezone js
1704
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1705
-    }
1706
-
1707
-
1708
-    /**
1709
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1710
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1711
-     * help popups then in your templates or your content you set "triggers" for the content using the
1712
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1713
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1714
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1715
-     * for the
1716
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1717
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1718
-     *    'help_trigger_id' => array(
1719
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1720
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1721
-     *    )
1722
-     * );
1723
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1724
-     *
1725
-     * @param array $help_array
1726
-     * @param bool  $display
1727
-     * @return string content
1728
-     * @throws DomainException
1729
-     * @throws EE_Error
1730
-     */
1731
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1732
-    {
1733
-        $content = '';
1734
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1735
-        // loop through the array and setup content
1736
-        foreach ($help_array as $trigger => $help) {
1737
-            // make sure the array is setup properly
1738
-            if (! isset($help['title'], $help['content'])) {
1739
-                throw new EE_Error(
1740
-                    esc_html__(
1741
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1742
-                        'event_espresso'
1743
-                    )
1744
-                );
1745
-            }
1746
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1747
-            $template_args = array(
1748
-                'help_popup_id'      => $trigger,
1749
-                'help_popup_title'   => $help['title'],
1750
-                'help_popup_content' => $help['content'],
1751
-            );
1752
-            $content .= EEH_Template::display_template(
1753
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1754
-                $template_args,
1755
-                true
1756
-            );
1757
-        }
1758
-        if ($display) {
1759
-            echo $content;
1760
-            return '';
1761
-        }
1762
-        return $content;
1763
-    }
1764
-
1765
-
1766
-    /**
1767
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1768
-     *
1769
-     * @return array properly formatted array for help popup content
1770
-     * @throws EE_Error
1771
-     */
1772
-    private function _get_help_content()
1773
-    {
1774
-        // what is the method we're looking for?
1775
-        $method_name = '_help_popup_content_' . $this->_req_action;
1776
-        // if method doesn't exist let's get out.
1777
-        if (! method_exists($this, $method_name)) {
1778
-            return array();
1779
-        }
1780
-        // k we're good to go let's retrieve the help array
1781
-        $help_array = $this->{$method_name}();
1782
-        // make sure we've got an array!
1783
-        if (! is_array($help_array)) {
1784
-            throw new EE_Error(
1785
-                esc_html__(
1786
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1787
-                    'event_espresso'
1788
-                )
1789
-            );
1790
-        }
1791
-        return $help_array;
1792
-    }
1793
-
1794
-
1795
-    /**
1796
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1797
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1798
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1799
-     *
1800
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1801
-     * @param boolean $display    if false then we return the trigger string
1802
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1803
-     * @return string
1804
-     * @throws DomainException
1805
-     * @throws EE_Error
1806
-     */
1807
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1808
-    {
1809
-        if (defined('DOING_AJAX')) {
1810
-            return '';
1811
-        }
1812
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1813
-        $help_array = $this->_get_help_content();
1814
-        $help_content = '';
1815
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1816
-            $help_array[ $trigger_id ] = array(
1817
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1818
-                'content' => esc_html__(
1819
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1820
-                    'event_espresso'
1821
-                ),
1822
-            );
1823
-            $help_content = $this->_set_help_popup_content($help_array);
1824
-        }
1825
-        // let's setup the trigger
1826
-        $content = '<a class="ee-dialog" href="?height='
1827
-                   . $dimensions[0]
1828
-                   . '&width='
1829
-                   . $dimensions[1]
1830
-                   . '&inlineId='
1831
-                   . $trigger_id
1832
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1833
-        $content .= $help_content;
1834
-        if ($display) {
1835
-            echo $content;
1836
-            return '';
1837
-        }
1838
-        return $content;
1839
-    }
1840
-
1841
-
1842
-    /**
1843
-     * _add_global_screen_options
1844
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1845
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1846
-     *
1847
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1848
-     *         see also WP_Screen object documents...
1849
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1850
-     * @abstract
1851
-     * @return void
1852
-     */
1853
-    private function _add_global_screen_options()
1854
-    {
1855
-    }
1856
-
1857
-
1858
-    /**
1859
-     * _add_global_feature_pointers
1860
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1861
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1862
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1863
-     *
1864
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1865
-     *         extended) also see:
1866
-     * @link   http://eamann.com/tech/wordpress-portland/
1867
-     * @abstract
1868
-     * @return void
1869
-     */
1870
-    private function _add_global_feature_pointers()
1871
-    {
1872
-    }
1873
-
1874
-
1875
-    /**
1876
-     * load_global_scripts_styles
1877
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1878
-     *
1879
-     * @return void
1880
-     * @throws EE_Error
1881
-     */
1882
-    public function load_global_scripts_styles()
1883
-    {
1884
-        /** STYLES **/
1885
-        // add debugging styles
1886
-        if (WP_DEBUG) {
1887
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1888
-        }
1889
-        // register all styles
1890
-        wp_register_style(
1891
-            'espresso-ui-theme',
1892
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1893
-            array(),
1894
-            EVENT_ESPRESSO_VERSION
1895
-        );
1896
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1897
-        // helpers styles
1898
-        wp_register_style(
1899
-            'ee-text-links',
1900
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1901
-            array(),
1902
-            EVENT_ESPRESSO_VERSION
1903
-        );
1904
-        /** SCRIPTS **/
1905
-        // register all scripts
1906
-        wp_register_script(
1907
-            'ee-dialog',
1908
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1909
-            array('jquery', 'jquery-ui-draggable'),
1910
-            EVENT_ESPRESSO_VERSION,
1911
-            true
1912
-        );
1913
-        wp_register_script(
1914
-            'ee_admin_js',
1915
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1916
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1917
-            EVENT_ESPRESSO_VERSION,
1918
-            true
1919
-        );
1920
-        wp_register_script(
1921
-            'jquery-ui-timepicker-addon',
1922
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1923
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1924
-            EVENT_ESPRESSO_VERSION,
1925
-            true
1926
-        );
1927
-        if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1928
-            add_filter('FHEE_load_joyride', '__return_true');
1929
-        }
1930
-        // script for sorting tables
1931
-        wp_register_script(
1932
-            'espresso_ajax_table_sorting',
1933
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1934
-            array('ee_admin_js', 'jquery-ui-sortable'),
1935
-            EVENT_ESPRESSO_VERSION,
1936
-            true
1937
-        );
1938
-        // script for parsing uri's
1939
-        wp_register_script(
1940
-            'ee-parse-uri',
1941
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1942
-            array(),
1943
-            EVENT_ESPRESSO_VERSION,
1944
-            true
1945
-        );
1946
-        // and parsing associative serialized form elements
1947
-        wp_register_script(
1948
-            'ee-serialize-full-array',
1949
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1950
-            array('jquery'),
1951
-            EVENT_ESPRESSO_VERSION,
1952
-            true
1953
-        );
1954
-        // helpers scripts
1955
-        wp_register_script(
1956
-            'ee-text-links',
1957
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1958
-            array('jquery'),
1959
-            EVENT_ESPRESSO_VERSION,
1960
-            true
1961
-        );
1962
-        wp_register_script(
1963
-            'ee-moment-core',
1964
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1965
-            array(),
1966
-            EVENT_ESPRESSO_VERSION,
1967
-            true
1968
-        );
1969
-        wp_register_script(
1970
-            'ee-moment',
1971
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1972
-            array('ee-moment-core'),
1973
-            EVENT_ESPRESSO_VERSION,
1974
-            true
1975
-        );
1976
-        wp_register_script(
1977
-            'ee-datepicker',
1978
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1979
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1980
-            EVENT_ESPRESSO_VERSION,
1981
-            true
1982
-        );
1983
-        // google charts
1984
-        wp_register_script(
1985
-            'google-charts',
1986
-            'https://www.gstatic.com/charts/loader.js',
1987
-            array(),
1988
-            EVENT_ESPRESSO_VERSION
1989
-        );
1990
-        // ENQUEUE ALL BASICS BY DEFAULT
1991
-        wp_enqueue_style('ee-admin-css');
1992
-        wp_enqueue_script('ee_admin_js');
1993
-        wp_enqueue_script('ee-accounting');
1994
-        wp_enqueue_script('jquery-validate');
1995
-        // taking care of metaboxes
1996
-        if (empty($this->_cpt_route)
1997
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1998
-        ) {
1999
-            wp_enqueue_script('dashboard');
2000
-        }
2001
-        // LOCALIZED DATA
2002
-        // localize script for ajax lazy loading
2003
-        $lazy_loader_container_ids = apply_filters(
2004
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2005
-            array('espresso_news_post_box_content')
2006
-        );
2007
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2008
-        /**
2009
-         * help tour stuff
2010
-         */
2011
-        if (! empty($this->_help_tour)) {
2012
-            // register the js for kicking things off
2013
-            wp_enqueue_script(
2014
-                'ee-help-tour',
2015
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
2016
-                array('jquery-joyride'),
2017
-                EVENT_ESPRESSO_VERSION,
2018
-                true
2019
-            );
2020
-            $tours = array();
2021
-            // setup tours for the js tour object
2022
-            foreach ($this->_help_tour['tours'] as $tour) {
2023
-                if ($tour instanceof EE_Help_Tour) {
2024
-                    $tours[] = array(
2025
-                        'id'      => $tour->get_slug(),
2026
-                        'options' => $tour->get_options(),
2027
-                    );
2028
-                }
2029
-            }
2030
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2031
-            // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2032
-        }
2033
-    }
2034
-
2035
-
2036
-    /**
2037
-     *        admin_footer_scripts_eei18n_js_strings
2038
-     *
2039
-     * @return        void
2040
-     */
2041
-    public function admin_footer_scripts_eei18n_js_strings()
2042
-    {
2043
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2044
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2045
-            'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2046
-            'event_espresso'
2047
-        );
2048
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2049
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2050
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2051
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2052
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2053
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2054
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2055
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2056
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2057
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2058
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2059
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2060
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2061
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2062
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2063
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2064
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2065
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2066
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2067
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2068
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2069
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2070
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2071
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2072
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2073
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2074
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2075
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2076
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2077
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2078
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2079
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2080
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2081
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2082
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2083
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2084
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2085
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2086
-    }
2087
-
2088
-
2089
-    /**
2090
-     *        load enhanced xdebug styles for ppl with failing eyesight
2091
-     *
2092
-     * @return        void
2093
-     */
2094
-    public function add_xdebug_style()
2095
-    {
2096
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2097
-    }
2098
-
2099
-
2100
-    /************************/
2101
-    /** LIST TABLE METHODS **/
2102
-    /************************/
2103
-    /**
2104
-     * this sets up the list table if the current view requires it.
2105
-     *
2106
-     * @return void
2107
-     * @throws EE_Error
2108
-     * @throws InvalidArgumentException
2109
-     * @throws InvalidDataTypeException
2110
-     * @throws InvalidInterfaceException
2111
-     */
2112
-    protected function _set_list_table()
2113
-    {
2114
-        // first is this a list_table view?
2115
-        if (! isset($this->_route_config['list_table'])) {
2116
-            return;
2117
-        } //not a list_table view so get out.
2118
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2119
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2120
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2121
-            // user error msg
2122
-            $error_msg = esc_html__(
2123
-                'An error occurred. The requested list table views could not be found.',
2124
-                'event_espresso'
2125
-            );
2126
-            // developer error msg
2127
-            $error_msg .= '||'
2128
-                          . sprintf(
2129
-                              esc_html__(
2130
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2131
-                                  'event_espresso'
2132
-                              ),
2133
-                              $this->_req_action,
2134
-                              $list_table_view
2135
-                          );
2136
-            throw new EE_Error($error_msg);
2137
-        }
2138
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2139
-        $this->_views = apply_filters(
2140
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2141
-            $this->_views
2142
-        );
2143
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2144
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2145
-        $this->_set_list_table_view();
2146
-        $this->_set_list_table_object();
2147
-    }
2148
-
2149
-
2150
-    /**
2151
-     * set current view for List Table
2152
-     *
2153
-     * @return void
2154
-     */
2155
-    protected function _set_list_table_view()
2156
-    {
2157
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2158
-        // looking at active items or dumpster diving ?
2159
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2160
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2161
-        } else {
2162
-            $this->_view = sanitize_key($this->_req_data['status']);
2163
-        }
2164
-    }
2165
-
2166
-
2167
-    /**
2168
-     * _set_list_table_object
2169
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2170
-     *
2171
-     * @throws InvalidInterfaceException
2172
-     * @throws InvalidArgumentException
2173
-     * @throws InvalidDataTypeException
2174
-     * @throws EE_Error
2175
-     * @throws InvalidInterfaceException
2176
-     */
2177
-    protected function _set_list_table_object()
2178
-    {
2179
-        if (isset($this->_route_config['list_table'])) {
2180
-            if (! class_exists($this->_route_config['list_table'])) {
2181
-                throw new EE_Error(
2182
-                    sprintf(
2183
-                        esc_html__(
2184
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2185
-                            'event_espresso'
2186
-                        ),
2187
-                        $this->_route_config['list_table'],
2188
-                        get_class($this)
2189
-                    )
2190
-                );
2191
-            }
2192
-            $this->_list_table_object = $this->loader->getShared(
2193
-                $this->_route_config['list_table'],
2194
-                array($this)
2195
-            );
2196
-        }
2197
-    }
2198
-
2199
-
2200
-    /**
2201
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2202
-     *
2203
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2204
-     *                                                    urls.  The array should be indexed by the view it is being
2205
-     *                                                    added to.
2206
-     * @return array
2207
-     */
2208
-    public function get_list_table_view_RLs($extra_query_args = array())
2209
-    {
2210
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2211
-        if (empty($this->_views)) {
2212
-            $this->_views = array();
2213
-        }
2214
-        // cycle thru views
2215
-        foreach ($this->_views as $key => $view) {
2216
-            $query_args = array();
2217
-            // check for current view
2218
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2219
-            $query_args['action'] = $this->_req_action;
2220
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2221
-            $query_args['status'] = $view['slug'];
2222
-            // merge any other arguments sent in.
2223
-            if (isset($extra_query_args[ $view['slug'] ])) {
2224
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2225
-                    $query_args[] = $extra_query_arg;
2226
-                }
2227
-            }
2228
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2229
-        }
2230
-        return $this->_views;
2231
-    }
2232
-
2233
-
2234
-    /**
2235
-     * _entries_per_page_dropdown
2236
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2237
-     *
2238
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2239
-     *         WP does it.
2240
-     * @param int $max_entries total number of rows in the table
2241
-     * @return string
2242
-     */
2243
-    protected function _entries_per_page_dropdown($max_entries = 0)
2244
-    {
2245
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2246
-        $values = array(10, 25, 50, 100);
2247
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2248
-        if ($max_entries) {
2249
-            $values[] = $max_entries;
2250
-            sort($values);
2251
-        }
2252
-        $entries_per_page_dropdown = '
109
+	/**
110
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
+	 * actions.
112
+	 *
113
+	 * @since 4.6.x
114
+	 * @var array.
115
+	 */
116
+	protected $_default_route_query_args;
117
+
118
+	// set via request page and action args.
119
+	protected $_current_page;
120
+
121
+	protected $_current_view;
122
+
123
+	protected $_current_page_view_url;
124
+
125
+	// sanitized request action (and nonce)
126
+
127
+	/**
128
+	 * @var string $_req_action
129
+	 */
130
+	protected $_req_action;
131
+
132
+	/**
133
+	 * @var string $_req_nonce
134
+	 */
135
+	protected $_req_nonce;
136
+
137
+	// search related
138
+	protected $_search_btn_label;
139
+
140
+	protected $_search_box_callback;
141
+
142
+	/**
143
+	 * WP Current Screen object
144
+	 *
145
+	 * @var WP_Screen
146
+	 */
147
+	protected $_current_screen;
148
+
149
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
+	protected $_hook_obj;
151
+
152
+	// for holding incoming request data
153
+	protected $_req_data;
154
+
155
+	// yes / no array for admin form fields
156
+	protected $_yes_no_values = array();
157
+
158
+	// some default things shared by all child classes
159
+	protected $_default_espresso_metaboxes;
160
+
161
+	/**
162
+	 *    EE_Registry Object
163
+	 *
164
+	 * @var    EE_Registry
165
+	 */
166
+	protected $EE;
167
+
168
+
169
+	/**
170
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
171
+	 *
172
+	 * @var boolean
173
+	 */
174
+	protected $_is_caf = false;
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws ReflectionException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function __construct($routing = true)
187
+	{
188
+		$this->loader = LoaderFactory::getLoader();
189
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
+			$this->_is_caf = true;
191
+		}
192
+		$this->_yes_no_values = array(
193
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
+		);
196
+		// set the _req_data property.
197
+		$this->_req_data = array_merge($_GET, $_POST);
198
+		// routing enabled?
199
+		$this->_routing = $routing;
200
+	}
201
+
202
+
203
+	/**
204
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
205
+	 * for child classes that needed to set properties prior to these methods getting called,
206
+	 * but also needed the parent class to have its construction completed as well.
207
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
208
+	 * and any complex initialization logic should only run after instantiation is complete.
209
+	 *
210
+	 * This method gets called immediately after construction from within
211
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
212
+	 *
213
+	 * @throws EE_Error
214
+	 * @throws InvalidArgumentException
215
+	 * @throws InvalidDataTypeException
216
+	 * @throws InvalidInterfaceException
217
+	 * @throws ReflectionException
218
+	 * @since $VID:$
219
+	 */
220
+	public function initializePage()
221
+	{
222
+		// set initial page props (child method)
223
+		$this->_init_page_props();
224
+		// set global defaults
225
+		$this->_set_defaults();
226
+		// set early because incoming requests could be ajax related and we need to register those hooks.
227
+		$this->_global_ajax_hooks();
228
+		$this->_ajax_hooks();
229
+		// other_page_hooks have to be early too.
230
+		$this->_do_other_page_hooks();
231
+		// This just allows us to have extending classes do something specific
232
+		// before the parent constructor runs _page_setup().
233
+		if (method_exists($this, '_before_page_setup')) {
234
+			$this->_before_page_setup();
235
+		}
236
+		// set up page dependencies
237
+		$this->_page_setup();
238
+	}
239
+
240
+
241
+	/**
242
+	 * _init_page_props
243
+	 * Child classes use to set at least the following properties:
244
+	 * $page_slug.
245
+	 * $page_label.
246
+	 *
247
+	 * @abstract
248
+	 * @return void
249
+	 */
250
+	abstract protected function _init_page_props();
251
+
252
+
253
+	/**
254
+	 * _ajax_hooks
255
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
256
+	 * Note: within the ajax callback methods.
257
+	 *
258
+	 * @abstract
259
+	 * @return void
260
+	 */
261
+	abstract protected function _ajax_hooks();
262
+
263
+
264
+	/**
265
+	 * _define_page_props
266
+	 * child classes define page properties in here.  Must include at least:
267
+	 * $_admin_base_url = base_url for all admin pages
268
+	 * $_admin_page_title = default admin_page_title for admin pages
269
+	 * $_labels = array of default labels for various automatically generated elements:
270
+	 *    array(
271
+	 *        'buttons' => array(
272
+	 *            'add' => esc_html__('label for add new button'),
273
+	 *            'edit' => esc_html__('label for edit button'),
274
+	 *            'delete' => esc_html__('label for delete button')
275
+	 *            )
276
+	 *        )
277
+	 *
278
+	 * @abstract
279
+	 * @return void
280
+	 */
281
+	abstract protected function _define_page_props();
282
+
283
+
284
+	/**
285
+	 * _set_page_routes
286
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
287
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
288
+	 * have a 'default' route. Here's the format
289
+	 * $this->_page_routes = array(
290
+	 *        'default' => array(
291
+	 *            'func' => '_default_method_handling_route',
292
+	 *            'args' => array('array','of','args'),
293
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
294
+	 *            ajax request, backend processing)
295
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
296
+	 *            headers route after.  The string you enter here should match the defined route reference for a
297
+	 *            headers sent route.
298
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
299
+	 *            this route.
300
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
301
+	 *            checks).
302
+	 *        ),
303
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
304
+	 *        handling method.
305
+	 *        )
306
+	 * )
307
+	 *
308
+	 * @abstract
309
+	 * @return void
310
+	 */
311
+	abstract protected function _set_page_routes();
312
+
313
+
314
+	/**
315
+	 * _set_page_config
316
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
317
+	 * array corresponds to the page_route for the loaded page. Format:
318
+	 * $this->_page_config = array(
319
+	 *        'default' => array(
320
+	 *            'labels' => array(
321
+	 *                'buttons' => array(
322
+	 *                    'add' => esc_html__('label for adding item'),
323
+	 *                    'edit' => esc_html__('label for editing item'),
324
+	 *                    'delete' => esc_html__('label for deleting item')
325
+	 *                ),
326
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
327
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
328
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
329
+	 *            _define_page_props() method
330
+	 *            'nav' => array(
331
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
332
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
333
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
334
+	 *                'order' => 10, //required to indicate tab position.
335
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
336
+	 *                displayed then add this parameter.
337
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
338
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
339
+	 *            metaboxes set for eventespresso admin pages.
340
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
341
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
342
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
343
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
344
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
345
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
346
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
347
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
348
+	 *            want to display.
349
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
350
+	 *                'tab_id' => array(
351
+	 *                    'title' => 'tab_title',
352
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
353
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
354
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
355
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
356
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
357
+	 *                    attempt to use the callback which should match the name of a method in the class
358
+	 *                    ),
359
+	 *                'tab2_id' => array(
360
+	 *                    'title' => 'tab2 title',
361
+	 *                    'filename' => 'file_name_2'
362
+	 *                    'callback' => 'callback_method_for_content',
363
+	 *                 ),
364
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
365
+	 *            help tab area on an admin page. @link
366
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
367
+	 *            'help_tour' => array(
368
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
369
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
370
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
371
+	 *            ),
372
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
373
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
374
+	 *            just set
375
+	 *            'require_nonce' to FALSE
376
+	 *            )
377
+	 * )
378
+	 *
379
+	 * @abstract
380
+	 * @return void
381
+	 */
382
+	abstract protected function _set_page_config();
383
+
384
+
385
+
386
+
387
+
388
+	/** end sample help_tour methods **/
389
+	/**
390
+	 * _add_screen_options
391
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
+	 * to a particular view.
394
+	 *
395
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
+	 *         see also WP_Screen object documents...
397
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
+	 * @abstract
399
+	 * @return void
400
+	 */
401
+	abstract protected function _add_screen_options();
402
+
403
+
404
+	/**
405
+	 * _add_feature_pointers
406
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
+	 * extended) also see:
411
+	 *
412
+	 * @link   http://eamann.com/tech/wordpress-portland/
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract protected function _add_feature_pointers();
417
+
418
+
419
+	/**
420
+	 * load_scripts_styles
421
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
+	 * scripts/styles per view by putting them in a dynamic function in this format
424
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function load_scripts_styles();
430
+
431
+
432
+	/**
433
+	 * admin_init
434
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
+	 * all pages/views loaded by child class.
436
+	 *
437
+	 * @abstract
438
+	 * @return void
439
+	 */
440
+	abstract public function admin_init();
441
+
442
+
443
+	/**
444
+	 * admin_notices
445
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
+	 * all pages/views loaded by child class.
447
+	 *
448
+	 * @abstract
449
+	 * @return void
450
+	 */
451
+	abstract public function admin_notices();
452
+
453
+
454
+	/**
455
+	 * admin_footer_scripts
456
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
+	 * will apply to all pages/views loaded by child class.
458
+	 *
459
+	 * @return void
460
+	 */
461
+	abstract public function admin_footer_scripts();
462
+
463
+
464
+	/**
465
+	 * admin_footer
466
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
+	 * apply to all pages/views loaded by child class.
468
+	 *
469
+	 * @return void
470
+	 */
471
+	public function admin_footer()
472
+	{
473
+	}
474
+
475
+
476
+	/**
477
+	 * _global_ajax_hooks
478
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
+	 * Note: within the ajax callback methods.
480
+	 *
481
+	 * @abstract
482
+	 * @return void
483
+	 */
484
+	protected function _global_ajax_hooks()
485
+	{
486
+		// for lazy loading of metabox content
487
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
488
+	}
489
+
490
+
491
+	public function ajax_metabox_content()
492
+	{
493
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
494
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
495
+		self::cached_rss_display($contentid, $url);
496
+		wp_die();
497
+	}
498
+
499
+
500
+	/**
501
+	 * _page_setup
502
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
503
+	 * doesn't match the object.
504
+	 *
505
+	 * @final
506
+	 * @return void
507
+	 * @throws EE_Error
508
+	 * @throws InvalidArgumentException
509
+	 * @throws ReflectionException
510
+	 * @throws InvalidDataTypeException
511
+	 * @throws InvalidInterfaceException
512
+	 */
513
+	final protected function _page_setup()
514
+	{
515
+		// requires?
516
+		// admin_init stuff - global - we're setting this REALLY early
517
+		// so if EE_Admin pages have to hook into other WP pages they can.
518
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
519
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
520
+		// next verify if we need to load anything...
521
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
522
+		$this->page_folder = strtolower(
523
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
524
+		);
525
+		global $ee_menu_slugs;
526
+		$ee_menu_slugs = (array) $ee_menu_slugs;
527
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
528
+			return;
529
+		}
530
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
531
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
532
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
533
+				? $this->_req_data['action2']
534
+				: $this->_req_data['action'];
535
+		}
536
+		// then set blank or -1 action values to 'default'
537
+		$this->_req_action = isset($this->_req_data['action'])
538
+							 && ! empty($this->_req_data['action'])
539
+							 && $this->_req_data['action'] !== '-1'
540
+			? sanitize_key($this->_req_data['action'])
541
+			: 'default';
542
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
543
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
544
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
545
+			? $this->_req_data['route'] : $this->_req_action;
546
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
547
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
548
+			? $this->_req_data['route']
549
+			: $this->_req_action;
550
+		$this->_current_view = $this->_req_action;
551
+		$this->_req_nonce = $this->_req_action . '_nonce';
552
+		$this->_define_page_props();
553
+		$this->_current_page_view_url = add_query_arg(
554
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
555
+			$this->_admin_base_url
556
+		);
557
+		// default things
558
+		$this->_default_espresso_metaboxes = array(
559
+			'_espresso_news_post_box',
560
+			'_espresso_links_post_box',
561
+			'_espresso_ratings_request',
562
+			'_espresso_sponsors_post_box',
563
+		);
564
+		// set page configs
565
+		$this->_set_page_routes();
566
+		$this->_set_page_config();
567
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
568
+		if (isset($this->_req_data['wp_referer'])) {
569
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
570
+		}
571
+		// for caffeinated and other extended functionality.
572
+		//  If there is a _extend_page_config method
573
+		// then let's run that to modify the all the various page configuration arrays
574
+		if (method_exists($this, '_extend_page_config')) {
575
+			$this->_extend_page_config();
576
+		}
577
+		// for CPT and other extended functionality.
578
+		// If there is an _extend_page_config_for_cpt
579
+		// then let's run that to modify all the various page configuration arrays.
580
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
581
+			$this->_extend_page_config_for_cpt();
582
+		}
583
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
584
+		$this->_page_routes = apply_filters(
585
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
586
+			$this->_page_routes,
587
+			$this
588
+		);
589
+		$this->_page_config = apply_filters(
590
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
591
+			$this->_page_config,
592
+			$this
593
+		);
594
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
595
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
596
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
597
+			add_action(
598
+				'AHEE__EE_Admin_Page__route_admin_request',
599
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
600
+				10,
601
+				2
602
+			);
603
+		}
604
+		// next route only if routing enabled
605
+		if ($this->_routing && ! defined('DOING_AJAX')) {
606
+			$this->_verify_routes();
607
+			// next let's just check user_access and kill if no access
608
+			$this->check_user_access();
609
+			if ($this->_is_UI_request) {
610
+				// admin_init stuff - global, all views for this page class, specific view
611
+				add_action('admin_init', array($this, 'admin_init'), 10);
612
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
613
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
614
+				}
615
+			} else {
616
+				// hijack regular WP loading and route admin request immediately
617
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
618
+				$this->route_admin_request();
619
+			}
620
+		}
621
+	}
622
+
623
+
624
+	/**
625
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
626
+	 *
627
+	 * @return void
628
+	 * @throws ReflectionException
629
+	 * @throws EE_Error
630
+	 */
631
+	private function _do_other_page_hooks()
632
+	{
633
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
634
+		foreach ($registered_pages as $page) {
635
+			// now let's setup the file name and class that should be present
636
+			$classname = str_replace('.class.php', '', $page);
637
+			// autoloaders should take care of loading file
638
+			if (! class_exists($classname)) {
639
+				$error_msg[] = sprintf(
640
+					esc_html__(
641
+						'Something went wrong with loading the %s admin hooks page.',
642
+						'event_espresso'
643
+					),
644
+					$page
645
+				);
646
+				$error_msg[] = $error_msg[0]
647
+							   . "\r\n"
648
+							   . sprintf(
649
+								   esc_html__(
650
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
651
+									   'event_espresso'
652
+								   ),
653
+								   $page,
654
+								   '<br />',
655
+								   '<strong>' . $classname . '</strong>'
656
+							   );
657
+				throw new EE_Error(implode('||', $error_msg));
658
+			}
659
+			// // notice we are passing the instance of this class to the hook object.
660
+			$this->loader->getShared($classname, [$this]);
661
+		}
662
+	}
663
+
664
+
665
+	/**
666
+	 * @throws DomainException
667
+	 * @throws EE_Error
668
+	 * @throws InvalidArgumentException
669
+	 * @throws InvalidDataTypeException
670
+	 * @throws InvalidInterfaceException
671
+	 * @throws ReflectionException
672
+	 * @since $VID:$
673
+	 */
674
+	public function load_page_dependencies()
675
+	{
676
+		try {
677
+			$this->_load_page_dependencies();
678
+		} catch (EE_Error $e) {
679
+			$e->get_error();
680
+		}
681
+	}
682
+
683
+
684
+	/**
685
+	 * load_page_dependencies
686
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
687
+	 *
688
+	 * @return void
689
+	 * @throws DomainException
690
+	 * @throws EE_Error
691
+	 * @throws InvalidArgumentException
692
+	 * @throws InvalidDataTypeException
693
+	 * @throws InvalidInterfaceException
694
+	 * @throws ReflectionException
695
+	 */
696
+	protected function _load_page_dependencies()
697
+	{
698
+		// let's set the current_screen and screen options to override what WP set
699
+		$this->_current_screen = get_current_screen();
700
+		// load admin_notices - global, page class, and view specific
701
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
702
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
703
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
704
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
705
+		}
706
+		// load network admin_notices - global, page class, and view specific
707
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
708
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
709
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
710
+		}
711
+		// this will save any per_page screen options if they are present
712
+		$this->_set_per_page_screen_options();
713
+		// setup list table properties
714
+		$this->_set_list_table();
715
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
716
+		// However in some cases the metaboxes will need to be added within a route handling callback.
717
+		$this->_add_registered_meta_boxes();
718
+		$this->_add_screen_columns();
719
+		// add screen options - global, page child class, and view specific
720
+		$this->_add_global_screen_options();
721
+		$this->_add_screen_options();
722
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
723
+		if (method_exists($this, $add_screen_options)) {
724
+			$this->{$add_screen_options}();
725
+		}
726
+		// add help tab(s) and tours- set via page_config and qtips.
727
+		$this->_add_help_tour();
728
+		$this->_add_help_tabs();
729
+		$this->_add_qtips();
730
+		// add feature_pointers - global, page child class, and view specific
731
+		$this->_add_feature_pointers();
732
+		$this->_add_global_feature_pointers();
733
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
734
+		if (method_exists($this, $add_feature_pointer)) {
735
+			$this->{$add_feature_pointer}();
736
+		}
737
+		// enqueue scripts/styles - global, page class, and view specific
738
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
739
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
740
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
741
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
742
+		}
743
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
744
+		// admin_print_footer_scripts - global, page child class, and view specific.
745
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
746
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
747
+		// is a good use case. Notice the late priority we're giving these
748
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
749
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
750
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
751
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
752
+		}
753
+		// admin footer scripts
754
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
755
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
756
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
757
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
758
+		}
759
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
760
+		// targeted hook
761
+		do_action(
762
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
763
+		);
764
+	}
765
+
766
+
767
+	/**
768
+	 * _set_defaults
769
+	 * This sets some global defaults for class properties.
770
+	 */
771
+	private function _set_defaults()
772
+	{
773
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
774
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
775
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
776
+		$this->_page_config = $this->_default_route_query_args = array();
777
+		$this->_default_nav_tab_name = 'overview';
778
+		// init template args
779
+		$this->_template_args = array(
780
+			'admin_page_header'  => '',
781
+			'admin_page_content' => '',
782
+			'post_body_content'  => '',
783
+			'before_list_table'  => '',
784
+			'after_list_table'   => '',
785
+		);
786
+	}
787
+
788
+
789
+	/**
790
+	 * route_admin_request
791
+	 *
792
+	 * @see    _route_admin_request()
793
+	 * @return exception|void error
794
+	 * @throws InvalidArgumentException
795
+	 * @throws InvalidInterfaceException
796
+	 * @throws InvalidDataTypeException
797
+	 * @throws EE_Error
798
+	 * @throws ReflectionException
799
+	 */
800
+	public function route_admin_request()
801
+	{
802
+		try {
803
+			$this->_route_admin_request();
804
+		} catch (EE_Error $e) {
805
+			$e->get_error();
806
+		}
807
+	}
808
+
809
+
810
+	public function set_wp_page_slug($wp_page_slug)
811
+	{
812
+		$this->_wp_page_slug = $wp_page_slug;
813
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
814
+		if (is_network_admin()) {
815
+			$this->_wp_page_slug .= '-network';
816
+		}
817
+	}
818
+
819
+
820
+	/**
821
+	 * _verify_routes
822
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
823
+	 * we know if we need to drop out.
824
+	 *
825
+	 * @return bool
826
+	 * @throws EE_Error
827
+	 */
828
+	protected function _verify_routes()
829
+	{
830
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
831
+			return false;
832
+		}
833
+		$this->_route = false;
834
+		// check that the page_routes array is not empty
835
+		if (empty($this->_page_routes)) {
836
+			// user error msg
837
+			$error_msg = sprintf(
838
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
839
+				$this->_admin_page_title
840
+			);
841
+			// developer error msg
842
+			$error_msg .= '||' . $error_msg
843
+						  . esc_html__(
844
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
845
+							  'event_espresso'
846
+						  );
847
+			throw new EE_Error($error_msg);
848
+		}
849
+		// and that the requested page route exists
850
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
851
+			$this->_route = $this->_page_routes[ $this->_req_action ];
852
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
853
+				? $this->_page_config[ $this->_req_action ] : array();
854
+		} else {
855
+			// user error msg
856
+			$error_msg = sprintf(
857
+				esc_html__(
858
+					'The requested page route does not exist for the %s admin page.',
859
+					'event_espresso'
860
+				),
861
+				$this->_admin_page_title
862
+			);
863
+			// developer error msg
864
+			$error_msg .= '||' . $error_msg
865
+						  . sprintf(
866
+							  esc_html__(
867
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
868
+								  'event_espresso'
869
+							  ),
870
+							  $this->_req_action
871
+						  );
872
+			throw new EE_Error($error_msg);
873
+		}
874
+		// and that a default route exists
875
+		if (! array_key_exists('default', $this->_page_routes)) {
876
+			// user error msg
877
+			$error_msg = sprintf(
878
+				esc_html__(
879
+					'A default page route has not been set for the % admin page.',
880
+					'event_espresso'
881
+				),
882
+				$this->_admin_page_title
883
+			);
884
+			// developer error msg
885
+			$error_msg .= '||' . $error_msg
886
+						  . esc_html__(
887
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
888
+							  'event_espresso'
889
+						  );
890
+			throw new EE_Error($error_msg);
891
+		}
892
+
893
+		// first lets' catch if the UI request has EVER been set.
894
+		if ($this->_is_UI_request === null) {
895
+			// lets set if this is a UI request or not.
896
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
897
+			// wait a minute... we might have a noheader in the route array
898
+			$this->_is_UI_request = is_array($this->_route)
899
+									&& isset($this->_route['noheader'])
900
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
901
+		}
902
+		$this->_set_current_labels();
903
+		return true;
904
+	}
905
+
906
+
907
+	/**
908
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
909
+	 *
910
+	 * @param  string $route the route name we're verifying
911
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
912
+	 * @throws EE_Error
913
+	 */
914
+	protected function _verify_route($route)
915
+	{
916
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
917
+			return true;
918
+		}
919
+		// user error msg
920
+		$error_msg = sprintf(
921
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
922
+			$this->_admin_page_title
923
+		);
924
+		// developer error msg
925
+		$error_msg .= '||' . $error_msg
926
+					  . sprintf(
927
+						  esc_html__(
928
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
929
+							  'event_espresso'
930
+						  ),
931
+						  $route
932
+					  );
933
+		throw new EE_Error($error_msg);
934
+	}
935
+
936
+
937
+	/**
938
+	 * perform nonce verification
939
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
940
+	 * using this method (and save retyping!)
941
+	 *
942
+	 * @param string $nonce     The nonce sent
943
+	 * @param string $nonce_ref The nonce reference string (name0)
944
+	 * @return void
945
+	 * @throws EE_Error
946
+	 * @throws InvalidArgumentException
947
+	 * @throws InvalidDataTypeException
948
+	 * @throws InvalidInterfaceException
949
+	 */
950
+	protected function _verify_nonce($nonce, $nonce_ref)
951
+	{
952
+		// verify nonce against expected value
953
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
954
+			// these are not the droids you are looking for !!!
955
+			$msg = sprintf(
956
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
957
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
958
+				'</a>'
959
+			);
960
+			if (WP_DEBUG) {
961
+				$msg .= "\n  "
962
+						. sprintf(
963
+							esc_html__(
964
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
965
+								'event_espresso'
966
+							),
967
+							__CLASS__
968
+						);
969
+			}
970
+			if (! defined('DOING_AJAX')) {
971
+				wp_die($msg);
972
+			} else {
973
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
974
+				$this->_return_json();
975
+			}
976
+		}
977
+	}
978
+
979
+
980
+	/**
981
+	 * _route_admin_request()
982
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
983
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
984
+	 * in the page routes and then will try to load the corresponding method.
985
+	 *
986
+	 * @return void
987
+	 * @throws EE_Error
988
+	 * @throws InvalidArgumentException
989
+	 * @throws InvalidDataTypeException
990
+	 * @throws InvalidInterfaceException
991
+	 * @throws ReflectionException
992
+	 */
993
+	protected function _route_admin_request()
994
+	{
995
+		if (! $this->_is_UI_request) {
996
+			$this->_verify_routes();
997
+		}
998
+		$nonce_check = isset($this->_route_config['require_nonce'])
999
+			? $this->_route_config['require_nonce']
1000
+			: true;
1001
+		if ($this->_req_action !== 'default' && $nonce_check) {
1002
+			// set nonce from post data
1003
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
1004
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1005
+				: '';
1006
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1007
+		}
1008
+		// set the nav_tabs array but ONLY if this is  UI_request
1009
+		if ($this->_is_UI_request) {
1010
+			$this->_set_nav_tabs();
1011
+		}
1012
+		// grab callback function
1013
+		$func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1014
+		// check if callback has args
1015
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1016
+		$error_msg = '';
1017
+		// action right before calling route
1018
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1019
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1020
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1021
+		}
1022
+		// right before calling the route, let's remove _wp_http_referer from the
1023
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1024
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
1025
+			'_wp_http_referer',
1026
+			wp_unslash($_SERVER['REQUEST_URI'])
1027
+		);
1028
+		if (! empty($func)) {
1029
+			if (is_array($func)) {
1030
+				list($class, $method) = $func;
1031
+			} elseif (strpos($func, '::') !== false) {
1032
+				list($class, $method) = explode('::', $func);
1033
+			} else {
1034
+				$class = $this;
1035
+				$method = $func;
1036
+			}
1037
+			if (! (is_object($class) && $class === $this)) {
1038
+				// send along this admin page object for access by addons.
1039
+				$args['admin_page_object'] = $this;
1040
+			}
1041
+			// is it a method on a class that doesn't work?
1042
+			if (((method_exists($class, $method)
1043
+				  && call_user_func_array(array($class, $method), $args) === false)
1044
+				 && (// is it a standalone function that doesn't work?
1045
+					 function_exists($method)
1046
+					 && call_user_func_array(
1047
+						 $func,
1048
+						 array_merge(array('admin_page_object' => $this), $args)
1049
+					 ) === false
1050
+				 )) || (// is it neither a class method NOR a standalone function?
1051
+					! function_exists($method)
1052
+					&& ! method_exists($class, $method)
1053
+				)
1054
+			) {
1055
+				// user error msg
1056
+				$error_msg = esc_html__(
1057
+					'An error occurred. The  requested page route could not be found.',
1058
+					'event_espresso'
1059
+				);
1060
+				// developer error msg
1061
+				$error_msg .= '||';
1062
+				$error_msg .= sprintf(
1063
+					esc_html__(
1064
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1065
+						'event_espresso'
1066
+					),
1067
+					$method
1068
+				);
1069
+			}
1070
+			if (! empty($error_msg)) {
1071
+				throw new EE_Error($error_msg);
1072
+			}
1073
+		}
1074
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1075
+		// then we need to reset the routing properties to the new route.
1076
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1077
+		if ($this->_is_UI_request === false
1078
+			&& is_array($this->_route)
1079
+			&& ! empty($this->_route['headers_sent_route'])
1080
+		) {
1081
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1082
+		}
1083
+	}
1084
+
1085
+
1086
+	/**
1087
+	 * This method just allows the resetting of page properties in the case where a no headers
1088
+	 * route redirects to a headers route in its route config.
1089
+	 *
1090
+	 * @since   4.3.0
1091
+	 * @param  string $new_route New (non header) route to redirect to.
1092
+	 * @return   void
1093
+	 * @throws ReflectionException
1094
+	 * @throws InvalidArgumentException
1095
+	 * @throws InvalidInterfaceException
1096
+	 * @throws InvalidDataTypeException
1097
+	 * @throws EE_Error
1098
+	 */
1099
+	protected function _reset_routing_properties($new_route)
1100
+	{
1101
+		$this->_is_UI_request = true;
1102
+		// now we set the current route to whatever the headers_sent_route is set at
1103
+		$this->_req_data['action'] = $new_route;
1104
+		// rerun page setup
1105
+		$this->_page_setup();
1106
+	}
1107
+
1108
+
1109
+	/**
1110
+	 * _add_query_arg
1111
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1112
+	 *(internally just uses EEH_URL's function with the same name)
1113
+	 *
1114
+	 * @param array  $args
1115
+	 * @param string $url
1116
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1117
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1118
+	 *                                        Example usage: If the current page is:
1119
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1120
+	 *                                        &action=default&event_id=20&month_range=March%202015
1121
+	 *                                        &_wpnonce=5467821
1122
+	 *                                        and you call:
1123
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1124
+	 *                                        array(
1125
+	 *                                        'action' => 'resend_something',
1126
+	 *                                        'page=>espresso_registrations'
1127
+	 *                                        ),
1128
+	 *                                        $some_url,
1129
+	 *                                        true
1130
+	 *                                        );
1131
+	 *                                        It will produce a url in this structure:
1132
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1133
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1134
+	 *                                        month_range]=March%202015
1135
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1136
+	 * @return string
1137
+	 */
1138
+	public static function add_query_args_and_nonce(
1139
+		$args = array(),
1140
+		$url = '',
1141
+		$sticky = false,
1142
+		$exclude_nonce = false
1143
+	) {
1144
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1145
+		if ($sticky) {
1146
+			$request = $_REQUEST;
1147
+			unset($request['_wp_http_referer'], $request['wp_referer']);
1148
+			foreach ($request as $key => $value) {
1149
+				// do not add nonces
1150
+				if (strpos($key, 'nonce') !== false) {
1151
+					continue;
1152
+				}
1153
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1154
+			}
1155
+		}
1156
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1157
+	}
1158
+
1159
+
1160
+	/**
1161
+	 * This returns a generated link that will load the related help tab.
1162
+	 *
1163
+	 * @param  string $help_tab_id the id for the connected help tab
1164
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1165
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1166
+	 * @uses EEH_Template::get_help_tab_link()
1167
+	 * @return string              generated link
1168
+	 */
1169
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1170
+	{
1171
+		return EEH_Template::get_help_tab_link(
1172
+			$help_tab_id,
1173
+			$this->page_slug,
1174
+			$this->_req_action,
1175
+			$icon_style,
1176
+			$help_text
1177
+		);
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * _add_help_tabs
1183
+	 * Note child classes define their help tabs within the page_config array.
1184
+	 *
1185
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1186
+	 * @return void
1187
+	 * @throws DomainException
1188
+	 * @throws EE_Error
1189
+	 */
1190
+	protected function _add_help_tabs()
1191
+	{
1192
+		$tour_buttons = '';
1193
+		if (isset($this->_page_config[ $this->_req_action ])) {
1194
+			$config = $this->_page_config[ $this->_req_action ];
1195
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1196
+			if (isset($this->_help_tour[ $this->_req_action ])) {
1197
+				$tb = array();
1198
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1199
+				foreach ($this->_help_tour['tours'] as $tour) {
1200
+					// if this is the end tour then we don't need to setup a button
1201
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1202
+						continue;
1203
+					}
1204
+					$tb[] = '<button id="trigger-tour-'
1205
+							. $tour->get_slug()
1206
+							. '" class="button-primary trigger-ee-help-tour">'
1207
+							. $tour->get_label()
1208
+							. '</button>';
1209
+				}
1210
+				$tour_buttons .= implode('<br />', $tb);
1211
+				$tour_buttons .= '</div></div>';
1212
+			}
1213
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1214
+			if (is_array($config) && isset($config['help_sidebar'])) {
1215
+				// check that the callback given is valid
1216
+				if (! method_exists($this, $config['help_sidebar'])) {
1217
+					throw new EE_Error(
1218
+						sprintf(
1219
+							esc_html__(
1220
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1221
+								'event_espresso'
1222
+							),
1223
+							$config['help_sidebar'],
1224
+							get_class($this)
1225
+						)
1226
+					);
1227
+				}
1228
+				$content = apply_filters(
1229
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1230
+					$this->{$config['help_sidebar']}()
1231
+				);
1232
+				$content .= $tour_buttons; // add help tour buttons.
1233
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1234
+				$this->_current_screen->set_help_sidebar($content);
1235
+			}
1236
+			// if there ARE tour buttons...
1237
+			if (! empty($tour_buttons)) {
1238
+				// if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1239
+				if (! isset($config['help_sidebar'])) {
1240
+					$this->_current_screen->set_help_sidebar($tour_buttons);
1241
+				}
1242
+				// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1243
+				if (! isset($config['help_tabs'])) {
1244
+					$_ht['id'] = $this->page_slug;
1245
+					$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1246
+					$_ht['content'] = '<p>'
1247
+									  . esc_html__(
1248
+										  'The buttons to the right allow you to start/restart any help tours available for this page',
1249
+										  'event_espresso'
1250
+									  ) . '</p>';
1251
+					$this->_current_screen->add_help_tab($_ht);
1252
+				}
1253
+			}
1254
+			if (! isset($config['help_tabs'])) {
1255
+				return;
1256
+			} //no help tabs for this route
1257
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1258
+				// we're here so there ARE help tabs!
1259
+				// make sure we've got what we need
1260
+				if (! isset($cfg['title'])) {
1261
+					throw new EE_Error(
1262
+						esc_html__(
1263
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1264
+							'event_espresso'
1265
+						)
1266
+					);
1267
+				}
1268
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1269
+					throw new EE_Error(
1270
+						esc_html__(
1271
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1272
+							'event_espresso'
1273
+						)
1274
+					);
1275
+				}
1276
+				// first priority goes to content.
1277
+				if (! empty($cfg['content'])) {
1278
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1279
+					// second priority goes to filename
1280
+				} elseif (! empty($cfg['filename'])) {
1281
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1282
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1283
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1284
+															 . basename($this->_get_dir())
1285
+															 . '/help_tabs/'
1286
+															 . $cfg['filename']
1287
+															 . '.help_tab.php' : $file_path;
1288
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1289
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1290
+						EE_Error::add_error(
1291
+							sprintf(
1292
+								esc_html__(
1293
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1294
+									'event_espresso'
1295
+								),
1296
+								$tab_id,
1297
+								key($config),
1298
+								$file_path
1299
+							),
1300
+							__FILE__,
1301
+							__FUNCTION__,
1302
+							__LINE__
1303
+						);
1304
+						return;
1305
+					}
1306
+					$template_args['admin_page_obj'] = $this;
1307
+					$content = EEH_Template::display_template(
1308
+						$file_path,
1309
+						$template_args,
1310
+						true
1311
+					);
1312
+				} else {
1313
+					$content = '';
1314
+				}
1315
+				// check if callback is valid
1316
+				if (empty($content) && (
1317
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1318
+					)
1319
+				) {
1320
+					EE_Error::add_error(
1321
+						sprintf(
1322
+							esc_html__(
1323
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1324
+								'event_espresso'
1325
+							),
1326
+							$cfg['title']
1327
+						),
1328
+						__FILE__,
1329
+						__FUNCTION__,
1330
+						__LINE__
1331
+					);
1332
+					return;
1333
+				}
1334
+				// setup config array for help tab method
1335
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1336
+				$_ht = array(
1337
+					'id'       => $id,
1338
+					'title'    => $cfg['title'],
1339
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1340
+					'content'  => $content,
1341
+				);
1342
+				$this->_current_screen->add_help_tab($_ht);
1343
+			}
1344
+		}
1345
+	}
1346
+
1347
+
1348
+	/**
1349
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1350
+	 * an array with properties for setting up usage of the joyride plugin
1351
+	 *
1352
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1353
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1354
+	 *         _set_page_config() comments
1355
+	 * @return void
1356
+	 * @throws EE_Error
1357
+	 * @throws InvalidArgumentException
1358
+	 * @throws InvalidDataTypeException
1359
+	 * @throws InvalidInterfaceException
1360
+	 */
1361
+	protected function _add_help_tour()
1362
+	{
1363
+		$tours = array();
1364
+		$this->_help_tour = array();
1365
+		// exit early if help tours are turned off globally
1366
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1367
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1368
+		) {
1369
+			return;
1370
+		}
1371
+		// loop through _page_config to find any help_tour defined
1372
+		foreach ($this->_page_config as $route => $config) {
1373
+			// we're only going to set things up for this route
1374
+			if ($route !== $this->_req_action) {
1375
+				continue;
1376
+			}
1377
+			if (isset($config['help_tour'])) {
1378
+				foreach ($config['help_tour'] as $tour) {
1379
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1380
+					// let's see if we can get that file...
1381
+					// if not its possible this is a decaf route not set in caffeinated
1382
+					// so lets try and get the caffeinated equivalent
1383
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1384
+															 . basename($this->_get_dir())
1385
+															 . '/help_tours/'
1386
+															 . $tour
1387
+															 . '.class.php' : $file_path;
1388
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1389
+					if (! is_readable($file_path)) {
1390
+						EE_Error::add_error(
1391
+							sprintf(
1392
+								esc_html__(
1393
+									'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1394
+									'event_espresso'
1395
+								),
1396
+								$file_path,
1397
+								$tour
1398
+							),
1399
+							__FILE__,
1400
+							__FUNCTION__,
1401
+							__LINE__
1402
+						);
1403
+						return;
1404
+					}
1405
+					require_once $file_path;
1406
+					if (! class_exists($tour)) {
1407
+						$error_msg[] = sprintf(
1408
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1409
+							$tour
1410
+						);
1411
+						$error_msg[] = $error_msg[0] . "\r\n"
1412
+									   . sprintf(
1413
+										   esc_html__(
1414
+											   'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1415
+											   'event_espresso'
1416
+										   ),
1417
+										   $tour,
1418
+										   '<br />',
1419
+										   $tour,
1420
+										   $this->_req_action,
1421
+										   get_class($this)
1422
+									   );
1423
+						throw new EE_Error(implode('||', $error_msg));
1424
+					}
1425
+					$tour_obj = new $tour($this->_is_caf);
1426
+					$tours[] = $tour_obj;
1427
+					$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1428
+				}
1429
+				// let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1430
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1431
+				$tours[] = $end_stop_tour;
1432
+				$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1433
+			}
1434
+		}
1435
+
1436
+		if (! empty($tours)) {
1437
+			$this->_help_tour['tours'] = $tours;
1438
+		}
1439
+		// that's it!  Now that the $_help_tours property is set (or not)
1440
+		// the scripts and html should be taken care of automatically.
1441
+
1442
+		/**
1443
+		 * Allow extending the help tours variable.
1444
+		 *
1445
+		 * @param Array $_help_tour The array containing all help tour information to be displayed.
1446
+		 */
1447
+		$this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1448
+	}
1449
+
1450
+
1451
+	/**
1452
+	 * This simply sets up any qtips that have been defined in the page config
1453
+	 *
1454
+	 * @return void
1455
+	 */
1456
+	protected function _add_qtips()
1457
+	{
1458
+		if (isset($this->_route_config['qtips'])) {
1459
+			$qtips = (array) $this->_route_config['qtips'];
1460
+			// load qtip loader
1461
+			$path = array(
1462
+				$this->_get_dir() . '/qtips/',
1463
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1464
+			);
1465
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1466
+		}
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * _set_nav_tabs
1472
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1473
+	 * wish to add additional tabs or modify accordingly.
1474
+	 *
1475
+	 * @return void
1476
+	 * @throws InvalidArgumentException
1477
+	 * @throws InvalidInterfaceException
1478
+	 * @throws InvalidDataTypeException
1479
+	 */
1480
+	protected function _set_nav_tabs()
1481
+	{
1482
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1483
+		$i = 0;
1484
+		foreach ($this->_page_config as $slug => $config) {
1485
+			if (! is_array($config)
1486
+				|| (
1487
+					is_array($config)
1488
+					&& (
1489
+						(isset($config['nav']) && ! $config['nav'])
1490
+						|| ! isset($config['nav'])
1491
+					)
1492
+				)
1493
+			) {
1494
+				continue;
1495
+			}
1496
+			// no nav tab for this config
1497
+			// check for persistent flag
1498
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1499
+				// nav tab is only to appear when route requested.
1500
+				continue;
1501
+			}
1502
+			if (! $this->check_user_access($slug, true)) {
1503
+				// no nav tab because current user does not have access.
1504
+				continue;
1505
+			}
1506
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1507
+			$this->_nav_tabs[ $slug ] = array(
1508
+				'url'       => isset($config['nav']['url'])
1509
+					? $config['nav']['url']
1510
+					: self::add_query_args_and_nonce(
1511
+						array('action' => $slug),
1512
+						$this->_admin_base_url
1513
+					),
1514
+				'link_text' => isset($config['nav']['label'])
1515
+					? $config['nav']['label']
1516
+					: ucwords(
1517
+						str_replace('_', ' ', $slug)
1518
+					),
1519
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1520
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1521
+			);
1522
+			$i++;
1523
+		}
1524
+		// if $this->_nav_tabs is empty then lets set the default
1525
+		if (empty($this->_nav_tabs)) {
1526
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1527
+				'url'       => $this->_admin_base_url,
1528
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1529
+				'css_class' => 'nav-tab-active',
1530
+				'order'     => 10,
1531
+			);
1532
+		}
1533
+		// now let's sort the tabs according to order
1534
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1535
+	}
1536
+
1537
+
1538
+	/**
1539
+	 * _set_current_labels
1540
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1541
+	 * property array
1542
+	 *
1543
+	 * @return void
1544
+	 */
1545
+	private function _set_current_labels()
1546
+	{
1547
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1548
+			foreach ($this->_route_config['labels'] as $label => $text) {
1549
+				if (is_array($text)) {
1550
+					foreach ($text as $sublabel => $subtext) {
1551
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1552
+					}
1553
+				} else {
1554
+					$this->_labels[ $label ] = $text;
1555
+				}
1556
+			}
1557
+		}
1558
+	}
1559
+
1560
+
1561
+	/**
1562
+	 *        verifies user access for this admin page
1563
+	 *
1564
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1565
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1566
+	 *                               return false if verify fail.
1567
+	 * @return bool
1568
+	 * @throws InvalidArgumentException
1569
+	 * @throws InvalidDataTypeException
1570
+	 * @throws InvalidInterfaceException
1571
+	 */
1572
+	public function check_user_access($route_to_check = '', $verify_only = false)
1573
+	{
1574
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1575
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1576
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1577
+					  && is_array(
1578
+						  $this->_page_routes[ $route_to_check ]
1579
+					  )
1580
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1581
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1582
+		if (empty($capability) && empty($route_to_check)) {
1583
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1584
+				: $this->_route['capability'];
1585
+		} else {
1586
+			$capability = empty($capability) ? 'manage_options' : $capability;
1587
+		}
1588
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1589
+		if (! defined('DOING_AJAX')
1590
+			&& (
1591
+				! function_exists('is_admin')
1592
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1593
+					$capability,
1594
+					$this->page_slug
1595
+					. '_'
1596
+					. $route_to_check,
1597
+					$id
1598
+				)
1599
+			)
1600
+		) {
1601
+			if ($verify_only) {
1602
+				return false;
1603
+			}
1604
+			if (is_user_logged_in()) {
1605
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1606
+			} else {
1607
+				return false;
1608
+			}
1609
+		}
1610
+		return true;
1611
+	}
1612
+
1613
+
1614
+	/**
1615
+	 * admin_init_global
1616
+	 * This runs all the code that we want executed within the WP admin_init hook.
1617
+	 * This method executes for ALL EE Admin pages.
1618
+	 *
1619
+	 * @return void
1620
+	 */
1621
+	public function admin_init_global()
1622
+	{
1623
+	}
1624
+
1625
+
1626
+	/**
1627
+	 * wp_loaded_global
1628
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1629
+	 * EE_Admin page and will execute on every EE Admin Page load
1630
+	 *
1631
+	 * @return void
1632
+	 */
1633
+	public function wp_loaded()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+	/**
1639
+	 * admin_notices
1640
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1641
+	 * ALL EE_Admin pages.
1642
+	 *
1643
+	 * @return void
1644
+	 */
1645
+	public function admin_notices_global()
1646
+	{
1647
+		$this->_display_no_javascript_warning();
1648
+		$this->_display_espresso_notices();
1649
+	}
1650
+
1651
+
1652
+	public function network_admin_notices_global()
1653
+	{
1654
+		$this->_display_no_javascript_warning();
1655
+		$this->_display_espresso_notices();
1656
+	}
1657
+
1658
+
1659
+	/**
1660
+	 * admin_footer_scripts_global
1661
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1662
+	 * will apply on ALL EE_Admin pages.
1663
+	 *
1664
+	 * @return void
1665
+	 */
1666
+	public function admin_footer_scripts_global()
1667
+	{
1668
+		$this->_add_admin_page_ajax_loading_img();
1669
+		$this->_add_admin_page_overlay();
1670
+		// if metaboxes are present we need to add the nonce field
1671
+		if (isset($this->_route_config['metaboxes'])
1672
+			|| isset($this->_route_config['list_table'])
1673
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1674
+		) {
1675
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1676
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1677
+		}
1678
+	}
1679
+
1680
+
1681
+	/**
1682
+	 * admin_footer_global
1683
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1684
+	 * This particular method will apply on ALL EE_Admin Pages.
1685
+	 *
1686
+	 * @return void
1687
+	 * @throws InvalidArgumentException
1688
+	 * @throws InvalidDataTypeException
1689
+	 * @throws InvalidInterfaceException
1690
+	 */
1691
+	public function admin_footer_global()
1692
+	{
1693
+		// dialog container for dialog helper
1694
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1695
+		$d_cont .= '<div class="ee-notices"></div>';
1696
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1697
+		$d_cont .= '</div>';
1698
+		echo $d_cont;
1699
+		// help tour stuff?
1700
+		if (isset($this->_help_tour[ $this->_req_action ])) {
1701
+			echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1702
+		}
1703
+		// current set timezone for timezone js
1704
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1705
+	}
1706
+
1707
+
1708
+	/**
1709
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1710
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1711
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1712
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1713
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1714
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1715
+	 * for the
1716
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1717
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1718
+	 *    'help_trigger_id' => array(
1719
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1720
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1721
+	 *    )
1722
+	 * );
1723
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1724
+	 *
1725
+	 * @param array $help_array
1726
+	 * @param bool  $display
1727
+	 * @return string content
1728
+	 * @throws DomainException
1729
+	 * @throws EE_Error
1730
+	 */
1731
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1732
+	{
1733
+		$content = '';
1734
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1735
+		// loop through the array and setup content
1736
+		foreach ($help_array as $trigger => $help) {
1737
+			// make sure the array is setup properly
1738
+			if (! isset($help['title'], $help['content'])) {
1739
+				throw new EE_Error(
1740
+					esc_html__(
1741
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1742
+						'event_espresso'
1743
+					)
1744
+				);
1745
+			}
1746
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1747
+			$template_args = array(
1748
+				'help_popup_id'      => $trigger,
1749
+				'help_popup_title'   => $help['title'],
1750
+				'help_popup_content' => $help['content'],
1751
+			);
1752
+			$content .= EEH_Template::display_template(
1753
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1754
+				$template_args,
1755
+				true
1756
+			);
1757
+		}
1758
+		if ($display) {
1759
+			echo $content;
1760
+			return '';
1761
+		}
1762
+		return $content;
1763
+	}
1764
+
1765
+
1766
+	/**
1767
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1768
+	 *
1769
+	 * @return array properly formatted array for help popup content
1770
+	 * @throws EE_Error
1771
+	 */
1772
+	private function _get_help_content()
1773
+	{
1774
+		// what is the method we're looking for?
1775
+		$method_name = '_help_popup_content_' . $this->_req_action;
1776
+		// if method doesn't exist let's get out.
1777
+		if (! method_exists($this, $method_name)) {
1778
+			return array();
1779
+		}
1780
+		// k we're good to go let's retrieve the help array
1781
+		$help_array = $this->{$method_name}();
1782
+		// make sure we've got an array!
1783
+		if (! is_array($help_array)) {
1784
+			throw new EE_Error(
1785
+				esc_html__(
1786
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1787
+					'event_espresso'
1788
+				)
1789
+			);
1790
+		}
1791
+		return $help_array;
1792
+	}
1793
+
1794
+
1795
+	/**
1796
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1797
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1798
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1799
+	 *
1800
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1801
+	 * @param boolean $display    if false then we return the trigger string
1802
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1803
+	 * @return string
1804
+	 * @throws DomainException
1805
+	 * @throws EE_Error
1806
+	 */
1807
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1808
+	{
1809
+		if (defined('DOING_AJAX')) {
1810
+			return '';
1811
+		}
1812
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1813
+		$help_array = $this->_get_help_content();
1814
+		$help_content = '';
1815
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1816
+			$help_array[ $trigger_id ] = array(
1817
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1818
+				'content' => esc_html__(
1819
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1820
+					'event_espresso'
1821
+				),
1822
+			);
1823
+			$help_content = $this->_set_help_popup_content($help_array);
1824
+		}
1825
+		// let's setup the trigger
1826
+		$content = '<a class="ee-dialog" href="?height='
1827
+				   . $dimensions[0]
1828
+				   . '&width='
1829
+				   . $dimensions[1]
1830
+				   . '&inlineId='
1831
+				   . $trigger_id
1832
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1833
+		$content .= $help_content;
1834
+		if ($display) {
1835
+			echo $content;
1836
+			return '';
1837
+		}
1838
+		return $content;
1839
+	}
1840
+
1841
+
1842
+	/**
1843
+	 * _add_global_screen_options
1844
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1845
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1846
+	 *
1847
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1848
+	 *         see also WP_Screen object documents...
1849
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1850
+	 * @abstract
1851
+	 * @return void
1852
+	 */
1853
+	private function _add_global_screen_options()
1854
+	{
1855
+	}
1856
+
1857
+
1858
+	/**
1859
+	 * _add_global_feature_pointers
1860
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1861
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1862
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1863
+	 *
1864
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1865
+	 *         extended) also see:
1866
+	 * @link   http://eamann.com/tech/wordpress-portland/
1867
+	 * @abstract
1868
+	 * @return void
1869
+	 */
1870
+	private function _add_global_feature_pointers()
1871
+	{
1872
+	}
1873
+
1874
+
1875
+	/**
1876
+	 * load_global_scripts_styles
1877
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1878
+	 *
1879
+	 * @return void
1880
+	 * @throws EE_Error
1881
+	 */
1882
+	public function load_global_scripts_styles()
1883
+	{
1884
+		/** STYLES **/
1885
+		// add debugging styles
1886
+		if (WP_DEBUG) {
1887
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1888
+		}
1889
+		// register all styles
1890
+		wp_register_style(
1891
+			'espresso-ui-theme',
1892
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1893
+			array(),
1894
+			EVENT_ESPRESSO_VERSION
1895
+		);
1896
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1897
+		// helpers styles
1898
+		wp_register_style(
1899
+			'ee-text-links',
1900
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1901
+			array(),
1902
+			EVENT_ESPRESSO_VERSION
1903
+		);
1904
+		/** SCRIPTS **/
1905
+		// register all scripts
1906
+		wp_register_script(
1907
+			'ee-dialog',
1908
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1909
+			array('jquery', 'jquery-ui-draggable'),
1910
+			EVENT_ESPRESSO_VERSION,
1911
+			true
1912
+		);
1913
+		wp_register_script(
1914
+			'ee_admin_js',
1915
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1916
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1917
+			EVENT_ESPRESSO_VERSION,
1918
+			true
1919
+		);
1920
+		wp_register_script(
1921
+			'jquery-ui-timepicker-addon',
1922
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1923
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1924
+			EVENT_ESPRESSO_VERSION,
1925
+			true
1926
+		);
1927
+		if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1928
+			add_filter('FHEE_load_joyride', '__return_true');
1929
+		}
1930
+		// script for sorting tables
1931
+		wp_register_script(
1932
+			'espresso_ajax_table_sorting',
1933
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1934
+			array('ee_admin_js', 'jquery-ui-sortable'),
1935
+			EVENT_ESPRESSO_VERSION,
1936
+			true
1937
+		);
1938
+		// script for parsing uri's
1939
+		wp_register_script(
1940
+			'ee-parse-uri',
1941
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1942
+			array(),
1943
+			EVENT_ESPRESSO_VERSION,
1944
+			true
1945
+		);
1946
+		// and parsing associative serialized form elements
1947
+		wp_register_script(
1948
+			'ee-serialize-full-array',
1949
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1950
+			array('jquery'),
1951
+			EVENT_ESPRESSO_VERSION,
1952
+			true
1953
+		);
1954
+		// helpers scripts
1955
+		wp_register_script(
1956
+			'ee-text-links',
1957
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1958
+			array('jquery'),
1959
+			EVENT_ESPRESSO_VERSION,
1960
+			true
1961
+		);
1962
+		wp_register_script(
1963
+			'ee-moment-core',
1964
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1965
+			array(),
1966
+			EVENT_ESPRESSO_VERSION,
1967
+			true
1968
+		);
1969
+		wp_register_script(
1970
+			'ee-moment',
1971
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1972
+			array('ee-moment-core'),
1973
+			EVENT_ESPRESSO_VERSION,
1974
+			true
1975
+		);
1976
+		wp_register_script(
1977
+			'ee-datepicker',
1978
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1979
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1980
+			EVENT_ESPRESSO_VERSION,
1981
+			true
1982
+		);
1983
+		// google charts
1984
+		wp_register_script(
1985
+			'google-charts',
1986
+			'https://www.gstatic.com/charts/loader.js',
1987
+			array(),
1988
+			EVENT_ESPRESSO_VERSION
1989
+		);
1990
+		// ENQUEUE ALL BASICS BY DEFAULT
1991
+		wp_enqueue_style('ee-admin-css');
1992
+		wp_enqueue_script('ee_admin_js');
1993
+		wp_enqueue_script('ee-accounting');
1994
+		wp_enqueue_script('jquery-validate');
1995
+		// taking care of metaboxes
1996
+		if (empty($this->_cpt_route)
1997
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1998
+		) {
1999
+			wp_enqueue_script('dashboard');
2000
+		}
2001
+		// LOCALIZED DATA
2002
+		// localize script for ajax lazy loading
2003
+		$lazy_loader_container_ids = apply_filters(
2004
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2005
+			array('espresso_news_post_box_content')
2006
+		);
2007
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2008
+		/**
2009
+		 * help tour stuff
2010
+		 */
2011
+		if (! empty($this->_help_tour)) {
2012
+			// register the js for kicking things off
2013
+			wp_enqueue_script(
2014
+				'ee-help-tour',
2015
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
2016
+				array('jquery-joyride'),
2017
+				EVENT_ESPRESSO_VERSION,
2018
+				true
2019
+			);
2020
+			$tours = array();
2021
+			// setup tours for the js tour object
2022
+			foreach ($this->_help_tour['tours'] as $tour) {
2023
+				if ($tour instanceof EE_Help_Tour) {
2024
+					$tours[] = array(
2025
+						'id'      => $tour->get_slug(),
2026
+						'options' => $tour->get_options(),
2027
+					);
2028
+				}
2029
+			}
2030
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2031
+			// admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2032
+		}
2033
+	}
2034
+
2035
+
2036
+	/**
2037
+	 *        admin_footer_scripts_eei18n_js_strings
2038
+	 *
2039
+	 * @return        void
2040
+	 */
2041
+	public function admin_footer_scripts_eei18n_js_strings()
2042
+	{
2043
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2044
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2045
+			'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2046
+			'event_espresso'
2047
+		);
2048
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2049
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2050
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2051
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2052
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2053
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2054
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2055
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2056
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2057
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2058
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2059
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2060
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2061
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2062
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2063
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2064
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2065
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2066
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2067
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2068
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2069
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2070
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2071
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2072
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2073
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2074
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2075
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2076
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2077
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2078
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2079
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2080
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2081
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2082
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2083
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2084
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2085
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2086
+	}
2087
+
2088
+
2089
+	/**
2090
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2091
+	 *
2092
+	 * @return        void
2093
+	 */
2094
+	public function add_xdebug_style()
2095
+	{
2096
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2097
+	}
2098
+
2099
+
2100
+	/************************/
2101
+	/** LIST TABLE METHODS **/
2102
+	/************************/
2103
+	/**
2104
+	 * this sets up the list table if the current view requires it.
2105
+	 *
2106
+	 * @return void
2107
+	 * @throws EE_Error
2108
+	 * @throws InvalidArgumentException
2109
+	 * @throws InvalidDataTypeException
2110
+	 * @throws InvalidInterfaceException
2111
+	 */
2112
+	protected function _set_list_table()
2113
+	{
2114
+		// first is this a list_table view?
2115
+		if (! isset($this->_route_config['list_table'])) {
2116
+			return;
2117
+		} //not a list_table view so get out.
2118
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2119
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2120
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2121
+			// user error msg
2122
+			$error_msg = esc_html__(
2123
+				'An error occurred. The requested list table views could not be found.',
2124
+				'event_espresso'
2125
+			);
2126
+			// developer error msg
2127
+			$error_msg .= '||'
2128
+						  . sprintf(
2129
+							  esc_html__(
2130
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2131
+								  'event_espresso'
2132
+							  ),
2133
+							  $this->_req_action,
2134
+							  $list_table_view
2135
+						  );
2136
+			throw new EE_Error($error_msg);
2137
+		}
2138
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2139
+		$this->_views = apply_filters(
2140
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2141
+			$this->_views
2142
+		);
2143
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2144
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2145
+		$this->_set_list_table_view();
2146
+		$this->_set_list_table_object();
2147
+	}
2148
+
2149
+
2150
+	/**
2151
+	 * set current view for List Table
2152
+	 *
2153
+	 * @return void
2154
+	 */
2155
+	protected function _set_list_table_view()
2156
+	{
2157
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2158
+		// looking at active items or dumpster diving ?
2159
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2160
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2161
+		} else {
2162
+			$this->_view = sanitize_key($this->_req_data['status']);
2163
+		}
2164
+	}
2165
+
2166
+
2167
+	/**
2168
+	 * _set_list_table_object
2169
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2170
+	 *
2171
+	 * @throws InvalidInterfaceException
2172
+	 * @throws InvalidArgumentException
2173
+	 * @throws InvalidDataTypeException
2174
+	 * @throws EE_Error
2175
+	 * @throws InvalidInterfaceException
2176
+	 */
2177
+	protected function _set_list_table_object()
2178
+	{
2179
+		if (isset($this->_route_config['list_table'])) {
2180
+			if (! class_exists($this->_route_config['list_table'])) {
2181
+				throw new EE_Error(
2182
+					sprintf(
2183
+						esc_html__(
2184
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2185
+							'event_espresso'
2186
+						),
2187
+						$this->_route_config['list_table'],
2188
+						get_class($this)
2189
+					)
2190
+				);
2191
+			}
2192
+			$this->_list_table_object = $this->loader->getShared(
2193
+				$this->_route_config['list_table'],
2194
+				array($this)
2195
+			);
2196
+		}
2197
+	}
2198
+
2199
+
2200
+	/**
2201
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2202
+	 *
2203
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2204
+	 *                                                    urls.  The array should be indexed by the view it is being
2205
+	 *                                                    added to.
2206
+	 * @return array
2207
+	 */
2208
+	public function get_list_table_view_RLs($extra_query_args = array())
2209
+	{
2210
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2211
+		if (empty($this->_views)) {
2212
+			$this->_views = array();
2213
+		}
2214
+		// cycle thru views
2215
+		foreach ($this->_views as $key => $view) {
2216
+			$query_args = array();
2217
+			// check for current view
2218
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2219
+			$query_args['action'] = $this->_req_action;
2220
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2221
+			$query_args['status'] = $view['slug'];
2222
+			// merge any other arguments sent in.
2223
+			if (isset($extra_query_args[ $view['slug'] ])) {
2224
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2225
+					$query_args[] = $extra_query_arg;
2226
+				}
2227
+			}
2228
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2229
+		}
2230
+		return $this->_views;
2231
+	}
2232
+
2233
+
2234
+	/**
2235
+	 * _entries_per_page_dropdown
2236
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2237
+	 *
2238
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2239
+	 *         WP does it.
2240
+	 * @param int $max_entries total number of rows in the table
2241
+	 * @return string
2242
+	 */
2243
+	protected function _entries_per_page_dropdown($max_entries = 0)
2244
+	{
2245
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2246
+		$values = array(10, 25, 50, 100);
2247
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2248
+		if ($max_entries) {
2249
+			$values[] = $max_entries;
2250
+			sort($values);
2251
+		}
2252
+		$entries_per_page_dropdown = '
2253 2253
 			<div id="entries-per-page-dv" class="alignleft actions">
2254 2254
 				<label class="hide-if-no-js">
2255 2255
 					Show
2256 2256
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2257
-        foreach ($values as $value) {
2258
-            if ($value < $max_entries) {
2259
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2260
-                $entries_per_page_dropdown .= '
2257
+		foreach ($values as $value) {
2258
+			if ($value < $max_entries) {
2259
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2260
+				$entries_per_page_dropdown .= '
2261 2261
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2262
-            }
2263
-        }
2264
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2265
-        $entries_per_page_dropdown .= '
2262
+			}
2263
+		}
2264
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2265
+		$entries_per_page_dropdown .= '
2266 2266
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2267
-        $entries_per_page_dropdown .= '
2267
+		$entries_per_page_dropdown .= '
2268 2268
 					</select>
2269 2269
 					entries
2270 2270
 				</label>
2271 2271
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2272 2272
 			</div>
2273 2273
 		';
2274
-        return $entries_per_page_dropdown;
2275
-    }
2276
-
2277
-
2278
-    /**
2279
-     *        _set_search_attributes
2280
-     *
2281
-     * @return        void
2282
-     */
2283
-    public function _set_search_attributes()
2284
-    {
2285
-        $this->_template_args['search']['btn_label'] = sprintf(
2286
-            esc_html__('Search %s', 'event_espresso'),
2287
-            empty($this->_search_btn_label) ? $this->page_label
2288
-                : $this->_search_btn_label
2289
-        );
2290
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2291
-    }
2292
-
2293
-
2294
-
2295
-    /*** END LIST TABLE METHODS **/
2296
-
2297
-
2298
-    /**
2299
-     * _add_registered_metaboxes
2300
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2301
-     *
2302
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2303
-     * @return void
2304
-     * @throws EE_Error
2305
-     */
2306
-    private function _add_registered_meta_boxes()
2307
-    {
2308
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2309
-        // we only add meta boxes if the page_route calls for it
2310
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2311
-            && is_array(
2312
-                $this->_route_config['metaboxes']
2313
-            )
2314
-        ) {
2315
-            // this simply loops through the callbacks provided
2316
-            // and checks if there is a corresponding callback registered by the child
2317
-            // if there is then we go ahead and process the metabox loader.
2318
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2319
-                // first check for Closures
2320
-                if ($metabox_callback instanceof Closure) {
2321
-                    $result = $metabox_callback();
2322
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2323
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2324
-                } else {
2325
-                    $result = $this->{$metabox_callback}();
2326
-                }
2327
-                if ($result === false) {
2328
-                    // user error msg
2329
-                    $error_msg = esc_html__(
2330
-                        'An error occurred. The  requested metabox could not be found.',
2331
-                        'event_espresso'
2332
-                    );
2333
-                    // developer error msg
2334
-                    $error_msg .= '||'
2335
-                                  . sprintf(
2336
-                                      esc_html__(
2337
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2338
-                                          'event_espresso'
2339
-                                      ),
2340
-                                      $metabox_callback
2341
-                                  );
2342
-                    throw new EE_Error($error_msg);
2343
-                }
2344
-            }
2345
-        }
2346
-    }
2347
-
2348
-
2349
-    /**
2350
-     * _add_screen_columns
2351
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2352
-     * the dynamic column template and we'll setup the column options for the page.
2353
-     *
2354
-     * @return void
2355
-     */
2356
-    private function _add_screen_columns()
2357
-    {
2358
-        if (is_array($this->_route_config)
2359
-            && isset($this->_route_config['columns'])
2360
-            && is_array($this->_route_config['columns'])
2361
-            && count($this->_route_config['columns']) === 2
2362
-        ) {
2363
-            add_screen_option(
2364
-                'layout_columns',
2365
-                array(
2366
-                    'max'     => (int) $this->_route_config['columns'][0],
2367
-                    'default' => (int) $this->_route_config['columns'][1],
2368
-                )
2369
-            );
2370
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2371
-            $screen_id = $this->_current_screen->id;
2372
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2373
-            $total_columns = ! empty($screen_columns)
2374
-                ? $screen_columns
2375
-                : $this->_route_config['columns'][1];
2376
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2377
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2378
-            $this->_template_args['screen'] = $this->_current_screen;
2379
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2380
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2381
-            // finally if we don't have has_metaboxes set in the route config
2382
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2383
-            $this->_route_config['has_metaboxes'] = true;
2384
-        }
2385
-    }
2386
-
2387
-
2388
-
2389
-    /** GLOBALLY AVAILABLE METABOXES **/
2390
-
2391
-
2392
-    /**
2393
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2394
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2395
-     * these get loaded on.
2396
-     */
2397
-    private function _espresso_news_post_box()
2398
-    {
2399
-        $news_box_title = apply_filters(
2400
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2401
-            esc_html__('New @ Event Espresso', 'event_espresso')
2402
-        );
2403
-        add_meta_box(
2404
-            'espresso_news_post_box',
2405
-            $news_box_title,
2406
-            array(
2407
-                $this,
2408
-                'espresso_news_post_box',
2409
-            ),
2410
-            $this->_wp_page_slug,
2411
-            'side'
2412
-        );
2413
-    }
2414
-
2415
-
2416
-    /**
2417
-     * Code for setting up espresso ratings request metabox.
2418
-     */
2419
-    protected function _espresso_ratings_request()
2420
-    {
2421
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2422
-            return;
2423
-        }
2424
-        $ratings_box_title = apply_filters(
2425
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2426
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2427
-        );
2428
-        add_meta_box(
2429
-            'espresso_ratings_request',
2430
-            $ratings_box_title,
2431
-            array(
2432
-                $this,
2433
-                'espresso_ratings_request',
2434
-            ),
2435
-            $this->_wp_page_slug,
2436
-            'side'
2437
-        );
2438
-    }
2439
-
2440
-
2441
-    /**
2442
-     * Code for setting up espresso ratings request metabox content.
2443
-     *
2444
-     * @throws DomainException
2445
-     */
2446
-    public function espresso_ratings_request()
2447
-    {
2448
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2449
-    }
2450
-
2451
-
2452
-    public static function cached_rss_display($rss_id, $url)
2453
-    {
2454
-        $loading = '<p class="widget-loading hide-if-no-js">'
2455
-                   . __('Loading&#8230;', 'event_espresso')
2456
-                   . '</p><p class="hide-if-js">'
2457
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2458
-                   . '</p>';
2459
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2460
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2461
-        $post = '</div>' . "\n";
2462
-        $cache_key = 'ee_rss_' . md5($rss_id);
2463
-        $output = get_transient($cache_key);
2464
-        if ($output !== false) {
2465
-            echo $pre . $output . $post;
2466
-            return true;
2467
-        }
2468
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2469
-            echo $pre . $loading . $post;
2470
-            return false;
2471
-        }
2472
-        ob_start();
2473
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2474
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2475
-        return true;
2476
-    }
2477
-
2478
-
2479
-    public function espresso_news_post_box()
2480
-    {
2481
-        ?>
2274
+		return $entries_per_page_dropdown;
2275
+	}
2276
+
2277
+
2278
+	/**
2279
+	 *        _set_search_attributes
2280
+	 *
2281
+	 * @return        void
2282
+	 */
2283
+	public function _set_search_attributes()
2284
+	{
2285
+		$this->_template_args['search']['btn_label'] = sprintf(
2286
+			esc_html__('Search %s', 'event_espresso'),
2287
+			empty($this->_search_btn_label) ? $this->page_label
2288
+				: $this->_search_btn_label
2289
+		);
2290
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2291
+	}
2292
+
2293
+
2294
+
2295
+	/*** END LIST TABLE METHODS **/
2296
+
2297
+
2298
+	/**
2299
+	 * _add_registered_metaboxes
2300
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2301
+	 *
2302
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2303
+	 * @return void
2304
+	 * @throws EE_Error
2305
+	 */
2306
+	private function _add_registered_meta_boxes()
2307
+	{
2308
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2309
+		// we only add meta boxes if the page_route calls for it
2310
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2311
+			&& is_array(
2312
+				$this->_route_config['metaboxes']
2313
+			)
2314
+		) {
2315
+			// this simply loops through the callbacks provided
2316
+			// and checks if there is a corresponding callback registered by the child
2317
+			// if there is then we go ahead and process the metabox loader.
2318
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2319
+				// first check for Closures
2320
+				if ($metabox_callback instanceof Closure) {
2321
+					$result = $metabox_callback();
2322
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2323
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2324
+				} else {
2325
+					$result = $this->{$metabox_callback}();
2326
+				}
2327
+				if ($result === false) {
2328
+					// user error msg
2329
+					$error_msg = esc_html__(
2330
+						'An error occurred. The  requested metabox could not be found.',
2331
+						'event_espresso'
2332
+					);
2333
+					// developer error msg
2334
+					$error_msg .= '||'
2335
+								  . sprintf(
2336
+									  esc_html__(
2337
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2338
+										  'event_espresso'
2339
+									  ),
2340
+									  $metabox_callback
2341
+								  );
2342
+					throw new EE_Error($error_msg);
2343
+				}
2344
+			}
2345
+		}
2346
+	}
2347
+
2348
+
2349
+	/**
2350
+	 * _add_screen_columns
2351
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2352
+	 * the dynamic column template and we'll setup the column options for the page.
2353
+	 *
2354
+	 * @return void
2355
+	 */
2356
+	private function _add_screen_columns()
2357
+	{
2358
+		if (is_array($this->_route_config)
2359
+			&& isset($this->_route_config['columns'])
2360
+			&& is_array($this->_route_config['columns'])
2361
+			&& count($this->_route_config['columns']) === 2
2362
+		) {
2363
+			add_screen_option(
2364
+				'layout_columns',
2365
+				array(
2366
+					'max'     => (int) $this->_route_config['columns'][0],
2367
+					'default' => (int) $this->_route_config['columns'][1],
2368
+				)
2369
+			);
2370
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2371
+			$screen_id = $this->_current_screen->id;
2372
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2373
+			$total_columns = ! empty($screen_columns)
2374
+				? $screen_columns
2375
+				: $this->_route_config['columns'][1];
2376
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2377
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2378
+			$this->_template_args['screen'] = $this->_current_screen;
2379
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2380
+										   . 'admin_details_metabox_column_wrapper.template.php';
2381
+			// finally if we don't have has_metaboxes set in the route config
2382
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2383
+			$this->_route_config['has_metaboxes'] = true;
2384
+		}
2385
+	}
2386
+
2387
+
2388
+
2389
+	/** GLOBALLY AVAILABLE METABOXES **/
2390
+
2391
+
2392
+	/**
2393
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2394
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2395
+	 * these get loaded on.
2396
+	 */
2397
+	private function _espresso_news_post_box()
2398
+	{
2399
+		$news_box_title = apply_filters(
2400
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2401
+			esc_html__('New @ Event Espresso', 'event_espresso')
2402
+		);
2403
+		add_meta_box(
2404
+			'espresso_news_post_box',
2405
+			$news_box_title,
2406
+			array(
2407
+				$this,
2408
+				'espresso_news_post_box',
2409
+			),
2410
+			$this->_wp_page_slug,
2411
+			'side'
2412
+		);
2413
+	}
2414
+
2415
+
2416
+	/**
2417
+	 * Code for setting up espresso ratings request metabox.
2418
+	 */
2419
+	protected function _espresso_ratings_request()
2420
+	{
2421
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2422
+			return;
2423
+		}
2424
+		$ratings_box_title = apply_filters(
2425
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2426
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2427
+		);
2428
+		add_meta_box(
2429
+			'espresso_ratings_request',
2430
+			$ratings_box_title,
2431
+			array(
2432
+				$this,
2433
+				'espresso_ratings_request',
2434
+			),
2435
+			$this->_wp_page_slug,
2436
+			'side'
2437
+		);
2438
+	}
2439
+
2440
+
2441
+	/**
2442
+	 * Code for setting up espresso ratings request metabox content.
2443
+	 *
2444
+	 * @throws DomainException
2445
+	 */
2446
+	public function espresso_ratings_request()
2447
+	{
2448
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2449
+	}
2450
+
2451
+
2452
+	public static function cached_rss_display($rss_id, $url)
2453
+	{
2454
+		$loading = '<p class="widget-loading hide-if-no-js">'
2455
+				   . __('Loading&#8230;', 'event_espresso')
2456
+				   . '</p><p class="hide-if-js">'
2457
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2458
+				   . '</p>';
2459
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2460
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2461
+		$post = '</div>' . "\n";
2462
+		$cache_key = 'ee_rss_' . md5($rss_id);
2463
+		$output = get_transient($cache_key);
2464
+		if ($output !== false) {
2465
+			echo $pre . $output . $post;
2466
+			return true;
2467
+		}
2468
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2469
+			echo $pre . $loading . $post;
2470
+			return false;
2471
+		}
2472
+		ob_start();
2473
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2474
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2475
+		return true;
2476
+	}
2477
+
2478
+
2479
+	public function espresso_news_post_box()
2480
+	{
2481
+		?>
2482 2482
         <div class="padding">
2483 2483
             <div id="espresso_news_post_box_content" class="infolinks">
2484 2484
                 <?php
2485
-                // Get RSS Feed(s)
2486
-                self::cached_rss_display(
2487
-                    'espresso_news_post_box_content',
2488
-                    urlencode(
2489
-                        apply_filters(
2490
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2491
-                            'http://eventespresso.com/feed/'
2492
-                        )
2493
-                    )
2494
-                );
2495
-                ?>
2485
+				// Get RSS Feed(s)
2486
+				self::cached_rss_display(
2487
+					'espresso_news_post_box_content',
2488
+					urlencode(
2489
+						apply_filters(
2490
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2491
+							'http://eventespresso.com/feed/'
2492
+						)
2493
+					)
2494
+				);
2495
+				?>
2496 2496
             </div>
2497 2497
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2498 2498
         </div>
2499 2499
         <?php
2500
-    }
2501
-
2502
-
2503
-    private function _espresso_links_post_box()
2504
-    {
2505
-        // Hiding until we actually have content to put in here...
2506
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2507
-    }
2508
-
2509
-
2510
-    public function espresso_links_post_box()
2511
-    {
2512
-        // Hiding until we actually have content to put in here...
2513
-        // EEH_Template::display_template(
2514
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2515
-        // );
2516
-    }
2517
-
2518
-
2519
-    protected function _espresso_sponsors_post_box()
2520
-    {
2521
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2522
-            add_meta_box(
2523
-                'espresso_sponsors_post_box',
2524
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2525
-                array($this, 'espresso_sponsors_post_box'),
2526
-                $this->_wp_page_slug,
2527
-                'side'
2528
-            );
2529
-        }
2530
-    }
2531
-
2532
-
2533
-    public function espresso_sponsors_post_box()
2534
-    {
2535
-        EEH_Template::display_template(
2536
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2537
-        );
2538
-    }
2539
-
2540
-
2541
-    private function _publish_post_box()
2542
-    {
2543
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2544
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2545
-        // then we'll use that for the metabox label.
2546
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2547
-        if (! empty($this->_labels['publishbox'])) {
2548
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2549
-                : $this->_labels['publishbox'];
2550
-        } else {
2551
-            $box_label = esc_html__('Publish', 'event_espresso');
2552
-        }
2553
-        $box_label = apply_filters(
2554
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2555
-            $box_label,
2556
-            $this->_req_action,
2557
-            $this
2558
-        );
2559
-        add_meta_box(
2560
-            $meta_box_ref,
2561
-            $box_label,
2562
-            array($this, 'editor_overview'),
2563
-            $this->_current_screen->id,
2564
-            'side',
2565
-            'high'
2566
-        );
2567
-    }
2568
-
2569
-
2570
-    public function editor_overview()
2571
-    {
2572
-        // if we have extra content set let's add it in if not make sure its empty
2573
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2574
-            ? $this->_template_args['publish_box_extra_content']
2575
-            : '';
2576
-        echo EEH_Template::display_template(
2577
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2578
-            $this->_template_args,
2579
-            true
2580
-        );
2581
-    }
2582
-
2583
-
2584
-    /** end of globally available metaboxes section **/
2585
-
2586
-
2587
-    /**
2588
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2589
-     * protected method.
2590
-     *
2591
-     * @see   $this->_set_publish_post_box_vars for param details
2592
-     * @since 4.6.0
2593
-     * @param string $name
2594
-     * @param int    $id
2595
-     * @param bool   $delete
2596
-     * @param string $save_close_redirect_URL
2597
-     * @param bool   $both_btns
2598
-     * @throws EE_Error
2599
-     * @throws InvalidArgumentException
2600
-     * @throws InvalidDataTypeException
2601
-     * @throws InvalidInterfaceException
2602
-     */
2603
-    public function set_publish_post_box_vars(
2604
-        $name = '',
2605
-        $id = 0,
2606
-        $delete = false,
2607
-        $save_close_redirect_URL = '',
2608
-        $both_btns = true
2609
-    ) {
2610
-        $this->_set_publish_post_box_vars(
2611
-            $name,
2612
-            $id,
2613
-            $delete,
2614
-            $save_close_redirect_URL,
2615
-            $both_btns
2616
-        );
2617
-    }
2618
-
2619
-
2620
-    /**
2621
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2622
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2623
-     * save, and save and close buttons to work properly, then you will want to include a
2624
-     * values for the name and id arguments.
2625
-     *
2626
-     * @todo  Add in validation for name/id arguments.
2627
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2628
-     * @param    int     $id                      id attached to the item published
2629
-     * @param    string  $delete                  page route callback for the delete action
2630
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2631
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2632
-     *                                            the Save button
2633
-     * @throws EE_Error
2634
-     * @throws InvalidArgumentException
2635
-     * @throws InvalidDataTypeException
2636
-     * @throws InvalidInterfaceException
2637
-     */
2638
-    protected function _set_publish_post_box_vars(
2639
-        $name = '',
2640
-        $id = 0,
2641
-        $delete = '',
2642
-        $save_close_redirect_URL = '',
2643
-        $both_btns = true
2644
-    ) {
2645
-        // if Save & Close, use a custom redirect URL or default to the main page?
2646
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2647
-            ? $save_close_redirect_URL
2648
-            : $this->_admin_base_url;
2649
-        // create the Save & Close and Save buttons
2650
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2651
-        // if we have extra content set let's add it in if not make sure its empty
2652
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2653
-            ? $this->_template_args['publish_box_extra_content']
2654
-            : '';
2655
-        if ($delete && ! empty($id)) {
2656
-            // make sure we have a default if just true is sent.
2657
-            $delete = ! empty($delete) ? $delete : 'delete';
2658
-            $delete_link_args = array($name => $id);
2659
-            $delete = $this->get_action_link_or_button(
2660
-                $delete,
2661
-                $delete,
2662
-                $delete_link_args,
2663
-                'submitdelete deletion'
2664
-            );
2665
-        }
2666
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2667
-        if (! empty($name) && ! empty($id)) {
2668
-            $hidden_field_arr[ $name ] = array(
2669
-                'type'  => 'hidden',
2670
-                'value' => $id,
2671
-            );
2672
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2673
-        } else {
2674
-            $hf = '';
2675
-        }
2676
-        // add hidden field
2677
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2678
-            ? $hf[ $name ]['field']
2679
-            : $hf;
2680
-    }
2681
-
2682
-
2683
-    /**
2684
-     * displays an error message to ppl who have javascript disabled
2685
-     *
2686
-     * @return void
2687
-     */
2688
-    private function _display_no_javascript_warning()
2689
-    {
2690
-        ?>
2500
+	}
2501
+
2502
+
2503
+	private function _espresso_links_post_box()
2504
+	{
2505
+		// Hiding until we actually have content to put in here...
2506
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2507
+	}
2508
+
2509
+
2510
+	public function espresso_links_post_box()
2511
+	{
2512
+		// Hiding until we actually have content to put in here...
2513
+		// EEH_Template::display_template(
2514
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2515
+		// );
2516
+	}
2517
+
2518
+
2519
+	protected function _espresso_sponsors_post_box()
2520
+	{
2521
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2522
+			add_meta_box(
2523
+				'espresso_sponsors_post_box',
2524
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2525
+				array($this, 'espresso_sponsors_post_box'),
2526
+				$this->_wp_page_slug,
2527
+				'side'
2528
+			);
2529
+		}
2530
+	}
2531
+
2532
+
2533
+	public function espresso_sponsors_post_box()
2534
+	{
2535
+		EEH_Template::display_template(
2536
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2537
+		);
2538
+	}
2539
+
2540
+
2541
+	private function _publish_post_box()
2542
+	{
2543
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2544
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2545
+		// then we'll use that for the metabox label.
2546
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2547
+		if (! empty($this->_labels['publishbox'])) {
2548
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2549
+				: $this->_labels['publishbox'];
2550
+		} else {
2551
+			$box_label = esc_html__('Publish', 'event_espresso');
2552
+		}
2553
+		$box_label = apply_filters(
2554
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2555
+			$box_label,
2556
+			$this->_req_action,
2557
+			$this
2558
+		);
2559
+		add_meta_box(
2560
+			$meta_box_ref,
2561
+			$box_label,
2562
+			array($this, 'editor_overview'),
2563
+			$this->_current_screen->id,
2564
+			'side',
2565
+			'high'
2566
+		);
2567
+	}
2568
+
2569
+
2570
+	public function editor_overview()
2571
+	{
2572
+		// if we have extra content set let's add it in if not make sure its empty
2573
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2574
+			? $this->_template_args['publish_box_extra_content']
2575
+			: '';
2576
+		echo EEH_Template::display_template(
2577
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2578
+			$this->_template_args,
2579
+			true
2580
+		);
2581
+	}
2582
+
2583
+
2584
+	/** end of globally available metaboxes section **/
2585
+
2586
+
2587
+	/**
2588
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2589
+	 * protected method.
2590
+	 *
2591
+	 * @see   $this->_set_publish_post_box_vars for param details
2592
+	 * @since 4.6.0
2593
+	 * @param string $name
2594
+	 * @param int    $id
2595
+	 * @param bool   $delete
2596
+	 * @param string $save_close_redirect_URL
2597
+	 * @param bool   $both_btns
2598
+	 * @throws EE_Error
2599
+	 * @throws InvalidArgumentException
2600
+	 * @throws InvalidDataTypeException
2601
+	 * @throws InvalidInterfaceException
2602
+	 */
2603
+	public function set_publish_post_box_vars(
2604
+		$name = '',
2605
+		$id = 0,
2606
+		$delete = false,
2607
+		$save_close_redirect_URL = '',
2608
+		$both_btns = true
2609
+	) {
2610
+		$this->_set_publish_post_box_vars(
2611
+			$name,
2612
+			$id,
2613
+			$delete,
2614
+			$save_close_redirect_URL,
2615
+			$both_btns
2616
+		);
2617
+	}
2618
+
2619
+
2620
+	/**
2621
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2622
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2623
+	 * save, and save and close buttons to work properly, then you will want to include a
2624
+	 * values for the name and id arguments.
2625
+	 *
2626
+	 * @todo  Add in validation for name/id arguments.
2627
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2628
+	 * @param    int     $id                      id attached to the item published
2629
+	 * @param    string  $delete                  page route callback for the delete action
2630
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2631
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2632
+	 *                                            the Save button
2633
+	 * @throws EE_Error
2634
+	 * @throws InvalidArgumentException
2635
+	 * @throws InvalidDataTypeException
2636
+	 * @throws InvalidInterfaceException
2637
+	 */
2638
+	protected function _set_publish_post_box_vars(
2639
+		$name = '',
2640
+		$id = 0,
2641
+		$delete = '',
2642
+		$save_close_redirect_URL = '',
2643
+		$both_btns = true
2644
+	) {
2645
+		// if Save & Close, use a custom redirect URL or default to the main page?
2646
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2647
+			? $save_close_redirect_URL
2648
+			: $this->_admin_base_url;
2649
+		// create the Save & Close and Save buttons
2650
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2651
+		// if we have extra content set let's add it in if not make sure its empty
2652
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2653
+			? $this->_template_args['publish_box_extra_content']
2654
+			: '';
2655
+		if ($delete && ! empty($id)) {
2656
+			// make sure we have a default if just true is sent.
2657
+			$delete = ! empty($delete) ? $delete : 'delete';
2658
+			$delete_link_args = array($name => $id);
2659
+			$delete = $this->get_action_link_or_button(
2660
+				$delete,
2661
+				$delete,
2662
+				$delete_link_args,
2663
+				'submitdelete deletion'
2664
+			);
2665
+		}
2666
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2667
+		if (! empty($name) && ! empty($id)) {
2668
+			$hidden_field_arr[ $name ] = array(
2669
+				'type'  => 'hidden',
2670
+				'value' => $id,
2671
+			);
2672
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2673
+		} else {
2674
+			$hf = '';
2675
+		}
2676
+		// add hidden field
2677
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2678
+			? $hf[ $name ]['field']
2679
+			: $hf;
2680
+	}
2681
+
2682
+
2683
+	/**
2684
+	 * displays an error message to ppl who have javascript disabled
2685
+	 *
2686
+	 * @return void
2687
+	 */
2688
+	private function _display_no_javascript_warning()
2689
+	{
2690
+		?>
2691 2691
         <noscript>
2692 2692
             <div id="no-js-message" class="error">
2693 2693
                 <p style="font-size:1.3em;">
2694 2694
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2695 2695
                     <?php esc_html_e(
2696
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2697
-                        'event_espresso'
2698
-                    ); ?>
2696
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2697
+						'event_espresso'
2698
+					); ?>
2699 2699
                 </p>
2700 2700
             </div>
2701 2701
         </noscript>
2702 2702
         <?php
2703
-    }
2704
-
2705
-
2706
-    /**
2707
-     * displays espresso success and/or error notices
2708
-     *
2709
-     * @return void
2710
-     */
2711
-    private function _display_espresso_notices()
2712
-    {
2713
-        $notices = $this->_get_transient(true);
2714
-        echo stripslashes($notices);
2715
-    }
2716
-
2717
-
2718
-    /**
2719
-     * spinny things pacify the masses
2720
-     *
2721
-     * @return void
2722
-     */
2723
-    protected function _add_admin_page_ajax_loading_img()
2724
-    {
2725
-        ?>
2703
+	}
2704
+
2705
+
2706
+	/**
2707
+	 * displays espresso success and/or error notices
2708
+	 *
2709
+	 * @return void
2710
+	 */
2711
+	private function _display_espresso_notices()
2712
+	{
2713
+		$notices = $this->_get_transient(true);
2714
+		echo stripslashes($notices);
2715
+	}
2716
+
2717
+
2718
+	/**
2719
+	 * spinny things pacify the masses
2720
+	 *
2721
+	 * @return void
2722
+	 */
2723
+	protected function _add_admin_page_ajax_loading_img()
2724
+	{
2725
+		?>
2726 2726
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2727 2727
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2728
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2728
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2729 2729
         </div>
2730 2730
         <?php
2731
-    }
2731
+	}
2732 2732
 
2733 2733
 
2734
-    /**
2735
-     * add admin page overlay for modal boxes
2736
-     *
2737
-     * @return void
2738
-     */
2739
-    protected function _add_admin_page_overlay()
2740
-    {
2741
-        ?>
2734
+	/**
2735
+	 * add admin page overlay for modal boxes
2736
+	 *
2737
+	 * @return void
2738
+	 */
2739
+	protected function _add_admin_page_overlay()
2740
+	{
2741
+		?>
2742 2742
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2743 2743
         <?php
2744
-    }
2745
-
2746
-
2747
-    /**
2748
-     * facade for add_meta_box
2749
-     *
2750
-     * @param string  $action        where the metabox get's displayed
2751
-     * @param string  $title         Title of Metabox (output in metabox header)
2752
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2753
-     *                               instead of the one created in here.
2754
-     * @param array   $callback_args an array of args supplied for the metabox
2755
-     * @param string  $column        what metabox column
2756
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2757
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2758
-     *                               created but just set our own callback for wp's add_meta_box.
2759
-     * @throws DomainException
2760
-     */
2761
-    public function _add_admin_page_meta_box(
2762
-        $action,
2763
-        $title,
2764
-        $callback,
2765
-        $callback_args,
2766
-        $column = 'normal',
2767
-        $priority = 'high',
2768
-        $create_func = true
2769
-    ) {
2770
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2771
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2772
-        if (empty($callback_args) && $create_func) {
2773
-            $callback_args = array(
2774
-                'template_path' => $this->_template_path,
2775
-                'template_args' => $this->_template_args,
2776
-            );
2777
-        }
2778
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2779
-        $call_back_func = $create_func
2780
-            ? static function ($post, $metabox) {
2781
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2782
-                echo EEH_Template::display_template(
2783
-                    $metabox['args']['template_path'],
2784
-                    $metabox['args']['template_args'],
2785
-                    true
2786
-                );
2787
-            }
2788
-            : $callback;
2789
-        add_meta_box(
2790
-            str_replace('_', '-', $action) . '-mbox',
2791
-            $title,
2792
-            $call_back_func,
2793
-            $this->_wp_page_slug,
2794
-            $column,
2795
-            $priority,
2796
-            $callback_args
2797
-        );
2798
-    }
2799
-
2800
-
2801
-    /**
2802
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2803
-     *
2804
-     * @throws DomainException
2805
-     * @throws EE_Error
2806
-     * @throws InvalidArgumentException
2807
-     * @throws InvalidDataTypeException
2808
-     * @throws InvalidInterfaceException
2809
-     */
2810
-    public function display_admin_page_with_metabox_columns()
2811
-    {
2812
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2813
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2814
-            $this->_column_template_path,
2815
-            $this->_template_args,
2816
-            true
2817
-        );
2818
-        // the final wrapper
2819
-        $this->admin_page_wrapper();
2820
-    }
2821
-
2822
-
2823
-    /**
2824
-     * generates  HTML wrapper for an admin details page
2825
-     *
2826
-     * @return void
2827
-     * @throws DomainException
2828
-     * @throws EE_Error
2829
-     * @throws InvalidArgumentException
2830
-     * @throws InvalidDataTypeException
2831
-     * @throws InvalidInterfaceException
2832
-     */
2833
-    public function display_admin_page_with_sidebar()
2834
-    {
2835
-        $this->_display_admin_page(true);
2836
-    }
2837
-
2838
-
2839
-    /**
2840
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2841
-     *
2842
-     * @return void
2843
-     * @throws DomainException
2844
-     * @throws EE_Error
2845
-     * @throws InvalidArgumentException
2846
-     * @throws InvalidDataTypeException
2847
-     * @throws InvalidInterfaceException
2848
-     */
2849
-    public function display_admin_page_with_no_sidebar()
2850
-    {
2851
-        $this->_display_admin_page();
2852
-    }
2853
-
2854
-
2855
-    /**
2856
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2857
-     *
2858
-     * @return void
2859
-     * @throws DomainException
2860
-     * @throws EE_Error
2861
-     * @throws InvalidArgumentException
2862
-     * @throws InvalidDataTypeException
2863
-     * @throws InvalidInterfaceException
2864
-     */
2865
-    public function display_about_admin_page()
2866
-    {
2867
-        $this->_display_admin_page(false, true);
2868
-    }
2869
-
2870
-
2871
-    /**
2872
-     * display_admin_page
2873
-     * contains the code for actually displaying an admin page
2874
-     *
2875
-     * @param boolean $sidebar true with sidebar, false without
2876
-     * @param boolean $about   use the about admin wrapper instead of the default.
2877
-     * @return void
2878
-     * @throws DomainException
2879
-     * @throws EE_Error
2880
-     * @throws InvalidArgumentException
2881
-     * @throws InvalidDataTypeException
2882
-     * @throws InvalidInterfaceException
2883
-     */
2884
-    private function _display_admin_page($sidebar = false, $about = false)
2885
-    {
2886
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2887
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2888
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2889
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2890
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2891
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2892
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2893
-            ? 'poststuff'
2894
-            : 'espresso-default-admin';
2895
-        $template_path = $sidebar
2896
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2897
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2898
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2899
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2900
-        }
2901
-        $template_path = ! empty($this->_column_template_path)
2902
-            ? $this->_column_template_path : $template_path;
2903
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2904
-            ? $this->_template_args['admin_page_content']
2905
-            : '';
2906
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2907
-            ? $this->_template_args['before_admin_page_content']
2908
-            : '';
2909
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2910
-            ? $this->_template_args['after_admin_page_content']
2911
-            : '';
2912
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2913
-            $template_path,
2914
-            $this->_template_args,
2915
-            true
2916
-        );
2917
-        // the final template wrapper
2918
-        $this->admin_page_wrapper($about);
2919
-    }
2920
-
2921
-
2922
-    /**
2923
-     * This is used to display caf preview pages.
2924
-     *
2925
-     * @since 4.3.2
2926
-     * @param string $utm_campaign_source what is the key used for google analytics link
2927
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2928
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2929
-     * @return void
2930
-     * @throws DomainException
2931
-     * @throws EE_Error
2932
-     * @throws InvalidArgumentException
2933
-     * @throws InvalidDataTypeException
2934
-     * @throws InvalidInterfaceException
2935
-     */
2936
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2937
-    {
2938
-        // let's generate a default preview action button if there isn't one already present.
2939
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2940
-            'Upgrade to Event Espresso 4 Right Now',
2941
-            'event_espresso'
2942
-        );
2943
-        $buy_now_url = add_query_arg(
2944
-            array(
2945
-                'ee_ver'       => 'ee4',
2946
-                'utm_source'   => 'ee4_plugin_admin',
2947
-                'utm_medium'   => 'link',
2948
-                'utm_campaign' => $utm_campaign_source,
2949
-                'utm_content'  => 'buy_now_button',
2950
-            ),
2951
-            'http://eventespresso.com/pricing/'
2952
-        );
2953
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2954
-            ? $this->get_action_link_or_button(
2955
-                '',
2956
-                'buy_now',
2957
-                array(),
2958
-                'button-primary button-large',
2959
-                $buy_now_url,
2960
-                true
2961
-            )
2962
-            : $this->_template_args['preview_action_button'];
2963
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2964
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2965
-            $this->_template_args,
2966
-            true
2967
-        );
2968
-        $this->_display_admin_page($display_sidebar);
2969
-    }
2970
-
2971
-
2972
-    /**
2973
-     * display_admin_list_table_page_with_sidebar
2974
-     * generates HTML wrapper for an admin_page with list_table
2975
-     *
2976
-     * @return void
2977
-     * @throws DomainException
2978
-     * @throws EE_Error
2979
-     * @throws InvalidArgumentException
2980
-     * @throws InvalidDataTypeException
2981
-     * @throws InvalidInterfaceException
2982
-     */
2983
-    public function display_admin_list_table_page_with_sidebar()
2984
-    {
2985
-        $this->_display_admin_list_table_page(true);
2986
-    }
2987
-
2988
-
2989
-    /**
2990
-     * display_admin_list_table_page_with_no_sidebar
2991
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2992
-     *
2993
-     * @return void
2994
-     * @throws DomainException
2995
-     * @throws EE_Error
2996
-     * @throws InvalidArgumentException
2997
-     * @throws InvalidDataTypeException
2998
-     * @throws InvalidInterfaceException
2999
-     */
3000
-    public function display_admin_list_table_page_with_no_sidebar()
3001
-    {
3002
-        $this->_display_admin_list_table_page();
3003
-    }
3004
-
3005
-
3006
-    /**
3007
-     * generates html wrapper for an admin_list_table page
3008
-     *
3009
-     * @param boolean $sidebar whether to display with sidebar or not.
3010
-     * @return void
3011
-     * @throws DomainException
3012
-     * @throws EE_Error
3013
-     * @throws InvalidArgumentException
3014
-     * @throws InvalidDataTypeException
3015
-     * @throws InvalidInterfaceException
3016
-     */
3017
-    private function _display_admin_list_table_page($sidebar = false)
3018
-    {
3019
-        // setup search attributes
3020
-        $this->_set_search_attributes();
3021
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
3022
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3023
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
3024
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3025
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
3026
-        $this->_template_args['list_table'] = $this->_list_table_object;
3027
-        $this->_template_args['current_route'] = $this->_req_action;
3028
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3029
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
3030
-        if (! empty($ajax_sorting_callback)) {
3031
-            $sortable_list_table_form_fields = wp_nonce_field(
3032
-                $ajax_sorting_callback . '_nonce',
3033
-                $ajax_sorting_callback . '_nonce',
3034
-                false,
3035
-                false
3036
-            );
3037
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3038
-                                                . $this->page_slug
3039
-                                                . '" />';
3040
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3041
-                                                . $ajax_sorting_callback
3042
-                                                . '" />';
3043
-        } else {
3044
-            $sortable_list_table_form_fields = '';
3045
-        }
3046
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3047
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
3048
-            ? $this->_template_args['list_table_hidden_fields']
3049
-            : '';
3050
-        $nonce_ref = $this->_req_action . '_nonce';
3051
-        $hidden_form_fields .= '<input type="hidden" name="'
3052
-                               . $nonce_ref
3053
-                               . '" value="'
3054
-                               . wp_create_nonce($nonce_ref)
3055
-                               . '">';
3056
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3057
-        // display message about search results?
3058
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3059
-            ? '<p class="ee-search-results">' . sprintf(
3060
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3061
-                trim($this->_req_data['s'], '%')
3062
-            ) . '</p>'
3063
-            : '';
3064
-        // filter before_list_table template arg
3065
-        $this->_template_args['before_list_table'] = apply_filters(
3066
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3067
-            $this->_template_args['before_list_table'],
3068
-            $this->page_slug,
3069
-            $this->_req_data,
3070
-            $this->_req_action
3071
-        );
3072
-        // convert to array and filter again
3073
-        // arrays are easier to inject new items in a specific location,
3074
-        // but would not be backwards compatible, so we have to add a new filter
3075
-        $this->_template_args['before_list_table'] = implode(
3076
-            " \n",
3077
-            (array) apply_filters(
3078
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3079
-                (array) $this->_template_args['before_list_table'],
3080
-                $this->page_slug,
3081
-                $this->_req_data,
3082
-                $this->_req_action
3083
-            )
3084
-        );
3085
-        // filter after_list_table template arg
3086
-        $this->_template_args['after_list_table'] = apply_filters(
3087
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3088
-            $this->_template_args['after_list_table'],
3089
-            $this->page_slug,
3090
-            $this->_req_data,
3091
-            $this->_req_action
3092
-        );
3093
-        // convert to array and filter again
3094
-        // arrays are easier to inject new items in a specific location,
3095
-        // but would not be backwards compatible, so we have to add a new filter
3096
-        $this->_template_args['after_list_table'] = implode(
3097
-            " \n",
3098
-            (array) apply_filters(
3099
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3100
-                (array) $this->_template_args['after_list_table'],
3101
-                $this->page_slug,
3102
-                $this->_req_data,
3103
-                $this->_req_action
3104
-            )
3105
-        );
3106
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3107
-            $template_path,
3108
-            $this->_template_args,
3109
-            true
3110
-        );
3111
-        // the final template wrapper
3112
-        if ($sidebar) {
3113
-            $this->display_admin_page_with_sidebar();
3114
-        } else {
3115
-            $this->display_admin_page_with_no_sidebar();
3116
-        }
3117
-    }
3118
-
3119
-
3120
-    /**
3121
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3122
-     * html string for the legend.
3123
-     * $items are expected in an array in the following format:
3124
-     * $legend_items = array(
3125
-     *        'item_id' => array(
3126
-     *            'icon' => 'http://url_to_icon_being_described.png',
3127
-     *            'desc' => esc_html__('localized description of item');
3128
-     *        )
3129
-     * );
3130
-     *
3131
-     * @param  array $items see above for format of array
3132
-     * @return string html string of legend
3133
-     * @throws DomainException
3134
-     */
3135
-    protected function _display_legend($items)
3136
-    {
3137
-        $this->_template_args['items'] = apply_filters(
3138
-            'FHEE__EE_Admin_Page___display_legend__items',
3139
-            (array) $items,
3140
-            $this
3141
-        );
3142
-        return EEH_Template::display_template(
3143
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3144
-            $this->_template_args,
3145
-            true
3146
-        );
3147
-    }
3148
-
3149
-
3150
-    /**
3151
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3152
-     * The returned json object is created from an array in the following format:
3153
-     * array(
3154
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3155
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3156
-     *  'notices' => '', // - contains any EE_Error formatted notices
3157
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3158
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3159
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3160
-     *  that might be included in here)
3161
-     * )
3162
-     * The json object is populated by whatever is set in the $_template_args property.
3163
-     *
3164
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3165
-     *                                 instead of displayed.
3166
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3167
-     * @return void
3168
-     * @throws EE_Error
3169
-     * @throws InvalidArgumentException
3170
-     * @throws InvalidDataTypeException
3171
-     * @throws InvalidInterfaceException
3172
-     */
3173
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3174
-    {
3175
-        // make sure any EE_Error notices have been handled.
3176
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3177
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3178
-        unset($this->_template_args['data']);
3179
-        $json = array(
3180
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3181
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3182
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3183
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3184
-            'notices'   => EE_Error::get_notices(),
3185
-            'content'   => isset($this->_template_args['admin_page_content'])
3186
-                ? $this->_template_args['admin_page_content'] : '',
3187
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3188
-            'isEEajax'  => true
3189
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3190
-        );
3191
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3192
-        if (null === error_get_last() || ! headers_sent()) {
3193
-            header('Content-Type: application/json; charset=UTF-8');
3194
-        }
3195
-        echo wp_json_encode($json);
3196
-        exit();
3197
-    }
3198
-
3199
-
3200
-    /**
3201
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3202
-     *
3203
-     * @return void
3204
-     * @throws EE_Error
3205
-     * @throws InvalidArgumentException
3206
-     * @throws InvalidDataTypeException
3207
-     * @throws InvalidInterfaceException
3208
-     */
3209
-    public function return_json()
3210
-    {
3211
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3212
-            $this->_return_json();
3213
-        } else {
3214
-            throw new EE_Error(
3215
-                sprintf(
3216
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3217
-                    __FUNCTION__
3218
-                )
3219
-            );
3220
-        }
3221
-    }
3222
-
3223
-
3224
-    /**
3225
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3226
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3227
-     *
3228
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3229
-     */
3230
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3231
-    {
3232
-        $this->_hook_obj = $hook_obj;
3233
-    }
3234
-
3235
-
3236
-    /**
3237
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3238
-     *
3239
-     * @param boolean $about whether to use the special about page wrapper or default.
3240
-     * @return void
3241
-     * @throws DomainException
3242
-     * @throws EE_Error
3243
-     * @throws InvalidArgumentException
3244
-     * @throws InvalidDataTypeException
3245
-     * @throws InvalidInterfaceException
3246
-     */
3247
-    public function admin_page_wrapper($about = false)
3248
-    {
3249
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3250
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3251
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3252
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3253
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3254
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3255
-            isset($this->_template_args['before_admin_page_content'])
3256
-                ? $this->_template_args['before_admin_page_content']
3257
-                : ''
3258
-        );
3259
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3260
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3261
-            isset($this->_template_args['after_admin_page_content'])
3262
-                ? $this->_template_args['after_admin_page_content']
3263
-                : ''
3264
-        );
3265
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3266
-        // load settings page wrapper template
3267
-        $template_path = ! defined('DOING_AJAX')
3268
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3269
-            : EE_ADMIN_TEMPLATE
3270
-              . 'admin_wrapper_ajax.template.php';
3271
-        // about page?
3272
-        $template_path = $about
3273
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3274
-            : $template_path;
3275
-        if (defined('DOING_AJAX')) {
3276
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3277
-                $template_path,
3278
-                $this->_template_args,
3279
-                true
3280
-            );
3281
-            $this->_return_json();
3282
-        } else {
3283
-            EEH_Template::display_template($template_path, $this->_template_args);
3284
-        }
3285
-    }
3286
-
3287
-
3288
-    /**
3289
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3290
-     *
3291
-     * @return string html
3292
-     * @throws EE_Error
3293
-     */
3294
-    protected function _get_main_nav_tabs()
3295
-    {
3296
-        // let's generate the html using the EEH_Tabbed_Content helper.
3297
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3298
-        // (rather than setting in the page_routes array)
3299
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3300
-    }
3301
-
3302
-
3303
-    /**
3304
-     *        sort nav tabs
3305
-     *
3306
-     * @param $a
3307
-     * @param $b
3308
-     * @return int
3309
-     */
3310
-    private function _sort_nav_tabs($a, $b)
3311
-    {
3312
-        if ($a['order'] === $b['order']) {
3313
-            return 0;
3314
-        }
3315
-        return ($a['order'] < $b['order']) ? -1 : 1;
3316
-    }
3317
-
3318
-
3319
-    /**
3320
-     *    generates HTML for the forms used on admin pages
3321
-     *
3322
-     * @param    array $input_vars - array of input field details
3323
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3324
-     *                             use)
3325
-     * @param bool     $id
3326
-     * @return string
3327
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3328
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3329
-     */
3330
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3331
-    {
3332
-        $content = $generator === 'string'
3333
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3334
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3335
-        return $content;
3336
-    }
3337
-
3338
-
3339
-    /**
3340
-     * generates the "Save" and "Save & Close" buttons for edit forms
3341
-     *
3342
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3343
-     *                                   Close" button.
3344
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3345
-     *                                   'Save', [1] => 'save & close')
3346
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3347
-     *                                   via the "name" value in the button).  We can also use this to just dump
3348
-     *                                   default actions by submitting some other value.
3349
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3350
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3351
-     *                                   close (normal form handling).
3352
-     */
3353
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3354
-    {
3355
-        // make sure $text and $actions are in an array
3356
-        $text = (array) $text;
3357
-        $actions = (array) $actions;
3358
-        $referrer_url = empty($referrer)
3359
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3360
-              . $_SERVER['REQUEST_URI']
3361
-              . '" />'
3362
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3363
-              . $referrer
3364
-              . '" />';
3365
-        $button_text = ! empty($text)
3366
-            ? $text
3367
-            : array(
3368
-                esc_html__('Save', 'event_espresso'),
3369
-                esc_html__('Save and Close', 'event_espresso'),
3370
-            );
3371
-        $default_names = array('save', 'save_and_close');
3372
-        // add in a hidden index for the current page (so save and close redirects properly)
3373
-        $this->_template_args['save_buttons'] = $referrer_url;
3374
-        foreach ($button_text as $key => $button) {
3375
-            $ref = $default_names[ $key ];
3376
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3377
-                                                     . $ref
3378
-                                                     . '" value="'
3379
-                                                     . $button
3380
-                                                     . '" name="'
3381
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3382
-                                                     . '" id="'
3383
-                                                     . $this->_current_view . '_' . $ref
3384
-                                                     . '" />';
3385
-            if (! $both) {
3386
-                break;
3387
-            }
3388
-        }
3389
-    }
3390
-
3391
-
3392
-    /**
3393
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3394
-     *
3395
-     * @see   $this->_set_add_edit_form_tags() for details on params
3396
-     * @since 4.6.0
3397
-     * @param string $route
3398
-     * @param array  $additional_hidden_fields
3399
-     */
3400
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3401
-    {
3402
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3403
-    }
3404
-
3405
-
3406
-    /**
3407
-     * set form open and close tags on add/edit pages.
3408
-     *
3409
-     * @param string $route                    the route you want the form to direct to
3410
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3411
-     * @return void
3412
-     */
3413
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3414
-    {
3415
-        if (empty($route)) {
3416
-            $user_msg = esc_html__(
3417
-                'An error occurred. No action was set for this page\'s form.',
3418
-                'event_espresso'
3419
-            );
3420
-            $dev_msg = $user_msg . "\n"
3421
-                       . sprintf(
3422
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3423
-                           __FUNCTION__,
3424
-                           __CLASS__
3425
-                       );
3426
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3427
-        }
3428
-        // open form
3429
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3430
-                                                             . $this->_admin_base_url
3431
-                                                             . '" id="'
3432
-                                                             . $route
3433
-                                                             . '_event_form" >';
3434
-        // add nonce
3435
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3436
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3437
-        // add REQUIRED form action
3438
-        $hidden_fields = array(
3439
-            'action' => array('type' => 'hidden', 'value' => $route),
3440
-        );
3441
-        // merge arrays
3442
-        $hidden_fields = is_array($additional_hidden_fields)
3443
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3444
-            : $hidden_fields;
3445
-        // generate form fields
3446
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3447
-        // add fields to form
3448
-        foreach ((array) $form_fields as $field_name => $form_field) {
3449
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3450
-        }
3451
-        // close form
3452
-        $this->_template_args['after_admin_page_content'] = '</form>';
3453
-    }
3454
-
3455
-
3456
-    /**
3457
-     * Public Wrapper for _redirect_after_action() method since its
3458
-     * discovered it would be useful for external code to have access.
3459
-     *
3460
-     * @param bool   $success
3461
-     * @param string $what
3462
-     * @param string $action_desc
3463
-     * @param array  $query_args
3464
-     * @param bool   $override_overwrite
3465
-     * @throws EE_Error
3466
-     * @throws InvalidArgumentException
3467
-     * @throws InvalidDataTypeException
3468
-     * @throws InvalidInterfaceException
3469
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3470
-     * @since 4.5.0
3471
-     */
3472
-    public function redirect_after_action(
3473
-        $success = false,
3474
-        $what = 'item',
3475
-        $action_desc = 'processed',
3476
-        $query_args = array(),
3477
-        $override_overwrite = false
3478
-    ) {
3479
-        $this->_redirect_after_action(
3480
-            $success,
3481
-            $what,
3482
-            $action_desc,
3483
-            $query_args,
3484
-            $override_overwrite
3485
-        );
3486
-    }
3487
-
3488
-
3489
-    /**
3490
-     * Helper method for merging existing request data with the returned redirect url.
3491
-     *
3492
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3493
-     * filters are still applied.
3494
-     *
3495
-     * @param array $new_route_data
3496
-     * @return array
3497
-     */
3498
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3499
-    {
3500
-        foreach ($this->_req_data as $ref => $value) {
3501
-            // unset nonces
3502
-            if (strpos($ref, 'nonce') !== false) {
3503
-                unset($this->_req_data[ $ref ]);
3504
-                continue;
3505
-            }
3506
-            // urlencode values.
3507
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3508
-            $this->_req_data[ $ref ] = $value;
3509
-        }
3510
-        return array_merge($this->_req_data, $new_route_data);
3511
-    }
3512
-
3513
-
3514
-    /**
3515
-     *    _redirect_after_action
3516
-     *
3517
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3518
-     * @param string $what               - what the action was performed on
3519
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3520
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3521
-     *                                   action is completed
3522
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3523
-     *                                   override this so that they show.
3524
-     * @return void
3525
-     * @throws EE_Error
3526
-     * @throws InvalidArgumentException
3527
-     * @throws InvalidDataTypeException
3528
-     * @throws InvalidInterfaceException
3529
-     */
3530
-    protected function _redirect_after_action(
3531
-        $success = 0,
3532
-        $what = 'item',
3533
-        $action_desc = 'processed',
3534
-        $query_args = array(),
3535
-        $override_overwrite = false
3536
-    ) {
3537
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3538
-        // class name for actions/filters.
3539
-        $classname = get_class($this);
3540
-        // set redirect url.
3541
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3542
-        // otherwise we go with whatever is set as the _admin_base_url
3543
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3544
-        $notices = EE_Error::get_notices(false);
3545
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3546
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3547
-            EE_Error::overwrite_success();
3548
-        }
3549
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3550
-            // how many records affected ? more than one record ? or just one ?
3551
-            if ($success > 1) {
3552
-                // set plural msg
3553
-                EE_Error::add_success(
3554
-                    sprintf(
3555
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3556
-                        $what,
3557
-                        $action_desc
3558
-                    ),
3559
-                    __FILE__,
3560
-                    __FUNCTION__,
3561
-                    __LINE__
3562
-                );
3563
-            } elseif ($success === 1) {
3564
-                // set singular msg
3565
-                EE_Error::add_success(
3566
-                    sprintf(
3567
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3568
-                        $what,
3569
-                        $action_desc
3570
-                    ),
3571
-                    __FILE__,
3572
-                    __FUNCTION__,
3573
-                    __LINE__
3574
-                );
3575
-            }
3576
-        }
3577
-        // check that $query_args isn't something crazy
3578
-        if (! is_array($query_args)) {
3579
-            $query_args = array();
3580
-        }
3581
-        /**
3582
-         * Allow injecting actions before the query_args are modified for possible different
3583
-         * redirections on save and close actions
3584
-         *
3585
-         * @since 4.2.0
3586
-         * @param array $query_args       The original query_args array coming into the
3587
-         *                                method.
3588
-         */
3589
-        do_action(
3590
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3591
-            $query_args
3592
-        );
3593
-        // calculate where we're going (if we have a "save and close" button pushed)
3594
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3595
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3596
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3597
-            // regenerate query args array from referrer URL
3598
-            parse_str($parsed_url['query'], $query_args);
3599
-            // correct page and action will be in the query args now
3600
-            $redirect_url = admin_url('admin.php');
3601
-        }
3602
-        // merge any default query_args set in _default_route_query_args property
3603
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3604
-            $args_to_merge = array();
3605
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3606
-                // is there a wp_referer array in our _default_route_query_args property?
3607
-                if ($query_param === 'wp_referer') {
3608
-                    $query_value = (array) $query_value;
3609
-                    foreach ($query_value as $reference => $value) {
3610
-                        if (strpos($reference, 'nonce') !== false) {
3611
-                            continue;
3612
-                        }
3613
-                        // finally we will override any arguments in the referer with
3614
-                        // what might be set on the _default_route_query_args array.
3615
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3616
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3617
-                        } else {
3618
-                            $args_to_merge[ $reference ] = urlencode($value);
3619
-                        }
3620
-                    }
3621
-                    continue;
3622
-                }
3623
-                $args_to_merge[ $query_param ] = $query_value;
3624
-            }
3625
-            // now let's merge these arguments but override with what was specifically sent in to the
3626
-            // redirect.
3627
-            $query_args = array_merge($args_to_merge, $query_args);
3628
-        }
3629
-        $this->_process_notices($query_args);
3630
-        // generate redirect url
3631
-        // if redirecting to anything other than the main page, add a nonce
3632
-        if (isset($query_args['action'])) {
3633
-            // manually generate wp_nonce and merge that with the query vars
3634
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3635
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3636
-        }
3637
-        // we're adding some hooks and filters in here for processing any things just before redirects
3638
-        // (example: an admin page has done an insert or update and we want to run something after that).
3639
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3640
-        $redirect_url = apply_filters(
3641
-            'FHEE_redirect_' . $classname . $this->_req_action,
3642
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3643
-            $query_args
3644
-        );
3645
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3646
-        if (defined('DOING_AJAX')) {
3647
-            $default_data = array(
3648
-                'close'        => true,
3649
-                'redirect_url' => $redirect_url,
3650
-                'where'        => 'main',
3651
-                'what'         => 'append',
3652
-            );
3653
-            $this->_template_args['success'] = $success;
3654
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3655
-                $default_data,
3656
-                $this->_template_args['data']
3657
-            ) : $default_data;
3658
-            $this->_return_json();
3659
-        }
3660
-        wp_safe_redirect($redirect_url);
3661
-        exit();
3662
-    }
3663
-
3664
-
3665
-    /**
3666
-     * process any notices before redirecting (or returning ajax request)
3667
-     * This method sets the $this->_template_args['notices'] attribute;
3668
-     *
3669
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3670
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3671
-     *                                  page_routes haven't been defined yet.
3672
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3673
-     *                                  still save a transient for the notice.
3674
-     * @return void
3675
-     * @throws EE_Error
3676
-     * @throws InvalidArgumentException
3677
-     * @throws InvalidDataTypeException
3678
-     * @throws InvalidInterfaceException
3679
-     */
3680
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3681
-    {
3682
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3683
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3684
-            $notices = EE_Error::get_notices(false);
3685
-            if (empty($this->_template_args['success'])) {
3686
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3687
-            }
3688
-            if (empty($this->_template_args['errors'])) {
3689
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3690
-            }
3691
-            if (empty($this->_template_args['attention'])) {
3692
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3693
-            }
3694
-        }
3695
-        $this->_template_args['notices'] = EE_Error::get_notices();
3696
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3697
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3698
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3699
-            $this->_add_transient(
3700
-                $route,
3701
-                $this->_template_args['notices'],
3702
-                true,
3703
-                $skip_route_verify
3704
-            );
3705
-        }
3706
-    }
3707
-
3708
-
3709
-    /**
3710
-     * get_action_link_or_button
3711
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3712
-     *
3713
-     * @param string $action        use this to indicate which action the url is generated with.
3714
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3715
-     *                              property.
3716
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3717
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3718
-     * @param string $base_url      If this is not provided
3719
-     *                              the _admin_base_url will be used as the default for the button base_url.
3720
-     *                              Otherwise this value will be used.
3721
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3722
-     * @return string
3723
-     * @throws InvalidArgumentException
3724
-     * @throws InvalidInterfaceException
3725
-     * @throws InvalidDataTypeException
3726
-     * @throws EE_Error
3727
-     */
3728
-    public function get_action_link_or_button(
3729
-        $action,
3730
-        $type = 'add',
3731
-        $extra_request = array(),
3732
-        $class = 'button-primary',
3733
-        $base_url = '',
3734
-        $exclude_nonce = false
3735
-    ) {
3736
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3737
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3738
-            throw new EE_Error(
3739
-                sprintf(
3740
-                    esc_html__(
3741
-                        'There is no page route for given action for the button.  This action was given: %s',
3742
-                        'event_espresso'
3743
-                    ),
3744
-                    $action
3745
-                )
3746
-            );
3747
-        }
3748
-        if (! isset($this->_labels['buttons'][ $type ])) {
3749
-            throw new EE_Error(
3750
-                sprintf(
3751
-                    __(
3752
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3753
-                        'event_espresso'
3754
-                    ),
3755
-                    $type
3756
-                )
3757
-            );
3758
-        }
3759
-        // finally check user access for this button.
3760
-        $has_access = $this->check_user_access($action, true);
3761
-        if (! $has_access) {
3762
-            return '';
3763
-        }
3764
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3765
-        $query_args = array(
3766
-            'action' => $action,
3767
-        );
3768
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3769
-        if (! empty($extra_request)) {
3770
-            $query_args = array_merge($extra_request, $query_args);
3771
-        }
3772
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3773
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3774
-    }
3775
-
3776
-
3777
-    /**
3778
-     * _per_page_screen_option
3779
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3780
-     *
3781
-     * @return void
3782
-     * @throws InvalidArgumentException
3783
-     * @throws InvalidInterfaceException
3784
-     * @throws InvalidDataTypeException
3785
-     */
3786
-    protected function _per_page_screen_option()
3787
-    {
3788
-        $option = 'per_page';
3789
-        $args = array(
3790
-            'label'   => apply_filters(
3791
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3792
-                $this->_admin_page_title,
3793
-                $this
3794
-            ),
3795
-            'default' => (int) apply_filters(
3796
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3797
-                20
3798
-            ),
3799
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3800
-        );
3801
-        // ONLY add the screen option if the user has access to it.
3802
-        if ($this->check_user_access($this->_current_view, true)) {
3803
-            add_screen_option($option, $args);
3804
-        }
3805
-    }
3806
-
3807
-
3808
-    /**
3809
-     * set_per_page_screen_option
3810
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3811
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3812
-     * admin_menu.
3813
-     *
3814
-     * @return void
3815
-     */
3816
-    private function _set_per_page_screen_options()
3817
-    {
3818
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3819
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3820
-            if (! $user = wp_get_current_user()) {
3821
-                return;
3822
-            }
3823
-            $option = $_POST['wp_screen_options']['option'];
3824
-            $value = $_POST['wp_screen_options']['value'];
3825
-            if ($option !== sanitize_key($option)) {
3826
-                return;
3827
-            }
3828
-            $map_option = $option;
3829
-            $option = str_replace('-', '_', $option);
3830
-            switch ($map_option) {
3831
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3832
-                    $value = (int) $value;
3833
-                    $max_value = apply_filters(
3834
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3835
-                        999,
3836
-                        $this->_current_page,
3837
-                        $this->_current_view
3838
-                    );
3839
-                    if ($value < 1) {
3840
-                        return;
3841
-                    }
3842
-                    $value = min($value, $max_value);
3843
-                    break;
3844
-                default:
3845
-                    $value = apply_filters(
3846
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3847
-                        false,
3848
-                        $option,
3849
-                        $value
3850
-                    );
3851
-                    if (false === $value) {
3852
-                        return;
3853
-                    }
3854
-                    break;
3855
-            }
3856
-            update_user_meta($user->ID, $option, $value);
3857
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3858
-            exit;
3859
-        }
3860
-    }
3861
-
3862
-
3863
-    /**
3864
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3865
-     *
3866
-     * @param array $data array that will be assigned to template args.
3867
-     */
3868
-    public function set_template_args($data)
3869
-    {
3870
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3871
-    }
3872
-
3873
-
3874
-    /**
3875
-     * This makes available the WP transient system for temporarily moving data between routes
3876
-     *
3877
-     * @param string $route             the route that should receive the transient
3878
-     * @param array  $data              the data that gets sent
3879
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3880
-     *                                  normal route transient.
3881
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3882
-     *                                  when we are adding a transient before page_routes have been defined.
3883
-     * @return void
3884
-     * @throws EE_Error
3885
-     */
3886
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3887
-    {
3888
-        $user_id = get_current_user_id();
3889
-        if (! $skip_route_verify) {
3890
-            $this->_verify_route($route);
3891
-        }
3892
-        // now let's set the string for what kind of transient we're setting
3893
-        $transient = $notices
3894
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3895
-            : 'rte_tx_' . $route . '_' . $user_id;
3896
-        $data = $notices ? array('notices' => $data) : $data;
3897
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3898
-        $existing = is_multisite() && is_network_admin()
3899
-            ? get_site_transient($transient)
3900
-            : get_transient($transient);
3901
-        if ($existing) {
3902
-            $data = array_merge((array) $data, (array) $existing);
3903
-        }
3904
-        if (is_multisite() && is_network_admin()) {
3905
-            set_site_transient($transient, $data, 8);
3906
-        } else {
3907
-            set_transient($transient, $data, 8);
3908
-        }
3909
-    }
3910
-
3911
-
3912
-    /**
3913
-     * this retrieves the temporary transient that has been set for moving data between routes.
3914
-     *
3915
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3916
-     * @param string $route
3917
-     * @return mixed data
3918
-     */
3919
-    protected function _get_transient($notices = false, $route = '')
3920
-    {
3921
-        $user_id = get_current_user_id();
3922
-        $route = ! $route ? $this->_req_action : $route;
3923
-        $transient = $notices
3924
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3925
-            : 'rte_tx_' . $route . '_' . $user_id;
3926
-        $data = is_multisite() && is_network_admin()
3927
-            ? get_site_transient($transient)
3928
-            : get_transient($transient);
3929
-        // delete transient after retrieval (just in case it hasn't expired);
3930
-        if (is_multisite() && is_network_admin()) {
3931
-            delete_site_transient($transient);
3932
-        } else {
3933
-            delete_transient($transient);
3934
-        }
3935
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3936
-    }
3937
-
3938
-
3939
-    /**
3940
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3941
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3942
-     * default route callback on the EE_Admin page you want it run.)
3943
-     *
3944
-     * @return void
3945
-     */
3946
-    protected function _transient_garbage_collection()
3947
-    {
3948
-        global $wpdb;
3949
-        // retrieve all existing transients
3950
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3951
-        if ($results = $wpdb->get_results($query)) {
3952
-            foreach ($results as $result) {
3953
-                $transient = str_replace('_transient_', '', $result->option_name);
3954
-                get_transient($transient);
3955
-                if (is_multisite() && is_network_admin()) {
3956
-                    get_site_transient($transient);
3957
-                }
3958
-            }
3959
-        }
3960
-    }
3961
-
3962
-
3963
-    /**
3964
-     * get_view
3965
-     *
3966
-     * @return string content of _view property
3967
-     */
3968
-    public function get_view()
3969
-    {
3970
-        return $this->_view;
3971
-    }
3972
-
3973
-
3974
-    /**
3975
-     * getter for the protected $_views property
3976
-     *
3977
-     * @return array
3978
-     */
3979
-    public function get_views()
3980
-    {
3981
-        return $this->_views;
3982
-    }
3983
-
3984
-
3985
-    /**
3986
-     * get_current_page
3987
-     *
3988
-     * @return string _current_page property value
3989
-     */
3990
-    public function get_current_page()
3991
-    {
3992
-        return $this->_current_page;
3993
-    }
3994
-
3995
-
3996
-    /**
3997
-     * get_current_view
3998
-     *
3999
-     * @return string _current_view property value
4000
-     */
4001
-    public function get_current_view()
4002
-    {
4003
-        return $this->_current_view;
4004
-    }
4005
-
4006
-
4007
-    /**
4008
-     * get_current_screen
4009
-     *
4010
-     * @return object The current WP_Screen object
4011
-     */
4012
-    public function get_current_screen()
4013
-    {
4014
-        return $this->_current_screen;
4015
-    }
4016
-
4017
-
4018
-    /**
4019
-     * get_current_page_view_url
4020
-     *
4021
-     * @return string This returns the url for the current_page_view.
4022
-     */
4023
-    public function get_current_page_view_url()
4024
-    {
4025
-        return $this->_current_page_view_url;
4026
-    }
4027
-
4028
-
4029
-    /**
4030
-     * just returns the _req_data property
4031
-     *
4032
-     * @return array
4033
-     */
4034
-    public function get_request_data()
4035
-    {
4036
-        return $this->_req_data;
4037
-    }
4038
-
4039
-
4040
-    /**
4041
-     * returns the _req_data protected property
4042
-     *
4043
-     * @return string
4044
-     */
4045
-    public function get_req_action()
4046
-    {
4047
-        return $this->_req_action;
4048
-    }
4049
-
4050
-
4051
-    /**
4052
-     * @return bool  value of $_is_caf property
4053
-     */
4054
-    public function is_caf()
4055
-    {
4056
-        return $this->_is_caf;
4057
-    }
4058
-
4059
-
4060
-    /**
4061
-     * @return mixed
4062
-     */
4063
-    public function default_espresso_metaboxes()
4064
-    {
4065
-        return $this->_default_espresso_metaboxes;
4066
-    }
4067
-
4068
-
4069
-    /**
4070
-     * @return mixed
4071
-     */
4072
-    public function admin_base_url()
4073
-    {
4074
-        return $this->_admin_base_url;
4075
-    }
4076
-
4077
-
4078
-    /**
4079
-     * @return mixed
4080
-     */
4081
-    public function wp_page_slug()
4082
-    {
4083
-        return $this->_wp_page_slug;
4084
-    }
4085
-
4086
-
4087
-    /**
4088
-     * updates  espresso configuration settings
4089
-     *
4090
-     * @param string                   $tab
4091
-     * @param EE_Config_Base|EE_Config $config
4092
-     * @param string                   $file file where error occurred
4093
-     * @param string                   $func function  where error occurred
4094
-     * @param string                   $line line no where error occurred
4095
-     * @return boolean
4096
-     */
4097
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4098
-    {
4099
-        // remove any options that are NOT going to be saved with the config settings.
4100
-        if (isset($config->core->ee_ueip_optin)) {
4101
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4102
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4103
-            update_option('ee_ueip_has_notified', true);
4104
-        }
4105
-        // and save it (note we're also doing the network save here)
4106
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4107
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4108
-        if ($config_saved && $net_saved) {
4109
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4110
-            return true;
4111
-        }
4112
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4113
-        return false;
4114
-    }
4115
-
4116
-
4117
-    /**
4118
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4119
-     *
4120
-     * @return array
4121
-     */
4122
-    public function get_yes_no_values()
4123
-    {
4124
-        return $this->_yes_no_values;
4125
-    }
4126
-
4127
-
4128
-    protected function _get_dir()
4129
-    {
4130
-        $reflector = new ReflectionClass(get_class($this));
4131
-        return dirname($reflector->getFileName());
4132
-    }
4133
-
4134
-
4135
-    /**
4136
-     * A helper for getting a "next link".
4137
-     *
4138
-     * @param string $url   The url to link to
4139
-     * @param string $class The class to use.
4140
-     * @return string
4141
-     */
4142
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4143
-    {
4144
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4145
-    }
4146
-
4147
-
4148
-    /**
4149
-     * A helper for getting a "previous link".
4150
-     *
4151
-     * @param string $url   The url to link to
4152
-     * @param string $class The class to use.
4153
-     * @return string
4154
-     */
4155
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4156
-    {
4157
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4158
-    }
4159
-
4160
-
4161
-
4162
-
4163
-
4164
-
4165
-
4166
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4167
-
4168
-
4169
-    /**
4170
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4171
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4172
-     * _req_data array.
4173
-     *
4174
-     * @return bool success/fail
4175
-     * @throws EE_Error
4176
-     * @throws InvalidArgumentException
4177
-     * @throws ReflectionException
4178
-     * @throws InvalidDataTypeException
4179
-     * @throws InvalidInterfaceException
4180
-     */
4181
-    protected function _process_resend_registration()
4182
-    {
4183
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4184
-        do_action(
4185
-            'AHEE__EE_Admin_Page___process_resend_registration',
4186
-            $this->_template_args['success'],
4187
-            $this->_req_data
4188
-        );
4189
-        return $this->_template_args['success'];
4190
-    }
4191
-
4192
-
4193
-    /**
4194
-     * This automatically processes any payment message notifications when manual payment has been applied.
4195
-     *
4196
-     * @param EE_Payment $payment
4197
-     * @return bool success/fail
4198
-     */
4199
-    protected function _process_payment_notification(EE_Payment $payment)
4200
-    {
4201
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4202
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4203
-        $this->_template_args['success'] = apply_filters(
4204
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4205
-            false,
4206
-            $payment
4207
-        );
4208
-        return $this->_template_args['success'];
4209
-    }
2744
+	}
2745
+
2746
+
2747
+	/**
2748
+	 * facade for add_meta_box
2749
+	 *
2750
+	 * @param string  $action        where the metabox get's displayed
2751
+	 * @param string  $title         Title of Metabox (output in metabox header)
2752
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2753
+	 *                               instead of the one created in here.
2754
+	 * @param array   $callback_args an array of args supplied for the metabox
2755
+	 * @param string  $column        what metabox column
2756
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2757
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2758
+	 *                               created but just set our own callback for wp's add_meta_box.
2759
+	 * @throws DomainException
2760
+	 */
2761
+	public function _add_admin_page_meta_box(
2762
+		$action,
2763
+		$title,
2764
+		$callback,
2765
+		$callback_args,
2766
+		$column = 'normal',
2767
+		$priority = 'high',
2768
+		$create_func = true
2769
+	) {
2770
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2771
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2772
+		if (empty($callback_args) && $create_func) {
2773
+			$callback_args = array(
2774
+				'template_path' => $this->_template_path,
2775
+				'template_args' => $this->_template_args,
2776
+			);
2777
+		}
2778
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2779
+		$call_back_func = $create_func
2780
+			? static function ($post, $metabox) {
2781
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2782
+				echo EEH_Template::display_template(
2783
+					$metabox['args']['template_path'],
2784
+					$metabox['args']['template_args'],
2785
+					true
2786
+				);
2787
+			}
2788
+			: $callback;
2789
+		add_meta_box(
2790
+			str_replace('_', '-', $action) . '-mbox',
2791
+			$title,
2792
+			$call_back_func,
2793
+			$this->_wp_page_slug,
2794
+			$column,
2795
+			$priority,
2796
+			$callback_args
2797
+		);
2798
+	}
2799
+
2800
+
2801
+	/**
2802
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2803
+	 *
2804
+	 * @throws DomainException
2805
+	 * @throws EE_Error
2806
+	 * @throws InvalidArgumentException
2807
+	 * @throws InvalidDataTypeException
2808
+	 * @throws InvalidInterfaceException
2809
+	 */
2810
+	public function display_admin_page_with_metabox_columns()
2811
+	{
2812
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2813
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2814
+			$this->_column_template_path,
2815
+			$this->_template_args,
2816
+			true
2817
+		);
2818
+		// the final wrapper
2819
+		$this->admin_page_wrapper();
2820
+	}
2821
+
2822
+
2823
+	/**
2824
+	 * generates  HTML wrapper for an admin details page
2825
+	 *
2826
+	 * @return void
2827
+	 * @throws DomainException
2828
+	 * @throws EE_Error
2829
+	 * @throws InvalidArgumentException
2830
+	 * @throws InvalidDataTypeException
2831
+	 * @throws InvalidInterfaceException
2832
+	 */
2833
+	public function display_admin_page_with_sidebar()
2834
+	{
2835
+		$this->_display_admin_page(true);
2836
+	}
2837
+
2838
+
2839
+	/**
2840
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2841
+	 *
2842
+	 * @return void
2843
+	 * @throws DomainException
2844
+	 * @throws EE_Error
2845
+	 * @throws InvalidArgumentException
2846
+	 * @throws InvalidDataTypeException
2847
+	 * @throws InvalidInterfaceException
2848
+	 */
2849
+	public function display_admin_page_with_no_sidebar()
2850
+	{
2851
+		$this->_display_admin_page();
2852
+	}
2853
+
2854
+
2855
+	/**
2856
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2857
+	 *
2858
+	 * @return void
2859
+	 * @throws DomainException
2860
+	 * @throws EE_Error
2861
+	 * @throws InvalidArgumentException
2862
+	 * @throws InvalidDataTypeException
2863
+	 * @throws InvalidInterfaceException
2864
+	 */
2865
+	public function display_about_admin_page()
2866
+	{
2867
+		$this->_display_admin_page(false, true);
2868
+	}
2869
+
2870
+
2871
+	/**
2872
+	 * display_admin_page
2873
+	 * contains the code for actually displaying an admin page
2874
+	 *
2875
+	 * @param boolean $sidebar true with sidebar, false without
2876
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2877
+	 * @return void
2878
+	 * @throws DomainException
2879
+	 * @throws EE_Error
2880
+	 * @throws InvalidArgumentException
2881
+	 * @throws InvalidDataTypeException
2882
+	 * @throws InvalidInterfaceException
2883
+	 */
2884
+	private function _display_admin_page($sidebar = false, $about = false)
2885
+	{
2886
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2887
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2888
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2889
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2890
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2891
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2892
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2893
+			? 'poststuff'
2894
+			: 'espresso-default-admin';
2895
+		$template_path = $sidebar
2896
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2897
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2898
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2899
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2900
+		}
2901
+		$template_path = ! empty($this->_column_template_path)
2902
+			? $this->_column_template_path : $template_path;
2903
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2904
+			? $this->_template_args['admin_page_content']
2905
+			: '';
2906
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2907
+			? $this->_template_args['before_admin_page_content']
2908
+			: '';
2909
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2910
+			? $this->_template_args['after_admin_page_content']
2911
+			: '';
2912
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2913
+			$template_path,
2914
+			$this->_template_args,
2915
+			true
2916
+		);
2917
+		// the final template wrapper
2918
+		$this->admin_page_wrapper($about);
2919
+	}
2920
+
2921
+
2922
+	/**
2923
+	 * This is used to display caf preview pages.
2924
+	 *
2925
+	 * @since 4.3.2
2926
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2927
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2928
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2929
+	 * @return void
2930
+	 * @throws DomainException
2931
+	 * @throws EE_Error
2932
+	 * @throws InvalidArgumentException
2933
+	 * @throws InvalidDataTypeException
2934
+	 * @throws InvalidInterfaceException
2935
+	 */
2936
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2937
+	{
2938
+		// let's generate a default preview action button if there isn't one already present.
2939
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2940
+			'Upgrade to Event Espresso 4 Right Now',
2941
+			'event_espresso'
2942
+		);
2943
+		$buy_now_url = add_query_arg(
2944
+			array(
2945
+				'ee_ver'       => 'ee4',
2946
+				'utm_source'   => 'ee4_plugin_admin',
2947
+				'utm_medium'   => 'link',
2948
+				'utm_campaign' => $utm_campaign_source,
2949
+				'utm_content'  => 'buy_now_button',
2950
+			),
2951
+			'http://eventespresso.com/pricing/'
2952
+		);
2953
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2954
+			? $this->get_action_link_or_button(
2955
+				'',
2956
+				'buy_now',
2957
+				array(),
2958
+				'button-primary button-large',
2959
+				$buy_now_url,
2960
+				true
2961
+			)
2962
+			: $this->_template_args['preview_action_button'];
2963
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2964
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2965
+			$this->_template_args,
2966
+			true
2967
+		);
2968
+		$this->_display_admin_page($display_sidebar);
2969
+	}
2970
+
2971
+
2972
+	/**
2973
+	 * display_admin_list_table_page_with_sidebar
2974
+	 * generates HTML wrapper for an admin_page with list_table
2975
+	 *
2976
+	 * @return void
2977
+	 * @throws DomainException
2978
+	 * @throws EE_Error
2979
+	 * @throws InvalidArgumentException
2980
+	 * @throws InvalidDataTypeException
2981
+	 * @throws InvalidInterfaceException
2982
+	 */
2983
+	public function display_admin_list_table_page_with_sidebar()
2984
+	{
2985
+		$this->_display_admin_list_table_page(true);
2986
+	}
2987
+
2988
+
2989
+	/**
2990
+	 * display_admin_list_table_page_with_no_sidebar
2991
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2992
+	 *
2993
+	 * @return void
2994
+	 * @throws DomainException
2995
+	 * @throws EE_Error
2996
+	 * @throws InvalidArgumentException
2997
+	 * @throws InvalidDataTypeException
2998
+	 * @throws InvalidInterfaceException
2999
+	 */
3000
+	public function display_admin_list_table_page_with_no_sidebar()
3001
+	{
3002
+		$this->_display_admin_list_table_page();
3003
+	}
3004
+
3005
+
3006
+	/**
3007
+	 * generates html wrapper for an admin_list_table page
3008
+	 *
3009
+	 * @param boolean $sidebar whether to display with sidebar or not.
3010
+	 * @return void
3011
+	 * @throws DomainException
3012
+	 * @throws EE_Error
3013
+	 * @throws InvalidArgumentException
3014
+	 * @throws InvalidDataTypeException
3015
+	 * @throws InvalidInterfaceException
3016
+	 */
3017
+	private function _display_admin_list_table_page($sidebar = false)
3018
+	{
3019
+		// setup search attributes
3020
+		$this->_set_search_attributes();
3021
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
3022
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3023
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
3024
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3025
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
3026
+		$this->_template_args['list_table'] = $this->_list_table_object;
3027
+		$this->_template_args['current_route'] = $this->_req_action;
3028
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3029
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
3030
+		if (! empty($ajax_sorting_callback)) {
3031
+			$sortable_list_table_form_fields = wp_nonce_field(
3032
+				$ajax_sorting_callback . '_nonce',
3033
+				$ajax_sorting_callback . '_nonce',
3034
+				false,
3035
+				false
3036
+			);
3037
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3038
+												. $this->page_slug
3039
+												. '" />';
3040
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3041
+												. $ajax_sorting_callback
3042
+												. '" />';
3043
+		} else {
3044
+			$sortable_list_table_form_fields = '';
3045
+		}
3046
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3047
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
3048
+			? $this->_template_args['list_table_hidden_fields']
3049
+			: '';
3050
+		$nonce_ref = $this->_req_action . '_nonce';
3051
+		$hidden_form_fields .= '<input type="hidden" name="'
3052
+							   . $nonce_ref
3053
+							   . '" value="'
3054
+							   . wp_create_nonce($nonce_ref)
3055
+							   . '">';
3056
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3057
+		// display message about search results?
3058
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3059
+			? '<p class="ee-search-results">' . sprintf(
3060
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3061
+				trim($this->_req_data['s'], '%')
3062
+			) . '</p>'
3063
+			: '';
3064
+		// filter before_list_table template arg
3065
+		$this->_template_args['before_list_table'] = apply_filters(
3066
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3067
+			$this->_template_args['before_list_table'],
3068
+			$this->page_slug,
3069
+			$this->_req_data,
3070
+			$this->_req_action
3071
+		);
3072
+		// convert to array and filter again
3073
+		// arrays are easier to inject new items in a specific location,
3074
+		// but would not be backwards compatible, so we have to add a new filter
3075
+		$this->_template_args['before_list_table'] = implode(
3076
+			" \n",
3077
+			(array) apply_filters(
3078
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3079
+				(array) $this->_template_args['before_list_table'],
3080
+				$this->page_slug,
3081
+				$this->_req_data,
3082
+				$this->_req_action
3083
+			)
3084
+		);
3085
+		// filter after_list_table template arg
3086
+		$this->_template_args['after_list_table'] = apply_filters(
3087
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3088
+			$this->_template_args['after_list_table'],
3089
+			$this->page_slug,
3090
+			$this->_req_data,
3091
+			$this->_req_action
3092
+		);
3093
+		// convert to array and filter again
3094
+		// arrays are easier to inject new items in a specific location,
3095
+		// but would not be backwards compatible, so we have to add a new filter
3096
+		$this->_template_args['after_list_table'] = implode(
3097
+			" \n",
3098
+			(array) apply_filters(
3099
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3100
+				(array) $this->_template_args['after_list_table'],
3101
+				$this->page_slug,
3102
+				$this->_req_data,
3103
+				$this->_req_action
3104
+			)
3105
+		);
3106
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3107
+			$template_path,
3108
+			$this->_template_args,
3109
+			true
3110
+		);
3111
+		// the final template wrapper
3112
+		if ($sidebar) {
3113
+			$this->display_admin_page_with_sidebar();
3114
+		} else {
3115
+			$this->display_admin_page_with_no_sidebar();
3116
+		}
3117
+	}
3118
+
3119
+
3120
+	/**
3121
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3122
+	 * html string for the legend.
3123
+	 * $items are expected in an array in the following format:
3124
+	 * $legend_items = array(
3125
+	 *        'item_id' => array(
3126
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3127
+	 *            'desc' => esc_html__('localized description of item');
3128
+	 *        )
3129
+	 * );
3130
+	 *
3131
+	 * @param  array $items see above for format of array
3132
+	 * @return string html string of legend
3133
+	 * @throws DomainException
3134
+	 */
3135
+	protected function _display_legend($items)
3136
+	{
3137
+		$this->_template_args['items'] = apply_filters(
3138
+			'FHEE__EE_Admin_Page___display_legend__items',
3139
+			(array) $items,
3140
+			$this
3141
+		);
3142
+		return EEH_Template::display_template(
3143
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3144
+			$this->_template_args,
3145
+			true
3146
+		);
3147
+	}
3148
+
3149
+
3150
+	/**
3151
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3152
+	 * The returned json object is created from an array in the following format:
3153
+	 * array(
3154
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3155
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3156
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3157
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3158
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3159
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3160
+	 *  that might be included in here)
3161
+	 * )
3162
+	 * The json object is populated by whatever is set in the $_template_args property.
3163
+	 *
3164
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3165
+	 *                                 instead of displayed.
3166
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3167
+	 * @return void
3168
+	 * @throws EE_Error
3169
+	 * @throws InvalidArgumentException
3170
+	 * @throws InvalidDataTypeException
3171
+	 * @throws InvalidInterfaceException
3172
+	 */
3173
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3174
+	{
3175
+		// make sure any EE_Error notices have been handled.
3176
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3177
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3178
+		unset($this->_template_args['data']);
3179
+		$json = array(
3180
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3181
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3182
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3183
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3184
+			'notices'   => EE_Error::get_notices(),
3185
+			'content'   => isset($this->_template_args['admin_page_content'])
3186
+				? $this->_template_args['admin_page_content'] : '',
3187
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3188
+			'isEEajax'  => true
3189
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3190
+		);
3191
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3192
+		if (null === error_get_last() || ! headers_sent()) {
3193
+			header('Content-Type: application/json; charset=UTF-8');
3194
+		}
3195
+		echo wp_json_encode($json);
3196
+		exit();
3197
+	}
3198
+
3199
+
3200
+	/**
3201
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3202
+	 *
3203
+	 * @return void
3204
+	 * @throws EE_Error
3205
+	 * @throws InvalidArgumentException
3206
+	 * @throws InvalidDataTypeException
3207
+	 * @throws InvalidInterfaceException
3208
+	 */
3209
+	public function return_json()
3210
+	{
3211
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3212
+			$this->_return_json();
3213
+		} else {
3214
+			throw new EE_Error(
3215
+				sprintf(
3216
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3217
+					__FUNCTION__
3218
+				)
3219
+			);
3220
+		}
3221
+	}
3222
+
3223
+
3224
+	/**
3225
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3226
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3227
+	 *
3228
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3229
+	 */
3230
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3231
+	{
3232
+		$this->_hook_obj = $hook_obj;
3233
+	}
3234
+
3235
+
3236
+	/**
3237
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3238
+	 *
3239
+	 * @param boolean $about whether to use the special about page wrapper or default.
3240
+	 * @return void
3241
+	 * @throws DomainException
3242
+	 * @throws EE_Error
3243
+	 * @throws InvalidArgumentException
3244
+	 * @throws InvalidDataTypeException
3245
+	 * @throws InvalidInterfaceException
3246
+	 */
3247
+	public function admin_page_wrapper($about = false)
3248
+	{
3249
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3250
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3251
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3252
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3253
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3254
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3255
+			isset($this->_template_args['before_admin_page_content'])
3256
+				? $this->_template_args['before_admin_page_content']
3257
+				: ''
3258
+		);
3259
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3260
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3261
+			isset($this->_template_args['after_admin_page_content'])
3262
+				? $this->_template_args['after_admin_page_content']
3263
+				: ''
3264
+		);
3265
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3266
+		// load settings page wrapper template
3267
+		$template_path = ! defined('DOING_AJAX')
3268
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3269
+			: EE_ADMIN_TEMPLATE
3270
+			  . 'admin_wrapper_ajax.template.php';
3271
+		// about page?
3272
+		$template_path = $about
3273
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3274
+			: $template_path;
3275
+		if (defined('DOING_AJAX')) {
3276
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3277
+				$template_path,
3278
+				$this->_template_args,
3279
+				true
3280
+			);
3281
+			$this->_return_json();
3282
+		} else {
3283
+			EEH_Template::display_template($template_path, $this->_template_args);
3284
+		}
3285
+	}
3286
+
3287
+
3288
+	/**
3289
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3290
+	 *
3291
+	 * @return string html
3292
+	 * @throws EE_Error
3293
+	 */
3294
+	protected function _get_main_nav_tabs()
3295
+	{
3296
+		// let's generate the html using the EEH_Tabbed_Content helper.
3297
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3298
+		// (rather than setting in the page_routes array)
3299
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3300
+	}
3301
+
3302
+
3303
+	/**
3304
+	 *        sort nav tabs
3305
+	 *
3306
+	 * @param $a
3307
+	 * @param $b
3308
+	 * @return int
3309
+	 */
3310
+	private function _sort_nav_tabs($a, $b)
3311
+	{
3312
+		if ($a['order'] === $b['order']) {
3313
+			return 0;
3314
+		}
3315
+		return ($a['order'] < $b['order']) ? -1 : 1;
3316
+	}
3317
+
3318
+
3319
+	/**
3320
+	 *    generates HTML for the forms used on admin pages
3321
+	 *
3322
+	 * @param    array $input_vars - array of input field details
3323
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3324
+	 *                             use)
3325
+	 * @param bool     $id
3326
+	 * @return string
3327
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3328
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3329
+	 */
3330
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3331
+	{
3332
+		$content = $generator === 'string'
3333
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3334
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3335
+		return $content;
3336
+	}
3337
+
3338
+
3339
+	/**
3340
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3341
+	 *
3342
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3343
+	 *                                   Close" button.
3344
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3345
+	 *                                   'Save', [1] => 'save & close')
3346
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3347
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3348
+	 *                                   default actions by submitting some other value.
3349
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3350
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3351
+	 *                                   close (normal form handling).
3352
+	 */
3353
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3354
+	{
3355
+		// make sure $text and $actions are in an array
3356
+		$text = (array) $text;
3357
+		$actions = (array) $actions;
3358
+		$referrer_url = empty($referrer)
3359
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3360
+			  . $_SERVER['REQUEST_URI']
3361
+			  . '" />'
3362
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3363
+			  . $referrer
3364
+			  . '" />';
3365
+		$button_text = ! empty($text)
3366
+			? $text
3367
+			: array(
3368
+				esc_html__('Save', 'event_espresso'),
3369
+				esc_html__('Save and Close', 'event_espresso'),
3370
+			);
3371
+		$default_names = array('save', 'save_and_close');
3372
+		// add in a hidden index for the current page (so save and close redirects properly)
3373
+		$this->_template_args['save_buttons'] = $referrer_url;
3374
+		foreach ($button_text as $key => $button) {
3375
+			$ref = $default_names[ $key ];
3376
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3377
+													 . $ref
3378
+													 . '" value="'
3379
+													 . $button
3380
+													 . '" name="'
3381
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3382
+													 . '" id="'
3383
+													 . $this->_current_view . '_' . $ref
3384
+													 . '" />';
3385
+			if (! $both) {
3386
+				break;
3387
+			}
3388
+		}
3389
+	}
3390
+
3391
+
3392
+	/**
3393
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3394
+	 *
3395
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3396
+	 * @since 4.6.0
3397
+	 * @param string $route
3398
+	 * @param array  $additional_hidden_fields
3399
+	 */
3400
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3401
+	{
3402
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3403
+	}
3404
+
3405
+
3406
+	/**
3407
+	 * set form open and close tags on add/edit pages.
3408
+	 *
3409
+	 * @param string $route                    the route you want the form to direct to
3410
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3411
+	 * @return void
3412
+	 */
3413
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3414
+	{
3415
+		if (empty($route)) {
3416
+			$user_msg = esc_html__(
3417
+				'An error occurred. No action was set for this page\'s form.',
3418
+				'event_espresso'
3419
+			);
3420
+			$dev_msg = $user_msg . "\n"
3421
+					   . sprintf(
3422
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3423
+						   __FUNCTION__,
3424
+						   __CLASS__
3425
+					   );
3426
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3427
+		}
3428
+		// open form
3429
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3430
+															 . $this->_admin_base_url
3431
+															 . '" id="'
3432
+															 . $route
3433
+															 . '_event_form" >';
3434
+		// add nonce
3435
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3436
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3437
+		// add REQUIRED form action
3438
+		$hidden_fields = array(
3439
+			'action' => array('type' => 'hidden', 'value' => $route),
3440
+		);
3441
+		// merge arrays
3442
+		$hidden_fields = is_array($additional_hidden_fields)
3443
+			? array_merge($hidden_fields, $additional_hidden_fields)
3444
+			: $hidden_fields;
3445
+		// generate form fields
3446
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3447
+		// add fields to form
3448
+		foreach ((array) $form_fields as $field_name => $form_field) {
3449
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3450
+		}
3451
+		// close form
3452
+		$this->_template_args['after_admin_page_content'] = '</form>';
3453
+	}
3454
+
3455
+
3456
+	/**
3457
+	 * Public Wrapper for _redirect_after_action() method since its
3458
+	 * discovered it would be useful for external code to have access.
3459
+	 *
3460
+	 * @param bool   $success
3461
+	 * @param string $what
3462
+	 * @param string $action_desc
3463
+	 * @param array  $query_args
3464
+	 * @param bool   $override_overwrite
3465
+	 * @throws EE_Error
3466
+	 * @throws InvalidArgumentException
3467
+	 * @throws InvalidDataTypeException
3468
+	 * @throws InvalidInterfaceException
3469
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3470
+	 * @since 4.5.0
3471
+	 */
3472
+	public function redirect_after_action(
3473
+		$success = false,
3474
+		$what = 'item',
3475
+		$action_desc = 'processed',
3476
+		$query_args = array(),
3477
+		$override_overwrite = false
3478
+	) {
3479
+		$this->_redirect_after_action(
3480
+			$success,
3481
+			$what,
3482
+			$action_desc,
3483
+			$query_args,
3484
+			$override_overwrite
3485
+		);
3486
+	}
3487
+
3488
+
3489
+	/**
3490
+	 * Helper method for merging existing request data with the returned redirect url.
3491
+	 *
3492
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3493
+	 * filters are still applied.
3494
+	 *
3495
+	 * @param array $new_route_data
3496
+	 * @return array
3497
+	 */
3498
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3499
+	{
3500
+		foreach ($this->_req_data as $ref => $value) {
3501
+			// unset nonces
3502
+			if (strpos($ref, 'nonce') !== false) {
3503
+				unset($this->_req_data[ $ref ]);
3504
+				continue;
3505
+			}
3506
+			// urlencode values.
3507
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3508
+			$this->_req_data[ $ref ] = $value;
3509
+		}
3510
+		return array_merge($this->_req_data, $new_route_data);
3511
+	}
3512
+
3513
+
3514
+	/**
3515
+	 *    _redirect_after_action
3516
+	 *
3517
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3518
+	 * @param string $what               - what the action was performed on
3519
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3520
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3521
+	 *                                   action is completed
3522
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3523
+	 *                                   override this so that they show.
3524
+	 * @return void
3525
+	 * @throws EE_Error
3526
+	 * @throws InvalidArgumentException
3527
+	 * @throws InvalidDataTypeException
3528
+	 * @throws InvalidInterfaceException
3529
+	 */
3530
+	protected function _redirect_after_action(
3531
+		$success = 0,
3532
+		$what = 'item',
3533
+		$action_desc = 'processed',
3534
+		$query_args = array(),
3535
+		$override_overwrite = false
3536
+	) {
3537
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3538
+		// class name for actions/filters.
3539
+		$classname = get_class($this);
3540
+		// set redirect url.
3541
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3542
+		// otherwise we go with whatever is set as the _admin_base_url
3543
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3544
+		$notices = EE_Error::get_notices(false);
3545
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3546
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3547
+			EE_Error::overwrite_success();
3548
+		}
3549
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3550
+			// how many records affected ? more than one record ? or just one ?
3551
+			if ($success > 1) {
3552
+				// set plural msg
3553
+				EE_Error::add_success(
3554
+					sprintf(
3555
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3556
+						$what,
3557
+						$action_desc
3558
+					),
3559
+					__FILE__,
3560
+					__FUNCTION__,
3561
+					__LINE__
3562
+				);
3563
+			} elseif ($success === 1) {
3564
+				// set singular msg
3565
+				EE_Error::add_success(
3566
+					sprintf(
3567
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3568
+						$what,
3569
+						$action_desc
3570
+					),
3571
+					__FILE__,
3572
+					__FUNCTION__,
3573
+					__LINE__
3574
+				);
3575
+			}
3576
+		}
3577
+		// check that $query_args isn't something crazy
3578
+		if (! is_array($query_args)) {
3579
+			$query_args = array();
3580
+		}
3581
+		/**
3582
+		 * Allow injecting actions before the query_args are modified for possible different
3583
+		 * redirections on save and close actions
3584
+		 *
3585
+		 * @since 4.2.0
3586
+		 * @param array $query_args       The original query_args array coming into the
3587
+		 *                                method.
3588
+		 */
3589
+		do_action(
3590
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3591
+			$query_args
3592
+		);
3593
+		// calculate where we're going (if we have a "save and close" button pushed)
3594
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3595
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3596
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3597
+			// regenerate query args array from referrer URL
3598
+			parse_str($parsed_url['query'], $query_args);
3599
+			// correct page and action will be in the query args now
3600
+			$redirect_url = admin_url('admin.php');
3601
+		}
3602
+		// merge any default query_args set in _default_route_query_args property
3603
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3604
+			$args_to_merge = array();
3605
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3606
+				// is there a wp_referer array in our _default_route_query_args property?
3607
+				if ($query_param === 'wp_referer') {
3608
+					$query_value = (array) $query_value;
3609
+					foreach ($query_value as $reference => $value) {
3610
+						if (strpos($reference, 'nonce') !== false) {
3611
+							continue;
3612
+						}
3613
+						// finally we will override any arguments in the referer with
3614
+						// what might be set on the _default_route_query_args array.
3615
+						if (isset($this->_default_route_query_args[ $reference ])) {
3616
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3617
+						} else {
3618
+							$args_to_merge[ $reference ] = urlencode($value);
3619
+						}
3620
+					}
3621
+					continue;
3622
+				}
3623
+				$args_to_merge[ $query_param ] = $query_value;
3624
+			}
3625
+			// now let's merge these arguments but override with what was specifically sent in to the
3626
+			// redirect.
3627
+			$query_args = array_merge($args_to_merge, $query_args);
3628
+		}
3629
+		$this->_process_notices($query_args);
3630
+		// generate redirect url
3631
+		// if redirecting to anything other than the main page, add a nonce
3632
+		if (isset($query_args['action'])) {
3633
+			// manually generate wp_nonce and merge that with the query vars
3634
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3635
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3636
+		}
3637
+		// we're adding some hooks and filters in here for processing any things just before redirects
3638
+		// (example: an admin page has done an insert or update and we want to run something after that).
3639
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3640
+		$redirect_url = apply_filters(
3641
+			'FHEE_redirect_' . $classname . $this->_req_action,
3642
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3643
+			$query_args
3644
+		);
3645
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3646
+		if (defined('DOING_AJAX')) {
3647
+			$default_data = array(
3648
+				'close'        => true,
3649
+				'redirect_url' => $redirect_url,
3650
+				'where'        => 'main',
3651
+				'what'         => 'append',
3652
+			);
3653
+			$this->_template_args['success'] = $success;
3654
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3655
+				$default_data,
3656
+				$this->_template_args['data']
3657
+			) : $default_data;
3658
+			$this->_return_json();
3659
+		}
3660
+		wp_safe_redirect($redirect_url);
3661
+		exit();
3662
+	}
3663
+
3664
+
3665
+	/**
3666
+	 * process any notices before redirecting (or returning ajax request)
3667
+	 * This method sets the $this->_template_args['notices'] attribute;
3668
+	 *
3669
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3670
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3671
+	 *                                  page_routes haven't been defined yet.
3672
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3673
+	 *                                  still save a transient for the notice.
3674
+	 * @return void
3675
+	 * @throws EE_Error
3676
+	 * @throws InvalidArgumentException
3677
+	 * @throws InvalidDataTypeException
3678
+	 * @throws InvalidInterfaceException
3679
+	 */
3680
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3681
+	{
3682
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3683
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3684
+			$notices = EE_Error::get_notices(false);
3685
+			if (empty($this->_template_args['success'])) {
3686
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3687
+			}
3688
+			if (empty($this->_template_args['errors'])) {
3689
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3690
+			}
3691
+			if (empty($this->_template_args['attention'])) {
3692
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3693
+			}
3694
+		}
3695
+		$this->_template_args['notices'] = EE_Error::get_notices();
3696
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3697
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3698
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3699
+			$this->_add_transient(
3700
+				$route,
3701
+				$this->_template_args['notices'],
3702
+				true,
3703
+				$skip_route_verify
3704
+			);
3705
+		}
3706
+	}
3707
+
3708
+
3709
+	/**
3710
+	 * get_action_link_or_button
3711
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3712
+	 *
3713
+	 * @param string $action        use this to indicate which action the url is generated with.
3714
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3715
+	 *                              property.
3716
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3717
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3718
+	 * @param string $base_url      If this is not provided
3719
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3720
+	 *                              Otherwise this value will be used.
3721
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3722
+	 * @return string
3723
+	 * @throws InvalidArgumentException
3724
+	 * @throws InvalidInterfaceException
3725
+	 * @throws InvalidDataTypeException
3726
+	 * @throws EE_Error
3727
+	 */
3728
+	public function get_action_link_or_button(
3729
+		$action,
3730
+		$type = 'add',
3731
+		$extra_request = array(),
3732
+		$class = 'button-primary',
3733
+		$base_url = '',
3734
+		$exclude_nonce = false
3735
+	) {
3736
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3737
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3738
+			throw new EE_Error(
3739
+				sprintf(
3740
+					esc_html__(
3741
+						'There is no page route for given action for the button.  This action was given: %s',
3742
+						'event_espresso'
3743
+					),
3744
+					$action
3745
+				)
3746
+			);
3747
+		}
3748
+		if (! isset($this->_labels['buttons'][ $type ])) {
3749
+			throw new EE_Error(
3750
+				sprintf(
3751
+					__(
3752
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3753
+						'event_espresso'
3754
+					),
3755
+					$type
3756
+				)
3757
+			);
3758
+		}
3759
+		// finally check user access for this button.
3760
+		$has_access = $this->check_user_access($action, true);
3761
+		if (! $has_access) {
3762
+			return '';
3763
+		}
3764
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3765
+		$query_args = array(
3766
+			'action' => $action,
3767
+		);
3768
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3769
+		if (! empty($extra_request)) {
3770
+			$query_args = array_merge($extra_request, $query_args);
3771
+		}
3772
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3773
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3774
+	}
3775
+
3776
+
3777
+	/**
3778
+	 * _per_page_screen_option
3779
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3780
+	 *
3781
+	 * @return void
3782
+	 * @throws InvalidArgumentException
3783
+	 * @throws InvalidInterfaceException
3784
+	 * @throws InvalidDataTypeException
3785
+	 */
3786
+	protected function _per_page_screen_option()
3787
+	{
3788
+		$option = 'per_page';
3789
+		$args = array(
3790
+			'label'   => apply_filters(
3791
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3792
+				$this->_admin_page_title,
3793
+				$this
3794
+			),
3795
+			'default' => (int) apply_filters(
3796
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3797
+				20
3798
+			),
3799
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3800
+		);
3801
+		// ONLY add the screen option if the user has access to it.
3802
+		if ($this->check_user_access($this->_current_view, true)) {
3803
+			add_screen_option($option, $args);
3804
+		}
3805
+	}
3806
+
3807
+
3808
+	/**
3809
+	 * set_per_page_screen_option
3810
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3811
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3812
+	 * admin_menu.
3813
+	 *
3814
+	 * @return void
3815
+	 */
3816
+	private function _set_per_page_screen_options()
3817
+	{
3818
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3819
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3820
+			if (! $user = wp_get_current_user()) {
3821
+				return;
3822
+			}
3823
+			$option = $_POST['wp_screen_options']['option'];
3824
+			$value = $_POST['wp_screen_options']['value'];
3825
+			if ($option !== sanitize_key($option)) {
3826
+				return;
3827
+			}
3828
+			$map_option = $option;
3829
+			$option = str_replace('-', '_', $option);
3830
+			switch ($map_option) {
3831
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3832
+					$value = (int) $value;
3833
+					$max_value = apply_filters(
3834
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3835
+						999,
3836
+						$this->_current_page,
3837
+						$this->_current_view
3838
+					);
3839
+					if ($value < 1) {
3840
+						return;
3841
+					}
3842
+					$value = min($value, $max_value);
3843
+					break;
3844
+				default:
3845
+					$value = apply_filters(
3846
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3847
+						false,
3848
+						$option,
3849
+						$value
3850
+					);
3851
+					if (false === $value) {
3852
+						return;
3853
+					}
3854
+					break;
3855
+			}
3856
+			update_user_meta($user->ID, $option, $value);
3857
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3858
+			exit;
3859
+		}
3860
+	}
3861
+
3862
+
3863
+	/**
3864
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3865
+	 *
3866
+	 * @param array $data array that will be assigned to template args.
3867
+	 */
3868
+	public function set_template_args($data)
3869
+	{
3870
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3871
+	}
3872
+
3873
+
3874
+	/**
3875
+	 * This makes available the WP transient system for temporarily moving data between routes
3876
+	 *
3877
+	 * @param string $route             the route that should receive the transient
3878
+	 * @param array  $data              the data that gets sent
3879
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3880
+	 *                                  normal route transient.
3881
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3882
+	 *                                  when we are adding a transient before page_routes have been defined.
3883
+	 * @return void
3884
+	 * @throws EE_Error
3885
+	 */
3886
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3887
+	{
3888
+		$user_id = get_current_user_id();
3889
+		if (! $skip_route_verify) {
3890
+			$this->_verify_route($route);
3891
+		}
3892
+		// now let's set the string for what kind of transient we're setting
3893
+		$transient = $notices
3894
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3895
+			: 'rte_tx_' . $route . '_' . $user_id;
3896
+		$data = $notices ? array('notices' => $data) : $data;
3897
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3898
+		$existing = is_multisite() && is_network_admin()
3899
+			? get_site_transient($transient)
3900
+			: get_transient($transient);
3901
+		if ($existing) {
3902
+			$data = array_merge((array) $data, (array) $existing);
3903
+		}
3904
+		if (is_multisite() && is_network_admin()) {
3905
+			set_site_transient($transient, $data, 8);
3906
+		} else {
3907
+			set_transient($transient, $data, 8);
3908
+		}
3909
+	}
3910
+
3911
+
3912
+	/**
3913
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3914
+	 *
3915
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3916
+	 * @param string $route
3917
+	 * @return mixed data
3918
+	 */
3919
+	protected function _get_transient($notices = false, $route = '')
3920
+	{
3921
+		$user_id = get_current_user_id();
3922
+		$route = ! $route ? $this->_req_action : $route;
3923
+		$transient = $notices
3924
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3925
+			: 'rte_tx_' . $route . '_' . $user_id;
3926
+		$data = is_multisite() && is_network_admin()
3927
+			? get_site_transient($transient)
3928
+			: get_transient($transient);
3929
+		// delete transient after retrieval (just in case it hasn't expired);
3930
+		if (is_multisite() && is_network_admin()) {
3931
+			delete_site_transient($transient);
3932
+		} else {
3933
+			delete_transient($transient);
3934
+		}
3935
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3936
+	}
3937
+
3938
+
3939
+	/**
3940
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3941
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3942
+	 * default route callback on the EE_Admin page you want it run.)
3943
+	 *
3944
+	 * @return void
3945
+	 */
3946
+	protected function _transient_garbage_collection()
3947
+	{
3948
+		global $wpdb;
3949
+		// retrieve all existing transients
3950
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3951
+		if ($results = $wpdb->get_results($query)) {
3952
+			foreach ($results as $result) {
3953
+				$transient = str_replace('_transient_', '', $result->option_name);
3954
+				get_transient($transient);
3955
+				if (is_multisite() && is_network_admin()) {
3956
+					get_site_transient($transient);
3957
+				}
3958
+			}
3959
+		}
3960
+	}
3961
+
3962
+
3963
+	/**
3964
+	 * get_view
3965
+	 *
3966
+	 * @return string content of _view property
3967
+	 */
3968
+	public function get_view()
3969
+	{
3970
+		return $this->_view;
3971
+	}
3972
+
3973
+
3974
+	/**
3975
+	 * getter for the protected $_views property
3976
+	 *
3977
+	 * @return array
3978
+	 */
3979
+	public function get_views()
3980
+	{
3981
+		return $this->_views;
3982
+	}
3983
+
3984
+
3985
+	/**
3986
+	 * get_current_page
3987
+	 *
3988
+	 * @return string _current_page property value
3989
+	 */
3990
+	public function get_current_page()
3991
+	{
3992
+		return $this->_current_page;
3993
+	}
3994
+
3995
+
3996
+	/**
3997
+	 * get_current_view
3998
+	 *
3999
+	 * @return string _current_view property value
4000
+	 */
4001
+	public function get_current_view()
4002
+	{
4003
+		return $this->_current_view;
4004
+	}
4005
+
4006
+
4007
+	/**
4008
+	 * get_current_screen
4009
+	 *
4010
+	 * @return object The current WP_Screen object
4011
+	 */
4012
+	public function get_current_screen()
4013
+	{
4014
+		return $this->_current_screen;
4015
+	}
4016
+
4017
+
4018
+	/**
4019
+	 * get_current_page_view_url
4020
+	 *
4021
+	 * @return string This returns the url for the current_page_view.
4022
+	 */
4023
+	public function get_current_page_view_url()
4024
+	{
4025
+		return $this->_current_page_view_url;
4026
+	}
4027
+
4028
+
4029
+	/**
4030
+	 * just returns the _req_data property
4031
+	 *
4032
+	 * @return array
4033
+	 */
4034
+	public function get_request_data()
4035
+	{
4036
+		return $this->_req_data;
4037
+	}
4038
+
4039
+
4040
+	/**
4041
+	 * returns the _req_data protected property
4042
+	 *
4043
+	 * @return string
4044
+	 */
4045
+	public function get_req_action()
4046
+	{
4047
+		return $this->_req_action;
4048
+	}
4049
+
4050
+
4051
+	/**
4052
+	 * @return bool  value of $_is_caf property
4053
+	 */
4054
+	public function is_caf()
4055
+	{
4056
+		return $this->_is_caf;
4057
+	}
4058
+
4059
+
4060
+	/**
4061
+	 * @return mixed
4062
+	 */
4063
+	public function default_espresso_metaboxes()
4064
+	{
4065
+		return $this->_default_espresso_metaboxes;
4066
+	}
4067
+
4068
+
4069
+	/**
4070
+	 * @return mixed
4071
+	 */
4072
+	public function admin_base_url()
4073
+	{
4074
+		return $this->_admin_base_url;
4075
+	}
4076
+
4077
+
4078
+	/**
4079
+	 * @return mixed
4080
+	 */
4081
+	public function wp_page_slug()
4082
+	{
4083
+		return $this->_wp_page_slug;
4084
+	}
4085
+
4086
+
4087
+	/**
4088
+	 * updates  espresso configuration settings
4089
+	 *
4090
+	 * @param string                   $tab
4091
+	 * @param EE_Config_Base|EE_Config $config
4092
+	 * @param string                   $file file where error occurred
4093
+	 * @param string                   $func function  where error occurred
4094
+	 * @param string                   $line line no where error occurred
4095
+	 * @return boolean
4096
+	 */
4097
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4098
+	{
4099
+		// remove any options that are NOT going to be saved with the config settings.
4100
+		if (isset($config->core->ee_ueip_optin)) {
4101
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4102
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4103
+			update_option('ee_ueip_has_notified', true);
4104
+		}
4105
+		// and save it (note we're also doing the network save here)
4106
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4107
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4108
+		if ($config_saved && $net_saved) {
4109
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4110
+			return true;
4111
+		}
4112
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4113
+		return false;
4114
+	}
4115
+
4116
+
4117
+	/**
4118
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4119
+	 *
4120
+	 * @return array
4121
+	 */
4122
+	public function get_yes_no_values()
4123
+	{
4124
+		return $this->_yes_no_values;
4125
+	}
4126
+
4127
+
4128
+	protected function _get_dir()
4129
+	{
4130
+		$reflector = new ReflectionClass(get_class($this));
4131
+		return dirname($reflector->getFileName());
4132
+	}
4133
+
4134
+
4135
+	/**
4136
+	 * A helper for getting a "next link".
4137
+	 *
4138
+	 * @param string $url   The url to link to
4139
+	 * @param string $class The class to use.
4140
+	 * @return string
4141
+	 */
4142
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4143
+	{
4144
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4145
+	}
4146
+
4147
+
4148
+	/**
4149
+	 * A helper for getting a "previous link".
4150
+	 *
4151
+	 * @param string $url   The url to link to
4152
+	 * @param string $class The class to use.
4153
+	 * @return string
4154
+	 */
4155
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4156
+	{
4157
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4158
+	}
4159
+
4160
+
4161
+
4162
+
4163
+
4164
+
4165
+
4166
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4167
+
4168
+
4169
+	/**
4170
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4171
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4172
+	 * _req_data array.
4173
+	 *
4174
+	 * @return bool success/fail
4175
+	 * @throws EE_Error
4176
+	 * @throws InvalidArgumentException
4177
+	 * @throws ReflectionException
4178
+	 * @throws InvalidDataTypeException
4179
+	 * @throws InvalidInterfaceException
4180
+	 */
4181
+	protected function _process_resend_registration()
4182
+	{
4183
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4184
+		do_action(
4185
+			'AHEE__EE_Admin_Page___process_resend_registration',
4186
+			$this->_template_args['success'],
4187
+			$this->_req_data
4188
+		);
4189
+		return $this->_template_args['success'];
4190
+	}
4191
+
4192
+
4193
+	/**
4194
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4195
+	 *
4196
+	 * @param EE_Payment $payment
4197
+	 * @return bool success/fail
4198
+	 */
4199
+	protected function _process_payment_notification(EE_Payment $payment)
4200
+	{
4201
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4202
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4203
+		$this->_template_args['success'] = apply_filters(
4204
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4205
+			false,
4206
+			$payment
4207
+		);
4208
+		return $this->_template_args['success'];
4209
+	}
4210 4210
 }
Please login to merge, or discard this patch.