Completed
Branch BUG/11268/session-ticket-relea... (bab17c)
by
unknown
31:21 queued 14:43
created
modules/ticket_selector/ProcessTicketSelector.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * cancelTicketSelections
44 44
      *
45
-     * @return        string
45
+     * @return        false|null
46 46
      * @throws EE_Error
47 47
      * @throws InvalidArgumentException
48 48
      * @throws InvalidInterfaceException
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     /**
115 115
      * process_ticket_selections
116 116
      *
117
-     * @return array|bool
117
+     * @return null|boolean
118 118
      * @throws \ReflectionException
119 119
      * @throws InvalidArgumentException
120 120
      * @throws InvalidInterfaceException
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      * validate_post_data
299 299
      *
300 300
      * @param int $id
301
-     * @return array|FALSE
301
+     * @return string
302 302
      * @throws \ReflectionException
303 303
      * @throws InvalidArgumentException
304 304
      * @throws InvalidInterfaceException
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      *
422 422
      * @param EE_Ticket $ticket
423 423
      * @param int        $qty
424
-     * @return TRUE on success, FALSE on fail
424
+     * @return boolean on success, FALSE on fail
425 425
      * @throws InvalidArgumentException
426 426
      * @throws InvalidInterfaceException
427 427
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 use InvalidArgumentException;
15 15
 
16 16
 if (! defined('EVENT_ESPRESSO_VERSION')) {
17
-    exit('No direct script access allowed');
17
+	exit('No direct script access allowed');
18 18
 }
19 19
 
20 20
 
@@ -31,602 +31,602 @@  discard block
 block discarded – undo
31 31
 class ProcessTicketSelector
32 32
 {
33 33
 
34
-    /**
35
-     * array of datetimes and the spaces available for them
36
-     *
37
-     * @var array[][]
38
-     */
39
-    private static $_available_spaces = array();
34
+	/**
35
+	 * array of datetimes and the spaces available for them
36
+	 *
37
+	 * @var array[][]
38
+	 */
39
+	private static $_available_spaces = array();
40 40
 
41 41
 
42
-    /**
43
-     * cancelTicketSelections
44
-     *
45
-     * @return        string
46
-     * @throws EE_Error
47
-     * @throws InvalidArgumentException
48
-     * @throws InvalidInterfaceException
49
-     * @throws InvalidDataTypeException
50
-     */
51
-    public function cancelTicketSelections()
52
-    {
53
-        // check nonce
54
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
55
-            return false;
56
-        }
57
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
58
-        if (EE_Registry::instance()->REQ->is_set('event_id')) {
59
-            wp_safe_redirect(
60
-                EEH_Event_View::event_link_url(
61
-                    EE_Registry::instance()->REQ->get('event_id')
62
-                )
63
-            );
64
-        } else {
65
-            wp_safe_redirect(
66
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
67
-            );
68
-        }
69
-        exit();
70
-    }
42
+	/**
43
+	 * cancelTicketSelections
44
+	 *
45
+	 * @return        string
46
+	 * @throws EE_Error
47
+	 * @throws InvalidArgumentException
48
+	 * @throws InvalidInterfaceException
49
+	 * @throws InvalidDataTypeException
50
+	 */
51
+	public function cancelTicketSelections()
52
+	{
53
+		// check nonce
54
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
55
+			return false;
56
+		}
57
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
58
+		if (EE_Registry::instance()->REQ->is_set('event_id')) {
59
+			wp_safe_redirect(
60
+				EEH_Event_View::event_link_url(
61
+					EE_Registry::instance()->REQ->get('event_id')
62
+				)
63
+			);
64
+		} else {
65
+			wp_safe_redirect(
66
+				site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
67
+			);
68
+		}
69
+		exit();
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * processTicketSelectorNonce
75
-     *
76
-     * @param  string $nonce_name
77
-     * @param string  $id
78
-     * @return bool
79
-     * @throws InvalidArgumentException
80
-     * @throws InvalidInterfaceException
81
-     * @throws InvalidDataTypeException
82
-     */
83
-    private function processTicketSelectorNonce($nonce_name, $id = '')
84
-    {
85
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
86
-        if (
87
-            ! is_admin()
88
-            && (
89
-                ! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
90
-                || ! wp_verify_nonce(
91
-                    EE_Registry::instance()->REQ->get($nonce_name_with_id),
92
-                    $nonce_name
93
-                )
94
-            )
95
-        ) {
96
-            EE_Error::add_error(
97
-                sprintf(
98
-                    __(
99
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
100
-                        'event_espresso'
101
-                    ),
102
-                    '<br/>'
103
-                ),
104
-                __FILE__,
105
-                __FUNCTION__,
106
-                __LINE__
107
-            );
108
-            return false;
109
-        }
110
-        return true;
111
-    }
73
+	/**
74
+	 * processTicketSelectorNonce
75
+	 *
76
+	 * @param  string $nonce_name
77
+	 * @param string  $id
78
+	 * @return bool
79
+	 * @throws InvalidArgumentException
80
+	 * @throws InvalidInterfaceException
81
+	 * @throws InvalidDataTypeException
82
+	 */
83
+	private function processTicketSelectorNonce($nonce_name, $id = '')
84
+	{
85
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
86
+		if (
87
+			! is_admin()
88
+			&& (
89
+				! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
90
+				|| ! wp_verify_nonce(
91
+					EE_Registry::instance()->REQ->get($nonce_name_with_id),
92
+					$nonce_name
93
+				)
94
+			)
95
+		) {
96
+			EE_Error::add_error(
97
+				sprintf(
98
+					__(
99
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
100
+						'event_espresso'
101
+					),
102
+					'<br/>'
103
+				),
104
+				__FILE__,
105
+				__FUNCTION__,
106
+				__LINE__
107
+			);
108
+			return false;
109
+		}
110
+		return true;
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     * process_ticket_selections
116
-     *
117
-     * @return array|bool
118
-     * @throws \ReflectionException
119
-     * @throws InvalidArgumentException
120
-     * @throws InvalidInterfaceException
121
-     * @throws InvalidDataTypeException
122
-     * @throws EE_Error
123
-     */
124
-    public function processTicketSelections()
125
-    {
126
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
127
-        $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
128
-        if($request->isBot()) {
129
-            wp_safe_redirect(
130
-                apply_filters(
131
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
132
-                    site_url()
133
-                )
134
-            );
135
-            exit();
136
-        }
137
-        // do we have an event id?
138
-        if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
139
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
140
-            EE_Error::add_error(
141
-                sprintf(
142
-                    __(
143
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
144
-                        'event_espresso'
145
-                    ),
146
-                    '<br/>'
147
-                ),
148
-                __FILE__,
149
-                __FUNCTION__,
150
-                __LINE__
151
-            );
152
-        }
153
-        //if event id is valid
154
-        $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
155
-        //		d( \EE_Registry::instance()->REQ );
156
-        self::$_available_spaces = array(
157
-            'tickets'   => array(),
158
-            'datetimes' => array(),
159
-        );
160
-        //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
161
-        // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
162
-        EE_Registry::instance()->load_core('Session');
163
-        // unless otherwise requested, clear the session
164
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
165
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
166
-        }
167
-        //d( \EE_Registry::instance()->SSN );
168
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
169
-        // validate/sanitize data
170
-        $valid = $this->validatePostData($id);
171
-        //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
172
-        //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
173
-        //EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
174
-        //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
175
-        //check total tickets ordered vs max number of attendees that can register
176
-        if ($valid['total_tickets'] > $valid['max_atndz']) {
177
-            // ordering too many tickets !!!
178
-            $total_tickets_string = _n(
179
-                'You have attempted to purchase %s ticket.',
180
-                'You have attempted to purchase %s tickets.',
181
-                $valid['total_tickets'],
182
-                'event_espresso'
183
-            );
184
-            $limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
185
-            // dev only message
186
-            $max_atndz_string = _n(
187
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
188
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
189
-                $valid['max_atndz'],
190
-                'event_espresso'
191
-            );
192
-            $limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
194
-        } else {
195
-            // all data appears to be valid
196
-            $tckts_slctd   = false;
197
-            $tickets_added = 0;
198
-            $valid         = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
199
-                $valid);
200
-            if ($valid['total_tickets'] > 0) {
201
-                // load cart
202
-                EE_Registry::instance()->load_core('Cart');
203
-                // cycle thru the number of data rows sent from the event listing
204
-                for ($x = 0; $x < $valid['rows']; $x++) {
205
-                    // does this row actually contain a ticket quantity?
206
-                    if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
207
-                        // YES we have a ticket quantity
208
-                        $tckts_slctd = true;
209
-                        //						d( $valid['ticket_obj'][$x] );
210
-                        if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
211
-                            // then add ticket to cart
212
-                            $tickets_added += $this->addTicketToCart(
213
-                                $valid['ticket_obj'][ $x ],
214
-                                $valid['qty'][ $x ]
215
-                            );
216
-                            if (EE_Error::has_error()) {
217
-                                break;
218
-                            }
219
-                        } else {
220
-                            // nothing added to cart retrieved
221
-                            EE_Error::add_error(
222
-                                sprintf(
223
-                                    __(
224
-                                        'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
225
-                                        'event_espresso'
226
-                                    ),
227
-                                    '<br/>'
228
-                                ),
229
-                                __FILE__, __FUNCTION__, __LINE__
230
-                            );
231
-                        }
232
-                    }
233
-                }
234
-            }
235
-            do_action(
236
-                'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
237
-                EE_Registry::instance()->CART,
238
-                $this
239
-            );
240
-            //d( \EE_Registry::instance()->CART );
241
-            //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
242
-            if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
243
-                if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
244
-                    do_action(
245
-                        'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
246
-                        EE_Registry::instance()->CART,
247
-                        $this
248
-                    );
249
-                    EE_Registry::instance()->CART->recalculate_all_cart_totals();
250
-                    EE_Registry::instance()->CART->save_cart(false);
251
-                    // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
252
-                    // just return TRUE for registrations being made from admin
253
-                    if (is_admin()) {
254
-                        return true;
255
-                    }
256
-                    EE_Error::get_notices(false, true);
257
-                    wp_safe_redirect(
258
-                        apply_filters(
259
-                            'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
260
-                            EE_Registry::instance()->CFG->core->reg_page_url()
261
-                        )
262
-                    );
263
-                    exit();
264
-                } else {
265
-                    if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
266
-                        // nothing added to cart
267
-                        EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
268
-                            __FILE__, __FUNCTION__, __LINE__);
269
-                    }
270
-                }
271
-            } else {
272
-                // no ticket quantities were selected
273
-                EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
274
-                    'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
275
-            }
276
-        }
277
-        //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
278
-        // at this point, just return if registration is being made from admin
279
-        if (is_admin()) {
280
-            return false;
281
-        }
282
-        if ($valid['return_url']) {
283
-            EE_Error::get_notices(false, true);
284
-            wp_safe_redirect($valid['return_url']);
285
-            exit();
286
-        } elseif (isset($event_to_add['id'])) {
287
-            EE_Error::get_notices(false, true);
288
-            wp_safe_redirect(get_permalink($event_to_add['id']));
289
-            exit();
290
-        } else {
291
-            echo EE_Error::get_notices();
292
-        }
293
-        return false;
294
-    }
114
+	/**
115
+	 * process_ticket_selections
116
+	 *
117
+	 * @return array|bool
118
+	 * @throws \ReflectionException
119
+	 * @throws InvalidArgumentException
120
+	 * @throws InvalidInterfaceException
121
+	 * @throws InvalidDataTypeException
122
+	 * @throws EE_Error
123
+	 */
124
+	public function processTicketSelections()
125
+	{
126
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
127
+		$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
128
+		if($request->isBot()) {
129
+			wp_safe_redirect(
130
+				apply_filters(
131
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
132
+					site_url()
133
+				)
134
+			);
135
+			exit();
136
+		}
137
+		// do we have an event id?
138
+		if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
139
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
140
+			EE_Error::add_error(
141
+				sprintf(
142
+					__(
143
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
144
+						'event_espresso'
145
+					),
146
+					'<br/>'
147
+				),
148
+				__FILE__,
149
+				__FUNCTION__,
150
+				__LINE__
151
+			);
152
+		}
153
+		//if event id is valid
154
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
155
+		//		d( \EE_Registry::instance()->REQ );
156
+		self::$_available_spaces = array(
157
+			'tickets'   => array(),
158
+			'datetimes' => array(),
159
+		);
160
+		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
161
+		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
162
+		EE_Registry::instance()->load_core('Session');
163
+		// unless otherwise requested, clear the session
164
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
165
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
166
+		}
167
+		//d( \EE_Registry::instance()->SSN );
168
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
169
+		// validate/sanitize data
170
+		$valid = $this->validatePostData($id);
171
+		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
172
+		//EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
173
+		//EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
174
+		//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
175
+		//check total tickets ordered vs max number of attendees that can register
176
+		if ($valid['total_tickets'] > $valid['max_atndz']) {
177
+			// ordering too many tickets !!!
178
+			$total_tickets_string = _n(
179
+				'You have attempted to purchase %s ticket.',
180
+				'You have attempted to purchase %s tickets.',
181
+				$valid['total_tickets'],
182
+				'event_espresso'
183
+			);
184
+			$limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
185
+			// dev only message
186
+			$max_atndz_string = _n(
187
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
188
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
189
+				$valid['max_atndz'],
190
+				'event_espresso'
191
+			);
192
+			$limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
+			EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
194
+		} else {
195
+			// all data appears to be valid
196
+			$tckts_slctd   = false;
197
+			$tickets_added = 0;
198
+			$valid         = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
199
+				$valid);
200
+			if ($valid['total_tickets'] > 0) {
201
+				// load cart
202
+				EE_Registry::instance()->load_core('Cart');
203
+				// cycle thru the number of data rows sent from the event listing
204
+				for ($x = 0; $x < $valid['rows']; $x++) {
205
+					// does this row actually contain a ticket quantity?
206
+					if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
207
+						// YES we have a ticket quantity
208
+						$tckts_slctd = true;
209
+						//						d( $valid['ticket_obj'][$x] );
210
+						if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
211
+							// then add ticket to cart
212
+							$tickets_added += $this->addTicketToCart(
213
+								$valid['ticket_obj'][ $x ],
214
+								$valid['qty'][ $x ]
215
+							);
216
+							if (EE_Error::has_error()) {
217
+								break;
218
+							}
219
+						} else {
220
+							// nothing added to cart retrieved
221
+							EE_Error::add_error(
222
+								sprintf(
223
+									__(
224
+										'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
225
+										'event_espresso'
226
+									),
227
+									'<br/>'
228
+								),
229
+								__FILE__, __FUNCTION__, __LINE__
230
+							);
231
+						}
232
+					}
233
+				}
234
+			}
235
+			do_action(
236
+				'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
237
+				EE_Registry::instance()->CART,
238
+				$this
239
+			);
240
+			//d( \EE_Registry::instance()->CART );
241
+			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
242
+			if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
243
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
244
+					do_action(
245
+						'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
246
+						EE_Registry::instance()->CART,
247
+						$this
248
+					);
249
+					EE_Registry::instance()->CART->recalculate_all_cart_totals();
250
+					EE_Registry::instance()->CART->save_cart(false);
251
+					// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
252
+					// just return TRUE for registrations being made from admin
253
+					if (is_admin()) {
254
+						return true;
255
+					}
256
+					EE_Error::get_notices(false, true);
257
+					wp_safe_redirect(
258
+						apply_filters(
259
+							'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
260
+							EE_Registry::instance()->CFG->core->reg_page_url()
261
+						)
262
+					);
263
+					exit();
264
+				} else {
265
+					if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
266
+						// nothing added to cart
267
+						EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
268
+							__FILE__, __FUNCTION__, __LINE__);
269
+					}
270
+				}
271
+			} else {
272
+				// no ticket quantities were selected
273
+				EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
274
+					'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
275
+			}
276
+		}
277
+		//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
278
+		// at this point, just return if registration is being made from admin
279
+		if (is_admin()) {
280
+			return false;
281
+		}
282
+		if ($valid['return_url']) {
283
+			EE_Error::get_notices(false, true);
284
+			wp_safe_redirect($valid['return_url']);
285
+			exit();
286
+		} elseif (isset($event_to_add['id'])) {
287
+			EE_Error::get_notices(false, true);
288
+			wp_safe_redirect(get_permalink($event_to_add['id']));
289
+			exit();
290
+		} else {
291
+			echo EE_Error::get_notices();
292
+		}
293
+		return false;
294
+	}
295 295
 
296 296
 
297
-    /**
298
-     * validate_post_data
299
-     *
300
-     * @param int $id
301
-     * @return array|FALSE
302
-     * @throws \ReflectionException
303
-     * @throws InvalidArgumentException
304
-     * @throws InvalidInterfaceException
305
-     * @throws InvalidDataTypeException
306
-     * @throws EE_Error
307
-     */
308
-    private function validatePostData($id = 0)
309
-    {
310
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
311
-        if (! $id) {
312
-            EE_Error::add_error(
313
-                __('The event id provided was not valid.', 'event_espresso'),
314
-                __FILE__,
315
-                __FUNCTION__,
316
-                __LINE__
317
-            );
318
-            return false;
319
-        }
320
-        // start with an empty array()
321
-        $valid_data = array();
322
-        // grab valid id
323
-        $valid_data['id'] = $id;
324
-        // array of other form names
325
-        $inputs_to_clean = array(
326
-            'event_id'   => 'tkt-slctr-event-id',
327
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
328
-            'rows'       => 'tkt-slctr-rows-',
329
-            'qty'        => 'tkt-slctr-qty-',
330
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
331
-            'return_url' => 'tkt-slctr-return-url-',
332
-        );
333
-        // let's track the total number of tickets ordered.'
334
-        $valid_data['total_tickets'] = 0;
335
-        // cycle through $inputs_to_clean array
336
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
337
-            // check for POST data
338
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
339
-                // grab value
340
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
341
-                switch ($what) {
342
-                    // integers
343
-                    case 'event_id':
344
-                        $valid_data[ $what ] = absint($input_value);
345
-                        // get event via the event id we put in the form
346
-                        $valid_data['event'] = EE_Registry::instance()
347
-                                                           ->load_model('Event')
348
-                                                           ->get_one_by_ID($valid_data['event_id']);
349
-                        break;
350
-                    case 'rows':
351
-                    case 'max_atndz':
352
-                        $valid_data[ $what ] = absint($input_value);
353
-                        break;
354
-                    // arrays of integers
355
-                    case 'qty':
356
-                        /** @var array $row_qty */
357
-                        $row_qty = $input_value;
358
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
359
-                        if (! is_array($row_qty)) {
360
-                            // get number of rows
361
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
362
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
363
-                                : 1;
364
-                            // explode ints by the dash
365
-                            $row_qty = explode('-', $row_qty);
366
-                            $row     = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
367
-                            $qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
368
-                            $row_qty = array($row => $qty);
369
-                            for ($x = 1; $x <= $rows; $x++) {
370
-                                if (! isset($row_qty[ $x ])) {
371
-                                    $row_qty[ $x ] = 0;
372
-                                }
373
-                            }
374
-                        }
375
-                        ksort($row_qty);
376
-                        // cycle thru values
377
-                        foreach ($row_qty as $qty) {
378
-                            $qty = absint($qty);
379
-                            // sanitize as integers
380
-                            $valid_data[ $what ][]       = $qty;
381
-                            $valid_data['total_tickets'] += $qty;
382
-                        }
383
-                        break;
384
-                    // array of integers
385
-                    case 'ticket_id':
386
-                        $value_array = array();
387
-                        // cycle thru values
388
-                        foreach ((array) $input_value as $key => $value) {
389
-                            // allow only numbers, letters,  spaces, commas and dashes
390
-                            $value_array[ $key ] = wp_strip_all_tags($value);
391
-                            // get ticket via the ticket id we put in the form
392
-                            $ticket_obj                       = EE_Registry::instance()
393
-                                                                            ->load_model('Ticket')
394
-                                                                            ->get_one_by_ID($value);
395
-                            $valid_data['ticket_obj'][ $key ] = $ticket_obj;
396
-                        }
397
-                        $valid_data[ $what ] = $value_array;
398
-                        break;
399
-                    case 'return_url' :
400
-                        // grab and sanitize return-url
401
-                        $input_value = esc_url_raw($input_value);
402
-                        // was the request coming from an iframe ? if so, then:
403
-                        if (strpos($input_value, 'event_list=iframe')) {
404
-                            // get anchor fragment
405
-                            $input_value = explode('#', $input_value);
406
-                            $input_value = end($input_value);
407
-                            // use event list url instead, but append anchor
408
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
409
-                        }
410
-                        $valid_data[ $what ] = $input_value;
411
-                        break;
412
-                }    // end switch $what
413
-            }
414
-        }    // end foreach $inputs_to_clean
415
-        return $valid_data;
416
-    }
297
+	/**
298
+	 * validate_post_data
299
+	 *
300
+	 * @param int $id
301
+	 * @return array|FALSE
302
+	 * @throws \ReflectionException
303
+	 * @throws InvalidArgumentException
304
+	 * @throws InvalidInterfaceException
305
+	 * @throws InvalidDataTypeException
306
+	 * @throws EE_Error
307
+	 */
308
+	private function validatePostData($id = 0)
309
+	{
310
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
311
+		if (! $id) {
312
+			EE_Error::add_error(
313
+				__('The event id provided was not valid.', 'event_espresso'),
314
+				__FILE__,
315
+				__FUNCTION__,
316
+				__LINE__
317
+			);
318
+			return false;
319
+		}
320
+		// start with an empty array()
321
+		$valid_data = array();
322
+		// grab valid id
323
+		$valid_data['id'] = $id;
324
+		// array of other form names
325
+		$inputs_to_clean = array(
326
+			'event_id'   => 'tkt-slctr-event-id',
327
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
328
+			'rows'       => 'tkt-slctr-rows-',
329
+			'qty'        => 'tkt-slctr-qty-',
330
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
331
+			'return_url' => 'tkt-slctr-return-url-',
332
+		);
333
+		// let's track the total number of tickets ordered.'
334
+		$valid_data['total_tickets'] = 0;
335
+		// cycle through $inputs_to_clean array
336
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
337
+			// check for POST data
338
+			if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
339
+				// grab value
340
+				$input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
341
+				switch ($what) {
342
+					// integers
343
+					case 'event_id':
344
+						$valid_data[ $what ] = absint($input_value);
345
+						// get event via the event id we put in the form
346
+						$valid_data['event'] = EE_Registry::instance()
347
+														   ->load_model('Event')
348
+														   ->get_one_by_ID($valid_data['event_id']);
349
+						break;
350
+					case 'rows':
351
+					case 'max_atndz':
352
+						$valid_data[ $what ] = absint($input_value);
353
+						break;
354
+					// arrays of integers
355
+					case 'qty':
356
+						/** @var array $row_qty */
357
+						$row_qty = $input_value;
358
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
359
+						if (! is_array($row_qty)) {
360
+							// get number of rows
361
+							$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
362
+								? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
363
+								: 1;
364
+							// explode ints by the dash
365
+							$row_qty = explode('-', $row_qty);
366
+							$row     = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
367
+							$qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
368
+							$row_qty = array($row => $qty);
369
+							for ($x = 1; $x <= $rows; $x++) {
370
+								if (! isset($row_qty[ $x ])) {
371
+									$row_qty[ $x ] = 0;
372
+								}
373
+							}
374
+						}
375
+						ksort($row_qty);
376
+						// cycle thru values
377
+						foreach ($row_qty as $qty) {
378
+							$qty = absint($qty);
379
+							// sanitize as integers
380
+							$valid_data[ $what ][]       = $qty;
381
+							$valid_data['total_tickets'] += $qty;
382
+						}
383
+						break;
384
+					// array of integers
385
+					case 'ticket_id':
386
+						$value_array = array();
387
+						// cycle thru values
388
+						foreach ((array) $input_value as $key => $value) {
389
+							// allow only numbers, letters,  spaces, commas and dashes
390
+							$value_array[ $key ] = wp_strip_all_tags($value);
391
+							// get ticket via the ticket id we put in the form
392
+							$ticket_obj                       = EE_Registry::instance()
393
+																			->load_model('Ticket')
394
+																			->get_one_by_ID($value);
395
+							$valid_data['ticket_obj'][ $key ] = $ticket_obj;
396
+						}
397
+						$valid_data[ $what ] = $value_array;
398
+						break;
399
+					case 'return_url' :
400
+						// grab and sanitize return-url
401
+						$input_value = esc_url_raw($input_value);
402
+						// was the request coming from an iframe ? if so, then:
403
+						if (strpos($input_value, 'event_list=iframe')) {
404
+							// get anchor fragment
405
+							$input_value = explode('#', $input_value);
406
+							$input_value = end($input_value);
407
+							// use event list url instead, but append anchor
408
+							$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
409
+						}
410
+						$valid_data[ $what ] = $input_value;
411
+						break;
412
+				}    // end switch $what
413
+			}
414
+		}    // end foreach $inputs_to_clean
415
+		return $valid_data;
416
+	}
417 417
 
418 418
 
419
-    /**
420
-     * adds a ticket to the cart
421
-     *
422
-     * @param EE_Ticket $ticket
423
-     * @param int        $qty
424
-     * @return TRUE on success, FALSE on fail
425
-     * @throws InvalidArgumentException
426
-     * @throws InvalidInterfaceException
427
-     * @throws InvalidDataTypeException
428
-     * @throws EE_Error
429
-     */
430
-    private function addTicketToCart(EE_Ticket $ticket = null, $qty = 1)
431
-    {
432
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
433
-        // get the number of spaces left for this datetime ticket
434
-        $available_spaces = $this->ticketDatetimeAvailability($ticket);
435
-        // compare available spaces against the number of tickets being purchased
436
-        if ($available_spaces >= $qty) {
437
-            // allow addons to prevent a ticket from being added to cart
438
-            if (
439
-            ! apply_filters(
440
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
441
-                true,
442
-                $ticket,
443
-                $qty,
444
-                $available_spaces
445
-            )
446
-            ) {
447
-                return false;
448
-            }
449
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
450
-            // add event to cart
451
-            if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
452
-                $this->recalculateTicketDatetimeAvailability($ticket, $qty);
453
-                return true;
454
-            }
455
-            return false;
456
-        }
457
-        // tickets can not be purchased but let's find the exact number left
458
-        // for the last ticket selected PRIOR to subtracting tickets
459
-        $available_spaces = $this->ticketDatetimeAvailability($ticket, true);
460
-        // greedy greedy greedy eh?
461
-        if ($available_spaces > 0) {
462
-            if (
463
-            apply_filters(
464
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
465
-                true,
466
-                $ticket,
467
-                $qty,
468
-                $available_spaces
469
-            )
470
-            ) {
471
-                $this->displayAvailabilityError($available_spaces);
472
-            }
473
-        } else {
474
-            EE_Error::add_error(
475
-                __(
476
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
477
-                    'event_espresso'
478
-                ),
479
-                __FILE__, __FUNCTION__, __LINE__
480
-            );
481
-        }
482
-        return false;
483
-    }
419
+	/**
420
+	 * adds a ticket to the cart
421
+	 *
422
+	 * @param EE_Ticket $ticket
423
+	 * @param int        $qty
424
+	 * @return TRUE on success, FALSE on fail
425
+	 * @throws InvalidArgumentException
426
+	 * @throws InvalidInterfaceException
427
+	 * @throws InvalidDataTypeException
428
+	 * @throws EE_Error
429
+	 */
430
+	private function addTicketToCart(EE_Ticket $ticket = null, $qty = 1)
431
+	{
432
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
433
+		// get the number of spaces left for this datetime ticket
434
+		$available_spaces = $this->ticketDatetimeAvailability($ticket);
435
+		// compare available spaces against the number of tickets being purchased
436
+		if ($available_spaces >= $qty) {
437
+			// allow addons to prevent a ticket from being added to cart
438
+			if (
439
+			! apply_filters(
440
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
441
+				true,
442
+				$ticket,
443
+				$qty,
444
+				$available_spaces
445
+			)
446
+			) {
447
+				return false;
448
+			}
449
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
450
+			// add event to cart
451
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
452
+				$this->recalculateTicketDatetimeAvailability($ticket, $qty);
453
+				return true;
454
+			}
455
+			return false;
456
+		}
457
+		// tickets can not be purchased but let's find the exact number left
458
+		// for the last ticket selected PRIOR to subtracting tickets
459
+		$available_spaces = $this->ticketDatetimeAvailability($ticket, true);
460
+		// greedy greedy greedy eh?
461
+		if ($available_spaces > 0) {
462
+			if (
463
+			apply_filters(
464
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
465
+				true,
466
+				$ticket,
467
+				$qty,
468
+				$available_spaces
469
+			)
470
+			) {
471
+				$this->displayAvailabilityError($available_spaces);
472
+			}
473
+		} else {
474
+			EE_Error::add_error(
475
+				__(
476
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
477
+					'event_espresso'
478
+				),
479
+				__FILE__, __FUNCTION__, __LINE__
480
+			);
481
+		}
482
+		return false;
483
+	}
484 484
 
