Completed
Branch BUG/brents-suggested-tweaks-fo... (ceef0f)
by
unknown
08:41 queued 01:01
created
core/libraries/shortcodes/EE_Recipient_List_Shortcodes.lib.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -18,225 +18,225 @@
 block discarded – undo
18 18
 class EE_Recipient_List_Shortcodes extends EE_Shortcodes
19 19
 {
20 20
 
21
-    public function __construct()
22
-    {
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-    protected function _init_props()
28
-    {
29
-        $this->label = __('Recipient List Shortcodes', 'event_espresso');
30
-        $this->description = __('All shortcodes specific to registrant recipients list type data.', 'event_espresso');
31
-        $this->_shortcodes = array(
32
-            '[RECIPIENT_TICKET_LIST]' => __(
33
-                'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.',
34
-                'event_espresso'
35
-            ),
36
-            '[RECIPIENT_DATETIME_LIST]' => __(
37
-                'Will output a list of datetimes that the person receiving this message has been registered for.',
38
-                'event_espresso'
39
-            ),
40
-        );
41
-    }
42
-
43
-
44
-    protected function _parser($shortcode)
45
-    {
46
-        switch ($shortcode) {
47
-            case '[RECIPIENT_TICKET_LIST]':
48
-                return $this->_get_recipient_ticket_list();
49
-                break;
50
-
51
-            case '[RECIPIENT_DATETIME_LIST]':
52
-                return $this->_get_recipient_datetime_list();
53
-                break;
54
-        }
55
-        return '';
56
-    }
57
-
58
-
59
-    /**
60
-     * figure out what the incoming data is and then return the appropriate parsed value
61
-     *
62
-     * @return string
63
-     */
64
-    private function _get_recipient_ticket_list()
65
-    {
66
-        $this->_validate_list_requirements();
67
-
68
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
69
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data']);
70
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
71
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']);
72
-        } else {
73
-            return '';
74
-        }
75
-    }
76
-
77
-
78
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data)
79
-    {
80
-        // first get registrations just for this attendee.
81
-        $att = $data->att_obj;
82
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
83
-        $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84
-            ? array($data->reg_obj) : $registrations_on_attendee;
85
-        $tkts = array();
86
-
87
-        // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee.
88
-        // which means we want to get tickets for all events this addressee is a part of.
89
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
90
-            $valid_shortcodes = array(
91
-                'ticket',
92
-                'event_list',
93
-                'attendee_list',
94
-                'datetime_list',
95
-                'registration_details',
96
-                'attendee',
97
-                'recipient_details',
98
-            );
99
-            $template = $this->_data['template'];
100
-
101
-            // tickets will be tickets for all registrations on this attendee.
102
-            foreach ($registrations_on_attendee as $reg) {
103
-                if ($reg instanceof EE_Registration) {
104
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
-                        $data->registrations[ $reg->ID() ]
106
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
-                    ) ]['tkt_obj'] : null;
108
-                    if ($ticket instanceof EE_Ticket) {
109
-                        $tkts[ $ticket->ID() ] = $ticket;
110
-                    }
111
-                }
112
-            }
113
-        }
114
-
115
-        // if coming from the context of the event list parser, then let's return just the tickets for that event.
116
-        $event = $this->_data['data'];
117
-        if ($event instanceof EE_Event) {
118
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details');
119
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
120
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
121
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
122
-            $template = str_replace('[EVENT_LIST]', '', $template);
123
-            // data will be tickets for this event for this recipient.
124
-            foreach ($registrations_on_attendee as $reg) {
125
-                if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
-                        $data->registrations[ $reg->ID() ]
128
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
-                    ) ]['tkt_obj'] : null;
130
-                    if ($ticket instanceof EE_Ticket) {
131
-                        $tkts[ $ticket->ID() ] = $ticket;
132
-                    }
133
-                }
134
-            }
135
-        }
136
-
137
-        $tkt_parsed = '';
138
-        foreach ($tkts as $ticket) {
139
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
140
-                $template,
141
-                $ticket,
142
-                $valid_shortcodes,
143
-                $this->_extra_data
144
-            );
145
-        }
146
-        return $tkt_parsed;
147
-    }
148
-
149
-
150
-    /**
151
-     * figure out what the incoming data is and then return the appropriate parsed value
152
-     *
153
-     * @return string
154
-     */
155
-    private function _get_recipient_datetime_list()
156
-    {
157
-        $this->_validate_list_requirements();
158
-
159
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data']);
161
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']);
163
-        } else {
164
-            return '';
165
-        }
166
-    }
167
-
168
-
169
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data)
170
-    {
171
-        // first get registrations just for this attendee.
172
-        $att = $data->att_obj;
173
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
174
-        $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175
-            ? array($data->reg_obj)
176
-            : $registrations_on_attendee;
177
-        $valid_shortcodes = array('datetime', 'attendee', 'recipient_details');
178
-        $template = '';
179
-        $dtts = array();
180
-
181
-        // setup valid shortcodes depending on what the status of the $this->_data property is
182
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
183
-            $template = $this->_data['template'];
184
-
185
-            // dtts will be datetimes for all registrations on this attendee
186
-            foreach ($registrations_on_attendee as $reg) {
187
-                if ($reg instanceof EE_Registration) {
188
-                    $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
-                        $data->registrations[ $reg->ID() ]
190
-                    ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
-                    ) ]['dtt_objs'] : array();
192
-                    $dtt_objs = (array) $dtt_objs;
193
-                    foreach ($dtt_objs as $dtt_obj) {
194
-                        if ($dtt_obj instanceof EE_Datetime) {
195
-                            $dtts[ $dtt_obj->ID() ] = $dtt_obj;
196
-                        }
197
-                    }
198
-                }
199
-            }
200
-        }
201
-
202
-        // if coming from the context of the event list parser, then let's just return the datetimes for the specific event.
203
-        $event = $this->_data['data'];
204
-        if ($event instanceof EE_Event) {
205
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
206
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
207
-
208
-            // data will be datetimes for this event for this recipient
209
-            foreach ($registrations_on_attendee as $reg) {
210
-                if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
-                        $data->registrations[ $reg->ID() ]
213
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
-                    ) ]['tkt_obj'] : null;
215
-                    if ($ticket instanceof EE_Ticket) {
216
-                        $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
-                            $data->tickets[ $ticket->ID() ]
218
-                        ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
-                        ) ]['dtt_objs'] : array();
220
-                        $dtt_objs = (array) $dtt_objs;
221
-                        foreach ($dtt_objs as $dtt_obj) {
222
-                            if ($dtt_obj instanceof EE_Datetime) {
223
-                                $dtts[ $dtt_obj->ID() ] = $dtt_obj;
224
-                            }
225
-                        }
226
-                    }
227
-                }
228
-            }
229
-        }
230
-
231
-        $dtt_parsed = '';
232
-        foreach ($dtts as $datetime) {
233
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
234
-                $template,
235
-                $datetime,
236
-                $valid_shortcodes,
237
-                $this->_extra_data
238
-            );
239
-        }
240
-        return $dtt_parsed;
241
-    }
21
+	public function __construct()
22
+	{
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+	protected function _init_props()
28
+	{
29
+		$this->label = __('Recipient List Shortcodes', 'event_espresso');
30
+		$this->description = __('All shortcodes specific to registrant recipients list type data.', 'event_espresso');
31
+		$this->_shortcodes = array(
32
+			'[RECIPIENT_TICKET_LIST]' => __(
33
+				'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.',
34
+				'event_espresso'
35
+			),
36
+			'[RECIPIENT_DATETIME_LIST]' => __(
37
+				'Will output a list of datetimes that the person receiving this message has been registered for.',
38
+				'event_espresso'
39
+			),
40
+		);
41
+	}
42
+
43
+
44
+	protected function _parser($shortcode)
45
+	{
46
+		switch ($shortcode) {
47
+			case '[RECIPIENT_TICKET_LIST]':
48
+				return $this->_get_recipient_ticket_list();
49
+				break;
50
+
51
+			case '[RECIPIENT_DATETIME_LIST]':
52
+				return $this->_get_recipient_datetime_list();
53
+				break;
54
+		}
55
+		return '';
56
+	}
57
+
58
+
59
+	/**
60
+	 * figure out what the incoming data is and then return the appropriate parsed value
61
+	 *
62
+	 * @return string
63
+	 */
64
+	private function _get_recipient_ticket_list()
65
+	{
66
+		$this->_validate_list_requirements();
67
+
68
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
69
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data']);
70
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
71
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']);
72
+		} else {
73
+			return '';
74
+		}
75
+	}
76
+
77
+
78
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data)
79
+	{
80
+		// first get registrations just for this attendee.
81
+		$att = $data->att_obj;
82
+		$registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
83
+		$registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84
+			? array($data->reg_obj) : $registrations_on_attendee;
85
+		$tkts = array();
86
+
87
+		// if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee.
88
+		// which means we want to get tickets for all events this addressee is a part of.
89
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
90
+			$valid_shortcodes = array(
91
+				'ticket',
92
+				'event_list',
93
+				'attendee_list',
94
+				'datetime_list',
95
+				'registration_details',
96
+				'attendee',
97
+				'recipient_details',
98
+			);
99
+			$template = $this->_data['template'];
100
+
101
+			// tickets will be tickets for all registrations on this attendee.
102
+			foreach ($registrations_on_attendee as $reg) {
103
+				if ($reg instanceof EE_Registration) {
104
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
+						$data->registrations[ $reg->ID() ]
106
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
+					) ]['tkt_obj'] : null;
108
+					if ($ticket instanceof EE_Ticket) {
109
+						$tkts[ $ticket->ID() ] = $ticket;
110
+					}
111
+				}
112
+			}
113
+		}
114
+
115
+		// if coming from the context of the event list parser, then let's return just the tickets for that event.
116
+		$event = $this->_data['data'];
117
+		if ($event instanceof EE_Event) {
118
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details');
119
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
120
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
121
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
122
+			$template = str_replace('[EVENT_LIST]', '', $template);
123
+			// data will be tickets for this event for this recipient.
124
+			foreach ($registrations_on_attendee as $reg) {
125
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
+						$data->registrations[ $reg->ID() ]
128
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
+					) ]['tkt_obj'] : null;
130
+					if ($ticket instanceof EE_Ticket) {
131
+						$tkts[ $ticket->ID() ] = $ticket;
132
+					}
133
+				}
134
+			}
135
+		}
136
+
137
+		$tkt_parsed = '';
138
+		foreach ($tkts as $ticket) {
139
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
140
+				$template,
141
+				$ticket,
142
+				$valid_shortcodes,
143
+				$this->_extra_data
144
+			);
145
+		}
146
+		return $tkt_parsed;
147
+	}
148
+
149
+
150
+	/**
151
+	 * figure out what the incoming data is and then return the appropriate parsed value
152
+	 *
153
+	 * @return string
154
+	 */
155
+	private function _get_recipient_datetime_list()
156
+	{
157
+		$this->_validate_list_requirements();
158
+
159
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data']);
161
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']);
163
+		} else {
164
+			return '';
165
+		}
166
+	}
167
+
168
+
169
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data)
170
+	{
171
+		// first get registrations just for this attendee.
172
+		$att = $data->att_obj;
173
+		$registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
174
+		$registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175
+			? array($data->reg_obj)
176
+			: $registrations_on_attendee;
177
+		$valid_shortcodes = array('datetime', 'attendee', 'recipient_details');
178
+		$template = '';
179
+		$dtts = array();
180
+
181
+		// setup valid shortcodes depending on what the status of the $this->_data property is
182
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
183
+			$template = $this->_data['template'];
184
+
185
+			// dtts will be datetimes for all registrations on this attendee
186
+			foreach ($registrations_on_attendee as $reg) {
187
+				if ($reg instanceof EE_Registration) {
188
+					$dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
+						$data->registrations[ $reg->ID() ]
190
+					) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
+					) ]['dtt_objs'] : array();
192
+					$dtt_objs = (array) $dtt_objs;
193
+					foreach ($dtt_objs as $dtt_obj) {
194
+						if ($dtt_obj instanceof EE_Datetime) {
195
+							$dtts[ $dtt_obj->ID() ] = $dtt_obj;
196
+						}
197
+					}
198
+				}
199
+			}
200
+		}
201
+
202
+		// if coming from the context of the event list parser, then let's just return the datetimes for the specific event.
203
+		$event = $this->_data['data'];
204
+		if ($event instanceof EE_Event) {
205
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
206
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
207
+
208
+			// data will be datetimes for this event for this recipient
209
+			foreach ($registrations_on_attendee as $reg) {
210
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
+					$ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
+						$data->registrations[ $reg->ID() ]
213
+					) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
+					) ]['tkt_obj'] : null;
215
+					if ($ticket instanceof EE_Ticket) {
216
+						$dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
+							$data->tickets[ $ticket->ID() ]
218
+						) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
+						) ]['dtt_objs'] : array();
220
+						$dtt_objs = (array) $dtt_objs;
221
+						foreach ($dtt_objs as $dtt_obj) {
222
+							if ($dtt_obj instanceof EE_Datetime) {
223
+								$dtts[ $dtt_obj->ID() ] = $dtt_obj;
224
+							}
225
+						}
226
+					}
227
+				}
228
+			}
229
+		}
230
+
231
+		$dtt_parsed = '';
232
+		foreach ($dtts as $datetime) {
233
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
234
+				$template,
235
+				$datetime,
236
+				$valid_shortcodes,
237
+				$this->_extra_data
238
+			);
239
+		}
240
+		return $dtt_parsed;
241
+	}
242 242
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         // first get registrations just for this attendee.
81 81
         $att = $data->att_obj;
82
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
82
+        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array();
83 83
         $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
84 84
             ? array($data->reg_obj) : $registrations_on_attendee;
85 85
         $tkts = array();
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
             // tickets will be tickets for all registrations on this attendee.
102 102
             foreach ($registrations_on_attendee as $reg) {
103 103
                 if ($reg instanceof EE_Registration) {
104
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
105
-                        $data->registrations[ $reg->ID() ]
106
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
107
-                    ) ]['tkt_obj'] : null;
104
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
105
+                        $data->registrations[$reg->ID()]
106
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
107
+                    )]['tkt_obj'] : null;
108 108
                     if ($ticket instanceof EE_Ticket) {
109
-                        $tkts[ $ticket->ID() ] = $ticket;
109
+                        $tkts[$ticket->ID()] = $ticket;
110 110
                     }
111 111
                 }
112 112
             }
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
             // data will be tickets for this event for this recipient.
124 124
             foreach ($registrations_on_attendee as $reg) {
125 125
                 if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
126
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
127
-                        $data->registrations[ $reg->ID() ]
128
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
129
-                    ) ]['tkt_obj'] : null;
126
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
127
+                        $data->registrations[$reg->ID()]
128
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
129
+                    )]['tkt_obj'] : null;
130 130
                     if ($ticket instanceof EE_Ticket) {
131
-                        $tkts[ $ticket->ID() ] = $ticket;
131
+                        $tkts[$ticket->ID()] = $ticket;
132 132
                     }
133 133
                 }
134 134
             }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     {
171 171
         // first get registrations just for this attendee.
172 172
         $att = $data->att_obj;
173
-        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array();
173
+        $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array();
174 174
         $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration
175 175
             ? array($data->reg_obj)
176 176
             : $registrations_on_attendee;
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
             // dtts will be datetimes for all registrations on this attendee
186 186
             foreach ($registrations_on_attendee as $reg) {
187 187
                 if ($reg instanceof EE_Registration) {
188
-                    $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array(
189
-                        $data->registrations[ $reg->ID() ]
190
-                    ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID(
191
-                    ) ]['dtt_objs'] : array();
188
+                    $dtt_objs = isset($data->registrations[$reg->ID()]) && is_array(
189
+                        $data->registrations[$reg->ID()]
190
+                    ) && isset($data->registrations[$reg->ID()]['dtt_objs']) ? $data->registrations[$reg->ID(
191
+                    )]['dtt_objs'] : array();
192 192
                     $dtt_objs = (array) $dtt_objs;
193 193
                     foreach ($dtt_objs as $dtt_obj) {
194 194
                         if ($dtt_obj instanceof EE_Datetime) {
195
-                            $dtts[ $dtt_obj->ID() ] = $dtt_obj;
195
+                            $dtts[$dtt_obj->ID()] = $dtt_obj;
196 196
                         }
197 197
                     }
198 198
                 }
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
             // data will be datetimes for this event for this recipient
209 209
             foreach ($registrations_on_attendee as $reg) {
210 210
                 if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
211
-                    $ticket = isset($data->registrations[ $reg->ID() ]) && is_array(
212
-                        $data->registrations[ $reg->ID() ]
213
-                    ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID(
214
-                    ) ]['tkt_obj'] : null;
211
+                    $ticket = isset($data->registrations[$reg->ID()]) && is_array(
212
+                        $data->registrations[$reg->ID()]
213
+                    ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID(
214
+                    )]['tkt_obj'] : null;
215 215
                     if ($ticket instanceof EE_Ticket) {
216
-                        $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array(
217
-                            $data->tickets[ $ticket->ID() ]
218
-                        ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID(
219
-                        ) ]['dtt_objs'] : array();
216
+                        $dtt_objs = isset($data->tickets[$ticket->ID()]) && is_array(
217
+                            $data->tickets[$ticket->ID()]
218
+                        ) && isset($data->tickets[$ticket->ID()]['dtt_objs']) ? $data->tickets[$ticket->ID(
219
+                        )]['dtt_objs'] : array();
220 220
                         $dtt_objs = (array) $dtt_objs;
221 221
                         foreach ($dtt_objs as $dtt_obj) {
222 222
                             if ($dtt_obj instanceof EE_Datetime) {
223
-                                $dtts[ $dtt_obj->ID() ] = $dtt_obj;
223
+                                $dtts[$dtt_obj->ID()] = $dtt_obj;
224 224
                             }
225 225
                         }
226 226
                     }
Please login to merge, or discard this patch.
core/domain/services/admin/registrations/list_table/QueryBuilder.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -383,7 +383,7 @@
 block discarded – undo
383 383
     /**
384 384
      * Sets up the limit for the registrations query.
385 385
      *
386
-     * @param $per_page
386
+     * @param integer $per_page
387 387
      * @return array
388 388
      */
389 389
     protected function getLimitClause($per_page)
Please login to merge, or discard this patch.
Indentation   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -21,384 +21,384 @@
 block discarded – undo
21 21
 class QueryBuilder
22 22
 {
23 23
 
24
-    /**
25
-     * @var RequestInterface $request
26
-     */
27
-    protected $request;
28
-
29
-    /**
30
-     * @var EEM_Registration $registration_model
31
-     */
32
-    protected $registration_model;
33
-
34
-    /**
35
-     * @var string $view
36
-     */
37
-    protected $view;
38
-
39
-    /**
40
-     * @var array $where_params
41
-     */
42
-    protected $where_params;
43
-
44
-
45
-    /**
46
-     * QueryBuilder constructor.
47
-     *
48
-     * @param array            $extra_request_params
49
-     * @param RequestInterface $request
50
-     * @param EEM_Registration $registration_model
51
-     */
52
-    public function __construct(
53
-        array $extra_request_params,
54
-        RequestInterface $request,
55
-        EEM_Registration $registration_model
56
-    ) {
57
-        $this->request = $request;
58
-        $this->registration_model = $registration_model;
59
-        foreach ($extra_request_params as $key => $value) {
60
-            $this->request->setRequestParam($key, $value);
61
-        }
62
-        $this->view = $this->request->getRequestParam('status', '');
63
-        $this->where_params = [];
64
-    }
65
-
66
-
67
-    /**
68
-     * Sets up the where conditions for the registrations query.
69
-     *
70
-     * @param int  $per_page
71
-     * @param bool $count_query
72
-     * @return array
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     */
78
-    public function getQueryParams($per_page = 10, $count_query = false)
79
-    {
80
-        $query_params = [
81
-            0                          => $this->getWhereClause(),
82
-            'caps'                     => EEM_Registration::caps_read_admin,
83
-            'default_where_conditions' => 'this_model_only',
84
-        ];
85
-        if (! $count_query) {
86
-            $query_params = array_merge(
87
-                $query_params,
88
-                $this->getOrderbyClause(),
89
-                $this->getLimitClause($per_page)
90
-            );
91
-        }
92
-
93
-        return $query_params;
94
-    }
95
-
96
-
97
-    /**
98
-     * Sets up the where conditions for the registrations query.
99
-     *
100
-     * @return array
101
-     * @throws EE_Error
102
-     * @throws InvalidArgumentException
103
-     * @throws InvalidDataTypeException
104
-     * @throws InvalidInterfaceException
105
-     */
106
-    protected function getWhereClause()
107
-    {
108
-        $this->addAttendeeIdToWhereConditions();
109
-        $this->addEventIdToWhereConditions();
110
-        $this->addCategoryIdToWhereConditions();
111
-        $this->addDatetimeIdToWhereConditions();
112
-        $this->addTicketIdToWhereConditions();
113
-        $this->addRegistrationStatusToWhereConditions();
114
-        $this->addDateToWhereConditions();
115
-        $this->addSearchToWhereConditions();
116
-        return apply_filters(
117
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
-            $this->where_params,
119
-            $this->request->requestParams()
120
-        );
121
-    }
122
-
123
-
124
-    /**
125
-     * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
-     */
127
-    protected function addAttendeeIdToWhereConditions()
128
-    {
129
-        $ATT_ID = $this->request->getRequestParam('attendee_id');
130
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID);
131
-        if ($ATT_ID) {
132
-            $this->where_params['ATT_ID'] = absint($ATT_ID);
133
-        }
134
-    }
135
-
136
-
137
-    /**
138
-     * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
-     */
140
-    protected function addEventIdToWhereConditions()
141
-    {
142
-        $EVT_ID = $this->request->getRequestParam('event_id');
143
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID);
144
-        if ($EVT_ID) {
145
-            $this->where_params['EVT_ID'] = absint($EVT_ID);
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
-     */
153
-    protected function addCategoryIdToWhereConditions()
154
-    {
155
-        $EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT');
156
-        if ($EVT_CAT > 0) {
157
-            $this->where_params['Event.Term_Taxonomy.term_id'] = absint($EVT_CAT);
158
-        }
159
-    }
160
-
161
-
162
-    /**
163
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
-     */
165
-    protected function addDatetimeIdToWhereConditions()
166
-    {
167
-        // first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
-        $DTT_ID = $this->request->getRequestParam('datetime_id');
169
-        $DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID);
170
-        if ($DTT_ID) {
171
-            $this->where_params['Ticket.Datetime.DTT_ID'] = absint($DTT_ID);
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
-     */
179
-    protected function addTicketIdToWhereConditions()
180
-    {
181
-        // first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
-        $TKT_ID = $this->request->getRequestParam('ticket_id');
183
-        $TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID);
184
-        if ($TKT_ID) {
185
-            $this->where_params['TKT_ID'] = absint($TKT_ID);
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * Adds the correct registration status to the where conditions for the registrations query.
192
-     * If filtering by registration status, then we show registrations matching that status.
193
-     * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
-     * UNLESS viewing trashed registrations.
195
-     */
196
-    protected function addRegistrationStatusToWhereConditions()
197
-    {
198
-        $registration_status = $this->request->getRequestParam('_reg_status');
199
-        if ($registration_status) {
200
-            $this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
-            return;
202
-        }
203
-        // make sure we exclude incomplete registrations, but only if not trashed.
204
-        if ($this->view === 'trash') {
205
-            $this->where_params['REG_deleted'] = true;
206
-            return;
207
-        }
208
-        $this->where_params['STS_ID'] = $this->view === 'incomplete'
209
-            ? EEM_Registration::status_id_incomplete
210
-            : ['!=', EEM_Registration::status_id_incomplete];
211
-    }
212
-
213
-
214
-    /**
215
-     * Adds any provided date restraints to the where conditions for the registrations query.
216
-     *
217
-     * @throws EE_Error
218
-     * @throws InvalidArgumentException
219
-     * @throws InvalidDataTypeException
220
-     * @throws InvalidInterfaceException
221
-     */
222
-    protected function addDateToWhereConditions()
223
-    {
224
-        if ($this->view === 'today') {
225
-            $now = date('Y-m-d', current_time('timestamp'));
226
-            $this->where_params['REG_date'] = [
227
-                'BETWEEN',
228
-                [
229
-                    $this->registration_model->convert_datetime_for_query(
230
-                        'REG_date',
231
-                        $now . ' 00:00:00',
232
-                        'Y-m-d H:i:s'
233
-                    ),
234
-                    $this->registration_model->convert_datetime_for_query(
235
-                        'REG_date',
236
-                        $now . ' 23:59:59',
237
-                        'Y-m-d H:i:s'
238
-                    ),
239
-                ],
240
-            ];
241
-            return;
242
-        }
243
-        if ($this->view === 'month') {
244
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
245
-            $days_this_month = date('t', current_time('timestamp'));
246
-            $this->where_params['REG_date'] = [
247
-                'BETWEEN',
248
-                [
249
-                    $this->registration_model->convert_datetime_for_query(
250
-                        'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
252
-                        'Y-m-d H:i:s'
253
-                    ),
254
-                    $this->registration_model->convert_datetime_for_query(
255
-                        'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
-                        'Y-m-d H:i:s'
258
-                    ),
259
-                ],
260
-            ];
261
-            return;
262
-        }
263
-        $month_range = $this->request->getRequestParam('month_range');
264
-        if ($month_range) {
265
-            $month_range = sanitize_text_field($month_range);
266
-            $pieces = explode(' ', $month_range, 3);
267
-            $month_requested = ! empty($pieces[0])
268
-                ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
-                : '';
270
-            $year_requested = ! empty($pieces[1])
271
-                ? $pieces[1]
272
-                : '';
273
-            // if there is not a month or year then we can't go further
274
-            if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
-                $this->where_params['REG_date'] = [
277
-                    'BETWEEN',
278
-                    [
279
-                        $this->registration_model->convert_datetime_for_query(
280
-                            'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
282
-                            'Y-m-d H:i:s'
283
-                        ),
284
-                        $this->registration_model->convert_datetime_for_query(
285
-                            'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
-                            'Y-m-d H:i:s'
288
-                        ),
289
-                    ],
290
-                ];
291
-            }
292
-        }
293
-    }
294
-
295
-
296
-    /**
297
-     * Adds any provided search restraints to the where conditions for the registrations query
298
-     */
299
-    protected function addSearchToWhereConditions()
300
-    {
301
-        $search = $this->request->getRequestParam('s');
302
-        if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
304
-            $this->where_params['OR*search_conditions'] = [
305
-                'Event.EVT_name'                          => ['LIKE', $search_string],
306
-                'Event.EVT_desc'                          => ['LIKE', $search_string],
307
-                'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
-                'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
-                'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
-                'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
-                'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
-                'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
-                'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
-                'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
-                'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
-                'REG_final_price'                         => ['LIKE', $search_string],
317
-                'REG_code'                                => ['LIKE', $search_string],
318
-                'REG_count'                               => ['LIKE', $search_string],
319
-                'REG_group_size'                          => ['LIKE', $search_string],
320
-                'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
-                'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
-            ];
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * Sets up the orderby for the registrations query.
330
-     *
331
-     * @return array
332
-     */
333
-    protected function getOrderbyClause()
334
-    {
335
-        $orderby_field = $this->request->getRequestParam('orderby');
336
-        $orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
-        switch ($orderby_field) {
338
-            case '_REG_ID':
339
-                $orderby = ['REG_ID'];
340
-                break;
341
-            case '_Reg_status':
342
-                $orderby = ['STS_ID'];
343
-                break;
344
-            case 'ATT_fname':
345
-                $orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
-                break;
347
-            case 'ATT_lname':
348
-                $orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
-                break;
350
-            case 'event_name':
351
-                $orderby = ['Event.EVT_name'];
352
-                break;
353
-            case 'DTT_EVT_start':
354
-                $orderby = ['Event.Datetime.DTT_EVT_start'];
355
-                break;
356
-            case '_REG_date':
357
-                $orderby = ['REG_date'];
358
-                break;
359
-            default:
360
-                $orderby = [$orderby_field];
361
-                break;
362
-        }
363
-        $order = $this->request->getRequestParam('order');
364
-        $order = $order ? sanitize_text_field($order) : 'DESC';
365
-
366
-        $orderby = array_combine(
367
-            $orderby,
368
-            array_fill(0, count($orderby), $order)
369
-        );
370
-        // because there are many registrations with the same date, define
371
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
372
-        if (empty($orderby['REG_ID'])) {
373
-            $orderby['REG_ID'] = $order;
374
-        }
375
-
376
-        $orderby = apply_filters(
377
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
-            $orderby,
379
-            $this->request->requestParams()
380
-        );
381
-        return ['order_by' => $orderby];
382
-    }
383
-
384
-
385
-    /**
386
-     * Sets up the limit for the registrations query.
387
-     *
388
-     * @param $per_page
389
-     * @return array
390
-     */
391
-    protected function getLimitClause($per_page)
392
-    {
393
-        $current_page = $this->request->getRequestParam('paged');
394
-        $current_page = $current_page ? absint($current_page) : 1;
395
-        $per_page = (int) $this->request->getRequestParam('perpage', $per_page);
396
-        // -1 means return all results so get out if that's set.
397
-        if ($per_page === -1) {
398
-            return [];
399
-        }
400
-        $per_page = absint($per_page);
401
-        $offset = ($current_page - 1) * $per_page;
402
-        return ['limit' => [$offset, $per_page]];
403
-    }
24
+	/**
25
+	 * @var RequestInterface $request
26
+	 */
27
+	protected $request;
28
+
29
+	/**
30
+	 * @var EEM_Registration $registration_model
31
+	 */
32
+	protected $registration_model;
33
+
34
+	/**
35
+	 * @var string $view
36
+	 */
37
+	protected $view;
38
+
39
+	/**
40
+	 * @var array $where_params
41
+	 */
42
+	protected $where_params;
43
+
44
+
45
+	/**
46
+	 * QueryBuilder constructor.
47
+	 *
48
+	 * @param array            $extra_request_params
49
+	 * @param RequestInterface $request
50
+	 * @param EEM_Registration $registration_model
51
+	 */
52
+	public function __construct(
53
+		array $extra_request_params,
54
+		RequestInterface $request,
55
+		EEM_Registration $registration_model
56
+	) {
57
+		$this->request = $request;
58
+		$this->registration_model = $registration_model;
59
+		foreach ($extra_request_params as $key => $value) {
60
+			$this->request->setRequestParam($key, $value);
61
+		}
62
+		$this->view = $this->request->getRequestParam('status', '');
63
+		$this->where_params = [];
64
+	}
65
+
66
+
67
+	/**
68
+	 * Sets up the where conditions for the registrations query.
69
+	 *
70
+	 * @param int  $per_page
71
+	 * @param bool $count_query
72
+	 * @return array
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 */
78
+	public function getQueryParams($per_page = 10, $count_query = false)
79
+	{
80
+		$query_params = [
81
+			0                          => $this->getWhereClause(),
82
+			'caps'                     => EEM_Registration::caps_read_admin,
83
+			'default_where_conditions' => 'this_model_only',
84
+		];
85
+		if (! $count_query) {
86
+			$query_params = array_merge(
87
+				$query_params,
88
+				$this->getOrderbyClause(),
89
+				$this->getLimitClause($per_page)
90
+			);
91
+		}
92
+
93
+		return $query_params;
94
+	}
95
+
96
+
97
+	/**
98
+	 * Sets up the where conditions for the registrations query.
99
+	 *
100
+	 * @return array
101
+	 * @throws EE_Error
102
+	 * @throws InvalidArgumentException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws InvalidInterfaceException
105
+	 */
106
+	protected function getWhereClause()
107
+	{
108
+		$this->addAttendeeIdToWhereConditions();
109
+		$this->addEventIdToWhereConditions();
110
+		$this->addCategoryIdToWhereConditions();
111
+		$this->addDatetimeIdToWhereConditions();
112
+		$this->addTicketIdToWhereConditions();
113
+		$this->addRegistrationStatusToWhereConditions();
114
+		$this->addDateToWhereConditions();
115
+		$this->addSearchToWhereConditions();
116
+		return apply_filters(
117
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
118
+			$this->where_params,
119
+			$this->request->requestParams()
120
+		);
121
+	}
122
+
123
+
124
+	/**
125
+	 * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
126
+	 */
127
+	protected function addAttendeeIdToWhereConditions()
128
+	{
129
+		$ATT_ID = $this->request->getRequestParam('attendee_id');
130
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID);
131
+		if ($ATT_ID) {
132
+			$this->where_params['ATT_ID'] = absint($ATT_ID);
133
+		}
134
+	}
135
+
136
+
137
+	/**
138
+	 * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
139
+	 */
140
+	protected function addEventIdToWhereConditions()
141
+	{
142
+		$EVT_ID = $this->request->getRequestParam('event_id');
143
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID);
144
+		if ($EVT_ID) {
145
+			$this->where_params['EVT_ID'] = absint($EVT_ID);
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
152
+	 */
153
+	protected function addCategoryIdToWhereConditions()
154
+	{
155
+		$EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT');
156
+		if ($EVT_CAT > 0) {
157
+			$this->where_params['Event.Term_Taxonomy.term_id'] = absint($EVT_CAT);
158
+		}
159
+	}
160
+
161
+
162
+	/**
163
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
164
+	 */
165
+	protected function addDatetimeIdToWhereConditions()
166
+	{
167
+		// first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
168
+		$DTT_ID = $this->request->getRequestParam('datetime_id');
169
+		$DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID);
170
+		if ($DTT_ID) {
171
+			$this->where_params['Ticket.Datetime.DTT_ID'] = absint($DTT_ID);
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
178
+	 */
179
+	protected function addTicketIdToWhereConditions()
180
+	{
181
+		// first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
182
+		$TKT_ID = $this->request->getRequestParam('ticket_id');
183
+		$TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID);
184
+		if ($TKT_ID) {
185
+			$this->where_params['TKT_ID'] = absint($TKT_ID);
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * Adds the correct registration status to the where conditions for the registrations query.
192
+	 * If filtering by registration status, then we show registrations matching that status.
193
+	 * If not filtering by specified status, then we show all registrations excluding incomplete registrations
194
+	 * UNLESS viewing trashed registrations.
195
+	 */
196
+	protected function addRegistrationStatusToWhereConditions()
197
+	{
198
+		$registration_status = $this->request->getRequestParam('_reg_status');
199
+		if ($registration_status) {
200
+			$this->where_params['STS_ID'] = sanitize_text_field($registration_status);
201
+			return;
202
+		}
203
+		// make sure we exclude incomplete registrations, but only if not trashed.
204
+		if ($this->view === 'trash') {
205
+			$this->where_params['REG_deleted'] = true;
206
+			return;
207
+		}
208
+		$this->where_params['STS_ID'] = $this->view === 'incomplete'
209
+			? EEM_Registration::status_id_incomplete
210
+			: ['!=', EEM_Registration::status_id_incomplete];
211
+	}
212
+
213
+
214
+	/**
215
+	 * Adds any provided date restraints to the where conditions for the registrations query.
216
+	 *
217
+	 * @throws EE_Error
218
+	 * @throws InvalidArgumentException
219
+	 * @throws InvalidDataTypeException
220
+	 * @throws InvalidInterfaceException
221
+	 */
222
+	protected function addDateToWhereConditions()
223
+	{
224
+		if ($this->view === 'today') {
225
+			$now = date('Y-m-d', current_time('timestamp'));
226
+			$this->where_params['REG_date'] = [
227
+				'BETWEEN',
228
+				[
229
+					$this->registration_model->convert_datetime_for_query(
230
+						'REG_date',
231
+						$now . ' 00:00:00',
232
+						'Y-m-d H:i:s'
233
+					),
234
+					$this->registration_model->convert_datetime_for_query(
235
+						'REG_date',
236
+						$now . ' 23:59:59',
237
+						'Y-m-d H:i:s'
238
+					),
239
+				],
240
+			];
241
+			return;
242
+		}
243
+		if ($this->view === 'month') {
244
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
245
+			$days_this_month = date('t', current_time('timestamp'));
246
+			$this->where_params['REG_date'] = [
247
+				'BETWEEN',
248
+				[
249
+					$this->registration_model->convert_datetime_for_query(
250
+						'REG_date',
251
+						$current_year_and_month . '-01 00:00:00',
252
+						'Y-m-d H:i:s'
253
+					),
254
+					$this->registration_model->convert_datetime_for_query(
255
+						'REG_date',
256
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
257
+						'Y-m-d H:i:s'
258
+					),
259
+				],
260
+			];
261
+			return;
262
+		}
263
+		$month_range = $this->request->getRequestParam('month_range');
264
+		if ($month_range) {
265
+			$month_range = sanitize_text_field($month_range);
266
+			$pieces = explode(' ', $month_range, 3);
267
+			$month_requested = ! empty($pieces[0])
268
+				? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
269
+				: '';
270
+			$year_requested = ! empty($pieces[1])
271
+				? $pieces[1]
272
+				: '';
273
+			// if there is not a month or year then we can't go further
274
+			if ($month_requested && $year_requested) {
275
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
276
+				$this->where_params['REG_date'] = [
277
+					'BETWEEN',
278
+					[
279
+						$this->registration_model->convert_datetime_for_query(
280
+							'REG_date',
281
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
282
+							'Y-m-d H:i:s'
283
+						),
284
+						$this->registration_model->convert_datetime_for_query(
285
+							'REG_date',
286
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
287
+							'Y-m-d H:i:s'
288
+						),
289
+					],
290
+				];
291
+			}
292
+		}
293
+	}
294
+
295
+
296
+	/**
297
+	 * Adds any provided search restraints to the where conditions for the registrations query
298
+	 */
299
+	protected function addSearchToWhereConditions()
300
+	{
301
+		$search = $this->request->getRequestParam('s');
302
+		if ($search) {
303
+			$search_string = '%' . sanitize_text_field($search) . '%';
304
+			$this->where_params['OR*search_conditions'] = [
305
+				'Event.EVT_name'                          => ['LIKE', $search_string],
306
+				'Event.EVT_desc'                          => ['LIKE', $search_string],
307
+				'Event.EVT_short_desc'                    => ['LIKE', $search_string],
308
+				'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
309
+				'Attendee.ATT_fname'                      => ['LIKE', $search_string],
310
+				'Attendee.ATT_lname'                      => ['LIKE', $search_string],
311
+				'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
312
+				'Attendee.ATT_email'                      => ['LIKE', $search_string],
313
+				'Attendee.ATT_address'                    => ['LIKE', $search_string],
314
+				'Attendee.ATT_address2'                   => ['LIKE', $search_string],
315
+				'Attendee.ATT_city'                       => ['LIKE', $search_string],
316
+				'REG_final_price'                         => ['LIKE', $search_string],
317
+				'REG_code'                                => ['LIKE', $search_string],
318
+				'REG_count'                               => ['LIKE', $search_string],
319
+				'REG_group_size'                          => ['LIKE', $search_string],
320
+				'Ticket.TKT_name'                         => ['LIKE', $search_string],
321
+				'Ticket.TKT_description'                  => ['LIKE', $search_string],
322
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
323
+			];
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * Sets up the orderby for the registrations query.
330
+	 *
331
+	 * @return array
332
+	 */
333
+	protected function getOrderbyClause()
334
+	{
335
+		$orderby_field = $this->request->getRequestParam('orderby');
336
+		$orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
337
+		switch ($orderby_field) {
338
+			case '_REG_ID':
339
+				$orderby = ['REG_ID'];
340
+				break;
341
+			case '_Reg_status':
342
+				$orderby = ['STS_ID'];
343
+				break;
344
+			case 'ATT_fname':
345
+				$orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
346
+				break;
347
+			case 'ATT_lname':
348
+				$orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
349
+				break;
350
+			case 'event_name':
351
+				$orderby = ['Event.EVT_name'];
352
+				break;
353
+			case 'DTT_EVT_start':
354
+				$orderby = ['Event.Datetime.DTT_EVT_start'];
355
+				break;
356
+			case '_REG_date':
357
+				$orderby = ['REG_date'];
358
+				break;
359
+			default:
360
+				$orderby = [$orderby_field];
361
+				break;
362
+		}
363
+		$order = $this->request->getRequestParam('order');
364
+		$order = $order ? sanitize_text_field($order) : 'DESC';
365
+
366
+		$orderby = array_combine(
367
+			$orderby,
368
+			array_fill(0, count($orderby), $order)
369
+		);
370
+		// because there are many registrations with the same date, define
371
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
372
+		if (empty($orderby['REG_ID'])) {
373
+			$orderby['REG_ID'] = $order;
374
+		}
375
+
376
+		$orderby = apply_filters(
377
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
378
+			$orderby,
379
+			$this->request->requestParams()
380
+		);
381
+		return ['order_by' => $orderby];
382
+	}
383
+
384
+
385
+	/**
386
+	 * Sets up the limit for the registrations query.
387
+	 *
388
+	 * @param $per_page
389
+	 * @return array
390
+	 */
391
+	protected function getLimitClause($per_page)
392
+	{
393
+		$current_page = $this->request->getRequestParam('paged');
394
+		$current_page = $current_page ? absint($current_page) : 1;
395
+		$per_page = (int) $this->request->getRequestParam('perpage', $per_page);
396
+		// -1 means return all results so get out if that's set.
397
+		if ($per_page === -1) {
398
+			return [];
399
+		}
400
+		$per_page = absint($per_page);
401
+		$offset = ($current_page - 1) * $per_page;
402
+		return ['limit' => [$offset, $per_page]];
403
+	}
404 404
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'caps'                     => EEM_Registration::caps_read_admin,
83 83
             'default_where_conditions' => 'this_model_only',
84 84
         ];
85
-        if (! $count_query) {
85
+        if ( ! $count_query) {
86 86
             $query_params = array_merge(
87 87
                 $query_params,
88 88
                 $this->getOrderbyClause(),
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
                 [
229 229
                     $this->registration_model->convert_datetime_for_query(
230 230
                         'REG_date',
231
-                        $now . ' 00:00:00',
231
+                        $now.' 00:00:00',
232 232
                         'Y-m-d H:i:s'
233 233
                     ),
234 234
                     $this->registration_model->convert_datetime_for_query(
235 235
                         'REG_date',
236
-                        $now . ' 23:59:59',
236
+                        $now.' 23:59:59',
237 237
                         'Y-m-d H:i:s'
238 238
                     ),
239 239
                 ],
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                 [
249 249
                     $this->registration_model->convert_datetime_for_query(
250 250
                         'REG_date',
251
-                        $current_year_and_month . '-01 00:00:00',
251
+                        $current_year_and_month.'-01 00:00:00',
252 252
                         'Y-m-d H:i:s'
253 253
                     ),
254 254
                     $this->registration_model->convert_datetime_for_query(
255 255
                         'REG_date',
256
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
256
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
257 257
                         'Y-m-d H:i:s'
258 258
                     ),
259 259
                 ],
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
                 : '';
273 273
             // if there is not a month or year then we can't go further
274 274
             if ($month_requested && $year_requested) {
275
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
275
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
276 276
                 $this->where_params['REG_date'] = [
277 277
                     'BETWEEN',
278 278
                     [
279 279
                         $this->registration_model->convert_datetime_for_query(
280 280
                             'REG_date',
281
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
281
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
282 282
                             'Y-m-d H:i:s'
283 283
                         ),
284 284
                         $this->registration_model->convert_datetime_for_query(
285 285
                             'REG_date',
286
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
286
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
287 287
                             'Y-m-d H:i:s'
288 288
                         ),
289 289
                     ],
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         $search = $this->request->getRequestParam('s');
302 302
         if ($search) {
303
-            $search_string = '%' . sanitize_text_field($search) . '%';
303
+            $search_string = '%'.sanitize_text_field($search).'%';
304 304
             $this->where_params['OR*search_conditions'] = [
305 305
                 'Event.EVT_name'                          => ['LIKE', $search_string],
306 306
                 'Event.EVT_desc'                          => ['LIKE', $search_string],
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1124 added lines, -1124 removed lines patch added patch discarded remove patch
@@ -20,1128 +20,1128 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Cart'                                                                                                     => array(
463
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_Front_Controller'                                                                                         => array(
466
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messenger_Collection_Loader'                                                                              => array(
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ),
473
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Message_Resource_Manager'                                                                                 => array(
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ),
481
-            'EE_Message_Factory'                                                                                          => array(
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_messages'                                                                                                 => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Generator'                                                                                       => array(
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ),
493
-            'EE_Messages_Processor'                                                                                       => array(
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Messages_Queue'                                                                                           => array(
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ),
499
-            'EE_Messages_Template_Defaults'                                                                               => array(
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ),
503
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ),
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_Data_Migration_Class_Base'                                                                                => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EE_DMS_Core_4_9_0' => array(
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EE_DMS_Core_4_10_0' => array(
604
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
-            ),
608
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
-                array(),
610
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
-            ),
647
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
-                null,
649
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
-            ),
654
-            'LEGACY_MODELS'                                                                                               => array(
655
-                null,
656
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EE_Module_Request_Router'                                                                                    => array(
659
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
660
-            ),
661
-            'EE_Registration_Processor'                                                                                   => array(
662
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
-                null,
666
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
674
-                null,
675
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
-            ),
682
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
-            ),
686
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
-            ),
698
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
-            ),
701
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
-            ),
705
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
-            ),
708
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
-            ),
715
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
-            ),
718
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
-            ),
725
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
-            ),
728
-            'EE_CPT_Strategy'                                                                                             => array(
729
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
-            ),
732
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
-            ),
735
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
-            ),
742
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
-            ),
746
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
-            ),
749
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
-            ),
759
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
-            ),
762
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
-            ),
765
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
-            ),
769
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
-                null,
771
-                null,
772
-                null,
773
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
-            ),
777
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
-                'EE_Config' => EE_Dependency_Map::load_from_cache
780
-            ),
781
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
-            ),
787
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
-            ),
792
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
-            ),
801
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
-            ),
806
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
-            ),
810
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
-            ),
814
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
-            ),
817
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
-            ),
820
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
-            ),
823
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
-            ),
827
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
-            ),
831
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
-            ),
834
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
835
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
-            ),
837
-            'EE_URL_Validation_Strategy' => array(
838
-                null,
839
-                null,
840
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
-            ),
842
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
-            ),
849
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
-            ),
853
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
-            ),
857
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
-            ),
861
-            'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
-            ),
864
-            'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
-            ],
867
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
-                null,
869
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
-                'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
-            ],
872
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
-                'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
-            ],
876
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
-                'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
-            ],
880
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
-                'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
-            ],
884
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
-                'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
-            ],
888
-        );
889
-    }
890
-
891
-
892
-    /**
893
-     * Registers how core classes are loaded.
894
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
895
-     *        'EE_Request_Handler' => 'load_core'
896
-     *        'EE_Messages_Queue'  => 'load_lib'
897
-     *        'EEH_Debug_Tools'    => 'load_helper'
898
-     * or, if greater control is required, by providing a custom closure. For example:
899
-     *        'Some_Class' => function () {
900
-     *            return new Some_Class();
901
-     *        },
902
-     * This is required for instantiating dependencies
903
-     * where an interface has been type hinted in a class constructor. For example:
904
-     *        'Required_Interface' => function () {
905
-     *            return new A_Class_That_Implements_Required_Interface();
906
-     *        },
907
-     */
908
-    protected function _register_core_class_loaders()
909
-    {
910
-        $this->_class_loaders = array(
911
-            // load_core
912
-            'EE_Dependency_Map'                            => function () {
913
-                return $this;
914
-            },
915
-            'EE_Capabilities'                              => 'load_core',
916
-            'EE_Encryption'                                => 'load_core',
917
-            'EE_Front_Controller'                          => 'load_core',
918
-            'EE_Module_Request_Router'                     => 'load_core',
919
-            'EE_Registry'                                  => 'load_core',
920
-            'EE_Request'                                   => function () {
921
-                return $this->legacy_request;
922
-            },
923
-            'EventEspresso\core\services\request\Request'  => function () {
924
-                return $this->request;
925
-            },
926
-            'EventEspresso\core\services\request\Response' => function () {
927
-                return $this->response;
928
-            },
929
-            'EE_Base'                                      => 'load_core',
930
-            'EE_Request_Handler'                           => 'load_core',
931
-            'EE_Session'                                   => 'load_core',
932
-            'EE_Cron_Tasks'                                => 'load_core',
933
-            'EE_System'                                    => 'load_core',
934
-            'EE_Maintenance_Mode'                          => 'load_core',
935
-            'EE_Register_CPTs'                             => 'load_core',
936
-            'EE_Admin'                                     => 'load_core',
937
-            'EE_CPT_Strategy'                              => 'load_core',
938
-            // load_class
939
-            'EE_Registration_Processor'                    => 'load_class',
940
-            // load_lib
941
-            'EE_Message_Resource_Manager'                  => 'load_lib',
942
-            'EE_Message_Type_Collection'                   => 'load_lib',
943
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
944
-            'EE_Messenger_Collection'                      => 'load_lib',
945
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
946
-            'EE_Messages_Processor'                        => 'load_lib',
947
-            'EE_Message_Repository'                        => 'load_lib',
948
-            'EE_Messages_Queue'                            => 'load_lib',
949
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
950
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
951
-            'EE_Payment_Method_Manager'                    => 'load_lib',
952
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
953
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
954
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
955
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
956
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
957
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
958
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
959
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
960
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
961
-            'EE_Messages_Generator'                        => function () {
962
-                return EE_Registry::instance()->load_lib(
963
-                    'Messages_Generator',
964
-                    array(),
965
-                    false,
966
-                    false
967
-                );
968
-            },
969
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
970
-                return EE_Registry::instance()->load_lib(
971
-                    'Messages_Template_Defaults',
972
-                    $arguments,
973
-                    false,
974
-                    false
975
-                );
976
-            },
977
-            // load_helper
978
-            'EEH_Parse_Shortcodes'                         => function () {
979
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
980
-                    return new EEH_Parse_Shortcodes();
981
-                }
982
-                return null;
983
-            },
984
-            'EE_Template_Config'                           => function () {
985
-                return EE_Config::instance()->template_settings;
986
-            },
987
-            'EE_Currency_Config'                           => function () {
988
-                return EE_Config::instance()->currency;
989
-            },
990
-            'EE_Registration_Config'                       => function () {
991
-                return EE_Config::instance()->registration;
992
-            },
993
-            'EE_Core_Config'                               => function () {
994
-                return EE_Config::instance()->core;
995
-            },
996
-            'EventEspresso\core\services\loaders\Loader'   => function () {
997
-                return LoaderFactory::getLoader();
998
-            },
999
-            'EE_Network_Config'                            => function () {
1000
-                return EE_Network_Config::instance();
1001
-            },
1002
-            'EE_Config'                                    => function () {
1003
-                return EE_Config::instance();
1004
-            },
1005
-            'EventEspresso\core\domain\Domain'             => function () {
1006
-                return DomainFactory::getEventEspressoCoreDomain();
1007
-            },
1008
-            'EE_Admin_Config'                              => function () {
1009
-                return EE_Config::instance()->admin;
1010
-            },
1011
-            'EE_Organization_Config'                       => function () {
1012
-                return EE_Config::instance()->organization;
1013
-            },
1014
-            'EE_Network_Core_Config'                       => function () {
1015
-                return EE_Network_Config::instance()->core;
1016
-            },
1017
-            'EE_Environment_Config'                        => function () {
1018
-                return EE_Config::instance()->environment;
1019
-            },
1020
-        );
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * can be used for supplying alternate names for classes,
1026
-     * or for connecting interface names to instantiable classes
1027
-     */
1028
-    protected function _register_core_aliases()
1029
-    {
1030
-        $aliases = array(
1031
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1032
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1033
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1034
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1035
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1036
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1037
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1038
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1039
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1040
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1041
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1042
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1043
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1044
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1045
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1046
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1047
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1048
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1049
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1050
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1051
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1052
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1053
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1054
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1055
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1056
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1057
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1058
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1059
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1060
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1061
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1062
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1063
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1064
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1065
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1066
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1067
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1068
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1069
-        );
1070
-        foreach ($aliases as $alias => $fqn) {
1071
-            if (is_array($fqn)) {
1072
-                foreach ($fqn as $class => $for_class) {
1073
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1074
-                }
1075
-                continue;
1076
-            }
1077
-            $this->class_cache->addAlias($fqn, $alias);
1078
-        }
1079
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1080
-            $this->class_cache->addAlias(
1081
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1082
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1083
-            );
1084
-        }
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1090
-     * request Primarily used by unit tests.
1091
-     */
1092
-    public function reset()
1093
-    {
1094
-        $this->_register_core_class_loaders();
1095
-        $this->_register_core_dependencies();
1096
-    }
1097
-
1098
-
1099
-    /**
1100
-     * PLZ NOTE: a better name for this method would be is_alias()
1101
-     * because it returns TRUE if the provided fully qualified name IS an alias
1102
-     * WHY?
1103
-     * Because if a class is type hinting for a concretion,
1104
-     * then why would we need to find another class to supply it?
1105
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1106
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1107
-     * Don't go looking for some substitute.
1108
-     * Whereas if a class is type hinting for an interface...
1109
-     * then we need to find an actual class to use.
1110
-     * So the interface IS the alias for some other FQN,
1111
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1112
-     * represents some other class.
1113
-     *
1114
-     * @deprecated 4.9.62.p
1115
-     * @param string $fqn
1116
-     * @param string $for_class
1117
-     * @return bool
1118
-     */
1119
-    public function has_alias($fqn = '', $for_class = '')
1120
-    {
1121
-        return $this->isAlias($fqn, $for_class);
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1127
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1128
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1129
-     *  for example:
1130
-     *      if the following two entries were added to the _aliases array:
1131
-     *          array(
1132
-     *              'interface_alias'           => 'some\namespace\interface'
1133
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1134
-     *          )
1135
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1136
-     *      to load an instance of 'some\namespace\classname'
1137
-     *
1138
-     * @deprecated 4.9.62.p
1139
-     * @param string $alias
1140
-     * @param string $for_class
1141
-     * @return string
1142
-     */
1143
-    public function get_alias($alias = '', $for_class = '')
1144
-    {
1145
-        return $this->getFqnForAlias($alias, $for_class);
1146
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Cart'                                                                                                     => array(
463
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_Front_Controller'                                                                                         => array(
466
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messenger_Collection_Loader'                                                                              => array(
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			),
473
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Message_Resource_Manager'                                                                                 => array(
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			),
481
+			'EE_Message_Factory'                                                                                          => array(
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_messages'                                                                                                 => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Generator'                                                                                       => array(
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			),
493
+			'EE_Messages_Processor'                                                                                       => array(
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Messages_Queue'                                                                                           => array(
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			),
499
+			'EE_Messages_Template_Defaults'                                                                               => array(
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			),
503
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			),
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_Data_Migration_Class_Base'                                                                                => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EE_DMS_Core_4_9_0' => array(
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EE_DMS_Core_4_10_0' => array(
604
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
+			),
608
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
+				array(),
610
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
+			),
647
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
+				null,
649
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
+			),
654
+			'LEGACY_MODELS'                                                                                               => array(
655
+				null,
656
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EE_Module_Request_Router'                                                                                    => array(
659
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
660
+			),
661
+			'EE_Registration_Processor'                                                                                   => array(
662
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
+				null,
666
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
674
+				null,
675
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
+			),
682
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
+			),
686
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
+			),
698
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
+			),
701
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
+			),
705
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
+			),
708
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
+			),
715
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
+			),
718
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
+			),
725
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
+			),
728
+			'EE_CPT_Strategy'                                                                                             => array(
729
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
+			),
732
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
+			),
735
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
+			),
742
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
+			),
746
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
+			),
749
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
+			),
759
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
+			),
762
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
+			),
765
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
+			),
769
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
+				null,
771
+				null,
772
+				null,
773
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
+			),
777
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
+				'EE_Config' => EE_Dependency_Map::load_from_cache
780
+			),
781
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
+			),
787
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
+			),
792
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
+			),
796
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
+			),
801
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
+			),
806
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
+			),
810
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
+			),
814
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
+			),
817
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
+			),
820
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
+			),
823
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
+			),
827
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
+			),
831
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
+			),
834
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
835
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
+			),
837
+			'EE_URL_Validation_Strategy' => array(
838
+				null,
839
+				null,
840
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
+			),
842
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
+			),
849
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
+			),
853
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
+			),
857
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
+			),
861
+			'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
+			),
864
+			'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
+			],
867
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
+				null,
869
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
+				'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
+			],
872
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
+				'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
+			],
876
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
+				'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
+			],
880
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
+				'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
+			],
884
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
+				'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
+			],
888
+		);
889
+	}
890
+
891
+
892
+	/**
893
+	 * Registers how core classes are loaded.
894
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
895
+	 *        'EE_Request_Handler' => 'load_core'
896
+	 *        'EE_Messages_Queue'  => 'load_lib'
897
+	 *        'EEH_Debug_Tools'    => 'load_helper'
898
+	 * or, if greater control is required, by providing a custom closure. For example:
899
+	 *        'Some_Class' => function () {
900
+	 *            return new Some_Class();
901
+	 *        },
902
+	 * This is required for instantiating dependencies
903
+	 * where an interface has been type hinted in a class constructor. For example:
904
+	 *        'Required_Interface' => function () {
905
+	 *            return new A_Class_That_Implements_Required_Interface();
906
+	 *        },
907
+	 */
908
+	protected function _register_core_class_loaders()
909
+	{
910
+		$this->_class_loaders = array(
911
+			// load_core
912
+			'EE_Dependency_Map'                            => function () {
913
+				return $this;
914
+			},
915
+			'EE_Capabilities'                              => 'load_core',
916
+			'EE_Encryption'                                => 'load_core',
917
+			'EE_Front_Controller'                          => 'load_core',
918
+			'EE_Module_Request_Router'                     => 'load_core',
919
+			'EE_Registry'                                  => 'load_core',
920
+			'EE_Request'                                   => function () {
921
+				return $this->legacy_request;
922
+			},
923
+			'EventEspresso\core\services\request\Request'  => function () {
924
+				return $this->request;
925
+			},
926
+			'EventEspresso\core\services\request\Response' => function () {
927
+				return $this->response;
928
+			},
929
+			'EE_Base'                                      => 'load_core',
930
+			'EE_Request_Handler'                           => 'load_core',
931
+			'EE_Session'                                   => 'load_core',
932
+			'EE_Cron_Tasks'                                => 'load_core',
933
+			'EE_System'                                    => 'load_core',
934
+			'EE_Maintenance_Mode'                          => 'load_core',
935
+			'EE_Register_CPTs'                             => 'load_core',
936
+			'EE_Admin'                                     => 'load_core',
937
+			'EE_CPT_Strategy'                              => 'load_core',
938
+			// load_class
939
+			'EE_Registration_Processor'                    => 'load_class',
940
+			// load_lib
941
+			'EE_Message_Resource_Manager'                  => 'load_lib',
942
+			'EE_Message_Type_Collection'                   => 'load_lib',
943
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
944
+			'EE_Messenger_Collection'                      => 'load_lib',
945
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
946
+			'EE_Messages_Processor'                        => 'load_lib',
947
+			'EE_Message_Repository'                        => 'load_lib',
948
+			'EE_Messages_Queue'                            => 'load_lib',
949
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
950
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
951
+			'EE_Payment_Method_Manager'                    => 'load_lib',
952
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
953
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
954
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
955
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
956
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
957
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
958
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
959
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
960
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
961
+			'EE_Messages_Generator'                        => function () {
962
+				return EE_Registry::instance()->load_lib(
963
+					'Messages_Generator',
964
+					array(),
965
+					false,
966
+					false
967
+				);
968
+			},
969
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
970
+				return EE_Registry::instance()->load_lib(
971
+					'Messages_Template_Defaults',
972
+					$arguments,
973
+					false,
974
+					false
975
+				);
976
+			},
977
+			// load_helper
978
+			'EEH_Parse_Shortcodes'                         => function () {
979
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
980
+					return new EEH_Parse_Shortcodes();
981
+				}
982
+				return null;
983
+			},
984
+			'EE_Template_Config'                           => function () {
985
+				return EE_Config::instance()->template_settings;
986
+			},
987
+			'EE_Currency_Config'                           => function () {
988
+				return EE_Config::instance()->currency;
989
+			},
990
+			'EE_Registration_Config'                       => function () {
991
+				return EE_Config::instance()->registration;
992
+			},
993
+			'EE_Core_Config'                               => function () {
994
+				return EE_Config::instance()->core;
995
+			},
996
+			'EventEspresso\core\services\loaders\Loader'   => function () {
997
+				return LoaderFactory::getLoader();
998
+			},
999
+			'EE_Network_Config'                            => function () {
1000
+				return EE_Network_Config::instance();
1001
+			},
1002
+			'EE_Config'                                    => function () {
1003
+				return EE_Config::instance();
1004
+			},
1005
+			'EventEspresso\core\domain\Domain'             => function () {
1006
+				return DomainFactory::getEventEspressoCoreDomain();
1007
+			},
1008
+			'EE_Admin_Config'                              => function () {
1009
+				return EE_Config::instance()->admin;
1010
+			},
1011
+			'EE_Organization_Config'                       => function () {
1012
+				return EE_Config::instance()->organization;
1013
+			},
1014
+			'EE_Network_Core_Config'                       => function () {
1015
+				return EE_Network_Config::instance()->core;
1016
+			},
1017
+			'EE_Environment_Config'                        => function () {
1018
+				return EE_Config::instance()->environment;
1019
+			},
1020
+		);
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * can be used for supplying alternate names for classes,
1026
+	 * or for connecting interface names to instantiable classes
1027
+	 */
1028
+	protected function _register_core_aliases()
1029
+	{
1030
+		$aliases = array(
1031
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1032
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1033
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1034
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1035
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1036
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1037
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1038
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1039
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1040
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1041
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1042
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1043
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1044
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1045
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1046
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1047
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1048
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1049
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1050
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1051
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1052
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1053
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1054
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1055
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1056
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1057
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1058
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1059
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1060
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1061
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1062
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1063
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1064
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1065
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1066
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1067
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1068
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1069
+		);
1070
+		foreach ($aliases as $alias => $fqn) {
1071
+			if (is_array($fqn)) {
1072
+				foreach ($fqn as $class => $for_class) {
1073
+					$this->class_cache->addAlias($class, $alias, $for_class);
1074
+				}
1075
+				continue;
1076
+			}
1077
+			$this->class_cache->addAlias($fqn, $alias);
1078
+		}
1079
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1080
+			$this->class_cache->addAlias(
1081
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1082
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1083
+			);
1084
+		}
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1090
+	 * request Primarily used by unit tests.
1091
+	 */
1092
+	public function reset()
1093
+	{
1094
+		$this->_register_core_class_loaders();
1095
+		$this->_register_core_dependencies();
1096
+	}
1097
+
1098
+
1099
+	/**
1100
+	 * PLZ NOTE: a better name for this method would be is_alias()
1101
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1102
+	 * WHY?
1103
+	 * Because if a class is type hinting for a concretion,
1104
+	 * then why would we need to find another class to supply it?
1105
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1106
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1107
+	 * Don't go looking for some substitute.
1108
+	 * Whereas if a class is type hinting for an interface...
1109
+	 * then we need to find an actual class to use.
1110
+	 * So the interface IS the alias for some other FQN,
1111
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1112
+	 * represents some other class.
1113
+	 *
1114
+	 * @deprecated 4.9.62.p
1115
+	 * @param string $fqn
1116
+	 * @param string $for_class
1117
+	 * @return bool
1118
+	 */
1119
+	public function has_alias($fqn = '', $for_class = '')
1120
+	{
1121
+		return $this->isAlias($fqn, $for_class);
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1127
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1128
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1129
+	 *  for example:
1130
+	 *      if the following two entries were added to the _aliases array:
1131
+	 *          array(
1132
+	 *              'interface_alias'           => 'some\namespace\interface'
1133
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1134
+	 *          )
1135
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1136
+	 *      to load an instance of 'some\namespace\classname'
1137
+	 *
1138
+	 * @deprecated 4.9.62.p
1139
+	 * @param string $alias
1140
+	 * @param string $for_class
1141
+	 * @return string
1142
+	 */
1143
+	public function get_alias($alias = '', $for_class = '')
1144
+	{
1145
+		return $this->getFqnForAlias($alias, $for_class);
1146
+	}
1147 1147
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Indentation   +1464 added lines, -1464 removed lines patch added patch discarded remove patch
@@ -28,492 +28,492 @@  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
-     * a boolean flag to set whether the current route is a cpt route or not.
42
-     *
43
-     * @var bool
44
-     */
45
-    protected $_cpt_route = false;
46
-
47
-
48
-    /**
49
-     * This property allows cpt classes to define multiple routes as cpt routes.
50
-     * //in this array we define what the custom post type for this route is.
51
-     * array(
52
-     * 'route_name' => 'custom_post_type_slug'
53
-     * )
54
-     *
55
-     * @var array
56
-     */
57
-    protected $_cpt_routes = array();
58
-
59
-
60
-    /**
61
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
62
-     * in this format:
63
-     * array(
64
-     * 'post_type_slug' => 'edit_route'
65
-     * )
66
-     *
67
-     * @var array
68
-     */
69
-    protected $_cpt_edit_routes = array();
70
-
71
-
72
-    /**
73
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
-     * _cpt_model_names property should be in the following format: array(
76
-     * 'route_defined_by_action_param' => 'Model_Name')
77
-     *
78
-     * @var array $_cpt_model_names
79
-     */
80
-    protected $_cpt_model_names = array();
81
-
82
-
83
-    /**
84
-     * @var EE_CPT_Base
85
-     */
86
-    protected $_cpt_model_obj = false;
87
-
88
-    /**
89
-     * @var LoaderInterface $loader ;
90
-     */
91
-    protected $loader;
92
-
93
-    /**
94
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
95
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
96
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
97
-     * Registration of containers should be done before load_page_dependencies() is run.
98
-     *
99
-     * @var array()
100
-     */
101
-    protected $_autosave_containers = array();
102
-    protected $_autosave_fields = array();
103
-
104
-    /**
105
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
106
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
107
-     *
108
-     * @var array
109
-     */
110
-    protected $_pagenow_map;
111
-
112
-
113
-    /**
114
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
115
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
116
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
117
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
118
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
119
-     *
120
-     * @access protected
121
-     * @abstract
122
-     * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
123
-     * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
124
-     * @return void
125
-     */
126
-    abstract protected function _insert_update_cpt_item($post_id, $post);
127
-
128
-
129
-    /**
130
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
131
-     *
132
-     * @abstract
133
-     * @access public
134
-     * @param  string $post_id The ID of the cpt that was trashed
135
-     * @return void
136
-     */
137
-    abstract public function trash_cpt_item($post_id);
138
-
139
-
140
-    /**
141
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
142
-     *
143
-     * @param  string $post_id theID of the cpt that was untrashed
144
-     * @return void
145
-     */
146
-    abstract public function restore_cpt_item($post_id);
147
-
148
-
149
-    /**
150
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
151
-     * from the db
152
-     *
153
-     * @param  string $post_id the ID of the cpt that was deleted
154
-     * @return void
155
-     */
156
-    abstract public function delete_cpt_item($post_id);
157
-
158
-
159
-    /**
160
-     * @return LoaderInterface
161
-     * @throws InvalidArgumentException
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     */
165
-    protected function getLoader()
166
-    {
167
-        if (! $this->loader instanceof LoaderInterface) {
168
-            $this->loader = LoaderFactory::getLoader();
169
-        }
170
-        return $this->loader;
171
-    }
172
-
173
-    /**
174
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
175
-     *
176
-     * @access protected
177
-     * @return void
178
-     */
179
-    protected function _before_page_setup()
180
-    {
181
-        $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
182
-        $this->_cpt_routes = array_merge(
183
-            array(
184
-                'create_new' => $this->page_slug,
185
-                'edit'       => $this->page_slug,
186
-                'trash'      => $this->page_slug,
187
-            ),
188
-            $this->_cpt_routes
189
-        );
190
-        // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
191
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
192
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
193
-            : get_post_type_object($page);
194
-        // tweak pagenow for page loading.
195
-        if (! $this->_pagenow_map) {
196
-            $this->_pagenow_map = array(
197
-                'create_new' => 'post-new.php',
198
-                'edit'       => 'post.php',
199
-                'trash'      => 'post.php',
200
-            );
201
-        }
202
-        add_action('current_screen', array($this, 'modify_pagenow'));
203
-        // TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
204
-        // get current page from autosave
205
-        $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
206
-            ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
207
-            : null;
208
-        $this->_current_page = isset($this->_req_data['current_page'])
209
-            ? $this->_req_data['current_page']
210
-            : $current_page;
211
-        // autosave... make sure its only for the correct page
212
-        // if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
213
-        // setup autosave ajax hook
214
-        // add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
215
-        // }
216
-    }
217
-
218
-
219
-    /**
220
-     * Simply ensure that we simulate the correct post route for cpt screens
221
-     *
222
-     * @param WP_Screen $current_screen
223
-     * @return void
224
-     */
225
-    public function modify_pagenow($current_screen)
226
-    {
227
-        global $pagenow, $hook_suffix;
228
-        // possibly reset pagenow.
229
-        if (! empty($this->_req_data['page'])
230
-            && $this->_req_data['page'] == $this->page_slug
231
-            && ! empty($this->_req_data['action'])
232
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
233
-        ) {
234
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
235
-            $hook_suffix = $pagenow;
236
-        }
237
-    }
238
-
239
-
240
-    /**
241
-     * This method is used to register additional autosave containers to the _autosave_containers property.
242
-     *
243
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
244
-     *       automatically register the id for the post metabox as a container.
245
-     * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
246
-     *                    you would send along the id of a metabox container.
247
-     * @return void
248
-     */
249
-    protected function _register_autosave_containers($ids)
250
-    {
251
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
252
-    }
253
-
254
-
255
-    /**
256
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
257
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
258
-     */
259
-    protected function _set_autosave_containers()
260
-    {
261
-        global $wp_meta_boxes;
262
-        $containers = array();
263
-        if (empty($wp_meta_boxes)) {
264
-            return;
265
-        }
266
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
267
-        foreach ($current_metaboxes as $box_context) {
268
-            foreach ($box_context as $box_details) {
269
-                foreach ($box_details as $box) {
270
-                    if (is_array($box['callback'])
271
-                        && (
272
-                            $box['callback'][0] instanceof EE_Admin_Page
273
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
274
-                        )
275
-                    ) {
276
-                        $containers[] = $box['id'];
277
-                    }
278
-                }
279
-            }
280
-        }
281
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
282
-        // add hidden inputs container
283
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
284
-    }
285
-
286
-
287
-    protected function _load_autosave_scripts_styles()
288
-    {
289
-        /*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 );
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
+	 * a boolean flag to set whether the current route is a cpt route or not.
42
+	 *
43
+	 * @var bool
44
+	 */
45
+	protected $_cpt_route = false;
46
+
47
+
48
+	/**
49
+	 * This property allows cpt classes to define multiple routes as cpt routes.
50
+	 * //in this array we define what the custom post type for this route is.
51
+	 * array(
52
+	 * 'route_name' => 'custom_post_type_slug'
53
+	 * )
54
+	 *
55
+	 * @var array
56
+	 */
57
+	protected $_cpt_routes = array();
58
+
59
+
60
+	/**
61
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
62
+	 * in this format:
63
+	 * array(
64
+	 * 'post_type_slug' => 'edit_route'
65
+	 * )
66
+	 *
67
+	 * @var array
68
+	 */
69
+	protected $_cpt_edit_routes = array();
70
+
71
+
72
+	/**
73
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
+	 * _cpt_model_names property should be in the following format: array(
76
+	 * 'route_defined_by_action_param' => 'Model_Name')
77
+	 *
78
+	 * @var array $_cpt_model_names
79
+	 */
80
+	protected $_cpt_model_names = array();
81
+
82
+
83
+	/**
84
+	 * @var EE_CPT_Base
85
+	 */
86
+	protected $_cpt_model_obj = false;
87
+
88
+	/**
89
+	 * @var LoaderInterface $loader ;
90
+	 */
91
+	protected $loader;
92
+
93
+	/**
94
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
95
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
96
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
97
+	 * Registration of containers should be done before load_page_dependencies() is run.
98
+	 *
99
+	 * @var array()
100
+	 */
101
+	protected $_autosave_containers = array();
102
+	protected $_autosave_fields = array();
103
+
104
+	/**
105
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
106
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
107
+	 *
108
+	 * @var array
109
+	 */
110
+	protected $_pagenow_map;
111
+
112
+
113
+	/**
114
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
115
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
116
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
117
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
118
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
119
+	 *
120
+	 * @access protected
121
+	 * @abstract
122
+	 * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
123
+	 * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
124
+	 * @return void
125
+	 */
126
+	abstract protected function _insert_update_cpt_item($post_id, $post);
127
+
128
+
129
+	/**
130
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
131
+	 *
132
+	 * @abstract
133
+	 * @access public
134
+	 * @param  string $post_id The ID of the cpt that was trashed
135
+	 * @return void
136
+	 */
137
+	abstract public function trash_cpt_item($post_id);
138
+
139
+
140
+	/**
141
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
142
+	 *
143
+	 * @param  string $post_id theID of the cpt that was untrashed
144
+	 * @return void
145
+	 */
146
+	abstract public function restore_cpt_item($post_id);
147
+
148
+
149
+	/**
150
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
151
+	 * from the db
152
+	 *
153
+	 * @param  string $post_id the ID of the cpt that was deleted
154
+	 * @return void
155
+	 */
156
+	abstract public function delete_cpt_item($post_id);
157
+
158
+
159
+	/**
160
+	 * @return LoaderInterface
161
+	 * @throws InvalidArgumentException
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 */
165
+	protected function getLoader()
166
+	{
167
+		if (! $this->loader instanceof LoaderInterface) {
168
+			$this->loader = LoaderFactory::getLoader();
169
+		}
170
+		return $this->loader;
171
+	}
172
+
173
+	/**
174
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
175
+	 *
176
+	 * @access protected
177
+	 * @return void
178
+	 */
179
+	protected function _before_page_setup()
180
+	{
181
+		$page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
182
+		$this->_cpt_routes = array_merge(
183
+			array(
184
+				'create_new' => $this->page_slug,
185
+				'edit'       => $this->page_slug,
186
+				'trash'      => $this->page_slug,
187
+			),
188
+			$this->_cpt_routes
189
+		);
190
+		// let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
191
+		$this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
192
+			? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
193
+			: get_post_type_object($page);
194
+		// tweak pagenow for page loading.
195
+		if (! $this->_pagenow_map) {
196
+			$this->_pagenow_map = array(
197
+				'create_new' => 'post-new.php',
198
+				'edit'       => 'post.php',
199
+				'trash'      => 'post.php',
200
+			);
201
+		}
202
+		add_action('current_screen', array($this, 'modify_pagenow'));
203
+		// TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
204
+		// get current page from autosave
205
+		$current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
206
+			? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
207
+			: null;
208
+		$this->_current_page = isset($this->_req_data['current_page'])
209
+			? $this->_req_data['current_page']
210
+			: $current_page;
211
+		// autosave... make sure its only for the correct page
212
+		// if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
213
+		// setup autosave ajax hook
214
+		// add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
215
+		// }
216
+	}
217
+
218
+
219
+	/**
220
+	 * Simply ensure that we simulate the correct post route for cpt screens
221
+	 *
222
+	 * @param WP_Screen $current_screen
223
+	 * @return void
224
+	 */
225
+	public function modify_pagenow($current_screen)
226
+	{
227
+		global $pagenow, $hook_suffix;
228
+		// possibly reset pagenow.
229
+		if (! empty($this->_req_data['page'])
230
+			&& $this->_req_data['page'] == $this->page_slug
231
+			&& ! empty($this->_req_data['action'])
232
+			&& isset($this->_pagenow_map[ $this->_req_data['action'] ])
233
+		) {
234
+			$pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
235
+			$hook_suffix = $pagenow;
236
+		}
237
+	}
238
+
239
+
240
+	/**
241
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
242
+	 *
243
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
244
+	 *       automatically register the id for the post metabox as a container.
245
+	 * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
246
+	 *                    you would send along the id of a metabox container.
247
+	 * @return void
248
+	 */
249
+	protected function _register_autosave_containers($ids)
250
+	{
251
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
252
+	}
253
+
254
+
255
+	/**
256
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
257
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
258
+	 */
259
+	protected function _set_autosave_containers()
260
+	{
261
+		global $wp_meta_boxes;
262
+		$containers = array();
263
+		if (empty($wp_meta_boxes)) {
264
+			return;
265
+		}
266
+		$current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
267
+		foreach ($current_metaboxes as $box_context) {
268
+			foreach ($box_context as $box_details) {
269
+				foreach ($box_details as $box) {
270
+					if (is_array($box['callback'])
271
+						&& (
272
+							$box['callback'][0] instanceof EE_Admin_Page
273
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
274
+						)
275
+					) {
276
+						$containers[] = $box['id'];
277
+					}
278
+				}
279
+			}
280
+		}
281
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
282
+		// add hidden inputs container
283
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
284
+	}
285
+
286
+
287
+	protected function _load_autosave_scripts_styles()
288
+	{
289
+		/*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 );
290 290
         wp_enqueue_script('cpt-autosave');/**/ // todo re-enable when we start doing autosave again in 4.2
291 291
 
292
-        // filter _autosave_containers
293
-        $containers = apply_filters(
294
-            'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
295
-            $this->_autosave_containers,
296
-            $this
297
-        );
298
-        $containers = apply_filters(
299
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
300
-            $containers,
301
-            $this
302
-        );
303
-
304
-        wp_localize_script(
305
-            'event_editor_js',
306
-            'EE_AUTOSAVE_IDS',
307
-            $containers
308
-        ); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
309
-
310
-        $unsaved_data_msg = array(
311
-            'eventmsg'     => sprintf(
312
-                __(
313
-                    "The changes you made to this %s will be lost if you navigate away from this page.",
314
-                    'event_espresso'
315
-                ),
316
-                $this->_cpt_object->labels->singular_name
317
-            ),
318
-            'inputChanged' => 0,
319
-        );
320
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
321
-    }
322
-
323
-
324
-    public function load_page_dependencies()
325
-    {
326
-        try {
327
-            $this->_load_page_dependencies();
328
-        } catch (EE_Error $e) {
329
-            $e->get_error();
330
-        }
331
-    }
332
-
333
-
334
-    /**
335
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
336
-     *
337
-     * @access protected
338
-     * @return void
339
-     */
340
-    protected function _load_page_dependencies()
341
-    {
342
-        // we only add stuff if this is a cpt_route!
343
-        if (! $this->_cpt_route) {
344
-            parent::_load_page_dependencies();
345
-            return;
346
-        }
347
-        // now let's do some automatic filters into the wp_system
348
-        // and we'll check to make sure the CHILD class
349
-        // automatically has the required methods in place.
350
-        // the following filters are for setting all the redirects
351
-        // on DEFAULT WP custom post type actions
352
-        // let's add a hidden input to the post-edit form
353
-        // so we know when we have to trigger our custom redirects!
354
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
355
-        add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
356
-        // inject our Admin page nav tabs...
357
-        // let's make sure the nav tabs are set if they aren't already
358
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
359
-        add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
360
-        // modify the post_updated messages array
361
-        add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
362
-        // add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
363
-        // cpts use the same format for shortlinks as posts!
364
-        add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
365
-        // This basically allows us to change the title of the "publish" metabox area
366
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
367
-        if (! empty($this->_labels['publishbox'])) {
368
-            $box_label = is_array($this->_labels['publishbox'])
369
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
370
-                ? $this->_labels['publishbox'][ $this->_req_action ]
371
-                : $this->_labels['publishbox'];
372
-            add_meta_box(
373
-                'submitdiv',
374
-                $box_label,
375
-                'post_submit_meta_box',
376
-                $this->_cpt_routes[ $this->_req_action ],
377
-                'side',
378
-                'core'
379
-            );
380
-        }
381
-        // let's add page_templates metabox if this cpt added support for it.
382
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
383
-            add_meta_box(
384
-                'page_templates',
385
-                __('Page Template', 'event_espresso'),
386
-                array($this, 'page_template_meta_box'),
387
-                $this->_cpt_routes[ $this->_req_action ],
388
-                'side',
389
-                'default'
390
-            );
391
-        }
392
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
393
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
394
-            add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
395
-        }
396
-        // add preview button
397
-        add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
398
-        // insert our own post_stati dropdown
399
-        add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
400
-        // This allows adding additional information to the publish post submitbox on the wp post edit form
401
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
402
-            add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
403
-        }
404
-        // This allows for adding additional stuff after the title field on the wp post edit form.
405
-        // This is also before the wp_editor for post description field.
406
-        if (method_exists($this, 'edit_form_after_title')) {
407
-            add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
408
-        }
409
-        /**
410
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
411
-         */
412
-        add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
413
-        parent::_load_page_dependencies();
414
-        // notice we are ALSO going to load the pagenow hook set for this route
415
-        // (see _before_page_setup for the reset of the pagenow global ).
416
-        // This is for any plugins that are doing things properly
417
-        // and hooking into the load page hook for core wp cpt routes.
418
-        global $pagenow;
419
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
420
-        do_action('load-' . $pagenow);
421
-        add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
422
-        // we route REALLY early.
423
-        try {
424
-            $this->_route_admin_request();
425
-        } catch (EE_Error $e) {
426
-            $e->get_error();
427
-        }
428
-    }
429
-
430
-
431
-    /**
432
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
433
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
434
-     * route instead.
435
-     *
436
-     * @param string $good_protocol_url The escaped url.
437
-     * @param string $original_url      The original url.
438
-     * @param string $_context          The context sent to the esc_url method.
439
-     * @return string possibly a new url for our route.
440
-     */
441
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
442
-    {
443
-        $routes_to_match = array(
444
-            0 => array(
445
-                'edit.php?post_type=espresso_attendees',
446
-                'admin.php?page=espresso_registrations&action=contact_list',
447
-            ),
448
-            1 => array(
449
-                'edit.php?post_type=' . $this->_cpt_object->name,
450
-                'admin.php?page=' . $this->_cpt_object->name,
451
-            ),
452
-        );
453
-        foreach ($routes_to_match as $route_matches) {
454
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
455
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
456
-            }
457
-        }
458
-        return $good_protocol_url;
459
-    }
460
-
461
-
462
-    /**
463
-     * Determine whether the current cpt supports page templates or not.
464
-     *
465
-     * @since %VER%
466
-     * @param string $cpt_name The cpt slug we're checking on.
467
-     * @return bool True supported, false not.
468
-     * @throws InvalidArgumentException
469
-     * @throws InvalidDataTypeException
470
-     * @throws InvalidInterfaceException
471
-     */
472
-    private function _supports_page_templates($cpt_name)
473
-    {
474
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
475
-        $custom_post_types = $this->getLoader()->getShared(
476
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
477
-        );
478
-        $cpt_args = $custom_post_types->getDefinitions();
479
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
480
-        $cpt_has_support = ! empty($cpt_args['page_templates']);
481
-
482
-        // if the installed version of WP is > 4.7 we do some additional checks.
483
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
484
-            $post_templates = wp_get_theme()->get_post_templates();
485
-            // if there are $post_templates for this cpt, then we return false for this method because
486
-            // that means we aren't going to load our page template manager and leave that up to the native
487
-            // cpt template manager.
488
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
489
-        }
490
-
491
-        return $cpt_has_support;
492
-    }
493
-
494
-
495
-    /**
496
-     * Callback for the page_templates metabox selector.
497
-     *
498
-     * @since %VER%
499
-     * @return void
500
-     */
501
-    public function page_template_meta_box()
502
-    {
503
-        global $post;
504
-        $template = '';
505
-
506
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
507
-            $page_template_count = count(get_page_templates());
508
-        } else {
509
-            $page_template_count = count(get_page_templates($post));
510
-        };
511
-
512
-        if ($page_template_count) {
513
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
514
-            $template = ! empty($page_template) ? $page_template : '';
515
-        }
516
-        ?>
292
+		// filter _autosave_containers
293
+		$containers = apply_filters(
294
+			'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
295
+			$this->_autosave_containers,
296
+			$this
297
+		);
298
+		$containers = apply_filters(
299
+			'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
300
+			$containers,
301
+			$this
302
+		);
303
+
304
+		wp_localize_script(
305
+			'event_editor_js',
306
+			'EE_AUTOSAVE_IDS',
307
+			$containers
308
+		); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
309
+
310
+		$unsaved_data_msg = array(
311
+			'eventmsg'     => sprintf(
312
+				__(
313
+					"The changes you made to this %s will be lost if you navigate away from this page.",
314
+					'event_espresso'
315
+				),
316
+				$this->_cpt_object->labels->singular_name
317
+			),
318
+			'inputChanged' => 0,
319
+		);
320
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
321
+	}
322
+
323
+
324
+	public function load_page_dependencies()
325
+	{
326
+		try {
327
+			$this->_load_page_dependencies();
328
+		} catch (EE_Error $e) {
329
+			$e->get_error();
330
+		}
331
+	}
332
+
333
+
334
+	/**
335
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
336
+	 *
337
+	 * @access protected
338
+	 * @return void
339
+	 */
340
+	protected function _load_page_dependencies()
341
+	{
342
+		// we only add stuff if this is a cpt_route!
343
+		if (! $this->_cpt_route) {
344
+			parent::_load_page_dependencies();
345
+			return;
346
+		}
347
+		// now let's do some automatic filters into the wp_system
348
+		// and we'll check to make sure the CHILD class
349
+		// automatically has the required methods in place.
350
+		// the following filters are for setting all the redirects
351
+		// on DEFAULT WP custom post type actions
352
+		// let's add a hidden input to the post-edit form
353
+		// so we know when we have to trigger our custom redirects!
354
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
355
+		add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
356
+		// inject our Admin page nav tabs...
357
+		// let's make sure the nav tabs are set if they aren't already
358
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
359
+		add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
360
+		// modify the post_updated messages array
361
+		add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
362
+		// add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
363
+		// cpts use the same format for shortlinks as posts!
364
+		add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
365
+		// This basically allows us to change the title of the "publish" metabox area
366
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
367
+		if (! empty($this->_labels['publishbox'])) {
368
+			$box_label = is_array($this->_labels['publishbox'])
369
+						 && isset($this->_labels['publishbox'][ $this->_req_action ])
370
+				? $this->_labels['publishbox'][ $this->_req_action ]
371
+				: $this->_labels['publishbox'];
372
+			add_meta_box(
373
+				'submitdiv',
374
+				$box_label,
375
+				'post_submit_meta_box',
376
+				$this->_cpt_routes[ $this->_req_action ],
377
+				'side',
378
+				'core'
379
+			);
380
+		}
381
+		// let's add page_templates metabox if this cpt added support for it.
382
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
383
+			add_meta_box(
384
+				'page_templates',
385
+				__('Page Template', 'event_espresso'),
386
+				array($this, 'page_template_meta_box'),
387
+				$this->_cpt_routes[ $this->_req_action ],
388
+				'side',
389
+				'default'
390
+			);
391
+		}
392
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
393
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
394
+			add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
395
+		}
396
+		// add preview button
397
+		add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
398
+		// insert our own post_stati dropdown
399
+		add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
400
+		// This allows adding additional information to the publish post submitbox on the wp post edit form
401
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
402
+			add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
403
+		}
404
+		// This allows for adding additional stuff after the title field on the wp post edit form.
405
+		// This is also before the wp_editor for post description field.
406
+		if (method_exists($this, 'edit_form_after_title')) {
407
+			add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
408
+		}
409
+		/**
410
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
411
+		 */
412
+		add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
413
+		parent::_load_page_dependencies();
414
+		// notice we are ALSO going to load the pagenow hook set for this route
415
+		// (see _before_page_setup for the reset of the pagenow global ).
416
+		// This is for any plugins that are doing things properly
417
+		// and hooking into the load page hook for core wp cpt routes.
418
+		global $pagenow;
419
+		add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
420
+		do_action('load-' . $pagenow);
421
+		add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
422
+		// we route REALLY early.
423
+		try {
424
+			$this->_route_admin_request();
425
+		} catch (EE_Error $e) {
426
+			$e->get_error();
427
+		}
428
+	}
429
+
430
+
431
+	/**
432
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
433
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
434
+	 * route instead.
435
+	 *
436
+	 * @param string $good_protocol_url The escaped url.
437
+	 * @param string $original_url      The original url.
438
+	 * @param string $_context          The context sent to the esc_url method.
439
+	 * @return string possibly a new url for our route.
440
+	 */
441
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
442
+	{
443
+		$routes_to_match = array(
444
+			0 => array(
445
+				'edit.php?post_type=espresso_attendees',
446
+				'admin.php?page=espresso_registrations&action=contact_list',
447
+			),
448
+			1 => array(
449
+				'edit.php?post_type=' . $this->_cpt_object->name,
450
+				'admin.php?page=' . $this->_cpt_object->name,
451
+			),
452
+		);
453
+		foreach ($routes_to_match as $route_matches) {
454
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
455
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
456
+			}
457
+		}
458
+		return $good_protocol_url;
459
+	}
460
+
461
+
462
+	/**
463
+	 * Determine whether the current cpt supports page templates or not.
464
+	 *
465
+	 * @since %VER%
466
+	 * @param string $cpt_name The cpt slug we're checking on.
467
+	 * @return bool True supported, false not.
468
+	 * @throws InvalidArgumentException
469
+	 * @throws InvalidDataTypeException
470
+	 * @throws InvalidInterfaceException
471
+	 */
472
+	private function _supports_page_templates($cpt_name)
473
+	{
474
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
475
+		$custom_post_types = $this->getLoader()->getShared(
476
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
477
+		);
478
+		$cpt_args = $custom_post_types->getDefinitions();
479
+		$cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
480
+		$cpt_has_support = ! empty($cpt_args['page_templates']);
481
+
482
+		// if the installed version of WP is > 4.7 we do some additional checks.
483
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
484
+			$post_templates = wp_get_theme()->get_post_templates();
485
+			// if there are $post_templates for this cpt, then we return false for this method because
486
+			// that means we aren't going to load our page template manager and leave that up to the native
487
+			// cpt template manager.
488
+			$cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
489
+		}
490
+
491
+		return $cpt_has_support;
492
+	}
493
+
494
+
495
+	/**
496
+	 * Callback for the page_templates metabox selector.
497
+	 *
498
+	 * @since %VER%
499
+	 * @return void
500
+	 */
501
+	public function page_template_meta_box()
502
+	{
503
+		global $post;
504
+		$template = '';
505
+
506
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
507
+			$page_template_count = count(get_page_templates());
508
+		} else {
509
+			$page_template_count = count(get_page_templates($post));
510
+		};
511
+
512
+		if ($page_template_count) {
513
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
514
+			$template = ! empty($page_template) ? $page_template : '';
515
+		}
516
+		?>
517 517
         <p><strong><?php _e('Template', 'event_espresso') ?></strong></p>
518 518
         <label class="screen-reader-text" for="page_template"><?php _e('Page Template', 'event_espresso') ?></label><select
519 519
         name="page_template" id="page_template">
@@ -521,468 +521,468 @@  discard block
 block discarded – undo
521 521
         <?php page_template_dropdown($template); ?>
522 522
     </select>
523 523
         <?php
524
-    }
525
-
526
-
527
-    /**
528
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
529
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
530
-     *
531
-     * @param  string $return    the current html
532
-     * @param  int    $id        the post id for the page
533
-     * @param  string $new_title What the title is
534
-     * @param  string $new_slug  what the slug is
535
-     * @return string            The new html string for the permalink area
536
-     */
537
-    public function preview_button_html($return, $id, $new_title, $new_slug)
538
-    {
539
-        $post = get_post($id);
540
-        if ('publish' !== get_post_status($post)) {
541
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
542
-                       . get_preview_post_link($id)
543
-                       . '" class="button button-small">'
544
-                       . __('Preview', 'event_espresso')
545
-                       . '</a></span>'
546
-                       . "\n";
547
-        }
548
-        return $return;
549
-    }
550
-
551
-
552
-    /**
553
-     * add our custom post stati dropdown on the wp post page for this cpt
554
-     *
555
-     * @return void
556
-     */
557
-    public function custom_post_stati_dropdown()
558
-    {
559
-
560
-        $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
561
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
-            ? $statuses[ $this->_cpt_model_obj->status() ]
563
-            : '';
564
-        $template_args = array(
565
-            'cur_status'            => $this->_cpt_model_obj->status(),
566
-            'statuses'              => $statuses,
567
-            'cur_status_label'      => $cur_status_label,
568
-            'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
569
-        );
570
-        // we'll add a trash post status (WP doesn't add one for some reason)
571
-        if ($this->_cpt_model_obj->status() === 'trash') {
572
-            $template_args['cur_status_label'] = __('Trashed', 'event_espresso');
573
-            $statuses['trash'] = __('Trashed', 'event_espresso');
574
-            $template_args['statuses'] = $statuses;
575
-        }
576
-
577
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
578
-        EEH_Template::display_template($template, $template_args);
579
-    }
580
-
581
-
582
-    public function setup_autosave_hooks()
583
-    {
584
-        $this->_set_autosave_containers();
585
-        $this->_load_autosave_scripts_styles();
586
-    }
587
-
588
-
589
-    /**
590
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
591
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
592
-     * for the nonce in here, but then this method looks for two things:
593
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
594
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
595
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
596
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
597
-     * template args.
598
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
599
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
600
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
601
-     *    $this->_template_args['data']['items'] = array(
602
-     *        'event-datetime-ids' => '1,2,3';
603
-     *    );
604
-     *    Keep in mind the following things:
605
-     *    - "where" index is for the input with the id as that string.
606
-     *    - "what" index is what will be used for the value of that input.
607
-     *
608
-     * @return void
609
-     */
610
-    public function do_extra_autosave_stuff()
611
-    {
612
-        // next let's check for the autosave nonce (we'll use _verify_nonce )
613
-        $nonce = isset($this->_req_data['autosavenonce'])
614
-            ? $this->_req_data['autosavenonce']
615
-            : null;
616
-        $this->_verify_nonce($nonce, 'autosave');
617
-        // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
618
-        if (! defined('DOING_AUTOSAVE')) {
619
-            define('DOING_AUTOSAVE', true);
620
-        }
621
-        // if we made it here then the nonce checked out.  Let's run our methods and actions
622
-        $autosave = "_ee_autosave_{$this->_current_view}";
623
-        if (method_exists($this, $autosave)) {
624
-            $this->$autosave();
625
-        } else {
626
-            $this->_template_args['success'] = true;
627
-        }
628
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
629
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
630
-        // now let's return json
631
-        $this->_return_json();
632
-    }
633
-
634
-
635
-    /**
636
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
637
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
638
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
639
-     *
640
-     * @access protected
641
-     * @throws EE_Error
642
-     * @return void
643
-     */
644
-    protected function _extend_page_config_for_cpt()
645
-    {
646
-        // before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
647
-        if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
648
-            return;
649
-        }
650
-        // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
651
-        if (! empty($this->_cpt_object)) {
652
-            $this->_page_routes = array_merge(
653
-                array(
654
-                    'create_new' => '_create_new_cpt_item',
655
-                    'edit'       => '_edit_cpt_item',
656
-                ),
657
-                $this->_page_routes
658
-            );
659
-            $this->_page_config = array_merge(
660
-                array(
661
-                    'create_new' => array(
662
-                        'nav'           => array(
663
-                            'label' => $this->_cpt_object->labels->add_new_item,
664
-                            'order' => 5,
665
-                        ),
666
-                        'require_nonce' => false,
667
-                    ),
668
-                    'edit'       => array(
669
-                        'nav'           => array(
670
-                            'label'      => $this->_cpt_object->labels->edit_item,
671
-                            'order'      => 5,
672
-                            'persistent' => false,
673
-                            'url'        => '',
674
-                        ),
675
-                        'require_nonce' => false,
676
-                    ),
677
-                ),
678
-                $this->_page_config
679
-            );
680
-        }
681
-        // load the next section only if this is a matching cpt route as set in the cpt routes array.
682
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
683
-            return;
684
-        }
685
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
686
-        // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
687
-        if (empty($this->_cpt_object)) {
688
-            $msg = sprintf(
689
-                __(
690
-                    '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).',
691
-                    'event_espresso'
692
-                ),
693
-                $this->page_slug,
694
-                $this->_req_action,
695
-                get_class($this)
696
-            );
697
-            throw new EE_Error($msg);
698
-        }
699
-        if ($this->_cpt_route) {
700
-            $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
701
-            $this->_set_model_object($id);
702
-        }
703
-    }
704
-
705
-
706
-    /**
707
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
708
-     *
709
-     * @access protected
710
-     * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
711
-     * @param bool   $ignore_route_check
712
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
713
-     * @throws EE_Error
714
-     * @throws InvalidArgumentException
715
-     * @throws InvalidDataTypeException
716
-     * @throws InvalidInterfaceException
717
-     * @throws ReflectionException
718
-     */
719
-    protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
720
-    {
721
-        $model = null;
722
-        if (empty($this->_cpt_model_names)
723
-            || (
724
-                ! $ignore_route_check
725
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
726
-            ) || (
727
-                $this->_cpt_model_obj instanceof EE_CPT_Base
728
-                && $this->_cpt_model_obj->ID() === $id
729
-            )
730
-        ) {
731
-            // 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.
732
-            return;
733
-        }
734
-        // if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
735
-        if ($ignore_route_check) {
736
-            $post_type = get_post_type($id);
737
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
738
-            $custom_post_types = $this->getLoader()->getShared(
739
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
740
-            );
741
-            $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
742
-            if (isset($model_names[ $post_type ])) {
743
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
744
-            }
745
-        } else {
746
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
747
-        }
748
-        if ($model instanceof EEM_Base) {
749
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
750
-        }
751
-        do_action(
752
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
753
-            $this->_cpt_model_obj,
754
-            $req_type
755
-        );
756
-    }
757
-
758
-
759
-    /**
760
-     * admin_init_global
761
-     * This runs all the code that we want executed within the WP admin_init hook.
762
-     * This method executes for ALL EE Admin pages.
763
-     *
764
-     * @access public
765
-     * @return void
766
-     */
767
-    public function admin_init_global()
768
-    {
769
-        $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
770
-        // its possible this is a new save so let's catch that instead
771
-        $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
772
-        $post_type = $post ? $post->post_type : false;
773
-        $current_route = isset($this->_req_data['current_route'])
774
-            ? $this->_req_data['current_route']
775
-            : 'shouldneverwork';
776
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
777
-            ? $this->_cpt_routes[ $current_route ]
778
-            : '';
779
-        add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
780
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
781
-        if ($post_type === $route_to_check) {
782
-            add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
783
-        }
784
-        // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
785
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
786
-        if (! empty($revision)) {
787
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
788
-            // doing a restore?
789
-            if (! empty($action) && $action === 'restore') {
790
-                // get post for revision
791
-                $rev_post = get_post($revision);
792
-                $rev_parent = get_post($rev_post->post_parent);
793
-                // only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
794
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
795
-                    add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
796
-                    // restores of revisions
797
-                    add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
798
-                }
799
-            }
800
-        }
801
-        // 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!
802
-        if ($post_type && $post_type === $route_to_check) {
803
-            // $post_id, $post
804
-            add_action('save_post', array($this, 'insert_update'), 10, 3);
805
-            // $post_id
806
-            add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
807
-            add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
808
-            add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
809
-            add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
810
-        }
811
-    }
812
-
813
-
814
-    /**
815
-     * Callback for the WordPress trashed_post hook.
816
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
817
-     *
818
-     * @param int $post_id
819
-     * @throws \EE_Error
820
-     */
821
-    public function before_trash_cpt_item($post_id)
822
-    {
823
-        $this->_set_model_object($post_id, true, 'trash');
824
-        // if our cpt object isn't existent then get out immediately.
825
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826
-            return;
827
-        }
828
-        $this->trash_cpt_item($post_id);
829
-    }
830
-
831
-
832
-    /**
833
-     * Callback for the WordPress untrashed_post hook.
834
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
835
-     *
836
-     * @param $post_id
837
-     * @throws \EE_Error
838
-     */
839
-    public function before_restore_cpt_item($post_id)
840
-    {
841
-        $this->_set_model_object($post_id, true, 'restore');
842
-        // if our cpt object isn't existent then get out immediately.
843
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
844
-            return;
845
-        }
846
-        $this->restore_cpt_item($post_id);
847
-    }
848
-
849
-
850
-    /**
851
-     * Callback for the WordPress after_delete_post hook.
852
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
853
-     *
854
-     * @param $post_id
855
-     * @throws \EE_Error
856
-     */
857
-    public function before_delete_cpt_item($post_id)
858
-    {
859
-        $this->_set_model_object($post_id, true, 'delete');
860
-        // if our cpt object isn't existent then get out immediately.
861
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862
-            return;
863
-        }
864
-        $this->delete_cpt_item($post_id);
865
-    }
866
-
867
-
868
-    /**
869
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
870
-     * accordingly.
871
-     *
872
-     * @access public
873
-     * @throws EE_Error
874
-     * @return void
875
-     */
876
-    public function verify_cpt_object()
877
-    {
878
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879
-        // verify event object
880
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881
-            throw new EE_Error(
882
-                sprintf(
883
-                    __(
884
-                        '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',
885
-                        'event_espresso'
886
-                    ),
887
-                    $label
888
-                )
889
-            );
890
-        }
891
-        // if auto-draft then throw an error
892
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
893
-            EE_Error::overwrite_errors();
894
-            EE_Error::add_error(
895
-                sprintf(
896
-                    __(
897
-                        '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.',
898
-                        'event_espresso'
899
-                    ),
900
-                    $label
901
-                ),
902
-                __FILE__,
903
-                __FUNCTION__,
904
-                __LINE__
905
-            );
906
-        }
907
-    }
908
-
909
-
910
-    /**
911
-     * admin_footer_scripts_global
912
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
913
-     * will apply on ALL EE_Admin pages.
914
-     *
915
-     * @access public
916
-     * @return void
917
-     */
918
-    public function admin_footer_scripts_global()
919
-    {
920
-        $this->_add_admin_page_ajax_loading_img();
921
-        $this->_add_admin_page_overlay();
922
-    }
923
-
924
-
925
-    /**
926
-     * add in any global scripts for cpt routes
927
-     *
928
-     * @return void
929
-     */
930
-    public function load_global_scripts_styles()
931
-    {
932
-        parent::load_global_scripts_styles();
933
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
934
-            // setup custom post status object for localize script but only if we've got a cpt object
935
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
936
-            if (! empty($statuses)) {
937
-                // get ALL statuses!
938
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
939
-                // setup object
940
-                $ee_cpt_statuses = array();
941
-                foreach ($statuses as $status => $label) {
942
-                    $ee_cpt_statuses[ $status ] = array(
943
-                        'label'      => $label,
944
-                        'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
945
-                    );
946
-                }
947
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
948
-            }
949
-        }
950
-    }
951
-
952
-
953
-    /**
954
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
955
-     * insert/updates
956
-     *
957
-     * @param  int     $post_id ID of post being updated
958
-     * @param  WP_Post $post    Post object from WP
959
-     * @param  bool    $update  Whether this is an update or a new save.
960
-     * @return void
961
-     * @throws \EE_Error
962
-     */
963
-    public function insert_update($post_id, $post, $update)
964
-    {
965
-        // make sure that if this is a revision OR trash action that we don't do any updates!
966
-        if (isset($this->_req_data['action'])
967
-            && (
968
-                $this->_req_data['action'] === 'restore'
969
-                || $this->_req_data['action'] === 'trash'
970
-            )
971
-        ) {
972
-            return;
973
-        }
974
-        $this->_set_model_object($post_id, true, 'insert_update');
975
-        // if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
976
-        if ($update
977
-            && (
978
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
979
-                || $this->_cpt_model_obj->ID() !== $post_id
980
-            )
981
-        ) {
982
-            return;
983
-        }
984
-        // check for autosave and update our req_data property accordingly.
985
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
524
+	}
525
+
526
+
527
+	/**
528
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
529
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
530
+	 *
531
+	 * @param  string $return    the current html
532
+	 * @param  int    $id        the post id for the page
533
+	 * @param  string $new_title What the title is
534
+	 * @param  string $new_slug  what the slug is
535
+	 * @return string            The new html string for the permalink area
536
+	 */
537
+	public function preview_button_html($return, $id, $new_title, $new_slug)
538
+	{
539
+		$post = get_post($id);
540
+		if ('publish' !== get_post_status($post)) {
541
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
542
+					   . get_preview_post_link($id)
543
+					   . '" class="button button-small">'
544
+					   . __('Preview', 'event_espresso')
545
+					   . '</a></span>'
546
+					   . "\n";
547
+		}
548
+		return $return;
549
+	}
550
+
551
+
552
+	/**
553
+	 * add our custom post stati dropdown on the wp post page for this cpt
554
+	 *
555
+	 * @return void
556
+	 */
557
+	public function custom_post_stati_dropdown()
558
+	{
559
+
560
+		$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
561
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
+			? $statuses[ $this->_cpt_model_obj->status() ]
563
+			: '';
564
+		$template_args = array(
565
+			'cur_status'            => $this->_cpt_model_obj->status(),
566
+			'statuses'              => $statuses,
567
+			'cur_status_label'      => $cur_status_label,
568
+			'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
569
+		);
570
+		// we'll add a trash post status (WP doesn't add one for some reason)
571
+		if ($this->_cpt_model_obj->status() === 'trash') {
572
+			$template_args['cur_status_label'] = __('Trashed', 'event_espresso');
573
+			$statuses['trash'] = __('Trashed', 'event_espresso');
574
+			$template_args['statuses'] = $statuses;
575
+		}
576
+
577
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
578
+		EEH_Template::display_template($template, $template_args);
579
+	}
580
+
581
+
582
+	public function setup_autosave_hooks()
583
+	{
584
+		$this->_set_autosave_containers();
585
+		$this->_load_autosave_scripts_styles();
586
+	}
587
+
588
+
589
+	/**
590
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
591
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
592
+	 * for the nonce in here, but then this method looks for two things:
593
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
594
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
595
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
596
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
597
+	 * template args.
598
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
599
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
600
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
601
+	 *    $this->_template_args['data']['items'] = array(
602
+	 *        'event-datetime-ids' => '1,2,3';
603
+	 *    );
604
+	 *    Keep in mind the following things:
605
+	 *    - "where" index is for the input with the id as that string.
606
+	 *    - "what" index is what will be used for the value of that input.
607
+	 *
608
+	 * @return void
609
+	 */
610
+	public function do_extra_autosave_stuff()
611
+	{
612
+		// next let's check for the autosave nonce (we'll use _verify_nonce )
613
+		$nonce = isset($this->_req_data['autosavenonce'])
614
+			? $this->_req_data['autosavenonce']
615
+			: null;
616
+		$this->_verify_nonce($nonce, 'autosave');
617
+		// make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
618
+		if (! defined('DOING_AUTOSAVE')) {
619
+			define('DOING_AUTOSAVE', true);
620
+		}
621
+		// if we made it here then the nonce checked out.  Let's run our methods and actions
622
+		$autosave = "_ee_autosave_{$this->_current_view}";
623
+		if (method_exists($this, $autosave)) {
624
+			$this->$autosave();
625
+		} else {
626
+			$this->_template_args['success'] = true;
627
+		}
628
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
629
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
630
+		// now let's return json
631
+		$this->_return_json();
632
+	}
633
+
634
+
635
+	/**
636
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
637
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
638
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
639
+	 *
640
+	 * @access protected
641
+	 * @throws EE_Error
642
+	 * @return void
643
+	 */
644
+	protected function _extend_page_config_for_cpt()
645
+	{
646
+		// before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
647
+		if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
648
+			return;
649
+		}
650
+		// set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
651
+		if (! empty($this->_cpt_object)) {
652
+			$this->_page_routes = array_merge(
653
+				array(
654
+					'create_new' => '_create_new_cpt_item',
655
+					'edit'       => '_edit_cpt_item',
656
+				),
657
+				$this->_page_routes
658
+			);
659
+			$this->_page_config = array_merge(
660
+				array(
661
+					'create_new' => array(
662
+						'nav'           => array(
663
+							'label' => $this->_cpt_object->labels->add_new_item,
664
+							'order' => 5,
665
+						),
666
+						'require_nonce' => false,
667
+					),
668
+					'edit'       => array(
669
+						'nav'           => array(
670
+							'label'      => $this->_cpt_object->labels->edit_item,
671
+							'order'      => 5,
672
+							'persistent' => false,
673
+							'url'        => '',
674
+						),
675
+						'require_nonce' => false,
676
+					),
677
+				),
678
+				$this->_page_config
679
+			);
680
+		}
681
+		// load the next section only if this is a matching cpt route as set in the cpt routes array.
682
+		if (! isset($this->_cpt_routes[ $this->_req_action ])) {
683
+			return;
684
+		}
685
+		$this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
686
+		// add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
687
+		if (empty($this->_cpt_object)) {
688
+			$msg = sprintf(
689
+				__(
690
+					'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).',
691
+					'event_espresso'
692
+				),
693
+				$this->page_slug,
694
+				$this->_req_action,
695
+				get_class($this)
696
+			);
697
+			throw new EE_Error($msg);
698
+		}
699
+		if ($this->_cpt_route) {
700
+			$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
701
+			$this->_set_model_object($id);
702
+		}
703
+	}
704
+
705
+
706
+	/**
707
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
708
+	 *
709
+	 * @access protected
710
+	 * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
711
+	 * @param bool   $ignore_route_check
712
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
713
+	 * @throws EE_Error
714
+	 * @throws InvalidArgumentException
715
+	 * @throws InvalidDataTypeException
716
+	 * @throws InvalidInterfaceException
717
+	 * @throws ReflectionException
718
+	 */
719
+	protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
720
+	{
721
+		$model = null;
722
+		if (empty($this->_cpt_model_names)
723
+			|| (
724
+				! $ignore_route_check
725
+				&& ! isset($this->_cpt_routes[ $this->_req_action ])
726
+			) || (
727
+				$this->_cpt_model_obj instanceof EE_CPT_Base
728
+				&& $this->_cpt_model_obj->ID() === $id
729
+			)
730
+		) {
731
+			// 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.
732
+			return;
733
+		}
734
+		// if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
735
+		if ($ignore_route_check) {
736
+			$post_type = get_post_type($id);
737
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
738
+			$custom_post_types = $this->getLoader()->getShared(
739
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
740
+			);
741
+			$model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
742
+			if (isset($model_names[ $post_type ])) {
743
+				$model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
744
+			}
745
+		} else {
746
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
747
+		}
748
+		if ($model instanceof EEM_Base) {
749
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
750
+		}
751
+		do_action(
752
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
753
+			$this->_cpt_model_obj,
754
+			$req_type
755
+		);
756
+	}
757
+
758
+
759
+	/**
760
+	 * admin_init_global
761
+	 * This runs all the code that we want executed within the WP admin_init hook.
762
+	 * This method executes for ALL EE Admin pages.
763
+	 *
764
+	 * @access public
765
+	 * @return void
766
+	 */
767
+	public function admin_init_global()
768
+	{
769
+		$post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
770
+		// its possible this is a new save so let's catch that instead
771
+		$post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
772
+		$post_type = $post ? $post->post_type : false;
773
+		$current_route = isset($this->_req_data['current_route'])
774
+			? $this->_req_data['current_route']
775
+			: 'shouldneverwork';
776
+		$route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
777
+			? $this->_cpt_routes[ $current_route ]
778
+			: '';
779
+		add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
780
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
781
+		if ($post_type === $route_to_check) {
782
+			add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
783
+		}
784
+		// now let's filter redirect if we're on a revision page and the revision is for an event CPT.
785
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
786
+		if (! empty($revision)) {
787
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
788
+			// doing a restore?
789
+			if (! empty($action) && $action === 'restore') {
790
+				// get post for revision
791
+				$rev_post = get_post($revision);
792
+				$rev_parent = get_post($rev_post->post_parent);
793
+				// only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
794
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
795
+					add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
796
+					// restores of revisions
797
+					add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
798
+				}
799
+			}
800
+		}
801
+		// 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!
802
+		if ($post_type && $post_type === $route_to_check) {
803
+			// $post_id, $post
804
+			add_action('save_post', array($this, 'insert_update'), 10, 3);
805
+			// $post_id
806
+			add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
807
+			add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
808
+			add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
809
+			add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
810
+		}
811
+	}
812
+
813
+
814
+	/**
815
+	 * Callback for the WordPress trashed_post hook.
816
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
817
+	 *
818
+	 * @param int $post_id
819
+	 * @throws \EE_Error
820
+	 */
821
+	public function before_trash_cpt_item($post_id)
822
+	{
823
+		$this->_set_model_object($post_id, true, 'trash');
824
+		// if our cpt object isn't existent then get out immediately.
825
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826
+			return;
827
+		}
828
+		$this->trash_cpt_item($post_id);
829
+	}
830
+
831
+
832
+	/**
833
+	 * Callback for the WordPress untrashed_post hook.
834
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
835
+	 *
836
+	 * @param $post_id
837
+	 * @throws \EE_Error
838
+	 */
839
+	public function before_restore_cpt_item($post_id)
840
+	{
841
+		$this->_set_model_object($post_id, true, 'restore');
842
+		// if our cpt object isn't existent then get out immediately.
843
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
844
+			return;
845
+		}
846
+		$this->restore_cpt_item($post_id);
847
+	}
848
+
849
+
850
+	/**
851
+	 * Callback for the WordPress after_delete_post hook.
852
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
853
+	 *
854
+	 * @param $post_id
855
+	 * @throws \EE_Error
856
+	 */
857
+	public function before_delete_cpt_item($post_id)
858
+	{
859
+		$this->_set_model_object($post_id, true, 'delete');
860
+		// if our cpt object isn't existent then get out immediately.
861
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862
+			return;
863
+		}
864
+		$this->delete_cpt_item($post_id);
865
+	}
866
+
867
+
868
+	/**
869
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
870
+	 * accordingly.
871
+	 *
872
+	 * @access public
873
+	 * @throws EE_Error
874
+	 * @return void
875
+	 */
876
+	public function verify_cpt_object()
877
+	{
878
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879
+		// verify event object
880
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881
+			throw new EE_Error(
882
+				sprintf(
883
+					__(
884
+						'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',
885
+						'event_espresso'
886
+					),
887
+					$label
888
+				)
889
+			);
890
+		}
891
+		// if auto-draft then throw an error
892
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
893
+			EE_Error::overwrite_errors();
894
+			EE_Error::add_error(
895
+				sprintf(
896
+					__(
897
+						'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.',
898
+						'event_espresso'
899
+					),
900
+					$label
901
+				),
902
+				__FILE__,
903
+				__FUNCTION__,
904
+				__LINE__
905
+			);
906
+		}
907
+	}
908
+
909
+
910
+	/**
911
+	 * admin_footer_scripts_global
912
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
913
+	 * will apply on ALL EE_Admin pages.
914
+	 *
915
+	 * @access public
916
+	 * @return void
917
+	 */
918
+	public function admin_footer_scripts_global()
919
+	{
920
+		$this->_add_admin_page_ajax_loading_img();
921
+		$this->_add_admin_page_overlay();
922
+	}
923
+
924
+
925
+	/**
926
+	 * add in any global scripts for cpt routes
927
+	 *
928
+	 * @return void
929
+	 */
930
+	public function load_global_scripts_styles()
931
+	{
932
+		parent::load_global_scripts_styles();
933
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
934
+			// setup custom post status object for localize script but only if we've got a cpt object
935
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
936
+			if (! empty($statuses)) {
937
+				// get ALL statuses!
938
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
939
+				// setup object
940
+				$ee_cpt_statuses = array();
941
+				foreach ($statuses as $status => $label) {
942
+					$ee_cpt_statuses[ $status ] = array(
943
+						'label'      => $label,
944
+						'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
945
+					);
946
+				}
947
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
948
+			}
949
+		}
950
+	}
951
+
952
+
953
+	/**
954
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
955
+	 * insert/updates
956
+	 *
957
+	 * @param  int     $post_id ID of post being updated
958
+	 * @param  WP_Post $post    Post object from WP
959
+	 * @param  bool    $update  Whether this is an update or a new save.
960
+	 * @return void
961
+	 * @throws \EE_Error
962
+	 */
963
+	public function insert_update($post_id, $post, $update)
964
+	{
965
+		// make sure that if this is a revision OR trash action that we don't do any updates!
966
+		if (isset($this->_req_data['action'])
967
+			&& (
968
+				$this->_req_data['action'] === 'restore'
969
+				|| $this->_req_data['action'] === 'trash'
970
+			)
971
+		) {
972
+			return;
973
+		}
974
+		$this->_set_model_object($post_id, true, 'insert_update');
975
+		// if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
976
+		if ($update
977
+			&& (
978
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
979
+				|| $this->_cpt_model_obj->ID() !== $post_id
980
+			)
981
+		) {
982
+			return;
983
+		}
984
+		// check for autosave and update our req_data property accordingly.
985
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
986 986
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
987 987
 
988 988
                 foreach ( (array) $values as $key => $value ) {
@@ -992,532 +992,532 @@  discard block
 block discarded – undo
992 992
 
993 993
         }/**/ // TODO reactivate after autosave is implemented in 4.2
994 994
 
995
-        // take care of updating any selected page_template IF this cpt supports it.
996
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
997
-            // wp version aware.
998
-            if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
999
-                $page_templates = wp_get_theme()->get_page_templates();
1000
-            } else {
1001
-                $post->page_template = $this->_req_data['page_template'];
1002
-                $page_templates = wp_get_theme()->get_page_templates($post);
1003
-            }
1004
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1005
-                EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1006
-            } else {
1007
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1008
-            }
1009
-        }
1010
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1011
-            return;
1012
-        } //TODO we'll remove this after reimplementing autosave in 4.2
1013
-        $this->_insert_update_cpt_item($post_id, $post);
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1019
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1020
-     * so we don't have to check for our CPT.
1021
-     *
1022
-     * @param  int $post_id ID of the post
1023
-     * @return void
1024
-     */
1025
-    public function dont_permanently_delete_ee_cpts($post_id)
1026
-    {
1027
-        // only do this if we're actually processing one of our CPTs
1028
-        // if our cpt object isn't existent then get out immediately.
1029
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1030
-            return;
1031
-        }
1032
-        delete_post_meta($post_id, '_wp_trash_meta_status');
1033
-        delete_post_meta($post_id, '_wp_trash_meta_time');
1034
-        // our cpts may have comments so let's take care of that too
1035
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1041
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1042
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1043
-     *
1044
-     * @param  int $post_id     ID of cpt item
1045
-     * @param  int $revision_id ID of revision being restored
1046
-     * @return void
1047
-     */
1048
-    public function restore_revision($post_id, $revision_id)
1049
-    {
1050
-        $this->_restore_cpt_item($post_id, $revision_id);
1051
-        // global action
1052
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1053
-        // class specific action so you can limit hooking into a specific page.
1054
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * @see restore_revision() for details
1060
-     * @param  int $post_id     ID of cpt item
1061
-     * @param  int $revision_id ID of revision for item
1062
-     * @return void
1063
-     */
1064
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
1065
-
1066
-
1067
-    /**
1068
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1069
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1070
-     * To fix we have to reset the current_screen using the page_slug
1071
-     * (which is identical - or should be - to our registered_post_type id.)
1072
-     * Also, since the core WP file loads the admin_header.php for WP
1073
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1074
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1075
-     *
1076
-     * @return void
1077
-     */
1078
-    public function modify_current_screen()
1079
-    {
1080
-        // ONLY do this if the current page_route IS a cpt route
1081
-        if (! $this->_cpt_route) {
1082
-            return;
1083
-        }
1084
-        // routing things REALLY early b/c this is a cpt admin page
1085
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1086
-        $this->_current_screen = get_current_screen();
1087
-        $this->_current_screen->base = 'event-espresso';
1088
-        $this->_add_help_tabs(); // we make sure we add any help tabs back in!
1089
-        /*try {
995
+		// take care of updating any selected page_template IF this cpt supports it.
996
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
997
+			// wp version aware.
998
+			if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
999
+				$page_templates = wp_get_theme()->get_page_templates();
1000
+			} else {
1001
+				$post->page_template = $this->_req_data['page_template'];
1002
+				$page_templates = wp_get_theme()->get_page_templates($post);
1003
+			}
1004
+			if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1005
+				EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1006
+			} else {
1007
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1008
+			}
1009
+		}
1010
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1011
+			return;
1012
+		} //TODO we'll remove this after reimplementing autosave in 4.2
1013
+		$this->_insert_update_cpt_item($post_id, $post);
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1019
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1020
+	 * so we don't have to check for our CPT.
1021
+	 *
1022
+	 * @param  int $post_id ID of the post
1023
+	 * @return void
1024
+	 */
1025
+	public function dont_permanently_delete_ee_cpts($post_id)
1026
+	{
1027
+		// only do this if we're actually processing one of our CPTs
1028
+		// if our cpt object isn't existent then get out immediately.
1029
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1030
+			return;
1031
+		}
1032
+		delete_post_meta($post_id, '_wp_trash_meta_status');
1033
+		delete_post_meta($post_id, '_wp_trash_meta_time');
1034
+		// our cpts may have comments so let's take care of that too
1035
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1041
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1042
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1043
+	 *
1044
+	 * @param  int $post_id     ID of cpt item
1045
+	 * @param  int $revision_id ID of revision being restored
1046
+	 * @return void
1047
+	 */
1048
+	public function restore_revision($post_id, $revision_id)
1049
+	{
1050
+		$this->_restore_cpt_item($post_id, $revision_id);
1051
+		// global action
1052
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1053
+		// class specific action so you can limit hooking into a specific page.
1054
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * @see restore_revision() for details
1060
+	 * @param  int $post_id     ID of cpt item
1061
+	 * @param  int $revision_id ID of revision for item
1062
+	 * @return void
1063
+	 */
1064
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
1065
+
1066
+
1067
+	/**
1068
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1069
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1070
+	 * To fix we have to reset the current_screen using the page_slug
1071
+	 * (which is identical - or should be - to our registered_post_type id.)
1072
+	 * Also, since the core WP file loads the admin_header.php for WP
1073
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1074
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1075
+	 *
1076
+	 * @return void
1077
+	 */
1078
+	public function modify_current_screen()
1079
+	{
1080
+		// ONLY do this if the current page_route IS a cpt route
1081
+		if (! $this->_cpt_route) {
1082
+			return;
1083
+		}
1084
+		// routing things REALLY early b/c this is a cpt admin page
1085
+		set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1086
+		$this->_current_screen = get_current_screen();
1087
+		$this->_current_screen->base = 'event-espresso';
1088
+		$this->_add_help_tabs(); // we make sure we add any help tabs back in!
1089
+		/*try {
1090 1090
             $this->_route_admin_request();
1091 1091
         } catch ( EE_Error $e ) {
1092 1092
             $e->get_error();
1093 1093
         }/**/
1094
-    }
1095
-
1096
-
1097
-    /**
1098
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1099
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1100
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1101
-     * default to be.
1102
-     *
1103
-     * @param string $title The new title (or existing if there is no editor_title defined)
1104
-     * @return string
1105
-     */
1106
-    public function add_custom_editor_default_title($title)
1107
-    {
1108
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1109
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1110
-            : $title;
1111
-    }
1112
-
1113
-
1114
-    /**
1115
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1116
-     *
1117
-     * @param string $shortlink   The already generated shortlink
1118
-     * @param int    $id          Post ID for this item
1119
-     * @param string $context     The context for the link
1120
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1121
-     * @return string
1122
-     */
1123
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1124
-    {
1125
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1126
-            $post = get_post($id);
1127
-            if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1128
-                $shortlink = home_url('?p=' . $post->ID);
1129
-            }
1130
-        }
1131
-        return $shortlink;
1132
-    }
1133
-
1134
-
1135
-    /**
1136
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1137
-     * already run in modify_current_screen())
1138
-     *
1139
-     * @return void
1140
-     */
1141
-    public function route_admin_request()
1142
-    {
1143
-        if ($this->_cpt_route) {
1144
-            return;
1145
-        }
1146
-        try {
1147
-            $this->_route_admin_request();
1148
-        } catch (EE_Error $e) {
1149
-            $e->get_error();
1150
-        }
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1156
-     *
1157
-     * @return void
1158
-     */
1159
-    public function cpt_post_form_hidden_input()
1160
-    {
1161
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1162
-        // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1163
-        echo '<div id="ee-cpt-hidden-inputs">';
1164
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1165
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1166
-        echo '</div>';
1167
-    }
1168
-
1169
-
1170
-    /**
1171
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1172
-     *
1173
-     * @param  string $location Original location url
1174
-     * @param  int    $status   Status for http header
1175
-     * @return string           new (or original) url to redirect to.
1176
-     */
1177
-    public function revision_redirect($location, $status)
1178
-    {
1179
-        // get revision
1180
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1181
-        // can't do anything without revision so let's get out if not present
1182
-        if (empty($rev_id)) {
1183
-            return $location;
1184
-        }
1185
-        // get rev_post_data
1186
-        $rev = get_post($rev_id);
1187
-        $admin_url = $this->_admin_base_url;
1188
-        $query_args = array(
1189
-            'action'   => 'edit',
1190
-            'post'     => $rev->post_parent,
1191
-            'revision' => $rev_id,
1192
-            'message'  => 5,
1193
-        );
1194
-        $this->_process_notices($query_args, true);
1195
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1196
-    }
1197
-
1198
-
1199
-    /**
1200
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1201
-     *
1202
-     * @param  string $link    the original generated link
1203
-     * @param  int    $id      post id
1204
-     * @param  string $context optional, defaults to display.  How to write the '&'
1205
-     * @return string          the link
1206
-     */
1207
-    public function modify_edit_post_link($link, $id, $context)
1208
-    {
1209
-        $post = get_post($id);
1210
-        if (! isset($this->_req_data['action'])
1211
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1212
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1213
-        ) {
1214
-            return $link;
1215
-        }
1216
-        $query_args = array(
1217
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1218
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1219
-                : 'edit',
1220
-            'post'   => $id,
1221
-        );
1222
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1223
-    }
1224
-
1225
-
1226
-    /**
1227
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1228
-     * our routes.
1229
-     *
1230
-     * @param  string $delete_link  original delete link
1231
-     * @param  int    $post_id      id of cpt object
1232
-     * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1233
-     * @return string new delete link
1234
-     * @throws EE_Error
1235
-     */
1236
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1237
-    {
1238
-        $post = get_post($post_id);
1239
-
1240
-        if (empty($this->_req_data['action'])
1241
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1242
-            || ! $post instanceof WP_Post
1243
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1244
-        ) {
1245
-            return $delete_link;
1246
-        }
1247
-        $this->_set_model_object($post->ID, true);
1248
-
1249
-        // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1250
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1251
-
1252
-        return EE_Admin_Page::add_query_args_and_nonce(
1253
-            array(
1254
-                'page'   => $this->_req_data['page'],
1255
-                'action' => $action,
1256
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1257
-                         => $post->ID,
1258
-            ),
1259
-            admin_url()
1260
-        );
1261
-    }
1262
-
1263
-
1264
-    /**
1265
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1266
-     * so that we can hijack the default redirect locations for wp custom post types
1267
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1268
-     *
1269
-     * @param  string $location This is the incoming currently set redirect location
1270
-     * @param  string $post_id  This is the 'ID' value of the wp_posts table
1271
-     * @return string           the new location to redirect to
1272
-     */
1273
-    public function cpt_post_location_redirect($location, $post_id)
1274
-    {
1275
-        // we DO have a match so let's setup the url
1276
-        // we have to get the post to determine our route
1277
-        $post = get_post($post_id);
1278
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1279
-        // shared query_args
1280
-        $query_args = array('action' => $edit_route, 'post' => $post_id);
1281
-        $admin_url = $this->_admin_base_url;
1282
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1283
-            $status = get_post_status($post_id);
1284
-            if (isset($this->_req_data['publish'])) {
1285
-                switch ($status) {
1286
-                    case 'pending':
1287
-                        $message = 8;
1288
-                        break;
1289
-                    case 'future':
1290
-                        $message = 9;
1291
-                        break;
1292
-                    default:
1293
-                        $message = 6;
1294
-                }
1295
-            } else {
1296
-                $message = 'draft' === $status ? 10 : 1;
1297
-            }
1298
-        } elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1299
-            $message = 2;
1300
-        } elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1301
-            $message = 3;
1302
-        } elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1303
-            $message = 7;
1304
-        } else {
1305
-            $message = 4;
1306
-        }
1307
-        // change the message if the post type is not viewable on the frontend
1308
-        $this->_cpt_object = get_post_type_object($post->post_type);
1309
-        $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1310
-        $query_args = array_merge(array('message' => $message), $query_args);
1311
-        $this->_process_notices($query_args, true);
1312
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1313
-    }
1314
-
1315
-
1316
-    /**
1317
-     * This method is called to inject nav tabs on core WP cpt pages
1318
-     *
1319
-     * @access public
1320
-     * @return void
1321
-     */
1322
-    public function inject_nav_tabs()
1323
-    {
1324
-        // can we hijack and insert the nav_tabs?
1325
-        $nav_tabs = $this->_get_main_nav_tabs();
1326
-        // first close off existing form tag
1327
-        $html = '>';
1328
-        $html .= $nav_tabs;
1329
-        // now let's handle the remaining tag ( missing ">" is CORRECT )
1330
-        $html .= '<span></span';
1331
-        echo $html;
1332
-    }
1333
-
1334
-
1335
-    /**
1336
-     * This just sets up the post update messages when an update form is loaded
1337
-     *
1338
-     * @access public
1339
-     * @param  array $messages the original messages array
1340
-     * @return array           the new messages array
1341
-     */
1342
-    public function post_update_messages($messages)
1343
-    {
1344
-        global $post;
1345
-        $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1346
-        $id = empty($id) && is_object($post) ? $post->ID : null;
1347
-        /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1094
+	}
1095
+
1096
+
1097
+	/**
1098
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1099
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1100
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1101
+	 * default to be.
1102
+	 *
1103
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1104
+	 * @return string
1105
+	 */
1106
+	public function add_custom_editor_default_title($title)
1107
+	{
1108
+		return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1109
+			? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1110
+			: $title;
1111
+	}
1112
+
1113
+
1114
+	/**
1115
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1116
+	 *
1117
+	 * @param string $shortlink   The already generated shortlink
1118
+	 * @param int    $id          Post ID for this item
1119
+	 * @param string $context     The context for the link
1120
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1121
+	 * @return string
1122
+	 */
1123
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1124
+	{
1125
+		if (! empty($id) && get_option('permalink_structure') !== '') {
1126
+			$post = get_post($id);
1127
+			if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1128
+				$shortlink = home_url('?p=' . $post->ID);
1129
+			}
1130
+		}
1131
+		return $shortlink;
1132
+	}
1133
+
1134
+
1135
+	/**
1136
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1137
+	 * already run in modify_current_screen())
1138
+	 *
1139
+	 * @return void
1140
+	 */
1141
+	public function route_admin_request()
1142
+	{
1143
+		if ($this->_cpt_route) {
1144
+			return;
1145
+		}
1146
+		try {
1147
+			$this->_route_admin_request();
1148
+		} catch (EE_Error $e) {
1149
+			$e->get_error();
1150
+		}
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1156
+	 *
1157
+	 * @return void
1158
+	 */
1159
+	public function cpt_post_form_hidden_input()
1160
+	{
1161
+		echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1162
+		// we're also going to add the route value and the current page so we can direct autosave parsing correctly
1163
+		echo '<div id="ee-cpt-hidden-inputs">';
1164
+		echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1165
+		echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1166
+		echo '</div>';
1167
+	}
1168
+
1169
+
1170
+	/**
1171
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1172
+	 *
1173
+	 * @param  string $location Original location url
1174
+	 * @param  int    $status   Status for http header
1175
+	 * @return string           new (or original) url to redirect to.
1176
+	 */
1177
+	public function revision_redirect($location, $status)
1178
+	{
1179
+		// get revision
1180
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1181
+		// can't do anything without revision so let's get out if not present
1182
+		if (empty($rev_id)) {
1183
+			return $location;
1184
+		}
1185
+		// get rev_post_data
1186
+		$rev = get_post($rev_id);
1187
+		$admin_url = $this->_admin_base_url;
1188
+		$query_args = array(
1189
+			'action'   => 'edit',
1190
+			'post'     => $rev->post_parent,
1191
+			'revision' => $rev_id,
1192
+			'message'  => 5,
1193
+		);
1194
+		$this->_process_notices($query_args, true);
1195
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1196
+	}
1197
+
1198
+
1199
+	/**
1200
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1201
+	 *
1202
+	 * @param  string $link    the original generated link
1203
+	 * @param  int    $id      post id
1204
+	 * @param  string $context optional, defaults to display.  How to write the '&'
1205
+	 * @return string          the link
1206
+	 */
1207
+	public function modify_edit_post_link($link, $id, $context)
1208
+	{
1209
+		$post = get_post($id);
1210
+		if (! isset($this->_req_data['action'])
1211
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1212
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1213
+		) {
1214
+			return $link;
1215
+		}
1216
+		$query_args = array(
1217
+			'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1218
+				? $this->_cpt_edit_routes[ $post->post_type ]
1219
+				: 'edit',
1220
+			'post'   => $id,
1221
+		);
1222
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1223
+	}
1224
+
1225
+
1226
+	/**
1227
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1228
+	 * our routes.
1229
+	 *
1230
+	 * @param  string $delete_link  original delete link
1231
+	 * @param  int    $post_id      id of cpt object
1232
+	 * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1233
+	 * @return string new delete link
1234
+	 * @throws EE_Error
1235
+	 */
1236
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1237
+	{
1238
+		$post = get_post($post_id);
1239
+
1240
+		if (empty($this->_req_data['action'])
1241
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1242
+			|| ! $post instanceof WP_Post
1243
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1244
+		) {
1245
+			return $delete_link;
1246
+		}
1247
+		$this->_set_model_object($post->ID, true);
1248
+
1249
+		// returns something like `trash_event` or `trash_attendee` or `trash_venue`
1250
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1251
+
1252
+		return EE_Admin_Page::add_query_args_and_nonce(
1253
+			array(
1254
+				'page'   => $this->_req_data['page'],
1255
+				'action' => $action,
1256
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1257
+						 => $post->ID,
1258
+			),
1259
+			admin_url()
1260
+		);
1261
+	}
1262
+
1263
+
1264
+	/**
1265
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1266
+	 * so that we can hijack the default redirect locations for wp custom post types
1267
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1268
+	 *
1269
+	 * @param  string $location This is the incoming currently set redirect location
1270
+	 * @param  string $post_id  This is the 'ID' value of the wp_posts table
1271
+	 * @return string           the new location to redirect to
1272
+	 */
1273
+	public function cpt_post_location_redirect($location, $post_id)
1274
+	{
1275
+		// we DO have a match so let's setup the url
1276
+		// we have to get the post to determine our route
1277
+		$post = get_post($post_id);
1278
+		$edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1279
+		// shared query_args
1280
+		$query_args = array('action' => $edit_route, 'post' => $post_id);
1281
+		$admin_url = $this->_admin_base_url;
1282
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1283
+			$status = get_post_status($post_id);
1284
+			if (isset($this->_req_data['publish'])) {
1285
+				switch ($status) {
1286
+					case 'pending':
1287
+						$message = 8;
1288
+						break;
1289
+					case 'future':
1290
+						$message = 9;
1291
+						break;
1292
+					default:
1293
+						$message = 6;
1294
+				}
1295
+			} else {
1296
+				$message = 'draft' === $status ? 10 : 1;
1297
+			}
1298
+		} elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1299
+			$message = 2;
1300
+		} elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1301
+			$message = 3;
1302
+		} elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1303
+			$message = 7;
1304
+		} else {
1305
+			$message = 4;
1306
+		}
1307
+		// change the message if the post type is not viewable on the frontend
1308
+		$this->_cpt_object = get_post_type_object($post->post_type);
1309
+		$message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1310
+		$query_args = array_merge(array('message' => $message), $query_args);
1311
+		$this->_process_notices($query_args, true);
1312
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1313
+	}
1314
+
1315
+
1316
+	/**
1317
+	 * This method is called to inject nav tabs on core WP cpt pages
1318
+	 *
1319
+	 * @access public
1320
+	 * @return void
1321
+	 */
1322
+	public function inject_nav_tabs()
1323
+	{
1324
+		// can we hijack and insert the nav_tabs?
1325
+		$nav_tabs = $this->_get_main_nav_tabs();
1326
+		// first close off existing form tag
1327
+		$html = '>';
1328
+		$html .= $nav_tabs;
1329
+		// now let's handle the remaining tag ( missing ">" is CORRECT )
1330
+		$html .= '<span></span';
1331
+		echo $html;
1332
+	}
1333
+
1334
+
1335
+	/**
1336
+	 * This just sets up the post update messages when an update form is loaded
1337
+	 *
1338
+	 * @access public
1339
+	 * @param  array $messages the original messages array
1340
+	 * @return array           the new messages array
1341
+	 */
1342
+	public function post_update_messages($messages)
1343
+	{
1344
+		global $post;
1345
+		$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1346
+		$id = empty($id) && is_object($post) ? $post->ID : null;
1347
+		/*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1348 1348
 
1349 1349
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1350
-        $messages[ $post->post_type ] = array(
1351
-            0  => '', // Unused. Messages start at index 1.
1352
-            1  => sprintf(
1353
-                __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1354
-                $this->_cpt_object->labels->singular_name,
1355
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1356
-                '</a>'
1357
-            ),
1358
-            2  => __('Custom field updated', 'event_espresso'),
1359
-            3  => __('Custom field deleted.', 'event_espresso'),
1360
-            4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1361
-            5  => isset($_GET['revision']) ? sprintf(
1362
-                __('%s restored to revision from %s', 'event_espresso'),
1363
-                $this->_cpt_object->labels->singular_name,
1364
-                wp_post_revision_title((int) $_GET['revision'], false)
1365
-            )
1366
-                : false,
1367
-            6  => sprintf(
1368
-                __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1369
-                $this->_cpt_object->labels->singular_name,
1370
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1371
-                '</a>'
1372
-            ),
1373
-            7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1374
-            8  => sprintf(
1375
-                __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1376
-                $this->_cpt_object->labels->singular_name,
1377
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1378
-                '</a>'
1379
-            ),
1380
-            9  => sprintf(
1381
-                __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1382
-                $this->_cpt_object->labels->singular_name,
1383
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1384
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1385
-                '</a>'
1386
-            ),
1387
-            10 => sprintf(
1388
-                __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1389
-                $this->_cpt_object->labels->singular_name,
1390
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1391
-                '</a>'
1392
-            ),
1393
-        );
1394
-        return $messages;
1395
-    }
1396
-
1397
-
1398
-    /**
1399
-     * default method for the 'create_new' route for cpt admin pages.
1400
-     * For reference what to include in here, see wp-admin/post-new.php
1401
-     *
1402
-     * @access  protected
1403
-     * @return void
1404
-     */
1405
-    protected function _create_new_cpt_item()
1406
-    {
1407
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1408
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1409
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1410
-        $post_type_object = $this->_cpt_object;
1411
-        $title = $post_type_object->labels->add_new_item;
1412
-        $post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1413
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1414
-        // modify the default editor title field with default title.
1415
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1416
-        $this->loadEditorTemplate(true);
1417
-    }
1418
-
1419
-
1420
-    /**
1421
-     * Enqueues auto-save and loads the editor template
1422
-     *
1423
-     * @param bool $creating
1424
-     */
1425
-    private function loadEditorTemplate($creating = true)
1426
-    {
1427
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1428
-        // these vars are used by the template
1429
-        $editing = true;
1430
-        $post_ID = $post->ID;
1431
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1432
-            // only enqueue autosave when creating event (necessary to get permalink/url generated)
1433
-            // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1434
-            if ($creating) {
1435
-                wp_enqueue_script('autosave');
1436
-            } else {
1437
-                if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1438
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1439
-                ) {
1440
-                    $create_new_action = apply_filters(
1441
-                        'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1442
-                        'create_new',
1443
-                        $this
1444
-                    );
1445
-                    $post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1446
-                        array(
1447
-                            'action' => $create_new_action,
1448
-                            'page'   => $this->page_slug,
1449
-                        ),
1450
-                        'admin.php'
1451
-                    );
1452
-                }
1453
-            }
1454
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1455
-        }
1456
-    }
1457
-
1458
-
1459
-    public function add_new_admin_page_global()
1460
-    {
1461
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1462
-        ?>
1350
+		$messages[ $post->post_type ] = array(
1351
+			0  => '', // Unused. Messages start at index 1.
1352
+			1  => sprintf(
1353
+				__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1354
+				$this->_cpt_object->labels->singular_name,
1355
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1356
+				'</a>'
1357
+			),
1358
+			2  => __('Custom field updated', 'event_espresso'),
1359
+			3  => __('Custom field deleted.', 'event_espresso'),
1360
+			4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1361
+			5  => isset($_GET['revision']) ? sprintf(
1362
+				__('%s restored to revision from %s', 'event_espresso'),
1363
+				$this->_cpt_object->labels->singular_name,
1364
+				wp_post_revision_title((int) $_GET['revision'], false)
1365
+			)
1366
+				: false,
1367
+			6  => sprintf(
1368
+				__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1369
+				$this->_cpt_object->labels->singular_name,
1370
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1371
+				'</a>'
1372
+			),
1373
+			7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1374
+			8  => sprintf(
1375
+				__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1376
+				$this->_cpt_object->labels->singular_name,
1377
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1378
+				'</a>'
1379
+			),
1380
+			9  => sprintf(
1381
+				__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1382
+				$this->_cpt_object->labels->singular_name,
1383
+				'<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1384
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1385
+				'</a>'
1386
+			),
1387
+			10 => sprintf(
1388
+				__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1389
+				$this->_cpt_object->labels->singular_name,
1390
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1391
+				'</a>'
1392
+			),
1393
+		);
1394
+		return $messages;
1395
+	}
1396
+
1397
+
1398
+	/**
1399
+	 * default method for the 'create_new' route for cpt admin pages.
1400
+	 * For reference what to include in here, see wp-admin/post-new.php
1401
+	 *
1402
+	 * @access  protected
1403
+	 * @return void
1404
+	 */
1405
+	protected function _create_new_cpt_item()
1406
+	{
1407
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1408
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1409
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1410
+		$post_type_object = $this->_cpt_object;
1411
+		$title = $post_type_object->labels->add_new_item;
1412
+		$post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1413
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1414
+		// modify the default editor title field with default title.
1415
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1416
+		$this->loadEditorTemplate(true);
1417
+	}
1418
+
1419
+
1420
+	/**
1421
+	 * Enqueues auto-save and loads the editor template
1422
+	 *
1423
+	 * @param bool $creating
1424
+	 */
1425
+	private function loadEditorTemplate($creating = true)
1426
+	{
1427
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1428
+		// these vars are used by the template
1429
+		$editing = true;
1430
+		$post_ID = $post->ID;
1431
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1432
+			// only enqueue autosave when creating event (necessary to get permalink/url generated)
1433
+			// otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1434
+			if ($creating) {
1435
+				wp_enqueue_script('autosave');
1436
+			} else {
1437
+				if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1438
+					&& ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1439
+				) {
1440
+					$create_new_action = apply_filters(
1441
+						'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1442
+						'create_new',
1443
+						$this
1444
+					);
1445
+					$post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1446
+						array(
1447
+							'action' => $create_new_action,
1448
+							'page'   => $this->page_slug,
1449
+						),
1450
+						'admin.php'
1451
+					);
1452
+				}
1453
+			}
1454
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1455
+		}
1456
+	}
1457
+
1458
+
1459
+	public function add_new_admin_page_global()
1460
+	{
1461
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1462
+		?>
1463 1463
         <script type="text/javascript">
1464 1464
             adminpage = '<?php echo $admin_page; ?>';
1465 1465
         </script>
1466 1466
         <?php
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * default method for the 'edit' route for cpt admin pages
1472
-     * For reference on what to put in here, refer to wp-admin/post.php
1473
-     *
1474
-     * @access protected
1475
-     * @return string   template for edit cpt form
1476
-     */
1477
-    protected function _edit_cpt_item()
1478
-    {
1479
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1480
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1481
-        $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1482
-        if (empty($post)) {
1483
-            wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1484
-        }
1485
-        if (! empty($_GET['get-post-lock'])) {
1486
-            wp_set_post_lock($post_id);
1487
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1488
-            exit();
1489
-        }
1490
-
1491
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1492
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1493
-        $post_type_object = $this->_cpt_object;
1494
-
1495
-        if (! wp_check_post_lock($post->ID)) {
1496
-            wp_set_post_lock($post->ID);
1497
-        }
1498
-        add_action('admin_footer', '_admin_notice_post_locked');
1499
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1500
-            wp_enqueue_script('admin-comments');
1501
-            enqueue_comment_hotkeys_js();
1502
-        }
1503
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1504
-        // modify the default editor title field with default title.
1505
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1506
-        $this->loadEditorTemplate(false);
1507
-    }
1508
-
1509
-
1510
-
1511
-    /**
1512
-     * some getters
1513
-     */
1514
-    /**
1515
-     * This returns the protected _cpt_model_obj property
1516
-     *
1517
-     * @return EE_CPT_Base
1518
-     */
1519
-    public function get_cpt_model_obj()
1520
-    {
1521
-        return $this->_cpt_model_obj;
1522
-    }
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * default method for the 'edit' route for cpt admin pages
1472
+	 * For reference on what to put in here, refer to wp-admin/post.php
1473
+	 *
1474
+	 * @access protected
1475
+	 * @return string   template for edit cpt form
1476
+	 */
1477
+	protected function _edit_cpt_item()
1478
+	{
1479
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1480
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1481
+		$post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1482
+		if (empty($post)) {
1483
+			wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1484
+		}
1485
+		if (! empty($_GET['get-post-lock'])) {
1486
+			wp_set_post_lock($post_id);
1487
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1488
+			exit();
1489
+		}
1490
+
1491
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1492
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1493
+		$post_type_object = $this->_cpt_object;
1494
+
1495
+		if (! wp_check_post_lock($post->ID)) {
1496
+			wp_set_post_lock($post->ID);
1497
+		}
1498
+		add_action('admin_footer', '_admin_notice_post_locked');
1499
+		if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1500
+			wp_enqueue_script('admin-comments');
1501
+			enqueue_comment_hotkeys_js();
1502
+		}
1503
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1504
+		// modify the default editor title field with default title.
1505
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1506
+		$this->loadEditorTemplate(false);
1507
+	}
1508
+
1509
+
1510
+
1511
+	/**
1512
+	 * some getters
1513
+	 */
1514
+	/**
1515
+	 * This returns the protected _cpt_model_obj property
1516
+	 *
1517
+	 * @return EE_CPT_Base
1518
+	 */
1519
+	public function get_cpt_model_obj()
1520
+	{
1521
+		return $this->_cpt_model_obj;
1522
+	}
1523 1523
 }
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     protected function getLoader()
166 166
     {
167
-        if (! $this->loader instanceof LoaderInterface) {
167
+        if ( ! $this->loader instanceof LoaderInterface) {
168 168
             $this->loader = LoaderFactory::getLoader();
169 169
         }
170 170
         return $this->loader;
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
             $this->_cpt_routes
189 189
         );
190 190
         // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
191
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
192
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
191
+        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
192
+            ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
193 193
             : get_post_type_object($page);
194 194
         // tweak pagenow for page loading.
195
-        if (! $this->_pagenow_map) {
195
+        if ( ! $this->_pagenow_map) {
196 196
             $this->_pagenow_map = array(
197 197
                 'create_new' => 'post-new.php',
198 198
                 'edit'       => 'post.php',
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
     {
227 227
         global $pagenow, $hook_suffix;
228 228
         // possibly reset pagenow.
229
-        if (! empty($this->_req_data['page'])
229
+        if ( ! empty($this->_req_data['page'])
230 230
             && $this->_req_data['page'] == $this->page_slug
231 231
             && ! empty($this->_req_data['action'])
232
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
232
+            && isset($this->_pagenow_map[$this->_req_data['action']])
233 233
         ) {
234
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
234
+            $pagenow = $this->_pagenow_map[$this->_req_data['action']];
235 235
             $hook_suffix = $pagenow;
236 236
         }
237 237
     }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         if (empty($wp_meta_boxes)) {
264 264
             return;
265 265
         }
266
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
266
+        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
267 267
         foreach ($current_metaboxes as $box_context) {
268 268
             foreach ($box_context as $box_details) {
269 269
                 foreach ($box_details as $box) {
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             $this
297 297
         );
298 298
         $containers = apply_filters(
299
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
299
+            'FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
300 300
             $containers,
301 301
             $this
302 302
         );
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     protected function _load_page_dependencies()
341 341
     {
342 342
         // we only add stuff if this is a cpt_route!
343
-        if (! $this->_cpt_route) {
343
+        if ( ! $this->_cpt_route) {
344 344
             parent::_load_page_dependencies();
345 345
             return;
346 346
         }
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
         add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
365 365
         // This basically allows us to change the title of the "publish" metabox area
366 366
         // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
367
-        if (! empty($this->_labels['publishbox'])) {
367
+        if ( ! empty($this->_labels['publishbox'])) {
368 368
             $box_label = is_array($this->_labels['publishbox'])
369
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
370
-                ? $this->_labels['publishbox'][ $this->_req_action ]
369
+                         && isset($this->_labels['publishbox'][$this->_req_action])
370
+                ? $this->_labels['publishbox'][$this->_req_action]
371 371
                 : $this->_labels['publishbox'];
372 372
             add_meta_box(
373 373
                 'submitdiv',
374 374
                 $box_label,
375 375
                 'post_submit_meta_box',
376
-                $this->_cpt_routes[ $this->_req_action ],
376
+                $this->_cpt_routes[$this->_req_action],
377 377
                 'side',
378 378
                 'core'
379 379
             );
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
                 'page_templates',
385 385
                 __('Page Template', 'event_espresso'),
386 386
                 array($this, 'page_template_meta_box'),
387
-                $this->_cpt_routes[ $this->_req_action ],
387
+                $this->_cpt_routes[$this->_req_action],
388 388
                 'side',
389 389
                 'default'
390 390
             );
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
         // This is for any plugins that are doing things properly
417 417
         // and hooking into the load page hook for core wp cpt routes.
418 418
         global $pagenow;
419
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
420
-        do_action('load-' . $pagenow);
419
+        add_action('load-'.$pagenow, array($this, 'modify_current_screen'), 20);
420
+        do_action('load-'.$pagenow);
421 421
         add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
422 422
         // we route REALLY early.
423 423
         try {
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
                 'admin.php?page=espresso_registrations&action=contact_list',
447 447
             ),
448 448
             1 => array(
449
-                'edit.php?post_type=' . $this->_cpt_object->name,
450
-                'admin.php?page=' . $this->_cpt_object->name,
449
+                'edit.php?post_type='.$this->_cpt_object->name,
450
+                'admin.php?page='.$this->_cpt_object->name,
451 451
             ),
452 452
         );
453 453
         foreach ($routes_to_match as $route_matches) {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
             'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
477 477
         );
478 478
         $cpt_args = $custom_post_types->getDefinitions();
479
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
479
+        $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
480 480
         $cpt_has_support = ! empty($cpt_args['page_templates']);
481 481
 
482 482
         // if the installed version of WP is > 4.7 we do some additional checks.
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
             // if there are $post_templates for this cpt, then we return false for this method because
486 486
             // that means we aren't going to load our page template manager and leave that up to the native
487 487
             // cpt template manager.
488
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
488
+            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
489 489
         }
490 490
 
491 491
         return $cpt_has_support;
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 
560 560
         $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
561 561
         $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
-            ? $statuses[ $this->_cpt_model_obj->status() ]
562
+            ? $statuses[$this->_cpt_model_obj->status()]
563 563
             : '';
564 564
         $template_args = array(
565 565
             'cur_status'            => $this->_cpt_model_obj->status(),
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             $template_args['statuses'] = $statuses;
575 575
         }
576 576
 
577
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
577
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
578 578
         EEH_Template::display_template($template, $template_args);
579 579
     }
580 580
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             : null;
616 616
         $this->_verify_nonce($nonce, 'autosave');
617 617
         // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
618
-        if (! defined('DOING_AUTOSAVE')) {
618
+        if ( ! defined('DOING_AUTOSAVE')) {
619 619
             define('DOING_AUTOSAVE', true);
620 620
         }
621 621
         // if we made it here then the nonce checked out.  Let's run our methods and actions
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
             $this->_template_args['success'] = true;
627 627
         }
628 628
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
629
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
629
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
630 630
         // now let's return json
631 631
         $this->_return_json();
632 632
     }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
             return;
649 649
         }
650 650
         // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
651
-        if (! empty($this->_cpt_object)) {
651
+        if ( ! empty($this->_cpt_object)) {
652 652
             $this->_page_routes = array_merge(
653 653
                 array(
654 654
                     'create_new' => '_create_new_cpt_item',
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
             );
680 680
         }
681 681
         // load the next section only if this is a matching cpt route as set in the cpt routes array.
682
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
682
+        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
683 683
             return;
684 684
         }
685
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
685
+        $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
686 686
         // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
687 687
         if (empty($this->_cpt_object)) {
688 688
             $msg = sprintf(
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
         if (empty($this->_cpt_model_names)
723 723
             || (
724 724
                 ! $ignore_route_check
725
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
725
+                && ! isset($this->_cpt_routes[$this->_req_action])
726 726
             ) || (
727 727
                 $this->_cpt_model_obj instanceof EE_CPT_Base
728 728
                 && $this->_cpt_model_obj->ID() === $id
@@ -739,11 +739,11 @@  discard block
 block discarded – undo
739 739
                 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
740 740
             );
741 741
             $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
742
-            if (isset($model_names[ $post_type ])) {
743
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
742
+            if (isset($model_names[$post_type])) {
743
+                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
744 744
             }
745 745
         } else {
746
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
746
+            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
747 747
         }
748 748
         if ($model instanceof EEM_Base) {
749 749
             $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
         $current_route = isset($this->_req_data['current_route'])
774 774
             ? $this->_req_data['current_route']
775 775
             : 'shouldneverwork';
776
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
777
-            ? $this->_cpt_routes[ $current_route ]
776
+        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
777
+            ? $this->_cpt_routes[$current_route]
778 778
             : '';
779 779
         add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
780 780
         add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
         }
784 784
         // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
785 785
         $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
786
-        if (! empty($revision)) {
786
+        if ( ! empty($revision)) {
787 787
             $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
788 788
             // doing a restore?
789
-            if (! empty($action) && $action === 'restore') {
789
+            if ( ! empty($action) && $action === 'restore') {
790 790
                 // get post for revision
791 791
                 $rev_post = get_post($revision);
792 792
                 $rev_parent = get_post($rev_post->post_parent);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
     {
823 823
         $this->_set_model_object($post_id, true, 'trash');
824 824
         // if our cpt object isn't existent then get out immediately.
825
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
825
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826 826
             return;
827 827
         }
828 828
         $this->trash_cpt_item($post_id);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
     {
841 841
         $this->_set_model_object($post_id, true, 'restore');
842 842
         // if our cpt object isn't existent then get out immediately.
843
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
843
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
844 844
             return;
845 845
         }
846 846
         $this->restore_cpt_item($post_id);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     {
859 859
         $this->_set_model_object($post_id, true, 'delete');
860 860
         // if our cpt object isn't existent then get out immediately.
861
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
861
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862 862
             return;
863 863
         }
864 864
         $this->delete_cpt_item($post_id);
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
     {
878 878
         $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879 879
         // verify event object
880
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
880
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881 881
             throw new EE_Error(
882 882
                 sprintf(
883 883
                     __(
@@ -933,13 +933,13 @@  discard block
 block discarded – undo
933 933
         if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
934 934
             // setup custom post status object for localize script but only if we've got a cpt object
935 935
             $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
936
-            if (! empty($statuses)) {
936
+            if ( ! empty($statuses)) {
937 937
                 // get ALL statuses!
938 938
                 $statuses = $this->_cpt_model_obj->get_all_post_statuses();
939 939
                 // setup object
940 940
                 $ee_cpt_statuses = array();
941 941
                 foreach ($statuses as $status => $label) {
942
-                    $ee_cpt_statuses[ $status ] = array(
942
+                    $ee_cpt_statuses[$status] = array(
943 943
                         'label'      => $label,
944 944
                         'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
945 945
                     );
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
                 $post->page_template = $this->_req_data['page_template'];
1002 1002
                 $page_templates = wp_get_theme()->get_page_templates($post);
1003 1003
             }
1004
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1004
+            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
1005 1005
                 EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1006 1006
             } else {
1007 1007
                 update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
     {
1027 1027
         // only do this if we're actually processing one of our CPTs
1028 1028
         // if our cpt object isn't existent then get out immediately.
1029
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1029
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1030 1030
             return;
1031 1031
         }
1032 1032
         delete_post_meta($post_id, '_wp_trash_meta_status');
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
         // global action
1052 1052
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1053 1053
         // class specific action so you can limit hooking into a specific page.
1054
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1054
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
1055 1055
     }
1056 1056
 
1057 1057
 
@@ -1078,11 +1078,11 @@  discard block
 block discarded – undo
1078 1078
     public function modify_current_screen()
1079 1079
     {
1080 1080
         // ONLY do this if the current page_route IS a cpt route
1081
-        if (! $this->_cpt_route) {
1081
+        if ( ! $this->_cpt_route) {
1082 1082
             return;
1083 1083
         }
1084 1084
         // routing things REALLY early b/c this is a cpt admin page
1085
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1085
+        set_current_screen($this->_cpt_routes[$this->_req_action]);
1086 1086
         $this->_current_screen = get_current_screen();
1087 1087
         $this->_current_screen->base = 'event-espresso';
1088 1088
         $this->_add_help_tabs(); // we make sure we add any help tabs back in!
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
      */
1106 1106
     public function add_custom_editor_default_title($title)
1107 1107
     {
1108
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1109
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1108
+        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1109
+            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1110 1110
             : $title;
1111 1111
     }
1112 1112
 
@@ -1122,10 +1122,10 @@  discard block
 block discarded – undo
1122 1122
      */
1123 1123
     public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1124 1124
     {
1125
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1125
+        if ( ! empty($id) && get_option('permalink_structure') !== '') {
1126 1126
             $post = get_post($id);
1127 1127
             if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1128
-                $shortlink = home_url('?p=' . $post->ID);
1128
+                $shortlink = home_url('?p='.$post->ID);
1129 1129
             }
1130 1130
         }
1131 1131
         return $shortlink;
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
      */
1159 1159
     public function cpt_post_form_hidden_input()
1160 1160
     {
1161
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1161
+        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />';
1162 1162
         // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1163 1163
         echo '<div id="ee-cpt-hidden-inputs">';
1164
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1165
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1164
+        echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />';
1165
+        echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />';
1166 1166
         echo '</div>';
1167 1167
     }
1168 1168
 
@@ -1207,15 +1207,15 @@  discard block
 block discarded – undo
1207 1207
     public function modify_edit_post_link($link, $id, $context)
1208 1208
     {
1209 1209
         $post = get_post($id);
1210
-        if (! isset($this->_req_data['action'])
1211
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1212
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1210
+        if ( ! isset($this->_req_data['action'])
1211
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1212
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1213 1213
         ) {
1214 1214
             return $link;
1215 1215
         }
1216 1216
         $query_args = array(
1217
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1218
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1217
+            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1218
+                ? $this->_cpt_edit_routes[$post->post_type]
1219 1219
                 : 'edit',
1220 1220
             'post'   => $id,
1221 1221
         );
@@ -1238,16 +1238,16 @@  discard block
 block discarded – undo
1238 1238
         $post = get_post($post_id);
1239 1239
 
1240 1240
         if (empty($this->_req_data['action'])
1241
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1241
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1242 1242
             || ! $post instanceof WP_Post
1243
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1243
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1244 1244
         ) {
1245 1245
             return $delete_link;
1246 1246
         }
1247 1247
         $this->_set_model_object($post->ID, true);
1248 1248
 
1249 1249
         // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1250
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1250
+        $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1251 1251
 
1252 1252
         return EE_Admin_Page::add_query_args_and_nonce(
1253 1253
             array(
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
         // we DO have a match so let's setup the url
1276 1276
         // we have to get the post to determine our route
1277 1277
         $post = get_post($post_id);
1278
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1278
+        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1279 1279
         // shared query_args
1280 1280
         $query_args = array('action' => $edit_route, 'post' => $post_id);
1281 1281
         $admin_url = $this->_admin_base_url;
@@ -1347,12 +1347,12 @@  discard block
 block discarded – undo
1347 1347
         /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1348 1348
 
1349 1349
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1350
-        $messages[ $post->post_type ] = array(
1350
+        $messages[$post->post_type] = array(
1351 1351
             0  => '', // Unused. Messages start at index 1.
1352 1352
             1  => sprintf(
1353 1353
                 __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1354 1354
                 $this->_cpt_object->labels->singular_name,
1355
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1355
+                '<a href="'.esc_url(get_permalink($id)).'">',
1356 1356
                 '</a>'
1357 1357
             ),
1358 1358
             2  => __('Custom field updated', 'event_espresso'),
@@ -1367,27 +1367,27 @@  discard block
 block discarded – undo
1367 1367
             6  => sprintf(
1368 1368
                 __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1369 1369
                 $this->_cpt_object->labels->singular_name,
1370
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1370
+                '<a href="'.esc_url(get_permalink($id)).'">',
1371 1371
                 '</a>'
1372 1372
             ),
1373 1373
             7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1374 1374
             8  => sprintf(
1375 1375
                 __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1376 1376
                 $this->_cpt_object->labels->singular_name,
1377
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1377
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1378 1378
                 '</a>'
1379 1379
             ),
1380 1380
             9  => sprintf(
1381 1381
                 __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1382 1382
                 $this->_cpt_object->labels->singular_name,
1383
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1384
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1383
+                '<strong>'.date_i18n('M j, Y @ G:i', strtotime($post->post_date)).'</strong>',
1384
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1385 1385
                 '</a>'
1386 1386
             ),
1387 1387
             10 => sprintf(
1388 1388
                 __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1389 1389
                 $this->_cpt_object->labels->singular_name,
1390
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1390
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1391 1391
                 '</a>'
1392 1392
             ),
1393 1393
         );
@@ -1406,10 +1406,10 @@  discard block
 block discarded – undo
1406 1406
     {
1407 1407
         // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1408 1408
         global $post, $title, $is_IE, $post_type, $post_type_object;
1409
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1409
+        $post_type = $this->_cpt_routes[$this->_req_action];
1410 1410
         $post_type_object = $this->_cpt_object;
1411 1411
         $title = $post_type_object->labels->add_new_item;
1412
-        $post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1412
+        $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1413 1413
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1414 1414
         // modify the default editor title field with default title.
1415 1415
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
@@ -1434,8 +1434,8 @@  discard block
 block discarded – undo
1434 1434
             if ($creating) {
1435 1435
                 wp_enqueue_script('autosave');
1436 1436
             } else {
1437
-                if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1438
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1437
+                if (isset($this->_cpt_routes[$this->_req_data['action']])
1438
+                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1439 1439
                 ) {
1440 1440
                     $create_new_action = apply_filters(
1441 1441
                         'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
                     );
1452 1452
                 }
1453 1453
             }
1454
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1454
+            include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1455 1455
         }
1456 1456
     }
1457 1457
 
@@ -1482,21 +1482,21 @@  discard block
 block discarded – undo
1482 1482
         if (empty($post)) {
1483 1483
             wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1484 1484
         }
1485
-        if (! empty($_GET['get-post-lock'])) {
1485
+        if ( ! empty($_GET['get-post-lock'])) {
1486 1486
             wp_set_post_lock($post_id);
1487 1487
             wp_redirect(get_edit_post_link($post_id, 'url'));
1488 1488
             exit();
1489 1489
         }
1490 1490
 
1491 1491
         // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1492
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1492
+        $post_type = $this->_cpt_routes[$this->_req_action];
1493 1493
         $post_type_object = $this->_cpt_object;
1494 1494
 
1495
-        if (! wp_check_post_lock($post->ID)) {
1495
+        if ( ! wp_check_post_lock($post->ID)) {
1496 1496
             wp_set_post_lock($post->ID);
1497 1497
         }
1498 1498
         add_action('admin_footer', '_admin_notice_post_locked');
1499
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1499
+        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1500 1500
             wp_enqueue_script('admin-comments');
1501 1501
             enqueue_comment_hotkeys_js();
1502 1502
         }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/DateFilterHeader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
                 $text .= '<span class="drk-grey-text">';
71 71
                 $text .= '<span class="dashicons dashicons-calendar"></span>';
72 72
                 $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
73
+                $text .= ' ( '.$datetime->start_date().' )';
74 74
                 $text .= '</span></h3>';
75 75
             }
76 76
         }
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@
 block discarded – undo
23 23
 class DateFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Datetime $datetime_model
28
-     */
29
-    private $datetime_model;
26
+	/**
27
+	 * @var EEM_Datetime $datetime_model
28
+	 */
29
+	private $datetime_model;
30 30
 
31 31
 
32
-    /**
33
-     * DateFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Datetime     $datetime_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->datetime_model = $datetime_model;
42
-    }
32
+	/**
33
+	 * DateFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Datetime     $datetime_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->datetime_model = $datetime_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since 4.10.2.p
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $DTT_ID = $this->request->getRequestParam('DTT_ID');
58
-        $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID);
59
-        $DTT_ID = absint($DTT_ID);
60
-        if ($DTT_ID) {
61
-            $datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
62
-            if ($datetime instanceof EE_Datetime && $text !== '') {
63
-                // remove the closing h3 heading tag if it exists
64
-                $text = str_replace(
65
-                    '</h3>',
66
-                    '',
67
-                    $text
68
-                );
69
-                $text .= '&nbsp; &nbsp; ';
70
-                $text .= '<span class="drk-grey-text">';
71
-                $text .= '<span class="dashicons dashicons-calendar"></span>';
72
-                $text .= $datetime->name();
73
-                $text .= ' ( ' . $datetime->start_date() . ' )';
74
-                $text .= '</span></h3>';
75
-            }
76
-        }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since 4.10.2.p
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$DTT_ID = $this->request->getRequestParam('DTT_ID');
58
+		$DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID);
59
+		$DTT_ID = absint($DTT_ID);
60
+		if ($DTT_ID) {
61
+			$datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
62
+			if ($datetime instanceof EE_Datetime && $text !== '') {
63
+				// remove the closing h3 heading tag if it exists
64
+				$text = str_replace(
65
+					'</h3>',
66
+					'',
67
+					$text
68
+				);
69
+				$text .= '&nbsp; &nbsp; ';
70
+				$text .= '<span class="drk-grey-text">';
71
+				$text .= '<span class="dashicons dashicons-calendar"></span>';
72
+				$text .= $datetime->name();
73
+				$text .= ' ( ' . $datetime->start_date() . ' )';
74
+				$text .= '</span></h3>';
75
+			}
76
+		}
77 77
 
78
-        return $text;
79
-    }
78
+		return $text;
79
+	}
80 80
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/TicketFilterHeader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
         if ($TKT_ID) {
61 61
             $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62 62
             if ($ticket instanceof EE_Ticket) {
63
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
63
+                $ticket_details = '<span class="ee-ticket-name">'.$ticket->name().'</span> ';
64 64
                 $ticket_details .= ! $ticket->is_free()
65
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
65
+                    ? '<span class="ee-ticket-price">'.$ticket->pretty_price().'</span>'
66 66
                     : '<span class="reg-overview-free-event-spn">'
67 67
                       . __('free', 'event_espresso')
68 68
                       . '</span>';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 $text .= '&nbsp; &nbsp; ';
81 81
                 $text .= '<span class="drk-grey-text" style="font-size:.9em;">';
82 82
                 $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
83
-                $text .= $ticket_details . '</span></h3>';
83
+                $text .= $ticket_details.'</span></h3>';
84 84
             }
85 85
         }
86 86
         return $text;
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -23,65 +23,65 @@
 block discarded – undo
23 23
 class TicketFilterHeader extends AdminPageHeaderDecorator
24 24
 {
25 25
 
26
-    /**
27
-     * @var EEM_Ticket $ticket_model
28
-     */
29
-    private $ticket_model;
26
+	/**
27
+	 * @var EEM_Ticket $ticket_model
28
+	 */
29
+	private $ticket_model;
30 30
 
31 31
 
32
-    /**
33
-     * TicketFilterHeader constructor.
34
-     *
35
-     * @param RequestInterface $request
36
-     * @param EEM_Ticket       $ticket_model
37
-     */
38
-    public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
39
-    {
40
-        parent::__construct($request);
41
-        $this->ticket_model = $ticket_model;
42
-    }
32
+	/**
33
+	 * TicketFilterHeader constructor.
34
+	 *
35
+	 * @param RequestInterface $request
36
+	 * @param EEM_Ticket       $ticket_model
37
+	 */
38
+	public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
39
+	{
40
+		parent::__construct($request);
41
+		$this->ticket_model = $ticket_model;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param string $text
47
-     * @return string
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws ReflectionException
53
-     * @since 4.10.2.p
54
-     */
55
-    public function getHeaderText($text = '')
56
-    {
57
-        $TKT_ID = $this->request->getRequestParam('TKT_ID');
58
-        $TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID);
59
-        $TKT_ID = absint($TKT_ID);
60
-        if ($TKT_ID) {
61
-            $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62
-            if ($ticket instanceof EE_Ticket) {
63
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
64
-                $ticket_details .= ! $ticket->is_free()
65
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
66
-                    : '<span class="reg-overview-free-event-spn">'
67
-                      . __('free', 'event_espresso')
68
-                      . '</span>';
69
-                // remove the closing h3 heading tag if it exists
70
-                $text = str_replace(
71
-                    '</h3>',
72
-                    '',
73
-                    $text
74
-                );
75
-                if (empty($text)) {
76
-                    $text = '<h3 style="line-height:1.5em;">';
77
-                    $text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
78
-                }
79
-                $text .= '&nbsp; &nbsp; ';
80
-                $text .= '<span class="drk-grey-text" style="font-size:.9em;">';
81
-                $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
82
-                $text .= $ticket_details . '</span></h3>';
83
-            }
84
-        }
85
-        return $text;
86
-    }
45
+	/**
46
+	 * @param string $text
47
+	 * @return string
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws ReflectionException
53
+	 * @since 4.10.2.p
54
+	 */
55
+	public function getHeaderText($text = '')
56
+	{
57
+		$TKT_ID = $this->request->getRequestParam('TKT_ID');
58
+		$TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID);
59
+		$TKT_ID = absint($TKT_ID);
60
+		if ($TKT_ID) {
61
+			$ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
62
+			if ($ticket instanceof EE_Ticket) {
63
+				$ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
64
+				$ticket_details .= ! $ticket->is_free()
65
+					? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
66
+					: '<span class="reg-overview-free-event-spn">'
67
+					  . __('free', 'event_espresso')
68
+					  . '</span>';
69
+				// remove the closing h3 heading tag if it exists
70
+				$text = str_replace(
71
+					'</h3>',
72
+					'',
73
+					$text
74
+				);
75
+				if (empty($text)) {
76
+					$text = '<h3 style="line-height:1.5em;">';
77
+					$text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
78
+				}
79
+				$text .= '&nbsp; &nbsp; ';
80
+				$text .= '<span class="drk-grey-text" style="font-size:.9em;">';
81
+				$text .= '<span class="dashicons dashicons-tickets-alt"></span>';
82
+				$text .= $ticket_details . '</span></h3>';
83
+			}
84
+		}
85
+		return $text;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
admin/registrations/list_table/page_header/AttendeeFilterHeader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@
 block discarded – undo
59 59
                         'event_espresso'
60 60
                     ),
61 61
                     '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
62
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
63 63
                         array(
64 64
                             'action' => 'edit_attendee',
65 65
                             'post'   => $ATT_ID,
66 66
                         ),
67 67
                         REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
68
+                    ).'">'.$attendee->full_name().'</a>',
69 69
                     '</h3>'
70 70
                 );
71 71
             }
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -20,56 +20,56 @@
 block discarded – undo
20 20
 class AttendeeFilterHeader extends AdminPageHeaderDecorator
21 21
 {
22 22
 
23
-    /**
24
-     * @var EEM_Attendee $attendee_model
25
-     */
26
-    private $attendee_model;
23
+	/**
24
+	 * @var EEM_Attendee $attendee_model
25
+	 */
26
+	private $attendee_model;
27 27
 
28 28
 
29
-    /**
30
-     * AttendeeFilterHeader constructor.
31
-     *
32
-     * @param RequestInterface $request
33
-     * @param EEM_Attendee     $attendee_model
34
-     */
35
-    public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
-    {
37
-        parent::__construct($request);
38
-        $this->attendee_model = $attendee_model;
39
-    }
29
+	/**
30
+	 * AttendeeFilterHeader constructor.
31
+	 *
32
+	 * @param RequestInterface $request
33
+	 * @param EEM_Attendee     $attendee_model
34
+	 */
35
+	public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
36
+	{
37
+		parent::__construct($request);
38
+		$this->attendee_model = $attendee_model;
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * @param string $text
44
-     * @return string
45
-     * @throws EE_Error
46
-     * @since 4.10.2.p
47
-     */
48
-    public function getHeaderText($text = '')
49
-    {
50
-        $ATT_ID = $this->request->getRequestParam('ATT_ID');
51
-        $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID);
52
-        $ATT_ID = absint($ATT_ID);
53
-        if ($ATT_ID) {
54
-            $attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
55
-            if ($attendee instanceof EE_Attendee) {
56
-                $text .= sprintf(
57
-                    esc_html__(
58
-                        '%1$s Viewing registrations for %2$s%3$s',
59
-                        'event_espresso'
60
-                    ),
61
-                    '<h3 style="line-height:1.5em;">',
62
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
63
-                        array(
64
-                            'action' => 'edit_attendee',
65
-                            'post'   => $ATT_ID,
66
-                        ),
67
-                        REG_ADMIN_URL
68
-                    ) . '">' . $attendee->full_name() . '</a>',
69
-                    '</h3>'
70
-                );
71
-            }
72
-        }
73
-        return $text;
74
-    }
42
+	/**
43
+	 * @param string $text
44
+	 * @return string
45
+	 * @throws EE_Error
46
+	 * @since 4.10.2.p
47
+	 */
48
+	public function getHeaderText($text = '')
49
+	{
50
+		$ATT_ID = $this->request->getRequestParam('ATT_ID');
51
+		$ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID);
52
+		$ATT_ID = absint($ATT_ID);
53
+		if ($ATT_ID) {
54
+			$attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
55
+			if ($attendee instanceof EE_Attendee) {
56
+				$text .= sprintf(
57
+					esc_html__(
58
+						'%1$s Viewing registrations for %2$s%3$s',
59
+						'event_espresso'
60
+					),
61
+					'<h3 style="line-height:1.5em;">',
62
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
63
+						array(
64
+							'action' => 'edit_attendee',
65
+							'post'   => $ATT_ID,
66
+						),
67
+						REG_ADMIN_URL
68
+					) . '">' . $attendee->full_name() . '</a>',
69
+					'</h3>'
70
+				);
71
+			}
72
+		}
73
+		return $text;
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4054 added lines, -4054 removed lines patch added patch discarded remove patch
@@ -17,4121 +17,4121 @@
 block discarded – undo
17 17
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    protected $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	protected $loader;
24 24
 
25
-    // set in _init_page_props()
26
-    public $page_slug;
25
+	// set in _init_page_props()
26
+	public $page_slug;
27 27
 
28
-    public $page_label;
28
+	public $page_label;
29 29
 
30
-    public $page_folder;
30
+	public $page_folder;
31 31
 
32
-    // set in define_page_props()
33
-    protected $_admin_base_url;
32
+	// set in define_page_props()
33
+	protected $_admin_base_url;
34 34
 
35
-    protected $_admin_base_path;
35
+	protected $_admin_base_path;
36 36
 
37
-    protected $_admin_page_title;
37
+	protected $_admin_page_title;
38 38
 
39
-    protected $_labels;
39
+	protected $_labels;
40 40
 
41 41
 
42
-    // set early within EE_Admin_Init
43
-    protected $_wp_page_slug;
42
+	// set early within EE_Admin_Init
43
+	protected $_wp_page_slug;
44 44
 
45
-    // navtabs
46
-    protected $_nav_tabs;
45
+	// navtabs
46
+	protected $_nav_tabs;
47 47
 
48
-    protected $_default_nav_tab_name;
48
+	protected $_default_nav_tab_name;
49 49
 
50
-    /**
51
-     * @var array $_help_tour
52
-     */
53
-    protected $_help_tour = array();
50
+	/**
51
+	 * @var array $_help_tour
52
+	 */
53
+	protected $_help_tour = array();
54 54
 
55 55
 
56
-    // template variables (used by templates)
57
-    protected $_template_path;
56
+	// template variables (used by templates)
57
+	protected $_template_path;
58 58
 
59
-    protected $_column_template_path;
59
+	protected $_column_template_path;
60 60
 
61
-    /**
62
-     * @var array $_template_args
63
-     */
64
-    protected $_template_args = array();
61
+	/**
62
+	 * @var array $_template_args
63
+	 */
64
+	protected $_template_args = array();
65 65
 
66
-    /**
67
-     * this will hold the list table object for a given view.
68
-     *
69
-     * @var EE_Admin_List_Table $_list_table_object
70
-     */
71
-    protected $_list_table_object;
66
+	/**
67
+	 * this will hold the list table object for a given view.
68
+	 *
69
+	 * @var EE_Admin_List_Table $_list_table_object
70
+	 */
71
+	protected $_list_table_object;
72 72
 
73
-    // bools
74
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
73
+	// bools
74
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
75 75
 
76
-    protected $_routing;
76
+	protected $_routing;
77 77
 
78
-    // list table args
79
-    protected $_view;
78
+	// list table args
79
+	protected $_view;
80 80
 
81
-    protected $_views;
81
+	protected $_views;
82 82
 
83 83
 
84
-    // action => method pairs used for routing incoming requests
85
-    protected $_page_routes;
84
+	// action => method pairs used for routing incoming requests
85
+	protected $_page_routes;
86 86
 
87
-    /**
88
-     * @var array $_page_config
89
-     */
90
-    protected $_page_config;
87
+	/**
88
+	 * @var array $_page_config
89
+	 */
90
+	protected $_page_config;
91 91
 
92
-    /**
93
-     * the current page route and route config
94
-     *
95
-     * @var string $_route
96
-     */
97
-    protected $_route;
92
+	/**
93
+	 * the current page route and route config
94
+	 *
95
+	 * @var string $_route
96
+	 */
97
+	protected $_route;
98 98
 
99
-    /**
100
-     * @var string $_cpt_route
101
-     */
102
-    protected $_cpt_route;
99
+	/**
100
+	 * @var string $_cpt_route
101
+	 */
102
+	protected $_cpt_route;
103 103
 
104
-    /**
105
-     * @var array $_route_config
106
-     */
107
-    protected $_route_config;
108
-
109
-    /**
110
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
-     * actions.
112
-     *
113
-     * @since 4.6.x
114
-     * @var array.
115
-     */
116
-    protected $_default_route_query_args;
117
-
118
-    // set via request page and action args.
119
-    protected $_current_page;
120
-
121
-    protected $_current_view;
122
-
123
-    protected $_current_page_view_url;
124
-
125
-    // sanitized request action (and nonce)
126
-
127
-    /**
128
-     * @var string $_req_action
129
-     */
130
-    protected $_req_action;
131
-
132
-    /**
133
-     * @var string $_req_nonce
134
-     */
135
-    protected $_req_nonce;
136
-
137
-    // search related
138
-    protected $_search_btn_label;
139
-
140
-    protected $_search_box_callback;
141
-
142
-    /**
143
-     * WP Current Screen object
144
-     *
145
-     * @var WP_Screen
146
-     */
147
-    protected $_current_screen;
148
-
149
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
-    protected $_hook_obj;
151
-
152
-    // for holding incoming request data
153
-    protected $_req_data;
154
-
155
-    // yes / no array for admin form fields
156
-    protected $_yes_no_values = array();
157
-
158
-    // some default things shared by all child classes
159
-    protected $_default_espresso_metaboxes;
160
-
161
-    /**
162
-     *    EE_Registry Object
163
-     *
164
-     * @var    EE_Registry
165
-     */
166
-    protected $EE = null;
167
-
168
-
169
-    /**
170
-     * This is just a property that flags whether the given route is a caffeinated route or not.
171
-     *
172
-     * @var boolean
173
-     */
174
-    protected $_is_caf = false;
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws ReflectionException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function __construct($routing = true)
187
-    {
188
-        $this->loader = LoaderFactory::getLoader();
189
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
-            $this->_is_caf = true;
191
-        }
192
-        $this->_yes_no_values = array(
193
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
-        );
196
-        // set the _req_data property.
197
-        $this->_req_data = array_merge($_GET, $_POST);
198
-        // routing enabled?
199
-        $this->_routing = $routing;
200
-        // set initial page props (child method)
201
-        $this->_init_page_props();
202
-        // set global defaults
203
-        $this->_set_defaults();
204
-        // set early because incoming requests could be ajax related and we need to register those hooks.
205
-        $this->_global_ajax_hooks();
206
-        $this->_ajax_hooks();
207
-        // other_page_hooks have to be early too.
208
-        $this->_do_other_page_hooks();
209
-        // This just allows us to have extending classes do something specific
210
-        // before the parent constructor runs _page_setup().
211
-        if (method_exists($this, '_before_page_setup')) {
212
-            $this->_before_page_setup();
213
-        }
214
-        // set up page dependencies
215
-        $this->_page_setup();
216
-    }
217
-
218
-
219
-    /**
220
-     * _init_page_props
221
-     * Child classes use to set at least the following properties:
222
-     * $page_slug.
223
-     * $page_label.
224
-     *
225
-     * @abstract
226
-     * @return void
227
-     */
228
-    abstract protected function _init_page_props();
229
-
230
-
231
-    /**
232
-     * _ajax_hooks
233
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
-     * Note: within the ajax callback methods.
235
-     *
236
-     * @abstract
237
-     * @return void
238
-     */
239
-    abstract protected function _ajax_hooks();
240
-
241
-
242
-    /**
243
-     * _define_page_props
244
-     * child classes define page properties in here.  Must include at least:
245
-     * $_admin_base_url = base_url for all admin pages
246
-     * $_admin_page_title = default admin_page_title for admin pages
247
-     * $_labels = array of default labels for various automatically generated elements:
248
-     *    array(
249
-     *        'buttons' => array(
250
-     *            'add' => esc_html__('label for add new button'),
251
-     *            'edit' => esc_html__('label for edit button'),
252
-     *            'delete' => esc_html__('label for delete button')
253
-     *            )
254
-     *        )
255
-     *
256
-     * @abstract
257
-     * @return void
258
-     */
259
-    abstract protected function _define_page_props();
260
-
261
-
262
-    /**
263
-     * _set_page_routes
264
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
-     * have a 'default' route. Here's the format
267
-     * $this->_page_routes = array(
268
-     *        'default' => array(
269
-     *            'func' => '_default_method_handling_route',
270
-     *            'args' => array('array','of','args'),
271
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
-     *            ajax request, backend processing)
273
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
-     *            headers route after.  The string you enter here should match the defined route reference for a
275
-     *            headers sent route.
276
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
-     *            this route.
278
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
-     *            checks).
280
-     *        ),
281
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
-     *        handling method.
283
-     *        )
284
-     * )
285
-     *
286
-     * @abstract
287
-     * @return void
288
-     */
289
-    abstract protected function _set_page_routes();
290
-
291
-
292
-    /**
293
-     * _set_page_config
294
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
-     * array corresponds to the page_route for the loaded page. Format:
296
-     * $this->_page_config = array(
297
-     *        'default' => array(
298
-     *            'labels' => array(
299
-     *                'buttons' => array(
300
-     *                    'add' => esc_html__('label for adding item'),
301
-     *                    'edit' => esc_html__('label for editing item'),
302
-     *                    'delete' => esc_html__('label for deleting item')
303
-     *                ),
304
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
-     *            _define_page_props() method
308
-     *            'nav' => array(
309
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
-     *                'order' => 10, //required to indicate tab position.
313
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
-     *                displayed then add this parameter.
315
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
-     *            metaboxes set for eventespresso admin pages.
318
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
-     *            want to display.
327
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
328
-     *                'tab_id' => array(
329
-     *                    'title' => 'tab_title',
330
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
-     *                    attempt to use the callback which should match the name of a method in the class
336
-     *                    ),
337
-     *                'tab2_id' => array(
338
-     *                    'title' => 'tab2 title',
339
-     *                    'filename' => 'file_name_2'
340
-     *                    'callback' => 'callback_method_for_content',
341
-     *                 ),
342
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
-     *            help tab area on an admin page. @link
344
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
-     *            'help_tour' => array(
346
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
-     *            ),
350
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
-     *            just set
353
-     *            'require_nonce' to FALSE
354
-     *            )
355
-     * )
356
-     *
357
-     * @abstract
358
-     * @return void
359
-     */
360
-    abstract protected function _set_page_config();
361
-
362
-
363
-
364
-
365
-
366
-    /** end sample help_tour methods **/
367
-    /**
368
-     * _add_screen_options
369
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
-     * to a particular view.
372
-     *
373
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
-     *         see also WP_Screen object documents...
375
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
-     * @abstract
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-    /**
383
-     * _add_feature_pointers
384
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
-     * extended) also see:
389
-     *
390
-     * @link   http://eamann.com/tech/wordpress-portland/
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _add_feature_pointers();
395
-
396
-
397
-    /**
398
-     * load_scripts_styles
399
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
-     * scripts/styles per view by putting them in a dynamic function in this format
402
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
-     *
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract public function load_scripts_styles();
408
-
409
-
410
-    /**
411
-     * admin_init
412
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
-     * all pages/views loaded by child class.
414
-     *
415
-     * @abstract
416
-     * @return void
417
-     */
418
-    abstract public function admin_init();
419
-
420
-
421
-    /**
422
-     * admin_notices
423
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
-     * all pages/views loaded by child class.
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function admin_notices();
430
-
431
-
432
-    /**
433
-     * admin_footer_scripts
434
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
-     * will apply to all pages/views loaded by child class.
436
-     *
437
-     * @return void
438
-     */
439
-    abstract public function admin_footer_scripts();
440
-
441
-
442
-    /**
443
-     * admin_footer
444
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
-     * apply to all pages/views loaded by child class.
446
-     *
447
-     * @return void
448
-     */
449
-    public function admin_footer()
450
-    {
451
-    }
452
-
453
-
454
-    /**
455
-     * _global_ajax_hooks
456
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
-     * Note: within the ajax callback methods.
458
-     *
459
-     * @abstract
460
-     * @return void
461
-     */
462
-    protected function _global_ajax_hooks()
463
-    {
464
-        // for lazy loading of metabox content
465
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
-    }
467
-
468
-
469
-    public function ajax_metabox_content()
470
-    {
471
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
-        self::cached_rss_display($contentid, $url);
474
-        wp_die();
475
-    }
476
-
477
-
478
-    /**
479
-     * _page_setup
480
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
-     * doesn't match the object.
482
-     *
483
-     * @final
484
-     * @return void
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws ReflectionException
488
-     * @throws InvalidDataTypeException
489
-     * @throws InvalidInterfaceException
490
-     */
491
-    final protected function _page_setup()
492
-    {
493
-        // requires?
494
-        // admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
496
-        // next verify if we need to load anything...
497
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
-        $this->page_folder = strtolower(
499
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
-        );
501
-        global $ee_menu_slugs;
502
-        $ee_menu_slugs = (array) $ee_menu_slugs;
503
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
-            return;
505
-        }
506
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
-                ? $this->_req_data['action2']
510
-                : $this->_req_data['action'];
511
-        }
512
-        // then set blank or -1 action values to 'default'
513
-        $this->_req_action = isset($this->_req_data['action'])
514
-                             && ! empty($this->_req_data['action'])
515
-                             && $this->_req_data['action'] !== '-1'
516
-            ? sanitize_key($this->_req_data['action'])
517
-            : 'default';
518
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
520
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
-            ? $this->_req_data['route'] : $this->_req_action;
522
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
-            ? $this->_req_data['route']
525
-            : $this->_req_action;
526
-        $this->_current_view = $this->_req_action;
527
-        $this->_req_nonce = $this->_req_action . '_nonce';
528
-        $this->_define_page_props();
529
-        $this->_current_page_view_url = add_query_arg(
530
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
531
-            $this->_admin_base_url
532
-        );
533
-        // default things
534
-        $this->_default_espresso_metaboxes = array(
535
-            '_espresso_news_post_box',
536
-            '_espresso_links_post_box',
537
-            '_espresso_ratings_request',
538
-            '_espresso_sponsors_post_box',
539
-        );
540
-        // set page configs
541
-        $this->_set_page_routes();
542
-        $this->_set_page_config();
543
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
544
-        if (isset($this->_req_data['wp_referer'])) {
545
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
-        }
547
-        // for caffeinated and other extended functionality.
548
-        //  If there is a _extend_page_config method
549
-        // then let's run that to modify the all the various page configuration arrays
550
-        if (method_exists($this, '_extend_page_config')) {
551
-            $this->_extend_page_config();
552
-        }
553
-        // for CPT and other extended functionality.
554
-        // If there is an _extend_page_config_for_cpt
555
-        // then let's run that to modify all the various page configuration arrays.
556
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
557
-            $this->_extend_page_config_for_cpt();
558
-        }
559
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
560
-        $this->_page_routes = apply_filters(
561
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
-            $this->_page_routes,
563
-            $this
564
-        );
565
-        $this->_page_config = apply_filters(
566
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
567
-            $this->_page_config,
568
-            $this
569
-        );
570
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
-            add_action(
574
-                'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
-                10,
577
-                2
578
-            );
579
-        }
580
-        // next route only if routing enabled
581
-        if ($this->_routing && ! defined('DOING_AJAX')) {
582
-            $this->_verify_routes();
583
-            // next let's just check user_access and kill if no access
584
-            $this->check_user_access();
585
-            if ($this->_is_UI_request) {
586
-                // admin_init stuff - global, all views for this page class, specific view
587
-                add_action('admin_init', array($this, 'admin_init'), 10);
588
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
-                }
591
-            } else {
592
-                // hijack regular WP loading and route admin request immediately
593
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
-                $this->route_admin_request();
595
-            }
596
-        }
597
-    }
598
-
599
-
600
-    /**
601
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
-     *
603
-     * @return void
604
-     * @throws ReflectionException
605
-     * @throws EE_Error
606
-     */
607
-    private function _do_other_page_hooks()
608
-    {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
-        foreach ($registered_pages as $page) {
611
-            // now let's setup the file name and class that should be present
612
-            $classname = str_replace('.class.php', '', $page);
613
-            // autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
615
-                $error_msg[] = sprintf(
616
-                    esc_html__(
617
-                        'Something went wrong with loading the %s admin hooks page.',
618
-                        'event_espresso'
619
-                    ),
620
-                    $page
621
-                );
622
-                $error_msg[] = $error_msg[0]
623
-                               . "\r\n"
624
-                               . sprintf(
625
-                                   esc_html__(
626
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
627
-                                       'event_espresso'
628
-                                   ),
629
-                                   $page,
630
-                                   '<br />',
631
-                                   '<strong>' . $classname . '</strong>'
632
-                               );
633
-                throw new EE_Error(implode('||', $error_msg));
634
-            }
635
-            $a = new ReflectionClass($classname);
636
-            // notice we are passing the instance of this class to the hook object.
637
-            $hookobj[] = $a->newInstance($this);
638
-        }
639
-    }
640
-
641
-
642
-    public function load_page_dependencies()
643
-    {
644
-        try {
645
-            $this->_load_page_dependencies();
646
-        } catch (EE_Error $e) {
647
-            $e->get_error();
648
-        }
649
-    }
650
-
651
-
652
-    /**
653
-     * load_page_dependencies
654
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
-     *
656
-     * @return void
657
-     * @throws DomainException
658
-     * @throws EE_Error
659
-     * @throws InvalidArgumentException
660
-     * @throws InvalidDataTypeException
661
-     * @throws InvalidInterfaceException
662
-     * @throws ReflectionException
663
-     */
664
-    protected function _load_page_dependencies()
665
-    {
666
-        // let's set the current_screen and screen options to override what WP set
667
-        $this->_current_screen = get_current_screen();
668
-        // load admin_notices - global, page class, and view specific
669
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
671
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
-        }
674
-        // load network admin_notices - global, page class, and view specific
675
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
-        }
679
-        // this will save any per_page screen options if they are present
680
-        $this->_set_per_page_screen_options();
681
-        // setup list table properties
682
-        $this->_set_list_table();
683
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
-        // However in some cases the metaboxes will need to be added within a route handling callback.
685
-        $this->_add_registered_meta_boxes();
686
-        $this->_add_screen_columns();
687
-        // add screen options - global, page child class, and view specific
688
-        $this->_add_global_screen_options();
689
-        $this->_add_screen_options();
690
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
691
-        if (method_exists($this, $add_screen_options)) {
692
-            $this->{$add_screen_options}();
693
-        }
694
-        // add help tab(s) and tours- set via page_config and qtips.
695
-        $this->_add_help_tour();
696
-        $this->_add_help_tabs();
697
-        $this->_add_qtips();
698
-        // add feature_pointers - global, page child class, and view specific
699
-        $this->_add_feature_pointers();
700
-        $this->_add_global_feature_pointers();
701
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
-        if (method_exists($this, $add_feature_pointer)) {
703
-            $this->{$add_feature_pointer}();
704
-        }
705
-        // enqueue scripts/styles - global, page class, and view specific
706
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
-        }
711
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
-        // admin_print_footer_scripts - global, page child class, and view specific.
713
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
-        // is a good use case. Notice the late priority we're giving these
716
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
-        }
721
-        // admin footer scripts
722
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
724
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
-        }
727
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
-        // targeted hook
729
-        do_action(
730
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
-        );
732
-    }
733
-
734
-
735
-    /**
736
-     * _set_defaults
737
-     * This sets some global defaults for class properties.
738
-     */
739
-    private function _set_defaults()
740
-    {
741
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
743
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
-        $this->_page_config = $this->_default_route_query_args = array();
745
-        $this->_default_nav_tab_name = 'overview';
746
-        // init template args
747
-        $this->_template_args = array(
748
-            'admin_page_header'  => '',
749
-            'admin_page_content' => '',
750
-            'post_body_content'  => '',
751
-            'before_list_table'  => '',
752
-            'after_list_table'   => '',
753
-        );
754
-    }
755
-
756
-
757
-    /**
758
-     * route_admin_request
759
-     *
760
-     * @see    _route_admin_request()
761
-     * @return exception|void error
762
-     * @throws InvalidArgumentException
763
-     * @throws InvalidInterfaceException
764
-     * @throws InvalidDataTypeException
765
-     * @throws EE_Error
766
-     * @throws ReflectionException
767
-     */
768
-    public function route_admin_request()
769
-    {
770
-        try {
771
-            $this->_route_admin_request();
772
-        } catch (EE_Error $e) {
773
-            $e->get_error();
774
-        }
775
-    }
776
-
777
-
778
-    public function set_wp_page_slug($wp_page_slug)
779
-    {
780
-        $this->_wp_page_slug = $wp_page_slug;
781
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
-        if (is_network_admin()) {
783
-            $this->_wp_page_slug .= '-network';
784
-        }
785
-    }
786
-
787
-
788
-    /**
789
-     * _verify_routes
790
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
-     * we know if we need to drop out.
792
-     *
793
-     * @return bool
794
-     * @throws EE_Error
795
-     */
796
-    protected function _verify_routes()
797
-    {
798
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
-            return false;
801
-        }
802
-        $this->_route = false;
803
-        // check that the page_routes array is not empty
804
-        if (empty($this->_page_routes)) {
805
-            // user error msg
806
-            $error_msg = sprintf(
807
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
-                $this->_admin_page_title
809
-            );
810
-            // developer error msg
811
-            $error_msg .= '||' . $error_msg
812
-                          . esc_html__(
813
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
-                              'event_espresso'
815
-                          );
816
-            throw new EE_Error($error_msg);
817
-        }
818
-        // and that the requested page route exists
819
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
-            $this->_route = $this->_page_routes[ $this->_req_action ];
821
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
-                ? $this->_page_config[ $this->_req_action ] : array();
823
-        } else {
824
-            // user error msg
825
-            $error_msg = sprintf(
826
-                esc_html__(
827
-                    'The requested page route does not exist for the %s admin page.',
828
-                    'event_espresso'
829
-                ),
830
-                $this->_admin_page_title
831
-            );
832
-            // developer error msg
833
-            $error_msg .= '||' . $error_msg
834
-                          . sprintf(
835
-                              esc_html__(
836
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
-                                  'event_espresso'
838
-                              ),
839
-                              $this->_req_action
840
-                          );
841
-            throw new EE_Error($error_msg);
842
-        }
843
-        // and that a default route exists
844
-        if (! array_key_exists('default', $this->_page_routes)) {
845
-            // user error msg
846
-            $error_msg = sprintf(
847
-                esc_html__(
848
-                    'A default page route has not been set for the % admin page.',
849
-                    'event_espresso'
850
-                ),
851
-                $this->_admin_page_title
852
-            );
853
-            // developer error msg
854
-            $error_msg .= '||' . $error_msg
855
-                          . esc_html__(
856
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
-                              'event_espresso'
858
-                          );
859
-            throw new EE_Error($error_msg);
860
-        }
861
-        // first lets' catch if the UI request has EVER been set.
862
-        if ($this->_is_UI_request === null) {
863
-            // lets set if this is a UI request or not.
864
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
-            // wait a minute... we might have a noheader in the route array
866
-            $this->_is_UI_request = is_array($this->_route)
867
-                                    && isset($this->_route['noheader'])
868
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
869
-        }
870
-        $this->_set_current_labels();
871
-        return true;
872
-    }
873
-
874
-
875
-    /**
876
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
-     *
878
-     * @param  string $route the route name we're verifying
879
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
-     * @throws EE_Error
881
-     */
882
-    protected function _verify_route($route)
883
-    {
884
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
-            return true;
886
-        }
887
-        // user error msg
888
-        $error_msg = sprintf(
889
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
-            $this->_admin_page_title
891
-        );
892
-        // developer error msg
893
-        $error_msg .= '||' . $error_msg
894
-                      . sprintf(
895
-                          esc_html__(
896
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
-                              'event_espresso'
898
-                          ),
899
-                          $route
900
-                      );
901
-        throw new EE_Error($error_msg);
902
-    }
903
-
904
-
905
-    /**
906
-     * perform nonce verification
907
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
-     * using this method (and save retyping!)
909
-     *
910
-     * @param  string $nonce     The nonce sent
911
-     * @param  string $nonce_ref The nonce reference string (name0)
912
-     * @return void
913
-     * @throws EE_Error
914
-     */
915
-    protected function _verify_nonce($nonce, $nonce_ref)
916
-    {
917
-        // verify nonce against expected value
918
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
-            // these are not the droids you are looking for !!!
920
-            $msg = sprintf(
921
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
-                '</a>'
924
-            );
925
-            if (WP_DEBUG) {
926
-                $msg .= "\n  "
927
-                        . sprintf(
928
-                            esc_html__(
929
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
-                                'event_espresso'
931
-                            ),
932
-                            __CLASS__
933
-                        );
934
-            }
935
-            if (! defined('DOING_AJAX')) {
936
-                wp_die($msg);
937
-            } else {
938
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
-                $this->_return_json();
940
-            }
941
-        }
942
-    }
943
-
944
-
945
-    /**
946
-     * _route_admin_request()
947
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
-     * in the page routes and then will try to load the corresponding method.
950
-     *
951
-     * @return void
952
-     * @throws EE_Error
953
-     * @throws InvalidArgumentException
954
-     * @throws InvalidDataTypeException
955
-     * @throws InvalidInterfaceException
956
-     * @throws ReflectionException
957
-     */
958
-    protected function _route_admin_request()
959
-    {
960
-        if (! $this->_is_UI_request) {
961
-            $this->_verify_routes();
962
-        }
963
-        $nonce_check = isset($this->_route_config['require_nonce'])
964
-            ? $this->_route_config['require_nonce']
965
-            : true;
966
-        if ($this->_req_action !== 'default' && $nonce_check) {
967
-            // set nonce from post data
968
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
969
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
-                : '';
971
-            $this->_verify_nonce($nonce, $this->_req_nonce);
972
-        }
973
-        // set the nav_tabs array but ONLY if this is  UI_request
974
-        if ($this->_is_UI_request) {
975
-            $this->_set_nav_tabs();
976
-        }
977
-        // grab callback function
978
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
-        // check if callback has args
980
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
-        $error_msg = '';
982
-        // action right before calling route
983
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
-        }
987
-        // right before calling the route, let's remove _wp_http_referer from the
988
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
990
-            '_wp_http_referer',
991
-            wp_unslash($_SERVER['REQUEST_URI'])
992
-        );
993
-        if (! empty($func)) {
994
-            if (is_array($func)) {
995
-                list($class, $method) = $func;
996
-            } elseif (strpos($func, '::') !== false) {
997
-                list($class, $method) = explode('::', $func);
998
-            } else {
999
-                $class = $this;
1000
-                $method = $func;
1001
-            }
1002
-            if (! (is_object($class) && $class === $this)) {
1003
-                // send along this admin page object for access by addons.
1004
-                $args['admin_page_object'] = $this;
1005
-            }
1006
-            if (// is it a method on a class that doesn't work?
1007
-                (
1008
-                    (
1009
-                        method_exists($class, $method)
1010
-                        && call_user_func_array(array($class, $method), $args) === false
1011
-                    )
1012
-                    && (
1013
-                        // is it a standalone function that doesn't work?
1014
-                        function_exists($method)
1015
-                        && call_user_func_array(
1016
-                            $func,
1017
-                            array_merge(array('admin_page_object' => $this), $args)
1018
-                        ) === false
1019
-                    )
1020
-                )
1021
-                || (
1022
-                    // is it neither a class method NOR a standalone function?
1023
-                    ! method_exists($class, $method)
1024
-                    && ! function_exists($method)
1025
-                )
1026
-            ) {
1027
-                // user error msg
1028
-                $error_msg = esc_html__(
1029
-                    'An error occurred. The  requested page route could not be found.',
1030
-                    'event_espresso'
1031
-                );
1032
-                // developer error msg
1033
-                $error_msg .= '||';
1034
-                $error_msg .= sprintf(
1035
-                    esc_html__(
1036
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
-                        'event_espresso'
1038
-                    ),
1039
-                    $method
1040
-                );
1041
-            }
1042
-            if (! empty($error_msg)) {
1043
-                throw new EE_Error($error_msg);
1044
-            }
1045
-        }
1046
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1047
-        // then we need to reset the routing properties to the new route.
1048
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1049
-        if ($this->_is_UI_request === false
1050
-            && is_array($this->_route)
1051
-            && ! empty($this->_route['headers_sent_route'])
1052
-        ) {
1053
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
-        }
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * This method just allows the resetting of page properties in the case where a no headers
1060
-     * route redirects to a headers route in its route config.
1061
-     *
1062
-     * @since   4.3.0
1063
-     * @param  string $new_route New (non header) route to redirect to.
1064
-     * @return   void
1065
-     * @throws ReflectionException
1066
-     * @throws InvalidArgumentException
1067
-     * @throws InvalidInterfaceException
1068
-     * @throws InvalidDataTypeException
1069
-     * @throws EE_Error
1070
-     */
1071
-    protected function _reset_routing_properties($new_route)
1072
-    {
1073
-        $this->_is_UI_request = true;
1074
-        // now we set the current route to whatever the headers_sent_route is set at
1075
-        $this->_req_data['action'] = $new_route;
1076
-        // rerun page setup
1077
-        $this->_page_setup();
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * _add_query_arg
1083
-     * adds nonce to array of arguments then calls WP add_query_arg function
1084
-     *(internally just uses EEH_URL's function with the same name)
1085
-     *
1086
-     * @param array  $args
1087
-     * @param string $url
1088
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
-     *                                        Example usage: If the current page is:
1091
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
-     *                                        &action=default&event_id=20&month_range=March%202015
1093
-     *                                        &_wpnonce=5467821
1094
-     *                                        and you call:
1095
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
-     *                                        array(
1097
-     *                                        'action' => 'resend_something',
1098
-     *                                        'page=>espresso_registrations'
1099
-     *                                        ),
1100
-     *                                        $some_url,
1101
-     *                                        true
1102
-     *                                        );
1103
-     *                                        It will produce a url in this structure:
1104
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
-     *                                        month_range]=March%202015
1107
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
-     * @return string
1109
-     */
1110
-    public static function add_query_args_and_nonce(
1111
-        $args = array(),
1112
-        $url = false,
1113
-        $sticky = false,
1114
-        $exclude_nonce = false
1115
-    ) {
1116
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
-        if ($sticky) {
1118
-            $request = $_REQUEST;
1119
-            unset($request['_wp_http_referer']);
1120
-            unset($request['wp_referer']);
1121
-            foreach ($request as $key => $value) {
1122
-                // do not add nonces
1123
-                if (strpos($key, 'nonce') !== false) {
1124
-                    continue;
1125
-                }
1126
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1127
-            }
1128
-        }
1129
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * This returns a generated link that will load the related help tab.
1135
-     *
1136
-     * @param  string $help_tab_id the id for the connected help tab
1137
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
-     * @uses EEH_Template::get_help_tab_link()
1140
-     * @return string              generated link
1141
-     */
1142
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
-    {
1144
-        return EEH_Template::get_help_tab_link(
1145
-            $help_tab_id,
1146
-            $this->page_slug,
1147
-            $this->_req_action,
1148
-            $icon_style,
1149
-            $help_text
1150
-        );
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * _add_help_tabs
1156
-     * Note child classes define their help tabs within the page_config array.
1157
-     *
1158
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
-     * @return void
1160
-     * @throws DomainException
1161
-     * @throws EE_Error
1162
-     */
1163
-    protected function _add_help_tabs()
1164
-    {
1165
-        $tour_buttons = '';
1166
-        if (isset($this->_page_config[ $this->_req_action ])) {
1167
-            $config = $this->_page_config[ $this->_req_action ];
1168
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1169
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1170
-                $tb = array();
1171
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1172
-                foreach ($this->_help_tour['tours'] as $tour) {
1173
-                    // if this is the end tour then we don't need to setup a button
1174
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1175
-                        continue;
1176
-                    }
1177
-                    $tb[] = '<button id="trigger-tour-'
1178
-                            . $tour->get_slug()
1179
-                            . '" class="button-primary trigger-ee-help-tour">'
1180
-                            . $tour->get_label()
1181
-                            . '</button>';
1182
-                }
1183
-                $tour_buttons .= implode('<br />', $tb);
1184
-                $tour_buttons .= '</div></div>';
1185
-            }
1186
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1187
-            if (is_array($config) && isset($config['help_sidebar'])) {
1188
-                // check that the callback given is valid
1189
-                if (! method_exists($this, $config['help_sidebar'])) {
1190
-                    throw new EE_Error(
1191
-                        sprintf(
1192
-                            esc_html__(
1193
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1194
-                                'event_espresso'
1195
-                            ),
1196
-                            $config['help_sidebar'],
1197
-                            get_class($this)
1198
-                        )
1199
-                    );
1200
-                }
1201
-                $content = apply_filters(
1202
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1203
-                    $this->{$config['help_sidebar']}()
1204
-                );
1205
-                $content .= $tour_buttons; // add help tour buttons.
1206
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1207
-                $this->_current_screen->set_help_sidebar($content);
1208
-            }
1209
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1210
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1211
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1212
-            }
1213
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1214
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1215
-                $_ht['id'] = $this->page_slug;
1216
-                $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1217
-                $_ht['content'] = '<p>'
1218
-                                  . esc_html__(
1219
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1220
-                                      'event_espresso'
1221
-                                  ) . '</p>';
1222
-                $this->_current_screen->add_help_tab($_ht);
1223
-            }
1224
-            if (! isset($config['help_tabs'])) {
1225
-                return;
1226
-            } //no help tabs for this route
1227
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1228
-                // we're here so there ARE help tabs!
1229
-                // make sure we've got what we need
1230
-                if (! isset($cfg['title'])) {
1231
-                    throw new EE_Error(
1232
-                        esc_html__(
1233
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1234
-                            'event_espresso'
1235
-                        )
1236
-                    );
1237
-                }
1238
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1239
-                    throw new EE_Error(
1240
-                        esc_html__(
1241
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1242
-                            'event_espresso'
1243
-                        )
1244
-                    );
1245
-                }
1246
-                // first priority goes to content.
1247
-                if (! empty($cfg['content'])) {
1248
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1249
-                    // second priority goes to filename
1250
-                } elseif (! empty($cfg['filename'])) {
1251
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1252
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1253
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1254
-                                                             . basename($this->_get_dir())
1255
-                                                             . '/help_tabs/'
1256
-                                                             . $cfg['filename']
1257
-                                                             . '.help_tab.php' : $file_path;
1258
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1259
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1260
-                        EE_Error::add_error(
1261
-                            sprintf(
1262
-                                esc_html__(
1263
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1264
-                                    'event_espresso'
1265
-                                ),
1266
-                                $tab_id,
1267
-                                key($config),
1268
-                                $file_path
1269
-                            ),
1270
-                            __FILE__,
1271
-                            __FUNCTION__,
1272
-                            __LINE__
1273
-                        );
1274
-                        return;
1275
-                    }
1276
-                    $template_args['admin_page_obj'] = $this;
1277
-                    $content = EEH_Template::display_template(
1278
-                        $file_path,
1279
-                        $template_args,
1280
-                        true
1281
-                    );
1282
-                } else {
1283
-                    $content = '';
1284
-                }
1285
-                // check if callback is valid
1286
-                if (empty($content) && (
1287
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1288
-                    )
1289
-                ) {
1290
-                    EE_Error::add_error(
1291
-                        sprintf(
1292
-                            esc_html__(
1293
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1294
-                                'event_espresso'
1295
-                            ),
1296
-                            $cfg['title']
1297
-                        ),
1298
-                        __FILE__,
1299
-                        __FUNCTION__,
1300
-                        __LINE__
1301
-                    );
1302
-                    return;
1303
-                }
1304
-                // setup config array for help tab method
1305
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1306
-                $_ht = array(
1307
-                    'id'       => $id,
1308
-                    'title'    => $cfg['title'],
1309
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1310
-                    'content'  => $content,
1311
-                );
1312
-                $this->_current_screen->add_help_tab($_ht);
1313
-            }
1314
-        }
1315
-    }
1316
-
1317
-
1318
-    /**
1319
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1320
-     * an array with properties for setting up usage of the joyride plugin
1321
-     *
1322
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1323
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1324
-     *         _set_page_config() comments
1325
-     * @return void
1326
-     * @throws EE_Error
1327
-     * @throws InvalidArgumentException
1328
-     * @throws InvalidDataTypeException
1329
-     * @throws InvalidInterfaceException
1330
-     */
1331
-    protected function _add_help_tour()
1332
-    {
1333
-        $tours = array();
1334
-        $this->_help_tour = array();
1335
-        // exit early if help tours are turned off globally
1336
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1337
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1338
-        ) {
1339
-            return;
1340
-        }
1341
-        // loop through _page_config to find any help_tour defined
1342
-        foreach ($this->_page_config as $route => $config) {
1343
-            // we're only going to set things up for this route
1344
-            if ($route !== $this->_req_action) {
1345
-                continue;
1346
-            }
1347
-            if (isset($config['help_tour'])) {
1348
-                foreach ($config['help_tour'] as $tour) {
1349
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1350
-                    // let's see if we can get that file...
1351
-                    // if not its possible this is a decaf route not set in caffeinated
1352
-                    // so lets try and get the caffeinated equivalent
1353
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1354
-                                                             . basename($this->_get_dir())
1355
-                                                             . '/help_tours/'
1356
-                                                             . $tour
1357
-                                                             . '.class.php' : $file_path;
1358
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1359
-                    if (! is_readable($file_path)) {
1360
-                        EE_Error::add_error(
1361
-                            sprintf(
1362
-                                esc_html__(
1363
-                                    'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1364
-                                    'event_espresso'
1365
-                                ),
1366
-                                $file_path,
1367
-                                $tour
1368
-                            ),
1369
-                            __FILE__,
1370
-                            __FUNCTION__,
1371
-                            __LINE__
1372
-                        );
1373
-                        return;
1374
-                    }
1375
-                    require_once $file_path;
1376
-                    if (! class_exists($tour)) {
1377
-                        $error_msg[] = sprintf(
1378
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1379
-                            $tour
1380
-                        );
1381
-                        $error_msg[] = $error_msg[0] . "\r\n"
1382
-                                       . sprintf(
1383
-                                           esc_html__(
1384
-                                               'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1385
-                                               'event_espresso'
1386
-                                           ),
1387
-                                           $tour,
1388
-                                           '<br />',
1389
-                                           $tour,
1390
-                                           $this->_req_action,
1391
-                                           get_class($this)
1392
-                                       );
1393
-                        throw new EE_Error(implode('||', $error_msg));
1394
-                    }
1395
-                    $tour_obj = new $tour($this->_is_caf);
1396
-                    $tours[] = $tour_obj;
1397
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1398
-                }
1399
-                // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1400
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1401
-                $tours[] = $end_stop_tour;
1402
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1403
-            }
1404
-        }
1405
-
1406
-        if (! empty($tours)) {
1407
-            $this->_help_tour['tours'] = $tours;
1408
-        }
1409
-        // that's it!  Now that the $_help_tours property is set (or not)
1410
-        // the scripts and html should be taken care of automatically.
1411
-
1412
-        /**
1413
-         * Allow extending the help tours variable.
1414
-         *
1415
-         * @param Array $_help_tour The array containing all help tour information to be displayed.
1416
-         */
1417
-        $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1418
-    }
1419
-
1420
-
1421
-    /**
1422
-     * This simply sets up any qtips that have been defined in the page config
1423
-     *
1424
-     * @return void
1425
-     */
1426
-    protected function _add_qtips()
1427
-    {
1428
-        if (isset($this->_route_config['qtips'])) {
1429
-            $qtips = (array) $this->_route_config['qtips'];
1430
-            // load qtip loader
1431
-            $path = array(
1432
-                $this->_get_dir() . '/qtips/',
1433
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1434
-            );
1435
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1436
-        }
1437
-    }
1438
-
1439
-
1440
-    /**
1441
-     * _set_nav_tabs
1442
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1443
-     * wish to add additional tabs or modify accordingly.
1444
-     *
1445
-     * @return void
1446
-     * @throws InvalidArgumentException
1447
-     * @throws InvalidInterfaceException
1448
-     * @throws InvalidDataTypeException
1449
-     */
1450
-    protected function _set_nav_tabs()
1451
-    {
1452
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1453
-        $i = 0;
1454
-        foreach ($this->_page_config as $slug => $config) {
1455
-            if (! is_array($config)
1456
-                || (
1457
-                    is_array($config)
1458
-                    && (
1459
-                        (isset($config['nav']) && ! $config['nav'])
1460
-                        || ! isset($config['nav'])
1461
-                    )
1462
-                )
1463
-            ) {
1464
-                continue;
1465
-            }
1466
-            // no nav tab for this config
1467
-            // check for persistent flag
1468
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1469
-                // nav tab is only to appear when route requested.
1470
-                continue;
1471
-            }
1472
-            if (! $this->check_user_access($slug, true)) {
1473
-                // no nav tab because current user does not have access.
1474
-                continue;
1475
-            }
1476
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1477
-            $this->_nav_tabs[ $slug ] = array(
1478
-                'url'       => isset($config['nav']['url'])
1479
-                    ? $config['nav']['url']
1480
-                    : self::add_query_args_and_nonce(
1481
-                        array('action' => $slug),
1482
-                        $this->_admin_base_url
1483
-                    ),
1484
-                'link_text' => isset($config['nav']['label'])
1485
-                    ? $config['nav']['label']
1486
-                    : ucwords(
1487
-                        str_replace('_', ' ', $slug)
1488
-                    ),
1489
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1490
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1491
-            );
1492
-            $i++;
1493
-        }
1494
-        // if $this->_nav_tabs is empty then lets set the default
1495
-        if (empty($this->_nav_tabs)) {
1496
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1497
-                'url'       => $this->_admin_base_url,
1498
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1499
-                'css_class' => 'nav-tab-active',
1500
-                'order'     => 10,
1501
-            );
1502
-        }
1503
-        // now let's sort the tabs according to order
1504
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1505
-    }
1506
-
1507
-
1508
-    /**
1509
-     * _set_current_labels
1510
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1511
-     * property array
1512
-     *
1513
-     * @return void
1514
-     */
1515
-    private function _set_current_labels()
1516
-    {
1517
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1518
-            foreach ($this->_route_config['labels'] as $label => $text) {
1519
-                if (is_array($text)) {
1520
-                    foreach ($text as $sublabel => $subtext) {
1521
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1522
-                    }
1523
-                } else {
1524
-                    $this->_labels[ $label ] = $text;
1525
-                }
1526
-            }
1527
-        }
1528
-    }
1529
-
1530
-
1531
-    /**
1532
-     *        verifies user access for this admin page
1533
-     *
1534
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1535
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1536
-     *                               return false if verify fail.
1537
-     * @return bool
1538
-     * @throws InvalidArgumentException
1539
-     * @throws InvalidDataTypeException
1540
-     * @throws InvalidInterfaceException
1541
-     */
1542
-    public function check_user_access($route_to_check = '', $verify_only = false)
1543
-    {
1544
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1545
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1546
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1547
-                      && is_array(
1548
-                          $this->_page_routes[ $route_to_check ]
1549
-                      )
1550
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1551
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1552
-        if (empty($capability) && empty($route_to_check)) {
1553
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1554
-                : $this->_route['capability'];
1555
-        } else {
1556
-            $capability = empty($capability) ? 'manage_options' : $capability;
1557
-        }
1558
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1559
-        if (! defined('DOING_AJAX')
1560
-            && (
1561
-                ! function_exists('is_admin')
1562
-                || ! EE_Registry::instance()->CAP->current_user_can(
1563
-                    $capability,
1564
-                    $this->page_slug
1565
-                    . '_'
1566
-                    . $route_to_check,
1567
-                    $id
1568
-                )
1569
-            )
1570
-        ) {
1571
-            if ($verify_only) {
1572
-                return false;
1573
-            }
1574
-            if (is_user_logged_in()) {
1575
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1576
-            } else {
1577
-                return false;
1578
-            }
1579
-        }
1580
-        return true;
1581
-    }
1582
-
1583
-
1584
-    /**
1585
-     * admin_init_global
1586
-     * This runs all the code that we want executed within the WP admin_init hook.
1587
-     * This method executes for ALL EE Admin pages.
1588
-     *
1589
-     * @return void
1590
-     */
1591
-    public function admin_init_global()
1592
-    {
1593
-    }
1594
-
1595
-
1596
-    /**
1597
-     * wp_loaded_global
1598
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1599
-     * EE_Admin page and will execute on every EE Admin Page load
1600
-     *
1601
-     * @return void
1602
-     */
1603
-    public function wp_loaded()
1604
-    {
1605
-    }
1606
-
1607
-
1608
-    /**
1609
-     * admin_notices
1610
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1611
-     * ALL EE_Admin pages.
1612
-     *
1613
-     * @return void
1614
-     */
1615
-    public function admin_notices_global()
1616
-    {
1617
-        $this->_display_no_javascript_warning();
1618
-        $this->_display_espresso_notices();
1619
-    }
1620
-
1621
-
1622
-    public function network_admin_notices_global()
1623
-    {
1624
-        $this->_display_no_javascript_warning();
1625
-        $this->_display_espresso_notices();
1626
-    }
1627
-
1628
-
1629
-    /**
1630
-     * admin_footer_scripts_global
1631
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1632
-     * will apply on ALL EE_Admin pages.
1633
-     *
1634
-     * @return void
1635
-     */
1636
-    public function admin_footer_scripts_global()
1637
-    {
1638
-        $this->_add_admin_page_ajax_loading_img();
1639
-        $this->_add_admin_page_overlay();
1640
-        // if metaboxes are present we need to add the nonce field
1641
-        if (isset($this->_route_config['metaboxes'])
1642
-            || isset($this->_route_config['list_table'])
1643
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1644
-        ) {
1645
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1646
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1647
-        }
1648
-    }
1649
-
1650
-
1651
-    /**
1652
-     * admin_footer_global
1653
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1654
-     * ALL EE_Admin Pages.
1655
-     *
1656
-     * @return void
1657
-     * @throws EE_Error
1658
-     */
1659
-    public function admin_footer_global()
1660
-    {
1661
-        // dialog container for dialog helper
1662
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1663
-        $d_cont .= '<div class="ee-notices"></div>';
1664
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1665
-        $d_cont .= '</div>';
1666
-        echo $d_cont;
1667
-        // help tour stuff?
1668
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1669
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1670
-        }
1671
-        // current set timezone for timezone js
1672
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1673
-    }
1674
-
1675
-
1676
-    /**
1677
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1678
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1679
-     * help popups then in your templates or your content you set "triggers" for the content using the
1680
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1681
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1682
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1683
-     * for the
1684
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1685
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1686
-     *    'help_trigger_id' => array(
1687
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1688
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1689
-     *    )
1690
-     * );
1691
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1692
-     *
1693
-     * @param array $help_array
1694
-     * @param bool  $display
1695
-     * @return string content
1696
-     * @throws DomainException
1697
-     * @throws EE_Error
1698
-     */
1699
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1700
-    {
1701
-        $content = '';
1702
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1703
-        // loop through the array and setup content
1704
-        foreach ($help_array as $trigger => $help) {
1705
-            // make sure the array is setup properly
1706
-            if (! isset($help['title']) || ! isset($help['content'])) {
1707
-                throw new EE_Error(
1708
-                    esc_html__(
1709
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1710
-                        'event_espresso'
1711
-                    )
1712
-                );
1713
-            }
1714
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1715
-            $template_args = array(
1716
-                'help_popup_id'      => $trigger,
1717
-                'help_popup_title'   => $help['title'],
1718
-                'help_popup_content' => $help['content'],
1719
-            );
1720
-            $content .= EEH_Template::display_template(
1721
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1722
-                $template_args,
1723
-                true
1724
-            );
1725
-        }
1726
-        if ($display) {
1727
-            echo $content;
1728
-            return '';
1729
-        }
1730
-        return $content;
1731
-    }
1732
-
1733
-
1734
-    /**
1735
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1736
-     *
1737
-     * @return array properly formatted array for help popup content
1738
-     * @throws EE_Error
1739
-     */
1740
-    private function _get_help_content()
1741
-    {
1742
-        // what is the method we're looking for?
1743
-        $method_name = '_help_popup_content_' . $this->_req_action;
1744
-        // if method doesn't exist let's get out.
1745
-        if (! method_exists($this, $method_name)) {
1746
-            return array();
1747
-        }
1748
-        // k we're good to go let's retrieve the help array
1749
-        $help_array = call_user_func(array($this, $method_name));
1750
-        // make sure we've got an array!
1751
-        if (! is_array($help_array)) {
1752
-            throw new EE_Error(
1753
-                esc_html__(
1754
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1755
-                    'event_espresso'
1756
-                )
1757
-            );
1758
-        }
1759
-        return $help_array;
1760
-    }
1761
-
1762
-
1763
-    /**
1764
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1765
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1766
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1767
-     *
1768
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1769
-     * @param boolean $display    if false then we return the trigger string
1770
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1771
-     * @return string
1772
-     * @throws DomainException
1773
-     * @throws EE_Error
1774
-     */
1775
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1776
-    {
1777
-        if (defined('DOING_AJAX')) {
1778
-            return '';
1779
-        }
1780
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1781
-        $help_array = $this->_get_help_content();
1782
-        $help_content = '';
1783
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1784
-            $help_array[ $trigger_id ] = array(
1785
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1786
-                'content' => esc_html__(
1787
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1788
-                    'event_espresso'
1789
-                ),
1790
-            );
1791
-            $help_content = $this->_set_help_popup_content($help_array, false);
1792
-        }
1793
-        // let's setup the trigger
1794
-        $content = '<a class="ee-dialog" href="?height='
1795
-                   . $dimensions[0]
1796
-                   . '&width='
1797
-                   . $dimensions[1]
1798
-                   . '&inlineId='
1799
-                   . $trigger_id
1800
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1801
-        $content .= $help_content;
1802
-        if ($display) {
1803
-            echo $content;
1804
-            return '';
1805
-        }
1806
-        return $content;
1807
-    }
1808
-
1809
-
1810
-    /**
1811
-     * _add_global_screen_options
1812
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1813
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1814
-     *
1815
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1816
-     *         see also WP_Screen object documents...
1817
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1818
-     * @abstract
1819
-     * @return void
1820
-     */
1821
-    private function _add_global_screen_options()
1822
-    {
1823
-    }
1824
-
1825
-
1826
-    /**
1827
-     * _add_global_feature_pointers
1828
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1829
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1830
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1831
-     *
1832
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1833
-     *         extended) also see:
1834
-     * @link   http://eamann.com/tech/wordpress-portland/
1835
-     * @abstract
1836
-     * @return void
1837
-     */
1838
-    private function _add_global_feature_pointers()
1839
-    {
1840
-    }
1841
-
1842
-
1843
-    /**
1844
-     * load_global_scripts_styles
1845
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1846
-     *
1847
-     * @return void
1848
-     * @throws EE_Error
1849
-     */
1850
-    public function load_global_scripts_styles()
1851
-    {
1852
-        /** STYLES **/
1853
-        // add debugging styles
1854
-        if (WP_DEBUG) {
1855
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1856
-        }
1857
-        // register all styles
1858
-        wp_register_style(
1859
-            'espresso-ui-theme',
1860
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1861
-            array(),
1862
-            EVENT_ESPRESSO_VERSION
1863
-        );
1864
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1865
-        // helpers styles
1866
-        wp_register_style(
1867
-            'ee-text-links',
1868
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1869
-            array(),
1870
-            EVENT_ESPRESSO_VERSION
1871
-        );
1872
-        /** SCRIPTS **/
1873
-        // register all scripts
1874
-        wp_register_script(
1875
-            'ee-dialog',
1876
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1877
-            array('jquery', 'jquery-ui-draggable'),
1878
-            EVENT_ESPRESSO_VERSION,
1879
-            true
1880
-        );
1881
-        wp_register_script(
1882
-            'ee_admin_js',
1883
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1884
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1885
-            EVENT_ESPRESSO_VERSION,
1886
-            true
1887
-        );
1888
-        wp_register_script(
1889
-            'jquery-ui-timepicker-addon',
1890
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1891
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1892
-            EVENT_ESPRESSO_VERSION,
1893
-            true
1894
-        );
1895
-        if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1896
-            add_filter('FHEE_load_joyride', '__return_true');
1897
-        }
1898
-        // script for sorting tables
1899
-        wp_register_script(
1900
-            'espresso_ajax_table_sorting',
1901
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1902
-            array('ee_admin_js', 'jquery-ui-sortable'),
1903
-            EVENT_ESPRESSO_VERSION,
1904
-            true
1905
-        );
1906
-        // script for parsing uri's
1907
-        wp_register_script(
1908
-            'ee-parse-uri',
1909
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1910
-            array(),
1911
-            EVENT_ESPRESSO_VERSION,
1912
-            true
1913
-        );
1914
-        // and parsing associative serialized form elements
1915
-        wp_register_script(
1916
-            'ee-serialize-full-array',
1917
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1918
-            array('jquery'),
1919
-            EVENT_ESPRESSO_VERSION,
1920
-            true
1921
-        );
1922
-        // helpers scripts
1923
-        wp_register_script(
1924
-            'ee-text-links',
1925
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1926
-            array('jquery'),
1927
-            EVENT_ESPRESSO_VERSION,
1928
-            true
1929
-        );
1930
-        wp_register_script(
1931
-            'ee-moment-core',
1932
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1933
-            array(),
1934
-            EVENT_ESPRESSO_VERSION,
1935
-            true
1936
-        );
1937
-        wp_register_script(
1938
-            'ee-moment',
1939
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1940
-            array('ee-moment-core'),
1941
-            EVENT_ESPRESSO_VERSION,
1942
-            true
1943
-        );
1944
-        wp_register_script(
1945
-            'ee-datepicker',
1946
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1947
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1948
-            EVENT_ESPRESSO_VERSION,
1949
-            true
1950
-        );
1951
-        // google charts
1952
-        wp_register_script(
1953
-            'google-charts',
1954
-            'https://www.gstatic.com/charts/loader.js',
1955
-            array(),
1956
-            EVENT_ESPRESSO_VERSION,
1957
-            false
1958
-        );
1959
-        // ENQUEUE ALL BASICS BY DEFAULT
1960
-        wp_enqueue_style('ee-admin-css');
1961
-        wp_enqueue_script('ee_admin_js');
1962
-        wp_enqueue_script('ee-accounting');
1963
-        wp_enqueue_script('jquery-validate');
1964
-        // taking care of metaboxes
1965
-        if (empty($this->_cpt_route)
1966
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1967
-        ) {
1968
-            wp_enqueue_script('dashboard');
1969
-        }
1970
-        // LOCALIZED DATA
1971
-        // localize script for ajax lazy loading
1972
-        $lazy_loader_container_ids = apply_filters(
1973
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1974
-            array('espresso_news_post_box_content')
1975
-        );
1976
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1977
-        /**
1978
-         * help tour stuff
1979
-         */
1980
-        if (! empty($this->_help_tour)) {
1981
-            // register the js for kicking things off
1982
-            wp_enqueue_script(
1983
-                'ee-help-tour',
1984
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1985
-                array('jquery-joyride'),
1986
-                EVENT_ESPRESSO_VERSION,
1987
-                true
1988
-            );
1989
-            $tours = array();
1990
-            // setup tours for the js tour object
1991
-            foreach ($this->_help_tour['tours'] as $tour) {
1992
-                if ($tour instanceof EE_Help_Tour) {
1993
-                    $tours[] = array(
1994
-                        'id'      => $tour->get_slug(),
1995
-                        'options' => $tour->get_options(),
1996
-                    );
1997
-                }
1998
-            }
1999
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2000
-            // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2001
-        }
2002
-    }
2003
-
2004
-
2005
-    /**
2006
-     *        admin_footer_scripts_eei18n_js_strings
2007
-     *
2008
-     * @return        void
2009
-     */
2010
-    public function admin_footer_scripts_eei18n_js_strings()
2011
-    {
2012
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2013
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2014
-            'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2015
-            'event_espresso'
2016
-        );
2017
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2018
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2019
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2020
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2021
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2022
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2023
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2024
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2025
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2026
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2027
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2028
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2029
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2030
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2031
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2032
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2033
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2034
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2035
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2036
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2037
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2038
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2039
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2040
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2041
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2042
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2043
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2044
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2045
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2046
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2047
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2048
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2049
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2050
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2051
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2052
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2053
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2054
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2055
-    }
2056
-
2057
-
2058
-    /**
2059
-     *        load enhanced xdebug styles for ppl with failing eyesight
2060
-     *
2061
-     * @return        void
2062
-     */
2063
-    public function add_xdebug_style()
2064
-    {
2065
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2066
-    }
2067
-
2068
-
2069
-    /************************/
2070
-    /** LIST TABLE METHODS **/
2071
-    /************************/
2072
-    /**
2073
-     * this sets up the list table if the current view requires it.
2074
-     *
2075
-     * @return void
2076
-     * @throws EE_Error
2077
-     */
2078
-    protected function _set_list_table()
2079
-    {
2080
-        // first is this a list_table view?
2081
-        if (! isset($this->_route_config['list_table'])) {
2082
-            return;
2083
-        } //not a list_table view so get out.
2084
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2085
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2086
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2087
-            // user error msg
2088
-            $error_msg = esc_html__(
2089
-                'An error occurred. The requested list table views could not be found.',
2090
-                'event_espresso'
2091
-            );
2092
-            // developer error msg
2093
-            $error_msg .= '||'
2094
-                          . sprintf(
2095
-                              esc_html__(
2096
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2097
-                                  'event_espresso'
2098
-                              ),
2099
-                              $this->_req_action,
2100
-                              $list_table_view
2101
-                          );
2102
-            throw new EE_Error($error_msg);
2103
-        }
2104
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2105
-        $this->_views = apply_filters(
2106
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2107
-            $this->_views
2108
-        );
2109
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2110
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2111
-        $this->_set_list_table_view();
2112
-        $this->_set_list_table_object();
2113
-    }
2114
-
2115
-
2116
-    /**
2117
-     * set current view for List Table
2118
-     *
2119
-     * @return void
2120
-     */
2121
-    protected function _set_list_table_view()
2122
-    {
2123
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
-        // looking at active items or dumpster diving ?
2125
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2126
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2127
-        } else {
2128
-            $this->_view = sanitize_key($this->_req_data['status']);
2129
-        }
2130
-    }
2131
-
2132
-
2133
-    /**
2134
-     * _set_list_table_object
2135
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2136
-     *
2137
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2138
-     * @throws \InvalidArgumentException
2139
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2140
-     * @throws EE_Error
2141
-     * @throws InvalidInterfaceException
2142
-     */
2143
-    protected function _set_list_table_object()
2144
-    {
2145
-        if (isset($this->_route_config['list_table'])) {
2146
-            if (! class_exists($this->_route_config['list_table'])) {
2147
-                throw new EE_Error(
2148
-                    sprintf(
2149
-                        esc_html__(
2150
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2151
-                            'event_espresso'
2152
-                        ),
2153
-                        $this->_route_config['list_table'],
2154
-                        get_class($this)
2155
-                    )
2156
-                );
2157
-            }
2158
-            $this->_list_table_object = $this->loader->getShared(
2159
-                $this->_route_config['list_table'],
2160
-                array($this)
2161
-            );
2162
-        }
2163
-    }
2164
-
2165
-
2166
-    /**
2167
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2168
-     *
2169
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2170
-     *                                                    urls.  The array should be indexed by the view it is being
2171
-     *                                                    added to.
2172
-     * @return array
2173
-     */
2174
-    public function get_list_table_view_RLs($extra_query_args = array())
2175
-    {
2176
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2177
-        if (empty($this->_views)) {
2178
-            $this->_views = array();
2179
-        }
2180
-        // cycle thru views
2181
-        foreach ($this->_views as $key => $view) {
2182
-            $query_args = array();
2183
-            // check for current view
2184
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2185
-            $query_args['action'] = $this->_req_action;
2186
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2187
-            $query_args['status'] = $view['slug'];
2188
-            // merge any other arguments sent in.
2189
-            if (isset($extra_query_args[ $view['slug'] ])) {
2190
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2191
-            }
2192
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2193
-        }
2194
-        return $this->_views;
2195
-    }
2196
-
2197
-
2198
-    /**
2199
-     * _entries_per_page_dropdown
2200
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2201
-     *
2202
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2203
-     *         WP does it.
2204
-     * @param int $max_entries total number of rows in the table
2205
-     * @return string
2206
-     */
2207
-    protected function _entries_per_page_dropdown($max_entries = 0)
2208
-    {
2209
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2210
-        $values = array(10, 25, 50, 100);
2211
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2212
-        if ($max_entries) {
2213
-            $values[] = $max_entries;
2214
-            sort($values);
2215
-        }
2216
-        $entries_per_page_dropdown = '
104
+	/**
105
+	 * @var array $_route_config
106
+	 */
107
+	protected $_route_config;
108
+
109
+	/**
110
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
+	 * actions.
112
+	 *
113
+	 * @since 4.6.x
114
+	 * @var array.
115
+	 */
116
+	protected $_default_route_query_args;
117
+
118
+	// set via request page and action args.
119
+	protected $_current_page;
120
+
121
+	protected $_current_view;
122
+
123
+	protected $_current_page_view_url;
124
+
125
+	// sanitized request action (and nonce)
126
+
127
+	/**
128
+	 * @var string $_req_action
129
+	 */
130
+	protected $_req_action;
131
+
132
+	/**
133
+	 * @var string $_req_nonce
134
+	 */
135
+	protected $_req_nonce;
136
+
137
+	// search related
138
+	protected $_search_btn_label;
139
+
140
+	protected $_search_box_callback;
141
+
142
+	/**
143
+	 * WP Current Screen object
144
+	 *
145
+	 * @var WP_Screen
146
+	 */
147
+	protected $_current_screen;
148
+
149
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
+	protected $_hook_obj;
151
+
152
+	// for holding incoming request data
153
+	protected $_req_data;
154
+
155
+	// yes / no array for admin form fields
156
+	protected $_yes_no_values = array();
157
+
158
+	// some default things shared by all child classes
159
+	protected $_default_espresso_metaboxes;
160
+
161
+	/**
162
+	 *    EE_Registry Object
163
+	 *
164
+	 * @var    EE_Registry
165
+	 */
166
+	protected $EE = null;
167
+
168
+
169
+	/**
170
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
171
+	 *
172
+	 * @var boolean
173
+	 */
174
+	protected $_is_caf = false;
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws ReflectionException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function __construct($routing = true)
187
+	{
188
+		$this->loader = LoaderFactory::getLoader();
189
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
+			$this->_is_caf = true;
191
+		}
192
+		$this->_yes_no_values = array(
193
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
+		);
196
+		// set the _req_data property.
197
+		$this->_req_data = array_merge($_GET, $_POST);
198
+		// routing enabled?
199
+		$this->_routing = $routing;
200
+		// set initial page props (child method)
201
+		$this->_init_page_props();
202
+		// set global defaults
203
+		$this->_set_defaults();
204
+		// set early because incoming requests could be ajax related and we need to register those hooks.
205
+		$this->_global_ajax_hooks();
206
+		$this->_ajax_hooks();
207
+		// other_page_hooks have to be early too.
208
+		$this->_do_other_page_hooks();
209
+		// This just allows us to have extending classes do something specific
210
+		// before the parent constructor runs _page_setup().
211
+		if (method_exists($this, '_before_page_setup')) {
212
+			$this->_before_page_setup();
213
+		}
214
+		// set up page dependencies
215
+		$this->_page_setup();
216
+	}
217
+
218
+
219
+	/**
220
+	 * _init_page_props
221
+	 * Child classes use to set at least the following properties:
222
+	 * $page_slug.
223
+	 * $page_label.
224
+	 *
225
+	 * @abstract
226
+	 * @return void
227
+	 */
228
+	abstract protected function _init_page_props();
229
+
230
+
231
+	/**
232
+	 * _ajax_hooks
233
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
+	 * Note: within the ajax callback methods.
235
+	 *
236
+	 * @abstract
237
+	 * @return void
238
+	 */
239
+	abstract protected function _ajax_hooks();
240
+
241
+
242
+	/**
243
+	 * _define_page_props
244
+	 * child classes define page properties in here.  Must include at least:
245
+	 * $_admin_base_url = base_url for all admin pages
246
+	 * $_admin_page_title = default admin_page_title for admin pages
247
+	 * $_labels = array of default labels for various automatically generated elements:
248
+	 *    array(
249
+	 *        'buttons' => array(
250
+	 *            'add' => esc_html__('label for add new button'),
251
+	 *            'edit' => esc_html__('label for edit button'),
252
+	 *            'delete' => esc_html__('label for delete button')
253
+	 *            )
254
+	 *        )
255
+	 *
256
+	 * @abstract
257
+	 * @return void
258
+	 */
259
+	abstract protected function _define_page_props();
260
+
261
+
262
+	/**
263
+	 * _set_page_routes
264
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
+	 * have a 'default' route. Here's the format
267
+	 * $this->_page_routes = array(
268
+	 *        'default' => array(
269
+	 *            'func' => '_default_method_handling_route',
270
+	 *            'args' => array('array','of','args'),
271
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
+	 *            ajax request, backend processing)
273
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
+	 *            headers route after.  The string you enter here should match the defined route reference for a
275
+	 *            headers sent route.
276
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
+	 *            this route.
278
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
+	 *            checks).
280
+	 *        ),
281
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
+	 *        handling method.
283
+	 *        )
284
+	 * )
285
+	 *
286
+	 * @abstract
287
+	 * @return void
288
+	 */
289
+	abstract protected function _set_page_routes();
290
+
291
+
292
+	/**
293
+	 * _set_page_config
294
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
+	 * array corresponds to the page_route for the loaded page. Format:
296
+	 * $this->_page_config = array(
297
+	 *        'default' => array(
298
+	 *            'labels' => array(
299
+	 *                'buttons' => array(
300
+	 *                    'add' => esc_html__('label for adding item'),
301
+	 *                    'edit' => esc_html__('label for editing item'),
302
+	 *                    'delete' => esc_html__('label for deleting item')
303
+	 *                ),
304
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
+	 *            _define_page_props() method
308
+	 *            'nav' => array(
309
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
+	 *                'order' => 10, //required to indicate tab position.
313
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
+	 *                displayed then add this parameter.
315
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
+	 *            metaboxes set for eventespresso admin pages.
318
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
+	 *            want to display.
327
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
328
+	 *                'tab_id' => array(
329
+	 *                    'title' => 'tab_title',
330
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
+	 *                    attempt to use the callback which should match the name of a method in the class
336
+	 *                    ),
337
+	 *                'tab2_id' => array(
338
+	 *                    'title' => 'tab2 title',
339
+	 *                    'filename' => 'file_name_2'
340
+	 *                    'callback' => 'callback_method_for_content',
341
+	 *                 ),
342
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
+	 *            help tab area on an admin page. @link
344
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
+	 *            'help_tour' => array(
346
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
+	 *            ),
350
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
+	 *            just set
353
+	 *            'require_nonce' to FALSE
354
+	 *            )
355
+	 * )
356
+	 *
357
+	 * @abstract
358
+	 * @return void
359
+	 */
360
+	abstract protected function _set_page_config();
361
+
362
+
363
+
364
+
365
+
366
+	/** end sample help_tour methods **/
367
+	/**
368
+	 * _add_screen_options
369
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
+	 * to a particular view.
372
+	 *
373
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
+	 *         see also WP_Screen object documents...
375
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
+	 * @abstract
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+	/**
383
+	 * _add_feature_pointers
384
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
+	 * extended) also see:
389
+	 *
390
+	 * @link   http://eamann.com/tech/wordpress-portland/
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _add_feature_pointers();
395
+
396
+
397
+	/**
398
+	 * load_scripts_styles
399
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
+	 * scripts/styles per view by putting them in a dynamic function in this format
402
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
+	 *
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract public function load_scripts_styles();
408
+
409
+
410
+	/**
411
+	 * admin_init
412
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
+	 * all pages/views loaded by child class.
414
+	 *
415
+	 * @abstract
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_init();
419
+
420
+
421
+	/**
422
+	 * admin_notices
423
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
+	 * all pages/views loaded by child class.
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function admin_notices();
430
+
431
+
432
+	/**
433
+	 * admin_footer_scripts
434
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
+	 * will apply to all pages/views loaded by child class.
436
+	 *
437
+	 * @return void
438
+	 */
439
+	abstract public function admin_footer_scripts();
440
+
441
+
442
+	/**
443
+	 * admin_footer
444
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
+	 * apply to all pages/views loaded by child class.
446
+	 *
447
+	 * @return void
448
+	 */
449
+	public function admin_footer()
450
+	{
451
+	}
452
+
453
+
454
+	/**
455
+	 * _global_ajax_hooks
456
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
+	 * Note: within the ajax callback methods.
458
+	 *
459
+	 * @abstract
460
+	 * @return void
461
+	 */
462
+	protected function _global_ajax_hooks()
463
+	{
464
+		// for lazy loading of metabox content
465
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
+	}
467
+
468
+
469
+	public function ajax_metabox_content()
470
+	{
471
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
+		self::cached_rss_display($contentid, $url);
474
+		wp_die();
475
+	}
476
+
477
+
478
+	/**
479
+	 * _page_setup
480
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
+	 * doesn't match the object.
482
+	 *
483
+	 * @final
484
+	 * @return void
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws ReflectionException
488
+	 * @throws InvalidDataTypeException
489
+	 * @throws InvalidInterfaceException
490
+	 */
491
+	final protected function _page_setup()
492
+	{
493
+		// requires?
494
+		// admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
496
+		// next verify if we need to load anything...
497
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
+		$this->page_folder = strtolower(
499
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
+		);
501
+		global $ee_menu_slugs;
502
+		$ee_menu_slugs = (array) $ee_menu_slugs;
503
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
+			return;
505
+		}
506
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
+				? $this->_req_data['action2']
510
+				: $this->_req_data['action'];
511
+		}
512
+		// then set blank or -1 action values to 'default'
513
+		$this->_req_action = isset($this->_req_data['action'])
514
+							 && ! empty($this->_req_data['action'])
515
+							 && $this->_req_data['action'] !== '-1'
516
+			? sanitize_key($this->_req_data['action'])
517
+			: 'default';
518
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
520
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
+			? $this->_req_data['route'] : $this->_req_action;
522
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
+			? $this->_req_data['route']
525
+			: $this->_req_action;
526
+		$this->_current_view = $this->_req_action;
527
+		$this->_req_nonce = $this->_req_action . '_nonce';
528
+		$this->_define_page_props();
529
+		$this->_current_page_view_url = add_query_arg(
530
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
531
+			$this->_admin_base_url
532
+		);
533
+		// default things
534
+		$this->_default_espresso_metaboxes = array(
535
+			'_espresso_news_post_box',
536
+			'_espresso_links_post_box',
537
+			'_espresso_ratings_request',
538
+			'_espresso_sponsors_post_box',
539
+		);
540
+		// set page configs
541
+		$this->_set_page_routes();
542
+		$this->_set_page_config();
543
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
544
+		if (isset($this->_req_data['wp_referer'])) {
545
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
+		}
547
+		// for caffeinated and other extended functionality.
548
+		//  If there is a _extend_page_config method
549
+		// then let's run that to modify the all the various page configuration arrays
550
+		if (method_exists($this, '_extend_page_config')) {
551
+			$this->_extend_page_config();
552
+		}
553
+		// for CPT and other extended functionality.
554
+		// If there is an _extend_page_config_for_cpt
555
+		// then let's run that to modify all the various page configuration arrays.
556
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
557
+			$this->_extend_page_config_for_cpt();
558
+		}
559
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
560
+		$this->_page_routes = apply_filters(
561
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
+			$this->_page_routes,
563
+			$this
564
+		);
565
+		$this->_page_config = apply_filters(
566
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
567
+			$this->_page_config,
568
+			$this
569
+		);
570
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
+			add_action(
574
+				'AHEE__EE_Admin_Page__route_admin_request',
575
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
+				10,
577
+				2
578
+			);
579
+		}
580
+		// next route only if routing enabled
581
+		if ($this->_routing && ! defined('DOING_AJAX')) {
582
+			$this->_verify_routes();
583
+			// next let's just check user_access and kill if no access
584
+			$this->check_user_access();
585
+			if ($this->_is_UI_request) {
586
+				// admin_init stuff - global, all views for this page class, specific view
587
+				add_action('admin_init', array($this, 'admin_init'), 10);
588
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
+				}
591
+			} else {
592
+				// hijack regular WP loading and route admin request immediately
593
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
+				$this->route_admin_request();
595
+			}
596
+		}
597
+	}
598
+
599
+
600
+	/**
601
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
+	 *
603
+	 * @return void
604
+	 * @throws ReflectionException
605
+	 * @throws EE_Error
606
+	 */
607
+	private function _do_other_page_hooks()
608
+	{
609
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
+		foreach ($registered_pages as $page) {
611
+			// now let's setup the file name and class that should be present
612
+			$classname = str_replace('.class.php', '', $page);
613
+			// autoloaders should take care of loading file
614
+			if (! class_exists($classname)) {
615
+				$error_msg[] = sprintf(
616
+					esc_html__(
617
+						'Something went wrong with loading the %s admin hooks page.',
618
+						'event_espresso'
619
+					),
620
+					$page
621
+				);
622
+				$error_msg[] = $error_msg[0]
623
+							   . "\r\n"
624
+							   . sprintf(
625
+								   esc_html__(
626
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
627
+									   'event_espresso'
628
+								   ),
629
+								   $page,
630
+								   '<br />',
631
+								   '<strong>' . $classname . '</strong>'
632
+							   );
633
+				throw new EE_Error(implode('||', $error_msg));
634
+			}
635
+			$a = new ReflectionClass($classname);
636
+			// notice we are passing the instance of this class to the hook object.
637
+			$hookobj[] = $a->newInstance($this);
638
+		}
639
+	}
640
+
641
+
642
+	public function load_page_dependencies()
643
+	{
644
+		try {
645
+			$this->_load_page_dependencies();
646
+		} catch (EE_Error $e) {
647
+			$e->get_error();
648
+		}
649
+	}
650
+
651
+
652
+	/**
653
+	 * load_page_dependencies
654
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
+	 *
656
+	 * @return void
657
+	 * @throws DomainException
658
+	 * @throws EE_Error
659
+	 * @throws InvalidArgumentException
660
+	 * @throws InvalidDataTypeException
661
+	 * @throws InvalidInterfaceException
662
+	 * @throws ReflectionException
663
+	 */
664
+	protected function _load_page_dependencies()
665
+	{
666
+		// let's set the current_screen and screen options to override what WP set
667
+		$this->_current_screen = get_current_screen();
668
+		// load admin_notices - global, page class, and view specific
669
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
671
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
+		}
674
+		// load network admin_notices - global, page class, and view specific
675
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
+		}
679
+		// this will save any per_page screen options if they are present
680
+		$this->_set_per_page_screen_options();
681
+		// setup list table properties
682
+		$this->_set_list_table();
683
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
+		// However in some cases the metaboxes will need to be added within a route handling callback.
685
+		$this->_add_registered_meta_boxes();
686
+		$this->_add_screen_columns();
687
+		// add screen options - global, page child class, and view specific
688
+		$this->_add_global_screen_options();
689
+		$this->_add_screen_options();
690
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
691
+		if (method_exists($this, $add_screen_options)) {
692
+			$this->{$add_screen_options}();
693
+		}
694
+		// add help tab(s) and tours- set via page_config and qtips.
695
+		$this->_add_help_tour();
696
+		$this->_add_help_tabs();
697
+		$this->_add_qtips();
698
+		// add feature_pointers - global, page child class, and view specific
699
+		$this->_add_feature_pointers();
700
+		$this->_add_global_feature_pointers();
701
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
+		if (method_exists($this, $add_feature_pointer)) {
703
+			$this->{$add_feature_pointer}();
704
+		}
705
+		// enqueue scripts/styles - global, page class, and view specific
706
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
+		}
711
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
+		// admin_print_footer_scripts - global, page child class, and view specific.
713
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
+		// is a good use case. Notice the late priority we're giving these
716
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
+		}
721
+		// admin footer scripts
722
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
724
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
+		}
727
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
+		// targeted hook
729
+		do_action(
730
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
+		);
732
+	}
733
+
734
+
735
+	/**
736
+	 * _set_defaults
737
+	 * This sets some global defaults for class properties.
738
+	 */
739
+	private function _set_defaults()
740
+	{
741
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
743
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
+		$this->_page_config = $this->_default_route_query_args = array();
745
+		$this->_default_nav_tab_name = 'overview';
746
+		// init template args
747
+		$this->_template_args = array(
748
+			'admin_page_header'  => '',
749
+			'admin_page_content' => '',
750
+			'post_body_content'  => '',
751
+			'before_list_table'  => '',
752
+			'after_list_table'   => '',
753
+		);
754
+	}
755
+
756
+
757
+	/**
758
+	 * route_admin_request
759
+	 *
760
+	 * @see    _route_admin_request()
761
+	 * @return exception|void error
762
+	 * @throws InvalidArgumentException
763
+	 * @throws InvalidInterfaceException
764
+	 * @throws InvalidDataTypeException
765
+	 * @throws EE_Error
766
+	 * @throws ReflectionException
767
+	 */
768
+	public function route_admin_request()
769
+	{
770
+		try {
771
+			$this->_route_admin_request();
772
+		} catch (EE_Error $e) {
773
+			$e->get_error();
774
+		}
775
+	}
776
+
777
+
778
+	public function set_wp_page_slug($wp_page_slug)
779
+	{
780
+		$this->_wp_page_slug = $wp_page_slug;
781
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
+		if (is_network_admin()) {
783
+			$this->_wp_page_slug .= '-network';
784
+		}
785
+	}
786
+
787
+
788
+	/**
789
+	 * _verify_routes
790
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
+	 * we know if we need to drop out.
792
+	 *
793
+	 * @return bool
794
+	 * @throws EE_Error
795
+	 */
796
+	protected function _verify_routes()
797
+	{
798
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
+			return false;
801
+		}
802
+		$this->_route = false;
803
+		// check that the page_routes array is not empty
804
+		if (empty($this->_page_routes)) {
805
+			// user error msg
806
+			$error_msg = sprintf(
807
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
+				$this->_admin_page_title
809
+			);
810
+			// developer error msg
811
+			$error_msg .= '||' . $error_msg
812
+						  . esc_html__(
813
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
+							  'event_espresso'
815
+						  );
816
+			throw new EE_Error($error_msg);
817
+		}
818
+		// and that the requested page route exists
819
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
+			$this->_route = $this->_page_routes[ $this->_req_action ];
821
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
+				? $this->_page_config[ $this->_req_action ] : array();
823
+		} else {
824
+			// user error msg
825
+			$error_msg = sprintf(
826
+				esc_html__(
827
+					'The requested page route does not exist for the %s admin page.',
828
+					'event_espresso'
829
+				),
830
+				$this->_admin_page_title
831
+			);
832
+			// developer error msg
833
+			$error_msg .= '||' . $error_msg
834
+						  . sprintf(
835
+							  esc_html__(
836
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
+								  'event_espresso'
838
+							  ),
839
+							  $this->_req_action
840
+						  );
841
+			throw new EE_Error($error_msg);
842
+		}
843
+		// and that a default route exists
844
+		if (! array_key_exists('default', $this->_page_routes)) {
845
+			// user error msg
846
+			$error_msg = sprintf(
847
+				esc_html__(
848
+					'A default page route has not been set for the % admin page.',
849
+					'event_espresso'
850
+				),
851
+				$this->_admin_page_title
852
+			);
853
+			// developer error msg
854
+			$error_msg .= '||' . $error_msg
855
+						  . esc_html__(
856
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
+							  'event_espresso'
858
+						  );
859
+			throw new EE_Error($error_msg);
860
+		}
861
+		// first lets' catch if the UI request has EVER been set.
862
+		if ($this->_is_UI_request === null) {
863
+			// lets set if this is a UI request or not.
864
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
+			// wait a minute... we might have a noheader in the route array
866
+			$this->_is_UI_request = is_array($this->_route)
867
+									&& isset($this->_route['noheader'])
868
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
869
+		}
870
+		$this->_set_current_labels();
871
+		return true;
872
+	}
873
+
874
+
875
+	/**
876
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
+	 *
878
+	 * @param  string $route the route name we're verifying
879
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
+	 * @throws EE_Error
881
+	 */
882
+	protected function _verify_route($route)
883
+	{
884
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
+			return true;
886
+		}
887
+		// user error msg
888
+		$error_msg = sprintf(
889
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
+			$this->_admin_page_title
891
+		);
892
+		// developer error msg
893
+		$error_msg .= '||' . $error_msg
894
+					  . sprintf(
895
+						  esc_html__(
896
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
+							  'event_espresso'
898
+						  ),
899
+						  $route
900
+					  );
901
+		throw new EE_Error($error_msg);
902
+	}
903
+
904
+
905
+	/**
906
+	 * perform nonce verification
907
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
+	 * using this method (and save retyping!)
909
+	 *
910
+	 * @param  string $nonce     The nonce sent
911
+	 * @param  string $nonce_ref The nonce reference string (name0)
912
+	 * @return void
913
+	 * @throws EE_Error
914
+	 */
915
+	protected function _verify_nonce($nonce, $nonce_ref)
916
+	{
917
+		// verify nonce against expected value
918
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
+			// these are not the droids you are looking for !!!
920
+			$msg = sprintf(
921
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
+				'</a>'
924
+			);
925
+			if (WP_DEBUG) {
926
+				$msg .= "\n  "
927
+						. sprintf(
928
+							esc_html__(
929
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
+								'event_espresso'
931
+							),
932
+							__CLASS__
933
+						);
934
+			}
935
+			if (! defined('DOING_AJAX')) {
936
+				wp_die($msg);
937
+			} else {
938
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
+				$this->_return_json();
940
+			}
941
+		}
942
+	}
943
+
944
+
945
+	/**
946
+	 * _route_admin_request()
947
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
+	 * in the page routes and then will try to load the corresponding method.
950
+	 *
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 * @throws InvalidArgumentException
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws InvalidInterfaceException
956
+	 * @throws ReflectionException
957
+	 */
958
+	protected function _route_admin_request()
959
+	{
960
+		if (! $this->_is_UI_request) {
961
+			$this->_verify_routes();
962
+		}
963
+		$nonce_check = isset($this->_route_config['require_nonce'])
964
+			? $this->_route_config['require_nonce']
965
+			: true;
966
+		if ($this->_req_action !== 'default' && $nonce_check) {
967
+			// set nonce from post data
968
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
969
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
+				: '';
971
+			$this->_verify_nonce($nonce, $this->_req_nonce);
972
+		}
973
+		// set the nav_tabs array but ONLY if this is  UI_request
974
+		if ($this->_is_UI_request) {
975
+			$this->_set_nav_tabs();
976
+		}
977
+		// grab callback function
978
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
+		// check if callback has args
980
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
+		$error_msg = '';
982
+		// action right before calling route
983
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
+		}
987
+		// right before calling the route, let's remove _wp_http_referer from the
988
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
990
+			'_wp_http_referer',
991
+			wp_unslash($_SERVER['REQUEST_URI'])
992
+		);
993
+		if (! empty($func)) {
994
+			if (is_array($func)) {
995
+				list($class, $method) = $func;
996
+			} elseif (strpos($func, '::') !== false) {
997
+				list($class, $method) = explode('::', $func);
998
+			} else {
999
+				$class = $this;
1000
+				$method = $func;
1001
+			}
1002
+			if (! (is_object($class) && $class === $this)) {
1003
+				// send along this admin page object for access by addons.
1004
+				$args['admin_page_object'] = $this;
1005
+			}
1006
+			if (// is it a method on a class that doesn't work?
1007
+				(
1008
+					(
1009
+						method_exists($class, $method)
1010
+						&& call_user_func_array(array($class, $method), $args) === false
1011
+					)
1012
+					&& (
1013
+						// is it a standalone function that doesn't work?
1014
+						function_exists($method)
1015
+						&& call_user_func_array(
1016
+							$func,
1017
+							array_merge(array('admin_page_object' => $this), $args)
1018
+						) === false
1019
+					)
1020
+				)
1021
+				|| (
1022
+					// is it neither a class method NOR a standalone function?
1023
+					! method_exists($class, $method)
1024
+					&& ! function_exists($method)
1025
+				)
1026
+			) {
1027
+				// user error msg
1028
+				$error_msg = esc_html__(
1029
+					'An error occurred. The  requested page route could not be found.',
1030
+					'event_espresso'
1031
+				);
1032
+				// developer error msg
1033
+				$error_msg .= '||';
1034
+				$error_msg .= sprintf(
1035
+					esc_html__(
1036
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
+						'event_espresso'
1038
+					),
1039
+					$method
1040
+				);
1041
+			}
1042
+			if (! empty($error_msg)) {
1043
+				throw new EE_Error($error_msg);
1044
+			}
1045
+		}
1046
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1047
+		// then we need to reset the routing properties to the new route.
1048
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1049
+		if ($this->_is_UI_request === false
1050
+			&& is_array($this->_route)
1051
+			&& ! empty($this->_route['headers_sent_route'])
1052
+		) {
1053
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
+		}
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * This method just allows the resetting of page properties in the case where a no headers
1060
+	 * route redirects to a headers route in its route config.
1061
+	 *
1062
+	 * @since   4.3.0
1063
+	 * @param  string $new_route New (non header) route to redirect to.
1064
+	 * @return   void
1065
+	 * @throws ReflectionException
1066
+	 * @throws InvalidArgumentException
1067
+	 * @throws InvalidInterfaceException
1068
+	 * @throws InvalidDataTypeException
1069
+	 * @throws EE_Error
1070
+	 */
1071
+	protected function _reset_routing_properties($new_route)
1072
+	{
1073
+		$this->_is_UI_request = true;
1074
+		// now we set the current route to whatever the headers_sent_route is set at
1075
+		$this->_req_data['action'] = $new_route;
1076
+		// rerun page setup
1077
+		$this->_page_setup();
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * _add_query_arg
1083
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1084
+	 *(internally just uses EEH_URL's function with the same name)
1085
+	 *
1086
+	 * @param array  $args
1087
+	 * @param string $url
1088
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
+	 *                                        Example usage: If the current page is:
1091
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
+	 *                                        &action=default&event_id=20&month_range=March%202015
1093
+	 *                                        &_wpnonce=5467821
1094
+	 *                                        and you call:
1095
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
+	 *                                        array(
1097
+	 *                                        'action' => 'resend_something',
1098
+	 *                                        'page=>espresso_registrations'
1099
+	 *                                        ),
1100
+	 *                                        $some_url,
1101
+	 *                                        true
1102
+	 *                                        );
1103
+	 *                                        It will produce a url in this structure:
1104
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
+	 *                                        month_range]=March%202015
1107
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
+	 * @return string
1109
+	 */
1110
+	public static function add_query_args_and_nonce(
1111
+		$args = array(),
1112
+		$url = false,
1113
+		$sticky = false,
1114
+		$exclude_nonce = false
1115
+	) {
1116
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
+		if ($sticky) {
1118
+			$request = $_REQUEST;
1119
+			unset($request['_wp_http_referer']);
1120
+			unset($request['wp_referer']);
1121
+			foreach ($request as $key => $value) {
1122
+				// do not add nonces
1123
+				if (strpos($key, 'nonce') !== false) {
1124
+					continue;
1125
+				}
1126
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1127
+			}
1128
+		}
1129
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * This returns a generated link that will load the related help tab.
1135
+	 *
1136
+	 * @param  string $help_tab_id the id for the connected help tab
1137
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
+	 * @uses EEH_Template::get_help_tab_link()
1140
+	 * @return string              generated link
1141
+	 */
1142
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
+	{
1144
+		return EEH_Template::get_help_tab_link(
1145
+			$help_tab_id,
1146
+			$this->page_slug,
1147
+			$this->_req_action,
1148
+			$icon_style,
1149
+			$help_text
1150
+		);
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * _add_help_tabs
1156
+	 * Note child classes define their help tabs within the page_config array.
1157
+	 *
1158
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
+	 * @return void
1160
+	 * @throws DomainException
1161
+	 * @throws EE_Error
1162
+	 */
1163
+	protected function _add_help_tabs()
1164
+	{
1165
+		$tour_buttons = '';
1166
+		if (isset($this->_page_config[ $this->_req_action ])) {
1167
+			$config = $this->_page_config[ $this->_req_action ];
1168
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1169
+			if (isset($this->_help_tour[ $this->_req_action ])) {
1170
+				$tb = array();
1171
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1172
+				foreach ($this->_help_tour['tours'] as $tour) {
1173
+					// if this is the end tour then we don't need to setup a button
1174
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1175
+						continue;
1176
+					}
1177
+					$tb[] = '<button id="trigger-tour-'
1178
+							. $tour->get_slug()
1179
+							. '" class="button-primary trigger-ee-help-tour">'
1180
+							. $tour->get_label()
1181
+							. '</button>';
1182
+				}
1183
+				$tour_buttons .= implode('<br />', $tb);
1184
+				$tour_buttons .= '</div></div>';
1185
+			}
1186
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1187
+			if (is_array($config) && isset($config['help_sidebar'])) {
1188
+				// check that the callback given is valid
1189
+				if (! method_exists($this, $config['help_sidebar'])) {
1190
+					throw new EE_Error(
1191
+						sprintf(
1192
+							esc_html__(
1193
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1194
+								'event_espresso'
1195
+							),
1196
+							$config['help_sidebar'],
1197
+							get_class($this)
1198
+						)
1199
+					);
1200
+				}
1201
+				$content = apply_filters(
1202
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1203
+					$this->{$config['help_sidebar']}()
1204
+				);
1205
+				$content .= $tour_buttons; // add help tour buttons.
1206
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1207
+				$this->_current_screen->set_help_sidebar($content);
1208
+			}
1209
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1210
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1211
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1212
+			}
1213
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1214
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1215
+				$_ht['id'] = $this->page_slug;
1216
+				$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1217
+				$_ht['content'] = '<p>'
1218
+								  . esc_html__(
1219
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1220
+									  'event_espresso'
1221
+								  ) . '</p>';
1222
+				$this->_current_screen->add_help_tab($_ht);
1223
+			}
1224
+			if (! isset($config['help_tabs'])) {
1225
+				return;
1226
+			} //no help tabs for this route
1227
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1228
+				// we're here so there ARE help tabs!
1229
+				// make sure we've got what we need
1230
+				if (! isset($cfg['title'])) {
1231
+					throw new EE_Error(
1232
+						esc_html__(
1233
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1234
+							'event_espresso'
1235
+						)
1236
+					);
1237
+				}
1238
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1239
+					throw new EE_Error(
1240
+						esc_html__(
1241
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1242
+							'event_espresso'
1243
+						)
1244
+					);
1245
+				}
1246
+				// first priority goes to content.
1247
+				if (! empty($cfg['content'])) {
1248
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1249
+					// second priority goes to filename
1250
+				} elseif (! empty($cfg['filename'])) {
1251
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1252
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1253
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1254
+															 . basename($this->_get_dir())
1255
+															 . '/help_tabs/'
1256
+															 . $cfg['filename']
1257
+															 . '.help_tab.php' : $file_path;
1258
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1259
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1260
+						EE_Error::add_error(
1261
+							sprintf(
1262
+								esc_html__(
1263
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1264
+									'event_espresso'
1265
+								),
1266
+								$tab_id,
1267
+								key($config),
1268
+								$file_path
1269
+							),
1270
+							__FILE__,
1271
+							__FUNCTION__,
1272
+							__LINE__
1273
+						);
1274
+						return;
1275
+					}
1276
+					$template_args['admin_page_obj'] = $this;
1277
+					$content = EEH_Template::display_template(
1278
+						$file_path,
1279
+						$template_args,
1280
+						true
1281
+					);
1282
+				} else {
1283
+					$content = '';
1284
+				}
1285
+				// check if callback is valid
1286
+				if (empty($content) && (
1287
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1288
+					)
1289
+				) {
1290
+					EE_Error::add_error(
1291
+						sprintf(
1292
+							esc_html__(
1293
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1294
+								'event_espresso'
1295
+							),
1296
+							$cfg['title']
1297
+						),
1298
+						__FILE__,
1299
+						__FUNCTION__,
1300
+						__LINE__
1301
+					);
1302
+					return;
1303
+				}
1304
+				// setup config array for help tab method
1305
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1306
+				$_ht = array(
1307
+					'id'       => $id,
1308
+					'title'    => $cfg['title'],
1309
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1310
+					'content'  => $content,
1311
+				);
1312
+				$this->_current_screen->add_help_tab($_ht);
1313
+			}
1314
+		}
1315
+	}
1316
+
1317
+
1318
+	/**
1319
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1320
+	 * an array with properties for setting up usage of the joyride plugin
1321
+	 *
1322
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1323
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1324
+	 *         _set_page_config() comments
1325
+	 * @return void
1326
+	 * @throws EE_Error
1327
+	 * @throws InvalidArgumentException
1328
+	 * @throws InvalidDataTypeException
1329
+	 * @throws InvalidInterfaceException
1330
+	 */
1331
+	protected function _add_help_tour()
1332
+	{
1333
+		$tours = array();
1334
+		$this->_help_tour = array();
1335
+		// exit early if help tours are turned off globally
1336
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1337
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1338
+		) {
1339
+			return;
1340
+		}
1341
+		// loop through _page_config to find any help_tour defined
1342
+		foreach ($this->_page_config as $route => $config) {
1343
+			// we're only going to set things up for this route
1344
+			if ($route !== $this->_req_action) {
1345
+				continue;
1346
+			}
1347
+			if (isset($config['help_tour'])) {
1348
+				foreach ($config['help_tour'] as $tour) {
1349
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1350
+					// let's see if we can get that file...
1351
+					// if not its possible this is a decaf route not set in caffeinated
1352
+					// so lets try and get the caffeinated equivalent
1353
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1354
+															 . basename($this->_get_dir())
1355
+															 . '/help_tours/'
1356
+															 . $tour
1357
+															 . '.class.php' : $file_path;
1358
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1359
+					if (! is_readable($file_path)) {
1360
+						EE_Error::add_error(
1361
+							sprintf(
1362
+								esc_html__(
1363
+									'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1364
+									'event_espresso'
1365
+								),
1366
+								$file_path,
1367
+								$tour
1368
+							),
1369
+							__FILE__,
1370
+							__FUNCTION__,
1371
+							__LINE__
1372
+						);
1373
+						return;
1374
+					}
1375
+					require_once $file_path;
1376
+					if (! class_exists($tour)) {
1377
+						$error_msg[] = sprintf(
1378
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1379
+							$tour
1380
+						);
1381
+						$error_msg[] = $error_msg[0] . "\r\n"
1382
+									   . sprintf(
1383
+										   esc_html__(
1384
+											   'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1385
+											   'event_espresso'
1386
+										   ),
1387
+										   $tour,
1388
+										   '<br />',
1389
+										   $tour,
1390
+										   $this->_req_action,
1391
+										   get_class($this)
1392
+									   );
1393
+						throw new EE_Error(implode('||', $error_msg));
1394
+					}
1395
+					$tour_obj = new $tour($this->_is_caf);
1396
+					$tours[] = $tour_obj;
1397
+					$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1398
+				}
1399
+				// let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1400
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1401
+				$tours[] = $end_stop_tour;
1402
+				$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1403
+			}
1404
+		}
1405
+
1406
+		if (! empty($tours)) {
1407
+			$this->_help_tour['tours'] = $tours;
1408
+		}
1409
+		// that's it!  Now that the $_help_tours property is set (or not)
1410
+		// the scripts and html should be taken care of automatically.
1411
+
1412
+		/**
1413
+		 * Allow extending the help tours variable.
1414
+		 *
1415
+		 * @param Array $_help_tour The array containing all help tour information to be displayed.
1416
+		 */
1417
+		$this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1418
+	}
1419
+
1420
+
1421
+	/**
1422
+	 * This simply sets up any qtips that have been defined in the page config
1423
+	 *
1424
+	 * @return void
1425
+	 */
1426
+	protected function _add_qtips()
1427
+	{
1428
+		if (isset($this->_route_config['qtips'])) {
1429
+			$qtips = (array) $this->_route_config['qtips'];
1430
+			// load qtip loader
1431
+			$path = array(
1432
+				$this->_get_dir() . '/qtips/',
1433
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1434
+			);
1435
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1436
+		}
1437
+	}
1438
+
1439
+
1440
+	/**
1441
+	 * _set_nav_tabs
1442
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1443
+	 * wish to add additional tabs or modify accordingly.
1444
+	 *
1445
+	 * @return void
1446
+	 * @throws InvalidArgumentException
1447
+	 * @throws InvalidInterfaceException
1448
+	 * @throws InvalidDataTypeException
1449
+	 */
1450
+	protected function _set_nav_tabs()
1451
+	{
1452
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1453
+		$i = 0;
1454
+		foreach ($this->_page_config as $slug => $config) {
1455
+			if (! is_array($config)
1456
+				|| (
1457
+					is_array($config)
1458
+					&& (
1459
+						(isset($config['nav']) && ! $config['nav'])
1460
+						|| ! isset($config['nav'])
1461
+					)
1462
+				)
1463
+			) {
1464
+				continue;
1465
+			}
1466
+			// no nav tab for this config
1467
+			// check for persistent flag
1468
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1469
+				// nav tab is only to appear when route requested.
1470
+				continue;
1471
+			}
1472
+			if (! $this->check_user_access($slug, true)) {
1473
+				// no nav tab because current user does not have access.
1474
+				continue;
1475
+			}
1476
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1477
+			$this->_nav_tabs[ $slug ] = array(
1478
+				'url'       => isset($config['nav']['url'])
1479
+					? $config['nav']['url']
1480
+					: self::add_query_args_and_nonce(
1481
+						array('action' => $slug),
1482
+						$this->_admin_base_url
1483
+					),
1484
+				'link_text' => isset($config['nav']['label'])
1485
+					? $config['nav']['label']
1486
+					: ucwords(
1487
+						str_replace('_', ' ', $slug)
1488
+					),
1489
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1490
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1491
+			);
1492
+			$i++;
1493
+		}
1494
+		// if $this->_nav_tabs is empty then lets set the default
1495
+		if (empty($this->_nav_tabs)) {
1496
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1497
+				'url'       => $this->_admin_base_url,
1498
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1499
+				'css_class' => 'nav-tab-active',
1500
+				'order'     => 10,
1501
+			);
1502
+		}
1503
+		// now let's sort the tabs according to order
1504
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1505
+	}
1506
+
1507
+
1508
+	/**
1509
+	 * _set_current_labels
1510
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1511
+	 * property array
1512
+	 *
1513
+	 * @return void
1514
+	 */
1515
+	private function _set_current_labels()
1516
+	{
1517
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1518
+			foreach ($this->_route_config['labels'] as $label => $text) {
1519
+				if (is_array($text)) {
1520
+					foreach ($text as $sublabel => $subtext) {
1521
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1522
+					}
1523
+				} else {
1524
+					$this->_labels[ $label ] = $text;
1525
+				}
1526
+			}
1527
+		}
1528
+	}
1529
+
1530
+
1531
+	/**
1532
+	 *        verifies user access for this admin page
1533
+	 *
1534
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1535
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1536
+	 *                               return false if verify fail.
1537
+	 * @return bool
1538
+	 * @throws InvalidArgumentException
1539
+	 * @throws InvalidDataTypeException
1540
+	 * @throws InvalidInterfaceException
1541
+	 */
1542
+	public function check_user_access($route_to_check = '', $verify_only = false)
1543
+	{
1544
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1545
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1546
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1547
+					  && is_array(
1548
+						  $this->_page_routes[ $route_to_check ]
1549
+					  )
1550
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1551
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1552
+		if (empty($capability) && empty($route_to_check)) {
1553
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1554
+				: $this->_route['capability'];
1555
+		} else {
1556
+			$capability = empty($capability) ? 'manage_options' : $capability;
1557
+		}
1558
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1559
+		if (! defined('DOING_AJAX')
1560
+			&& (
1561
+				! function_exists('is_admin')
1562
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1563
+					$capability,
1564
+					$this->page_slug
1565
+					. '_'
1566
+					. $route_to_check,
1567
+					$id
1568
+				)
1569
+			)
1570
+		) {
1571
+			if ($verify_only) {
1572
+				return false;
1573
+			}
1574
+			if (is_user_logged_in()) {
1575
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1576
+			} else {
1577
+				return false;
1578
+			}
1579
+		}
1580
+		return true;
1581
+	}
1582
+
1583
+
1584
+	/**
1585
+	 * admin_init_global
1586
+	 * This runs all the code that we want executed within the WP admin_init hook.
1587
+	 * This method executes for ALL EE Admin pages.
1588
+	 *
1589
+	 * @return void
1590
+	 */
1591
+	public function admin_init_global()
1592
+	{
1593
+	}
1594
+
1595
+
1596
+	/**
1597
+	 * wp_loaded_global
1598
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1599
+	 * EE_Admin page and will execute on every EE Admin Page load
1600
+	 *
1601
+	 * @return void
1602
+	 */
1603
+	public function wp_loaded()
1604
+	{
1605
+	}
1606
+
1607
+
1608
+	/**
1609
+	 * admin_notices
1610
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1611
+	 * ALL EE_Admin pages.
1612
+	 *
1613
+	 * @return void
1614
+	 */
1615
+	public function admin_notices_global()
1616
+	{
1617
+		$this->_display_no_javascript_warning();
1618
+		$this->_display_espresso_notices();
1619
+	}
1620
+
1621
+
1622
+	public function network_admin_notices_global()
1623
+	{
1624
+		$this->_display_no_javascript_warning();
1625
+		$this->_display_espresso_notices();
1626
+	}
1627
+
1628
+
1629
+	/**
1630
+	 * admin_footer_scripts_global
1631
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1632
+	 * will apply on ALL EE_Admin pages.
1633
+	 *
1634
+	 * @return void
1635
+	 */
1636
+	public function admin_footer_scripts_global()
1637
+	{
1638
+		$this->_add_admin_page_ajax_loading_img();
1639
+		$this->_add_admin_page_overlay();
1640
+		// if metaboxes are present we need to add the nonce field
1641
+		if (isset($this->_route_config['metaboxes'])
1642
+			|| isset($this->_route_config['list_table'])
1643
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1644
+		) {
1645
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1646
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1647
+		}
1648
+	}
1649
+
1650
+
1651
+	/**
1652
+	 * admin_footer_global
1653
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1654
+	 * ALL EE_Admin Pages.
1655
+	 *
1656
+	 * @return void
1657
+	 * @throws EE_Error
1658
+	 */
1659
+	public function admin_footer_global()
1660
+	{
1661
+		// dialog container for dialog helper
1662
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1663
+		$d_cont .= '<div class="ee-notices"></div>';
1664
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1665
+		$d_cont .= '</div>';
1666
+		echo $d_cont;
1667
+		// help tour stuff?
1668
+		if (isset($this->_help_tour[ $this->_req_action ])) {
1669
+			echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1670
+		}
1671
+		// current set timezone for timezone js
1672
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1673
+	}
1674
+
1675
+
1676
+	/**
1677
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1678
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1679
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1680
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1681
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1682
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1683
+	 * for the
1684
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1685
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1686
+	 *    'help_trigger_id' => array(
1687
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1688
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1689
+	 *    )
1690
+	 * );
1691
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1692
+	 *
1693
+	 * @param array $help_array
1694
+	 * @param bool  $display
1695
+	 * @return string content
1696
+	 * @throws DomainException
1697
+	 * @throws EE_Error
1698
+	 */
1699
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1700
+	{
1701
+		$content = '';
1702
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1703
+		// loop through the array and setup content
1704
+		foreach ($help_array as $trigger => $help) {
1705
+			// make sure the array is setup properly
1706
+			if (! isset($help['title']) || ! isset($help['content'])) {
1707
+				throw new EE_Error(
1708
+					esc_html__(
1709
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1710
+						'event_espresso'
1711
+					)
1712
+				);
1713
+			}
1714
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1715
+			$template_args = array(
1716
+				'help_popup_id'      => $trigger,
1717
+				'help_popup_title'   => $help['title'],
1718
+				'help_popup_content' => $help['content'],
1719
+			);
1720
+			$content .= EEH_Template::display_template(
1721
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1722
+				$template_args,
1723
+				true
1724
+			);
1725
+		}
1726
+		if ($display) {
1727
+			echo $content;
1728
+			return '';
1729
+		}
1730
+		return $content;
1731
+	}
1732
+
1733
+
1734
+	/**
1735
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1736
+	 *
1737
+	 * @return array properly formatted array for help popup content
1738
+	 * @throws EE_Error
1739
+	 */
1740
+	private function _get_help_content()
1741
+	{
1742
+		// what is the method we're looking for?
1743
+		$method_name = '_help_popup_content_' . $this->_req_action;
1744
+		// if method doesn't exist let's get out.
1745
+		if (! method_exists($this, $method_name)) {
1746
+			return array();
1747
+		}
1748
+		// k we're good to go let's retrieve the help array
1749
+		$help_array = call_user_func(array($this, $method_name));
1750
+		// make sure we've got an array!
1751
+		if (! is_array($help_array)) {
1752
+			throw new EE_Error(
1753
+				esc_html__(
1754
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1755
+					'event_espresso'
1756
+				)
1757
+			);
1758
+		}
1759
+		return $help_array;
1760
+	}
1761
+
1762
+
1763
+	/**
1764
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1765
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1766
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1767
+	 *
1768
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1769
+	 * @param boolean $display    if false then we return the trigger string
1770
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1771
+	 * @return string
1772
+	 * @throws DomainException
1773
+	 * @throws EE_Error
1774
+	 */
1775
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1776
+	{
1777
+		if (defined('DOING_AJAX')) {
1778
+			return '';
1779
+		}
1780
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1781
+		$help_array = $this->_get_help_content();
1782
+		$help_content = '';
1783
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1784
+			$help_array[ $trigger_id ] = array(
1785
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1786
+				'content' => esc_html__(
1787
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1788
+					'event_espresso'
1789
+				),
1790
+			);
1791
+			$help_content = $this->_set_help_popup_content($help_array, false);
1792
+		}
1793
+		// let's setup the trigger
1794
+		$content = '<a class="ee-dialog" href="?height='
1795
+				   . $dimensions[0]
1796
+				   . '&width='
1797
+				   . $dimensions[1]
1798
+				   . '&inlineId='
1799
+				   . $trigger_id
1800
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1801
+		$content .= $help_content;
1802
+		if ($display) {
1803
+			echo $content;
1804
+			return '';
1805
+		}
1806
+		return $content;
1807
+	}
1808
+
1809
+
1810
+	/**
1811
+	 * _add_global_screen_options
1812
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1813
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1814
+	 *
1815
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1816
+	 *         see also WP_Screen object documents...
1817
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1818
+	 * @abstract
1819
+	 * @return void
1820
+	 */
1821
+	private function _add_global_screen_options()
1822
+	{
1823
+	}
1824
+
1825
+
1826
+	/**
1827
+	 * _add_global_feature_pointers
1828
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1829
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1830
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1831
+	 *
1832
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1833
+	 *         extended) also see:
1834
+	 * @link   http://eamann.com/tech/wordpress-portland/
1835
+	 * @abstract
1836
+	 * @return void
1837
+	 */
1838
+	private function _add_global_feature_pointers()
1839
+	{
1840
+	}
1841
+
1842
+
1843
+	/**
1844
+	 * load_global_scripts_styles
1845
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1846
+	 *
1847
+	 * @return void
1848
+	 * @throws EE_Error
1849
+	 */
1850
+	public function load_global_scripts_styles()
1851
+	{
1852
+		/** STYLES **/
1853
+		// add debugging styles
1854
+		if (WP_DEBUG) {
1855
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1856
+		}
1857
+		// register all styles
1858
+		wp_register_style(
1859
+			'espresso-ui-theme',
1860
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1861
+			array(),
1862
+			EVENT_ESPRESSO_VERSION
1863
+		);
1864
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1865
+		// helpers styles
1866
+		wp_register_style(
1867
+			'ee-text-links',
1868
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1869
+			array(),
1870
+			EVENT_ESPRESSO_VERSION
1871
+		);
1872
+		/** SCRIPTS **/
1873
+		// register all scripts
1874
+		wp_register_script(
1875
+			'ee-dialog',
1876
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1877
+			array('jquery', 'jquery-ui-draggable'),
1878
+			EVENT_ESPRESSO_VERSION,
1879
+			true
1880
+		);
1881
+		wp_register_script(
1882
+			'ee_admin_js',
1883
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1884
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1885
+			EVENT_ESPRESSO_VERSION,
1886
+			true
1887
+		);
1888
+		wp_register_script(
1889
+			'jquery-ui-timepicker-addon',
1890
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1891
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1892
+			EVENT_ESPRESSO_VERSION,
1893
+			true
1894
+		);
1895
+		if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1896
+			add_filter('FHEE_load_joyride', '__return_true');
1897
+		}
1898
+		// script for sorting tables
1899
+		wp_register_script(
1900
+			'espresso_ajax_table_sorting',
1901
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1902
+			array('ee_admin_js', 'jquery-ui-sortable'),
1903
+			EVENT_ESPRESSO_VERSION,
1904
+			true
1905
+		);
1906
+		// script for parsing uri's
1907
+		wp_register_script(
1908
+			'ee-parse-uri',
1909
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1910
+			array(),
1911
+			EVENT_ESPRESSO_VERSION,
1912
+			true
1913
+		);
1914
+		// and parsing associative serialized form elements
1915
+		wp_register_script(
1916
+			'ee-serialize-full-array',
1917
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1918
+			array('jquery'),
1919
+			EVENT_ESPRESSO_VERSION,
1920
+			true
1921
+		);
1922
+		// helpers scripts
1923
+		wp_register_script(
1924
+			'ee-text-links',
1925
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1926
+			array('jquery'),
1927
+			EVENT_ESPRESSO_VERSION,
1928
+			true
1929
+		);
1930
+		wp_register_script(
1931
+			'ee-moment-core',
1932
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1933
+			array(),
1934
+			EVENT_ESPRESSO_VERSION,
1935
+			true
1936
+		);
1937
+		wp_register_script(
1938
+			'ee-moment',
1939
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1940
+			array('ee-moment-core'),
1941
+			EVENT_ESPRESSO_VERSION,
1942
+			true
1943
+		);
1944
+		wp_register_script(
1945
+			'ee-datepicker',
1946
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1947
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1948
+			EVENT_ESPRESSO_VERSION,
1949
+			true
1950
+		);
1951
+		// google charts
1952
+		wp_register_script(
1953
+			'google-charts',
1954
+			'https://www.gstatic.com/charts/loader.js',
1955
+			array(),
1956
+			EVENT_ESPRESSO_VERSION,
1957
+			false
1958
+		);
1959
+		// ENQUEUE ALL BASICS BY DEFAULT
1960
+		wp_enqueue_style('ee-admin-css');
1961
+		wp_enqueue_script('ee_admin_js');
1962
+		wp_enqueue_script('ee-accounting');
1963
+		wp_enqueue_script('jquery-validate');
1964
+		// taking care of metaboxes
1965
+		if (empty($this->_cpt_route)
1966
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1967
+		) {
1968
+			wp_enqueue_script('dashboard');
1969
+		}
1970
+		// LOCALIZED DATA
1971
+		// localize script for ajax lazy loading
1972
+		$lazy_loader_container_ids = apply_filters(
1973
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1974
+			array('espresso_news_post_box_content')
1975
+		);
1976
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1977
+		/**
1978
+		 * help tour stuff
1979
+		 */
1980
+		if (! empty($this->_help_tour)) {
1981
+			// register the js for kicking things off
1982
+			wp_enqueue_script(
1983
+				'ee-help-tour',
1984
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
1985
+				array('jquery-joyride'),
1986
+				EVENT_ESPRESSO_VERSION,
1987
+				true
1988
+			);
1989
+			$tours = array();
1990
+			// setup tours for the js tour object
1991
+			foreach ($this->_help_tour['tours'] as $tour) {
1992
+				if ($tour instanceof EE_Help_Tour) {
1993
+					$tours[] = array(
1994
+						'id'      => $tour->get_slug(),
1995
+						'options' => $tour->get_options(),
1996
+					);
1997
+				}
1998
+			}
1999
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2000
+			// admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2001
+		}
2002
+	}
2003
+
2004
+
2005
+	/**
2006
+	 *        admin_footer_scripts_eei18n_js_strings
2007
+	 *
2008
+	 * @return        void
2009
+	 */
2010
+	public function admin_footer_scripts_eei18n_js_strings()
2011
+	{
2012
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2013
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2014
+			'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2015
+			'event_espresso'
2016
+		);
2017
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2018
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2019
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2020
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2021
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2022
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2023
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2024
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2025
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2026
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2027
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2028
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2029
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2030
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2031
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2032
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2033
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2034
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2035
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2036
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2037
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2038
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2039
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2040
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2041
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2042
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2043
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2044
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2045
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2046
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2047
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2048
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2049
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2050
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2051
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2052
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2053
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2054
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2055
+	}
2056
+
2057
+
2058
+	/**
2059
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2060
+	 *
2061
+	 * @return        void
2062
+	 */
2063
+	public function add_xdebug_style()
2064
+	{
2065
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2066
+	}
2067
+
2068
+
2069
+	/************************/
2070
+	/** LIST TABLE METHODS **/
2071
+	/************************/
2072
+	/**
2073
+	 * this sets up the list table if the current view requires it.
2074
+	 *
2075
+	 * @return void
2076
+	 * @throws EE_Error
2077
+	 */
2078
+	protected function _set_list_table()
2079
+	{
2080
+		// first is this a list_table view?
2081
+		if (! isset($this->_route_config['list_table'])) {
2082
+			return;
2083
+		} //not a list_table view so get out.
2084
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2085
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2086
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2087
+			// user error msg
2088
+			$error_msg = esc_html__(
2089
+				'An error occurred. The requested list table views could not be found.',
2090
+				'event_espresso'
2091
+			);
2092
+			// developer error msg
2093
+			$error_msg .= '||'
2094
+						  . sprintf(
2095
+							  esc_html__(
2096
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2097
+								  'event_espresso'
2098
+							  ),
2099
+							  $this->_req_action,
2100
+							  $list_table_view
2101
+						  );
2102
+			throw new EE_Error($error_msg);
2103
+		}
2104
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2105
+		$this->_views = apply_filters(
2106
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2107
+			$this->_views
2108
+		);
2109
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2110
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2111
+		$this->_set_list_table_view();
2112
+		$this->_set_list_table_object();
2113
+	}
2114
+
2115
+
2116
+	/**
2117
+	 * set current view for List Table
2118
+	 *
2119
+	 * @return void
2120
+	 */
2121
+	protected function _set_list_table_view()
2122
+	{
2123
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
+		// looking at active items or dumpster diving ?
2125
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2126
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2127
+		} else {
2128
+			$this->_view = sanitize_key($this->_req_data['status']);
2129
+		}
2130
+	}
2131
+
2132
+
2133
+	/**
2134
+	 * _set_list_table_object
2135
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2136
+	 *
2137
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2138
+	 * @throws \InvalidArgumentException
2139
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2140
+	 * @throws EE_Error
2141
+	 * @throws InvalidInterfaceException
2142
+	 */
2143
+	protected function _set_list_table_object()
2144
+	{
2145
+		if (isset($this->_route_config['list_table'])) {
2146
+			if (! class_exists($this->_route_config['list_table'])) {
2147
+				throw new EE_Error(
2148
+					sprintf(
2149
+						esc_html__(
2150
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2151
+							'event_espresso'
2152
+						),
2153
+						$this->_route_config['list_table'],
2154
+						get_class($this)
2155
+					)
2156
+				);
2157
+			}
2158
+			$this->_list_table_object = $this->loader->getShared(
2159
+				$this->_route_config['list_table'],
2160
+				array($this)
2161
+			);
2162
+		}
2163
+	}
2164
+
2165
+
2166
+	/**
2167
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2168
+	 *
2169
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2170
+	 *                                                    urls.  The array should be indexed by the view it is being
2171
+	 *                                                    added to.
2172
+	 * @return array
2173
+	 */
2174
+	public function get_list_table_view_RLs($extra_query_args = array())
2175
+	{
2176
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2177
+		if (empty($this->_views)) {
2178
+			$this->_views = array();
2179
+		}
2180
+		// cycle thru views
2181
+		foreach ($this->_views as $key => $view) {
2182
+			$query_args = array();
2183
+			// check for current view
2184
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2185
+			$query_args['action'] = $this->_req_action;
2186
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2187
+			$query_args['status'] = $view['slug'];
2188
+			// merge any other arguments sent in.
2189
+			if (isset($extra_query_args[ $view['slug'] ])) {
2190
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2191
+			}
2192
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2193
+		}
2194
+		return $this->_views;
2195
+	}
2196
+
2197
+
2198
+	/**
2199
+	 * _entries_per_page_dropdown
2200
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2201
+	 *
2202
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2203
+	 *         WP does it.
2204
+	 * @param int $max_entries total number of rows in the table
2205
+	 * @return string
2206
+	 */
2207
+	protected function _entries_per_page_dropdown($max_entries = 0)
2208
+	{
2209
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2210
+		$values = array(10, 25, 50, 100);
2211
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2212
+		if ($max_entries) {
2213
+			$values[] = $max_entries;
2214
+			sort($values);
2215
+		}
2216
+		$entries_per_page_dropdown = '
2217 2217
 			<div id="entries-per-page-dv" class="alignleft actions">
2218 2218
 				<label class="hide-if-no-js">
2219 2219
 					Show
2220 2220
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2221
-        foreach ($values as $value) {
2222
-            if ($value < $max_entries) {
2223
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2224
-                $entries_per_page_dropdown .= '
2221
+		foreach ($values as $value) {
2222
+			if ($value < $max_entries) {
2223
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2224
+				$entries_per_page_dropdown .= '
2225 2225
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2226
-            }
2227
-        }
2228
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2229
-        $entries_per_page_dropdown .= '
2226
+			}
2227
+		}
2228
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2229
+		$entries_per_page_dropdown .= '
2230 2230
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2231
-        $entries_per_page_dropdown .= '
2231
+		$entries_per_page_dropdown .= '
2232 2232
 					</select>
2233 2233
 					entries
2234 2234
 				</label>
2235 2235
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2236 2236
 			</div>
2237 2237
 		';
2238
-        return $entries_per_page_dropdown;
2239
-    }
2240
-
2241
-
2242
-    /**
2243
-     *        _set_search_attributes
2244
-     *
2245
-     * @return        void
2246
-     */
2247
-    public function _set_search_attributes()
2248
-    {
2249
-        $this->_template_args['search']['btn_label'] = sprintf(
2250
-            esc_html__('Search %s', 'event_espresso'),
2251
-            empty($this->_search_btn_label) ? $this->page_label
2252
-                : $this->_search_btn_label
2253
-        );
2254
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2255
-    }
2256
-
2257
-
2258
-
2259
-    /*** END LIST TABLE METHODS **/
2260
-
2261
-
2262
-    /**
2263
-     * _add_registered_metaboxes
2264
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2265
-     *
2266
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2267
-     * @return void
2268
-     * @throws EE_Error
2269
-     */
2270
-    private function _add_registered_meta_boxes()
2271
-    {
2272
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2273
-        // we only add meta boxes if the page_route calls for it
2274
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2275
-            && is_array(
2276
-                $this->_route_config['metaboxes']
2277
-            )
2278
-        ) {
2279
-            // this simply loops through the callbacks provided
2280
-            // and checks if there is a corresponding callback registered by the child
2281
-            // if there is then we go ahead and process the metabox loader.
2282
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2283
-                // first check for Closures
2284
-                if ($metabox_callback instanceof Closure) {
2285
-                    $result = $metabox_callback();
2286
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2287
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2288
-                } else {
2289
-                    $result = call_user_func(array($this, &$metabox_callback));
2290
-                }
2291
-                if ($result === false) {
2292
-                    // user error msg
2293
-                    $error_msg = esc_html__(
2294
-                        'An error occurred. The  requested metabox could not be found.',
2295
-                        'event_espresso'
2296
-                    );
2297
-                    // developer error msg
2298
-                    $error_msg .= '||'
2299
-                                  . sprintf(
2300
-                                      esc_html__(
2301
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2302
-                                          'event_espresso'
2303
-                                      ),
2304
-                                      $metabox_callback
2305
-                                  );
2306
-                    throw new EE_Error($error_msg);
2307
-                }
2308
-            }
2309
-        }
2310
-    }
2311
-
2312
-
2313
-    /**
2314
-     * _add_screen_columns
2315
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2316
-     * the dynamic column template and we'll setup the column options for the page.
2317
-     *
2318
-     * @return void
2319
-     */
2320
-    private function _add_screen_columns()
2321
-    {
2322
-        if (is_array($this->_route_config)
2323
-            && isset($this->_route_config['columns'])
2324
-            && is_array($this->_route_config['columns'])
2325
-            && count($this->_route_config['columns']) === 2
2326
-        ) {
2327
-            add_screen_option(
2328
-                'layout_columns',
2329
-                array(
2330
-                    'max'     => (int) $this->_route_config['columns'][0],
2331
-                    'default' => (int) $this->_route_config['columns'][1],
2332
-                )
2333
-            );
2334
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2335
-            $screen_id = $this->_current_screen->id;
2336
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2337
-            $total_columns = ! empty($screen_columns)
2338
-                ? $screen_columns
2339
-                : $this->_route_config['columns'][1];
2340
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2341
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2342
-            $this->_template_args['screen'] = $this->_current_screen;
2343
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2344
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2345
-            // finally if we don't have has_metaboxes set in the route config
2346
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2347
-            $this->_route_config['has_metaboxes'] = true;
2348
-        }
2349
-    }
2350
-
2351
-
2352
-
2353
-    /** GLOBALLY AVAILABLE METABOXES **/
2354
-
2355
-
2356
-    /**
2357
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2358
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2359
-     * these get loaded on.
2360
-     */
2361
-    private function _espresso_news_post_box()
2362
-    {
2363
-        $news_box_title = apply_filters(
2364
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2365
-            esc_html__('New @ Event Espresso', 'event_espresso')
2366
-        );
2367
-        add_meta_box(
2368
-            'espresso_news_post_box',
2369
-            $news_box_title,
2370
-            array(
2371
-                $this,
2372
-                'espresso_news_post_box',
2373
-            ),
2374
-            $this->_wp_page_slug,
2375
-            'side'
2376
-        );
2377
-    }
2378
-
2379
-
2380
-    /**
2381
-     * Code for setting up espresso ratings request metabox.
2382
-     */
2383
-    protected function _espresso_ratings_request()
2384
-    {
2385
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2386
-            return;
2387
-        }
2388
-        $ratings_box_title = apply_filters(
2389
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2390
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2391
-        );
2392
-        add_meta_box(
2393
-            'espresso_ratings_request',
2394
-            $ratings_box_title,
2395
-            array(
2396
-                $this,
2397
-                'espresso_ratings_request',
2398
-            ),
2399
-            $this->_wp_page_slug,
2400
-            'side'
2401
-        );
2402
-    }
2403
-
2404
-
2405
-    /**
2406
-     * Code for setting up espresso ratings request metabox content.
2407
-     *
2408
-     * @throws DomainException
2409
-     */
2410
-    public function espresso_ratings_request()
2411
-    {
2412
-        EEH_Template::display_template(
2413
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2414
-            array()
2415
-        );
2416
-    }
2417
-
2418
-
2419
-    public static function cached_rss_display($rss_id, $url)
2420
-    {
2421
-        $loading = '<p class="widget-loading hide-if-no-js">'
2422
-                   . __('Loading&#8230;', 'event_espresso')
2423
-                   . '</p><p class="hide-if-js">'
2424
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2425
-                   . '</p>';
2426
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2427
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2428
-        $post = '</div>' . "\n";
2429
-        $cache_key = 'ee_rss_' . md5($rss_id);
2430
-        $output = get_transient($cache_key);
2431
-        if ($output !== false) {
2432
-            echo $pre . $output . $post;
2433
-            return true;
2434
-        }
2435
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2436
-            echo $pre . $loading . $post;
2437
-            return false;
2438
-        }
2439
-        ob_start();
2440
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2441
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2442
-        return true;
2443
-    }
2444
-
2445
-
2446
-    public function espresso_news_post_box()
2447
-    {
2448
-        ?>
2238
+		return $entries_per_page_dropdown;
2239
+	}
2240
+
2241
+
2242
+	/**
2243
+	 *        _set_search_attributes
2244
+	 *
2245
+	 * @return        void
2246
+	 */
2247
+	public function _set_search_attributes()
2248
+	{
2249
+		$this->_template_args['search']['btn_label'] = sprintf(
2250
+			esc_html__('Search %s', 'event_espresso'),
2251
+			empty($this->_search_btn_label) ? $this->page_label
2252
+				: $this->_search_btn_label
2253
+		);
2254
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2255
+	}
2256
+
2257
+
2258
+
2259
+	/*** END LIST TABLE METHODS **/
2260
+
2261
+
2262
+	/**
2263
+	 * _add_registered_metaboxes
2264
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2265
+	 *
2266
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2267
+	 * @return void
2268
+	 * @throws EE_Error
2269
+	 */
2270
+	private function _add_registered_meta_boxes()
2271
+	{
2272
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2273
+		// we only add meta boxes if the page_route calls for it
2274
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2275
+			&& is_array(
2276
+				$this->_route_config['metaboxes']
2277
+			)
2278
+		) {
2279
+			// this simply loops through the callbacks provided
2280
+			// and checks if there is a corresponding callback registered by the child
2281
+			// if there is then we go ahead and process the metabox loader.
2282
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2283
+				// first check for Closures
2284
+				if ($metabox_callback instanceof Closure) {
2285
+					$result = $metabox_callback();
2286
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2287
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2288
+				} else {
2289
+					$result = call_user_func(array($this, &$metabox_callback));
2290
+				}
2291
+				if ($result === false) {
2292
+					// user error msg
2293
+					$error_msg = esc_html__(
2294
+						'An error occurred. The  requested metabox could not be found.',
2295
+						'event_espresso'
2296
+					);
2297
+					// developer error msg
2298
+					$error_msg .= '||'
2299
+								  . sprintf(
2300
+									  esc_html__(
2301
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2302
+										  'event_espresso'
2303
+									  ),
2304
+									  $metabox_callback
2305
+								  );
2306
+					throw new EE_Error($error_msg);
2307
+				}
2308
+			}
2309
+		}
2310
+	}
2311
+
2312
+
2313
+	/**
2314
+	 * _add_screen_columns
2315
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2316
+	 * the dynamic column template and we'll setup the column options for the page.
2317
+	 *
2318
+	 * @return void
2319
+	 */
2320
+	private function _add_screen_columns()
2321
+	{
2322
+		if (is_array($this->_route_config)
2323
+			&& isset($this->_route_config['columns'])
2324
+			&& is_array($this->_route_config['columns'])
2325
+			&& count($this->_route_config['columns']) === 2
2326
+		) {
2327
+			add_screen_option(
2328
+				'layout_columns',
2329
+				array(
2330
+					'max'     => (int) $this->_route_config['columns'][0],
2331
+					'default' => (int) $this->_route_config['columns'][1],
2332
+				)
2333
+			);
2334
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2335
+			$screen_id = $this->_current_screen->id;
2336
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2337
+			$total_columns = ! empty($screen_columns)
2338
+				? $screen_columns
2339
+				: $this->_route_config['columns'][1];
2340
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2341
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2342
+			$this->_template_args['screen'] = $this->_current_screen;
2343
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2344
+										   . 'admin_details_metabox_column_wrapper.template.php';
2345
+			// finally if we don't have has_metaboxes set in the route config
2346
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2347
+			$this->_route_config['has_metaboxes'] = true;
2348
+		}
2349
+	}
2350
+
2351
+
2352
+
2353
+	/** GLOBALLY AVAILABLE METABOXES **/
2354
+
2355
+
2356
+	/**
2357
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2358
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2359
+	 * these get loaded on.
2360
+	 */
2361
+	private function _espresso_news_post_box()
2362
+	{
2363
+		$news_box_title = apply_filters(
2364
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2365
+			esc_html__('New @ Event Espresso', 'event_espresso')
2366
+		);
2367
+		add_meta_box(
2368
+			'espresso_news_post_box',
2369
+			$news_box_title,
2370
+			array(
2371
+				$this,
2372
+				'espresso_news_post_box',
2373
+			),
2374
+			$this->_wp_page_slug,
2375
+			'side'
2376
+		);
2377
+	}
2378
+
2379
+
2380
+	/**
2381
+	 * Code for setting up espresso ratings request metabox.
2382
+	 */
2383
+	protected function _espresso_ratings_request()
2384
+	{
2385
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2386
+			return;
2387
+		}
2388
+		$ratings_box_title = apply_filters(
2389
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2390
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2391
+		);
2392
+		add_meta_box(
2393
+			'espresso_ratings_request',
2394
+			$ratings_box_title,
2395
+			array(
2396
+				$this,
2397
+				'espresso_ratings_request',
2398
+			),
2399
+			$this->_wp_page_slug,
2400
+			'side'
2401
+		);
2402
+	}
2403
+
2404
+
2405
+	/**
2406
+	 * Code for setting up espresso ratings request metabox content.
2407
+	 *
2408
+	 * @throws DomainException
2409
+	 */
2410
+	public function espresso_ratings_request()
2411
+	{
2412
+		EEH_Template::display_template(
2413
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2414
+			array()
2415
+		);
2416
+	}
2417
+
2418
+
2419
+	public static function cached_rss_display($rss_id, $url)
2420
+	{
2421
+		$loading = '<p class="widget-loading hide-if-no-js">'
2422
+				   . __('Loading&#8230;', 'event_espresso')
2423
+				   . '</p><p class="hide-if-js">'
2424
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2425
+				   . '</p>';
2426
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2427
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2428
+		$post = '</div>' . "\n";
2429
+		$cache_key = 'ee_rss_' . md5($rss_id);
2430
+		$output = get_transient($cache_key);
2431
+		if ($output !== false) {
2432
+			echo $pre . $output . $post;
2433
+			return true;
2434
+		}
2435
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2436
+			echo $pre . $loading . $post;
2437
+			return false;
2438
+		}
2439
+		ob_start();
2440
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2441
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2442
+		return true;
2443
+	}
2444
+
2445
+
2446
+	public function espresso_news_post_box()
2447
+	{
2448
+		?>
2449 2449
         <div class="padding">
2450 2450
             <div id="espresso_news_post_box_content" class="infolinks">
2451 2451
                 <?php
2452
-                // Get RSS Feed(s)
2453
-                self::cached_rss_display(
2454
-                    'espresso_news_post_box_content',
2455
-                    urlencode(
2456
-                        apply_filters(
2457
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2458
-                            'http://eventespresso.com/feed/'
2459
-                        )
2460
-                    )
2461
-                );
2462
-                ?>
2452
+				// Get RSS Feed(s)
2453
+				self::cached_rss_display(
2454
+					'espresso_news_post_box_content',
2455
+					urlencode(
2456
+						apply_filters(
2457
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2458
+							'http://eventespresso.com/feed/'
2459
+						)
2460
+					)
2461
+				);
2462
+				?>
2463 2463
             </div>
2464 2464
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2465 2465
         </div>
2466 2466
         <?php
2467
-    }
2468
-
2469
-
2470
-    private function _espresso_links_post_box()
2471
-    {
2472
-        // Hiding until we actually have content to put in here...
2473
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2474
-    }
2475
-
2476
-
2477
-    public function espresso_links_post_box()
2478
-    {
2479
-        // Hiding until we actually have content to put in here...
2480
-        // EEH_Template::display_template(
2481
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2482
-        // );
2483
-    }
2484
-
2485
-
2486
-    protected function _espresso_sponsors_post_box()
2487
-    {
2488
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2489
-            add_meta_box(
2490
-                'espresso_sponsors_post_box',
2491
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2492
-                array($this, 'espresso_sponsors_post_box'),
2493
-                $this->_wp_page_slug,
2494
-                'side'
2495
-            );
2496
-        }
2497
-    }
2498
-
2499
-
2500
-    public function espresso_sponsors_post_box()
2501
-    {
2502
-        EEH_Template::display_template(
2503
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2504
-        );
2505
-    }
2506
-
2507
-
2508
-    private function _publish_post_box()
2509
-    {
2510
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2511
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2512
-        // then we'll use that for the metabox label.
2513
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2514
-        if (! empty($this->_labels['publishbox'])) {
2515
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2516
-                : $this->_labels['publishbox'];
2517
-        } else {
2518
-            $box_label = esc_html__('Publish', 'event_espresso');
2519
-        }
2520
-        $box_label = apply_filters(
2521
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2522
-            $box_label,
2523
-            $this->_req_action,
2524
-            $this
2525
-        );
2526
-        add_meta_box(
2527
-            $meta_box_ref,
2528
-            $box_label,
2529
-            array($this, 'editor_overview'),
2530
-            $this->_current_screen->id,
2531
-            'side',
2532
-            'high'
2533
-        );
2534
-    }
2535
-
2536
-
2537
-    public function editor_overview()
2538
-    {
2539
-        // if we have extra content set let's add it in if not make sure its empty
2540
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2541
-            ? $this->_template_args['publish_box_extra_content']
2542
-            : '';
2543
-        echo EEH_Template::display_template(
2544
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2545
-            $this->_template_args,
2546
-            true
2547
-        );
2548
-    }
2549
-
2550
-
2551
-    /** end of globally available metaboxes section **/
2552
-
2553
-
2554
-    /**
2555
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2556
-     * protected method.
2557
-     *
2558
-     * @see   $this->_set_publish_post_box_vars for param details
2559
-     * @since 4.6.0
2560
-     * @param string $name
2561
-     * @param int    $id
2562
-     * @param bool   $delete
2563
-     * @param string $save_close_redirect_URL
2564
-     * @param bool   $both_btns
2565
-     * @throws EE_Error
2566
-     * @throws InvalidArgumentException
2567
-     * @throws InvalidDataTypeException
2568
-     * @throws InvalidInterfaceException
2569
-     */
2570
-    public function set_publish_post_box_vars(
2571
-        $name = '',
2572
-        $id = 0,
2573
-        $delete = false,
2574
-        $save_close_redirect_URL = '',
2575
-        $both_btns = true
2576
-    ) {
2577
-        $this->_set_publish_post_box_vars(
2578
-            $name,
2579
-            $id,
2580
-            $delete,
2581
-            $save_close_redirect_URL,
2582
-            $both_btns
2583
-        );
2584
-    }
2585
-
2586
-
2587
-    /**
2588
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2589
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2590
-     * save, and save and close buttons to work properly, then you will want to include a
2591
-     * values for the name and id arguments.
2592
-     *
2593
-     * @todo  Add in validation for name/id arguments.
2594
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2595
-     * @param    int     $id                      id attached to the item published
2596
-     * @param    string  $delete                  page route callback for the delete action
2597
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2598
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2599
-     *                                            the Save button
2600
-     * @throws EE_Error
2601
-     * @throws InvalidArgumentException
2602
-     * @throws InvalidDataTypeException
2603
-     * @throws InvalidInterfaceException
2604
-     */
2605
-    protected function _set_publish_post_box_vars(
2606
-        $name = '',
2607
-        $id = 0,
2608
-        $delete = '',
2609
-        $save_close_redirect_URL = '',
2610
-        $both_btns = true
2611
-    ) {
2612
-        // if Save & Close, use a custom redirect URL or default to the main page?
2613
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2614
-            ? $save_close_redirect_URL
2615
-            : $this->_admin_base_url;
2616
-        // create the Save & Close and Save buttons
2617
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2618
-        // if we have extra content set let's add it in if not make sure its empty
2619
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2620
-            ? $this->_template_args['publish_box_extra_content']
2621
-            : '';
2622
-        if ($delete && ! empty($id)) {
2623
-            // make sure we have a default if just true is sent.
2624
-            $delete = ! empty($delete) ? $delete : 'delete';
2625
-            $delete_link_args = array($name => $id);
2626
-            $delete = $this->get_action_link_or_button(
2627
-                $delete,
2628
-                $delete,
2629
-                $delete_link_args,
2630
-                'submitdelete deletion',
2631
-                '',
2632
-                false
2633
-            );
2634
-        }
2635
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2636
-        if (! empty($name) && ! empty($id)) {
2637
-            $hidden_field_arr[ $name ] = array(
2638
-                'type'  => 'hidden',
2639
-                'value' => $id,
2640
-            );
2641
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2642
-        } else {
2643
-            $hf = '';
2644
-        }
2645
-        // add hidden field
2646
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2647
-            ? $hf[ $name ]['field']
2648
-            : $hf;
2649
-    }
2650
-
2651
-
2652
-    /**
2653
-     * displays an error message to ppl who have javascript disabled
2654
-     *
2655
-     * @return void
2656
-     */
2657
-    private function _display_no_javascript_warning()
2658
-    {
2659
-        ?>
2467
+	}
2468
+
2469
+
2470
+	private function _espresso_links_post_box()
2471
+	{
2472
+		// Hiding until we actually have content to put in here...
2473
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2474
+	}
2475
+
2476
+
2477
+	public function espresso_links_post_box()
2478
+	{
2479
+		// Hiding until we actually have content to put in here...
2480
+		// EEH_Template::display_template(
2481
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2482
+		// );
2483
+	}
2484
+
2485
+
2486
+	protected function _espresso_sponsors_post_box()
2487
+	{
2488
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2489
+			add_meta_box(
2490
+				'espresso_sponsors_post_box',
2491
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2492
+				array($this, 'espresso_sponsors_post_box'),
2493
+				$this->_wp_page_slug,
2494
+				'side'
2495
+			);
2496
+		}
2497
+	}
2498
+
2499
+
2500
+	public function espresso_sponsors_post_box()
2501
+	{
2502
+		EEH_Template::display_template(
2503
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2504
+		);
2505
+	}
2506
+
2507
+
2508
+	private function _publish_post_box()
2509
+	{
2510
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2511
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2512
+		// then we'll use that for the metabox label.
2513
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2514
+		if (! empty($this->_labels['publishbox'])) {
2515
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2516
+				: $this->_labels['publishbox'];
2517
+		} else {
2518
+			$box_label = esc_html__('Publish', 'event_espresso');
2519
+		}
2520
+		$box_label = apply_filters(
2521
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2522
+			$box_label,
2523
+			$this->_req_action,
2524
+			$this
2525
+		);
2526
+		add_meta_box(
2527
+			$meta_box_ref,
2528
+			$box_label,
2529
+			array($this, 'editor_overview'),
2530
+			$this->_current_screen->id,
2531
+			'side',
2532
+			'high'
2533
+		);
2534
+	}
2535
+
2536
+
2537
+	public function editor_overview()
2538
+	{
2539
+		// if we have extra content set let's add it in if not make sure its empty
2540
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2541
+			? $this->_template_args['publish_box_extra_content']
2542
+			: '';
2543
+		echo EEH_Template::display_template(
2544
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2545
+			$this->_template_args,
2546
+			true
2547
+		);
2548
+	}
2549
+
2550
+
2551
+	/** end of globally available metaboxes section **/
2552
+
2553
+
2554
+	/**
2555
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2556
+	 * protected method.
2557
+	 *
2558
+	 * @see   $this->_set_publish_post_box_vars for param details
2559
+	 * @since 4.6.0
2560
+	 * @param string $name
2561
+	 * @param int    $id
2562
+	 * @param bool   $delete
2563
+	 * @param string $save_close_redirect_URL
2564
+	 * @param bool   $both_btns
2565
+	 * @throws EE_Error
2566
+	 * @throws InvalidArgumentException
2567
+	 * @throws InvalidDataTypeException
2568
+	 * @throws InvalidInterfaceException
2569
+	 */
2570
+	public function set_publish_post_box_vars(
2571
+		$name = '',
2572
+		$id = 0,
2573
+		$delete = false,
2574
+		$save_close_redirect_URL = '',
2575
+		$both_btns = true
2576
+	) {
2577
+		$this->_set_publish_post_box_vars(
2578
+			$name,
2579
+			$id,
2580
+			$delete,
2581
+			$save_close_redirect_URL,
2582
+			$both_btns
2583
+		);
2584
+	}
2585
+
2586
+
2587
+	/**
2588
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2589
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2590
+	 * save, and save and close buttons to work properly, then you will want to include a
2591
+	 * values for the name and id arguments.
2592
+	 *
2593
+	 * @todo  Add in validation for name/id arguments.
2594
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2595
+	 * @param    int     $id                      id attached to the item published
2596
+	 * @param    string  $delete                  page route callback for the delete action
2597
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2598
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2599
+	 *                                            the Save button
2600
+	 * @throws EE_Error
2601
+	 * @throws InvalidArgumentException
2602
+	 * @throws InvalidDataTypeException
2603
+	 * @throws InvalidInterfaceException
2604
+	 */
2605
+	protected function _set_publish_post_box_vars(
2606
+		$name = '',
2607
+		$id = 0,
2608
+		$delete = '',
2609
+		$save_close_redirect_URL = '',
2610
+		$both_btns = true
2611
+	) {
2612
+		// if Save & Close, use a custom redirect URL or default to the main page?
2613
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2614
+			? $save_close_redirect_URL
2615
+			: $this->_admin_base_url;
2616
+		// create the Save & Close and Save buttons
2617
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2618
+		// if we have extra content set let's add it in if not make sure its empty
2619
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2620
+			? $this->_template_args['publish_box_extra_content']
2621
+			: '';
2622
+		if ($delete && ! empty($id)) {
2623
+			// make sure we have a default if just true is sent.
2624
+			$delete = ! empty($delete) ? $delete : 'delete';
2625
+			$delete_link_args = array($name => $id);
2626
+			$delete = $this->get_action_link_or_button(
2627
+				$delete,
2628
+				$delete,
2629
+				$delete_link_args,
2630
+				'submitdelete deletion',
2631
+				'',
2632
+				false
2633
+			);
2634
+		}
2635
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2636
+		if (! empty($name) && ! empty($id)) {
2637
+			$hidden_field_arr[ $name ] = array(
2638
+				'type'  => 'hidden',
2639
+				'value' => $id,
2640
+			);
2641
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2642
+		} else {
2643
+			$hf = '';
2644
+		}
2645
+		// add hidden field
2646
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2647
+			? $hf[ $name ]['field']
2648
+			: $hf;
2649
+	}
2650
+
2651
+
2652
+	/**
2653
+	 * displays an error message to ppl who have javascript disabled
2654
+	 *
2655
+	 * @return void
2656
+	 */
2657
+	private function _display_no_javascript_warning()
2658
+	{
2659
+		?>
2660 2660
         <noscript>
2661 2661
             <div id="no-js-message" class="error">
2662 2662
                 <p style="font-size:1.3em;">
2663 2663
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2664 2664
                     <?php esc_html_e(
2665
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2666
-                        'event_espresso'
2667
-                    ); ?>
2665
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2666
+						'event_espresso'
2667
+					); ?>
2668 2668
                 </p>
2669 2669
             </div>
2670 2670
         </noscript>
2671 2671
         <?php
2672
-    }
2673
-
2674
-
2675
-    /**
2676
-     * displays espresso success and/or error notices
2677
-     *
2678
-     * @return void
2679
-     */
2680
-    private function _display_espresso_notices()
2681
-    {
2682
-        $notices = $this->_get_transient(true);
2683
-        echo stripslashes($notices);
2684
-    }
2685
-
2686
-
2687
-    /**
2688
-     * spinny things pacify the masses
2689
-     *
2690
-     * @return void
2691
-     */
2692
-    protected function _add_admin_page_ajax_loading_img()
2693
-    {
2694
-        ?>
2672
+	}
2673
+
2674
+
2675
+	/**
2676
+	 * displays espresso success and/or error notices
2677
+	 *
2678
+	 * @return void
2679
+	 */
2680
+	private function _display_espresso_notices()
2681
+	{
2682
+		$notices = $this->_get_transient(true);
2683
+		echo stripslashes($notices);
2684
+	}
2685
+
2686
+
2687
+	/**
2688
+	 * spinny things pacify the masses
2689
+	 *
2690
+	 * @return void
2691
+	 */
2692
+	protected function _add_admin_page_ajax_loading_img()
2693
+	{
2694
+		?>
2695 2695
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2696 2696
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2697
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2697
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2698 2698
         </div>
2699 2699
         <?php
2700
-    }
2700
+	}
2701 2701
 
2702 2702
 
2703
-    /**
2704
-     * add admin page overlay for modal boxes
2705
-     *
2706
-     * @return void
2707
-     */
2708
-    protected function _add_admin_page_overlay()
2709
-    {
2710
-        ?>
2703
+	/**
2704
+	 * add admin page overlay for modal boxes
2705
+	 *
2706
+	 * @return void
2707
+	 */
2708
+	protected function _add_admin_page_overlay()
2709
+	{
2710
+		?>
2711 2711
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2712 2712
         <?php
2713
-    }
2714
-
2715
-
2716
-    /**
2717
-     * facade for add_meta_box
2718
-     *
2719
-     * @param string  $action        where the metabox get's displayed
2720
-     * @param string  $title         Title of Metabox (output in metabox header)
2721
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2722
-     *                               instead of the one created in here.
2723
-     * @param array   $callback_args an array of args supplied for the metabox
2724
-     * @param string  $column        what metabox column
2725
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2726
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2727
-     *                               created but just set our own callback for wp's add_meta_box.
2728
-     * @throws \DomainException
2729
-     */
2730
-    public function _add_admin_page_meta_box(
2731
-        $action,
2732
-        $title,
2733
-        $callback,
2734
-        $callback_args,
2735
-        $column = 'normal',
2736
-        $priority = 'high',
2737
-        $create_func = true
2738
-    ) {
2739
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2740
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2741
-        if (empty($callback_args) && $create_func) {
2742
-            $callback_args = array(
2743
-                'template_path' => $this->_template_path,
2744
-                'template_args' => $this->_template_args,
2745
-            );
2746
-        }
2747
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2748
-        $call_back_func = $create_func
2749
-            ? function ($post, $metabox) {
2750
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2751
-                echo EEH_Template::display_template(
2752
-                    $metabox['args']['template_path'],
2753
-                    $metabox['args']['template_args'],
2754
-                    true
2755
-                );
2756
-            }
2757
-            : $callback;
2758
-        add_meta_box(
2759
-            str_replace('_', '-', $action) . '-mbox',
2760
-            $title,
2761
-            $call_back_func,
2762
-            $this->_wp_page_slug,
2763
-            $column,
2764
-            $priority,
2765
-            $callback_args
2766
-        );
2767
-    }
2768
-
2769
-
2770
-    /**
2771
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2772
-     *
2773
-     * @throws DomainException
2774
-     * @throws EE_Error
2775
-     */
2776
-    public function display_admin_page_with_metabox_columns()
2777
-    {
2778
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2779
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2780
-            $this->_column_template_path,
2781
-            $this->_template_args,
2782
-            true
2783
-        );
2784
-        // the final wrapper
2785
-        $this->admin_page_wrapper();
2786
-    }
2787
-
2788
-
2789
-    /**
2790
-     * generates  HTML wrapper for an admin details page
2791
-     *
2792
-     * @return void
2793
-     * @throws EE_Error
2794
-     * @throws DomainException
2795
-     */
2796
-    public function display_admin_page_with_sidebar()
2797
-    {
2798
-        $this->_display_admin_page(true);
2799
-    }
2800
-
2801
-
2802
-    /**
2803
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2804
-     *
2805
-     * @return void
2806
-     * @throws EE_Error
2807
-     * @throws DomainException
2808
-     */
2809
-    public function display_admin_page_with_no_sidebar()
2810
-    {
2811
-        $this->_display_admin_page();
2812
-    }
2813
-
2814
-
2815
-    /**
2816
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2817
-     *
2818
-     * @return void
2819
-     * @throws EE_Error
2820
-     * @throws DomainException
2821
-     */
2822
-    public function display_about_admin_page()
2823
-    {
2824
-        $this->_display_admin_page(false, true);
2825
-    }
2826
-
2827
-
2828
-    /**
2829
-     * display_admin_page
2830
-     * contains the code for actually displaying an admin page
2831
-     *
2832
-     * @param  boolean $sidebar true with sidebar, false without
2833
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2834
-     * @return void
2835
-     * @throws DomainException
2836
-     * @throws EE_Error
2837
-     */
2838
-    private function _display_admin_page($sidebar = false, $about = false)
2839
-    {
2840
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2841
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2842
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2843
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2844
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2845
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2846
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2847
-            ? 'poststuff'
2848
-            : 'espresso-default-admin';
2849
-        $template_path = $sidebar
2850
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2851
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2852
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2853
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2854
-        }
2855
-        $template_path = ! empty($this->_column_template_path)
2856
-            ? $this->_column_template_path : $template_path;
2857
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2858
-            ? $this->_template_args['admin_page_content']
2859
-            : '';
2860
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2861
-            ? $this->_template_args['before_admin_page_content']
2862
-            : '';
2863
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2864
-            ? $this->_template_args['after_admin_page_content']
2865
-            : '';
2866
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2867
-            $template_path,
2868
-            $this->_template_args,
2869
-            true
2870
-        );
2871
-        // the final template wrapper
2872
-        $this->admin_page_wrapper($about);
2873
-    }
2874
-
2875
-
2876
-    /**
2877
-     * This is used to display caf preview pages.
2878
-     *
2879
-     * @since 4.3.2
2880
-     * @param string $utm_campaign_source what is the key used for google analytics link
2881
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2882
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2883
-     * @return void
2884
-     * @throws DomainException
2885
-     * @throws EE_Error
2886
-     * @throws InvalidArgumentException
2887
-     * @throws InvalidDataTypeException
2888
-     * @throws InvalidInterfaceException
2889
-     */
2890
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2891
-    {
2892
-        // let's generate a default preview action button if there isn't one already present.
2893
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2894
-            'Upgrade to Event Espresso 4 Right Now',
2895
-            'event_espresso'
2896
-        );
2897
-        $buy_now_url = add_query_arg(
2898
-            array(
2899
-                'ee_ver'       => 'ee4',
2900
-                'utm_source'   => 'ee4_plugin_admin',
2901
-                'utm_medium'   => 'link',
2902
-                'utm_campaign' => $utm_campaign_source,
2903
-                'utm_content'  => 'buy_now_button',
2904
-            ),
2905
-            'http://eventespresso.com/pricing/'
2906
-        );
2907
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2908
-            ? $this->get_action_link_or_button(
2909
-                '',
2910
-                'buy_now',
2911
-                array(),
2912
-                'button-primary button-large',
2913
-                $buy_now_url,
2914
-                true
2915
-            )
2916
-            : $this->_template_args['preview_action_button'];
2917
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2918
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2919
-            $this->_template_args,
2920
-            true
2921
-        );
2922
-        $this->_display_admin_page($display_sidebar);
2923
-    }
2924
-
2925
-
2926
-    /**
2927
-     * display_admin_list_table_page_with_sidebar
2928
-     * generates HTML wrapper for an admin_page with list_table
2929
-     *
2930
-     * @return void
2931
-     * @throws EE_Error
2932
-     * @throws DomainException
2933
-     */
2934
-    public function display_admin_list_table_page_with_sidebar()
2935
-    {
2936
-        $this->_display_admin_list_table_page(true);
2937
-    }
2938
-
2939
-
2940
-    /**
2941
-     * display_admin_list_table_page_with_no_sidebar
2942
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2943
-     *
2944
-     * @return void
2945
-     * @throws EE_Error
2946
-     * @throws DomainException
2947
-     */
2948
-    public function display_admin_list_table_page_with_no_sidebar()
2949
-    {
2950
-        $this->_display_admin_list_table_page();
2951
-    }
2952
-
2953
-
2954
-    /**
2955
-     * generates html wrapper for an admin_list_table page
2956
-     *
2957
-     * @param boolean $sidebar whether to display with sidebar or not.
2958
-     * @return void
2959
-     * @throws DomainException
2960
-     * @throws EE_Error
2961
-     */
2962
-    private function _display_admin_list_table_page($sidebar = false)
2963
-    {
2964
-        // setup search attributes
2965
-        $this->_set_search_attributes();
2966
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2967
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2968
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2969
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2970
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2971
-        $this->_template_args['list_table'] = $this->_list_table_object;
2972
-        $this->_template_args['current_route'] = $this->_req_action;
2973
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2974
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2975
-        if (! empty($ajax_sorting_callback)) {
2976
-            $sortable_list_table_form_fields = wp_nonce_field(
2977
-                $ajax_sorting_callback . '_nonce',
2978
-                $ajax_sorting_callback . '_nonce',
2979
-                false,
2980
-                false
2981
-            );
2982
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2983
-                                                . $this->page_slug
2984
-                                                . '" />';
2985
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2986
-                                                . $ajax_sorting_callback
2987
-                                                . '" />';
2988
-        } else {
2989
-            $sortable_list_table_form_fields = '';
2990
-        }
2991
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2992
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2993
-            ? $this->_template_args['list_table_hidden_fields']
2994
-            : '';
2995
-        $nonce_ref = $this->_req_action . '_nonce';
2996
-        $hidden_form_fields .= '<input type="hidden" name="'
2997
-                               . $nonce_ref
2998
-                               . '" value="'
2999
-                               . wp_create_nonce($nonce_ref)
3000
-                               . '">';
3001
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3002
-        // display message about search results?
3003
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3004
-            ? '<p class="ee-search-results">' . sprintf(
3005
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3006
-                trim($this->_req_data['s'], '%')
3007
-            ) . '</p>'
3008
-            : '';
3009
-        // filter before_list_table template arg
3010
-        $this->_template_args['before_list_table'] = apply_filters(
3011
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3012
-            $this->_template_args['before_list_table'],
3013
-            $this->page_slug,
3014
-            $this->_req_data,
3015
-            $this->_req_action
3016
-        );
3017
-        // convert to array and filter again
3018
-        // arrays are easier to inject new items in a specific location,
3019
-        // but would not be backwards compatible, so we have to add a new filter
3020
-        $this->_template_args['before_list_table'] = implode(
3021
-            " \n",
3022
-            (array) apply_filters(
3023
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3024
-                (array) $this->_template_args['before_list_table'],
3025
-                $this->page_slug,
3026
-                $this->_req_data,
3027
-                $this->_req_action
3028
-            )
3029
-        );
3030
-        // filter after_list_table template arg
3031
-        $this->_template_args['after_list_table'] = apply_filters(
3032
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3033
-            $this->_template_args['after_list_table'],
3034
-            $this->page_slug,
3035
-            $this->_req_data,
3036
-            $this->_req_action
3037
-        );
3038
-        // convert to array and filter again
3039
-        // arrays are easier to inject new items in a specific location,
3040
-        // but would not be backwards compatible, so we have to add a new filter
3041
-        $this->_template_args['after_list_table'] = implode(
3042
-            " \n",
3043
-            (array) apply_filters(
3044
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3045
-                (array) $this->_template_args['after_list_table'],
3046
-                $this->page_slug,
3047
-                $this->_req_data,
3048
-                $this->_req_action
3049
-            )
3050
-        );
3051
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3052
-            $template_path,
3053
-            $this->_template_args,
3054
-            true
3055
-        );
3056
-        // the final template wrapper
3057
-        if ($sidebar) {
3058
-            $this->display_admin_page_with_sidebar();
3059
-        } else {
3060
-            $this->display_admin_page_with_no_sidebar();
3061
-        }
3062
-    }
3063
-
3064
-
3065
-    /**
3066
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3067
-     * html string for the legend.
3068
-     * $items are expected in an array in the following format:
3069
-     * $legend_items = array(
3070
-     *        'item_id' => array(
3071
-     *            'icon' => 'http://url_to_icon_being_described.png',
3072
-     *            'desc' => esc_html__('localized description of item');
3073
-     *        )
3074
-     * );
3075
-     *
3076
-     * @param  array $items see above for format of array
3077
-     * @return string html string of legend
3078
-     * @throws DomainException
3079
-     */
3080
-    protected function _display_legend($items)
3081
-    {
3082
-        $this->_template_args['items'] = apply_filters(
3083
-            'FHEE__EE_Admin_Page___display_legend__items',
3084
-            (array) $items,
3085
-            $this
3086
-        );
3087
-        return EEH_Template::display_template(
3088
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3089
-            $this->_template_args,
3090
-            true
3091
-        );
3092
-    }
3093
-
3094
-
3095
-    /**
3096
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3097
-     * The returned json object is created from an array in the following format:
3098
-     * array(
3099
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3100
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3101
-     *  'notices' => '', // - contains any EE_Error formatted notices
3102
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3103
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3104
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3105
-     *  that might be included in here)
3106
-     * )
3107
-     * The json object is populated by whatever is set in the $_template_args property.
3108
-     *
3109
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3110
-     *                                 instead of displayed.
3111
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3112
-     * @return void
3113
-     * @throws EE_Error
3114
-     */
3115
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3116
-    {
3117
-        // make sure any EE_Error notices have been handled.
3118
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3119
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3120
-        unset($this->_template_args['data']);
3121
-        $json = array(
3122
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3123
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3124
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3125
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3126
-            'notices'   => EE_Error::get_notices(),
3127
-            'content'   => isset($this->_template_args['admin_page_content'])
3128
-                ? $this->_template_args['admin_page_content'] : '',
3129
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3130
-            'isEEajax'  => true
3131
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3132
-        );
3133
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3134
-        if (null === error_get_last() || ! headers_sent()) {
3135
-            header('Content-Type: application/json; charset=UTF-8');
3136
-        }
3137
-        echo wp_json_encode($json);
3138
-        exit();
3139
-    }
3140
-
3141
-
3142
-    /**
3143
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3144
-     *
3145
-     * @return void
3146
-     * @throws EE_Error
3147
-     */
3148
-    public function return_json()
3149
-    {
3150
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3151
-            $this->_return_json();
3152
-        } else {
3153
-            throw new EE_Error(
3154
-                sprintf(
3155
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3156
-                    __FUNCTION__
3157
-                )
3158
-            );
3159
-        }
3160
-    }
3161
-
3162
-
3163
-    /**
3164
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3165
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3166
-     *
3167
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3168
-     */
3169
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3170
-    {
3171
-        $this->_hook_obj = $hook_obj;
3172
-    }
3173
-
3174
-
3175
-    /**
3176
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3177
-     *
3178
-     * @param  boolean $about whether to use the special about page wrapper or default.
3179
-     * @return void
3180
-     * @throws DomainException
3181
-     * @throws EE_Error
3182
-     */
3183
-    public function admin_page_wrapper($about = false)
3184
-    {
3185
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3186
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3187
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3188
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3189
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3190
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3191
-            isset($this->_template_args['before_admin_page_content'])
3192
-                ? $this->_template_args['before_admin_page_content']
3193
-                : ''
3194
-        );
3195
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3196
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3197
-            isset($this->_template_args['after_admin_page_content'])
3198
-                ? $this->_template_args['after_admin_page_content']
3199
-                : ''
3200
-        );
3201
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3202
-        // load settings page wrapper template
3203
-        $template_path = ! defined('DOING_AJAX')
3204
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3205
-            : EE_ADMIN_TEMPLATE
3206
-              . 'admin_wrapper_ajax.template.php';
3207
-        // about page?
3208
-        $template_path = $about
3209
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3210
-            : $template_path;
3211
-        if (defined('DOING_AJAX')) {
3212
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3213
-                $template_path,
3214
-                $this->_template_args,
3215
-                true
3216
-            );
3217
-            $this->_return_json();
3218
-        } else {
3219
-            EEH_Template::display_template($template_path, $this->_template_args);
3220
-        }
3221
-    }
3222
-
3223
-
3224
-    /**
3225
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3226
-     *
3227
-     * @return string html
3228
-     * @throws EE_Error
3229
-     */
3230
-    protected function _get_main_nav_tabs()
3231
-    {
3232
-        // let's generate the html using the EEH_Tabbed_Content helper.
3233
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3234
-        // (rather than setting in the page_routes array)
3235
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3236
-    }
3237
-
3238
-
3239
-    /**
3240
-     *        sort nav tabs
3241
-     *
3242
-     * @param $a
3243
-     * @param $b
3244
-     * @return int
3245
-     */
3246
-    private function _sort_nav_tabs($a, $b)
3247
-    {
3248
-        if ($a['order'] === $b['order']) {
3249
-            return 0;
3250
-        }
3251
-        return ($a['order'] < $b['order']) ? -1 : 1;
3252
-    }
3253
-
3254
-
3255
-    /**
3256
-     *    generates HTML for the forms used on admin pages
3257
-     *
3258
-     * @param    array $input_vars - array of input field details
3259
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3260
-     *                             use)
3261
-     * @param bool     $id
3262
-     * @return string
3263
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3264
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3265
-     */
3266
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3267
-    {
3268
-        $content = $generator === 'string'
3269
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3270
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3271
-        return $content;
3272
-    }
3273
-
3274
-
3275
-    /**
3276
-     * generates the "Save" and "Save & Close" buttons for edit forms
3277
-     *
3278
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3279
-     *                                   Close" button.
3280
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3281
-     *                                   'Save', [1] => 'save & close')
3282
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3283
-     *                                   via the "name" value in the button).  We can also use this to just dump
3284
-     *                                   default actions by submitting some other value.
3285
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3286
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3287
-     *                                   close (normal form handling).
3288
-     */
3289
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3290
-    {
3291
-        // make sure $text and $actions are in an array
3292
-        $text = (array) $text;
3293
-        $actions = (array) $actions;
3294
-        $referrer_url = empty($referrer)
3295
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3296
-              . $_SERVER['REQUEST_URI']
3297
-              . '" />'
3298
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3299
-              . $referrer
3300
-              . '" />';
3301
-        $button_text = ! empty($text)
3302
-            ? $text
3303
-            : array(
3304
-                esc_html__('Save', 'event_espresso'),
3305
-                esc_html__('Save and Close', 'event_espresso'),
3306
-            );
3307
-        $default_names = array('save', 'save_and_close');
3308
-        // add in a hidden index for the current page (so save and close redirects properly)
3309
-        $this->_template_args['save_buttons'] = $referrer_url;
3310
-        foreach ($button_text as $key => $button) {
3311
-            $ref = $default_names[ $key ];
3312
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3313
-                                                     . $ref
3314
-                                                     . '" value="'
3315
-                                                     . $button
3316
-                                                     . '" name="'
3317
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3318
-                                                     . '" id="'
3319
-                                                     . $this->_current_view . '_' . $ref
3320
-                                                     . '" />';
3321
-            if (! $both) {
3322
-                break;
3323
-            }
3324
-        }
3325
-    }
3326
-
3327
-
3328
-    /**
3329
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3330
-     *
3331
-     * @see   $this->_set_add_edit_form_tags() for details on params
3332
-     * @since 4.6.0
3333
-     * @param string $route
3334
-     * @param array  $additional_hidden_fields
3335
-     */
3336
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3337
-    {
3338
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3339
-    }
3340
-
3341
-
3342
-    /**
3343
-     * set form open and close tags on add/edit pages.
3344
-     *
3345
-     * @param string $route                    the route you want the form to direct to
3346
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3347
-     * @return void
3348
-     */
3349
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3350
-    {
3351
-        if (empty($route)) {
3352
-            $user_msg = esc_html__(
3353
-                'An error occurred. No action was set for this page\'s form.',
3354
-                'event_espresso'
3355
-            );
3356
-            $dev_msg = $user_msg . "\n"
3357
-                       . sprintf(
3358
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3359
-                           __FUNCTION__,
3360
-                           __CLASS__
3361
-                       );
3362
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3363
-        }
3364
-        // open form
3365
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3366
-                                                             . $this->_admin_base_url
3367
-                                                             . '" id="'
3368
-                                                             . $route
3369
-                                                             . '_event_form" >';
3370
-        // add nonce
3371
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3372
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3373
-        // add REQUIRED form action
3374
-        $hidden_fields = array(
3375
-            'action' => array('type' => 'hidden', 'value' => $route),
3376
-        );
3377
-        // merge arrays
3378
-        $hidden_fields = is_array($additional_hidden_fields)
3379
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3380
-            : $hidden_fields;
3381
-        // generate form fields
3382
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3383
-        // add fields to form
3384
-        foreach ((array) $form_fields as $field_name => $form_field) {
3385
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3386
-        }
3387
-        // close form
3388
-        $this->_template_args['after_admin_page_content'] = '</form>';
3389
-    }
3390
-
3391
-
3392
-    /**
3393
-     * Public Wrapper for _redirect_after_action() method since its
3394
-     * discovered it would be useful for external code to have access.
3395
-     *
3396
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3397
-     * @since 4.5.0
3398
-     * @param bool   $success
3399
-     * @param string $what
3400
-     * @param string $action_desc
3401
-     * @param array  $query_args
3402
-     * @param bool   $override_overwrite
3403
-     * @throws EE_Error
3404
-     */
3405
-    public function redirect_after_action(
3406
-        $success = false,
3407
-        $what = 'item',
3408
-        $action_desc = 'processed',
3409
-        $query_args = array(),
3410
-        $override_overwrite = false
3411
-    ) {
3412
-        $this->_redirect_after_action(
3413
-            $success,
3414
-            $what,
3415
-            $action_desc,
3416
-            $query_args,
3417
-            $override_overwrite
3418
-        );
3419
-    }
3420
-
3421
-
3422
-    /**
3423
-     * Helper method for merging existing request data with the returned redirect url.
3424
-     *
3425
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3426
-     * filters are still applied.
3427
-     *
3428
-     * @param array $new_route_data
3429
-     * @return array
3430
-     */
3431
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3432
-    {
3433
-        foreach ($this->_req_data as $ref => $value) {
3434
-            // unset nonces
3435
-            if (strpos($ref, 'nonce') !== false) {
3436
-                unset($this->_req_data[ $ref ]);
3437
-                continue;
3438
-            }
3439
-            // urlencode values.
3440
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3441
-            $this->_req_data[ $ref ] = $value;
3442
-        }
3443
-        return array_merge($this->_req_data, $new_route_data);
3444
-    }
3445
-
3446
-
3447
-    /**
3448
-     *    _redirect_after_action
3449
-     *
3450
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3451
-     * @param string $what               - what the action was performed on
3452
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3453
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3454
-     *                                   action is completed
3455
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3456
-     *                                   override this so that they show.
3457
-     * @return void
3458
-     * @throws EE_Error
3459
-     */
3460
-    protected function _redirect_after_action(
3461
-        $success = 0,
3462
-        $what = 'item',
3463
-        $action_desc = 'processed',
3464
-        $query_args = array(),
3465
-        $override_overwrite = false
3466
-    ) {
3467
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3468
-        // class name for actions/filters.
3469
-        $classname = get_class($this);
3470
-        // set redirect url.
3471
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3472
-        // otherwise we go with whatever is set as the _admin_base_url
3473
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3474
-        $notices = EE_Error::get_notices(false);
3475
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3476
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3477
-            EE_Error::overwrite_success();
3478
-        }
3479
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3480
-            // how many records affected ? more than one record ? or just one ?
3481
-            if ($success > 1) {
3482
-                // set plural msg
3483
-                EE_Error::add_success(
3484
-                    sprintf(
3485
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3486
-                        $what,
3487
-                        $action_desc
3488
-                    ),
3489
-                    __FILE__,
3490
-                    __FUNCTION__,
3491
-                    __LINE__
3492
-                );
3493
-            } elseif ($success === 1) {
3494
-                // set singular msg
3495
-                EE_Error::add_success(
3496
-                    sprintf(
3497
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3498
-                        $what,
3499
-                        $action_desc
3500
-                    ),
3501
-                    __FILE__,
3502
-                    __FUNCTION__,
3503
-                    __LINE__
3504
-                );
3505
-            }
3506
-        }
3507
-        // check that $query_args isn't something crazy
3508
-        if (! is_array($query_args)) {
3509
-            $query_args = array();
3510
-        }
3511
-        /**
3512
-         * Allow injecting actions before the query_args are modified for possible different
3513
-         * redirections on save and close actions
3514
-         *
3515
-         * @since 4.2.0
3516
-         * @param array $query_args       The original query_args array coming into the
3517
-         *                                method.
3518
-         */
3519
-        do_action(
3520
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3521
-            $query_args
3522
-        );
3523
-        // calculate where we're going (if we have a "save and close" button pushed)
3524
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3525
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3526
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3527
-            // regenerate query args array from referrer URL
3528
-            parse_str($parsed_url['query'], $query_args);
3529
-            // correct page and action will be in the query args now
3530
-            $redirect_url = admin_url('admin.php');
3531
-        }
3532
-        // merge any default query_args set in _default_route_query_args property
3533
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3534
-            $args_to_merge = array();
3535
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3536
-                // is there a wp_referer array in our _default_route_query_args property?
3537
-                if ($query_param === 'wp_referer') {
3538
-                    $query_value = (array) $query_value;
3539
-                    foreach ($query_value as $reference => $value) {
3540
-                        if (strpos($reference, 'nonce') !== false) {
3541
-                            continue;
3542
-                        }
3543
-                        // finally we will override any arguments in the referer with
3544
-                        // what might be set on the _default_route_query_args array.
3545
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3546
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3547
-                        } else {
3548
-                            $args_to_merge[ $reference ] = urlencode($value);
3549
-                        }
3550
-                    }
3551
-                    continue;
3552
-                }
3553
-                $args_to_merge[ $query_param ] = $query_value;
3554
-            }
3555
-            // now let's merge these arguments but override with what was specifically sent in to the
3556
-            // redirect.
3557
-            $query_args = array_merge($args_to_merge, $query_args);
3558
-        }
3559
-        $this->_process_notices($query_args);
3560
-        // generate redirect url
3561
-        // if redirecting to anything other than the main page, add a nonce
3562
-        if (isset($query_args['action'])) {
3563
-            // manually generate wp_nonce and merge that with the query vars
3564
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3565
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3566
-        }
3567
-        // we're adding some hooks and filters in here for processing any things just before redirects
3568
-        // (example: an admin page has done an insert or update and we want to run something after that).
3569
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3570
-        $redirect_url = apply_filters(
3571
-            'FHEE_redirect_' . $classname . $this->_req_action,
3572
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3573
-            $query_args
3574
-        );
3575
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3576
-        if (defined('DOING_AJAX')) {
3577
-            $default_data = array(
3578
-                'close'        => true,
3579
-                'redirect_url' => $redirect_url,
3580
-                'where'        => 'main',
3581
-                'what'         => 'append',
3582
-            );
3583
-            $this->_template_args['success'] = $success;
3584
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3585
-                $default_data,
3586
-                $this->_template_args['data']
3587
-            ) : $default_data;
3588
-            $this->_return_json();
3589
-        }
3590
-        wp_safe_redirect($redirect_url);
3591
-        exit();
3592
-    }
3593
-
3594
-
3595
-    /**
3596
-     * process any notices before redirecting (or returning ajax request)
3597
-     * This method sets the $this->_template_args['notices'] attribute;
3598
-     *
3599
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3600
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3601
-     *                                  page_routes haven't been defined yet.
3602
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3603
-     *                                  still save a transient for the notice.
3604
-     * @return void
3605
-     * @throws EE_Error
3606
-     */
3607
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3608
-    {
3609
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3610
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3611
-            $notices = EE_Error::get_notices(false);
3612
-            if (empty($this->_template_args['success'])) {
3613
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3614
-            }
3615
-            if (empty($this->_template_args['errors'])) {
3616
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3617
-            }
3618
-            if (empty($this->_template_args['attention'])) {
3619
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3620
-            }
3621
-        }
3622
-        $this->_template_args['notices'] = EE_Error::get_notices();
3623
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3624
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3625
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3626
-            $this->_add_transient(
3627
-                $route,
3628
-                $this->_template_args['notices'],
3629
-                true,
3630
-                $skip_route_verify
3631
-            );
3632
-        }
3633
-    }
3634
-
3635
-
3636
-    /**
3637
-     * get_action_link_or_button
3638
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3639
-     *
3640
-     * @param string $action        use this to indicate which action the url is generated with.
3641
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3642
-     *                              property.
3643
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3644
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3645
-     * @param string $base_url      If this is not provided
3646
-     *                              the _admin_base_url will be used as the default for the button base_url.
3647
-     *                              Otherwise this value will be used.
3648
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3649
-     * @return string
3650
-     * @throws InvalidArgumentException
3651
-     * @throws InvalidInterfaceException
3652
-     * @throws InvalidDataTypeException
3653
-     * @throws EE_Error
3654
-     */
3655
-    public function get_action_link_or_button(
3656
-        $action,
3657
-        $type = 'add',
3658
-        $extra_request = array(),
3659
-        $class = 'button-primary',
3660
-        $base_url = '',
3661
-        $exclude_nonce = false
3662
-    ) {
3663
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3664
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3665
-            throw new EE_Error(
3666
-                sprintf(
3667
-                    esc_html__(
3668
-                        'There is no page route for given action for the button.  This action was given: %s',
3669
-                        'event_espresso'
3670
-                    ),
3671
-                    $action
3672
-                )
3673
-            );
3674
-        }
3675
-        if (! isset($this->_labels['buttons'][ $type ])) {
3676
-            throw new EE_Error(
3677
-                sprintf(
3678
-                    __(
3679
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3680
-                        'event_espresso'
3681
-                    ),
3682
-                    $type
3683
-                )
3684
-            );
3685
-        }
3686
-        // finally check user access for this button.
3687
-        $has_access = $this->check_user_access($action, true);
3688
-        if (! $has_access) {
3689
-            return '';
3690
-        }
3691
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3692
-        $query_args = array(
3693
-            'action' => $action,
3694
-        );
3695
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3696
-        if (! empty($extra_request)) {
3697
-            $query_args = array_merge($extra_request, $query_args);
3698
-        }
3699
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3700
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3701
-    }
3702
-
3703
-
3704
-    /**
3705
-     * _per_page_screen_option
3706
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3707
-     *
3708
-     * @return void
3709
-     * @throws InvalidArgumentException
3710
-     * @throws InvalidInterfaceException
3711
-     * @throws InvalidDataTypeException
3712
-     */
3713
-    protected function _per_page_screen_option()
3714
-    {
3715
-        $option = 'per_page';
3716
-        $args = array(
3717
-            'label'   => apply_filters(
3718
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3719
-                $this->_admin_page_title,
3720
-                $this
3721
-            ),
3722
-            'default' => (int) apply_filters(
3723
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3724
-                20
3725
-            ),
3726
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3727
-        );
3728
-        // ONLY add the screen option if the user has access to it.
3729
-        if ($this->check_user_access($this->_current_view, true)) {
3730
-            add_screen_option($option, $args);
3731
-        }
3732
-    }
3733
-
3734
-
3735
-    /**
3736
-     * set_per_page_screen_option
3737
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3738
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3739
-     * admin_menu.
3740
-     *
3741
-     * @return void
3742
-     */
3743
-    private function _set_per_page_screen_options()
3744
-    {
3745
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3746
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3747
-            if (! $user = wp_get_current_user()) {
3748
-                return;
3749
-            }
3750
-            $option = $_POST['wp_screen_options']['option'];
3751
-            $value = $_POST['wp_screen_options']['value'];
3752
-            if ($option != sanitize_key($option)) {
3753
-                return;
3754
-            }
3755
-            $map_option = $option;
3756
-            $option = str_replace('-', '_', $option);
3757
-            switch ($map_option) {
3758
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3759
-                    $value = (int) $value;
3760
-                    $max_value = apply_filters(
3761
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3762
-                        999,
3763
-                        $this->_current_page,
3764
-                        $this->_current_view
3765
-                    );
3766
-                    if ($value < 1) {
3767
-                        return;
3768
-                    }
3769
-                    $value = min($value, $max_value);
3770
-                    break;
3771
-                default:
3772
-                    $value = apply_filters(
3773
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3774
-                        false,
3775
-                        $option,
3776
-                        $value
3777
-                    );
3778
-                    if (false === $value) {
3779
-                        return;
3780
-                    }
3781
-                    break;
3782
-            }
3783
-            update_user_meta($user->ID, $option, $value);
3784
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3785
-            exit;
3786
-        }
3787
-    }
3788
-
3789
-
3790
-    /**
3791
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3792
-     *
3793
-     * @param array $data array that will be assigned to template args.
3794
-     */
3795
-    public function set_template_args($data)
3796
-    {
3797
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3798
-    }
3799
-
3800
-
3801
-    /**
3802
-     * This makes available the WP transient system for temporarily moving data between routes
3803
-     *
3804
-     * @param string $route             the route that should receive the transient
3805
-     * @param array  $data              the data that gets sent
3806
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3807
-     *                                  normal route transient.
3808
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3809
-     *                                  when we are adding a transient before page_routes have been defined.
3810
-     * @return void
3811
-     * @throws EE_Error
3812
-     */
3813
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3814
-    {
3815
-        $user_id = get_current_user_id();
3816
-        if (! $skip_route_verify) {
3817
-            $this->_verify_route($route);
3818
-        }
3819
-        // now let's set the string for what kind of transient we're setting
3820
-        $transient = $notices
3821
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3822
-            : 'rte_tx_' . $route . '_' . $user_id;
3823
-        $data = $notices ? array('notices' => $data) : $data;
3824
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3825
-        $existing = is_multisite() && is_network_admin()
3826
-            ? get_site_transient($transient)
3827
-            : get_transient($transient);
3828
-        if ($existing) {
3829
-            $data = array_merge((array) $data, (array) $existing);
3830
-        }
3831
-        if (is_multisite() && is_network_admin()) {
3832
-            set_site_transient($transient, $data, 8);
3833
-        } else {
3834
-            set_transient($transient, $data, 8);
3835
-        }
3836
-    }
3837
-
3838
-
3839
-    /**
3840
-     * this retrieves the temporary transient that has been set for moving data between routes.
3841
-     *
3842
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3843
-     * @param string $route
3844
-     * @return mixed data
3845
-     */
3846
-    protected function _get_transient($notices = false, $route = '')
3847
-    {
3848
-        $user_id = get_current_user_id();
3849
-        $route = ! $route ? $this->_req_action : $route;
3850
-        $transient = $notices
3851
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3852
-            : 'rte_tx_' . $route . '_' . $user_id;
3853
-        $data = is_multisite() && is_network_admin()
3854
-            ? get_site_transient($transient)
3855
-            : get_transient($transient);
3856
-        // delete transient after retrieval (just in case it hasn't expired);
3857
-        if (is_multisite() && is_network_admin()) {
3858
-            delete_site_transient($transient);
3859
-        } else {
3860
-            delete_transient($transient);
3861
-        }
3862
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3868
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3869
-     * default route callback on the EE_Admin page you want it run.)
3870
-     *
3871
-     * @return void
3872
-     */
3873
-    protected function _transient_garbage_collection()
3874
-    {
3875
-        global $wpdb;
3876
-        // retrieve all existing transients
3877
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3878
-        if ($results = $wpdb->get_results($query)) {
3879
-            foreach ($results as $result) {
3880
-                $transient = str_replace('_transient_', '', $result->option_name);
3881
-                get_transient($transient);
3882
-                if (is_multisite() && is_network_admin()) {
3883
-                    get_site_transient($transient);
3884
-                }
3885
-            }
3886
-        }
3887
-    }
3888
-
3889
-
3890
-    /**
3891
-     * get_view
3892
-     *
3893
-     * @return string content of _view property
3894
-     */
3895
-    public function get_view()
3896
-    {
3897
-        return $this->_view;
3898
-    }
3899
-
3900
-
3901
-    /**
3902
-     * getter for the protected $_views property
3903
-     *
3904
-     * @return array
3905
-     */
3906
-    public function get_views()
3907
-    {
3908
-        return $this->_views;
3909
-    }
3910
-
3911
-
3912
-    /**
3913
-     * get_current_page
3914
-     *
3915
-     * @return string _current_page property value
3916
-     */
3917
-    public function get_current_page()
3918
-    {
3919
-        return $this->_current_page;
3920
-    }
3921
-
3922
-
3923
-    /**
3924
-     * get_current_view
3925
-     *
3926
-     * @return string _current_view property value
3927
-     */
3928
-    public function get_current_view()
3929
-    {
3930
-        return $this->_current_view;
3931
-    }
3932
-
3933
-
3934
-    /**
3935
-     * get_current_screen
3936
-     *
3937
-     * @return object The current WP_Screen object
3938
-     */
3939
-    public function get_current_screen()
3940
-    {
3941
-        return $this->_current_screen;
3942
-    }
3943
-
3944
-
3945
-    /**
3946
-     * get_current_page_view_url
3947
-     *
3948
-     * @return string This returns the url for the current_page_view.
3949
-     */
3950
-    public function get_current_page_view_url()
3951
-    {
3952
-        return $this->_current_page_view_url;
3953
-    }
3954
-
3955
-
3956
-    /**
3957
-     * just returns the _req_data property
3958
-     *
3959
-     * @return array
3960
-     */
3961
-    public function get_request_data()
3962
-    {
3963
-        return $this->_req_data;
3964
-    }
3965
-
3966
-
3967
-    /**
3968
-     * returns the _req_data protected property
3969
-     *
3970
-     * @return string
3971
-     */
3972
-    public function get_req_action()
3973
-    {
3974
-        return $this->_req_action;
3975
-    }
3976
-
3977
-
3978
-    /**
3979
-     * @return bool  value of $_is_caf property
3980
-     */
3981
-    public function is_caf()
3982
-    {
3983
-        return $this->_is_caf;
3984
-    }
3985
-
3986
-
3987
-    /**
3988
-     * @return mixed
3989
-     */
3990
-    public function default_espresso_metaboxes()
3991
-    {
3992
-        return $this->_default_espresso_metaboxes;
3993
-    }
3994
-
3995
-
3996
-    /**
3997
-     * @return mixed
3998
-     */
3999
-    public function admin_base_url()
4000
-    {
4001
-        return $this->_admin_base_url;
4002
-    }
4003
-
4004
-
4005
-    /**
4006
-     * @return mixed
4007
-     */
4008
-    public function wp_page_slug()
4009
-    {
4010
-        return $this->_wp_page_slug;
4011
-    }
4012
-
4013
-
4014
-    /**
4015
-     * updates  espresso configuration settings
4016
-     *
4017
-     * @param string                   $tab
4018
-     * @param EE_Config_Base|EE_Config $config
4019
-     * @param string                   $file file where error occurred
4020
-     * @param string                   $func function  where error occurred
4021
-     * @param string                   $line line no where error occurred
4022
-     * @return boolean
4023
-     */
4024
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4025
-    {
4026
-        // remove any options that are NOT going to be saved with the config settings.
4027
-        if (isset($config->core->ee_ueip_optin)) {
4028
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4029
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4030
-            update_option('ee_ueip_has_notified', true);
4031
-        }
4032
-        // and save it (note we're also doing the network save here)
4033
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4034
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4035
-        if ($config_saved && $net_saved) {
4036
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4037
-            return true;
4038
-        }
4039
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4040
-        return false;
4041
-    }
4042
-
4043
-
4044
-    /**
4045
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4046
-     *
4047
-     * @return array
4048
-     */
4049
-    public function get_yes_no_values()
4050
-    {
4051
-        return $this->_yes_no_values;
4052
-    }
4053
-
4054
-
4055
-    protected function _get_dir()
4056
-    {
4057
-        $reflector = new ReflectionClass(get_class($this));
4058
-        return dirname($reflector->getFileName());
4059
-    }
4060
-
4061
-
4062
-    /**
4063
-     * A helper for getting a "next link".
4064
-     *
4065
-     * @param string $url   The url to link to
4066
-     * @param string $class The class to use.
4067
-     * @return string
4068
-     */
4069
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4070
-    {
4071
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4072
-    }
4073
-
4074
-
4075
-    /**
4076
-     * A helper for getting a "previous link".
4077
-     *
4078
-     * @param string $url   The url to link to
4079
-     * @param string $class The class to use.
4080
-     * @return string
4081
-     */
4082
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4083
-    {
4084
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4085
-    }
4086
-
4087
-
4088
-
4089
-
4090
-
4091
-
4092
-
4093
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4094
-
4095
-
4096
-    /**
4097
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4098
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4099
-     * _req_data array.
4100
-     *
4101
-     * @return bool success/fail
4102
-     * @throws EE_Error
4103
-     * @throws InvalidArgumentException
4104
-     * @throws ReflectionException
4105
-     * @throws InvalidDataTypeException
4106
-     * @throws InvalidInterfaceException
4107
-     */
4108
-    protected function _process_resend_registration()
4109
-    {
4110
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4111
-        do_action(
4112
-            'AHEE__EE_Admin_Page___process_resend_registration',
4113
-            $this->_template_args['success'],
4114
-            $this->_req_data
4115
-        );
4116
-        return $this->_template_args['success'];
4117
-    }
4118
-
4119
-
4120
-    /**
4121
-     * This automatically processes any payment message notifications when manual payment has been applied.
4122
-     *
4123
-     * @param \EE_Payment $payment
4124
-     * @return bool success/fail
4125
-     */
4126
-    protected function _process_payment_notification(EE_Payment $payment)
4127
-    {
4128
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4129
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4130
-        $this->_template_args['success'] = apply_filters(
4131
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4132
-            false,
4133
-            $payment
4134
-        );
4135
-        return $this->_template_args['success'];
4136
-    }
2713
+	}
2714
+
2715
+
2716
+	/**
2717
+	 * facade for add_meta_box
2718
+	 *
2719
+	 * @param string  $action        where the metabox get's displayed
2720
+	 * @param string  $title         Title of Metabox (output in metabox header)
2721
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2722
+	 *                               instead of the one created in here.
2723
+	 * @param array   $callback_args an array of args supplied for the metabox
2724
+	 * @param string  $column        what metabox column
2725
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2726
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2727
+	 *                               created but just set our own callback for wp's add_meta_box.
2728
+	 * @throws \DomainException
2729
+	 */
2730
+	public function _add_admin_page_meta_box(
2731
+		$action,
2732
+		$title,
2733
+		$callback,
2734
+		$callback_args,
2735
+		$column = 'normal',
2736
+		$priority = 'high',
2737
+		$create_func = true
2738
+	) {
2739
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2740
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2741
+		if (empty($callback_args) && $create_func) {
2742
+			$callback_args = array(
2743
+				'template_path' => $this->_template_path,
2744
+				'template_args' => $this->_template_args,
2745
+			);
2746
+		}
2747
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2748
+		$call_back_func = $create_func
2749
+			? function ($post, $metabox) {
2750
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2751
+				echo EEH_Template::display_template(
2752
+					$metabox['args']['template_path'],
2753
+					$metabox['args']['template_args'],
2754
+					true
2755
+				);
2756
+			}
2757
+			: $callback;
2758
+		add_meta_box(
2759
+			str_replace('_', '-', $action) . '-mbox',
2760
+			$title,
2761
+			$call_back_func,
2762
+			$this->_wp_page_slug,
2763
+			$column,
2764
+			$priority,
2765
+			$callback_args
2766
+		);
2767
+	}
2768
+
2769
+
2770
+	/**
2771
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2772
+	 *
2773
+	 * @throws DomainException
2774
+	 * @throws EE_Error
2775
+	 */
2776
+	public function display_admin_page_with_metabox_columns()
2777
+	{
2778
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2779
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2780
+			$this->_column_template_path,
2781
+			$this->_template_args,
2782
+			true
2783
+		);
2784
+		// the final wrapper
2785
+		$this->admin_page_wrapper();
2786
+	}
2787
+
2788
+
2789
+	/**
2790
+	 * generates  HTML wrapper for an admin details page
2791
+	 *
2792
+	 * @return void
2793
+	 * @throws EE_Error
2794
+	 * @throws DomainException
2795
+	 */
2796
+	public function display_admin_page_with_sidebar()
2797
+	{
2798
+		$this->_display_admin_page(true);
2799
+	}
2800
+
2801
+
2802
+	/**
2803
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2804
+	 *
2805
+	 * @return void
2806
+	 * @throws EE_Error
2807
+	 * @throws DomainException
2808
+	 */
2809
+	public function display_admin_page_with_no_sidebar()
2810
+	{
2811
+		$this->_display_admin_page();
2812
+	}
2813
+
2814
+
2815
+	/**
2816
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2817
+	 *
2818
+	 * @return void
2819
+	 * @throws EE_Error
2820
+	 * @throws DomainException
2821
+	 */
2822
+	public function display_about_admin_page()
2823
+	{
2824
+		$this->_display_admin_page(false, true);
2825
+	}
2826
+
2827
+
2828
+	/**
2829
+	 * display_admin_page
2830
+	 * contains the code for actually displaying an admin page
2831
+	 *
2832
+	 * @param  boolean $sidebar true with sidebar, false without
2833
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2834
+	 * @return void
2835
+	 * @throws DomainException
2836
+	 * @throws EE_Error
2837
+	 */
2838
+	private function _display_admin_page($sidebar = false, $about = false)
2839
+	{
2840
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2841
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2842
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2843
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2844
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2845
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2846
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2847
+			? 'poststuff'
2848
+			: 'espresso-default-admin';
2849
+		$template_path = $sidebar
2850
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2851
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2852
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2853
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2854
+		}
2855
+		$template_path = ! empty($this->_column_template_path)
2856
+			? $this->_column_template_path : $template_path;
2857
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2858
+			? $this->_template_args['admin_page_content']
2859
+			: '';
2860
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2861
+			? $this->_template_args['before_admin_page_content']
2862
+			: '';
2863
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2864
+			? $this->_template_args['after_admin_page_content']
2865
+			: '';
2866
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2867
+			$template_path,
2868
+			$this->_template_args,
2869
+			true
2870
+		);
2871
+		// the final template wrapper
2872
+		$this->admin_page_wrapper($about);
2873
+	}
2874
+
2875
+
2876
+	/**
2877
+	 * This is used to display caf preview pages.
2878
+	 *
2879
+	 * @since 4.3.2
2880
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2881
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2882
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2883
+	 * @return void
2884
+	 * @throws DomainException
2885
+	 * @throws EE_Error
2886
+	 * @throws InvalidArgumentException
2887
+	 * @throws InvalidDataTypeException
2888
+	 * @throws InvalidInterfaceException
2889
+	 */
2890
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2891
+	{
2892
+		// let's generate a default preview action button if there isn't one already present.
2893
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2894
+			'Upgrade to Event Espresso 4 Right Now',
2895
+			'event_espresso'
2896
+		);
2897
+		$buy_now_url = add_query_arg(
2898
+			array(
2899
+				'ee_ver'       => 'ee4',
2900
+				'utm_source'   => 'ee4_plugin_admin',
2901
+				'utm_medium'   => 'link',
2902
+				'utm_campaign' => $utm_campaign_source,
2903
+				'utm_content'  => 'buy_now_button',
2904
+			),
2905
+			'http://eventespresso.com/pricing/'
2906
+		);
2907
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2908
+			? $this->get_action_link_or_button(
2909
+				'',
2910
+				'buy_now',
2911
+				array(),
2912
+				'button-primary button-large',
2913
+				$buy_now_url,
2914
+				true
2915
+			)
2916
+			: $this->_template_args['preview_action_button'];
2917
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2918
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2919
+			$this->_template_args,
2920
+			true
2921
+		);
2922
+		$this->_display_admin_page($display_sidebar);
2923
+	}
2924
+
2925
+
2926
+	/**
2927
+	 * display_admin_list_table_page_with_sidebar
2928
+	 * generates HTML wrapper for an admin_page with list_table
2929
+	 *
2930
+	 * @return void
2931
+	 * @throws EE_Error
2932
+	 * @throws DomainException
2933
+	 */
2934
+	public function display_admin_list_table_page_with_sidebar()
2935
+	{
2936
+		$this->_display_admin_list_table_page(true);
2937
+	}
2938
+
2939
+
2940
+	/**
2941
+	 * display_admin_list_table_page_with_no_sidebar
2942
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2943
+	 *
2944
+	 * @return void
2945
+	 * @throws EE_Error
2946
+	 * @throws DomainException
2947
+	 */
2948
+	public function display_admin_list_table_page_with_no_sidebar()
2949
+	{
2950
+		$this->_display_admin_list_table_page();
2951
+	}
2952
+
2953
+
2954
+	/**
2955
+	 * generates html wrapper for an admin_list_table page
2956
+	 *
2957
+	 * @param boolean $sidebar whether to display with sidebar or not.
2958
+	 * @return void
2959
+	 * @throws DomainException
2960
+	 * @throws EE_Error
2961
+	 */
2962
+	private function _display_admin_list_table_page($sidebar = false)
2963
+	{
2964
+		// setup search attributes
2965
+		$this->_set_search_attributes();
2966
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2967
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2968
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2969
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2970
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2971
+		$this->_template_args['list_table'] = $this->_list_table_object;
2972
+		$this->_template_args['current_route'] = $this->_req_action;
2973
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2974
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2975
+		if (! empty($ajax_sorting_callback)) {
2976
+			$sortable_list_table_form_fields = wp_nonce_field(
2977
+				$ajax_sorting_callback . '_nonce',
2978
+				$ajax_sorting_callback . '_nonce',
2979
+				false,
2980
+				false
2981
+			);
2982
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2983
+												. $this->page_slug
2984
+												. '" />';
2985
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2986
+												. $ajax_sorting_callback
2987
+												. '" />';
2988
+		} else {
2989
+			$sortable_list_table_form_fields = '';
2990
+		}
2991
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2992
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2993
+			? $this->_template_args['list_table_hidden_fields']
2994
+			: '';
2995
+		$nonce_ref = $this->_req_action . '_nonce';
2996
+		$hidden_form_fields .= '<input type="hidden" name="'
2997
+							   . $nonce_ref
2998
+							   . '" value="'
2999
+							   . wp_create_nonce($nonce_ref)
3000
+							   . '">';
3001
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3002
+		// display message about search results?
3003
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3004
+			? '<p class="ee-search-results">' . sprintf(
3005
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3006
+				trim($this->_req_data['s'], '%')
3007
+			) . '</p>'
3008
+			: '';
3009
+		// filter before_list_table template arg
3010
+		$this->_template_args['before_list_table'] = apply_filters(
3011
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3012
+			$this->_template_args['before_list_table'],
3013
+			$this->page_slug,
3014
+			$this->_req_data,
3015
+			$this->_req_action
3016
+		);
3017
+		// convert to array and filter again
3018
+		// arrays are easier to inject new items in a specific location,
3019
+		// but would not be backwards compatible, so we have to add a new filter
3020
+		$this->_template_args['before_list_table'] = implode(
3021
+			" \n",
3022
+			(array) apply_filters(
3023
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3024
+				(array) $this->_template_args['before_list_table'],
3025
+				$this->page_slug,
3026
+				$this->_req_data,
3027
+				$this->_req_action
3028
+			)
3029
+		);
3030
+		// filter after_list_table template arg
3031
+		$this->_template_args['after_list_table'] = apply_filters(
3032
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3033
+			$this->_template_args['after_list_table'],
3034
+			$this->page_slug,
3035
+			$this->_req_data,
3036
+			$this->_req_action
3037
+		);
3038
+		// convert to array and filter again
3039
+		// arrays are easier to inject new items in a specific location,
3040
+		// but would not be backwards compatible, so we have to add a new filter
3041
+		$this->_template_args['after_list_table'] = implode(
3042
+			" \n",
3043
+			(array) apply_filters(
3044
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3045
+				(array) $this->_template_args['after_list_table'],
3046
+				$this->page_slug,
3047
+				$this->_req_data,
3048
+				$this->_req_action
3049
+			)
3050
+		);
3051
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3052
+			$template_path,
3053
+			$this->_template_args,
3054
+			true
3055
+		);
3056
+		// the final template wrapper
3057
+		if ($sidebar) {
3058
+			$this->display_admin_page_with_sidebar();
3059
+		} else {
3060
+			$this->display_admin_page_with_no_sidebar();
3061
+		}
3062
+	}
3063
+
3064
+
3065
+	/**
3066
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3067
+	 * html string for the legend.
3068
+	 * $items are expected in an array in the following format:
3069
+	 * $legend_items = array(
3070
+	 *        'item_id' => array(
3071
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3072
+	 *            'desc' => esc_html__('localized description of item');
3073
+	 *        )
3074
+	 * );
3075
+	 *
3076
+	 * @param  array $items see above for format of array
3077
+	 * @return string html string of legend
3078
+	 * @throws DomainException
3079
+	 */
3080
+	protected function _display_legend($items)
3081
+	{
3082
+		$this->_template_args['items'] = apply_filters(
3083
+			'FHEE__EE_Admin_Page___display_legend__items',
3084
+			(array) $items,
3085
+			$this
3086
+		);
3087
+		return EEH_Template::display_template(
3088
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3089
+			$this->_template_args,
3090
+			true
3091
+		);
3092
+	}
3093
+
3094
+
3095
+	/**
3096
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3097
+	 * The returned json object is created from an array in the following format:
3098
+	 * array(
3099
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3100
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3101
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3102
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3103
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3104
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3105
+	 *  that might be included in here)
3106
+	 * )
3107
+	 * The json object is populated by whatever is set in the $_template_args property.
3108
+	 *
3109
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3110
+	 *                                 instead of displayed.
3111
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3112
+	 * @return void
3113
+	 * @throws EE_Error
3114
+	 */
3115
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3116
+	{
3117
+		// make sure any EE_Error notices have been handled.
3118
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3119
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3120
+		unset($this->_template_args['data']);
3121
+		$json = array(
3122
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3123
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3124
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3125
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3126
+			'notices'   => EE_Error::get_notices(),
3127
+			'content'   => isset($this->_template_args['admin_page_content'])
3128
+				? $this->_template_args['admin_page_content'] : '',
3129
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3130
+			'isEEajax'  => true
3131
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3132
+		);
3133
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3134
+		if (null === error_get_last() || ! headers_sent()) {
3135
+			header('Content-Type: application/json; charset=UTF-8');
3136
+		}
3137
+		echo wp_json_encode($json);
3138
+		exit();
3139
+	}
3140
+
3141
+
3142
+	/**
3143
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3144
+	 *
3145
+	 * @return void
3146
+	 * @throws EE_Error
3147
+	 */
3148
+	public function return_json()
3149
+	{
3150
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3151
+			$this->_return_json();
3152
+		} else {
3153
+			throw new EE_Error(
3154
+				sprintf(
3155
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3156
+					__FUNCTION__
3157
+				)
3158
+			);
3159
+		}
3160
+	}
3161
+
3162
+
3163
+	/**
3164
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3165
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3166
+	 *
3167
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3168
+	 */
3169
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3170
+	{
3171
+		$this->_hook_obj = $hook_obj;
3172
+	}
3173
+
3174
+
3175
+	/**
3176
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3177
+	 *
3178
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3179
+	 * @return void
3180
+	 * @throws DomainException
3181
+	 * @throws EE_Error
3182
+	 */
3183
+	public function admin_page_wrapper($about = false)
3184
+	{
3185
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3186
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3187
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3188
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3189
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3190
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3191
+			isset($this->_template_args['before_admin_page_content'])
3192
+				? $this->_template_args['before_admin_page_content']
3193
+				: ''
3194
+		);
3195
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3196
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3197
+			isset($this->_template_args['after_admin_page_content'])
3198
+				? $this->_template_args['after_admin_page_content']
3199
+				: ''
3200
+		);
3201
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3202
+		// load settings page wrapper template
3203
+		$template_path = ! defined('DOING_AJAX')
3204
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3205
+			: EE_ADMIN_TEMPLATE
3206
+			  . 'admin_wrapper_ajax.template.php';
3207
+		// about page?
3208
+		$template_path = $about
3209
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3210
+			: $template_path;
3211
+		if (defined('DOING_AJAX')) {
3212
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3213
+				$template_path,
3214
+				$this->_template_args,
3215
+				true
3216
+			);
3217
+			$this->_return_json();
3218
+		} else {
3219
+			EEH_Template::display_template($template_path, $this->_template_args);
3220
+		}
3221
+	}
3222
+
3223
+
3224
+	/**
3225
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3226
+	 *
3227
+	 * @return string html
3228
+	 * @throws EE_Error
3229
+	 */
3230
+	protected function _get_main_nav_tabs()
3231
+	{
3232
+		// let's generate the html using the EEH_Tabbed_Content helper.
3233
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3234
+		// (rather than setting in the page_routes array)
3235
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3236
+	}
3237
+
3238
+
3239
+	/**
3240
+	 *        sort nav tabs
3241
+	 *
3242
+	 * @param $a
3243
+	 * @param $b
3244
+	 * @return int
3245
+	 */
3246
+	private function _sort_nav_tabs($a, $b)
3247
+	{
3248
+		if ($a['order'] === $b['order']) {
3249
+			return 0;
3250
+		}
3251
+		return ($a['order'] < $b['order']) ? -1 : 1;
3252
+	}
3253
+
3254
+
3255
+	/**
3256
+	 *    generates HTML for the forms used on admin pages
3257
+	 *
3258
+	 * @param    array $input_vars - array of input field details
3259
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3260
+	 *                             use)
3261
+	 * @param bool     $id
3262
+	 * @return string
3263
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3264
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3265
+	 */
3266
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3267
+	{
3268
+		$content = $generator === 'string'
3269
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3270
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3271
+		return $content;
3272
+	}
3273
+
3274
+
3275
+	/**
3276
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3277
+	 *
3278
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3279
+	 *                                   Close" button.
3280
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3281
+	 *                                   'Save', [1] => 'save & close')
3282
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3283
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3284
+	 *                                   default actions by submitting some other value.
3285
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3286
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3287
+	 *                                   close (normal form handling).
3288
+	 */
3289
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3290
+	{
3291
+		// make sure $text and $actions are in an array
3292
+		$text = (array) $text;
3293
+		$actions = (array) $actions;
3294
+		$referrer_url = empty($referrer)
3295
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3296
+			  . $_SERVER['REQUEST_URI']
3297
+			  . '" />'
3298
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3299
+			  . $referrer
3300
+			  . '" />';
3301
+		$button_text = ! empty($text)
3302
+			? $text
3303
+			: array(
3304
+				esc_html__('Save', 'event_espresso'),
3305
+				esc_html__('Save and Close', 'event_espresso'),
3306
+			);
3307
+		$default_names = array('save', 'save_and_close');
3308
+		// add in a hidden index for the current page (so save and close redirects properly)
3309
+		$this->_template_args['save_buttons'] = $referrer_url;
3310
+		foreach ($button_text as $key => $button) {
3311
+			$ref = $default_names[ $key ];
3312
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3313
+													 . $ref
3314
+													 . '" value="'
3315
+													 . $button
3316
+													 . '" name="'
3317
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3318
+													 . '" id="'
3319
+													 . $this->_current_view . '_' . $ref
3320
+													 . '" />';
3321
+			if (! $both) {
3322
+				break;
3323
+			}
3324
+		}
3325
+	}
3326
+
3327
+
3328
+	/**
3329
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3330
+	 *
3331
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3332
+	 * @since 4.6.0
3333
+	 * @param string $route
3334
+	 * @param array  $additional_hidden_fields
3335
+	 */
3336
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3337
+	{
3338
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3339
+	}
3340
+
3341
+
3342
+	/**
3343
+	 * set form open and close tags on add/edit pages.
3344
+	 *
3345
+	 * @param string $route                    the route you want the form to direct to
3346
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3347
+	 * @return void
3348
+	 */
3349
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3350
+	{
3351
+		if (empty($route)) {
3352
+			$user_msg = esc_html__(
3353
+				'An error occurred. No action was set for this page\'s form.',
3354
+				'event_espresso'
3355
+			);
3356
+			$dev_msg = $user_msg . "\n"
3357
+					   . sprintf(
3358
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3359
+						   __FUNCTION__,
3360
+						   __CLASS__
3361
+					   );
3362
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3363
+		}
3364
+		// open form
3365
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3366
+															 . $this->_admin_base_url
3367
+															 . '" id="'
3368
+															 . $route
3369
+															 . '_event_form" >';
3370
+		// add nonce
3371
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3372
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3373
+		// add REQUIRED form action
3374
+		$hidden_fields = array(
3375
+			'action' => array('type' => 'hidden', 'value' => $route),
3376
+		);
3377
+		// merge arrays
3378
+		$hidden_fields = is_array($additional_hidden_fields)
3379
+			? array_merge($hidden_fields, $additional_hidden_fields)
3380
+			: $hidden_fields;
3381
+		// generate form fields
3382
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3383
+		// add fields to form
3384
+		foreach ((array) $form_fields as $field_name => $form_field) {
3385
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3386
+		}
3387
+		// close form
3388
+		$this->_template_args['after_admin_page_content'] = '</form>';
3389
+	}
3390
+
3391
+
3392
+	/**
3393
+	 * Public Wrapper for _redirect_after_action() method since its
3394
+	 * discovered it would be useful for external code to have access.
3395
+	 *
3396
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3397
+	 * @since 4.5.0
3398
+	 * @param bool   $success
3399
+	 * @param string $what
3400
+	 * @param string $action_desc
3401
+	 * @param array  $query_args
3402
+	 * @param bool   $override_overwrite
3403
+	 * @throws EE_Error
3404
+	 */
3405
+	public function redirect_after_action(
3406
+		$success = false,
3407
+		$what = 'item',
3408
+		$action_desc = 'processed',
3409
+		$query_args = array(),
3410
+		$override_overwrite = false
3411
+	) {
3412
+		$this->_redirect_after_action(
3413
+			$success,
3414
+			$what,
3415
+			$action_desc,
3416
+			$query_args,
3417
+			$override_overwrite
3418
+		);
3419
+	}
3420
+
3421
+
3422
+	/**
3423
+	 * Helper method for merging existing request data with the returned redirect url.
3424
+	 *
3425
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3426
+	 * filters are still applied.
3427
+	 *
3428
+	 * @param array $new_route_data
3429
+	 * @return array
3430
+	 */
3431
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3432
+	{
3433
+		foreach ($this->_req_data as $ref => $value) {
3434
+			// unset nonces
3435
+			if (strpos($ref, 'nonce') !== false) {
3436
+				unset($this->_req_data[ $ref ]);
3437
+				continue;
3438
+			}
3439
+			// urlencode values.
3440
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3441
+			$this->_req_data[ $ref ] = $value;
3442
+		}
3443
+		return array_merge($this->_req_data, $new_route_data);
3444
+	}
3445
+
3446
+
3447
+	/**
3448
+	 *    _redirect_after_action
3449
+	 *
3450
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3451
+	 * @param string $what               - what the action was performed on
3452
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3453
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3454
+	 *                                   action is completed
3455
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3456
+	 *                                   override this so that they show.
3457
+	 * @return void
3458
+	 * @throws EE_Error
3459
+	 */
3460
+	protected function _redirect_after_action(
3461
+		$success = 0,
3462
+		$what = 'item',
3463
+		$action_desc = 'processed',
3464
+		$query_args = array(),
3465
+		$override_overwrite = false
3466
+	) {
3467
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3468
+		// class name for actions/filters.
3469
+		$classname = get_class($this);
3470
+		// set redirect url.
3471
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3472
+		// otherwise we go with whatever is set as the _admin_base_url
3473
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3474
+		$notices = EE_Error::get_notices(false);
3475
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3476
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3477
+			EE_Error::overwrite_success();
3478
+		}
3479
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3480
+			// how many records affected ? more than one record ? or just one ?
3481
+			if ($success > 1) {
3482
+				// set plural msg
3483
+				EE_Error::add_success(
3484
+					sprintf(
3485
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3486
+						$what,
3487
+						$action_desc
3488
+					),
3489
+					__FILE__,
3490
+					__FUNCTION__,
3491
+					__LINE__
3492
+				);
3493
+			} elseif ($success === 1) {
3494
+				// set singular msg
3495
+				EE_Error::add_success(
3496
+					sprintf(
3497
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3498
+						$what,
3499
+						$action_desc
3500
+					),
3501
+					__FILE__,
3502
+					__FUNCTION__,
3503
+					__LINE__
3504
+				);
3505
+			}
3506
+		}
3507
+		// check that $query_args isn't something crazy
3508
+		if (! is_array($query_args)) {
3509
+			$query_args = array();
3510
+		}
3511
+		/**
3512
+		 * Allow injecting actions before the query_args are modified for possible different
3513
+		 * redirections on save and close actions
3514
+		 *
3515
+		 * @since 4.2.0
3516
+		 * @param array $query_args       The original query_args array coming into the
3517
+		 *                                method.
3518
+		 */
3519
+		do_action(
3520
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3521
+			$query_args
3522
+		);
3523
+		// calculate where we're going (if we have a "save and close" button pushed)
3524
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3525
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3526
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3527
+			// regenerate query args array from referrer URL
3528
+			parse_str($parsed_url['query'], $query_args);
3529
+			// correct page and action will be in the query args now
3530
+			$redirect_url = admin_url('admin.php');
3531
+		}
3532
+		// merge any default query_args set in _default_route_query_args property
3533
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3534
+			$args_to_merge = array();
3535
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3536
+				// is there a wp_referer array in our _default_route_query_args property?
3537
+				if ($query_param === 'wp_referer') {
3538
+					$query_value = (array) $query_value;
3539
+					foreach ($query_value as $reference => $value) {
3540
+						if (strpos($reference, 'nonce') !== false) {
3541
+							continue;
3542
+						}
3543
+						// finally we will override any arguments in the referer with
3544
+						// what might be set on the _default_route_query_args array.
3545
+						if (isset($this->_default_route_query_args[ $reference ])) {
3546
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3547
+						} else {
3548
+							$args_to_merge[ $reference ] = urlencode($value);
3549
+						}
3550
+					}
3551
+					continue;
3552
+				}
3553
+				$args_to_merge[ $query_param ] = $query_value;
3554
+			}
3555
+			// now let's merge these arguments but override with what was specifically sent in to the
3556
+			// redirect.
3557
+			$query_args = array_merge($args_to_merge, $query_args);
3558
+		}
3559
+		$this->_process_notices($query_args);
3560
+		// generate redirect url
3561
+		// if redirecting to anything other than the main page, add a nonce
3562
+		if (isset($query_args['action'])) {
3563
+			// manually generate wp_nonce and merge that with the query vars
3564
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3565
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3566
+		}
3567
+		// we're adding some hooks and filters in here for processing any things just before redirects
3568
+		// (example: an admin page has done an insert or update and we want to run something after that).
3569
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3570
+		$redirect_url = apply_filters(
3571
+			'FHEE_redirect_' . $classname . $this->_req_action,
3572
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3573
+			$query_args
3574
+		);
3575
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3576
+		if (defined('DOING_AJAX')) {
3577
+			$default_data = array(
3578
+				'close'        => true,
3579
+				'redirect_url' => $redirect_url,
3580
+				'where'        => 'main',
3581
+				'what'         => 'append',
3582
+			);
3583
+			$this->_template_args['success'] = $success;
3584
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3585
+				$default_data,
3586
+				$this->_template_args['data']
3587
+			) : $default_data;
3588
+			$this->_return_json();
3589
+		}
3590
+		wp_safe_redirect($redirect_url);
3591
+		exit();
3592
+	}
3593
+
3594
+
3595
+	/**
3596
+	 * process any notices before redirecting (or returning ajax request)
3597
+	 * This method sets the $this->_template_args['notices'] attribute;
3598
+	 *
3599
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3600
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3601
+	 *                                  page_routes haven't been defined yet.
3602
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3603
+	 *                                  still save a transient for the notice.
3604
+	 * @return void
3605
+	 * @throws EE_Error
3606
+	 */
3607
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3608
+	{
3609
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3610
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3611
+			$notices = EE_Error::get_notices(false);
3612
+			if (empty($this->_template_args['success'])) {
3613
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3614
+			}
3615
+			if (empty($this->_template_args['errors'])) {
3616
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3617
+			}
3618
+			if (empty($this->_template_args['attention'])) {
3619
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3620
+			}
3621
+		}
3622
+		$this->_template_args['notices'] = EE_Error::get_notices();
3623
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3624
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3625
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3626
+			$this->_add_transient(
3627
+				$route,
3628
+				$this->_template_args['notices'],
3629
+				true,
3630
+				$skip_route_verify
3631
+			);
3632
+		}
3633
+	}
3634
+
3635
+
3636
+	/**
3637
+	 * get_action_link_or_button
3638
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3639
+	 *
3640
+	 * @param string $action        use this to indicate which action the url is generated with.
3641
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3642
+	 *                              property.
3643
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3644
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3645
+	 * @param string $base_url      If this is not provided
3646
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3647
+	 *                              Otherwise this value will be used.
3648
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3649
+	 * @return string
3650
+	 * @throws InvalidArgumentException
3651
+	 * @throws InvalidInterfaceException
3652
+	 * @throws InvalidDataTypeException
3653
+	 * @throws EE_Error
3654
+	 */
3655
+	public function get_action_link_or_button(
3656
+		$action,
3657
+		$type = 'add',
3658
+		$extra_request = array(),
3659
+		$class = 'button-primary',
3660
+		$base_url = '',
3661
+		$exclude_nonce = false
3662
+	) {
3663
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3664
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3665
+			throw new EE_Error(
3666
+				sprintf(
3667
+					esc_html__(
3668
+						'There is no page route for given action for the button.  This action was given: %s',
3669
+						'event_espresso'
3670
+					),
3671
+					$action
3672
+				)
3673
+			);
3674
+		}
3675
+		if (! isset($this->_labels['buttons'][ $type ])) {
3676
+			throw new EE_Error(
3677
+				sprintf(
3678
+					__(
3679
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3680
+						'event_espresso'
3681
+					),
3682
+					$type
3683
+				)
3684
+			);
3685
+		}
3686
+		// finally check user access for this button.
3687
+		$has_access = $this->check_user_access($action, true);
3688
+		if (! $has_access) {
3689
+			return '';
3690
+		}
3691
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3692
+		$query_args = array(
3693
+			'action' => $action,
3694
+		);
3695
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3696
+		if (! empty($extra_request)) {
3697
+			$query_args = array_merge($extra_request, $query_args);
3698
+		}
3699
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3700
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3701
+	}
3702
+
3703
+
3704
+	/**
3705
+	 * _per_page_screen_option
3706
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3707
+	 *
3708
+	 * @return void
3709
+	 * @throws InvalidArgumentException
3710
+	 * @throws InvalidInterfaceException
3711
+	 * @throws InvalidDataTypeException
3712
+	 */
3713
+	protected function _per_page_screen_option()
3714
+	{
3715
+		$option = 'per_page';
3716
+		$args = array(
3717
+			'label'   => apply_filters(
3718
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3719
+				$this->_admin_page_title,
3720
+				$this
3721
+			),
3722
+			'default' => (int) apply_filters(
3723
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3724
+				20
3725
+			),
3726
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3727
+		);
3728
+		// ONLY add the screen option if the user has access to it.
3729
+		if ($this->check_user_access($this->_current_view, true)) {
3730
+			add_screen_option($option, $args);
3731
+		}
3732
+	}
3733
+
3734
+
3735
+	/**
3736
+	 * set_per_page_screen_option
3737
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3738
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3739
+	 * admin_menu.
3740
+	 *
3741
+	 * @return void
3742
+	 */
3743
+	private function _set_per_page_screen_options()
3744
+	{
3745
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3746
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3747
+			if (! $user = wp_get_current_user()) {
3748
+				return;
3749
+			}
3750
+			$option = $_POST['wp_screen_options']['option'];
3751
+			$value = $_POST['wp_screen_options']['value'];
3752
+			if ($option != sanitize_key($option)) {
3753
+				return;
3754
+			}
3755
+			$map_option = $option;
3756
+			$option = str_replace('-', '_', $option);
3757
+			switch ($map_option) {
3758
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3759
+					$value = (int) $value;
3760
+					$max_value = apply_filters(
3761
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3762
+						999,
3763
+						$this->_current_page,
3764
+						$this->_current_view
3765
+					);
3766
+					if ($value < 1) {
3767
+						return;
3768
+					}
3769
+					$value = min($value, $max_value);
3770
+					break;
3771
+				default:
3772
+					$value = apply_filters(
3773
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3774
+						false,
3775
+						$option,
3776
+						$value
3777
+					);
3778
+					if (false === $value) {
3779
+						return;
3780
+					}
3781
+					break;
3782
+			}
3783
+			update_user_meta($user->ID, $option, $value);
3784
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3785
+			exit;
3786
+		}
3787
+	}
3788
+
3789
+
3790
+	/**
3791
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3792
+	 *
3793
+	 * @param array $data array that will be assigned to template args.
3794
+	 */
3795
+	public function set_template_args($data)
3796
+	{
3797
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3798
+	}
3799
+
3800
+
3801
+	/**
3802
+	 * This makes available the WP transient system for temporarily moving data between routes
3803
+	 *
3804
+	 * @param string $route             the route that should receive the transient
3805
+	 * @param array  $data              the data that gets sent
3806
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3807
+	 *                                  normal route transient.
3808
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3809
+	 *                                  when we are adding a transient before page_routes have been defined.
3810
+	 * @return void
3811
+	 * @throws EE_Error
3812
+	 */
3813
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3814
+	{
3815
+		$user_id = get_current_user_id();
3816
+		if (! $skip_route_verify) {
3817
+			$this->_verify_route($route);
3818
+		}
3819
+		// now let's set the string for what kind of transient we're setting
3820
+		$transient = $notices
3821
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3822
+			: 'rte_tx_' . $route . '_' . $user_id;
3823
+		$data = $notices ? array('notices' => $data) : $data;
3824
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3825
+		$existing = is_multisite() && is_network_admin()
3826
+			? get_site_transient($transient)
3827
+			: get_transient($transient);
3828
+		if ($existing) {
3829
+			$data = array_merge((array) $data, (array) $existing);
3830
+		}
3831
+		if (is_multisite() && is_network_admin()) {
3832
+			set_site_transient($transient, $data, 8);
3833
+		} else {
3834
+			set_transient($transient, $data, 8);
3835
+		}
3836
+	}
3837
+
3838
+
3839
+	/**
3840
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3841
+	 *
3842
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3843
+	 * @param string $route
3844
+	 * @return mixed data
3845
+	 */
3846
+	protected function _get_transient($notices = false, $route = '')
3847
+	{
3848
+		$user_id = get_current_user_id();
3849
+		$route = ! $route ? $this->_req_action : $route;
3850
+		$transient = $notices
3851
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3852
+			: 'rte_tx_' . $route . '_' . $user_id;
3853
+		$data = is_multisite() && is_network_admin()
3854
+			? get_site_transient($transient)
3855
+			: get_transient($transient);
3856
+		// delete transient after retrieval (just in case it hasn't expired);
3857
+		if (is_multisite() && is_network_admin()) {
3858
+			delete_site_transient($transient);
3859
+		} else {
3860
+			delete_transient($transient);
3861
+		}
3862
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3868
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3869
+	 * default route callback on the EE_Admin page you want it run.)
3870
+	 *
3871
+	 * @return void
3872
+	 */
3873
+	protected function _transient_garbage_collection()
3874
+	{
3875
+		global $wpdb;
3876
+		// retrieve all existing transients
3877
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3878
+		if ($results = $wpdb->get_results($query)) {
3879
+			foreach ($results as $result) {
3880
+				$transient = str_replace('_transient_', '', $result->option_name);
3881
+				get_transient($transient);
3882
+				if (is_multisite() && is_network_admin()) {
3883
+					get_site_transient($transient);
3884
+				}
3885
+			}
3886
+		}
3887
+	}
3888
+
3889
+
3890
+	/**
3891
+	 * get_view
3892
+	 *
3893
+	 * @return string content of _view property
3894
+	 */
3895
+	public function get_view()
3896
+	{
3897
+		return $this->_view;
3898
+	}
3899
+
3900
+
3901
+	/**
3902
+	 * getter for the protected $_views property
3903
+	 *
3904
+	 * @return array
3905
+	 */
3906
+	public function get_views()
3907
+	{
3908
+		return $this->_views;
3909
+	}
3910
+
3911
+
3912
+	/**
3913
+	 * get_current_page
3914
+	 *
3915
+	 * @return string _current_page property value
3916
+	 */
3917
+	public function get_current_page()
3918
+	{
3919
+		return $this->_current_page;
3920
+	}
3921
+
3922
+
3923
+	/**
3924
+	 * get_current_view
3925
+	 *
3926
+	 * @return string _current_view property value
3927
+	 */
3928
+	public function get_current_view()
3929
+	{
3930
+		return $this->_current_view;
3931
+	}
3932
+
3933
+
3934
+	/**
3935
+	 * get_current_screen
3936
+	 *
3937
+	 * @return object The current WP_Screen object
3938
+	 */
3939
+	public function get_current_screen()
3940
+	{
3941
+		return $this->_current_screen;
3942
+	}
3943
+
3944
+
3945
+	/**
3946
+	 * get_current_page_view_url
3947
+	 *
3948
+	 * @return string This returns the url for the current_page_view.
3949
+	 */
3950
+	public function get_current_page_view_url()
3951
+	{
3952
+		return $this->_current_page_view_url;
3953
+	}
3954
+
3955
+
3956
+	/**
3957
+	 * just returns the _req_data property
3958
+	 *
3959
+	 * @return array
3960
+	 */
3961
+	public function get_request_data()
3962
+	{
3963
+		return $this->_req_data;
3964
+	}
3965
+
3966
+
3967
+	/**
3968
+	 * returns the _req_data protected property
3969
+	 *
3970
+	 * @return string
3971
+	 */
3972
+	public function get_req_action()
3973
+	{
3974
+		return $this->_req_action;
3975
+	}
3976
+
3977
+
3978
+	/**
3979
+	 * @return bool  value of $_is_caf property
3980
+	 */
3981
+	public function is_caf()
3982
+	{
3983
+		return $this->_is_caf;
3984
+	}
3985
+
3986
+
3987
+	/**
3988
+	 * @return mixed
3989
+	 */
3990
+	public function default_espresso_metaboxes()
3991
+	{
3992
+		return $this->_default_espresso_metaboxes;
3993
+	}
3994
+
3995
+
3996
+	/**
3997
+	 * @return mixed
3998
+	 */
3999
+	public function admin_base_url()
4000
+	{
4001
+		return $this->_admin_base_url;
4002
+	}
4003
+
4004
+
4005
+	/**
4006
+	 * @return mixed
4007
+	 */
4008
+	public function wp_page_slug()
4009
+	{
4010
+		return $this->_wp_page_slug;
4011
+	}
4012
+
4013
+
4014
+	/**
4015
+	 * updates  espresso configuration settings
4016
+	 *
4017
+	 * @param string                   $tab
4018
+	 * @param EE_Config_Base|EE_Config $config
4019
+	 * @param string                   $file file where error occurred
4020
+	 * @param string                   $func function  where error occurred
4021
+	 * @param string                   $line line no where error occurred
4022
+	 * @return boolean
4023
+	 */
4024
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4025
+	{
4026
+		// remove any options that are NOT going to be saved with the config settings.
4027
+		if (isset($config->core->ee_ueip_optin)) {
4028
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4029
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4030
+			update_option('ee_ueip_has_notified', true);
4031
+		}
4032
+		// and save it (note we're also doing the network save here)
4033
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4034
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4035
+		if ($config_saved && $net_saved) {
4036
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4037
+			return true;
4038
+		}
4039
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4040
+		return false;
4041
+	}
4042
+
4043
+
4044
+	/**
4045
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4046
+	 *
4047
+	 * @return array
4048
+	 */
4049
+	public function get_yes_no_values()
4050
+	{
4051
+		return $this->_yes_no_values;
4052
+	}
4053
+
4054
+
4055
+	protected function _get_dir()
4056
+	{
4057
+		$reflector = new ReflectionClass(get_class($this));
4058
+		return dirname($reflector->getFileName());
4059
+	}
4060
+
4061
+
4062
+	/**
4063
+	 * A helper for getting a "next link".
4064
+	 *
4065
+	 * @param string $url   The url to link to
4066
+	 * @param string $class The class to use.
4067
+	 * @return string
4068
+	 */
4069
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4070
+	{
4071
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4072
+	}
4073
+
4074
+
4075
+	/**
4076
+	 * A helper for getting a "previous link".
4077
+	 *
4078
+	 * @param string $url   The url to link to
4079
+	 * @param string $class The class to use.
4080
+	 * @return string
4081
+	 */
4082
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4083
+	{
4084
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4085
+	}
4086
+
4087
+
4088
+
4089
+
4090
+
4091
+
4092
+
4093
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4094
+
4095
+
4096
+	/**
4097
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4098
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4099
+	 * _req_data array.
4100
+	 *
4101
+	 * @return bool success/fail
4102
+	 * @throws EE_Error
4103
+	 * @throws InvalidArgumentException
4104
+	 * @throws ReflectionException
4105
+	 * @throws InvalidDataTypeException
4106
+	 * @throws InvalidInterfaceException
4107
+	 */
4108
+	protected function _process_resend_registration()
4109
+	{
4110
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4111
+		do_action(
4112
+			'AHEE__EE_Admin_Page___process_resend_registration',
4113
+			$this->_template_args['success'],
4114
+			$this->_req_data
4115
+		);
4116
+		return $this->_template_args['success'];
4117
+	}
4118
+
4119
+
4120
+	/**
4121
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4122
+	 *
4123
+	 * @param \EE_Payment $payment
4124
+	 * @return bool success/fail
4125
+	 */
4126
+	protected function _process_payment_notification(EE_Payment $payment)
4127
+	{
4128
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4129
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4130
+		$this->_template_args['success'] = apply_filters(
4131
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4132
+			false,
4133
+			$payment
4134
+		);
4135
+		return $this->_template_args['success'];
4136
+	}
4137 4137
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Div_Per_Section_Layout.strategy.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -14,136 +14,136 @@
 block discarded – undo
14 14
 class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base
15 15
 {
16 16
 
17
-    /**
18
-     * opening div tag for a form
19
-     *
20
-     * @return string
21
-     */
22
-    public function layout_form_begin()
23
-    {
24
-        return EEH_HTML::div(
25
-            '',
26
-            $this->_form_section->html_id(),
27
-            $this->_form_section->html_class(),
28
-            $this->_form_section->html_style()
29
-        );
30
-    }
31
-
32
-
33
-
34
-    /**
35
-     * Lays out the row for the input, including label and errors
36
-     *
37
-     * @param EE_Form_Input_Base $input
38
-     * @return string
39
-     * @throws \EE_Error
40
-     */
41
-    public function layout_input($input)
42
-    {
43
-        $html = '';
44
-        // set something unique for the id
45
-        $html_id = (string) $input->html_id() !== ''
46
-            ? (string) $input->html_id()
47
-            : spl_object_hash($input);
48
-        // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
50
-        if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
52
-        } elseif ($input instanceof EE_Submit_Input) {
53
-            $html .= EEH_HTML::div(
54
-                $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
56
-                "{$input->html_class()}-submit-dv {$html_class}"
57
-            );
58
-        } elseif ($input instanceof EE_Select_Input) {
59
-            $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
65
-                "{$input->html_class()}-input-dv {$html_class}"
66
-            );
67
-        } elseif ($input instanceof EE_Form_Input_With_Options_Base) {
68
-            $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
74
-                "{$input->html_class()}-input-dv {$html_class}"
75
-            );
76
-        } else {
77
-            $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
83
-                "{$input->html_class()}-input-dv {$html_class}"
84
-            );
85
-        }
86
-        return $html;
87
-    }
88
-
89
-
90
-
91
-    /**
92
-     *
93
-     * _display_label_for_option_type_question
94
-     * Gets the HTML for the 'label', which is just text for this (because labels
95
-     * should be for each input)
96
-     *
97
-     * @param EE_Form_Input_With_Options_Base $input
98
-     * @return string
99
-     */
100
-    protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
101
-    {
102
-        if ($input->display_html_label_text()) {
103
-            $html_label_text = $input->html_label_text();
104
-            $label_html = EEH_HTML::div(
105
-                $input->required()
106
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
107
-                    : $html_label_text,
108
-                $input->html_label_id(),
109
-                $input->required()
110
-                    ? 'ee-required-label ' . $input->html_label_class()
111
-                    : $input->html_label_class(),
112
-                $input->html_label_style(),
113
-                $input->other_html_attributes()
114
-            );
115
-            // if no content was provided to EEH_HTML::div() above (ie: an empty label),
116
-            // then we need to close the div manually
117
-            if (empty($html_label_text)) {
118
-                $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
119
-            }
120
-            return $label_html;
121
-        }
122
-        return '';
123
-    }
124
-
125
-
126
-
127
-    /**
128
-     * Lays out a row for the subsection
129
-     *
130
-     * @param EE_Form_Section_Proper $form_section
131
-     * @return string
132
-     */
133
-    public function layout_subsection($form_section)
134
-    {
135
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * closing div tag for a form
142
-     *
143
-     * @return string
144
-     */
145
-    public function layout_form_end()
146
-    {
147
-        return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
148
-    }
17
+	/**
18
+	 * opening div tag for a form
19
+	 *
20
+	 * @return string
21
+	 */
22
+	public function layout_form_begin()
23
+	{
24
+		return EEH_HTML::div(
25
+			'',
26
+			$this->_form_section->html_id(),
27
+			$this->_form_section->html_class(),
28
+			$this->_form_section->html_style()
29
+		);
30
+	}
31
+
32
+
33
+
34
+	/**
35
+	 * Lays out the row for the input, including label and errors
36
+	 *
37
+	 * @param EE_Form_Input_Base $input
38
+	 * @return string
39
+	 * @throws \EE_Error
40
+	 */
41
+	public function layout_input($input)
42
+	{
43
+		$html = '';
44
+		// set something unique for the id
45
+		$html_id = (string) $input->html_id() !== ''
46
+			? (string) $input->html_id()
47
+			: spl_object_hash($input);
48
+		// and add a generic input type class
49
+		$html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
50
+		if ($input instanceof EE_Hidden_Input) {
51
+			$html .= EEH_HTML::nl() . $input->get_html_for_input();
52
+		} elseif ($input instanceof EE_Submit_Input) {
53
+			$html .= EEH_HTML::div(
54
+				$input->get_html_for_input(),
55
+				$html_id . '-submit-dv',
56
+				"{$input->html_class()}-submit-dv {$html_class}"
57
+			);
58
+		} elseif ($input instanceof EE_Select_Input) {
59
+			$html .= EEH_HTML::div(
60
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
61
+				EEH_HTML::nl() . $input->get_html_for_errors() .
62
+				EEH_HTML::nl() . $input->get_html_for_input() .
63
+				EEH_HTML::nl() . $input->get_html_for_help(),
64
+				$html_id . '-input-dv',
65
+				"{$input->html_class()}-input-dv {$html_class}"
66
+			);
67
+		} elseif ($input instanceof EE_Form_Input_With_Options_Base) {
68
+			$html .= EEH_HTML::div(
69
+				EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
+				EEH_HTML::nl() . $input->get_html_for_errors() .
71
+				EEH_HTML::nl() . $input->get_html_for_input() .
72
+				EEH_HTML::nl() . $input->get_html_for_help(),
73
+				$html_id . '-input-dv',
74
+				"{$input->html_class()}-input-dv {$html_class}"
75
+			);
76
+		} else {
77
+			$html .= EEH_HTML::div(
78
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
79
+				EEH_HTML::nl() . $input->get_html_for_errors() .
80
+				EEH_HTML::nl() . $input->get_html_for_input() .
81
+				EEH_HTML::nl() . $input->get_html_for_help(),
82
+				$html_id . '-input-dv',
83
+				"{$input->html_class()}-input-dv {$html_class}"
84
+			);
85
+		}
86
+		return $html;
87
+	}
88
+
89
+
90
+
91
+	/**
92
+	 *
93
+	 * _display_label_for_option_type_question
94
+	 * Gets the HTML for the 'label', which is just text for this (because labels
95
+	 * should be for each input)
96
+	 *
97
+	 * @param EE_Form_Input_With_Options_Base $input
98
+	 * @return string
99
+	 */
100
+	protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
101
+	{
102
+		if ($input->display_html_label_text()) {
103
+			$html_label_text = $input->html_label_text();
104
+			$label_html = EEH_HTML::div(
105
+				$input->required()
106
+					? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
107
+					: $html_label_text,
108
+				$input->html_label_id(),
109
+				$input->required()
110
+					? 'ee-required-label ' . $input->html_label_class()
111
+					: $input->html_label_class(),
112
+				$input->html_label_style(),
113
+				$input->other_html_attributes()
114
+			);
115
+			// if no content was provided to EEH_HTML::div() above (ie: an empty label),
116
+			// then we need to close the div manually
117
+			if (empty($html_label_text)) {
118
+				$label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
119
+			}
120
+			return $label_html;
121
+		}
122
+		return '';
123
+	}
124
+
125
+
126
+
127
+	/**
128
+	 * Lays out a row for the subsection
129
+	 *
130
+	 * @param EE_Form_Section_Proper $form_section
131
+	 * @return string
132
+	 */
133
+	public function layout_subsection($form_section)
134
+	{
135
+		return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * closing div tag for a form
142
+	 *
143
+	 * @return string
144
+	 */
145
+	public function layout_form_end()
146
+	{
147
+		return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
148
+	}
149 149
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,40 +46,40 @@  discard block
 block discarded – undo
46 46
             ? (string) $input->html_id()
47 47
             : spl_object_hash($input);
48 48
         // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
49
+        $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv';
50 50
         if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
51
+            $html .= EEH_HTML::nl().$input->get_html_for_input();
52 52
         } elseif ($input instanceof EE_Submit_Input) {
53 53
             $html .= EEH_HTML::div(
54 54
                 $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
55
+                $html_id.'-submit-dv',
56 56
                 "{$input->html_class()}-submit-dv {$html_class}"
57 57
             );
58 58
         } elseif ($input instanceof EE_Select_Input) {
59 59
             $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
60
+                EEH_HTML::nl(1).$input->get_html_for_label().
61
+                EEH_HTML::nl().$input->get_html_for_errors().
62
+                EEH_HTML::nl().$input->get_html_for_input().
63
+                EEH_HTML::nl().$input->get_html_for_help(),
64
+                $html_id.'-input-dv',
65 65
                 "{$input->html_class()}-input-dv {$html_class}"
66 66
             );
67 67
         } elseif ($input instanceof EE_Form_Input_With_Options_Base) {
68 68
             $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
69
+                EEH_HTML::nl().$this->_display_label_for_option_type_question($input).
70
+                EEH_HTML::nl().$input->get_html_for_errors().
71
+                EEH_HTML::nl().$input->get_html_for_input().
72
+                EEH_HTML::nl().$input->get_html_for_help(),
73
+                $html_id.'-input-dv',
74 74
                 "{$input->html_class()}-input-dv {$html_class}"
75 75
             );
76 76
         } else {
77 77
             $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
78
+                EEH_HTML::nl(1).$input->get_html_for_label().
79
+                EEH_HTML::nl().$input->get_html_for_errors().
80
+                EEH_HTML::nl().$input->get_html_for_input().
81
+                EEH_HTML::nl().$input->get_html_for_help(),
82
+                $html_id.'-input-dv',
83 83
                 "{$input->html_class()}-input-dv {$html_class}"
84 84
             );
85 85
         }
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
             $html_label_text = $input->html_label_text();
104 104
             $label_html = EEH_HTML::div(
105 105
                 $input->required()
106
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
106
+                    ? $html_label_text.EEH_HTML::span('*', '', 'ee-asterisk')
107 107
                     : $html_label_text,
108 108
                 $input->html_label_id(),
109 109
                 $input->required()
110
-                    ? 'ee-required-label ' . $input->html_label_class()
110
+                    ? 'ee-required-label '.$input->html_label_class()
111 111
                     : $input->html_label_class(),
112 112
                 $input->html_label_style(),
113 113
                 $input->other_html_attributes()
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function layout_subsection($form_section)
134 134
     {
135
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
135
+        return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1);
136 136
     }
137 137
 
138 138
 
Please login to merge, or discard this patch.