485 485
 
486
-    /**
487
-     * @param int $available_spaces
488
-     * @throws InvalidArgumentException
489
-     * @throws InvalidInterfaceException
490
-     * @throws InvalidDataTypeException
491
-     * @throws EE_Error
492
-     */
493
-    private function displayAvailabilityError($available_spaces = 1)
494
-    {
495
-        // add error messaging - we're using the _n function that will generate
496
-        // the appropriate singular or plural message based on the number of $available_spaces
497
-        if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
498
-            $msg = sprintf(
499
-                _n(
500
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
501
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
502
-                    $available_spaces,
503
-                    'event_espresso'
504
-                ),
505
-                $available_spaces,
506
-                '<br />'
507
-            );
508
-        } else {
509
-            $msg = sprintf(
510
-                _n(
511
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
512
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
513
-                    $available_spaces,
514
-                    'event_espresso'
515
-                ),
516
-                $available_spaces,
517
-                '<br />'
518
-            );
519
-        }
520
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
521
-    }
486
+	/**
487
+	 * @param int $available_spaces
488
+	 * @throws InvalidArgumentException
489
+	 * @throws InvalidInterfaceException
490
+	 * @throws InvalidDataTypeException
491
+	 * @throws EE_Error
492
+	 */
493
+	private function displayAvailabilityError($available_spaces = 1)
494
+	{
495
+		// add error messaging - we're using the _n function that will generate
496
+		// the appropriate singular or plural message based on the number of $available_spaces
497
+		if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
498
+			$msg = sprintf(
499
+				_n(
500
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
501
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
502
+					$available_spaces,
503
+					'event_espresso'
504
+				),
505
+				$available_spaces,
506
+				'<br />'
507
+			);
508
+		} else {
509
+			$msg = sprintf(
510
+				_n(
511
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
512
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
513
+					$available_spaces,
514
+					'event_espresso'
515
+				),
516
+				$available_spaces,
517
+				'<br />'
518
+			);
519
+		}
520
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
521
+	}
522 522
 
523 523
 
524
-    /**
525
-     * ticketDatetimeAvailability
526
-     * creates an array of tickets plus all of the datetimes available to each ticket
527
-     * and tracks the spaces remaining for each of those datetimes
528
-     *
529
-     * @param EE_Ticket $ticket - selected ticket
530
-     * @param bool      $get_original_ticket_spaces
531
-     * @return int
532
-     * @throws InvalidArgumentException
533
-     * @throws InvalidInterfaceException
534
-     * @throws InvalidDataTypeException
535
-     * @throws EE_Error
536
-     */
537
-    private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
538
-    {
539
-        // if the $_available_spaces array has not been set up yet...
540
-        if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
541
-            $this->setInitialTicketDatetimeAvailability($ticket);
542
-        }
543
-        $available_spaces = $ticket->qty() - $ticket->sold();
544
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
545
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
546
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
547
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
548
-                if ($get_original_ticket_spaces) {
549
-                    // then grab the available spaces from the "tickets" array
550
-                    // and compare with the above to get the lowest number
551
-                    $available_spaces = min(
552
-                        $available_spaces,
553
-                        self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
554
-                    );
555
-                } else {
556
-                    // we want the updated ticket availability as stored in the "datetimes" array
557
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
558
-                }
559
-            }
560
-        }
561
-        return $available_spaces;
562
-    }
524
+	/**
525
+	 * ticketDatetimeAvailability
526
+	 * creates an array of tickets plus all of the datetimes available to each ticket
527
+	 * and tracks the spaces remaining for each of those datetimes
528
+	 *
529
+	 * @param EE_Ticket $ticket - selected ticket
530
+	 * @param bool      $get_original_ticket_spaces
531
+	 * @return int
532
+	 * @throws InvalidArgumentException
533
+	 * @throws InvalidInterfaceException
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws EE_Error
536
+	 */
537
+	private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
538
+	{
539
+		// if the $_available_spaces array has not been set up yet...
540
+		if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
541
+			$this->setInitialTicketDatetimeAvailability($ticket);
542
+		}
543
+		$available_spaces = $ticket->qty() - $ticket->sold();
544
+		if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
545
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
546
+			foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
547
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
548
+				if ($get_original_ticket_spaces) {
549
+					// then grab the available spaces from the "tickets" array
550
+					// and compare with the above to get the lowest number
551
+					$available_spaces = min(
552
+						$available_spaces,
553
+						self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
554
+					);
555
+				} else {
556
+					// we want the updated ticket availability as stored in the "datetimes" array
557
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
558
+				}
559
+			}
560
+		}
561
+		return $available_spaces;
562
+	}
563 563
 
564 564
 
565
-    /**
566
-     * @param EE_Ticket $ticket
567
-     * @return void
568
-     * @throws InvalidArgumentException
569
-     * @throws InvalidInterfaceException
570
-     * @throws InvalidDataTypeException
571
-     * @throws EE_Error
572
-     */
573
-    private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
574
-    {
575
-        // first, get all of the datetimes that are available to this ticket
576
-        $datetimes = $ticket->get_many_related(
577
-            'Datetime',
578
-            array(
579
-                array(
580
-                    'DTT_EVT_end' => array(
581
-                        '>=',
582
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
583
-                    ),
584
-                ),
585
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
586
-            )
587
-        );
588
-        if (! empty($datetimes)) {
589
-            // now loop thru all of the datetimes
590
-            foreach ($datetimes as $datetime) {
591
-                if ($datetime instanceof EE_Datetime) {
592
-                    // the number of spaces available for the datetime without considering individual ticket quantities
593
-                    $spaces_remaining = $datetime->spaces_remaining();
594
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
595
-                    // or the datetime spaces remaining) to this ticket using the datetime ID as the key
596
-                    self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
597
-                        $ticket->qty() - $ticket->sold(),
598
-                        $spaces_remaining
599
-                    );
600
-                    // if the remaining spaces for this datetime is already set,
601
-                    // then compare that against the datetime spaces remaining, and take the lowest number,
602
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
603
-                    self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
604
-                        self::$_available_spaces['datetimes'][ $datetime->ID() ]
605
-                    )
606
-                        ? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
607
-                        : $spaces_remaining;
608
-                }
609
-            }
610
-        }
611
-    }
565
+	/**
566
+	 * @param EE_Ticket $ticket
567
+	 * @return void
568
+	 * @throws InvalidArgumentException
569
+	 * @throws InvalidInterfaceException
570
+	 * @throws InvalidDataTypeException
571
+	 * @throws EE_Error
572
+	 */
573
+	private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
574
+	{
575
+		// first, get all of the datetimes that are available to this ticket
576
+		$datetimes = $ticket->get_many_related(
577
+			'Datetime',
578
+			array(
579
+				array(
580
+					'DTT_EVT_end' => array(
581
+						'>=',
582
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
583
+					),
584
+				),
585
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
586
+			)
587
+		);
588
+		if (! empty($datetimes)) {
589
+			// now loop thru all of the datetimes
590
+			foreach ($datetimes as $datetime) {
591
+				if ($datetime instanceof EE_Datetime) {
592
+					// the number of spaces available for the datetime without considering individual ticket quantities
593
+					$spaces_remaining = $datetime->spaces_remaining();
594
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
595
+					// or the datetime spaces remaining) to this ticket using the datetime ID as the key
596
+					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
597
+						$ticket->qty() - $ticket->sold(),
598
+						$spaces_remaining
599
+					);
600
+					// if the remaining spaces for this datetime is already set,
601
+					// then compare that against the datetime spaces remaining, and take the lowest number,
602
+					// else just take the datetime spaces remaining, and assign to the datetimes array
603
+					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
604
+						self::$_available_spaces['datetimes'][ $datetime->ID() ]
605
+					)
606
+						? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
607
+						: $spaces_remaining;
608
+				}
609
+			}
610
+		}
611
+	}
612 612
 
613 613
 
614
-    /**
615
-     * @param    EE_Ticket $ticket
616
-     * @param    int        $qty
617
-     * @return    void
618
-     * @throws EE_Error
619
-     */
620
-    private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
621
-    {
622
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
623
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
624
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
625
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
626
-                self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
627
-            }
628
-        }
629
-    }
614
+	/**
615
+	 * @param    EE_Ticket $ticket
616
+	 * @param    int        $qty
617
+	 * @return    void
618
+	 * @throws EE_Error
619
+	 */
620
+	private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
621
+	{
622
+		if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
623
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
624
+			foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
625
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
626
+				self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
627
+			}
628
+		}
629
+	}
630 630
 }
631 631
 // End of file ProcessTicketSelector.php
632 632
 // Location: /ProcessTicketSelector.php
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use EventEspresso\core\services\loaders\LoaderFactory;
14 14
 use InvalidArgumentException;
15 15
 
16
-if (! defined('EVENT_ESPRESSO_VERSION')) {
16
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
17 17
     exit('No direct script access allowed');
18 18
 }
19 19
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function cancelTicketSelections()
52 52
     {
53 53
         // check nonce
54
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
54
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
55 55
             return false;
56 56
         }
57 57
         EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             );
64 64
         } else {
65 65
             wp_safe_redirect(
66
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
66
+                site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/')
67 67
             );
68 68
         }
69 69
         exit();
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         do_action('EED_Ticket_Selector__process_ticket_selections__before');
127 127
         $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
128
-        if($request->isBot()) {
128
+        if ($request->isBot()) {
129 129
             wp_safe_redirect(
130 130
                 apply_filters(
131 131
                     'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             exit();
136 136
         }
137 137
         // do we have an event id?
138
-        if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
138
+        if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
139 139
             // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
140 140
             EE_Error::add_error(
141 141
                 sprintf(
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                 $valid['total_tickets'],
182 182
                 'event_espresso'
183 183
             );
184
-            $limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
184
+            $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
185 185
             // dev only message
186 186
             $max_atndz_string = _n(
187 187
                 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
                 $valid['max_atndz'],
190 190
                 'event_espresso'
191 191
             );
192
-            $limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
192
+            $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
+            EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
194 194
         } else {
195 195
             // all data appears to be valid
196 196
             $tckts_slctd   = false;
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
                 // cycle thru the number of data rows sent from the event listing
204 204
                 for ($x = 0; $x < $valid['rows']; $x++) {
205 205
                     // does this row actually contain a ticket quantity?
206
-                    if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
206
+                    if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
207 207
                         // YES we have a ticket quantity
208 208
                         $tckts_slctd = true;
209 209
                         //						d( $valid['ticket_obj'][$x] );
210
-                        if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
210
+                        if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
211 211
                             // then add ticket to cart
212 212
                             $tickets_added += $this->addTicketToCart(
213
-                                $valid['ticket_obj'][ $x ],
214
-                                $valid['qty'][ $x ]
213
+                                $valid['ticket_obj'][$x],
214
+                                $valid['qty'][$x]
215 215
                             );
216 216
                             if (EE_Error::has_error()) {
217 217
                                 break;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                     );
263 263
                     exit();
264 264
                 } else {
265
-                    if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
265
+                    if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
266 266
                         // nothing added to cart
267 267
                         EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
268 268
                             __FILE__, __FUNCTION__, __LINE__);
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     private function validatePostData($id = 0)
309 309
     {
310 310
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
311
-        if (! $id) {
311
+        if ( ! $id) {
312 312
             EE_Error::add_error(
313 313
                 __('The event id provided was not valid.', 'event_espresso'),
314 314
                 __FILE__,
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
         // cycle through $inputs_to_clean array
336 336
         foreach ($inputs_to_clean as $what => $input_to_clean) {
337 337
             // check for POST data
338
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
338
+            if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
339 339
                 // grab value
340
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
340
+                $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
341 341
                 switch ($what) {
342 342
                     // integers
343 343
                     case 'event_id':
344
-                        $valid_data[ $what ] = absint($input_value);
344
+                        $valid_data[$what] = absint($input_value);
345 345
                         // get event via the event id we put in the form
346 346
                         $valid_data['event'] = EE_Registry::instance()
347 347
                                                            ->load_model('Event')
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
                         break;
350 350
                     case 'rows':
351 351
                     case 'max_atndz':
352
-                        $valid_data[ $what ] = absint($input_value);
352
+                        $valid_data[$what] = absint($input_value);
353 353
                         break;
354 354
                     // arrays of integers
355 355
                     case 'qty':
356 356
                         /** @var array $row_qty */
357 357
                         $row_qty = $input_value;
358 358
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
359
-                        if (! is_array($row_qty)) {
359
+                        if ( ! is_array($row_qty)) {
360 360
                             // get number of rows
361
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
362
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
361
+                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id)
362
+                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id))
363 363
                                 : 1;
364 364
                             // explode ints by the dash
365 365
                             $row_qty = explode('-', $row_qty);
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
                             $qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
368 368
                             $row_qty = array($row => $qty);
369 369
                             for ($x = 1; $x <= $rows; $x++) {
370
-                                if (! isset($row_qty[ $x ])) {
371
-                                    $row_qty[ $x ] = 0;
370
+                                if ( ! isset($row_qty[$x])) {
371
+                                    $row_qty[$x] = 0;
372 372
                                 }
373 373
                             }
374 374
                         }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
                         foreach ($row_qty as $qty) {
378 378
                             $qty = absint($qty);
379 379
                             // sanitize as integers
380
-                            $valid_data[ $what ][]       = $qty;
380
+                            $valid_data[$what][] = $qty;
381 381
                             $valid_data['total_tickets'] += $qty;
382 382
                         }
383 383
                         break;
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
                         // cycle thru values
388 388
                         foreach ((array) $input_value as $key => $value) {
389 389
                             // allow only numbers, letters,  spaces, commas and dashes
390
-                            $value_array[ $key ] = wp_strip_all_tags($value);
390
+                            $value_array[$key] = wp_strip_all_tags($value);
391 391
                             // get ticket via the ticket id we put in the form
392 392
                             $ticket_obj                       = EE_Registry::instance()
393 393
                                                                             ->load_model('Ticket')
394 394
                                                                             ->get_one_by_ID($value);
395
-                            $valid_data['ticket_obj'][ $key ] = $ticket_obj;
395
+                            $valid_data['ticket_obj'][$key] = $ticket_obj;
396 396
                         }
397
-                        $valid_data[ $what ] = $value_array;
397
+                        $valid_data[$what] = $value_array;
398 398
                         break;
399 399
                     case 'return_url' :
400 400
                         // grab and sanitize return-url
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
                             $input_value = explode('#', $input_value);
406 406
                             $input_value = end($input_value);
407 407
                             // use event list url instead, but append anchor
408
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
408
+                            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
409 409
                         }
410
-                        $valid_data[ $what ] = $input_value;
410
+                        $valid_data[$what] = $input_value;
411 411
                         break;
412 412
                 }    // end switch $what
413 413
             }
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
     private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
538 538
     {
539 539
         // if the $_available_spaces array has not been set up yet...
540
-        if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
540
+        if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
541 541
             $this->setInitialTicketDatetimeAvailability($ticket);
542 542
         }
543 543
         $available_spaces = $ticket->qty() - $ticket->sold();
544
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
544
+        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
545 545
             // loop thru tickets, which will ALSO include individual ticket records AND a total
546
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
546
+            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
547 547
                 // if we want the original datetime availability BEFORE we started subtracting tickets ?
548 548
                 if ($get_original_ticket_spaces) {
549 549
                     // then grab the available spaces from the "tickets" array
550 550
                     // and compare with the above to get the lowest number
551 551
                     $available_spaces = min(
552 552
                         $available_spaces,
553
-                        self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
553
+                        self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]
554 554
                     );
555 555
                 } else {
556 556
                     // we want the updated ticket availability as stored in the "datetimes" array
557
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
557
+                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
558 558
                 }
559 559
             }
560 560
         }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                 'order_by' => array('DTT_EVT_start' => 'ASC'),
586 586
             )
587 587
         );
588
-        if (! empty($datetimes)) {
588
+        if ( ! empty($datetimes)) {
589 589
             // now loop thru all of the datetimes
590 590
             foreach ($datetimes as $datetime) {
591 591
                 if ($datetime instanceof EE_Datetime) {
@@ -593,17 +593,17 @@  discard block
 block discarded – undo
593 593
                     $spaces_remaining = $datetime->spaces_remaining();
594 594
                     // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
595 595
                     // or the datetime spaces remaining) to this ticket using the datetime ID as the key
596
-                    self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
596
+                    self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
597 597
                         $ticket->qty() - $ticket->sold(),
598 598
                         $spaces_remaining
599 599
                     );
600 600
                     // if the remaining spaces for this datetime is already set,
601 601
                     // then compare that against the datetime spaces remaining, and take the lowest number,
602 602
                     // else just take the datetime spaces remaining, and assign to the datetimes array
603
-                    self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
604
-                        self::$_available_spaces['datetimes'][ $datetime->ID() ]
603
+                    self::$_available_spaces['datetimes'][$datetime->ID()] = isset(
604
+                        self::$_available_spaces['datetimes'][$datetime->ID()]
605 605
                     )
606
-                        ? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
606
+                        ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
607 607
                         : $spaces_remaining;
608 608
                 }
609 609
             }
@@ -619,11 +619,11 @@  discard block
 block discarded – undo
619 619
      */
620 620
     private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
621 621
     {
622
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
622
+        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
623 623
             // loop thru tickets, which will ALSO include individual ticket records AND a total
624
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
624
+            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
625 625
                 // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
626
-                self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
626
+                self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
627 627
             }
628 628
         }
629 629
     }
Please login to merge, or discard this patch.
core/EE_Error.core.php 1 patch
Indentation   +1030 added lines, -1030 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 // if you're a dev and want to receive all errors via email
12 12
 // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
13 13
 if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) {
14
-    set_error_handler(array('EE_Error', 'error_handler'));
15
-    register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
14
+	set_error_handler(array('EE_Error', 'error_handler'));
15
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
16 16
 }
17 17
 
18 18
 
@@ -27,256 +27,256 @@  discard block
 block discarded – undo
27 27
 class EE_Error extends Exception
28 28
 {
29 29
 
30
-    const OPTIONS_KEY_NOTICES = 'ee_notices';
31
-
32
-
33
-    /**
34
-     * name of the file to log exceptions to
35
-     *
36
-     * @var string
37
-     */
38
-    private static $_exception_log_file = 'espresso_error_log.txt';
39
-
40
-    /**
41
-     *    stores details for all exception
42
-     *
43
-     * @var array
44
-     */
45
-    private static $_all_exceptions = array();
46
-
47
-    /**
48
-     *    tracks number of errors
49
-     *
50
-     * @var int
51
-     */
52
-    private static $_error_count = 0;
53
-
54
-    /**
55
-     * @var array $_espresso_notices
56
-     */
57
-    private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
58
-
59
-
60
-
61
-    /**
62
-     * @override default exception handling
63
-     * @param string         $message
64
-     * @param int            $code
65
-     * @param Exception|null $previous
66
-     */
67
-    public function __construct($message, $code = 0, Exception $previous = null)
68
-    {
69
-        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
70
-            parent::__construct($message, $code);
71
-        } else {
72
-            parent::__construct($message, $code, $previous);
73
-        }
74
-    }
75
-
76
-
77
-
78
-    /**
79
-     *    error_handler
80
-     *
81
-     * @param $code
82
-     * @param $message
83
-     * @param $file
84
-     * @param $line
85
-     * @return void
86
-     */
87
-    public static function error_handler($code, $message, $file, $line)
88
-    {
89
-        $type = EE_Error::error_type($code);
90
-        $site = site_url();
91
-        switch ($site) {
92
-            case 'http://ee4.eventespresso.com/' :
93
-            case 'http://ee4decaf.eventespresso.com/' :
94
-            case 'http://ee4hf.eventespresso.com/' :
95
-            case 'http://ee4a.eventespresso.com/' :
96
-            case 'http://ee4ad.eventespresso.com/' :
97
-            case 'http://ee4b.eventespresso.com/' :
98
-            case 'http://ee4bd.eventespresso.com/' :
99
-            case 'http://ee4d.eventespresso.com/' :
100
-            case 'http://ee4dd.eventespresso.com/' :
101
-                $to = '[email protected]';
102
-                break;
103
-            default :
104
-                $to = get_option('admin_email');
105
-        }
106
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
107
-        $msg = EE_Error::_format_error($type, $message, $file, $line);
108
-        if (function_exists('wp_mail')) {
109
-            add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
110
-            wp_mail($to, $subject, $msg);
111
-        }
112
-        echo '<div id="message" class="espresso-notices error"><p>';
113
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
114
-        echo '<br /></p></div>';
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * error_type
121
-     * http://www.php.net/manual/en/errorfunc.constants.php#109430
122
-     *
123
-     * @param $code
124
-     * @return string
125
-     */
126
-    public static function error_type($code)
127
-    {
128
-        switch ($code) {
129
-            case E_ERROR: // 1 //
130
-                return 'E_ERROR';
131
-            case E_WARNING: // 2 //
132
-                return 'E_WARNING';
133
-            case E_PARSE: // 4 //
134
-                return 'E_PARSE';
135
-            case E_NOTICE: // 8 //
136
-                return 'E_NOTICE';
137
-            case E_CORE_ERROR: // 16 //
138
-                return 'E_CORE_ERROR';
139
-            case E_CORE_WARNING: // 32 //
140
-                return 'E_CORE_WARNING';
141
-            case E_COMPILE_ERROR: // 64 //
142
-                return 'E_COMPILE_ERROR';
143
-            case E_COMPILE_WARNING: // 128 //
144
-                return 'E_COMPILE_WARNING';
145
-            case E_USER_ERROR: // 256 //
146
-                return 'E_USER_ERROR';
147
-            case E_USER_WARNING: // 512 //
148
-                return 'E_USER_WARNING';
149
-            case E_USER_NOTICE: // 1024 //
150
-                return 'E_USER_NOTICE';
151
-            case E_STRICT: // 2048 //
152
-                return 'E_STRICT';
153
-            case E_RECOVERABLE_ERROR: // 4096 //
154
-                return 'E_RECOVERABLE_ERROR';
155
-            case E_DEPRECATED: // 8192 //
156
-                return 'E_DEPRECATED';
157
-            case E_USER_DEPRECATED: // 16384 //
158
-                return 'E_USER_DEPRECATED';
159
-            case E_ALL: // 16384 //
160
-                return 'E_ALL';
161
-        }
162
-        return '';
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     *    fatal_error_handler
169
-     *
170
-     * @return void
171
-     */
172
-    public static function fatal_error_handler()
173
-    {
174
-        $last_error = error_get_last();
175
-        if ($last_error['type'] === E_ERROR) {
176
-            EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
177
-        }
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     * _format_error
184
-     *
185
-     * @param $code
186
-     * @param $message
187
-     * @param $file
188
-     * @param $line
189
-     * @return string
190
-     */
191
-    private static function _format_error($code, $message, $file, $line)
192
-    {
193
-        $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
194
-        $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
195
-        $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
196
-        $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
197
-        $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
198
-        $html .= '</tbody></table>';
199
-        return $html;
200
-    }
201
-
202
-
203
-
204
-    /**
205
-     * set_content_type
206
-     *
207
-     * @param $content_type
208
-     * @return string
209
-     */
210
-    public static function set_content_type($content_type)
211
-    {
212
-        return 'text/html';
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * @return void
219
-     * @throws EE_Error
220
-     * @throws ReflectionException
221
-     */
222
-    public function get_error()
223
-    {
224
-        if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
225
-            throw $this;
226
-        }
227
-        // get separate user and developer messages if they exist
228
-        $msg = explode('||', $this->getMessage());
229
-        $user_msg = $msg[0];
230
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
231
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
232
-        // add details to _all_exceptions array
233
-        $x_time = time();
234
-        self::$_all_exceptions[$x_time]['name'] = get_class($this);
235
-        self::$_all_exceptions[$x_time]['file'] = $this->getFile();
236
-        self::$_all_exceptions[$x_time]['line'] = $this->getLine();
237
-        self::$_all_exceptions[$x_time]['msg'] = $msg;
238
-        self::$_all_exceptions[$x_time]['code'] = $this->getCode();
239
-        self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
240
-        self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
241
-        self::$_error_count++;
242
-        //add_action( 'shutdown', array( $this, 'display_errors' ));
243
-        $this->display_errors();
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     * @param bool   $check_stored
250
-     * @param string $type_to_check
251
-     * @return bool
252
-     */
253
-    public static function has_error($check_stored = false, $type_to_check = 'errors')
254
-    {
255
-        $has_error = isset(self::$_espresso_notices[$type_to_check])
256
-                     && ! empty(self::$_espresso_notices[$type_to_check])
257
-            ? true
258
-            : false;
259
-        if ($check_stored && ! $has_error) {
260
-            $notices = (array)get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
261
-            foreach ($notices as $type => $notice) {
262
-                if ($type === $type_to_check && $notice) {
263
-                    return true;
264
-                }
265
-            }
266
-        }
267
-        return $has_error;
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * @echo string
274
-     * @throws \ReflectionException
275
-     */
276
-    public function display_errors()
277
-    {
278
-        $trace_details = '';
279
-        $output = '
30
+	const OPTIONS_KEY_NOTICES = 'ee_notices';
31
+
32
+
33
+	/**
34
+	 * name of the file to log exceptions to
35
+	 *
36
+	 * @var string
37
+	 */
38
+	private static $_exception_log_file = 'espresso_error_log.txt';
39
+
40
+	/**
41
+	 *    stores details for all exception
42
+	 *
43
+	 * @var array
44
+	 */
45
+	private static $_all_exceptions = array();
46
+
47
+	/**
48
+	 *    tracks number of errors
49
+	 *
50
+	 * @var int
51
+	 */
52
+	private static $_error_count = 0;
53
+
54
+	/**
55
+	 * @var array $_espresso_notices
56
+	 */
57
+	private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
58
+
59
+
60
+
61
+	/**
62
+	 * @override default exception handling
63
+	 * @param string         $message
64
+	 * @param int            $code
65
+	 * @param Exception|null $previous
66
+	 */
67
+	public function __construct($message, $code = 0, Exception $previous = null)
68
+	{
69
+		if (version_compare(PHP_VERSION, '5.3.0', '<')) {
70
+			parent::__construct($message, $code);
71
+		} else {
72
+			parent::__construct($message, $code, $previous);
73
+		}
74
+	}
75
+
76
+
77
+
78
+	/**
79
+	 *    error_handler
80
+	 *
81
+	 * @param $code
82
+	 * @param $message
83
+	 * @param $file
84
+	 * @param $line
85
+	 * @return void
86
+	 */
87
+	public static function error_handler($code, $message, $file, $line)
88
+	{
89
+		$type = EE_Error::error_type($code);
90
+		$site = site_url();
91
+		switch ($site) {
92
+			case 'http://ee4.eventespresso.com/' :
93
+			case 'http://ee4decaf.eventespresso.com/' :
94
+			case 'http://ee4hf.eventespresso.com/' :
95
+			case 'http://ee4a.eventespresso.com/' :
96
+			case 'http://ee4ad.eventespresso.com/' :
97
+			case 'http://ee4b.eventespresso.com/' :
98
+			case 'http://ee4bd.eventespresso.com/' :
99
+			case 'http://ee4d.eventespresso.com/' :
100
+			case 'http://ee4dd.eventespresso.com/' :
101
+				$to = '[email protected]';
102
+				break;
103
+			default :
104
+				$to = get_option('admin_email');
105
+		}
106
+		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
107
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
108
+		if (function_exists('wp_mail')) {
109
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
110
+			wp_mail($to, $subject, $msg);
111
+		}
112
+		echo '<div id="message" class="espresso-notices error"><p>';
113
+		echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
114
+		echo '<br /></p></div>';
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * error_type
121
+	 * http://www.php.net/manual/en/errorfunc.constants.php#109430
122
+	 *
123
+	 * @param $code
124
+	 * @return string
125
+	 */
126
+	public static function error_type($code)
127
+	{
128
+		switch ($code) {
129
+			case E_ERROR: // 1 //
130
+				return 'E_ERROR';
131
+			case E_WARNING: // 2 //
132
+				return 'E_WARNING';
133
+			case E_PARSE: // 4 //
134
+				return 'E_PARSE';
135
+			case E_NOTICE: // 8 //
136
+				return 'E_NOTICE';
137
+			case E_CORE_ERROR: // 16 //
138
+				return 'E_CORE_ERROR';
139
+			case E_CORE_WARNING: // 32 //
140
+				return 'E_CORE_WARNING';
141
+			case E_COMPILE_ERROR: // 64 //
142
+				return 'E_COMPILE_ERROR';
143
+			case E_COMPILE_WARNING: // 128 //
144
+				return 'E_COMPILE_WARNING';
145
+			case E_USER_ERROR: // 256 //
146
+				return 'E_USER_ERROR';
147
+			case E_USER_WARNING: // 512 //
148
+				return 'E_USER_WARNING';
149
+			case E_USER_NOTICE: // 1024 //
150
+				return 'E_USER_NOTICE';
151
+			case E_STRICT: // 2048 //
152
+				return 'E_STRICT';
153
+			case E_RECOVERABLE_ERROR: // 4096 //
154
+				return 'E_RECOVERABLE_ERROR';
155
+			case E_DEPRECATED: // 8192 //
156
+				return 'E_DEPRECATED';
157
+			case E_USER_DEPRECATED: // 16384 //
158
+				return 'E_USER_DEPRECATED';
159
+			case E_ALL: // 16384 //
160
+				return 'E_ALL';
161
+		}
162
+		return '';
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 *    fatal_error_handler
169
+	 *
170
+	 * @return void
171
+	 */
172
+	public static function fatal_error_handler()
173
+	{
174
+		$last_error = error_get_last();
175
+		if ($last_error['type'] === E_ERROR) {
176
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
177
+		}
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 * _format_error
184
+	 *
185
+	 * @param $code
186
+	 * @param $message
187
+	 * @param $file
188
+	 * @param $line
189
+	 * @return string
190
+	 */
191
+	private static function _format_error($code, $message, $file, $line)
192
+	{
193
+		$html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
194
+		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
195
+		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
196
+		$html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
197
+		$html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
198
+		$html .= '</tbody></table>';
199
+		return $html;
200
+	}
201
+
202
+
203
+
204
+	/**
205
+	 * set_content_type
206
+	 *
207
+	 * @param $content_type
208
+	 * @return string
209
+	 */
210
+	public static function set_content_type($content_type)
211
+	{
212
+		return 'text/html';
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * @return void
219
+	 * @throws EE_Error
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function get_error()
223
+	{
224
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
225
+			throw $this;
226
+		}
227
+		// get separate user and developer messages if they exist
228
+		$msg = explode('||', $this->getMessage());
229
+		$user_msg = $msg[0];
230
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
231
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
232
+		// add details to _all_exceptions array
233
+		$x_time = time();
234
+		self::$_all_exceptions[$x_time]['name'] = get_class($this);
235
+		self::$_all_exceptions[$x_time]['file'] = $this->getFile();
236
+		self::$_all_exceptions[$x_time]['line'] = $this->getLine();
237
+		self::$_all_exceptions[$x_time]['msg'] = $msg;
238
+		self::$_all_exceptions[$x_time]['code'] = $this->getCode();
239
+		self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
240
+		self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
241
+		self::$_error_count++;
242
+		//add_action( 'shutdown', array( $this, 'display_errors' ));
243
+		$this->display_errors();
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 * @param bool   $check_stored
250
+	 * @param string $type_to_check
251
+	 * @return bool
252
+	 */
253
+	public static function has_error($check_stored = false, $type_to_check = 'errors')
254
+	{
255
+		$has_error = isset(self::$_espresso_notices[$type_to_check])
256
+					 && ! empty(self::$_espresso_notices[$type_to_check])
257
+			? true
258
+			: false;
259
+		if ($check_stored && ! $has_error) {
260
+			$notices = (array)get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
261
+			foreach ($notices as $type => $notice) {
262
+				if ($type === $type_to_check && $notice) {
263
+					return true;
264
+				}
265
+			}
266
+		}
267
+		return $has_error;
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * @echo string
274
+	 * @throws \ReflectionException
275
+	 */
276
+	public function display_errors()
277
+	{
278
+		$trace_details = '';
279
+		$output = '
280 280
 <style type="text/css">
281 281
 	#ee-error-message {
282 282
 		max-width:90% !important;
@@ -332,21 +332,21 @@  discard block
 block discarded – undo
332 332
 	}
333 333
 </style>
334 334
 <div id="ee-error-message" class="error">';
335
-        if (! WP_DEBUG) {
336
-            $output .= '
335
+		if (! WP_DEBUG) {
336
+			$output .= '
337 337
 	<p>';
338
-        }
339
-        // cycle thru errors
340
-        foreach (self::$_all_exceptions as $time => $ex) {
341
-            $error_code = '';
342
-            // process trace info
343
-            if (empty($ex['trace'])) {
344
-                $trace_details .= __(
345
-                    'Sorry, but no trace information was available for this exception.',
346
-                    'event_espresso'
347
-                );
348
-            } else {
349
-                $trace_details .= '
338
+		}
339
+		// cycle thru errors
340
+		foreach (self::$_all_exceptions as $time => $ex) {
341
+			$error_code = '';
342
+			// process trace info
343
+			if (empty($ex['trace'])) {
344
+				$trace_details .= __(
345
+					'Sorry, but no trace information was available for this exception.',
346
+					'event_espresso'
347
+				);
348
+			} else {
349
+				$trace_details .= '
350 350
 			<div id="ee-trace-details">
351 351
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
352 352
 				<tr>
@@ -356,43 +356,43 @@  discard block
 block discarded – undo
356 356
 					<th scope="col" align="left">Class</th>
357 357
 					<th scope="col" align="left">Method( arguments )</th>
358 358
 				</tr>';
359
-                $last_on_stack = count($ex['trace']) - 1;
360
-                // reverse array so that stack is in proper chronological order
361
-                $sorted_trace = array_reverse($ex['trace']);
362
-                foreach ($sorted_trace as $nmbr => $trace) {
363
-                    $file = isset($trace['file']) ? $trace['file'] : '';
364
-                    $class = isset($trace['class']) ? $trace['class'] : '';
365
-                    $type = isset($trace['type']) ? $trace['type'] : '';
366
-                    $function = isset($trace['function']) ? $trace['function'] : '';
367
-                    $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
368
-                    $line = isset($trace['line']) ? $trace['line'] : '';
369
-                    $zebra = ($nmbr % 2) ? ' odd' : '';
370
-                    if (empty($file) && ! empty($class)) {
371
-                        $a = new ReflectionClass($class);
372
-                        $file = $a->getFileName();
373
-                        if (empty($line) && ! empty($function)) {
374
-                            try {
375
-                                //if $function is a closure, this throws an exception
376
-                                $b = new ReflectionMethod($class, $function);
377
-                                $line = $b->getStartLine();
378
-                            } catch (Exception $closure_exception) {
379
-                                $line = 'unknown';
380
-                            }
381
-                        }
382
-                    }
383
-                    if ($nmbr === $last_on_stack) {
384
-                        $file = $ex['file'] !== '' ? $ex['file'] : $file;
385
-                        $line = $ex['line'] !== '' ? $ex['line'] : $line;
386
-                        $error_code = self::generate_error_code($file, $trace['function'], $line);
387
-                    }
388
-                    $nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
389
-                    $line_dsply = ! empty($line) ? $line : '&nbsp;';
390
-                    $file_dsply = ! empty($file) ? $file : '&nbsp;';
391
-                    $class_dsply = ! empty($class) ? $class : '&nbsp;';
392
-                    $type_dsply = ! empty($type) ? $type : '&nbsp;';
393
-                    $function_dsply = ! empty($function) ? $function : '&nbsp;';
394
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
395
-                    $trace_details .= '
359
+				$last_on_stack = count($ex['trace']) - 1;
360
+				// reverse array so that stack is in proper chronological order
361
+				$sorted_trace = array_reverse($ex['trace']);
362
+				foreach ($sorted_trace as $nmbr => $trace) {
363
+					$file = isset($trace['file']) ? $trace['file'] : '';
364
+					$class = isset($trace['class']) ? $trace['class'] : '';
365
+					$type = isset($trace['type']) ? $trace['type'] : '';
366
+					$function = isset($trace['function']) ? $trace['function'] : '';
367
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
368
+					$line = isset($trace['line']) ? $trace['line'] : '';
369
+					$zebra = ($nmbr % 2) ? ' odd' : '';
370
+					if (empty($file) && ! empty($class)) {
371
+						$a = new ReflectionClass($class);
372
+						$file = $a->getFileName();
373
+						if (empty($line) && ! empty($function)) {
374
+							try {
375
+								//if $function is a closure, this throws an exception
376
+								$b = new ReflectionMethod($class, $function);
377
+								$line = $b->getStartLine();
378
+							} catch (Exception $closure_exception) {
379
+								$line = 'unknown';
380
+							}
381
+						}
382
+					}
383
+					if ($nmbr === $last_on_stack) {
384
+						$file = $ex['file'] !== '' ? $ex['file'] : $file;
385
+						$line = $ex['line'] !== '' ? $ex['line'] : $line;
386
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
387
+					}
388
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
389
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
390
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
391
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
392
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
393
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
394
+					$args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
395
+					$trace_details .= '
396 396
 					<tr>
397 397
 						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
398 398
 						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
@@ -400,523 +400,523 @@  discard block
 block discarded – undo
400 400
 						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
401 401
 						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
402 402
 					</tr>';
403
-                }
404
-                $trace_details .= '
403
+				}
404
+				$trace_details .= '
405 405
 			 </table>
406 406
 			</div>';
407
-            }
408
-            $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
409
-            // add generic non-identifying messages for non-privileged users
410
-            if (! WP_DEBUG) {
411
-                $output .= '<span class="ee-error-user-msg-spn">'
412
-                           . trim($ex['msg'])
413
-                           . '</span> &nbsp; <sup>'
414
-                           . $ex['code']
415
-                           . '</sup><br />';
416
-            } else {
417
-                // or helpful developer messages if debugging is on
418
-                $output .= '
407
+			}
408
+			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
409
+			// add generic non-identifying messages for non-privileged users
410
+			if (! WP_DEBUG) {
411
+				$output .= '<span class="ee-error-user-msg-spn">'
412
+						   . trim($ex['msg'])
413
+						   . '</span> &nbsp; <sup>'
414
+						   . $ex['code']
415
+						   . '</sup><br />';
416
+			} else {
417
+				// or helpful developer messages if debugging is on
418
+				$output .= '
419 419
 		<div class="ee-error-dev-msg-dv">
420 420
 			<p class="ee-error-dev-msg-pg">
421 421
 				<strong class="ee-error-dev-msg-str">An '
422
-                           . $ex['name']
423
-                           . ' exception was thrown!</strong>  &nbsp; <span>code: '
424
-                           . $ex['code']
425
-                           . '</span><br />
422
+						   . $ex['name']
423
+						   . ' exception was thrown!</strong>  &nbsp; <span>code: '
424
+						   . $ex['code']
425
+						   . '</span><br />
426 426
 				<span class="big-text">"'
427
-                           . trim($ex['msg'])
428
-                           . '"</span><br/>
427
+						   . trim($ex['msg'])
428
+						   . '"</span><br/>
429 429
 				<a id="display-ee-error-trace-'
430
-                           . self::$_error_count
431
-                           . $time
432
-                           . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
433
-                           . self::$_error_count
434
-                           . $time
435
-                           . '">
430
+						   . self::$_error_count
431
+						   . $time
432
+						   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
433
+						   . self::$_error_count
434
+						   . $time
435
+						   . '">
436 436
 					'
437
-                           . __('click to view backtrace and class/method details', 'event_espresso')
438
-                           . '
437
+						   . __('click to view backtrace and class/method details', 'event_espresso')
438
+						   . '
439 439
 				</a><br />
440 440
 				<span class="small-text lt-grey-text">'
441
-                           . $ex['file']
442
-                           . ' &nbsp; ( line no: '
443
-                           . $ex['line']
444
-                           . ' )</span>
441
+						   . $ex['file']
442
+						   . ' &nbsp; ( line no: '
443
+						   . $ex['line']
444
+						   . ' )</span>
445 445
 			</p>
446 446
 			<div id="ee-error-trace-'
447
-                           . self::$_error_count
448
-                           . $time
449
-                           . '-dv" class="ee-error-trace-dv" style="display: none;">
447
+						   . self::$_error_count
448
+						   . $time
449
+						   . '-dv" class="ee-error-trace-dv" style="display: none;">
450 450
 				'
451
-                           . $trace_details;
452
-                if (! empty($class)) {
453
-                    $output .= '
451
+						   . $trace_details;
452
+				if (! empty($class)) {
453
+					$output .= '
454 454
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
455 455
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
456 456
 						<h3>Class Details</h3>';
457
-                    $a = new ReflectionClass($class);
458
-                    $output .= '
457
+					$a = new ReflectionClass($class);
458
+					$output .= '
459 459
 						<pre>' . $a . '</pre>
460 460
 					</div>
461 461
 				</div>';
462
-                }
463
-                $output .= '
462
+				}
463
+				$output .= '
464 464
 			</div>
465 465
 		</div>
466 466
 		<br />';
467
-            }
468
-            $this->write_to_error_log($time, $ex);
469
-        }
470
-        // remove last linebreak
471
-        $output = substr($output, 0, -6);
472
-        if (! WP_DEBUG) {
473
-            $output .= '
467
+			}
468
+			$this->write_to_error_log($time, $ex);
469
+		}
470
+		// remove last linebreak
471
+		$output = substr($output, 0, -6);
472
+		if (! WP_DEBUG) {
473
+			$output .= '
474 474
 	</p>';
475
-        }
476
-        $output .= '
475
+		}
476
+		$output .= '
477 477
 </div>';
478
-        $output .= self::_print_scripts(true);
479
-        if (defined('DOING_AJAX')) {
480
-            echo wp_json_encode(array('error' => $output));
481
-            exit();
482
-        }
483
-        echo $output;
484
-        die();
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     *    generate string from exception trace args
491
-     *
492
-     * @param array $arguments
493
-     * @param bool  $array
494
-     * @return string
495
-     */
496
-    private function _convert_args_to_string($arguments = array(), $array = false)
497
-    {
498
-        $arg_string = '';
499
-        if (! empty($arguments)) {
500
-            $args = array();
501
-            foreach ($arguments as $arg) {
502
-                if (! empty($arg)) {
503
-                    if (is_string($arg)) {
504
-                        $args[] = " '" . $arg . "'";
505
-                    } elseif (is_array($arg)) {
506
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
507
-                    } elseif ($arg === null) {
508
-                        $args[] = ' NULL';
509
-                    } elseif (is_bool($arg)) {
510
-                        $args[] = ($arg) ? ' TRUE' : ' FALSE';
511
-                    } elseif (is_object($arg)) {
512
-                        $args[] = ' OBJECT ' . get_class($arg);
513
-                    } elseif (is_resource($arg)) {
514
-                        $args[] = get_resource_type($arg);
515
-                    } else {
516
-                        $args[] = $arg;
517
-                    }
518
-                }
519
-            }
520
-            $arg_string = implode(', ', $args);
521
-        }
522
-        if ($array) {
523
-            $arg_string .= ' )';
524
-        }
525
-        return $arg_string;
526
-    }
527
-
528
-
529
-
530
-    /**
531
-     *    add error message
532
-     *
533
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
534
-     *                            separate messages for user || dev
535
-     * @param        string $file the file that the error occurred in - just use __FILE__
536
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
537
-     * @param        string $line the line number where the error occurred - just use __LINE__
538
-     * @return        void
539
-     */
540
-    public static function add_error($msg = null, $file = null, $func = null, $line = null)
541
-    {
542
-        self::_add_notice('errors', $msg, $file, $func, $line);
543
-        self::$_error_count++;
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
550
-     * adds an error
551
-     *
552
-     * @param string $msg
553
-     * @param string $file
554
-     * @param string $func
555
-     * @param string $line
556
-     * @throws EE_Error
557
-     */
558
-    public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
559
-    {
560
-        if (WP_DEBUG) {
561
-            throw new EE_Error($msg);
562
-        }
563
-        EE_Error::add_error($msg, $file, $func, $line);
564
-    }
565
-
566
-
567
-
568
-    /**
569
-     *    add success message
570
-     *
571
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
572
-     *                            separate messages for user || dev
573
-     * @param        string $file the file that the error occurred in - just use __FILE__
574
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
575
-     * @param        string $line the line number where the error occurred - just use __LINE__
576
-     * @return        void
577
-     */
578
-    public static function add_success($msg = null, $file = null, $func = null, $line = null)
579
-    {
580
-        self::_add_notice('success', $msg, $file, $func, $line);
581
-    }
582
-
583
-
584
-
585
-    /**
586
-     *    add attention message
587
-     *
588
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
589
-     *                            separate messages for user || dev
590
-     * @param        string $file the file that the error occurred in - just use __FILE__
591
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
592
-     * @param        string $line the line number where the error occurred - just use __LINE__
593
-     * @return        void
594
-     */
595
-    public static function add_attention($msg = null, $file = null, $func = null, $line = null)
596
-    {
597
-        self::_add_notice('attention', $msg, $file, $func, $line);
598
-    }
599
-
600
-
601
-
602
-    /**
603
-     * @param string $type whether the message is for a success or error notification
604
-     * @param string $msg the message to display to users or developers
605
-     *                    - adding a double pipe || (OR) creates separate messages for user || dev
606
-     * @param string $file the file that the error occurred in - just use __FILE__
607
-     * @param string $func the function/method that the error occurred in - just use __FUNCTION__
608
-     * @param string $line the line number where the error occurred - just use __LINE__
609
-     * @return void
610
-     */
611
-    private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
612
-    {
613
-        if (empty($msg)) {
614
-            EE_Error::doing_it_wrong(
615
-                'EE_Error::add_' . $type . '()',
616
-                sprintf(
617
-                    __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
618
-                        'event_espresso'),
619
-                    $type,
620
-                    $file,
621
-                    $line
622
-                ),
623
-                EVENT_ESPRESSO_VERSION
624
-            );
625
-        }
626
-        if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
627
-            EE_Error::doing_it_wrong(
628
-                'EE_Error::add_error()',
629
-                __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
630
-                    'event_espresso'),
631
-                EVENT_ESPRESSO_VERSION
632
-            );
633
-        }
634
-        // get separate user and developer messages if they exist
635
-        $msg      = explode('||', $msg);
636
-        $user_msg = $msg[0];
637
-        $dev_msg  = isset($msg[1]) ? $msg[1] : $msg[0];
638
-        /**
639
-         * Do an action so other code can be triggered when a notice is created
640
-         *
641
-         * @param string $type     can be 'errors', 'attention', or 'success'
642
-         * @param string $user_msg message displayed to user when WP_DEBUG is off
643
-         * @param string $user_msg message displayed to user when WP_DEBUG is on
644
-         * @param string $file     file where error was generated
645
-         * @param string $func     function where error was generated
646
-         * @param string $line     line where error was generated
647
-         */
648
-        do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
649
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
650
-        // add notice if message exists
651
-        if (! empty($msg)) {
652
-            // get error code
653
-            $notice_code = EE_Error::generate_error_code($file, $func, $line);
654
-            if (WP_DEBUG && $type === 'errors') {
655
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
656
-            }
657
-            // add notice. Index by code if it's not blank
658
-            if ($notice_code) {
659
-                self::$_espresso_notices[$type][$notice_code] = $msg;
660
-            } else {
661
-                self::$_espresso_notices[$type][] = $msg;
662
-            }
663
-            add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
664
-        }
665
-    }
666
-
667
-
668
-    /**
669
-     * in some case it may be necessary to overwrite the existing success messages
670
-     *
671
-     * @return        void
672
-     */
673
-    public static function overwrite_success()
674
-    {
675
-        self::$_espresso_notices['success'] = false;
676
-    }
677
-
678
-
679
-
680
-    /**
681
-     * in some case it may be necessary to overwrite the existing attention messages
682
-     *
683
-     * @return void
684
-     */
685
-    public static function overwrite_attention()
686
-    {
687
-        self::$_espresso_notices['attention'] = false;
688
-    }
689
-
690
-
691
-
692
-    /**
693
-     * in some case it may be necessary to overwrite the existing error messages
694
-     *
695
-     * @return void
696
-     */
697
-    public static function overwrite_errors()
698
-    {
699
-        self::$_espresso_notices['errors'] = false;
700
-    }
701
-
702
-
703
-
704
-    /**
705
-     * @return void
706
-     */
707
-    public static function reset_notices()
708
-    {
709
-        self::$_espresso_notices['success']   = false;
710
-        self::$_espresso_notices['attention'] = false;
711
-        self::$_espresso_notices['errors']    = false;
712
-    }
713
-
714
-
715
-
716
-    /**
717
-     * @return int
718
-     */
719
-    public static function has_notices()
720
-    {
721
-        $has_notices = 0;
722
-        // check for success messages
723
-        $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
724
-            ? 3
725
-            : $has_notices;
726
-        // check for attention messages
727
-        $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
728
-            ? 2
729
-            : $has_notices;
730
-        // check for error messages
731
-        $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
732
-            ? 1
733
-            : $has_notices;
734
-        return $has_notices;
735
-    }
736
-
737
-
738
-    /**
739
-     * This simply returns non formatted error notices as they were sent into the EE_Error object.
740
-     *
741
-     * @since 4.9.0
742
-     * @return array
743
-     */
744
-    public static function get_vanilla_notices()
745
-    {
746
-        return array(
747
-            'success'   => isset(self::$_espresso_notices['success'])
748
-                ? self::$_espresso_notices['success']
749
-                : array(),
750
-            'attention' => isset(self::$_espresso_notices['attention'])
751
-                ? self::$_espresso_notices['attention']
752
-                : array(),
753
-            'errors'    => isset(self::$_espresso_notices['errors'])
754
-                ? self::$_espresso_notices['errors']
755
-                : array(),
756
-        );
757
-    }
758
-
759
-
760
-
761
-    /**
762
-     * compile all error or success messages into one string
763
-     *
764
-     * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
765
-     * @param boolean $format_output     whether or not to format the messages for display in the WP admin
766
-     * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request
767
-     *                                          - ONLY do this just before redirecting
768
-     * @param boolean $remove_empty      whether or not to unset empty messages
769
-     * @return array
770
-     */
771
-    public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
772
-    {
773
-        // do_action('AHEE_log', __FILE__, __FUNCTION__, '');
774
-        $success_messages   = '';
775
-        $attention_messages = '';
776
-        $error_messages     = '';
777
-        $print_scripts      = false;
778
-        // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
779
-        // either save notices to the db
780
-        if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
781
-            $existing_notices  = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
782
-            $existing_notices = is_array($existing_notices) ? $existing_notices : array();
783
-            self::$_espresso_notices = array_merge(
784
-                $existing_notices,
785
-                self::$_espresso_notices
786
-            );
787
-            update_option(EE_Error::OPTIONS_KEY_NOTICES, self::$_espresso_notices);
788
-            return array();
789
-        }
790
-        // grab any notices that have been previously saved
791
-        if ($notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array())) {
792
-            foreach ($notices as $type => $notice) {
793
-                if (is_array($notice) && ! empty($notice)) {
794
-                    // make sure that existing notice type is an array
795
-                    self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
796
-                                                      && ! empty(self::$_espresso_notices[$type])
797
-                        ? self::$_espresso_notices[$type]
798
-                        : array();
799
-                    // merge stored notices with any newly created ones
800
-                    self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
801
-                    $print_scripts                  = true;
802
-                }
803
-            }
804
-            // now clear any stored notices
805
-            update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
806
-        }
807
-        // check for success messages
808
-        if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
809
-            // combine messages
810
-            $success_messages .= implode(self::$_espresso_notices['success'], '<br />');
811
-            $print_scripts    = true;
812
-        }
813
-        // check for attention messages
814
-        if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
815
-            // combine messages
816
-            $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
817
-            $print_scripts      = true;
818
-        }
819
-        // check for error messages
820
-        if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
821
-            $error_messages .= count(self::$_espresso_notices['errors']) > 1
822
-                ? __('The following errors have occurred:<br />', 'event_espresso')
823
-                : __('An error has occurred:<br />', 'event_espresso');
824
-            // combine messages
825
-            $error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
826
-            $print_scripts  = true;
827
-        }
828
-        if ($format_output) {
829
-
830
-            $notices = '<div id="espresso-notices">';
831
-            $close = is_admin() ? ''
832
-                : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>';
833
-            if ($success_messages !== '') {
834
-                $css_id    = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
835
-                $css_class = is_admin() ? 'updated fade' : 'success fade-away';
836
-                //showMessage( $success_messages );
837
-                $notices .= '<div id="'
838
-                            . $css_id
839
-                            . '" class="espresso-notices '
840
-                            . $css_class
841
-                            . '" style="display:none;"><p>'
842
-                            . $success_messages
843
-                            . '</p>'
844
-                            . $close
845
-                            . '</div>';
846
-            }
847
-            if ($attention_messages !== '') {
848
-                $css_id    = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
849
-                $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
850
-                //showMessage( $error_messages, TRUE );
851
-                $notices .= '<div id="'
852
-                            . $css_id
853
-                            . '" class="espresso-notices '
854
-                            . $css_class
855
-                            . '" style="display:none;"><p>'
856
-                            . $attention_messages
857
-                            . '</p>'
858
-                            . $close
859
-                            . '</div>';
860
-            }
861
-            if ($error_messages !== '') {
862
-                $css_id    = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
863
-                $css_class = is_admin() ? 'error' : 'error fade-away';
864
-                //showMessage( $error_messages, TRUE );
865
-                $notices .= '<div id="'
866
-                            . $css_id
867
-                            . '" class="espresso-notices '
868
-                            . $css_class
869
-                            . '" style="display:none;"><p>'
870
-                            . $error_messages
871
-                            . '</p>'
872
-                            . $close
873
-                            . '</div>';
874
-            }
875
-            $notices .= '</div>';
876
-        } else {
877
-
878
-            $notices = array(
879
-                'success'   => $success_messages,
880
-                'attention' => $attention_messages,
881
-                'errors'    => $error_messages,
882
-            );
883
-            if ($remove_empty) {
884
-                // remove empty notices
885
-                foreach ($notices as $type => $notice) {
886
-                    if (empty($notice)) {
887
-                        unset($notices[$type]);
888
-                    }
889
-                }
890
-            }
891
-        }
892
-        if ($print_scripts) {
893
-            self::_print_scripts();
894
-        }
895
-        return $notices;
896
-    }
897
-
898
-
899
-
900
-    /**
901
-     * _print_scripts
902
-     *
903
-     * @param    bool $force_print
904
-     * @return    string
905
-     */
906
-    private static function _print_scripts($force_print = false)
907
-    {
908
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
909
-            if (wp_script_is('ee_error_js', 'enqueued')) {
910
-                return '';
911
-            }
912
-            if (wp_script_is('ee_error_js', 'registered')) {
913
-                wp_enqueue_style('espresso_default');
914
-                wp_enqueue_style('espresso_custom_css');
915
-                wp_enqueue_script('ee_error_js');
916
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
917
-            }
918
-        } else {
919
-            return '
478
+		$output .= self::_print_scripts(true);
479
+		if (defined('DOING_AJAX')) {
480
+			echo wp_json_encode(array('error' => $output));
481
+			exit();
482
+		}
483
+		echo $output;
484
+		die();
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 *    generate string from exception trace args
491
+	 *
492
+	 * @param array $arguments
493
+	 * @param bool  $array
494
+	 * @return string
495
+	 */
496
+	private function _convert_args_to_string($arguments = array(), $array = false)
497
+	{
498
+		$arg_string = '';
499
+		if (! empty($arguments)) {
500
+			$args = array();
501
+			foreach ($arguments as $arg) {
502
+				if (! empty($arg)) {
503
+					if (is_string($arg)) {
504
+						$args[] = " '" . $arg . "'";
505
+					} elseif (is_array($arg)) {
506
+						$args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
507
+					} elseif ($arg === null) {
508
+						$args[] = ' NULL';
509
+					} elseif (is_bool($arg)) {
510
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
511
+					} elseif (is_object($arg)) {
512
+						$args[] = ' OBJECT ' . get_class($arg);
513
+					} elseif (is_resource($arg)) {
514
+						$args[] = get_resource_type($arg);
515
+					} else {
516
+						$args[] = $arg;
517
+					}
518
+				}
519
+			}
520
+			$arg_string = implode(', ', $args);
521
+		}
522
+		if ($array) {
523
+			$arg_string .= ' )';
524
+		}
525
+		return $arg_string;
526
+	}
527
+
528
+
529
+
530
+	/**
531
+	 *    add error message
532
+	 *
533
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
534
+	 *                            separate messages for user || dev
535
+	 * @param        string $file the file that the error occurred in - just use __FILE__
536
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
537
+	 * @param        string $line the line number where the error occurred - just use __LINE__
538
+	 * @return        void
539
+	 */
540
+	public static function add_error($msg = null, $file = null, $func = null, $line = null)
541
+	{
542
+		self::_add_notice('errors', $msg, $file, $func, $line);
543
+		self::$_error_count++;
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
550
+	 * adds an error
551
+	 *
552
+	 * @param string $msg
553
+	 * @param string $file
554
+	 * @param string $func
555
+	 * @param string $line
556
+	 * @throws EE_Error
557
+	 */
558
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
559
+	{
560
+		if (WP_DEBUG) {
561
+			throw new EE_Error($msg);
562
+		}
563
+		EE_Error::add_error($msg, $file, $func, $line);
564
+	}
565
+
566
+
567
+
568
+	/**
569
+	 *    add success message
570
+	 *
571
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
572
+	 *                            separate messages for user || dev
573
+	 * @param        string $file the file that the error occurred in - just use __FILE__
574
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
575
+	 * @param        string $line the line number where the error occurred - just use __LINE__
576
+	 * @return        void
577
+	 */
578
+	public static function add_success($msg = null, $file = null, $func = null, $line = null)
579
+	{
580
+		self::_add_notice('success', $msg, $file, $func, $line);
581
+	}
582
+
583
+
584
+
585
+	/**
586
+	 *    add attention message
587
+	 *
588
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
589
+	 *                            separate messages for user || dev
590
+	 * @param        string $file the file that the error occurred in - just use __FILE__
591
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
592
+	 * @param        string $line the line number where the error occurred - just use __LINE__
593
+	 * @return        void
594
+	 */
595
+	public static function add_attention($msg = null, $file = null, $func = null, $line = null)
596
+	{
597
+		self::_add_notice('attention', $msg, $file, $func, $line);
598
+	}
599
+
600
+
601
+
602
+	/**
603
+	 * @param string $type whether the message is for a success or error notification
604
+	 * @param string $msg the message to display to users or developers
605
+	 *                    - adding a double pipe || (OR) creates separate messages for user || dev
606
+	 * @param string $file the file that the error occurred in - just use __FILE__
607
+	 * @param string $func the function/method that the error occurred in - just use __FUNCTION__
608
+	 * @param string $line the line number where the error occurred - just use __LINE__
609
+	 * @return void
610
+	 */
611
+	private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
612
+	{
613
+		if (empty($msg)) {
614
+			EE_Error::doing_it_wrong(
615
+				'EE_Error::add_' . $type . '()',
616
+				sprintf(
617
+					__('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
618
+						'event_espresso'),
619
+					$type,
620
+					$file,
621
+					$line
622
+				),
623
+				EVENT_ESPRESSO_VERSION
624
+			);
625
+		}
626
+		if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
627
+			EE_Error::doing_it_wrong(
628
+				'EE_Error::add_error()',
629
+				__('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
630
+					'event_espresso'),
631
+				EVENT_ESPRESSO_VERSION
632
+			);
633
+		}
634
+		// get separate user and developer messages if they exist
635
+		$msg      = explode('||', $msg);
636
+		$user_msg = $msg[0];
637
+		$dev_msg  = isset($msg[1]) ? $msg[1] : $msg[0];
638
+		/**
639
+		 * Do an action so other code can be triggered when a notice is created
640
+		 *
641
+		 * @param string $type     can be 'errors', 'attention', or 'success'
642
+		 * @param string $user_msg message displayed to user when WP_DEBUG is off
643
+		 * @param string $user_msg message displayed to user when WP_DEBUG is on
644
+		 * @param string $file     file where error was generated
645
+		 * @param string $func     function where error was generated
646
+		 * @param string $line     line where error was generated
647
+		 */
648
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
649
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
650
+		// add notice if message exists
651
+		if (! empty($msg)) {
652
+			// get error code
653
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
654
+			if (WP_DEBUG && $type === 'errors') {
655
+				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
656
+			}
657
+			// add notice. Index by code if it's not blank
658
+			if ($notice_code) {
659
+				self::$_espresso_notices[$type][$notice_code] = $msg;
660
+			} else {
661
+				self::$_espresso_notices[$type][] = $msg;
662
+			}
663
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
664
+		}
665
+	}
666
+
667
+
668
+	/**
669
+	 * in some case it may be necessary to overwrite the existing success messages
670
+	 *
671
+	 * @return        void
672
+	 */
673
+	public static function overwrite_success()
674
+	{
675
+		self::$_espresso_notices['success'] = false;
676
+	}
677
+
678
+
679
+
680
+	/**
681
+	 * in some case it may be necessary to overwrite the existing attention messages
682
+	 *
683
+	 * @return void
684
+	 */
685
+	public static function overwrite_attention()
686
+	{
687
+		self::$_espresso_notices['attention'] = false;
688
+	}
689
+
690
+
691
+
692
+	/**
693
+	 * in some case it may be necessary to overwrite the existing error messages
694
+	 *
695
+	 * @return void
696
+	 */
697
+	public static function overwrite_errors()
698
+	{
699
+		self::$_espresso_notices['errors'] = false;
700
+	}
701
+
702
+
703
+
704
+	/**
705
+	 * @return void
706
+	 */
707
+	public static function reset_notices()
708
+	{
709
+		self::$_espresso_notices['success']   = false;
710
+		self::$_espresso_notices['attention'] = false;
711
+		self::$_espresso_notices['errors']    = false;
712
+	}
713
+
714
+
715
+
716
+	/**
717
+	 * @return int
718
+	 */
719
+	public static function has_notices()
720
+	{
721
+		$has_notices = 0;
722
+		// check for success messages
723
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
724
+			? 3
725
+			: $has_notices;
726
+		// check for attention messages
727
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
728
+			? 2
729
+			: $has_notices;
730
+		// check for error messages
731
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
732
+			? 1
733
+			: $has_notices;
734
+		return $has_notices;
735
+	}
736
+
737
+
738
+	/**
739
+	 * This simply returns non formatted error notices as they were sent into the EE_Error object.
740
+	 *
741
+	 * @since 4.9.0
742
+	 * @return array
743
+	 */
744
+	public static function get_vanilla_notices()
745
+	{
746
+		return array(
747
+			'success'   => isset(self::$_espresso_notices['success'])
748
+				? self::$_espresso_notices['success']
749
+				: array(),
750
+			'attention' => isset(self::$_espresso_notices['attention'])
751
+				? self::$_espresso_notices['attention']
752
+				: array(),
753
+			'errors'    => isset(self::$_espresso_notices['errors'])
754
+				? self::$_espresso_notices['errors']
755
+				: array(),
756
+		);
757
+	}
758
+
759
+
760
+
761
+	/**
762
+	 * compile all error or success messages into one string
763
+	 *
764
+	 * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
765
+	 * @param boolean $format_output     whether or not to format the messages for display in the WP admin
766
+	 * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request
767
+	 *                                          - ONLY do this just before redirecting
768
+	 * @param boolean $remove_empty      whether or not to unset empty messages
769
+	 * @return array
770
+	 */
771
+	public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
772
+	{
773
+		// do_action('AHEE_log', __FILE__, __FUNCTION__, '');
774
+		$success_messages   = '';
775
+		$attention_messages = '';
776
+		$error_messages     = '';
777
+		$print_scripts      = false;
778
+		// EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
779
+		// either save notices to the db
780
+		if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
781
+			$existing_notices  = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
782
+			$existing_notices = is_array($existing_notices) ? $existing_notices : array();
783
+			self::$_espresso_notices = array_merge(
784
+				$existing_notices,
785
+				self::$_espresso_notices
786
+			);
787
+			update_option(EE_Error::OPTIONS_KEY_NOTICES, self::$_espresso_notices);
788
+			return array();
789
+		}
790
+		// grab any notices that have been previously saved
791
+		if ($notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array())) {
792
+			foreach ($notices as $type => $notice) {
793
+				if (is_array($notice) && ! empty($notice)) {
794
+					// make sure that existing notice type is an array
795
+					self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
796
+													  && ! empty(self::$_espresso_notices[$type])
797
+						? self::$_espresso_notices[$type]
798
+						: array();
799
+					// merge stored notices with any newly created ones
800
+					self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
801
+					$print_scripts                  = true;
802
+				}
803
+			}
804
+			// now clear any stored notices
805
+			update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
806
+		}
807
+		// check for success messages
808
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
809
+			// combine messages
810
+			$success_messages .= implode(self::$_espresso_notices['success'], '<br />');
811
+			$print_scripts    = true;
812
+		}
813
+		// check for attention messages
814
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
815
+			// combine messages
816
+			$attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
817
+			$print_scripts      = true;
818
+		}
819
+		// check for error messages
820
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
821
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1
822
+				? __('The following errors have occurred:<br />', 'event_espresso')
823
+				: __('An error has occurred:<br />', 'event_espresso');
824
+			// combine messages
825
+			$error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
826
+			$print_scripts  = true;
827
+		}
828
+		if ($format_output) {
829
+
830
+			$notices = '<div id="espresso-notices">';
831
+			$close = is_admin() ? ''
832
+				: '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>';
833
+			if ($success_messages !== '') {
834
+				$css_id    = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
835
+				$css_class = is_admin() ? 'updated fade' : 'success fade-away';
836
+				//showMessage( $success_messages );
837
+				$notices .= '<div id="'
838
+							. $css_id
839
+							. '" class="espresso-notices '
840
+							. $css_class
841
+							. '" style="display:none;"><p>'
842
+							. $success_messages
843
+							. '</p>'
844
+							. $close
845
+							. '</div>';
846
+			}
847
+			if ($attention_messages !== '') {
848
+				$css_id    = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
849
+				$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
850
+				//showMessage( $error_messages, TRUE );
851
+				$notices .= '<div id="'
852
+							. $css_id
853
+							. '" class="espresso-notices '
854
+							. $css_class
855
+							. '" style="display:none;"><p>'
856
+							. $attention_messages
857
+							. '</p>'
858
+							. $close
859
+							. '</div>';
860
+			}
861
+			if ($error_messages !== '') {
862
+				$css_id    = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
863
+				$css_class = is_admin() ? 'error' : 'error fade-away';
864
+				//showMessage( $error_messages, TRUE );
865
+				$notices .= '<div id="'
866
+							. $css_id
867
+							. '" class="espresso-notices '
868
+							. $css_class
869
+							. '" style="display:none;"><p>'
870
+							. $error_messages
871
+							. '</p>'
872
+							. $close
873
+							. '</div>';
874
+			}
875
+			$notices .= '</div>';
876
+		} else {
877
+
878
+			$notices = array(
879
+				'success'   => $success_messages,
880
+				'attention' => $attention_messages,
881
+				'errors'    => $error_messages,
882
+			);
883
+			if ($remove_empty) {
884
+				// remove empty notices
885
+				foreach ($notices as $type => $notice) {
886
+					if (empty($notice)) {
887
+						unset($notices[$type]);
888
+					}
889
+				}
890
+			}
891
+		}
892
+		if ($print_scripts) {
893
+			self::_print_scripts();
894
+		}
895
+		return $notices;
896
+	}
897
+
898
+
899
+
900
+	/**
901
+	 * _print_scripts
902
+	 *
903
+	 * @param    bool $force_print
904
+	 * @return    string
905
+	 */
906
+	private static function _print_scripts($force_print = false)
907
+	{
908
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
909
+			if (wp_script_is('ee_error_js', 'enqueued')) {
910
+				return '';
911
+			}
912
+			if (wp_script_is('ee_error_js', 'registered')) {
913
+				wp_enqueue_style('espresso_default');
914
+				wp_enqueue_style('espresso_custom_css');
915
+				wp_enqueue_script('ee_error_js');
916
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
917
+			}
918
+		} else {
919
+			return '
920 920
 <script>
921 921
 /* <![CDATA[ */
922 922
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -926,223 +926,223 @@  discard block
 block discarded – undo
926 926
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
927 927
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
928 928
 ';
929
-        }
930
-        return '';
931
-    }
932
-
933
-
934
-
935
-    /**
936
-     * @return void
937
-     */
938
-    public static function enqueue_error_scripts()
939
-    {
940
-        self::_print_scripts();
941
-    }
942
-
943
-
944
-
945
-    /**
946
-     * create error code from filepath, function name,
947
-     * and line number where exception or error was thrown
948
-     *
949
-     * @param string $file
950
-     * @param string $func
951
-     * @param string $line
952
-     * @return string
953
-     */
954
-    public static function generate_error_code($file = '', $func = '', $line = '')
955
-    {
956
-        $file       = explode('.', basename($file));
957
-        $error_code = ! empty($file[0]) ? $file[0] : '';
958
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
959
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
960
-        return $error_code;
961
-    }
962
-
963
-
964
-
965
-    /**
966
-     * write exception details to log file
967
-     * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
968
-     *
969
-     * @param int   $time
970
-     * @param array $ex
971
-     * @param bool  $clear
972
-     * @return void
973
-     */
974
-    public function write_to_error_log($time = 0, $ex = array(), $clear = false)
975
-    {
976
-        if (empty($ex)) {
977
-            return;
978
-        }
979
-        if (! $time) {
980
-            $time = time();
981
-        }
982
-        $exception_log = '----------------------------------------------------------------------------------------'
983
-                         . PHP_EOL;
984
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
985
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
986
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
987
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
988
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
989
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
990
-        $exception_log .= $ex['string'] . PHP_EOL;
991
-        $exception_log .= '----------------------------------------------------------------------------------------'
992
-                          . PHP_EOL;
993
-        try {
994
-            error_log($exception_log);
995
-        } catch (EE_Error $e) {
996
-            EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s',
997
-                'event_espresso'), $e->getMessage()));
998
-        }
999
-    }
1000
-
1001
-
1002
-
1003
-    /**
1004
-     * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1005
-     * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1006
-     * but the code execution is done in a manner that could lead to unexpected results
1007
-     * (i.e. running to early, or too late in WP or EE loading process).
1008
-     * A good test for knowing whether to use this method is:
1009
-     * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1010
-     * Yes -> use EE_Error::add_error() or throw new EE_Error()
1011
-     * 2. If this is loaded before something else, it won't break anything,
1012
-     * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1013
-     *
1014
-     * @uses   constant WP_DEBUG test if wp_debug is on or not
1015
-     * @param string $function      The function that was called
1016
-     * @param string $message       A message explaining what has been done incorrectly
1017
-     * @param string $version       The version of Event Espresso where the error was added
1018
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1019
-     *                              for a deprecated function. This allows deprecation to occur during one version,
1020
-     *                              but not have any notices appear until a later version. This allows developers
1021
-     *                              extra time to update their code before notices appear.
1022
-     * @param int    $error_type
1023
-     */
1024
-    public static function doing_it_wrong(
1025
-        $function,
1026
-        $message,
1027
-        $version,
1028
-        $applies_when = '',
1029
-        $error_type = null
1030
-    ) {
1031
-        if (defined('WP_DEBUG') && WP_DEBUG) {
1032
-            EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1033
-        }
1034
-    }
1035
-
1036
-
1037
-
1038
-    /**
1039
-     * Like get_notices, but returns an array of all the notices of the given type.
1040
-     *
1041
-     * @return array {
1042
-     *  @type array $success   all the success messages
1043
-     *  @type array $errors    all the error messages
1044
-     *  @type array $attention all the attention messages
1045
-     * }
1046
-     */
1047
-    public static function get_raw_notices()
1048
-    {
1049
-        return self::$_espresso_notices;
1050
-    }
1051
-
1052
-
1053
-
1054
-    /**
1055
-     * @deprecated 4.9.27
1056
-     * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1057
-     * @param string $pan_message  the message to be stored persistently until dismissed
1058
-     * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1059
-     * @return void
1060
-     * @throws InvalidDataTypeException
1061
-     */
1062
-    public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1063
-    {
1064
-        new PersistentAdminNotice(
1065
-            $pan_name,
1066
-            $pan_message,
1067
-            $force_update
1068
-        );
1069
-        EE_Error::doing_it_wrong(
1070
-            __METHOD__,
1071
-            sprintf(
1072
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1073
-                '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1074
-            ),
1075
-            '4.9.27'
1076
-        );
1077
-    }
1078
-
1079
-
1080
-
1081
-    /**
1082
-     * @deprecated 4.9.27
1083
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1084
-     * @param bool   $purge
1085
-     * @param bool   $return
1086
-     * @throws DomainException
1087
-     * @throws InvalidInterfaceException
1088
-     * @throws InvalidDataTypeException
1089
-     * @throws ServiceNotFoundException
1090
-     * @throws InvalidArgumentException
1091
-     */
1092
-    public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1093
-    {
1094
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1095
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1096
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1097
-        );
1098
-        $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1099
-        EE_Error::doing_it_wrong(
1100
-            __METHOD__,
1101
-            sprintf(
1102
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1103
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1104
-            ),
1105
-            '4.9.27'
1106
-        );
1107
-    }
1108
-
1109
-
1110
-
1111
-    /**
1112
-     * @deprecated 4.9.27
1113
-     * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1114
-     * @param  string $pan_message the message to be stored persistently until dismissed
1115
-     * @param  string $return_url  URL to go back to after nag notice is dismissed
1116
-     */
1117
-    public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1118
-    {
1119
-        EE_Error::doing_it_wrong(
1120
-            __METHOD__,
1121
-            sprintf(
1122
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1123
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1124
-            ),
1125
-            '4.9.27'
1126
-        );
1127
-    }
1128
-
1129
-
1130
-
1131
-    /**
1132
-     * @deprecated 4.9.27
1133
-     * @param string $return_url
1134
-     */
1135
-    public static function get_persistent_admin_notices($return_url = '')
1136
-    {
1137
-        EE_Error::doing_it_wrong(
1138
-            __METHOD__,
1139
-            sprintf(
1140
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1141
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1142
-            ),
1143
-            '4.9.27'
1144
-        );
1145
-    }
929
+		}
930
+		return '';
931
+	}
932
+
933
+
934
+
935
+	/**
936
+	 * @return void
937
+	 */
938
+	public static function enqueue_error_scripts()
939
+	{
940
+		self::_print_scripts();
941
+	}
942
+
943
+
944
+
945
+	/**
946
+	 * create error code from filepath, function name,
947
+	 * and line number where exception or error was thrown
948
+	 *
949
+	 * @param string $file
950
+	 * @param string $func
951
+	 * @param string $line
952
+	 * @return string
953
+	 */
954
+	public static function generate_error_code($file = '', $func = '', $line = '')
955
+	{
956
+		$file       = explode('.', basename($file));
957
+		$error_code = ! empty($file[0]) ? $file[0] : '';
958
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
959
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
960
+		return $error_code;
961
+	}
962
+
963
+
964
+
965
+	/**
966
+	 * write exception details to log file
967
+	 * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
968
+	 *
969
+	 * @param int   $time
970
+	 * @param array $ex
971
+	 * @param bool  $clear
972
+	 * @return void
973
+	 */
974
+	public function write_to_error_log($time = 0, $ex = array(), $clear = false)
975
+	{
976
+		if (empty($ex)) {
977
+			return;
978
+		}
979
+		if (! $time) {
980
+			$time = time();
981
+		}
982
+		$exception_log = '----------------------------------------------------------------------------------------'
983
+						 . PHP_EOL;
984
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
985
+		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
986
+		$exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
987
+		$exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
988
+		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
989
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
990
+		$exception_log .= $ex['string'] . PHP_EOL;
991
+		$exception_log .= '----------------------------------------------------------------------------------------'
992
+						  . PHP_EOL;
993
+		try {
994
+			error_log($exception_log);
995
+		} catch (EE_Error $e) {
996
+			EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s',
997
+				'event_espresso'), $e->getMessage()));
998
+		}
999
+	}
1000
+
1001
+
1002
+
1003
+	/**
1004
+	 * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1005
+	 * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1006
+	 * but the code execution is done in a manner that could lead to unexpected results
1007
+	 * (i.e. running to early, or too late in WP or EE loading process).
1008
+	 * A good test for knowing whether to use this method is:
1009
+	 * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1010
+	 * Yes -> use EE_Error::add_error() or throw new EE_Error()
1011
+	 * 2. If this is loaded before something else, it won't break anything,
1012
+	 * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1013
+	 *
1014
+	 * @uses   constant WP_DEBUG test if wp_debug is on or not
1015
+	 * @param string $function      The function that was called
1016
+	 * @param string $message       A message explaining what has been done incorrectly
1017
+	 * @param string $version       The version of Event Espresso where the error was added
1018
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1019
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
1020
+	 *                              but not have any notices appear until a later version. This allows developers
1021
+	 *                              extra time to update their code before notices appear.
1022
+	 * @param int    $error_type
1023
+	 */
1024
+	public static function doing_it_wrong(
1025
+		$function,
1026
+		$message,
1027
+		$version,
1028
+		$applies_when = '',
1029
+		$error_type = null
1030
+	) {
1031
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1032
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1033
+		}
1034
+	}
1035
+
1036
+
1037
+
1038
+	/**
1039
+	 * Like get_notices, but returns an array of all the notices of the given type.
1040
+	 *
1041
+	 * @return array {
1042
+	 *  @type array $success   all the success messages
1043
+	 *  @type array $errors    all the error messages
1044
+	 *  @type array $attention all the attention messages
1045
+	 * }
1046
+	 */
1047
+	public static function get_raw_notices()
1048
+	{
1049
+		return self::$_espresso_notices;
1050
+	}
1051
+
1052
+
1053
+
1054
+	/**
1055
+	 * @deprecated 4.9.27
1056
+	 * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1057
+	 * @param string $pan_message  the message to be stored persistently until dismissed
1058
+	 * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1059
+	 * @return void
1060
+	 * @throws InvalidDataTypeException
1061
+	 */
1062
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1063
+	{
1064
+		new PersistentAdminNotice(
1065
+			$pan_name,
1066
+			$pan_message,
1067
+			$force_update
1068
+		);
1069
+		EE_Error::doing_it_wrong(
1070
+			__METHOD__,
1071
+			sprintf(
1072
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1073
+				'\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1074
+			),
1075
+			'4.9.27'
1076
+		);
1077
+	}
1078
+
1079
+
1080
+
1081
+	/**
1082
+	 * @deprecated 4.9.27
1083
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1084
+	 * @param bool   $purge
1085
+	 * @param bool   $return
1086
+	 * @throws DomainException
1087
+	 * @throws InvalidInterfaceException
1088
+	 * @throws InvalidDataTypeException
1089
+	 * @throws ServiceNotFoundException
1090
+	 * @throws InvalidArgumentException
1091
+	 */
1092
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1093
+	{
1094
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1095
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1096
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1097
+		);
1098
+		$persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1099
+		EE_Error::doing_it_wrong(
1100
+			__METHOD__,
1101
+			sprintf(
1102
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1103
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1104
+			),
1105
+			'4.9.27'
1106
+		);
1107
+	}
1108
+
1109
+
1110
+
1111
+	/**
1112
+	 * @deprecated 4.9.27
1113
+	 * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1114
+	 * @param  string $pan_message the message to be stored persistently until dismissed
1115
+	 * @param  string $return_url  URL to go back to after nag notice is dismissed
1116
+	 */
1117
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1118
+	{
1119
+		EE_Error::doing_it_wrong(
1120
+			__METHOD__,
1121
+			sprintf(
1122
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1123
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1124
+			),
1125
+			'4.9.27'
1126
+		);
1127
+	}
1128
+
1129
+
1130
+
1131
+	/**
1132
+	 * @deprecated 4.9.27
1133
+	 * @param string $return_url
1134
+	 */
1135
+	public static function get_persistent_admin_notices($return_url = '')
1136
+	{
1137
+		EE_Error::doing_it_wrong(
1138
+			__METHOD__,
1139
+			sprintf(
1140
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1141
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1142
+			),
1143
+			'4.9.27'
1144
+		);
1145
+	}
1146 1146
 
1147 1147
 
1148 1148
 
@@ -1157,27 +1157,27 @@  discard block
 block discarded – undo
1157 1157
  */
1158 1158
 function espresso_error_enqueue_scripts()
1159 1159
 {
1160
-    // js for error handling
1161
-    wp_register_script(
1162
-        'espresso_core',
1163
-        EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1164
-        array('jquery'),
1165
-        EVENT_ESPRESSO_VERSION,
1166
-        false
1167
-    );
1168
-    wp_register_script(
1169
-        'ee_error_js',
1170
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1171
-        array('espresso_core'),
1172
-        EVENT_ESPRESSO_VERSION,
1173
-        false
1174
-    );
1160
+	// js for error handling
1161
+	wp_register_script(
1162
+		'espresso_core',
1163
+		EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1164
+		array('jquery'),
1165
+		EVENT_ESPRESSO_VERSION,
1166
+		false
1167
+	);
1168
+	wp_register_script(
1169
+		'ee_error_js',
1170
+		EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1171
+		array('espresso_core'),
1172
+		EVENT_ESPRESSO_VERSION,
1173
+		false
1174
+	);
1175 1175
 }
1176 1176
 
1177 1177
 if (is_admin()) {
1178
-    add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1178
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1179 1179
 } else {
1180
-    add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1180
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1181 1181
 }
1182 1182
 
1183 1183
 
Please login to merge, or discard this patch.
core/bootstrap_espresso.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function espresso_load_error_handling()
11 11
 {
12
-    static $error_handling_loaded = false;
13
-    if ($error_handling_loaded) {
14
-        return;
15
-    }
16
-    // load debugging tools
17
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
18
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
19
-        \EEH_Debug_Tools::instance();
20
-    }
21
-    // load error handling
22
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
23
-        require_once EE_CORE . 'EE_Error.core.php';
24
-    } else {
25
-        wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
26
-    }
27
-    $error_handling_loaded = true;
12
+	static $error_handling_loaded = false;
13
+	if ($error_handling_loaded) {
14
+		return;
15
+	}
16
+	// load debugging tools
17
+	if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
18
+		require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
19
+		\EEH_Debug_Tools::instance();
20
+	}
21
+	// load error handling
22
+	if (is_readable(EE_CORE . 'EE_Error.core.php')) {
23
+		require_once EE_CORE . 'EE_Error.core.php';
24
+	} else {
25
+		wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
26
+	}
27
+	$error_handling_loaded = true;
28 28
 }
29 29
 
30 30
 
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function espresso_load_required($classname, $full_path_to_file)
40 40
 {
41
-    if (is_readable($full_path_to_file)) {
42
-        require_once $full_path_to_file;
43
-    } else {
44
-        throw new \EE_Error (
45
-            sprintf(
46
-                esc_html__(
47
-                    'The %s class file could not be located or is not readable due to file permissions.',
48
-                    'event_espresso'
49
-                ),
50
-                $classname
51
-            )
52
-        );
53
-    }
41
+	if (is_readable($full_path_to_file)) {
42
+		require_once $full_path_to_file;
43
+	} else {
44
+		throw new \EE_Error (
45
+			sprintf(
46
+				esc_html__(
47
+					'The %s class file could not be located or is not readable due to file permissions.',
48
+					'event_espresso'
49
+				),
50
+				$classname
51
+			)
52
+		);
53
+	}
54 54
 }
55 55
 
56 56
 
@@ -69,41 +69,41 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function bootstrap_espresso()
71 71
 {
72
-    require_once __DIR__ . '/espresso_definitions.php';
73
-    try {
74
-        espresso_load_error_handling();
75
-        espresso_load_required(
76
-            'EEH_Base',
77
-            EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
78
-        );
79
-        espresso_load_required(
80
-            'EEH_File',
81
-            EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
82
-        );
83
-        espresso_load_required(
84
-            'EEH_File',
85
-            EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
86
-        );
87
-        espresso_load_required(
88
-            'EEH_Array',
89
-            EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
90
-        );
91
-        // instantiate and configure PSR4 autoloader
92
-        espresso_load_required(
93
-            'Psr4Autoloader',
94
-            EE_CORE . 'Psr4Autoloader.php'
95
-        );
96
-        espresso_load_required(
97
-            'EE_Psr4AutoloaderInit',
98
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
99
-        );
100
-        $AutoloaderInit = new EE_Psr4AutoloaderInit();
101
-        $AutoloaderInit->initializeAutoloader();
102
-        new EventEspresso\core\services\bootstrap\BootstrapCore();
103
-    } catch (Exception $e) {
104
-        require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
105
-        new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
106
-    }
72
+	require_once __DIR__ . '/espresso_definitions.php';
73
+	try {
74
+		espresso_load_error_handling();
75
+		espresso_load_required(
76
+			'EEH_Base',
77
+			EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
78
+		);
79
+		espresso_load_required(
80
+			'EEH_File',
81
+			EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
82
+		);
83
+		espresso_load_required(
84
+			'EEH_File',
85
+			EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
86
+		);
87
+		espresso_load_required(
88
+			'EEH_Array',
89
+			EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
90
+		);
91
+		// instantiate and configure PSR4 autoloader
92
+		espresso_load_required(
93
+			'Psr4Autoloader',
94
+			EE_CORE . 'Psr4Autoloader.php'
95
+		);
96
+		espresso_load_required(
97
+			'EE_Psr4AutoloaderInit',
98
+			EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
99
+		);
100
+		$AutoloaderInit = new EE_Psr4AutoloaderInit();
101
+		$AutoloaderInit->initializeAutoloader();
102
+		new EventEspresso\core\services\bootstrap\BootstrapCore();
103
+	} catch (Exception $e) {
104
+		require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
105
+		new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
106
+	}
107 107
 }
108 108
 
109 109
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
         return;
15 15
     }
16 16
     // load debugging tools
17
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
18
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
17
+    if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
18
+        require_once EE_HELPERS.'EEH_Debug_Tools.helper.php';
19 19
         \EEH_Debug_Tools::instance();
20 20
     }
21 21
     // load error handling
22
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
23
-        require_once EE_CORE . 'EE_Error.core.php';
22
+    if (is_readable(EE_CORE.'EE_Error.core.php')) {
23
+        require_once EE_CORE.'EE_Error.core.php';
24 24
     } else {
25 25
         wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
26 26
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     if (is_readable($full_path_to_file)) {
42 42
         require_once $full_path_to_file;
43 43
     } else {
44
-        throw new \EE_Error (
44
+        throw new \EE_Error(
45 45
             sprintf(
46 46
                 esc_html__(
47 47
                     'The %s class file could not be located or is not readable due to file permissions.',
@@ -69,39 +69,39 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function bootstrap_espresso()
71 71
 {
72
-    require_once __DIR__ . '/espresso_definitions.php';
72
+    require_once __DIR__.'/espresso_definitions.php';
73 73
     try {
74 74
         espresso_load_error_handling();
75 75
         espresso_load_required(
76 76
             'EEH_Base',
77
-            EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
77
+            EE_CORE.'helpers'.DS.'EEH_Base.helper.php'
78 78
         );
79 79
         espresso_load_required(
80 80
             'EEH_File',
81
-            EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
81
+            EE_CORE.'interfaces'.DS.'EEHI_File.interface.php'
82 82
         );
83 83
         espresso_load_required(
84 84
             'EEH_File',
85
-            EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
85
+            EE_CORE.'helpers'.DS.'EEH_File.helper.php'
86 86
         );
87 87
         espresso_load_required(
88 88
             'EEH_Array',
89
-            EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
89
+            EE_CORE.'helpers'.DS.'EEH_Array.helper.php'
90 90
         );
91 91
         // instantiate and configure PSR4 autoloader
92 92
         espresso_load_required(
93 93
             'Psr4Autoloader',
94
-            EE_CORE . 'Psr4Autoloader.php'
94
+            EE_CORE.'Psr4Autoloader.php'
95 95
         );
96 96
         espresso_load_required(
97 97
             'EE_Psr4AutoloaderInit',
98
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
98
+            EE_CORE.'EE_Psr4AutoloaderInit.core.php'
99 99
         );
100 100
         $AutoloaderInit = new EE_Psr4AutoloaderInit();
101 101
         $AutoloaderInit->initializeAutoloader();
102 102
         new EventEspresso\core\services\bootstrap\BootstrapCore();
103 103
     } catch (Exception $e) {
104
-        require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
104
+        require_once EE_CORE.'exceptions'.DS.'ExceptionStackTraceDisplay.php';
105 105
         new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
106 106
     }
107 107
 }
Please login to merge, or discard this patch.
espresso.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
+    if ( ! function_exists('espresso_duplicate_plugin_error')) {
42 42
         /**
43 43
          *    espresso_duplicate_plugin_error
44 44
          *    displays if more than one version of EE is activated at the same time
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 } else {
65 65
     define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67 67
         /**
68 68
          * espresso_minimum_php_version_error
69 69
          * @return void
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 
117 117
         register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
119
+        require_once __DIR__.'/core/bootstrap_espresso.php';
120 120
         bootstrap_espresso();
121 121
     }
122 122
 }
123
-if (! function_exists('espresso_deactivate_plugin')) {
123
+if ( ! function_exists('espresso_deactivate_plugin')) {
124 124
     /**
125 125
      *    deactivate_plugin
126 126
      * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      */
132 132
     function espresso_deactivate_plugin($plugin_basename = '')
133 133
     {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
134
+        if ( ! function_exists('deactivate_plugins')) {
135
+            require_once ABSPATH.'wp-admin/includes/plugin.php';
136 136
         }
137 137
         unset($_GET['activate'], $_REQUEST['activate']);
138 138
         deactivate_plugins($plugin_basename);
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.59.rc.009');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.59.rc.009');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Indentation   +1432 added lines, -1432 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\request\middleware\RecommendedVersions;
4 4
 
5 5
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6
-    exit('No direct script access allowed');
6
+	exit('No direct script access allowed');
7 7
 }
8 8
 
9 9
 /**
@@ -28,470 +28,470 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     * This gets set in _setup_cpt
33
-     * It will contain the object for the custom post type.
34
-     *
35
-     * @var EE_CPT_Base
36
-     */
37
-    protected $_cpt_object;
38
-
39
-
40
-
41
-    /**
42
-     * a boolean flag to set whether the current route is a cpt route or not.
43
-     *
44
-     * @var bool
45
-     */
46
-    protected $_cpt_route = false;
47
-
48
-
49
-
50
-    /**
51
-     * This property allows cpt classes to define multiple routes as cpt routes.
52
-     * //in this array we define what the custom post type for this route is.
53
-     * array(
54
-     * 'route_name' => 'custom_post_type_slug'
55
-     * )
56
-     *
57
-     * @var array
58
-     */
59
-    protected $_cpt_routes = array();
60
-
31
+	/**
32
+	 * This gets set in _setup_cpt
33
+	 * It will contain the object for the custom post type.
34
+	 *
35
+	 * @var EE_CPT_Base
36
+	 */
37
+	protected $_cpt_object;
38
+
39
+
40
+
41
+	/**
42
+	 * a boolean flag to set whether the current route is a cpt route or not.
43
+	 *
44
+	 * @var bool
45
+	 */
46
+	protected $_cpt_route = false;
47
+
48
+
49
+
50
+	/**
51
+	 * This property allows cpt classes to define multiple routes as cpt routes.
52
+	 * //in this array we define what the custom post type for this route is.
53
+	 * array(
54
+	 * 'route_name' => 'custom_post_type_slug'
55
+	 * )
56
+	 *
57
+	 * @var array
58
+	 */
59
+	protected $_cpt_routes = array();
60
+
61 61
 
62 62
 
63
-    /**
64
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
65
-     * in this format:
66
-     * array(
67
-     * 'post_type_slug' => 'edit_route'
68
-     * )
69
-     *
70
-     * @var array
71
-     */
72
-    protected $_cpt_edit_routes = array();
73
-
74
-
75
-
76
-    /**
77
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
78
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
79
-     * _cpt_model_names property should be in the following format: array(
80
-     * 'route_defined_by_action_param' => 'Model_Name')
81
-     *
82
-     * @var array $_cpt_model_names
83
-     */
84
-    protected $_cpt_model_names = array();
85
-
86
-
87
-    /**
88
-     * @var EE_CPT_Base
89
-     */
90
-    protected $_cpt_model_obj = false;
91
-
92
-
93
-
94
-    /**
95
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
96
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
97
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
98
-     * Registration of containers should be done before load_page_dependencies() is run.
99
-     *
100
-     * @var array()
101
-     */
102
-    protected $_autosave_containers = array();
103
-    protected $_autosave_fields = array();
104
-
105
-    /**
106
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
107
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
108
-     *
109
-     * @var array
110
-     */
111
-    protected $_pagenow_map;
112
-
113
-
114
-
115
-    /**
116
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
117
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
118
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
119
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
120
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
121
-     *
122
-     * @access protected
123
-     * @abstract
124
-     * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
125
-     * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
126
-     * @return void
127
-     */
128
-    abstract protected function _insert_update_cpt_item($post_id, $post);
129
-
130
-
131
-
132
-    /**
133
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
134
-     *
135
-     * @abstract
136
-     * @access public
137
-     * @param  string $post_id The ID of the cpt that was trashed
138
-     * @return void
139
-     */
140
-    abstract public function trash_cpt_item($post_id);
141
-
142
-
143
-
144
-    /**
145
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
146
-     *
147
-     * @param  string $post_id theID of the cpt that was untrashed
148
-     * @return void
149
-     */
150
-    abstract public function restore_cpt_item($post_id);
151
-
152
-
153
-
154
-    /**
155
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
156
-     * from the db
157
-     *
158
-     * @param  string $post_id the ID of the cpt that was deleted
159
-     * @return void
160
-     */
161
-    abstract public function delete_cpt_item($post_id);
162
-
163
-
164
-
165
-    /**
166
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
167
-     *
168
-     * @access protected
169
-     * @return void
170
-     */
171
-    protected function _before_page_setup()
172
-    {
173
-        $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
174
-        $this->_cpt_routes = array_merge(array(
175
-            'create_new' => $this->page_slug,
176
-            'edit'       => $this->page_slug,
177
-            'trash'      => $this->page_slug,
178
-        ), $this->_cpt_routes);
179
-        //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
180
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
181
-            ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
182
-            : get_post_type_object($page);
183
-        //tweak pagenow for page loading.
184
-        if ( ! $this->_pagenow_map) {
185
-            $this->_pagenow_map = array(
186
-                'create_new' => 'post-new.php',
187
-                'edit'       => 'post.php',
188
-                'trash'      => 'post.php',
189
-            );
190
-        }
191
-        add_action('current_screen', array($this, 'modify_pagenow'));
192
-        //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
193
-        //get current page from autosave
194
-        $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
195
-            ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
196
-            : null;
197
-        $this->_current_page = isset($this->_req_data['current_page'])
198
-            ? $this->_req_data['current_page']
199
-            : $current_page;
200
-        //autosave... make sure its only for the correct page
201
-        //if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
202
-            //setup autosave ajax hook
203
-            //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
204
-        //}
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * Simply ensure that we simulate the correct post route for cpt screens
211
-     *
212
-     * @param WP_Screen $current_screen
213
-     * @return void
214
-     */
215
-    public function modify_pagenow($current_screen)
216
-    {
217
-        global $pagenow, $hook_suffix;
218
-        //possibly reset pagenow.
219
-        if ( ! empty($this->_req_data['page'])
220
-             && $this->_req_data['page'] == $this->page_slug
221
-             && ! empty($this->_req_data['action'])
222
-             && isset($this->_pagenow_map[$this->_req_data['action']])
223
-        ) {
224
-            $pagenow = $this->_pagenow_map[$this->_req_data['action']];
225
-            $hook_suffix = $pagenow;
226
-        }
227
-    }
228
-
229
-
230
-
231
-    /**
232
-     * This method is used to register additional autosave containers to the _autosave_containers property.
233
-     *
234
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
235
-     *       automatically register the id for the post metabox as a container.
236
-     * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
237
-     *                    you would send along the id of a metabox container.
238
-     * @return void
239
-     */
240
-    protected function _register_autosave_containers($ids)
241
-    {
242
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids);
243
-    }
244
-
245
-
246
-
247
-    /**
248
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
249
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
250
-     */
251
-    protected function _set_autosave_containers()
252
-    {
253
-        global $wp_meta_boxes;
254
-        $containers = array();
255
-        if (empty($wp_meta_boxes)) {
256
-            return;
257
-        }
258
-        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
259
-        foreach ($current_metaboxes as $box_context) {
260
-            foreach ($box_context as $box_details) {
261
-                foreach ($box_details as $box) {
262
-                    if (
263
-                        is_array($box['callback'])
264
-                        && (
265
-                            $box['callback'][0] instanceof EE_Admin_Page
266
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
267
-                        )
268
-                    ) {
269
-                        $containers[] = $box['id'];
270
-                    }
271
-                }
272
-            }
273
-        }
274
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
275
-        //add hidden inputs container
276
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
277
-    }
278
-
279
-
280
-
281
-    protected function _load_autosave_scripts_styles()
282
-    {
283
-        /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
63
+	/**
64
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
65
+	 * in this format:
66
+	 * array(
67
+	 * 'post_type_slug' => 'edit_route'
68
+	 * )
69
+	 *
70
+	 * @var array
71
+	 */
72
+	protected $_cpt_edit_routes = array();
73
+
74
+
75
+
76
+	/**
77
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
78
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
79
+	 * _cpt_model_names property should be in the following format: array(
80
+	 * 'route_defined_by_action_param' => 'Model_Name')
81
+	 *
82
+	 * @var array $_cpt_model_names
83
+	 */
84
+	protected $_cpt_model_names = array();
85
+
86
+
87
+	/**
88
+	 * @var EE_CPT_Base
89
+	 */
90
+	protected $_cpt_model_obj = false;
91
+
92
+
93
+
94
+	/**
95
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
96
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
97
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
98
+	 * Registration of containers should be done before load_page_dependencies() is run.
99
+	 *
100
+	 * @var array()
101
+	 */
102
+	protected $_autosave_containers = array();
103
+	protected $_autosave_fields = array();
104
+
105
+	/**
106
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
107
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
108
+	 *
109
+	 * @var array
110
+	 */
111
+	protected $_pagenow_map;
112
+
113
+
114
+
115
+	/**
116
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
117
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
118
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
119
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
120
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
121
+	 *
122
+	 * @access protected
123
+	 * @abstract
124
+	 * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
125
+	 * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
126
+	 * @return void
127
+	 */
128
+	abstract protected function _insert_update_cpt_item($post_id, $post);
129
+
130
+
131
+
132
+	/**
133
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
134
+	 *
135
+	 * @abstract
136
+	 * @access public
137
+	 * @param  string $post_id The ID of the cpt that was trashed
138
+	 * @return void
139
+	 */
140
+	abstract public function trash_cpt_item($post_id);
141
+
142
+
143
+
144
+	/**
145
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
146
+	 *
147
+	 * @param  string $post_id theID of the cpt that was untrashed
148
+	 * @return void
149
+	 */
150
+	abstract public function restore_cpt_item($post_id);
151
+
152
+
153
+
154
+	/**
155
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
156
+	 * from the db
157
+	 *
158
+	 * @param  string $post_id the ID of the cpt that was deleted
159
+	 * @return void
160
+	 */
161
+	abstract public function delete_cpt_item($post_id);
162
+
163
+
164
+
165
+	/**
166
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
167
+	 *
168
+	 * @access protected
169
+	 * @return void
170
+	 */
171
+	protected function _before_page_setup()
172
+	{
173
+		$page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
174
+		$this->_cpt_routes = array_merge(array(
175
+			'create_new' => $this->page_slug,
176
+			'edit'       => $this->page_slug,
177
+			'trash'      => $this->page_slug,
178
+		), $this->_cpt_routes);
179
+		//let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
180
+		$this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
181
+			? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
182
+			: get_post_type_object($page);
183
+		//tweak pagenow for page loading.
184
+		if ( ! $this->_pagenow_map) {
185
+			$this->_pagenow_map = array(
186
+				'create_new' => 'post-new.php',
187
+				'edit'       => 'post.php',
188
+				'trash'      => 'post.php',
189
+			);
190
+		}
191
+		add_action('current_screen', array($this, 'modify_pagenow'));
192
+		//TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
193
+		//get current page from autosave
194
+		$current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
195
+			? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
196
+			: null;
197
+		$this->_current_page = isset($this->_req_data['current_page'])
198
+			? $this->_req_data['current_page']
199
+			: $current_page;
200
+		//autosave... make sure its only for the correct page
201
+		//if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
202
+			//setup autosave ajax hook
203
+			//add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
204
+		//}
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * Simply ensure that we simulate the correct post route for cpt screens
211
+	 *
212
+	 * @param WP_Screen $current_screen
213
+	 * @return void
214
+	 */
215
+	public function modify_pagenow($current_screen)
216
+	{
217
+		global $pagenow, $hook_suffix;
218
+		//possibly reset pagenow.
219
+		if ( ! empty($this->_req_data['page'])
220
+			 && $this->_req_data['page'] == $this->page_slug
221
+			 && ! empty($this->_req_data['action'])
222
+			 && isset($this->_pagenow_map[$this->_req_data['action']])
223
+		) {
224
+			$pagenow = $this->_pagenow_map[$this->_req_data['action']];
225
+			$hook_suffix = $pagenow;
226
+		}
227
+	}
228
+
229
+
230
+
231
+	/**
232
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
233
+	 *
234
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
235
+	 *       automatically register the id for the post metabox as a container.
236
+	 * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
237
+	 *                    you would send along the id of a metabox container.
238
+	 * @return void
239
+	 */
240
+	protected function _register_autosave_containers($ids)
241
+	{
242
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids);
243
+	}
244
+
245
+
246
+
247
+	/**
248
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
249
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
250
+	 */
251
+	protected function _set_autosave_containers()
252
+	{
253
+		global $wp_meta_boxes;
254
+		$containers = array();
255
+		if (empty($wp_meta_boxes)) {
256
+			return;
257
+		}
258
+		$current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
259
+		foreach ($current_metaboxes as $box_context) {
260
+			foreach ($box_context as $box_details) {
261
+				foreach ($box_details as $box) {
262
+					if (
263
+						is_array($box['callback'])
264
+						&& (
265
+							$box['callback'][0] instanceof EE_Admin_Page
266
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
267
+						)
268
+					) {
269
+						$containers[] = $box['id'];
270
+					}
271
+				}
272
+			}
273
+		}
274
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
275
+		//add hidden inputs container
276
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
277
+	}
278
+
279
+
280
+
281
+	protected function _load_autosave_scripts_styles()
282
+	{
283
+		/*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
284 284
         wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2
285 285
 
286
-        //filter _autosave_containers
287
-        $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
288
-            $this->_autosave_containers, $this);
289
-        $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
290
-            $containers, $this);
291
-
292
-        wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS',
293
-            $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
294
-
295
-        $unsaved_data_msg = array(
296
-            'eventmsg'     => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.",
297
-                'event_espresso'), $this->_cpt_object->labels->singular_name),
298
-            'inputChanged' => 0,
299
-        );
300
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
301
-    }
302
-
303
-
304
-
305
-    public function load_page_dependencies()
306
-    {
307
-        try {
308
-            $this->_load_page_dependencies();
309
-        } catch (EE_Error $e) {
310
-            $e->get_error();
311
-        }
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
318
-     *
319
-     * @access protected
320
-     * @return void
321
-     */
322
-    protected function _load_page_dependencies()
323
-    {
324
-        //we only add stuff if this is a cpt_route!
325
-        if ( ! $this->_cpt_route) {
326
-            parent::_load_page_dependencies();
327
-            return;
328
-        }
329
-        // now let's do some automatic filters into the wp_system
330
-        // and we'll check to make sure the CHILD class
331
-        // automatically has the required methods in place.
332
-        // the following filters are for setting all the redirects
333
-        // on DEFAULT WP custom post type actions
334
-        // let's add a hidden input to the post-edit form
335
-        // so we know when we have to trigger our custom redirects!
336
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
337
-        add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
338
-        // inject our Admin page nav tabs...
339
-        // let's make sure the nav tabs are set if they aren't already
340
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
341
-        add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
342
-        // modify the post_updated messages array
343
-        add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
344
-        // add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
345
-        // cpts use the same format for shortlinks as posts!
346
-        add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
347
-        // This basically allows us to change the title of the "publish" metabox area
348
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
349
-        if ( ! empty($this->_labels['publishbox'])) {
350
-            $box_label = is_array($this->_labels['publishbox'])
351
-                         && isset($this->_labels['publishbox'][$this->_req_action])
352
-                    ? $this->_labels['publishbox'][$this->_req_action]
353
-                    : $this->_labels['publishbox'];
354
-            add_meta_box(
355
-                'submitdiv',
356
-                $box_label,
357
-                'post_submit_meta_box',
358
-                $this->_cpt_routes[$this->_req_action],
359
-                'side',
360
-                'core'
361
-            );
362
-        }
363
-        //let's add page_templates metabox if this cpt added support for it.
364
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
365
-            add_meta_box(
366
-                'page_templates',
367
-                __('Page Template', 'event_espresso'),
368
-                array($this, 'page_template_meta_box'),
369
-                $this->_cpt_routes[$this->_req_action],
370
-                'side',
371
-                'default'
372
-            );
373
-        }
374
-        //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
375
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
376
-            add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
377
-        }
378
-        //add preview button
379
-        add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
380
-        //insert our own post_stati dropdown
381
-        add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
382
-        //This allows adding additional information to the publish post submitbox on the wp post edit form
383
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
384
-            add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
385
-        }
386
-        // This allows for adding additional stuff after the title field on the wp post edit form.
387
-        // This is also before the wp_editor for post description field.
388
-        if (method_exists($this, 'edit_form_after_title')) {
389
-            add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
390
-        }
391
-        /**
392
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
393
-         */
394
-        add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
395
-        parent::_load_page_dependencies();
396
-        // notice we are ALSO going to load the pagenow hook set for this route
397
-        // (see _before_page_setup for the reset of the pagenow global ).
398
-        // This is for any plugins that are doing things properly
399
-        // and hooking into the load page hook for core wp cpt routes.
400
-        global $pagenow;
401
-        do_action('load-' . $pagenow);
402
-        $this->modify_current_screen();
403
-        add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
404
-        //we route REALLY early.
405
-        try {
406
-            $this->_route_admin_request();
407
-        } catch (EE_Error $e) {
408
-            $e->get_error();
409
-        }
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
416
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
417
-     * route instead.
418
-     *
419
-     * @param string $good_protocol_url The escaped url.
420
-     * @param string $original_url      The original url.
421
-     * @param string $_context          The context sent to the esc_url method.
422
-     * @return string possibly a new url for our route.
423
-     */
424
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
425
-    {
426
-        $routes_to_match = array(
427
-            0 => array(
428
-                'edit.php?post_type=espresso_attendees',
429
-                'admin.php?page=espresso_registrations&action=contact_list',
430
-            ),
431
-            1 => array(
432
-                'edit.php?post_type=' . $this->_cpt_object->name,
433
-                'admin.php?page=' . $this->_cpt_object->name,
434
-            ),
435
-        );
436
-        foreach ($routes_to_match as $route_matches) {
437
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
438
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
439
-            }
440
-        }
441
-        return $good_protocol_url;
442
-    }
443
-
444
-
445
-
446
-    /**
447
-     * Determine whether the current cpt supports page templates or not.
448
-     *
449
-     * @since %VER%
450
-     * @param string $cpt_name The cpt slug we're checking on.
451
-     * @return bool True supported, false not.
452
-     */
453
-    private function _supports_page_templates($cpt_name)
454
-    {
455
-
456
-        $cpt_args = EE_Register_CPTs::get_CPTs();
457
-        $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
458
-        $cpt_has_support = ! empty($cpt_args['page_templates']);
459
-
460
-        //if the installed version of WP is > 4.7 we do some additional checks.
461
-        if (RecommendedVersions::compareWordPressVersion('4.7','>=')) {
462
-            $post_templates = wp_get_theme()->get_post_templates();
463
-            //if there are $post_templates for this cpt, then we return false for this method because
464
-            //that means we aren't going to load our page template manager and leave that up to the native
465
-            //cpt template manager.
466
-            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
467
-        }
468
-
469
-        return $cpt_has_support;
470
-    }
471
-
472
-
473
-    /**
474
-     * Callback for the page_templates metabox selector.
475
-     *
476
-     * @since %VER%
477
-     * @return void
478
-     */
479
-    public function page_template_meta_box()
480
-    {
481
-        global $post;
482
-        $template = '';
483
-
484
-        if (RecommendedVersions::compareWordPressVersion('4.7','>=')) {
485
-            $page_template_count = count(get_page_templates());
486
-        } else {
487
-            $page_template_count = count(get_page_templates($post));
488
-        };
489
-
490
-        if ($page_template_count) {
491
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
492
-            $template      = ! empty($page_template) ? $page_template : '';
493
-        }
494
-        ?>
286
+		//filter _autosave_containers
287
+		$containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
288
+			$this->_autosave_containers, $this);
289
+		$containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
290
+			$containers, $this);
291
+
292
+		wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS',
293
+			$containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
294
+
295
+		$unsaved_data_msg = array(
296
+			'eventmsg'     => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.",
297
+				'event_espresso'), $this->_cpt_object->labels->singular_name),
298
+			'inputChanged' => 0,
299
+		);
300
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
301
+	}
302
+
303
+
304
+
305
+	public function load_page_dependencies()
306
+	{
307
+		try {
308
+			$this->_load_page_dependencies();
309
+		} catch (EE_Error $e) {
310
+			$e->get_error();
311
+		}
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
318
+	 *
319
+	 * @access protected
320
+	 * @return void
321
+	 */
322
+	protected function _load_page_dependencies()
323
+	{
324
+		//we only add stuff if this is a cpt_route!
325
+		if ( ! $this->_cpt_route) {
326
+			parent::_load_page_dependencies();
327
+			return;
328
+		}
329
+		// now let's do some automatic filters into the wp_system
330
+		// and we'll check to make sure the CHILD class
331
+		// automatically has the required methods in place.
332
+		// the following filters are for setting all the redirects
333
+		// on DEFAULT WP custom post type actions
334
+		// let's add a hidden input to the post-edit form
335
+		// so we know when we have to trigger our custom redirects!
336
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
337
+		add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
338
+		// inject our Admin page nav tabs...
339
+		// let's make sure the nav tabs are set if they aren't already
340
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
341
+		add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
342
+		// modify the post_updated messages array
343
+		add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
344
+		// add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
345
+		// cpts use the same format for shortlinks as posts!
346
+		add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
347
+		// This basically allows us to change the title of the "publish" metabox area
348
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
349
+		if ( ! empty($this->_labels['publishbox'])) {
350
+			$box_label = is_array($this->_labels['publishbox'])
351
+						 && isset($this->_labels['publishbox'][$this->_req_action])
352
+					? $this->_labels['publishbox'][$this->_req_action]
353
+					: $this->_labels['publishbox'];
354
+			add_meta_box(
355
+				'submitdiv',
356
+				$box_label,
357
+				'post_submit_meta_box',
358
+				$this->_cpt_routes[$this->_req_action],
359
+				'side',
360
+				'core'
361
+			);
362
+		}
363
+		//let's add page_templates metabox if this cpt added support for it.
364
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
365
+			add_meta_box(
366
+				'page_templates',
367
+				__('Page Template', 'event_espresso'),
368
+				array($this, 'page_template_meta_box'),
369
+				$this->_cpt_routes[$this->_req_action],
370
+				'side',
371
+				'default'
372
+			);
373
+		}
374
+		//this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
375
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
376
+			add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
377
+		}
378
+		//add preview button
379
+		add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
380
+		//insert our own post_stati dropdown
381
+		add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
382
+		//This allows adding additional information to the publish post submitbox on the wp post edit form
383
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
384
+			add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
385
+		}
386
+		// This allows for adding additional stuff after the title field on the wp post edit form.
387
+		// This is also before the wp_editor for post description field.
388
+		if (method_exists($this, 'edit_form_after_title')) {
389
+			add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
390
+		}
391
+		/**
392
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
393
+		 */
394
+		add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
395
+		parent::_load_page_dependencies();
396
+		// notice we are ALSO going to load the pagenow hook set for this route
397
+		// (see _before_page_setup for the reset of the pagenow global ).
398
+		// This is for any plugins that are doing things properly
399
+		// and hooking into the load page hook for core wp cpt routes.
400
+		global $pagenow;
401
+		do_action('load-' . $pagenow);
402
+		$this->modify_current_screen();
403
+		add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
404
+		//we route REALLY early.
405
+		try {
406
+			$this->_route_admin_request();
407
+		} catch (EE_Error $e) {
408
+			$e->get_error();
409
+		}
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
416
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
417
+	 * route instead.
418
+	 *
419
+	 * @param string $good_protocol_url The escaped url.
420
+	 * @param string $original_url      The original url.
421
+	 * @param string $_context          The context sent to the esc_url method.
422
+	 * @return string possibly a new url for our route.
423
+	 */
424
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
425
+	{
426
+		$routes_to_match = array(
427
+			0 => array(
428
+				'edit.php?post_type=espresso_attendees',
429
+				'admin.php?page=espresso_registrations&action=contact_list',
430
+			),
431
+			1 => array(
432
+				'edit.php?post_type=' . $this->_cpt_object->name,
433
+				'admin.php?page=' . $this->_cpt_object->name,
434
+			),
435
+		);
436
+		foreach ($routes_to_match as $route_matches) {
437
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
438
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
439
+			}
440
+		}
441
+		return $good_protocol_url;
442
+	}
443
+
444
+
445
+
446
+	/**
447
+	 * Determine whether the current cpt supports page templates or not.
448
+	 *
449
+	 * @since %VER%
450
+	 * @param string $cpt_name The cpt slug we're checking on.
451
+	 * @return bool True supported, false not.
452
+	 */
453
+	private function _supports_page_templates($cpt_name)
454
+	{
455
+
456
+		$cpt_args = EE_Register_CPTs::get_CPTs();
457
+		$cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
458
+		$cpt_has_support = ! empty($cpt_args['page_templates']);
459
+
460
+		//if the installed version of WP is > 4.7 we do some additional checks.
461
+		if (RecommendedVersions::compareWordPressVersion('4.7','>=')) {
462
+			$post_templates = wp_get_theme()->get_post_templates();
463
+			//if there are $post_templates for this cpt, then we return false for this method because
464
+			//that means we aren't going to load our page template manager and leave that up to the native
465
+			//cpt template manager.
466
+			$cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
467
+		}
468
+
469
+		return $cpt_has_support;
470
+	}
471
+
472
+
473
+	/**
474
+	 * Callback for the page_templates metabox selector.
475
+	 *
476
+	 * @since %VER%
477
+	 * @return void
478
+	 */
479
+	public function page_template_meta_box()
480
+	{
481
+		global $post;
482
+		$template = '';
483
+
484
+		if (RecommendedVersions::compareWordPressVersion('4.7','>=')) {
485
+			$page_template_count = count(get_page_templates());
486
+		} else {
487
+			$page_template_count = count(get_page_templates($post));
488
+		};
489
+
490
+		if ($page_template_count) {
491
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
492
+			$template      = ! empty($page_template) ? $page_template : '';
493
+		}
494
+		?>
495 495
         <p><strong><?php _e('Template') ?></strong></p>
496 496
         <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select
497 497
             name="page_template" id="page_template">
@@ -499,450 +499,450 @@  discard block
 block discarded – undo
499 499
         <?php page_template_dropdown($template); ?>
500 500
     </select>
501 501
         <?php
502
-    }
503
-
504
-
505
-
506
-    /**
507
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
508
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
509
-     *
510
-     * @param  string $return    the current html
511
-     * @param  int    $id        the post id for the page
512
-     * @param  string $new_title What the title is
513
-     * @param  string $new_slug  what the slug is
514
-     * @return string            The new html string for the permalink area
515
-     */
516
-    public function preview_button_html($return, $id, $new_title, $new_slug)
517
-    {
518
-        $post = get_post($id);
519
-        if ('publish' !== get_post_status($post)) {
520
-            //include shims for the `get_preview_post_link` function
521
-            require_once( EE_CORE . 'wordpress-shims.php' );
522
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
523
-                       . get_preview_post_link($id)
524
-                       . '" class="button button-small">'
525
-                       . __('Preview', 'event_espresso')
526
-                       . '</a></span>'
527
-                       . "\n";
528
-        }
529
-        return $return;
530
-    }
531
-
532
-
533
-
534
-    /**
535
-     * add our custom post stati dropdown on the wp post page for this cpt
536
-     *
537
-     * @return void
538
-     */
539
-    public function custom_post_stati_dropdown()
540
-    {
541
-
542
-        $statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
543
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
544
-            ? $statuses[$this->_cpt_model_obj->status()]
545
-            : '';
546
-        $template_args    = array(
547
-            'cur_status'            => $this->_cpt_model_obj->status(),
548
-            'statuses'              => $statuses,
549
-            'cur_status_label'      => $cur_status_label,
550
-            'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
551
-        );
552
-        //we'll add a trash post status (WP doesn't add one for some reason)
553
-        if ($this->_cpt_model_obj->status() === 'trash') {
554
-            $template_args['cur_status_label'] = __('Trashed', 'event_espresso');
555
-            $statuses['trash']                 = __('Trashed', 'event_espresso');
556
-            $template_args['statuses']         = $statuses;
557
-        }
558
-
559
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
560
-        EEH_Template::display_template($template, $template_args);
561
-    }
562
-
563
-
564
-
565
-    public function setup_autosave_hooks()
566
-    {
567
-        $this->_set_autosave_containers();
568
-        $this->_load_autosave_scripts_styles();
569
-    }
570
-
571
-
572
-
573
-    /**
574
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
575
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
576
-     * for the nonce in here, but then this method looks for two things:
577
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
578
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
579
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
580
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
581
-     * template args.
582
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
583
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
584
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
585
-     *    $this->_template_args['data']['items'] = array(
586
-     *        'event-datetime-ids' => '1,2,3';
587
-     *    );
588
-     *    Keep in mind the following things:
589
-     *    - "where" index is for the input with the id as that string.
590
-     *    - "what" index is what will be used for the value of that input.
591
-     *
592
-     * @return void
593
-     */
594
-    public function do_extra_autosave_stuff()
595
-    {
596
-        //next let's check for the autosave nonce (we'll use _verify_nonce )
597
-        $nonce = isset($this->_req_data['autosavenonce'])
598
-                ? $this->_req_data['autosavenonce']
599
-                : null;
600
-        $this->_verify_nonce($nonce, 'autosave');
601
-        //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
602
-        if ( ! defined('DOING_AUTOSAVE')) {
603
-            define('DOING_AUTOSAVE', true);
604
-        }
605
-        //if we made it here then the nonce checked out.  Let's run our methods and actions
606
-        $autosave = "_ee_autosave_{$this->_current_view}";
607
-        if (method_exists($this, $autosave)) {
608
-            $this->$autosave();
609
-        } else {
610
-            $this->_template_args['success'] = true;
611
-        }
612
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
613
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
614
-        //now let's return json
615
-        $this->_return_json();
616
-    }
617
-
618
-
619
-
620
-    /**
621
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
622
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
623
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
624
-     *
625
-     * @access protected
626
-     * @throws EE_Error
627
-     * @return void
628
-     */
629
-    protected function _extend_page_config_for_cpt()
630
-    {
631
-        //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
632
-        if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
633
-            return;
634
-        }
635
-        //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
636
-        if ( ! empty($this->_cpt_object)) {
637
-            $this->_page_routes = array_merge(array(
638
-                'create_new' => '_create_new_cpt_item',
639
-                'edit'       => '_edit_cpt_item',
640
-            ), $this->_page_routes);
641
-            $this->_page_config = array_merge(array(
642
-                'create_new' => array(
643
-                    'nav'           => array(
644
-                        'label' => $this->_cpt_object->labels->add_new_item,
645
-                        'order' => 5,
646
-                    ),
647
-                    'require_nonce' => false,
648
-                ),
649
-                'edit'       => array(
650
-                    'nav'           => array(
651
-                        'label'      => $this->_cpt_object->labels->edit_item,
652
-                        'order'      => 5,
653
-                        'persistent' => false,
654
-                        'url'        => '',
655
-                    ),
656
-                    'require_nonce' => false,
657
-                ),
658
-            ),
659
-                $this->_page_config
660
-            );
661
-        }
662
-        //load the next section only if this is a matching cpt route as set in the cpt routes array.
663
-        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
664
-            return;
665
-        }
666
-        $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
667
-        //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
668
-        if (empty($this->_cpt_object)) {
669
-            $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'),
670
-                $this->page_slug, $this->_req_action, get_class($this));
671
-            throw new EE_Error($msg);
672
-        }
673
-        if ($this->_cpt_route) {
674
-            $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
675
-            $this->_set_model_object($id);
676
-        }
677
-    }
678
-
679
-
680
-
681
-    /**
682
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
683
-     *
684
-     * @access protected
685
-     * @param int  $id The id to retrieve the model object for. If empty we set a default object.
686
-     * @param bool $ignore_route_check
687
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
688
-     * @throws EE_Error
689
-     */
690
-    protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
691
-    {
692
-        $model = null;
693
-        if (
694
-            empty($this->_cpt_model_names)
695
-            || (
696
-                ! $ignore_route_check
697
-                && ! isset($this->_cpt_routes[$this->_req_action])
698
-            ) || (
699
-                $this->_cpt_model_obj instanceof EE_CPT_Base
700
-                && $this->_cpt_model_obj->ID() === $id
701
-            )
702
-        ) {
703
-            //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
704
-            return;
705
-        }
706
-        //if ignore_route_check is true, then get the model name via EE_Register_CPTs
707
-        if ($ignore_route_check) {
708
-            $model_names = EE_Register_CPTs::get_cpt_model_names();
709
-            $post_type   = get_post_type($id);
710
-            if (isset($model_names[$post_type])) {
711
-                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
712
-            }
713
-        } else {
714
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
715
-        }
716
-        if ($model instanceof EEM_Base) {
717
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
718
-        }
719
-        do_action(
720
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
721
-            $this->_cpt_model_obj,
722
-            $req_type
723
-        );
724
-    }
725
-
726
-
727
-
728
-    /**
729
-     * admin_init_global
730
-     * This runs all the code that we want executed within the WP admin_init hook.
731
-     * This method executes for ALL EE Admin pages.
732
-     *
733
-     * @access public
734
-     * @return void
735
-     */
736
-    public function admin_init_global()
737
-    {
738
-        $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
739
-        //its possible this is a new save so let's catch that instead
740
-        $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
741
-        $post_type = $post ? $post->post_type : false;
742
-        $current_route = isset($this->_req_data['current_route'])
743
-            ? $this->_req_data['current_route']
744
-            : 'shouldneverwork';
745
-        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
746
-            ? $this->_cpt_routes[$current_route]
747
-            : '';
748
-        add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
749
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
750
-        if ($post_type === $route_to_check) {
751
-            add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
752
-        }
753
-        //now let's filter redirect if we're on a revision page and the revision is for an event CPT.
754
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
755
-        if ( ! empty($revision)) {
756
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
757
-            //doing a restore?
758
-            if ( ! empty($action) && $action === 'restore') {
759
-                //get post for revision
760
-                $rev_post = get_post($revision);
761
-                $rev_parent = get_post($rev_post->post_parent);
762
-                //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
763
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
764
-                    add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
765
-                    //restores of revisions
766
-                    add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
767
-                }
768
-            }
769
-        }
770
-        //NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
771
-        if ($post_type && $post_type === $route_to_check) {
772
-            //$post_id, $post
773
-            add_action('save_post', array($this, 'insert_update'), 10, 3);
774
-            //$post_id
775
-            add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
776
-            add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
777
-            add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
778
-            add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
779
-        }
780
-    }
781
-
782
-
783
-
784
-    /**
785
-     * Callback for the WordPress trashed_post hook.
786
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
787
-     *
788
-     * @param int $post_id
789
-     * @throws \EE_Error
790
-     */
791
-    public function before_trash_cpt_item($post_id)
792
-    {
793
-        $this->_set_model_object($post_id, true, 'trash');
794
-        //if our cpt object isn't existent then get out immediately.
795
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
796
-            return;
797
-        }
798
-        $this->trash_cpt_item($post_id);
799
-    }
800
-
801
-
802
-
803
-    /**
804
-     * Callback for the WordPress untrashed_post hook.
805
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
806
-     *
807
-     * @param $post_id
808
-     * @throws \EE_Error
809
-     */
810
-    public function before_restore_cpt_item($post_id)
811
-    {
812
-        $this->_set_model_object($post_id, true, 'restore');
813
-        //if our cpt object isn't existent then get out immediately.
814
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
815
-            return;
816
-        }
817
-        $this->restore_cpt_item($post_id);
818
-    }
819
-
820
-
821
-
822
-    /**
823
-     * Callback for the WordPress after_delete_post hook.
824
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
825
-     *
826
-     * @param $post_id
827
-     * @throws \EE_Error
828
-     */
829
-    public function before_delete_cpt_item($post_id)
830
-    {
831
-        $this->_set_model_object($post_id, true, 'delete');
832
-        //if our cpt object isn't existent then get out immediately.
833
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
834
-            return;
835
-        }
836
-        $this->delete_cpt_item($post_id);
837
-    }
838
-
839
-
840
-
841
-    /**
842
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
843
-     * accordingly.
844
-     *
845
-     * @access public
846
-     * @throws EE_Error
847
-     * @return void
848
-     */
849
-    public function verify_cpt_object()
850
-    {
851
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
852
-        // verify event object
853
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
854
-            throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
855
-                    'event_espresso'), $label));
856
-        }
857
-        //if auto-draft then throw an error
858
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
859
-            EE_Error::overwrite_errors();
860
-            EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'),
861
-                    $label), __FILE__, __FUNCTION__, __LINE__);
862
-        }
863
-    }
864
-
865
-
866
-
867
-    /**
868
-     * admin_footer_scripts_global
869
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
870
-     * will apply on ALL EE_Admin pages.
871
-     *
872
-     * @access public
873
-     * @return void
874
-     */
875
-    public function admin_footer_scripts_global()
876
-    {
877
-        $this->_add_admin_page_ajax_loading_img();
878
-        $this->_add_admin_page_overlay();
879
-    }
880
-
881
-
882
-
883
-    /**
884
-     * add in any global scripts for cpt routes
885
-     *
886
-     * @return void
887
-     */
888
-    public function load_global_scripts_styles()
889
-    {
890
-        parent::load_global_scripts_styles();
891
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
892
-            //setup custom post status object for localize script but only if we've got a cpt object
893
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
894
-            if ( ! empty($statuses)) {
895
-                //get ALL statuses!
896
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
897
-                //setup object
898
-                $ee_cpt_statuses = array();
899
-                foreach ($statuses as $status => $label) {
900
-                    $ee_cpt_statuses[$status] = array(
901
-                        'label'      => $label,
902
-                        'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
903
-                    );
904
-                }
905
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
906
-            }
907
-        }
908
-    }
909
-
910
-
911
-
912
-    /**
913
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
914
-     * insert/updates
915
-     *
916
-     * @param  int     $post_id ID of post being updated
917
-     * @param  WP_Post $post    Post object from WP
918
-     * @param  bool    $update  Whether this is an update or a new save.
919
-     * @return void
920
-     * @throws \EE_Error
921
-     */
922
-    public function insert_update($post_id, $post, $update)
923
-    {
924
-        //make sure that if this is a revision OR trash action that we don't do any updates!
925
-        if (
926
-            isset($this->_req_data['action'])
927
-            && (
928
-                $this->_req_data['action'] === 'restore'
929
-                || $this->_req_data['action'] === 'trash'
930
-            )
931
-        ) {
932
-            return;
933
-        }
934
-        $this->_set_model_object($post_id, true, 'insert_update');
935
-        //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
936
-        if ($update
937
-            && (
938
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
939
-                || $this->_cpt_model_obj->ID() !== $post_id
940
-            )
941
-        ) {
942
-            return;
943
-        }
944
-        //check for autosave and update our req_data property accordingly.
945
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
502
+	}
503
+
504
+
505
+
506
+	/**
507
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
508
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
509
+	 *
510
+	 * @param  string $return    the current html
511
+	 * @param  int    $id        the post id for the page
512
+	 * @param  string $new_title What the title is
513
+	 * @param  string $new_slug  what the slug is
514
+	 * @return string            The new html string for the permalink area
515
+	 */
516
+	public function preview_button_html($return, $id, $new_title, $new_slug)
517
+	{
518
+		$post = get_post($id);
519
+		if ('publish' !== get_post_status($post)) {
520
+			//include shims for the `get_preview_post_link` function
521
+			require_once( EE_CORE . 'wordpress-shims.php' );
522
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
523
+					   . get_preview_post_link($id)
524
+					   . '" class="button button-small">'
525
+					   . __('Preview', 'event_espresso')
526
+					   . '</a></span>'
527
+					   . "\n";
528
+		}
529
+		return $return;
530
+	}
531
+
532
+
533
+
534
+	/**
535
+	 * add our custom post stati dropdown on the wp post page for this cpt
536
+	 *
537
+	 * @return void
538
+	 */
539
+	public function custom_post_stati_dropdown()
540
+	{
541
+
542
+		$statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
543
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
544
+			? $statuses[$this->_cpt_model_obj->status()]
545
+			: '';
546
+		$template_args    = array(
547
+			'cur_status'            => $this->_cpt_model_obj->status(),
548
+			'statuses'              => $statuses,
549
+			'cur_status_label'      => $cur_status_label,
550
+			'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
551
+		);
552
+		//we'll add a trash post status (WP doesn't add one for some reason)
553
+		if ($this->_cpt_model_obj->status() === 'trash') {
554
+			$template_args['cur_status_label'] = __('Trashed', 'event_espresso');
555
+			$statuses['trash']                 = __('Trashed', 'event_espresso');
556
+			$template_args['statuses']         = $statuses;
557
+		}
558
+
559
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
560
+		EEH_Template::display_template($template, $template_args);
561
+	}
562
+
563
+
564
+
565
+	public function setup_autosave_hooks()
566
+	{
567
+		$this->_set_autosave_containers();
568
+		$this->_load_autosave_scripts_styles();
569
+	}
570
+
571
+
572
+
573
+	/**
574
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
575
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
576
+	 * for the nonce in here, but then this method looks for two things:
577
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
578
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
579
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
580
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
581
+	 * template args.
582
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
583
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
584
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
585
+	 *    $this->_template_args['data']['items'] = array(
586
+	 *        'event-datetime-ids' => '1,2,3';
587
+	 *    );
588
+	 *    Keep in mind the following things:
589
+	 *    - "where" index is for the input with the id as that string.
590
+	 *    - "what" index is what will be used for the value of that input.
591
+	 *
592
+	 * @return void
593
+	 */
594
+	public function do_extra_autosave_stuff()
595
+	{
596
+		//next let's check for the autosave nonce (we'll use _verify_nonce )
597
+		$nonce = isset($this->_req_data['autosavenonce'])
598
+				? $this->_req_data['autosavenonce']
599
+				: null;
600
+		$this->_verify_nonce($nonce, 'autosave');
601
+		//make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
602
+		if ( ! defined('DOING_AUTOSAVE')) {
603
+			define('DOING_AUTOSAVE', true);
604
+		}
605
+		//if we made it here then the nonce checked out.  Let's run our methods and actions
606
+		$autosave = "_ee_autosave_{$this->_current_view}";
607
+		if (method_exists($this, $autosave)) {
608
+			$this->$autosave();
609
+		} else {
610
+			$this->_template_args['success'] = true;
611
+		}
612
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
613
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
614
+		//now let's return json
615
+		$this->_return_json();
616
+	}
617
+
618
+
619
+
620
+	/**
621
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
622
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
623
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
624
+	 *
625
+	 * @access protected
626
+	 * @throws EE_Error
627
+	 * @return void
628
+	 */
629
+	protected function _extend_page_config_for_cpt()
630
+	{
631
+		//before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
632
+		if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
633
+			return;
634
+		}
635
+		//set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
636
+		if ( ! empty($this->_cpt_object)) {
637
+			$this->_page_routes = array_merge(array(
638
+				'create_new' => '_create_new_cpt_item',
639
+				'edit'       => '_edit_cpt_item',
640
+			), $this->_page_routes);
641
+			$this->_page_config = array_merge(array(
642
+				'create_new' => array(
643
+					'nav'           => array(
644
+						'label' => $this->_cpt_object->labels->add_new_item,
645
+						'order' => 5,
646
+					),
647
+					'require_nonce' => false,
648
+				),
649
+				'edit'       => array(
650
+					'nav'           => array(
651
+						'label'      => $this->_cpt_object->labels->edit_item,
652
+						'order'      => 5,
653
+						'persistent' => false,
654
+						'url'        => '',
655
+					),
656
+					'require_nonce' => false,
657
+				),
658
+			),
659
+				$this->_page_config
660
+			);
661
+		}
662
+		//load the next section only if this is a matching cpt route as set in the cpt routes array.
663
+		if ( ! isset($this->_cpt_routes[$this->_req_action])) {
664
+			return;
665
+		}
666
+		$this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
667
+		//add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
668
+		if (empty($this->_cpt_object)) {
669
+			$msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'),
670
+				$this->page_slug, $this->_req_action, get_class($this));
671
+			throw new EE_Error($msg);
672
+		}
673
+		if ($this->_cpt_route) {
674
+			$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
675
+			$this->_set_model_object($id);
676
+		}
677
+	}
678
+
679
+
680
+
681
+	/**
682
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
683
+	 *
684
+	 * @access protected
685
+	 * @param int  $id The id to retrieve the model object for. If empty we set a default object.
686
+	 * @param bool $ignore_route_check
687
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
688
+	 * @throws EE_Error
689
+	 */
690
+	protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
691
+	{
692
+		$model = null;
693
+		if (
694
+			empty($this->_cpt_model_names)
695
+			|| (
696
+				! $ignore_route_check
697
+				&& ! isset($this->_cpt_routes[$this->_req_action])
698
+			) || (
699
+				$this->_cpt_model_obj instanceof EE_CPT_Base
700
+				&& $this->_cpt_model_obj->ID() === $id
701
+			)
702
+		) {
703
+			//get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
704
+			return;
705
+		}
706
+		//if ignore_route_check is true, then get the model name via EE_Register_CPTs
707
+		if ($ignore_route_check) {
708
+			$model_names = EE_Register_CPTs::get_cpt_model_names();
709
+			$post_type   = get_post_type($id);
710
+			if (isset($model_names[$post_type])) {
711
+				$model = EE_Registry::instance()->load_model($model_names[$post_type]);
712
+			}
713
+		} else {
714
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
715
+		}
716
+		if ($model instanceof EEM_Base) {
717
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
718
+		}
719
+		do_action(
720
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
721
+			$this->_cpt_model_obj,
722
+			$req_type
723
+		);
724
+	}
725
+
726
+
727
+
728
+	/**
729
+	 * admin_init_global
730
+	 * This runs all the code that we want executed within the WP admin_init hook.
731
+	 * This method executes for ALL EE Admin pages.
732
+	 *
733
+	 * @access public
734
+	 * @return void
735
+	 */
736
+	public function admin_init_global()
737
+	{
738
+		$post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
739
+		//its possible this is a new save so let's catch that instead
740
+		$post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
741
+		$post_type = $post ? $post->post_type : false;
742
+		$current_route = isset($this->_req_data['current_route'])
743
+			? $this->_req_data['current_route']
744
+			: 'shouldneverwork';
745
+		$route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
746
+			? $this->_cpt_routes[$current_route]
747
+			: '';
748
+		add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
749
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
750
+		if ($post_type === $route_to_check) {
751
+			add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
752
+		}
753
+		//now let's filter redirect if we're on a revision page and the revision is for an event CPT.
754
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
755
+		if ( ! empty($revision)) {
756
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
757
+			//doing a restore?
758
+			if ( ! empty($action) && $action === 'restore') {
759
+				//get post for revision
760
+				$rev_post = get_post($revision);
761
+				$rev_parent = get_post($rev_post->post_parent);
762
+				//only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
763
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
764
+					add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
765
+					//restores of revisions
766
+					add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
767
+				}
768
+			}
769
+		}
770
+		//NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
771
+		if ($post_type && $post_type === $route_to_check) {
772
+			//$post_id, $post
773
+			add_action('save_post', array($this, 'insert_update'), 10, 3);
774
+			//$post_id
775
+			add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
776
+			add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
777
+			add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
778
+			add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
779
+		}
780
+	}
781
+
782
+
783
+
784
+	/**
785
+	 * Callback for the WordPress trashed_post hook.
786
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
787
+	 *
788
+	 * @param int $post_id
789
+	 * @throws \EE_Error
790
+	 */
791
+	public function before_trash_cpt_item($post_id)
792
+	{
793
+		$this->_set_model_object($post_id, true, 'trash');
794
+		//if our cpt object isn't existent then get out immediately.
795
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
796
+			return;
797
+		}
798
+		$this->trash_cpt_item($post_id);
799
+	}
800
+
801
+
802
+
803
+	/**
804
+	 * Callback for the WordPress untrashed_post hook.
805
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
806
+	 *
807
+	 * @param $post_id
808
+	 * @throws \EE_Error
809
+	 */
810
+	public function before_restore_cpt_item($post_id)
811
+	{
812
+		$this->_set_model_object($post_id, true, 'restore');
813
+		//if our cpt object isn't existent then get out immediately.
814
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
815
+			return;
816
+		}
817
+		$this->restore_cpt_item($post_id);
818
+	}
819
+
820
+
821
+
822
+	/**
823
+	 * Callback for the WordPress after_delete_post hook.
824
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
825
+	 *
826
+	 * @param $post_id
827
+	 * @throws \EE_Error
828
+	 */
829
+	public function before_delete_cpt_item($post_id)
830
+	{
831
+		$this->_set_model_object($post_id, true, 'delete');
832
+		//if our cpt object isn't existent then get out immediately.
833
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
834
+			return;
835
+		}
836
+		$this->delete_cpt_item($post_id);
837
+	}
838
+
839
+
840
+
841
+	/**
842
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
843
+	 * accordingly.
844
+	 *
845
+	 * @access public
846
+	 * @throws EE_Error
847
+	 * @return void
848
+	 */
849
+	public function verify_cpt_object()
850
+	{
851
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
852
+		// verify event object
853
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
854
+			throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
855
+					'event_espresso'), $label));
856
+		}
857
+		//if auto-draft then throw an error
858
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
859
+			EE_Error::overwrite_errors();
860
+			EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'),
861
+					$label), __FILE__, __FUNCTION__, __LINE__);
862
+		}
863
+	}
864
+
865
+
866
+
867
+	/**
868
+	 * admin_footer_scripts_global
869
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
870
+	 * will apply on ALL EE_Admin pages.
871
+	 *
872
+	 * @access public
873
+	 * @return void
874
+	 */
875
+	public function admin_footer_scripts_global()
876
+	{
877
+		$this->_add_admin_page_ajax_loading_img();
878
+		$this->_add_admin_page_overlay();
879
+	}
880
+
881
+
882
+
883
+	/**
884
+	 * add in any global scripts for cpt routes
885
+	 *
886
+	 * @return void
887
+	 */
888
+	public function load_global_scripts_styles()
889
+	{
890
+		parent::load_global_scripts_styles();
891
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
892
+			//setup custom post status object for localize script but only if we've got a cpt object
893
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
894
+			if ( ! empty($statuses)) {
895
+				//get ALL statuses!
896
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
897
+				//setup object
898
+				$ee_cpt_statuses = array();
899
+				foreach ($statuses as $status => $label) {
900
+					$ee_cpt_statuses[$status] = array(
901
+						'label'      => $label,
902
+						'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
903
+					);
904
+				}
905
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
906
+			}
907
+		}
908
+	}
909
+
910
+
911
+
912
+	/**
913
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
914
+	 * insert/updates
915
+	 *
916
+	 * @param  int     $post_id ID of post being updated
917
+	 * @param  WP_Post $post    Post object from WP
918
+	 * @param  bool    $update  Whether this is an update or a new save.
919
+	 * @return void
920
+	 * @throws \EE_Error
921
+	 */
922
+	public function insert_update($post_id, $post, $update)
923
+	{
924
+		//make sure that if this is a revision OR trash action that we don't do any updates!
925
+		if (
926
+			isset($this->_req_data['action'])
927
+			&& (
928
+				$this->_req_data['action'] === 'restore'
929
+				|| $this->_req_data['action'] === 'trash'
930
+			)
931
+		) {
932
+			return;
933
+		}
934
+		$this->_set_model_object($post_id, true, 'insert_update');
935
+		//if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
936
+		if ($update
937
+			&& (
938
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
939
+				|| $this->_cpt_model_obj->ID() !== $post_id
940
+			)
941
+		) {
942
+			return;
943
+		}
944
+		//check for autosave and update our req_data property accordingly.
945
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
946 946
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
947 947
 
948 948
                 foreach ( (array) $values as $key => $value ) {
@@ -952,542 +952,542 @@  discard block
 block discarded – undo
952 952
 
953 953
         }/**/ //TODO reactivate after autosave is implemented in 4.2
954 954
 
955
-        //take care of updating any selected page_template IF this cpt supports it.
956
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
957
-            //wp version aware.
958
-            if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
959
-                $page_templates = wp_get_theme()->get_page_templates();
960
-            } else {
961
-                $post->page_template = $this->_req_data['page_template'];
962
-                $page_templates      = wp_get_theme()->get_page_templates($post);
963
-            }
964
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
965
-                EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
966
-            } else {
967
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
968
-            }
969
-        }
970
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
971
-            return;
972
-        } //TODO we'll remove this after reimplementing autosave in 4.2
973
-        $this->_insert_update_cpt_item($post_id, $post);
974
-    }
975
-
976
-
977
-
978
-    /**
979
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
980
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
981
-     * so we don't have to check for our CPT.
982
-     *
983
-     * @param  int $post_id ID of the post
984
-     * @return void
985
-     */
986
-    public function dont_permanently_delete_ee_cpts($post_id)
987
-    {
988
-        //only do this if we're actually processing one of our CPTs
989
-        //if our cpt object isn't existent then get out immediately.
990
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
991
-            return;
992
-        }
993
-        delete_post_meta($post_id, '_wp_trash_meta_status');
994
-        delete_post_meta($post_id, '_wp_trash_meta_time');
995
-        //our cpts may have comments so let's take care of that too
996
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
997
-    }
998
-
999
-
1000
-
1001
-    /**
1002
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1003
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1004
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1005
-     *
1006
-     * @param  int $post_id     ID of cpt item
1007
-     * @param  int $revision_id ID of revision being restored
1008
-     * @return void
1009
-     */
1010
-    public function restore_revision($post_id, $revision_id)
1011
-    {
1012
-        $this->_restore_cpt_item($post_id, $revision_id);
1013
-        //global action
1014
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1015
-        //class specific action so you can limit hooking into a specific page.
1016
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1017
-    }
1018
-
1019
-
1020
-
1021
-    /**
1022
-     * @see restore_revision() for details
1023
-     * @param  int $post_id     ID of cpt item
1024
-     * @param  int $revision_id ID of revision for item
1025
-     * @return void
1026
-     */
1027
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
1028
-
1029
-
1030
-
1031
-    /**
1032
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1033
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1034
-     * To fix we have to reset the current_screen using the page_slug
1035
-     * (which is identical - or should be - to our registered_post_type id.)
1036
-     * Also, since the core WP file loads the admin_header.php for WP
1037
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1038
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1039
-     *
1040
-     * @return void
1041
-     */
1042
-    public function modify_current_screen()
1043
-    {
1044
-        //ONLY do this if the current page_route IS a cpt route
1045
-        if ( ! $this->_cpt_route) {
1046
-            return;
1047
-        }
1048
-        //routing things REALLY early b/c this is a cpt admin page
1049
-        set_current_screen($this->_cpt_routes[$this->_req_action]);
1050
-        $this->_current_screen       = get_current_screen();
1051
-        $this->_current_screen->base = 'event-espresso';
1052
-        $this->_add_help_tabs(); //we make sure we add any help tabs back in!
1053
-        /*try {
955
+		//take care of updating any selected page_template IF this cpt supports it.
956
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
957
+			//wp version aware.
958
+			if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
959
+				$page_templates = wp_get_theme()->get_page_templates();
960
+			} else {
961
+				$post->page_template = $this->_req_data['page_template'];
962
+				$page_templates      = wp_get_theme()->get_page_templates($post);
963
+			}
964
+			if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
965
+				EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
966
+			} else {
967
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
968
+			}
969
+		}
970
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
971
+			return;
972
+		} //TODO we'll remove this after reimplementing autosave in 4.2
973
+		$this->_insert_update_cpt_item($post_id, $post);
974
+	}
975
+
976
+
977
+
978
+	/**
979
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
980
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
981
+	 * so we don't have to check for our CPT.
982
+	 *
983
+	 * @param  int $post_id ID of the post
984
+	 * @return void
985
+	 */
986
+	public function dont_permanently_delete_ee_cpts($post_id)
987
+	{
988
+		//only do this if we're actually processing one of our CPTs
989
+		//if our cpt object isn't existent then get out immediately.
990
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
991
+			return;
992
+		}
993
+		delete_post_meta($post_id, '_wp_trash_meta_status');
994
+		delete_post_meta($post_id, '_wp_trash_meta_time');
995
+		//our cpts may have comments so let's take care of that too
996
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
997
+	}
998
+
999
+
1000
+
1001
+	/**
1002
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1003
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1004
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1005
+	 *
1006
+	 * @param  int $post_id     ID of cpt item
1007
+	 * @param  int $revision_id ID of revision being restored
1008
+	 * @return void
1009
+	 */
1010
+	public function restore_revision($post_id, $revision_id)
1011
+	{
1012
+		$this->_restore_cpt_item($post_id, $revision_id);
1013
+		//global action
1014
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1015
+		//class specific action so you can limit hooking into a specific page.
1016
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1017
+	}
1018
+
1019
+
1020
+
1021
+	/**
1022
+	 * @see restore_revision() for details
1023
+	 * @param  int $post_id     ID of cpt item
1024
+	 * @param  int $revision_id ID of revision for item
1025
+	 * @return void
1026
+	 */
1027
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
1028
+
1029
+
1030
+
1031
+	/**
1032
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1033
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1034
+	 * To fix we have to reset the current_screen using the page_slug
1035
+	 * (which is identical - or should be - to our registered_post_type id.)
1036
+	 * Also, since the core WP file loads the admin_header.php for WP
1037
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1038
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1039
+	 *
1040
+	 * @return void
1041
+	 */
1042
+	public function modify_current_screen()
1043
+	{
1044
+		//ONLY do this if the current page_route IS a cpt route
1045
+		if ( ! $this->_cpt_route) {
1046
+			return;
1047
+		}
1048
+		//routing things REALLY early b/c this is a cpt admin page
1049
+		set_current_screen($this->_cpt_routes[$this->_req_action]);
1050
+		$this->_current_screen       = get_current_screen();
1051
+		$this->_current_screen->base = 'event-espresso';
1052
+		$this->_add_help_tabs(); //we make sure we add any help tabs back in!
1053
+		/*try {
1054 1054
             $this->_route_admin_request();
1055 1055
         } catch ( EE_Error $e ) {
1056 1056
             $e->get_error();
1057 1057
         }/**/
1058
-    }
1059
-
1060
-
1061
-
1062
-    /**
1063
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1064
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1065
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1066
-     * default to be.
1067
-     *
1068
-     * @param string $title The new title (or existing if there is no editor_title defined)
1069
-     * @return string
1070
-     */
1071
-    public function add_custom_editor_default_title($title)
1072
-    {
1073
-        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1074
-            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1075
-            : $title;
1076
-    }
1077
-
1078
-
1079
-
1080
-    /**
1081
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1082
-     *
1083
-     * @param string $shortlink   The already generated shortlink
1084
-     * @param int    $id          Post ID for this item
1085
-     * @param string $context     The context for the link
1086
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1087
-     * @return string
1088
-     */
1089
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1090
-    {
1091
-        if ( ! empty($id) && get_option('permalink_structure') !== '') {
1092
-            $post = get_post($id);
1093
-            if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1094
-                $shortlink = home_url('?p=' . $post->ID);
1095
-            }
1096
-        }
1097
-        return $shortlink;
1098
-    }
1099
-
1100
-
1101
-
1102
-    /**
1103
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1104
-     * already run in modify_current_screen())
1105
-     *
1106
-     * @return void
1107
-     */
1108
-    public function route_admin_request()
1109
-    {
1110
-        if ($this->_cpt_route) {
1111
-            return;
1112
-        }
1113
-        try {
1114
-            $this->_route_admin_request();
1115
-        } catch (EE_Error $e) {
1116
-            $e->get_error();
1117
-        }
1118
-    }
1119
-
1120
-
1121
-
1122
-    /**
1123
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1124
-     *
1125
-     * @return void
1126
-     */
1127
-    public function cpt_post_form_hidden_input()
1128
-    {
1129
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1130
-        //we're also going to add the route value and the current page so we can direct autosave parsing correctly
1131
-        echo '<div id="ee-cpt-hidden-inputs">';
1132
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1133
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1134
-        echo '</div>';
1135
-    }
1136
-
1137
-
1138
-
1139
-    /**
1140
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1141
-     *
1142
-     * @param  string $location Original location url
1143
-     * @param  int    $status   Status for http header
1144
-     * @return string           new (or original) url to redirect to.
1145
-     */
1146
-    public function revision_redirect($location, $status)
1147
-    {
1148
-        //get revision
1149
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1150
-        //can't do anything without revision so let's get out if not present
1151
-        if (empty($rev_id)) {
1152
-            return $location;
1153
-        }
1154
-        //get rev_post_data
1155
-        $rev = get_post($rev_id);
1156
-        $admin_url = $this->_admin_base_url;
1157
-        $query_args = array(
1158
-            'action'   => 'edit',
1159
-            'post'     => $rev->post_parent,
1160
-            'revision' => $rev_id,
1161
-            'message'  => 5,
1162
-        );
1163
-        $this->_process_notices($query_args, true);
1164
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1171
-     *
1172
-     * @param  string $link    the original generated link
1173
-     * @param  int    $id      post id
1174
-     * @param  string $context optional, defaults to display.  How to write the '&'
1175
-     * @return string          the link
1176
-     */
1177
-    public function modify_edit_post_link($link, $id, $context)
1178
-    {
1179
-        $post = get_post($id);
1180
-        if ( ! isset($this->_req_data['action'])
1181
-             || ! isset($this->_cpt_routes[$this->_req_data['action']])
1182
-             || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1183
-        ) {
1184
-            return $link;
1185
-        }
1186
-        $query_args = array(
1187
-            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1188
-                ? $this->_cpt_edit_routes[$post->post_type]
1189
-                : 'edit',
1190
-            'post'   => $id,
1191
-        );
1192
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1193
-    }
1194
-
1195
-
1196
-    /**
1197
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1198
-     * our routes.
1199
-     *
1200
-     * @param  string $delete_link  original delete link
1201
-     * @param  int    $post_id      id of cpt object
1202
-     * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1203
-     * @return string new delete link
1204
-     * @throws EE_Error
1205
-     */
1206
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1207
-    {
1208
-        $post = get_post($post_id);
1209
-
1210
-        if (empty($this->_req_data['action'])
1211
-            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1212
-            || ! $post instanceof WP_Post
1213
-            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1214
-        ) {
1215
-            return $delete_link;
1216
-        }
1217
-        $this->_set_model_object($post->ID, true);
1218
-
1219
-        //returns something like `trash_event` or `trash_attendee` or `trash_venue`
1220
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1221
-
1222
-        return EE_Admin_Page::add_query_args_and_nonce(
1223
-            array(
1224
-                'page' => $this->_req_data['page'],
1225
-                'action' => $action,
1226
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1227
-                    => $post->ID
1228
-            ),
1229
-            admin_url()
1230
-        );
1231
-    }
1232
-
1233
-
1234
-
1235
-    /**
1236
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1237
-     * so that we can hijack the default redirect locations for wp custom post types
1238
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1239
-     *
1240
-     * @param  string $location This is the incoming currently set redirect location
1241
-     * @param  string $post_id  This is the 'ID' value of the wp_posts table
1242
-     * @return string           the new location to redirect to
1243
-     */
1244
-    public function cpt_post_location_redirect($location, $post_id)
1245
-    {
1246
-        //we DO have a match so let's setup the url
1247
-        //we have to get the post to determine our route
1248
-        $post       = get_post($post_id);
1249
-        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1250
-        //shared query_args
1251
-        $query_args = array('action' => $edit_route, 'post' => $post_id);
1252
-        $admin_url  = $this->_admin_base_url;
1253
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1254
-            $status = get_post_status($post_id);
1255
-            if (isset($this->_req_data['publish'])) {
1256
-                switch ($status) {
1257
-                    case 'pending':
1258
-                        $message = 8;
1259
-                        break;
1260
-                    case 'future':
1261
-                        $message = 9;
1262
-                        break;
1263
-                    default:
1264
-                        $message = 6;
1265
-                }
1266
-            } else {
1267
-                $message = 'draft' === $status ? 10 : 1;
1268
-            }
1269
-        } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1270
-            $message = 2;
1271
-            //			$append = '#postcustom';
1272
-        } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1273
-            $message = 3;
1274
-            //			$append = '#postcustom';
1275
-        } elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1276
-            $message = 7;
1277
-        } else {
1278
-            $message = 4;
1279
-        }
1280
-        //change the message if the post type is not viewable on the frontend
1281
-        $this->_cpt_object = get_post_type_object($post->post_type);
1282
-        $message           = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1283
-        $query_args = array_merge(array('message' => $message), $query_args);
1284
-        $this->_process_notices($query_args, true);
1285
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1286
-    }
1287
-
1288
-
1289
-
1290
-    /**
1291
-     * This method is called to inject nav tabs on core WP cpt pages
1292
-     *
1293
-     * @access public
1294
-     * @return void
1295
-     */
1296
-    public function inject_nav_tabs()
1297
-    {
1298
-        //can we hijack and insert the nav_tabs?
1299
-        $nav_tabs = $this->_get_main_nav_tabs();
1300
-        //first close off existing form tag
1301
-        $html = '>';
1302
-        $html .= $nav_tabs;
1303
-        //now let's handle the remaining tag ( missing ">" is CORRECT )
1304
-        $html .= '<span></span';
1305
-        echo $html;
1306
-    }
1307
-
1308
-
1309
-
1310
-    /**
1311
-     * This just sets up the post update messages when an update form is loaded
1312
-     *
1313
-     * @access public
1314
-     * @param  array $messages the original messages array
1315
-     * @return array           the new messages array
1316
-     */
1317
-    public function post_update_messages($messages)
1318
-    {
1319
-        global $post;
1320
-        $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1321
-        $id = empty($id) && is_object($post) ? $post->ID : null;
1322
-        //		$post_type = $post ? $post->post_type : false;
1323
-        /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1058
+	}
1059
+
1060
+
1061
+
1062
+	/**
1063
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1064
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1065
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1066
+	 * default to be.
1067
+	 *
1068
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1069
+	 * @return string
1070
+	 */
1071
+	public function add_custom_editor_default_title($title)
1072
+	{
1073
+		return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1074
+			? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1075
+			: $title;
1076
+	}
1077
+
1078
+
1079
+
1080
+	/**
1081
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1082
+	 *
1083
+	 * @param string $shortlink   The already generated shortlink
1084
+	 * @param int    $id          Post ID for this item
1085
+	 * @param string $context     The context for the link
1086
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1087
+	 * @return string
1088
+	 */
1089
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1090
+	{
1091
+		if ( ! empty($id) && get_option('permalink_structure') !== '') {
1092
+			$post = get_post($id);
1093
+			if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1094
+				$shortlink = home_url('?p=' . $post->ID);
1095
+			}
1096
+		}
1097
+		return $shortlink;
1098
+	}
1099
+
1100
+
1101
+
1102
+	/**
1103
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1104
+	 * already run in modify_current_screen())
1105
+	 *
1106
+	 * @return void
1107
+	 */
1108
+	public function route_admin_request()
1109
+	{
1110
+		if ($this->_cpt_route) {
1111
+			return;
1112
+		}
1113
+		try {
1114
+			$this->_route_admin_request();
1115
+		} catch (EE_Error $e) {
1116
+			$e->get_error();
1117
+		}
1118
+	}
1119
+
1120
+
1121
+
1122
+	/**
1123
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1124
+	 *
1125
+	 * @return void
1126
+	 */
1127
+	public function cpt_post_form_hidden_input()
1128
+	{
1129
+		echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1130
+		//we're also going to add the route value and the current page so we can direct autosave parsing correctly
1131
+		echo '<div id="ee-cpt-hidden-inputs">';
1132
+		echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1133
+		echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1134
+		echo '</div>';
1135
+	}
1136
+
1137
+
1138
+
1139
+	/**
1140
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1141
+	 *
1142
+	 * @param  string $location Original location url
1143
+	 * @param  int    $status   Status for http header
1144
+	 * @return string           new (or original) url to redirect to.
1145
+	 */
1146
+	public function revision_redirect($location, $status)
1147
+	{
1148
+		//get revision
1149
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1150
+		//can't do anything without revision so let's get out if not present
1151
+		if (empty($rev_id)) {
1152
+			return $location;
1153
+		}
1154
+		//get rev_post_data
1155
+		$rev = get_post($rev_id);
1156
+		$admin_url = $this->_admin_base_url;
1157
+		$query_args = array(
1158
+			'action'   => 'edit',
1159
+			'post'     => $rev->post_parent,
1160
+			'revision' => $rev_id,
1161
+			'message'  => 5,
1162
+		);
1163
+		$this->_process_notices($query_args, true);
1164
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1171
+	 *
1172
+	 * @param  string $link    the original generated link
1173
+	 * @param  int    $id      post id
1174
+	 * @param  string $context optional, defaults to display.  How to write the '&'
1175
+	 * @return string          the link
1176
+	 */
1177
+	public function modify_edit_post_link($link, $id, $context)
1178
+	{
1179
+		$post = get_post($id);
1180
+		if ( ! isset($this->_req_data['action'])
1181
+			 || ! isset($this->_cpt_routes[$this->_req_data['action']])
1182
+			 || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1183
+		) {
1184
+			return $link;
1185
+		}
1186
+		$query_args = array(
1187
+			'action' => isset($this->_cpt_edit_routes[$post->post_type])
1188
+				? $this->_cpt_edit_routes[$post->post_type]
1189
+				: 'edit',
1190
+			'post'   => $id,
1191
+		);
1192
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1193
+	}
1194
+
1195
+
1196
+	/**
1197
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1198
+	 * our routes.
1199
+	 *
1200
+	 * @param  string $delete_link  original delete link
1201
+	 * @param  int    $post_id      id of cpt object
1202
+	 * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1203
+	 * @return string new delete link
1204
+	 * @throws EE_Error
1205
+	 */
1206
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1207
+	{
1208
+		$post = get_post($post_id);
1209
+
1210
+		if (empty($this->_req_data['action'])
1211
+			|| ! isset($this->_cpt_routes[$this->_req_data['action']])
1212
+			|| ! $post instanceof WP_Post
1213
+			|| $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1214
+		) {
1215
+			return $delete_link;
1216
+		}
1217
+		$this->_set_model_object($post->ID, true);
1218
+
1219
+		//returns something like `trash_event` or `trash_attendee` or `trash_venue`
1220
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1221
+
1222
+		return EE_Admin_Page::add_query_args_and_nonce(
1223
+			array(
1224
+				'page' => $this->_req_data['page'],
1225
+				'action' => $action,
1226
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1227
+					=> $post->ID
1228
+			),
1229
+			admin_url()
1230
+		);
1231
+	}
1232
+
1233
+
1234
+
1235
+	/**
1236
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1237
+	 * so that we can hijack the default redirect locations for wp custom post types
1238
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1239
+	 *
1240
+	 * @param  string $location This is the incoming currently set redirect location
1241
+	 * @param  string $post_id  This is the 'ID' value of the wp_posts table
1242
+	 * @return string           the new location to redirect to
1243
+	 */
1244
+	public function cpt_post_location_redirect($location, $post_id)
1245
+	{
1246
+		//we DO have a match so let's setup the url
1247
+		//we have to get the post to determine our route
1248
+		$post       = get_post($post_id);
1249
+		$edit_route = $this->_cpt_edit_routes[$post->post_type];
1250
+		//shared query_args
1251
+		$query_args = array('action' => $edit_route, 'post' => $post_id);
1252
+		$admin_url  = $this->_admin_base_url;
1253
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1254
+			$status = get_post_status($post_id);
1255
+			if (isset($this->_req_data['publish'])) {
1256
+				switch ($status) {
1257
+					case 'pending':
1258
+						$message = 8;
1259
+						break;
1260
+					case 'future':
1261
+						$message = 9;
1262
+						break;
1263
+					default:
1264
+						$message = 6;
1265
+				}
1266
+			} else {
1267
+				$message = 'draft' === $status ? 10 : 1;
1268
+			}
1269
+		} else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1270
+			$message = 2;
1271
+			//			$append = '#postcustom';
1272
+		} else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1273
+			$message = 3;
1274
+			//			$append = '#postcustom';
1275
+		} elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1276
+			$message = 7;
1277
+		} else {
1278
+			$message = 4;
1279
+		}
1280
+		//change the message if the post type is not viewable on the frontend
1281
+		$this->_cpt_object = get_post_type_object($post->post_type);
1282
+		$message           = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1283
+		$query_args = array_merge(array('message' => $message), $query_args);
1284
+		$this->_process_notices($query_args, true);
1285
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1286
+	}
1287
+
1288
+
1289
+
1290
+	/**
1291
+	 * This method is called to inject nav tabs on core WP cpt pages
1292
+	 *
1293
+	 * @access public
1294
+	 * @return void
1295
+	 */
1296
+	public function inject_nav_tabs()
1297
+	{
1298
+		//can we hijack and insert the nav_tabs?
1299
+		$nav_tabs = $this->_get_main_nav_tabs();
1300
+		//first close off existing form tag
1301
+		$html = '>';
1302
+		$html .= $nav_tabs;
1303
+		//now let's handle the remaining tag ( missing ">" is CORRECT )
1304
+		$html .= '<span></span';
1305
+		echo $html;
1306
+	}
1307
+
1308
+
1309
+
1310
+	/**
1311
+	 * This just sets up the post update messages when an update form is loaded
1312
+	 *
1313
+	 * @access public
1314
+	 * @param  array $messages the original messages array
1315
+	 * @return array           the new messages array
1316
+	 */
1317
+	public function post_update_messages($messages)
1318
+	{
1319
+		global $post;
1320
+		$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1321
+		$id = empty($id) && is_object($post) ? $post->ID : null;
1322
+		//		$post_type = $post ? $post->post_type : false;
1323
+		/*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1324 1324
 
1325 1325
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1326
-        $messages[$post->post_type] = array(
1327
-            0 => '', //Unused. Messages start at index 1.
1328
-            1 => sprintf(
1329
-                __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1330
-                $this->_cpt_object->labels->singular_name,
1331
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1332
-                '</a>'
1333
-            ),
1334
-            2 => __('Custom field updated'),
1335
-            3 => __('Custom field deleted.'),
1336
-            4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1337
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'),
1338
-                $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false))
1339
-                : false,
1340
-            6 => sprintf(
1341
-                __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1342
-                $this->_cpt_object->labels->singular_name,
1343
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1344
-                '</a>'
1345
-            ),
1346
-            7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1347
-            8 => sprintf(
1348
-                __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1349
-                $this->_cpt_object->labels->singular_name,
1350
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1351
-                '</a>'
1352
-            ),
1353
-            9 => sprintf(
1354
-                __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1355
-                $this->_cpt_object->labels->singular_name,
1356
-                '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>',
1357
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1358
-                '</a>'
1359
-            ),
1360
-            10 => sprintf(
1361
-                __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1362
-                $this->_cpt_object->labels->singular_name,
1363
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1364
-                '</a>'
1365
-            ),
1366
-        );
1367
-        return $messages;
1368
-    }
1369
-
1370
-
1371
-
1372
-    /**
1373
-     * default method for the 'create_new' route for cpt admin pages.
1374
-     * For reference what to include in here, see wp-admin/post-new.php
1375
-     *
1376
-     * @access  protected
1377
-     * @return void
1378
-     */
1379
-    protected function _create_new_cpt_item()
1380
-    {
1381
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1382
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1383
-        $post_type        = $this->_cpt_routes[$this->_req_action];
1384
-        $post_type_object = $this->_cpt_object;
1385
-        $title            = $post_type_object->labels->add_new_item;
1386
-        $post    = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1387
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1388
-        //modify the default editor title field with default title.
1389
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1390
-        $this->loadEditorTemplate(true);
1391
-    }
1392
-
1393
-
1394
-    /**
1395
-     * Enqueues auto-save and loads the editor template
1396
-     *
1397
-     * @param bool $creating
1398
-     */
1399
-    private function loadEditorTemplate($creating = true) {
1400
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1401
-        //these vars are used by the template
1402
-        $editing = true;
1403
-        $post_ID = $post->ID;
1404
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1405
-            //only enqueue autosave when creating event (necessary to get permalink/url generated)
1406
-            //otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1407
-            if ($creating) {
1408
-                wp_enqueue_script('autosave');
1409
-            } else {
1410
-                if (isset($this->_cpt_routes[$this->_req_data['action']])
1411
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1412
-                ) {
1413
-                    $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1414
-                        'create_new', $this);
1415
-                    $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array(
1416
-                        'action' => $create_new_action,
1417
-                        'page'   => $this->page_slug,
1418
-                    ), 'admin.php');
1419
-                }
1420
-            }
1421
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1422
-        }
1423
-    }
1424
-
1425
-
1426
-
1427
-    public function add_new_admin_page_global()
1428
-    {
1429
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1430
-        ?>
1326
+		$messages[$post->post_type] = array(
1327
+			0 => '', //Unused. Messages start at index 1.
1328
+			1 => sprintf(
1329
+				__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1330
+				$this->_cpt_object->labels->singular_name,
1331
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1332
+				'</a>'
1333
+			),
1334
+			2 => __('Custom field updated'),
1335
+			3 => __('Custom field deleted.'),
1336
+			4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1337
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'),
1338
+				$this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false))
1339
+				: false,
1340
+			6 => sprintf(
1341
+				__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1342
+				$this->_cpt_object->labels->singular_name,
1343
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1344
+				'</a>'
1345
+			),
1346
+			7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1347
+			8 => sprintf(
1348
+				__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1349
+				$this->_cpt_object->labels->singular_name,
1350
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1351
+				'</a>'
1352
+			),
1353
+			9 => sprintf(
1354
+				__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1355
+				$this->_cpt_object->labels->singular_name,
1356
+				'<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>',
1357
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1358
+				'</a>'
1359
+			),
1360
+			10 => sprintf(
1361
+				__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1362
+				$this->_cpt_object->labels->singular_name,
1363
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1364
+				'</a>'
1365
+			),
1366
+		);
1367
+		return $messages;
1368
+	}
1369
+
1370
+
1371
+
1372
+	/**
1373
+	 * default method for the 'create_new' route for cpt admin pages.
1374
+	 * For reference what to include in here, see wp-admin/post-new.php
1375
+	 *
1376
+	 * @access  protected
1377
+	 * @return void
1378
+	 */
1379
+	protected function _create_new_cpt_item()
1380
+	{
1381
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1382
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1383
+		$post_type        = $this->_cpt_routes[$this->_req_action];
1384
+		$post_type_object = $this->_cpt_object;
1385
+		$title            = $post_type_object->labels->add_new_item;
1386
+		$post    = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1387
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1388
+		//modify the default editor title field with default title.
1389
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1390
+		$this->loadEditorTemplate(true);
1391
+	}
1392
+
1393
+
1394
+	/**
1395
+	 * Enqueues auto-save and loads the editor template
1396
+	 *
1397
+	 * @param bool $creating
1398
+	 */
1399
+	private function loadEditorTemplate($creating = true) {
1400
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1401
+		//these vars are used by the template
1402
+		$editing = true;
1403
+		$post_ID = $post->ID;
1404
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1405
+			//only enqueue autosave when creating event (necessary to get permalink/url generated)
1406
+			//otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1407
+			if ($creating) {
1408
+				wp_enqueue_script('autosave');
1409
+			} else {
1410
+				if (isset($this->_cpt_routes[$this->_req_data['action']])
1411
+					&& ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1412
+				) {
1413
+					$create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1414
+						'create_new', $this);
1415
+					$post_new_file = EE_Admin_Page::add_query_args_and_nonce(array(
1416
+						'action' => $create_new_action,
1417
+						'page'   => $this->page_slug,
1418
+					), 'admin.php');
1419
+				}
1420
+			}
1421
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1422
+		}
1423
+	}
1424
+
1425
+
1426
+
1427
+	public function add_new_admin_page_global()
1428
+	{
1429
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1430
+		?>
1431 1431
         <script type="text/javascript">
1432 1432
             adminpage = '<?php echo $admin_page; ?>';
1433 1433
         </script>
1434 1434
         <?php
1435
-    }
1436
-
1437
-
1438
-
1439
-    /**
1440
-     * default method for the 'edit' route for cpt admin pages
1441
-     * For reference on what to put in here, refer to wp-admin/post.php
1442
-     *
1443
-     * @access protected
1444
-     * @return string   template for edit cpt form
1445
-     */
1446
-    protected function _edit_cpt_item()
1447
-    {
1448
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1449
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1450
-        $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1451
-        if (empty ($post)) {
1452
-            wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'));
1453
-        }
1454
-        if ( ! empty($_GET['get-post-lock'])) {
1455
-            wp_set_post_lock($post_id);
1456
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1457
-            exit();
1458
-        }
1459
-
1460
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1461
-        $post_type        = $this->_cpt_routes[$this->_req_action];
1462
-        $post_type_object = $this->_cpt_object;
1463
-
1464
-        if ( ! wp_check_post_lock($post->ID)) {
1465
-            wp_set_post_lock($post->ID);
1466
-        }
1467
-        add_action('admin_footer', '_admin_notice_post_locked');
1468
-        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1469
-            wp_enqueue_script('admin-comments');
1470
-            enqueue_comment_hotkeys_js();
1471
-        }
1472
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1473
-        //modify the default editor title field with default title.
1474
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1475
-        $this->loadEditorTemplate(false);
1476
-    }
1477
-
1478
-
1479
-
1480
-    /**
1481
-     * some getters
1482
-     */
1483
-    /**
1484
-     * This returns the protected _cpt_model_obj property
1485
-     *
1486
-     * @return EE_CPT_Base
1487
-     */
1488
-    public function get_cpt_model_obj()
1489
-    {
1490
-        return $this->_cpt_model_obj;
1491
-    }
1435
+	}
1436
+
1437
+
1438
+
1439
+	/**
1440
+	 * default method for the 'edit' route for cpt admin pages
1441
+	 * For reference on what to put in here, refer to wp-admin/post.php
1442
+	 *
1443
+	 * @access protected
1444
+	 * @return string   template for edit cpt form
1445
+	 */
1446
+	protected function _edit_cpt_item()
1447
+	{
1448
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1449
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1450
+		$post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1451
+		if (empty ($post)) {
1452
+			wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'));
1453
+		}
1454
+		if ( ! empty($_GET['get-post-lock'])) {
1455
+			wp_set_post_lock($post_id);
1456
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1457
+			exit();
1458
+		}
1459
+
1460
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1461
+		$post_type        = $this->_cpt_routes[$this->_req_action];
1462
+		$post_type_object = $this->_cpt_object;
1463
+
1464
+		if ( ! wp_check_post_lock($post->ID)) {
1465
+			wp_set_post_lock($post->ID);
1466
+		}
1467
+		add_action('admin_footer', '_admin_notice_post_locked');
1468
+		if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1469
+			wp_enqueue_script('admin-comments');
1470
+			enqueue_comment_hotkeys_js();
1471
+		}
1472
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1473
+		//modify the default editor title field with default title.
1474
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1475
+		$this->loadEditorTemplate(false);
1476
+	}
1477
+
1478
+
1479
+
1480
+	/**
1481
+	 * some getters
1482
+	 */
1483
+	/**
1484
+	 * This returns the protected _cpt_model_obj property
1485
+	 *
1486
+	 * @return EE_CPT_Base
1487
+	 */
1488
+	public function get_cpt_model_obj()
1489
+	{
1490
+		return $this->_cpt_model_obj;
1491
+	}
1492 1492
 
1493 1493
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      */
240 240
     protected function _register_autosave_containers($ids)
241 241
     {
242
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids);
242
+        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
243 243
     }
244 244
 
245 245
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         //filter _autosave_containers
287 287
         $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
288 288
             $this->_autosave_containers, $this);
289
-        $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
289
+        $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
290 290
             $containers, $this);
291 291
 
292 292
         wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS',
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         // This is for any plugins that are doing things properly
399 399
         // and hooking into the load page hook for core wp cpt routes.
400 400
         global $pagenow;
401
-        do_action('load-' . $pagenow);
401
+        do_action('load-'.$pagenow);
402 402
         $this->modify_current_screen();
403 403
         add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
404 404
         //we route REALLY early.
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
                 'admin.php?page=espresso_registrations&action=contact_list',
430 430
             ),
431 431
             1 => array(
432
-                'edit.php?post_type=' . $this->_cpt_object->name,
433
-                'admin.php?page=' . $this->_cpt_object->name,
432
+                'edit.php?post_type='.$this->_cpt_object->name,
433
+                'admin.php?page='.$this->_cpt_object->name,
434 434
             ),
435 435
         );
436 436
         foreach ($routes_to_match as $route_matches) {
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
         $cpt_has_support = ! empty($cpt_args['page_templates']);
459 459
 
460 460
         //if the installed version of WP is > 4.7 we do some additional checks.
461
-        if (RecommendedVersions::compareWordPressVersion('4.7','>=')) {
461
+        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
462 462
             $post_templates = wp_get_theme()->get_post_templates();
463 463
             //if there are $post_templates for this cpt, then we return false for this method because
464 464
             //that means we aren't going to load our page template manager and leave that up to the native
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
         global $post;
482 482
         $template = '';
483 483
 
484
-        if (RecommendedVersions::compareWordPressVersion('4.7','>=')) {
484
+        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
485 485
             $page_template_count = count(get_page_templates());
486 486
         } else {
487 487
             $page_template_count = count(get_page_templates($post));
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         $post = get_post($id);
519 519
         if ('publish' !== get_post_status($post)) {
520 520
             //include shims for the `get_preview_post_link` function
521
-            require_once( EE_CORE . 'wordpress-shims.php' );
521
+            require_once(EE_CORE.'wordpress-shims.php');
522 522
             $return .= '<span_id="view-post-btn"><a target="_blank" href="'
523 523
                        . get_preview_post_link($id)
524 524
                        . '" class="button button-small">'
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             $template_args['statuses']         = $statuses;
557 557
         }
558 558
 
559
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
559
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
560 560
         EEH_Template::display_template($template, $template_args);
561 561
     }
562 562
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
             $this->_template_args['success'] = true;
611 611
         }
612 612
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
613
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
613
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
614 614
         //now let's return json
615 615
         $this->_return_json();
616 616
     }
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
         //global action
1014 1014
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1015 1015
         //class specific action so you can limit hooking into a specific page.
1016
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1016
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
1017 1017
     }
1018 1018
 
1019 1019
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
         if ( ! empty($id) && get_option('permalink_structure') !== '') {
1092 1092
             $post = get_post($id);
1093 1093
             if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1094
-                $shortlink = home_url('?p=' . $post->ID);
1094
+                $shortlink = home_url('?p='.$post->ID);
1095 1095
             }
1096 1096
         }
1097 1097
         return $shortlink;
@@ -1126,11 +1126,11 @@  discard block
 block discarded – undo
1126 1126
      */
1127 1127
     public function cpt_post_form_hidden_input()
1128 1128
     {
1129
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1129
+        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />';
1130 1130
         //we're also going to add the route value and the current page so we can direct autosave parsing correctly
1131 1131
         echo '<div id="ee-cpt-hidden-inputs">';
1132
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1133
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1132
+        echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />';
1133
+        echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />';
1134 1134
         echo '</div>';
1135 1135
     }
1136 1136
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
         $this->_set_model_object($post->ID, true);
1218 1218
 
1219 1219
         //returns something like `trash_event` or `trash_attendee` or `trash_venue`
1220
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1220
+        $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1221 1221
 
1222 1222
         return EE_Admin_Page::add_query_args_and_nonce(
1223 1223
             array(
@@ -1328,39 +1328,39 @@  discard block
 block discarded – undo
1328 1328
             1 => sprintf(
1329 1329
                 __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1330 1330
                 $this->_cpt_object->labels->singular_name,
1331
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1331
+                '<a href="'.esc_url(get_permalink($id)).'">',
1332 1332
                 '</a>'
1333 1333
             ),
1334 1334
             2 => __('Custom field updated'),
1335 1335
             3 => __('Custom field deleted.'),
1336 1336
             4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1337 1337
             5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'),
1338
-                $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false))
1338
+                $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false))
1339 1339
                 : false,
1340 1340
             6 => sprintf(
1341 1341
                 __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1342 1342
                 $this->_cpt_object->labels->singular_name,
1343
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1343
+                '<a href="'.esc_url(get_permalink($id)).'">',
1344 1344
                 '</a>'
1345 1345
             ),
1346 1346
             7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1347 1347
             8 => sprintf(
1348 1348
                 __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1349 1349
                 $this->_cpt_object->labels->singular_name,
1350
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1350
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1351 1351
                 '</a>'
1352 1352
             ),
1353 1353
             9 => sprintf(
1354 1354
                 __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1355 1355
                 $this->_cpt_object->labels->singular_name,
1356
-                '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>',
1357
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1356
+                '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>',
1357
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1358 1358
                 '</a>'
1359 1359
             ),
1360 1360
             10 => sprintf(
1361 1361
                 __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1362 1362
                 $this->_cpt_object->labels->singular_name,
1363
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1363
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1364 1364
                 '</a>'
1365 1365
             ),
1366 1366
         );
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
         $post_type        = $this->_cpt_routes[$this->_req_action];
1384 1384
         $post_type_object = $this->_cpt_object;
1385 1385
         $title            = $post_type_object->labels->add_new_item;
1386
-        $post    = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1386
+        $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1387 1387
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1388 1388
         //modify the default editor title field with default title.
1389 1389
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
                     ), 'admin.php');
1419 1419
                 }
1420 1420
             }
1421
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1421
+            include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1422 1422
         }
1423 1423
     }
1424 1424
 
Please login to merge, or discard this patch.
core/services/request/middleware/RecommendedVersions.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -23,186 +23,186 @@
 block discarded – undo
23 23
 class RecommendedVersions extends Middleware
24 24
 {
25 25
 
26
-    /**
27
-     * converts a Request to a Response
28
-     *
29
-     * @param RequestInterface $request
30
-     * @param ResponseInterface      $response
31
-     * @return ResponseInterface
32
-     * @throws InvalidDataTypeException
33
-     */
34
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
35
-    {
36
-        $this->request  = $request;
37
-        $this->response = $response;
38
-        // check required WP version
39
-        if (! $this->minimumWordPressVersionRequired()) {
40
-            $this->request->unSetRequestParam('activate', true);
41
-            add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1);
42
-            $this->response->terminateRequest();
43
-            $this->response->deactivatePlugin();
44
-        }
45
-        // check recommended PHP version
46
-        if (! $this->minimumPhpVersionRecommended()) {
47
-            $this->displayMinimumRecommendedPhpVersionNotice();
48
-        }
49
-        //upcoming required version
50
-        if (! $this->upcomingRequiredPhpVersion()) {
51
-            $this->displayUpcomingRequiredVersion();
52
-        }
53
-        $this->response = $this->processRequestStack($this->request, $this->response);
54
-        return $this->response;
55
-    }
56
-
57
-
58
-    /**
59
-     * Helper method to assess installed wp version against given values.
60
-     * By default this compares the required minimum version of WP for EE against the installed version of WP
61
-     * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked
62
-     * against) so consider that when sending in your values.
63
-     *
64
-     * @param string $version_to_check
65
-     * @param string $operator
66
-     * @return bool
67
-     */
68
-    public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=')
69
-    {
70
-        global $wp_version;
71
-        return version_compare(
72
-        // first account for wp_version being pre-release
73
-        // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519
74
-            strpos($wp_version, '-') > 0
75
-                ? substr($wp_version, 0, strpos($wp_version, '-'))
76
-                : $wp_version,
77
-            $version_to_check,
78
-            $operator
79
-        );
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     * @return boolean
86
-     */
87
-    private function minimumWordPressVersionRequired()
88
-    {
89
-        return RecommendedVersions::compareWordPressVersion();
90
-    }
91
-
92
-
93
-
94
-    /**
95
-     * @param string $min_version
96
-     * @return boolean
97
-     */
98
-    private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED)
99
-    {
100
-        return version_compare(PHP_VERSION, $min_version, '>=') ? true : false;
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * @return boolean
107
-     */
108
-    private function minimumPhpVersionRecommended()
109
-    {
110
-        return $this->checkPhpVersion();
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * @return void
117
-     */
118
-    public function minimumWpVersionError()
119
-    {
120
-        global $wp_version;
121
-        ?>
26
+	/**
27
+	 * converts a Request to a Response
28
+	 *
29
+	 * @param RequestInterface $request
30
+	 * @param ResponseInterface      $response
31
+	 * @return ResponseInterface
32
+	 * @throws InvalidDataTypeException
33
+	 */
34
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
35
+	{
36
+		$this->request  = $request;
37
+		$this->response = $response;
38
+		// check required WP version
39
+		if (! $this->minimumWordPressVersionRequired()) {
40
+			$this->request->unSetRequestParam('activate', true);
41
+			add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1);
42
+			$this->response->terminateRequest();
43
+			$this->response->deactivatePlugin();
44
+		}
45
+		// check recommended PHP version
46
+		if (! $this->minimumPhpVersionRecommended()) {
47
+			$this->displayMinimumRecommendedPhpVersionNotice();
48
+		}
49
+		//upcoming required version
50
+		if (! $this->upcomingRequiredPhpVersion()) {
51
+			$this->displayUpcomingRequiredVersion();
52
+		}
53
+		$this->response = $this->processRequestStack($this->request, $this->response);
54
+		return $this->response;
55
+	}
56
+
57
+
58
+	/**
59
+	 * Helper method to assess installed wp version against given values.
60
+	 * By default this compares the required minimum version of WP for EE against the installed version of WP
61
+	 * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked
62
+	 * against) so consider that when sending in your values.
63
+	 *
64
+	 * @param string $version_to_check
65
+	 * @param string $operator
66
+	 * @return bool
67
+	 */
68
+	public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=')
69
+	{
70
+		global $wp_version;
71
+		return version_compare(
72
+		// first account for wp_version being pre-release
73
+		// (like RC, beta etc) which are usually in the format like 4.7-RC3-39519
74
+			strpos($wp_version, '-') > 0
75
+				? substr($wp_version, 0, strpos($wp_version, '-'))
76
+				: $wp_version,
77
+			$version_to_check,
78
+			$operator
79
+		);
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 * @return boolean
86
+	 */
87
+	private function minimumWordPressVersionRequired()
88
+	{
89
+		return RecommendedVersions::compareWordPressVersion();
90
+	}
91
+
92
+
93
+
94
+	/**
95
+	 * @param string $min_version
96
+	 * @return boolean
97
+	 */
98
+	private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED)
99
+	{
100
+		return version_compare(PHP_VERSION, $min_version, '>=') ? true : false;
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * @return boolean
107
+	 */
108
+	private function minimumPhpVersionRecommended()
109
+	{
110
+		return $this->checkPhpVersion();
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * @return void
117
+	 */
118
+	public function minimumWpVersionError()
119
+	{
120
+		global $wp_version;
121
+		?>
122 122
         <div class="error">
123 123
             <p>
124 124
                 <?php
125
-                printf(
126
-                    __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.',
127
-                        'event_espresso'),
128
-                    EE_MIN_WP_VER_REQUIRED,
129
-                    $wp_version,
130
-                    '<br/>',
131
-                    '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>'
132
-                );
133
-                ?>
125
+				printf(
126
+					__('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.',
127
+						'event_espresso'),
128
+					EE_MIN_WP_VER_REQUIRED,
129
+					$wp_version,
130
+					'<br/>',
131
+					'<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>'
132
+				);
133
+				?>
134 134
             </p>
135 135
         </div>
136 136
         <?php
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     *    _display_minimum_recommended_php_version_notice
143
-     *
144
-     * @access private
145
-     * @return void
146
-     * @throws InvalidDataTypeException
147
-     */
148
-    private function displayMinimumRecommendedPhpVersionNotice()
149
-    {
150
-        if ($this->request->isAdmin()) {
151
-            new PersistentAdminNotice(
152
-                'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended',
153
-                sprintf(
154
-                    esc_html__(
155
-                        'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
156
-                        'event_espresso'
157
-                    ),
158
-                    EE_MIN_PHP_VER_RECOMMENDED,
159
-                    PHP_VERSION,
160
-                    '<br/>',
161
-                    '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
162
-                )
163
-            );
164
-        }
165
-    }
166
-
167
-
168
-    /**
169
-     * Returns whether the provided php version number is greater than the current version of php installed on the server.
170
-     *
171
-     * @param string $version_required
172
-     * @return bool
173
-     */
174
-    private function upcomingRequiredPhpVersion($version_required = '5.5')
175
-    {
176
-        return $this->checkPhpVersion($version_required);
177
-    }
178
-
179
-
180
-    /**
181
-     *  Sets a notice for an upcoming required version of PHP in the next update of EE core.
182
-     */
183
-    private function displayUpcomingRequiredVersion()
184
-    {
185
-        if ($this->request->isAdmin()
186
-            && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request)
187
-            && current_user_can('update_plugins')
188
-        ) {
189
-            add_action('admin_notices', function ()
190
-            {
191
-                echo '<div class="notice event-espresso-admin-notice notice-warning"><p>'
192
-                     . sprintf(
193
-                         esc_html__(
194
-                             'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater.  Your web server\'s PHP version is %3$s.  You can contact your host and ask them to update your PHP version to at least PHP 5.6.  Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s',
195
-                             'event_espresso'
196
-                         ),
197
-                         '<strong>',
198
-                         '</strong>',
199
-                         PHP_VERSION,
200
-                         '<a href="https://wordpress.org/support/upgrade-php/">',
201
-                         '</a>'
202
-                     )
203
-                     . '</p></div>';
204
-            });
205
-        }
206
-    }
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 *    _display_minimum_recommended_php_version_notice
143
+	 *
144
+	 * @access private
145
+	 * @return void
146
+	 * @throws InvalidDataTypeException
147
+	 */
148
+	private function displayMinimumRecommendedPhpVersionNotice()
149
+	{
150
+		if ($this->request->isAdmin()) {
151
+			new PersistentAdminNotice(
152
+				'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended',
153
+				sprintf(
154
+					esc_html__(
155
+						'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
156
+						'event_espresso'
157
+					),
158
+					EE_MIN_PHP_VER_RECOMMENDED,
159
+					PHP_VERSION,
160
+					'<br/>',
161
+					'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
162
+				)
163
+			);
164
+		}
165
+	}
166
+
167
+
168
+	/**
169
+	 * Returns whether the provided php version number is greater than the current version of php installed on the server.
170
+	 *
171
+	 * @param string $version_required
172
+	 * @return bool
173
+	 */
174
+	private function upcomingRequiredPhpVersion($version_required = '5.5')
175
+	{
176
+		return $this->checkPhpVersion($version_required);
177
+	}
178
+
179
+
180
+	/**
181
+	 *  Sets a notice for an upcoming required version of PHP in the next update of EE core.
182
+	 */
183
+	private function displayUpcomingRequiredVersion()
184
+	{
185
+		if ($this->request->isAdmin()
186
+			&& apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request)
187
+			&& current_user_can('update_plugins')
188
+		) {
189
+			add_action('admin_notices', function ()
190
+			{
191
+				echo '<div class="notice event-espresso-admin-notice notice-warning"><p>'
192
+					 . sprintf(
193
+						 esc_html__(
194
+							 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater.  Your web server\'s PHP version is %3$s.  You can contact your host and ask them to update your PHP version to at least PHP 5.6.  Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s',
195
+							 'event_espresso'
196
+						 ),
197
+						 '<strong>',
198
+						 '</strong>',
199
+						 PHP_VERSION,
200
+						 '<a href="https://wordpress.org/support/upgrade-php/">',
201
+						 '</a>'
202
+					 )
203
+					 . '</p></div>';
204
+			});
205
+		}
206
+	}
207 207
 }
208 208
 // Location: RecommendedVersions.php
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
         $this->request  = $request;
37 37
         $this->response = $response;
38 38
         // check required WP version
39
-        if (! $this->minimumWordPressVersionRequired()) {
39
+        if ( ! $this->minimumWordPressVersionRequired()) {
40 40
             $this->request->unSetRequestParam('activate', true);
41 41
             add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1);
42 42
             $this->response->terminateRequest();
43 43
             $this->response->deactivatePlugin();
44 44
         }
45 45
         // check recommended PHP version
46
-        if (! $this->minimumPhpVersionRecommended()) {
46
+        if ( ! $this->minimumPhpVersionRecommended()) {
47 47
             $this->displayMinimumRecommendedPhpVersionNotice();
48 48
         }
49 49
         //upcoming required version
50
-        if (! $this->upcomingRequiredPhpVersion()) {
50
+        if ( ! $this->upcomingRequiredPhpVersion()) {
51 51
             $this->displayUpcomingRequiredVersion();
52 52
         }
53 53
         $this->response = $this->processRequestStack($this->request, $this->response);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         if ($this->request->isAdmin()) {
151 151
             new PersistentAdminNotice(
152
-                'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended',
152
+                'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended',
153 153
                 sprintf(
154 154
                     esc_html__(
155 155
                         'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request)
187 187
             && current_user_can('update_plugins')
188 188
         ) {
189
-            add_action('admin_notices', function ()
189
+            add_action('admin_notices', function()
190 190
             {
191 191
                 echo '<div class="notice event-espresso-admin-notice notice-warning"><p>'
192 192
                      . sprintf(
Please login to merge, or discard this patch.
core/middleware/EE_Recommended_Versions.core.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -21,77 +21,77 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * @deprecated
26
-     * @param EE_Request $request
27
-     * @param EE_Response   $response
28
-     * @return EE_Response
29
-     */
30
-    public function handle_request(EE_Request $request, EE_Response $response)
31
-    {
32
-        EE_Error::doing_it_wrong(
33
-            __METHOD__,
34
-            sprintf(
35
-                esc_html__(
36
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
37
-                    'event_espresso'
38
-                ),
39
-                'EventEspresso\core\services\request\middleware\RecommendedVersions',
40
-                '\core\services\request',
41
-                'EventEspresso\core\services\request'
42
-            ),
43
-            '4.9.52'
44
-        );
45
-        return $response;
46
-    }
24
+	/**
25
+	 * @deprecated
26
+	 * @param EE_Request $request
27
+	 * @param EE_Response   $response
28
+	 * @return EE_Response
29
+	 */
30
+	public function handle_request(EE_Request $request, EE_Response $response)
31
+	{
32
+		EE_Error::doing_it_wrong(
33
+			__METHOD__,
34
+			sprintf(
35
+				esc_html__(
36
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
37
+					'event_espresso'
38
+				),
39
+				'EventEspresso\core\services\request\middleware\RecommendedVersions',
40
+				'\core\services\request',
41
+				'EventEspresso\core\services\request'
42
+			),
43
+			'4.9.52'
44
+		);
45
+		return $response;
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * @deprecated
51
-     * @param string $version_to_check
52
-     * @param string $operator
53
-     * @return bool
54
-     */
55
-    public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=')
56
-    {
57
-        EE_Error::doing_it_wrong(
58
-            __METHOD__,
59
-            sprintf(
60
-                esc_html__(
61
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
62
-                    'event_espresso'
63
-                ),
64
-                'EventEspresso\core\services\request\middleware\RecommendedVersions::compareWordPressVersion()',
65
-                '\core\services\request',
66
-                'EventEspresso\core\services\request'
67
-            ),
68
-            '4.9.52',
69
-            '5.0.0'
70
-        );
71
-        return RecommendedVersions::compareWordPressVersion($version_to_check, $operator);
72
-    }
49
+	/**
50
+	 * @deprecated
51
+	 * @param string $version_to_check
52
+	 * @param string $operator
53
+	 * @return bool
54
+	 */
55
+	public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=')
56
+	{
57
+		EE_Error::doing_it_wrong(
58
+			__METHOD__,
59
+			sprintf(
60
+				esc_html__(
61
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
62
+					'event_espresso'
63
+				),
64
+				'EventEspresso\core\services\request\middleware\RecommendedVersions::compareWordPressVersion()',
65
+				'\core\services\request',
66
+				'EventEspresso\core\services\request'
67
+			),
68
+			'4.9.52',
69
+			'5.0.0'
70
+		);
71
+		return RecommendedVersions::compareWordPressVersion($version_to_check, $operator);
72
+	}
73 73
 
74 74
 
75 75
 
76
-    /**
77
-     * @deprecated
78
-     * @return void
79
-     */
80
-    public function minimum_wp_version_error()
81
-    {
82
-        EE_Error::doing_it_wrong(
83
-            __METHOD__,
84
-            sprintf(
85
-                esc_html__(
86
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
87
-                    'event_espresso'
88
-                ),
89
-                'EventEspresso\core\services\request\middleware\RecommendedVersions::minimumWpVersionError()',
90
-                '\core\services\request',
91
-                'EventEspresso\core\services\request'
92
-            ),
93
-            '4.9.52'
94
-        );
95
-    }
76
+	/**
77
+	 * @deprecated
78
+	 * @return void
79
+	 */
80
+	public function minimum_wp_version_error()
81
+	{
82
+		EE_Error::doing_it_wrong(
83
+			__METHOD__,
84
+			sprintf(
85
+				esc_html__(
86
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
87
+					'event_espresso'
88
+				),
89
+				'EventEspresso\core\services\request\middleware\RecommendedVersions::minimumWpVersionError()',
90
+				'\core\services\request',
91
+				'EventEspresso\core\services\request'
92
+			),
93
+			'4.9.52'
94
+		);
95
+	}
96 96
 
97 97
 }
Please login to merge, or discard this patch.