Completed
Branch EDTR/ConfirmDelete (bcc9b8)
by
unknown
17:21 queued 09:27
created
core/domain/services/graphql/data/loaders/AttendeeLoader.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 class AttendeeLoader extends AbstractLoader
14 14
 {
15 15
     /**
16
-     * @return EE_Base_Class
16
+     * @return EEM_Attendee
17 17
      * @throws EE_Error
18 18
      * @throws InvalidArgumentException
19 19
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
  */
13 13
 class AttendeeLoader extends AbstractLoader
14 14
 {
15
-    /**
16
-     * @return EE_Base_Class
17
-     * @throws EE_Error
18
-     * @throws InvalidArgumentException
19
-     * @throws InvalidDataTypeException
20
-     * @throws InvalidInterfaceException
21
-     */
22
-    protected function getQuery()
23
-    {
24
-        return EEM_Attendee::instance();
25
-    }
15
+	/**
16
+	 * @return EE_Base_Class
17
+	 * @throws EE_Error
18
+	 * @throws InvalidArgumentException
19
+	 * @throws InvalidDataTypeException
20
+	 * @throws InvalidInterfaceException
21
+	 */
22
+	protected function getQuery()
23
+	{
24
+		return EEM_Attendee::instance();
25
+	}
26 26
 
27
-    /**
28
-     * @param array $keys
29
-     *
30
-     * @return array
31
-     * @throws EE_Error
32
-     * @throws InvalidArgumentException
33
-     * @throws InvalidDataTypeException
34
-     * @throws InvalidInterfaceException
35
-     */
36
-    protected function getWhereParams(array $keys)
37
-    {
38
-        return [
39
-            'ATT_ID' => ['IN', $keys],
40
-        ];
41
-    }
27
+	/**
28
+	 * @param array $keys
29
+	 *
30
+	 * @return array
31
+	 * @throws EE_Error
32
+	 * @throws InvalidArgumentException
33
+	 * @throws InvalidDataTypeException
34
+	 * @throws InvalidInterfaceException
35
+	 */
36
+	protected function getWhereParams(array $keys)
37
+	{
38
+		return [
39
+			'ATT_ID' => ['IN', $keys],
40
+		];
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/types/Attendee.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 
37 37
 
38 38
     /**
39
-     * @return GraphQLFieldInterface[]
39
+     * @return GraphQLField[]
40 40
      * @since $VID:$
41 41
      */
42 42
     public function getFields()
Please login to merge, or discard this patch.
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -22,182 +22,182 @@
 block discarded – undo
22 22
 class Attendee extends TypeBase
23 23
 {
24 24
 
25
-    /**
26
-     * Attendee constructor.
27
-     *
28
-     * @param EEM_Attendee $attendee_model
29
-     */
30
-    public function __construct(EEM_Attendee $attendee_model)
31
-    {
32
-        $this->model = $attendee_model;
33
-        $this->setName($this->namespace . 'Attendee');
34
-        $this->setIsCustomPostType(false); // Set to false to use our model queries
35
-        parent::__construct();
36
-    }
25
+	/**
26
+	 * Attendee constructor.
27
+	 *
28
+	 * @param EEM_Attendee $attendee_model
29
+	 */
30
+	public function __construct(EEM_Attendee $attendee_model)
31
+	{
32
+		$this->model = $attendee_model;
33
+		$this->setName($this->namespace . 'Attendee');
34
+		$this->setIsCustomPostType(false); // Set to false to use our model queries
35
+		parent::__construct();
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @return GraphQLFieldInterface[]
41
-     * @since $VID:$
42
-     */
43
-    public function getFields()
44
-    {
45
-        return [
46
-            new GraphQLField(
47
-                'id',
48
-                ['non_null' => 'ID'],
49
-                null,
50
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
51
-            ),
52
-            new GraphQLOutputField(
53
-                'dbId',
54
-                ['non_null' => 'Int'],
55
-                'ID',
56
-                esc_html__('The attendee ID.', 'event_espresso')
57
-            ),
58
-            new GraphQLOutputField(
59
-                'cacheId',
60
-                ['non_null' => 'String'],
61
-                null,
62
-                esc_html__('The cache ID of the object.', 'event_espresso')
63
-            ),
64
-            new GraphQLOutputField(
65
-                'address',
66
-                'String',
67
-                'address',
68
-                esc_html__('Address Part 1', 'event_espresso'),
69
-                null,
70
-                null,
71
-                ['ee_edit_contacts']
72
-            ),
73
-            new GraphQLOutputField(
74
-                'address2',
75
-                'String',
76
-                'address2',
77
-                esc_html__('Address Part 2', 'event_espresso'),
78
-                null,
79
-                null,
80
-                ['ee_edit_contacts']
81
-            ),
82
-            new GraphQLOutputField(
83
-                'avatar',
84
-                'String',
85
-                null,
86
-                esc_html__('User avatar URL', 'event_espresso'),
87
-                null,
88
-                [$this, 'getAvatar'],
89
-                ['ee_edit_contacts']
90
-            ),
91
-            new GraphQLOutputField(
92
-                'bio',
93
-                'String',
94
-                'bio',
95
-                esc_html__('Attendee Biography', 'event_espresso'),
96
-                null,
97
-                null,
98
-                ['ee_edit_contacts']
99
-            ),
100
-            new GraphQLOutputField(
101
-                'city',
102
-                'String',
103
-                'city',
104
-                esc_html__('City', 'event_espresso'),
105
-                null,
106
-                null,
107
-                ['ee_edit_contacts']
108
-            ),
109
-            new GraphQLOutputField(
110
-                'country',
111
-                $this->namespace . 'Country',
112
-                null,
113
-                esc_html__('Country', 'event_espresso'),
114
-                null,
115
-                null,
116
-                ['ee_edit_contacts']
117
-            ),
118
-            new GraphQLOutputField(
119
-                'email',
120
-                'String',
121
-                'email',
122
-                esc_html__('Email Address', 'event_espresso'),
123
-                null,
124
-                null,
125
-                ['ee_edit_contacts']
126
-            ),
127
-            new GraphQLOutputField(
128
-                'firstName',
129
-                'String',
130
-                'fname',
131
-                esc_html__('Attendee First Name', 'event_espresso')
132
-            ),
133
-            new GraphQLOutputField(
134
-                'fullName',
135
-                'String',
136
-                'full_name',
137
-                esc_html__('Attendee Name', 'event_espresso')
138
-            ),
139
-            new GraphQLOutputField(
140
-                'lastName',
141
-                'String',
142
-                'lname',
143
-                esc_html__('Attendee Last Name', 'event_espresso')
144
-            ),
145
-            new GraphQLOutputField(
146
-                'phone',
147
-                'String',
148
-                'phone',
149
-                esc_html__('Phone', 'event_espresso'),
150
-                null,
151
-                null,
152
-                ['ee_edit_contacts']
153
-            ),
154
-            new GraphQLOutputField(
155
-                'shortBio',
156
-                'String',
157
-                'short_bio',
158
-                esc_html__('Attendee Short Biography', 'event_espresso'),
159
-                null,
160
-                null,
161
-                ['ee_edit_contacts']
162
-            ),
163
-            new GraphQLOutputField(
164
-                'state',
165
-                $this->namespace . 'State',
166
-                null,
167
-                esc_html__('State', 'event_espresso'),
168
-                null,
169
-                null,
170
-                ['ee_edit_contacts']
171
-            ),
172
-            new GraphQLOutputField(
173
-                'zip',
174
-                'String',
175
-                'zip',
176
-                esc_html__('ZIP/Postal Code', 'event_espresso'),
177
-                null,
178
-                null,
179
-                ['ee_edit_contacts']
180
-            ),
181
-        ];
182
-    }
39
+	/**
40
+	 * @return GraphQLFieldInterface[]
41
+	 * @since $VID:$
42
+	 */
43
+	public function getFields()
44
+	{
45
+		return [
46
+			new GraphQLField(
47
+				'id',
48
+				['non_null' => 'ID'],
49
+				null,
50
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
51
+			),
52
+			new GraphQLOutputField(
53
+				'dbId',
54
+				['non_null' => 'Int'],
55
+				'ID',
56
+				esc_html__('The attendee ID.', 'event_espresso')
57
+			),
58
+			new GraphQLOutputField(
59
+				'cacheId',
60
+				['non_null' => 'String'],
61
+				null,
62
+				esc_html__('The cache ID of the object.', 'event_espresso')
63
+			),
64
+			new GraphQLOutputField(
65
+				'address',
66
+				'String',
67
+				'address',
68
+				esc_html__('Address Part 1', 'event_espresso'),
69
+				null,
70
+				null,
71
+				['ee_edit_contacts']
72
+			),
73
+			new GraphQLOutputField(
74
+				'address2',
75
+				'String',
76
+				'address2',
77
+				esc_html__('Address Part 2', 'event_espresso'),
78
+				null,
79
+				null,
80
+				['ee_edit_contacts']
81
+			),
82
+			new GraphQLOutputField(
83
+				'avatar',
84
+				'String',
85
+				null,
86
+				esc_html__('User avatar URL', 'event_espresso'),
87
+				null,
88
+				[$this, 'getAvatar'],
89
+				['ee_edit_contacts']
90
+			),
91
+			new GraphQLOutputField(
92
+				'bio',
93
+				'String',
94
+				'bio',
95
+				esc_html__('Attendee Biography', 'event_espresso'),
96
+				null,
97
+				null,
98
+				['ee_edit_contacts']
99
+			),
100
+			new GraphQLOutputField(
101
+				'city',
102
+				'String',
103
+				'city',
104
+				esc_html__('City', 'event_espresso'),
105
+				null,
106
+				null,
107
+				['ee_edit_contacts']
108
+			),
109
+			new GraphQLOutputField(
110
+				'country',
111
+				$this->namespace . 'Country',
112
+				null,
113
+				esc_html__('Country', 'event_espresso'),
114
+				null,
115
+				null,
116
+				['ee_edit_contacts']
117
+			),
118
+			new GraphQLOutputField(
119
+				'email',
120
+				'String',
121
+				'email',
122
+				esc_html__('Email Address', 'event_espresso'),
123
+				null,
124
+				null,
125
+				['ee_edit_contacts']
126
+			),
127
+			new GraphQLOutputField(
128
+				'firstName',
129
+				'String',
130
+				'fname',
131
+				esc_html__('Attendee First Name', 'event_espresso')
132
+			),
133
+			new GraphQLOutputField(
134
+				'fullName',
135
+				'String',
136
+				'full_name',
137
+				esc_html__('Attendee Name', 'event_espresso')
138
+			),
139
+			new GraphQLOutputField(
140
+				'lastName',
141
+				'String',
142
+				'lname',
143
+				esc_html__('Attendee Last Name', 'event_espresso')
144
+			),
145
+			new GraphQLOutputField(
146
+				'phone',
147
+				'String',
148
+				'phone',
149
+				esc_html__('Phone', 'event_espresso'),
150
+				null,
151
+				null,
152
+				['ee_edit_contacts']
153
+			),
154
+			new GraphQLOutputField(
155
+				'shortBio',
156
+				'String',
157
+				'short_bio',
158
+				esc_html__('Attendee Short Biography', 'event_espresso'),
159
+				null,
160
+				null,
161
+				['ee_edit_contacts']
162
+			),
163
+			new GraphQLOutputField(
164
+				'state',
165
+				$this->namespace . 'State',
166
+				null,
167
+				esc_html__('State', 'event_espresso'),
168
+				null,
169
+				null,
170
+				['ee_edit_contacts']
171
+			),
172
+			new GraphQLOutputField(
173
+				'zip',
174
+				'String',
175
+				'zip',
176
+				esc_html__('ZIP/Postal Code', 'event_espresso'),
177
+				null,
178
+				null,
179
+				['ee_edit_contacts']
180
+			),
181
+		];
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * @param EE_Attendee   $source  The source that's passed down the GraphQL queries
187
-     * @param array       $args    The inputArgs on the field
188
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
189
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
190
-     * @return string
191
-     * @since $VID:$
192
-     */
193
-    public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info)
194
-    {
195
-        $email = $source->email();
185
+	/**
186
+	 * @param EE_Attendee   $source  The source that's passed down the GraphQL queries
187
+	 * @param array       $args    The inputArgs on the field
188
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
189
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
190
+	 * @return string
191
+	 * @since $VID:$
192
+	 */
193
+	public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info)
194
+	{
195
+		$email = $source->email();
196 196
 
197
-        if (empty($email)) {
198
-            return get_avatar_url('', array('force_default' => true));
199
-        }
200
-        $avatar = get_avatar_url($email);
201
-        return $avatar ? $avatar : null;
202
-    }
197
+		if (empty($email)) {
198
+			return get_avatar_url('', array('force_default' => true));
199
+		}
200
+		$avatar = get_avatar_url($email);
201
+		return $avatar ? $avatar : null;
202
+	}
203 203
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     public function __construct(EEM_Attendee $attendee_model)
31 31
     {
32 32
         $this->model = $attendee_model;
33
-        $this->setName($this->namespace . 'Attendee');
33
+        $this->setName($this->namespace.'Attendee');
34 34
         $this->setIsCustomPostType(false); // Set to false to use our model queries
35 35
         parent::__construct();
36 36
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             ),
109 109
             new GraphQLOutputField(
110 110
                 'country',
111
-                $this->namespace . 'Country',
111
+                $this->namespace.'Country',
112 112
                 null,
113 113
                 esc_html__('Country', 'event_espresso'),
114 114
                 null,
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             ),
163 163
             new GraphQLOutputField(
164 164
                 'state',
165
-                $this->namespace . 'State',
165
+                $this->namespace.'State',
166 166
                 null,
167 167
                 esc_html__('State', 'event_espresso'),
168 168
                 null,
Please login to merge, or discard this patch.
core/services/graphql/fields/GraphQLField.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,6 @@
 block discarded – undo
73 73
      * @param string          $description
74 74
      * @param callable|null   $formatter
75 75
      * @param callable|null   $resolver
76
-     * @param array           $args
77 76
      * @param array           $caps
78 77
      */
79 78
     public function __construct(
Please login to merge, or discard this patch.
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -20,254 +20,254 @@
 block discarded – undo
20 20
 class GraphQLField implements GraphQLFieldInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var string $name
25
-     */
26
-    protected $name;
27
-
28
-    /**
29
-     * @var string|string[] $type
30
-     */
31
-    protected $type;
32
-
33
-    /**
34
-     * @var string|null $key
35
-     */
36
-    protected $key;
37
-
38
-    /**
39
-     * @var string $description
40
-     */
41
-    protected $description;
42
-
43
-    /**
44
-     * @var callable $formatter
45
-     */
46
-    protected $formatter;
47
-
48
-    /**
49
-     * @var callable $resolve
50
-     */
51
-    protected $resolver;
52
-
53
-    /**
54
-     * @var array $caps
55
-     */
56
-    protected $caps;
57
-
58
-    /**
59
-     * @var bool $use_for_input
60
-     */
61
-    protected $use_for_input = true;
62
-
63
-    /**
64
-     * @var bool $use_for_output
65
-     */
66
-    protected $use_for_output = true;
67
-
68
-
69
-    /**
70
-     * @param string          $name
71
-     * @param string|string[] $type
72
-     * @param string|null     $key
73
-     * @param string          $description
74
-     * @param callable|null   $formatter
75
-     * @param callable|null   $resolver
76
-     * @param array           $args
77
-     * @param array           $caps
78
-     */
79
-    public function __construct(
80
-        $name,
81
-        $type,
82
-        $key = null,
83
-        $description = '',
84
-        callable $formatter = null,
85
-        callable $resolver = null,
86
-        array $caps = []
87
-    ) {
88
-        $this->name = $name;
89
-        $this->type = $type;
90
-        $this->key = $key;
91
-        $this->description = $description;
92
-        $this->formatter = $formatter;
93
-        $this->resolver = $resolver;
94
-        $this->caps = $caps;
95
-    }
96
-
97
-
98
-    /**
99
-     * @return array
100
-     */
101
-    public function caps()
102
-    {
103
-        return $this->caps;
104
-    }
105
-
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function description()
111
-    {
112
-        return $this->description;
113
-    }
114
-
115
-
116
-    /**
117
-     * @return string
118
-     */
119
-    public function key()
120
-    {
121
-        return $this->key;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    public function name()
129
-    {
130
-        return $this->name;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return string|string[]
136
-     */
137
-    public function type()
138
-    {
139
-        return $this->type;
140
-    }
141
-
142
-
143
-    /**
144
-     * Convert the field to array to be
145
-     * able to pass as config to WP GraphQL
146
-     *
147
-     * @return array
148
-     */
149
-    public function toArray()
150
-    {
151
-        return get_object_vars($this);
152
-    }
153
-
154
-
155
-    /**
156
-     * Sets the value for use_for_input.
157
-     *
158
-     * @param bool $use_for_input
159
-     */
160
-    protected function setUseForInput($use_for_input)
161
-    {
162
-        $this->use_for_input = filter_var($use_for_input, FILTER_VALIDATE_BOOLEAN);
163
-    }
164
-
165
-
166
-    /**
167
-     * Whether the field should be used for
168
-     * mutation inputs.
169
-     *
170
-     * @return bool
171
-     */
172
-    public function useForInput()
173
-    {
174
-        return (bool) $this->use_for_input;
175
-    }
176
-
177
-
178
-    /**
179
-     * Whether the field should be used for
180
-     * query outputs.
181
-     *
182
-     * @return bool
183
-     */
184
-    public function useForOutput()
185
-    {
186
-        return (bool) $this->use_for_output;
187
-    }
188
-
189
-
190
-    /**
191
-     * Sets the value for use_for_output
192
-     *
193
-     * @param bool $use_for_output
194
-     */
195
-    protected function setUseForOutput($use_for_output)
196
-    {
197
-        $this->use_for_output = filter_var($use_for_output, FILTER_VALIDATE_BOOLEAN);
198
-    }
199
-
200
-
201
-    /**
202
-     * Whether the field should resolve
203
-     * based on the user caps etc.
204
-     *
205
-     * @return boolean
206
-     */
207
-    public function shouldResolve()
208
-    {
209
-        foreach ($this->caps as $cap) {
210
-            if (! current_user_can($cap)) {
211
-                return false;
212
-            }
213
-        }
214
-        return true;
215
-    }
216
-
217
-
218
-    /**
219
-     * Whether the field has an explicit resolver set.
220
-     *
221
-     * @return boolean
222
-     */
223
-    public function hasInternalResolver()
224
-    {
225
-        return is_callable($this->resolver);
226
-    }
227
-
228
-
229
-    /**
230
-     * Whether the field has an explicit resolver set.
231
-     *
232
-     * @param mixed       $source  The source that's passed down the GraphQL queries
233
-     * @param array       $args    The inputArgs on the field
234
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
235
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
236
-     * @return mixed
237
-     * @throws LogicException
238
-     */
239
-    public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
240
-    {
241
-        if (! $this->hasInternalResolver()) {
242
-            throw new LogicException('GraphQLField has no internal resolver.');
243
-        }
244
-        // dynamic methods using $this don't play nice
245
-        // so capture resolver to a single var first
246
-        $resolver = $this->resolver;
247
-        return $resolver($source, $args, $context, $info);
248
-    }
249
-
250
-
251
-    /**
252
-     * Checks if the format callback is set.
253
-     * If yes, then uses it to format the value.
254
-     *
255
-     * @param mixed         $value
256
-     * @param EE_Base_Class $source
257
-     * @return mixed The formatted value.
258
-     * @throws InvalidDataTypeException
259
-     * @throws InvalidInterfaceException
260
-     * @throws InvalidArgumentException
261
-     * @throws ReflectionException
262
-     */
263
-    public function mayBeFormatValue($value, EE_Base_Class $source)
264
-    {
265
-        if (is_callable($this->formatter)) {
266
-            // dynamic methods using $this don't play nice
267
-            // so capture formatter to a single var first
268
-            $formatter = $this->formatter;
269
-            return $formatter($value, $source);
270
-        }
271
-        return $value;
272
-    }
23
+	/**
24
+	 * @var string $name
25
+	 */
26
+	protected $name;
27
+
28
+	/**
29
+	 * @var string|string[] $type
30
+	 */
31
+	protected $type;
32
+
33
+	/**
34
+	 * @var string|null $key
35
+	 */
36
+	protected $key;
37
+
38
+	/**
39
+	 * @var string $description
40
+	 */
41
+	protected $description;
42
+
43
+	/**
44
+	 * @var callable $formatter
45
+	 */
46
+	protected $formatter;
47
+
48
+	/**
49
+	 * @var callable $resolve
50
+	 */
51
+	protected $resolver;
52
+
53
+	/**
54
+	 * @var array $caps
55
+	 */
56
+	protected $caps;
57
+
58
+	/**
59
+	 * @var bool $use_for_input
60
+	 */
61
+	protected $use_for_input = true;
62
+
63
+	/**
64
+	 * @var bool $use_for_output
65
+	 */
66
+	protected $use_for_output = true;
67
+
68
+
69
+	/**
70
+	 * @param string          $name
71
+	 * @param string|string[] $type
72
+	 * @param string|null     $key
73
+	 * @param string          $description
74
+	 * @param callable|null   $formatter
75
+	 * @param callable|null   $resolver
76
+	 * @param array           $args
77
+	 * @param array           $caps
78
+	 */
79
+	public function __construct(
80
+		$name,
81
+		$type,
82
+		$key = null,
83
+		$description = '',
84
+		callable $formatter = null,
85
+		callable $resolver = null,
86
+		array $caps = []
87
+	) {
88
+		$this->name = $name;
89
+		$this->type = $type;
90
+		$this->key = $key;
91
+		$this->description = $description;
92
+		$this->formatter = $formatter;
93
+		$this->resolver = $resolver;
94
+		$this->caps = $caps;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return array
100
+	 */
101
+	public function caps()
102
+	{
103
+		return $this->caps;
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function description()
111
+	{
112
+		return $this->description;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return string
118
+	 */
119
+	public function key()
120
+	{
121
+		return $this->key;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	public function name()
129
+	{
130
+		return $this->name;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return string|string[]
136
+	 */
137
+	public function type()
138
+	{
139
+		return $this->type;
140
+	}
141
+
142
+
143
+	/**
144
+	 * Convert the field to array to be
145
+	 * able to pass as config to WP GraphQL
146
+	 *
147
+	 * @return array
148
+	 */
149
+	public function toArray()
150
+	{
151
+		return get_object_vars($this);
152
+	}
153
+
154
+
155
+	/**
156
+	 * Sets the value for use_for_input.
157
+	 *
158
+	 * @param bool $use_for_input
159
+	 */
160
+	protected function setUseForInput($use_for_input)
161
+	{
162
+		$this->use_for_input = filter_var($use_for_input, FILTER_VALIDATE_BOOLEAN);
163
+	}
164
+
165
+
166
+	/**
167
+	 * Whether the field should be used for
168
+	 * mutation inputs.
169
+	 *
170
+	 * @return bool
171
+	 */
172
+	public function useForInput()
173
+	{
174
+		return (bool) $this->use_for_input;
175
+	}
176
+
177
+
178
+	/**
179
+	 * Whether the field should be used for
180
+	 * query outputs.
181
+	 *
182
+	 * @return bool
183
+	 */
184
+	public function useForOutput()
185
+	{
186
+		return (bool) $this->use_for_output;
187
+	}
188
+
189
+
190
+	/**
191
+	 * Sets the value for use_for_output
192
+	 *
193
+	 * @param bool $use_for_output
194
+	 */
195
+	protected function setUseForOutput($use_for_output)
196
+	{
197
+		$this->use_for_output = filter_var($use_for_output, FILTER_VALIDATE_BOOLEAN);
198
+	}
199
+
200
+
201
+	/**
202
+	 * Whether the field should resolve
203
+	 * based on the user caps etc.
204
+	 *
205
+	 * @return boolean
206
+	 */
207
+	public function shouldResolve()
208
+	{
209
+		foreach ($this->caps as $cap) {
210
+			if (! current_user_can($cap)) {
211
+				return false;
212
+			}
213
+		}
214
+		return true;
215
+	}
216
+
217
+
218
+	/**
219
+	 * Whether the field has an explicit resolver set.
220
+	 *
221
+	 * @return boolean
222
+	 */
223
+	public function hasInternalResolver()
224
+	{
225
+		return is_callable($this->resolver);
226
+	}
227
+
228
+
229
+	/**
230
+	 * Whether the field has an explicit resolver set.
231
+	 *
232
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
233
+	 * @param array       $args    The inputArgs on the field
234
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
235
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
236
+	 * @return mixed
237
+	 * @throws LogicException
238
+	 */
239
+	public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
240
+	{
241
+		if (! $this->hasInternalResolver()) {
242
+			throw new LogicException('GraphQLField has no internal resolver.');
243
+		}
244
+		// dynamic methods using $this don't play nice
245
+		// so capture resolver to a single var first
246
+		$resolver = $this->resolver;
247
+		return $resolver($source, $args, $context, $info);
248
+	}
249
+
250
+
251
+	/**
252
+	 * Checks if the format callback is set.
253
+	 * If yes, then uses it to format the value.
254
+	 *
255
+	 * @param mixed         $value
256
+	 * @param EE_Base_Class $source
257
+	 * @return mixed The formatted value.
258
+	 * @throws InvalidDataTypeException
259
+	 * @throws InvalidInterfaceException
260
+	 * @throws InvalidArgumentException
261
+	 * @throws ReflectionException
262
+	 */
263
+	public function mayBeFormatValue($value, EE_Base_Class $source)
264
+	{
265
+		if (is_callable($this->formatter)) {
266
+			// dynamic methods using $this don't play nice
267
+			// so capture formatter to a single var first
268
+			$formatter = $this->formatter;
269
+			return $formatter($value, $source);
270
+		}
271
+		return $value;
272
+	}
273 273
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Indentation   +1535 added lines, -1535 removed lines patch added patch discarded remove patch
@@ -27,472 +27,472 @@  discard block
 block discarded – undo
27 27
 {
28 28
 
29 29
 
30
-    /**
31
-     * This gets set in _setup_cpt
32
-     * It will contain the object for the custom post type.
33
-     *
34
-     * @var EE_CPT_Base
35
-     */
36
-    protected $_cpt_object;
37
-
38
-
39
-    /**
40
-     * a boolean flag to set whether the current route is a cpt route or not.
41
-     *
42
-     * @var bool
43
-     */
44
-    protected $_cpt_route = false;
45
-
46
-
47
-    /**
48
-     * This property allows cpt classes to define multiple routes as cpt routes.
49
-     * //in this array we define what the custom post type for this route is.
50
-     * array(
51
-     * 'route_name' => 'custom_post_type_slug'
52
-     * )
53
-     *
54
-     * @var array
55
-     */
56
-    protected $_cpt_routes = array();
57
-
58
-
59
-    /**
60
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
61
-     * in this format:
62
-     * array(
63
-     * 'post_type_slug' => 'edit_route'
64
-     * )
65
-     *
66
-     * @var array
67
-     */
68
-    protected $_cpt_edit_routes = array();
69
-
70
-
71
-    /**
72
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
73
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
74
-     * _cpt_model_names property should be in the following format: array(
75
-     * 'route_defined_by_action_param' => 'Model_Name')
76
-     *
77
-     * @var array $_cpt_model_names
78
-     */
79
-    protected $_cpt_model_names = array();
80
-
81
-
82
-    /**
83
-     * @var EE_CPT_Base
84
-     */
85
-    protected $_cpt_model_obj = false;
86
-
87
-
88
-    /**
89
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
90
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
91
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
92
-     * Registration of containers should be done before load_page_dependencies() is run.
93
-     *
94
-     * @var array()
95
-     */
96
-    protected $_autosave_containers = array();
97
-    protected $_autosave_fields = array();
98
-
99
-    /**
100
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
101
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
102
-     *
103
-     * @var array
104
-     */
105
-    protected $_pagenow_map;
106
-
107
-    /**
108
-     * @var EspressoEditorAssetManager $asset_manager
109
-     */
110
-    protected $asset_manager;
111
-
112
-
113
-
114
-    /**
115
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
116
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
117
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
118
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
119
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
120
-     *
121
-     * @access protected
122
-     * @abstract
123
-     * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
124
-     * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
125
-     * @return void
126
-     */
127
-    abstract protected function _insert_update_cpt_item($post_id, $post);
128
-
129
-
130
-    /**
131
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
132
-     *
133
-     * @abstract
134
-     * @access public
135
-     * @param  string $post_id The ID of the cpt that was trashed
136
-     * @return void
137
-     */
138
-    abstract public function trash_cpt_item($post_id);
139
-
140
-
141
-    /**
142
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
143
-     *
144
-     * @param  string $post_id theID of the cpt that was untrashed
145
-     * @return void
146
-     */
147
-    abstract public function restore_cpt_item($post_id);
148
-
149
-
150
-    /**
151
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
152
-     * from the db
153
-     *
154
-     * @param  string $post_id the ID of the cpt that was deleted
155
-     * @return void
156
-     */
157
-    abstract public function delete_cpt_item($post_id);
158
-
159
-
160
-    /**
161
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
162
-     *
163
-     * @access protected
164
-     * @return void
165
-     */
166
-    protected function _before_page_setup()
167
-    {
168
-        $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
169
-        $this->_cpt_routes = array_merge(
170
-            array(
171
-                'create_new' => $this->page_slug,
172
-                'edit'       => $this->page_slug,
173
-                'trash'      => $this->page_slug,
174
-            ),
175
-            $this->_cpt_routes
176
-        );
177
-        // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
178
-        $this->_cpt_object = isset($this->_req_data['action'], $this->_cpt_routes[ $this->_req_data['action'] ])
179
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
180
-            : get_post_type_object($page);
181
-        // tweak pagenow for page loading.
182
-        if (! $this->_pagenow_map) {
183
-            $this->_pagenow_map = array(
184
-                'create_new' => 'post-new.php',
185
-                'edit'       => 'post.php',
186
-                'trash'      => 'post.php',
187
-            );
188
-        }
189
-        add_action('current_screen', array($this, 'modify_pagenow'));
190
-        // TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
191
-        // get current page from autosave
192
-        $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
193
-            ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
194
-            : null;
195
-        $this->_current_page = isset($this->_req_data['current_page'])
196
-            ? $this->_req_data['current_page']
197
-            : $current_page;
198
-        // autosave... make sure its only for the correct page
199
-        // if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
200
-        // setup autosave ajax hook
201
-        // add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
202
-        // }
203
-    }
204
-
205
-
206
-    /**
207
-     * Simply ensure that we simulate the correct post route for cpt screens
208
-     *
209
-     * @param WP_Screen $current_screen
210
-     * @return void
211
-     */
212
-    public function modify_pagenow($current_screen)
213
-    {
214
-        global $pagenow, $hook_suffix;
215
-        // possibly reset pagenow.
216
-        if (! empty($this->_req_data['page'])
217
-            && $this->_req_data['page'] === $this->page_slug
218
-            && ! empty($this->_req_data['action'])
219
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
220
-        ) {
221
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
222
-            $hook_suffix = $pagenow;
223
-        }
224
-    }
225
-
226
-
227
-    /**
228
-     * This method is used to register additional autosave containers to the _autosave_containers property.
229
-     *
230
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
231
-     *       automatically register the id for the post metabox as a container.
232
-     * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
233
-     *                    you would send along the id of a metabox container.
234
-     * @return void
235
-     */
236
-    protected function _register_autosave_containers($ids)
237
-    {
238
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
239
-    }
240
-
241
-
242
-    /**
243
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
244
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
245
-     */
246
-    protected function _set_autosave_containers()
247
-    {
248
-        global $wp_meta_boxes;
249
-        $containers = array();
250
-        if (empty($wp_meta_boxes)) {
251
-            return;
252
-        }
253
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
254
-        foreach ($current_metaboxes as $box_context) {
255
-            foreach ($box_context as $box_details) {
256
-                foreach ($box_details as $box) {
257
-                    if (is_array($box) && is_array($box['callback'])
258
-                        && (
259
-                            $box['callback'][0] instanceof EE_Admin_Page
260
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
261
-                        )
262
-                    ) {
263
-                        $containers[] = $box['id'];
264
-                    }
265
-                }
266
-            }
267
-        }
268
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
269
-        // add hidden inputs container
270
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
271
-    }
272
-
273
-
274
-    protected function _load_autosave_scripts_styles()
275
-    {
276
-        /*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 );
30
+	/**
31
+	 * This gets set in _setup_cpt
32
+	 * It will contain the object for the custom post type.
33
+	 *
34
+	 * @var EE_CPT_Base
35
+	 */
36
+	protected $_cpt_object;
37
+
38
+
39
+	/**
40
+	 * a boolean flag to set whether the current route is a cpt route or not.
41
+	 *
42
+	 * @var bool
43
+	 */
44
+	protected $_cpt_route = false;
45
+
46
+
47
+	/**
48
+	 * This property allows cpt classes to define multiple routes as cpt routes.
49
+	 * //in this array we define what the custom post type for this route is.
50
+	 * array(
51
+	 * 'route_name' => 'custom_post_type_slug'
52
+	 * )
53
+	 *
54
+	 * @var array
55
+	 */
56
+	protected $_cpt_routes = array();
57
+
58
+
59
+	/**
60
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
61
+	 * in this format:
62
+	 * array(
63
+	 * 'post_type_slug' => 'edit_route'
64
+	 * )
65
+	 *
66
+	 * @var array
67
+	 */
68
+	protected $_cpt_edit_routes = array();
69
+
70
+
71
+	/**
72
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
73
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
74
+	 * _cpt_model_names property should be in the following format: array(
75
+	 * 'route_defined_by_action_param' => 'Model_Name')
76
+	 *
77
+	 * @var array $_cpt_model_names
78
+	 */
79
+	protected $_cpt_model_names = array();
80
+
81
+
82
+	/**
83
+	 * @var EE_CPT_Base
84
+	 */
85
+	protected $_cpt_model_obj = false;
86
+
87
+
88
+	/**
89
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
90
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
91
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
92
+	 * Registration of containers should be done before load_page_dependencies() is run.
93
+	 *
94
+	 * @var array()
95
+	 */
96
+	protected $_autosave_containers = array();
97
+	protected $_autosave_fields = array();
98
+
99
+	/**
100
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
101
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
102
+	 *
103
+	 * @var array
104
+	 */
105
+	protected $_pagenow_map;
106
+
107
+	/**
108
+	 * @var EspressoEditorAssetManager $asset_manager
109
+	 */
110
+	protected $asset_manager;
111
+
112
+
113
+
114
+	/**
115
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
116
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
117
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
118
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
119
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
120
+	 *
121
+	 * @access protected
122
+	 * @abstract
123
+	 * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
124
+	 * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
125
+	 * @return void
126
+	 */
127
+	abstract protected function _insert_update_cpt_item($post_id, $post);
128
+
129
+
130
+	/**
131
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
132
+	 *
133
+	 * @abstract
134
+	 * @access public
135
+	 * @param  string $post_id The ID of the cpt that was trashed
136
+	 * @return void
137
+	 */
138
+	abstract public function trash_cpt_item($post_id);
139
+
140
+
141
+	/**
142
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
143
+	 *
144
+	 * @param  string $post_id theID of the cpt that was untrashed
145
+	 * @return void
146
+	 */
147
+	abstract public function restore_cpt_item($post_id);
148
+
149
+
150
+	/**
151
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
152
+	 * from the db
153
+	 *
154
+	 * @param  string $post_id the ID of the cpt that was deleted
155
+	 * @return void
156
+	 */
157
+	abstract public function delete_cpt_item($post_id);
158
+
159
+
160
+	/**
161
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
162
+	 *
163
+	 * @access protected
164
+	 * @return void
165
+	 */
166
+	protected function _before_page_setup()
167
+	{
168
+		$page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
169
+		$this->_cpt_routes = array_merge(
170
+			array(
171
+				'create_new' => $this->page_slug,
172
+				'edit'       => $this->page_slug,
173
+				'trash'      => $this->page_slug,
174
+			),
175
+			$this->_cpt_routes
176
+		);
177
+		// let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
178
+		$this->_cpt_object = isset($this->_req_data['action'], $this->_cpt_routes[ $this->_req_data['action'] ])
179
+			? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
180
+			: get_post_type_object($page);
181
+		// tweak pagenow for page loading.
182
+		if (! $this->_pagenow_map) {
183
+			$this->_pagenow_map = array(
184
+				'create_new' => 'post-new.php',
185
+				'edit'       => 'post.php',
186
+				'trash'      => 'post.php',
187
+			);
188
+		}
189
+		add_action('current_screen', array($this, 'modify_pagenow'));
190
+		// TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
191
+		// get current page from autosave
192
+		$current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
193
+			? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
194
+			: null;
195
+		$this->_current_page = isset($this->_req_data['current_page'])
196
+			? $this->_req_data['current_page']
197
+			: $current_page;
198
+		// autosave... make sure its only for the correct page
199
+		// if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
200
+		// setup autosave ajax hook
201
+		// add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
202
+		// }
203
+	}
204
+
205
+
206
+	/**
207
+	 * Simply ensure that we simulate the correct post route for cpt screens
208
+	 *
209
+	 * @param WP_Screen $current_screen
210
+	 * @return void
211
+	 */
212
+	public function modify_pagenow($current_screen)
213
+	{
214
+		global $pagenow, $hook_suffix;
215
+		// possibly reset pagenow.
216
+		if (! empty($this->_req_data['page'])
217
+			&& $this->_req_data['page'] === $this->page_slug
218
+			&& ! empty($this->_req_data['action'])
219
+			&& isset($this->_pagenow_map[ $this->_req_data['action'] ])
220
+		) {
221
+			$pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
222
+			$hook_suffix = $pagenow;
223
+		}
224
+	}
225
+
226
+
227
+	/**
228
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
229
+	 *
230
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
231
+	 *       automatically register the id for the post metabox as a container.
232
+	 * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
233
+	 *                    you would send along the id of a metabox container.
234
+	 * @return void
235
+	 */
236
+	protected function _register_autosave_containers($ids)
237
+	{
238
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
239
+	}
240
+
241
+
242
+	/**
243
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
244
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
245
+	 */
246
+	protected function _set_autosave_containers()
247
+	{
248
+		global $wp_meta_boxes;
249
+		$containers = array();
250
+		if (empty($wp_meta_boxes)) {
251
+			return;
252
+		}
253
+		$current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
254
+		foreach ($current_metaboxes as $box_context) {
255
+			foreach ($box_context as $box_details) {
256
+				foreach ($box_details as $box) {
257
+					if (is_array($box) && is_array($box['callback'])
258
+						&& (
259
+							$box['callback'][0] instanceof EE_Admin_Page
260
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
261
+						)
262
+					) {
263
+						$containers[] = $box['id'];
264
+					}
265
+				}
266
+			}
267
+		}
268
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
269
+		// add hidden inputs container
270
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
271
+	}
272
+
273
+
274
+	protected function _load_autosave_scripts_styles()
275
+	{
276
+		/*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 );
277 277
         wp_enqueue_script('cpt-autosave');/**/ // todo re-enable when we start doing autosave again in 4.2
278 278
 
279
-        // filter _autosave_containers
280
-        $containers = apply_filters(
281
-            'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
282
-            $this->_autosave_containers,
283
-            $this
284
-        );
285
-        $containers = apply_filters(
286
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
287
-            $containers,
288
-            $this
289
-        );
290
-
291
-        wp_localize_script(
292
-            'event_editor_js',
293
-            'EE_AUTOSAVE_IDS',
294
-            $containers
295
-        ); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
296
-
297
-        $unsaved_data_msg = array(
298
-            'eventmsg'     => sprintf(
299
-                __(
300
-                    'The changes you made to this %s will be lost if you navigate away from this page.',
301
-                    'event_espresso'
302
-                ),
303
-                $this->_cpt_object->labels->singular_name
304
-            ),
305
-            'inputChanged' => 0,
306
-        );
307
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
308
-    }
309
-
310
-
311
-    /**
312
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
313
-     *
314
-     * @access protected
315
-     * @return void
316
-     * @throws EE_Error
317
-     * @throws ReflectionException
318
-     */
319
-    protected function _load_page_dependencies()
320
-    {
321
-        // we only add stuff if this is a cpt_route!
322
-        if (! $this->_cpt_route) {
323
-            parent::_load_page_dependencies();
324
-            return;
325
-        }
326
-        // now let's do some automatic filters into the wp_system
327
-        // and we'll check to make sure the CHILD class
328
-        // automatically has the required methods in place.
329
-        // the following filters are for setting all the redirects
330
-        // on DEFAULT WP custom post type actions
331
-        // let's add a hidden input to the post-edit form
332
-        // so we know when we have to trigger our custom redirects!
333
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
334
-        add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
335
-        // inject our Admin page nav tabs...
336
-        // let's make sure the nav tabs are set if they aren't already
337
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
338
-        add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
339
-        // modify the post_updated messages array
340
-        add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
341
-        // add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
342
-        // cpts use the same format for shortlinks as posts!
343
-        add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
344
-        // This basically allows us to change the title of the "publish" metabox area
345
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
346
-        if (! empty($this->_labels['publishbox'])) {
347
-            $box_label = is_array($this->_labels['publishbox'])
348
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
349
-                ? $this->_labels['publishbox'][ $this->_req_action ]
350
-                : $this->_labels['publishbox'];
351
-            add_meta_box(
352
-                'submitdiv',
353
-                $box_label,
354
-                'post_submit_meta_box',
355
-                $this->_cpt_routes[ $this->_req_action ],
356
-                'side',
357
-                'core'
358
-            );
359
-        }
360
-        // let's add page_templates metabox if this cpt added support for it.
361
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
362
-            add_meta_box(
363
-                'page_templates',
364
-                __('Page Template', 'event_espresso'),
365
-                array($this, 'page_template_meta_box'),
366
-                $this->_cpt_routes[ $this->_req_action ],
367
-                'side',
368
-                'default'
369
-            );
370
-        }
371
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
372
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
373
-            add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
374
-        }
375
-        // add preview button
376
-        add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
377
-        // insert our own post_stati dropdown
378
-        add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
379
-        // This allows adding additional information to the publish post submitbox on the wp post edit form
380
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
381
-            add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
382
-        }
383
-        // This allows for adding additional stuff after the title field on the wp post edit form.
384
-        // This is also before the wp_editor for post description field.
385
-        if (method_exists($this, 'edit_form_after_title')) {
386
-            add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
387
-        }
388
-        /**
389
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
390
-         */
391
-        add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
392
-        parent::_load_page_dependencies();
393
-        // notice we are ALSO going to load the pagenow hook set for this route
394
-        // (see _before_page_setup for the reset of the pagenow global ).
395
-        // This is for any plugins that are doing things properly
396
-        // and hooking into the load page hook for core wp cpt routes.
397
-        global $pagenow;
398
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
399
-        do_action('load-' . $pagenow);
400
-        add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
401
-        // we route REALLY early.
402
-        try {
403
-            $this->_route_admin_request();
404
-        } catch (EE_Error $e) {
405
-            $e->get_error();
406
-        }
407
-    }
408
-
409
-
410
-    /**
411
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
412
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
413
-     * route instead.
414
-     *
415
-     * @param string $good_protocol_url The escaped url.
416
-     * @param string $original_url      The original url.
417
-     * @param string $_context          The context sent to the esc_url method.
418
-     * @return string possibly a new url for our route.
419
-     */
420
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
421
-    {
422
-        $routes_to_match = array(
423
-            0 => array(
424
-                'edit.php?post_type=espresso_attendees',
425
-                'admin.php?page=espresso_registrations&action=contact_list',
426
-            ),
427
-            1 => array(
428
-                'edit.php?post_type=' . $this->_cpt_object->name,
429
-                'admin.php?page=' . $this->_cpt_object->name,
430
-            ),
431
-        );
432
-        foreach ($routes_to_match as $route_matches) {
433
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
434
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
435
-            }
436
-        }
437
-        return $good_protocol_url;
438
-    }
439
-
440
-
441
-    /**
442
-     * Determine whether the current cpt supports page templates or not.
443
-     *
444
-     * @since %VER%
445
-     * @param string $cpt_name The cpt slug we're checking on.
446
-     * @return bool True supported, false not.
447
-     * @throws InvalidArgumentException
448
-     * @throws InvalidDataTypeException
449
-     * @throws InvalidInterfaceException
450
-     */
451
-    private function _supports_page_templates($cpt_name)
452
-    {
453
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
454
-        $custom_post_types = $this->loader->getShared(
455
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
456
-        );
457
-        $cpt_args = $custom_post_types->getDefinitions();
458
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
459
-        $cpt_has_support = ! empty($cpt_args['page_templates']);
460
-
461
-        // if the installed version of WP is > 4.7 we do some additional checks.
462
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
463
-            $post_templates = wp_get_theme()->get_post_templates();
464
-            // if there are $post_templates for this cpt, then we return false for this method because
465
-            // that means we aren't going to load our page template manager and leave that up to the native
466
-            // cpt template manager.
467
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
468
-        }
469
-
470
-        return $cpt_has_support;
471
-    }
472
-
473
-
474
-    /**
475
-     * Callback for the page_templates metabox selector.
476
-     *
477
-     * @since %VER%
478
-     * @return void
479
-     */
480
-    public function page_template_meta_box()
481
-    {
482
-        global $post;
483
-        $template = '';
484
-
485
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
486
-            $page_template_count = count(get_page_templates());
487
-        } else {
488
-            $page_template_count = count(get_page_templates($post));
489
-        }
490
-
491
-        if ($page_template_count) {
492
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
493
-            $template = ! empty($page_template) ? $page_template : '';
494
-        }
495
-        ?>
279
+		// filter _autosave_containers
280
+		$containers = apply_filters(
281
+			'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
282
+			$this->_autosave_containers,
283
+			$this
284
+		);
285
+		$containers = apply_filters(
286
+			'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
287
+			$containers,
288
+			$this
289
+		);
290
+
291
+		wp_localize_script(
292
+			'event_editor_js',
293
+			'EE_AUTOSAVE_IDS',
294
+			$containers
295
+		); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
296
+
297
+		$unsaved_data_msg = array(
298
+			'eventmsg'     => sprintf(
299
+				__(
300
+					'The changes you made to this %s will be lost if you navigate away from this page.',
301
+					'event_espresso'
302
+				),
303
+				$this->_cpt_object->labels->singular_name
304
+			),
305
+			'inputChanged' => 0,
306
+		);
307
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
308
+	}
309
+
310
+
311
+	/**
312
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
313
+	 *
314
+	 * @access protected
315
+	 * @return void
316
+	 * @throws EE_Error
317
+	 * @throws ReflectionException
318
+	 */
319
+	protected function _load_page_dependencies()
320
+	{
321
+		// we only add stuff if this is a cpt_route!
322
+		if (! $this->_cpt_route) {
323
+			parent::_load_page_dependencies();
324
+			return;
325
+		}
326
+		// now let's do some automatic filters into the wp_system
327
+		// and we'll check to make sure the CHILD class
328
+		// automatically has the required methods in place.
329
+		// the following filters are for setting all the redirects
330
+		// on DEFAULT WP custom post type actions
331
+		// let's add a hidden input to the post-edit form
332
+		// so we know when we have to trigger our custom redirects!
333
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
334
+		add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
335
+		// inject our Admin page nav tabs...
336
+		// let's make sure the nav tabs are set if they aren't already
337
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
338
+		add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
339
+		// modify the post_updated messages array
340
+		add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
341
+		// add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
342
+		// cpts use the same format for shortlinks as posts!
343
+		add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
344
+		// This basically allows us to change the title of the "publish" metabox area
345
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
346
+		if (! empty($this->_labels['publishbox'])) {
347
+			$box_label = is_array($this->_labels['publishbox'])
348
+						 && isset($this->_labels['publishbox'][ $this->_req_action ])
349
+				? $this->_labels['publishbox'][ $this->_req_action ]
350
+				: $this->_labels['publishbox'];
351
+			add_meta_box(
352
+				'submitdiv',
353
+				$box_label,
354
+				'post_submit_meta_box',
355
+				$this->_cpt_routes[ $this->_req_action ],
356
+				'side',
357
+				'core'
358
+			);
359
+		}
360
+		// let's add page_templates metabox if this cpt added support for it.
361
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
362
+			add_meta_box(
363
+				'page_templates',
364
+				__('Page Template', 'event_espresso'),
365
+				array($this, 'page_template_meta_box'),
366
+				$this->_cpt_routes[ $this->_req_action ],
367
+				'side',
368
+				'default'
369
+			);
370
+		}
371
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
372
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
373
+			add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
374
+		}
375
+		// add preview button
376
+		add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
377
+		// insert our own post_stati dropdown
378
+		add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
379
+		// This allows adding additional information to the publish post submitbox on the wp post edit form
380
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
381
+			add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
382
+		}
383
+		// This allows for adding additional stuff after the title field on the wp post edit form.
384
+		// This is also before the wp_editor for post description field.
385
+		if (method_exists($this, 'edit_form_after_title')) {
386
+			add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
387
+		}
388
+		/**
389
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
390
+		 */
391
+		add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
392
+		parent::_load_page_dependencies();
393
+		// notice we are ALSO going to load the pagenow hook set for this route
394
+		// (see _before_page_setup for the reset of the pagenow global ).
395
+		// This is for any plugins that are doing things properly
396
+		// and hooking into the load page hook for core wp cpt routes.
397
+		global $pagenow;
398
+		add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
399
+		do_action('load-' . $pagenow);
400
+		add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
401
+		// we route REALLY early.
402
+		try {
403
+			$this->_route_admin_request();
404
+		} catch (EE_Error $e) {
405
+			$e->get_error();
406
+		}
407
+	}
408
+
409
+
410
+	/**
411
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
412
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
413
+	 * route instead.
414
+	 *
415
+	 * @param string $good_protocol_url The escaped url.
416
+	 * @param string $original_url      The original url.
417
+	 * @param string $_context          The context sent to the esc_url method.
418
+	 * @return string possibly a new url for our route.
419
+	 */
420
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
421
+	{
422
+		$routes_to_match = array(
423
+			0 => array(
424
+				'edit.php?post_type=espresso_attendees',
425
+				'admin.php?page=espresso_registrations&action=contact_list',
426
+			),
427
+			1 => array(
428
+				'edit.php?post_type=' . $this->_cpt_object->name,
429
+				'admin.php?page=' . $this->_cpt_object->name,
430
+			),
431
+		);
432
+		foreach ($routes_to_match as $route_matches) {
433
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
434
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
435
+			}
436
+		}
437
+		return $good_protocol_url;
438
+	}
439
+
440
+
441
+	/**
442
+	 * Determine whether the current cpt supports page templates or not.
443
+	 *
444
+	 * @since %VER%
445
+	 * @param string $cpt_name The cpt slug we're checking on.
446
+	 * @return bool True supported, false not.
447
+	 * @throws InvalidArgumentException
448
+	 * @throws InvalidDataTypeException
449
+	 * @throws InvalidInterfaceException
450
+	 */
451
+	private function _supports_page_templates($cpt_name)
452
+	{
453
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
454
+		$custom_post_types = $this->loader->getShared(
455
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
456
+		);
457
+		$cpt_args = $custom_post_types->getDefinitions();
458
+		$cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
459
+		$cpt_has_support = ! empty($cpt_args['page_templates']);
460
+
461
+		// if the installed version of WP is > 4.7 we do some additional checks.
462
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
463
+			$post_templates = wp_get_theme()->get_post_templates();
464
+			// if there are $post_templates for this cpt, then we return false for this method because
465
+			// that means we aren't going to load our page template manager and leave that up to the native
466
+			// cpt template manager.
467
+			$cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
468
+		}
469
+
470
+		return $cpt_has_support;
471
+	}
472
+
473
+
474
+	/**
475
+	 * Callback for the page_templates metabox selector.
476
+	 *
477
+	 * @since %VER%
478
+	 * @return void
479
+	 */
480
+	public function page_template_meta_box()
481
+	{
482
+		global $post;
483
+		$template = '';
484
+
485
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
486
+			$page_template_count = count(get_page_templates());
487
+		} else {
488
+			$page_template_count = count(get_page_templates($post));
489
+		}
490
+
491
+		if ($page_template_count) {
492
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
493
+			$template = ! empty($page_template) ? $page_template : '';
494
+		}
495
+		?>
496 496
         <p><strong><?php _e('Template', 'event_espresso') ?></strong></p>
497 497
         <label class="screen-reader-text" for="page_template"><?php _e('Page Template', 'event_espresso') ?></label><select
498 498
         name="page_template" id="page_template">
@@ -500,554 +500,554 @@  discard block
 block discarded – undo
500 500
         <?php page_template_dropdown($template); ?>
501 501
     </select>
502 502
         <?php
503
-    }
504
-
505
-
506
-    /**
507
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
508
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
509
-     *
510
-     * @param  string $return    the current html
511
-     * @param  int    $id        the post id for the page
512
-     * @param  string $new_title What the title is
513
-     * @param  string $new_slug  what the slug is
514
-     * @return string            The new html string for the permalink area
515
-     */
516
-    public function preview_button_html($return, $id, $new_title, $new_slug)
517
-    {
518
-        $post = get_post($id);
519
-        if ('publish' !== get_post_status($post)) {
520
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
521
-                       . get_preview_post_link($id)
522
-                       . '" class="button button-small">'
523
-                       . __('Preview', 'event_espresso')
524
-                       . '</a></span>'
525
-                       . "\n";
526
-        }
527
-        return $return;
528
-    }
529
-
530
-
531
-    /**
532
-     * add our custom post stati dropdown on the wp post page for this cpt
533
-     *
534
-     * @return void
535
-     */
536
-    public function custom_post_stati_dropdown()
537
-    {
538
-
539
-        $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
540
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
541
-            ? $statuses[ $this->_cpt_model_obj->status() ]
542
-            : '';
543
-        $template_args = array(
544
-            'cur_status'            => $this->_cpt_model_obj->status(),
545
-            'statuses'              => $statuses,
546
-            'cur_status_label'      => $cur_status_label,
547
-            'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
548
-        );
549
-        // we'll add a trash post status (WP doesn't add one for some reason)
550
-        if ($this->_cpt_model_obj->status() === 'trash') {
551
-            $template_args['cur_status_label'] = __('Trashed', 'event_espresso');
552
-            $statuses['trash'] = __('Trashed', 'event_espresso');
553
-            $template_args['statuses'] = $statuses;
554
-        }
555
-
556
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
557
-        EEH_Template::display_template($template, $template_args);
558
-    }
559
-
560
-
561
-    public function setup_autosave_hooks()
562
-    {
563
-        $this->_set_autosave_containers();
564
-        $this->_load_autosave_scripts_styles();
565
-    }
566
-
567
-
568
-    /**
569
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
570
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
571
-     * for the nonce in here, but then this method looks for two things:
572
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
573
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
574
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
575
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
576
-     * template args.
577
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
578
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
579
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
580
-     *    $this->_template_args['data']['items'] = array(
581
-     *        'event-datetime-ids' => '1,2,3';
582
-     *    );
583
-     *    Keep in mind the following things:
584
-     *    - "where" index is for the input with the id as that string.
585
-     *    - "what" index is what will be used for the value of that input.
586
-     *
587
-     * @return void
588
-     * @throws EE_Error
589
-     */
590
-    public function do_extra_autosave_stuff()
591
-    {
592
-        // next let's check for the autosave nonce (we'll use _verify_nonce )
593
-        $nonce = isset($this->_req_data['autosavenonce'])
594
-            ? $this->_req_data['autosavenonce']
595
-            : null;
596
-        $this->_verify_nonce($nonce, 'autosave');
597
-        // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
598
-        if (! defined('DOING_AUTOSAVE')) {
599
-            define('DOING_AUTOSAVE', true);
600
-        }
601
-        // if we made it here then the nonce checked out.  Let's run our methods and actions
602
-        $autosave = "_ee_autosave_{$this->_current_view}";
603
-        if (method_exists($this, $autosave)) {
604
-            $this->$autosave();
605
-        } else {
606
-            $this->_template_args['success'] = true;
607
-        }
608
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
609
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
610
-        // now let's return json
611
-        $this->_return_json();
612
-    }
613
-
614
-
615
-    /**
616
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
617
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
618
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
619
-     *
620
-     * @access protected
621
-     * @return void
622
-     * @throws ReflectionException
623
-     * @throws EE_Error
624
-     */
625
-    protected function _extend_page_config_for_cpt()
626
-    {
627
-        // before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
628
-        if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
629
-            return;
630
-        }
631
-        // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
632
-        if (! empty($this->_cpt_object)) {
633
-            $this->_page_routes = array_merge(
634
-                array(
635
-                    'create_new' => '_create_new_cpt_item',
636
-                    'edit'       => '_edit_cpt_item',
637
-                ),
638
-                $this->_page_routes
639
-            );
640
-            $this->_page_config = array_merge(
641
-                array(
642
-                    'create_new' => array(
643
-                        'nav'           => array(
644
-                            'label' => $this->_cpt_object->labels->add_new_item,
645
-                            'order' => 5,
646
-                        ),
647
-                        'require_nonce' => false,
648
-                    ),
649
-                    'edit'       => array(
650
-                        'nav'           => array(
651
-                            'label'      => $this->_cpt_object->labels->edit_item,
652
-                            'order'      => 5,
653
-                            'persistent' => false,
654
-                            'url'        => '',
655
-                        ),
656
-                        'require_nonce' => false,
657
-                    ),
658
-                ),
659
-                $this->_page_config
660
-            );
661
-        }
662
-        // load the next section only if this is a matching cpt route as set in the cpt routes array.
663
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
664
-            return;
665
-        }
666
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
667
-        // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
668
-        if (empty($this->_cpt_object)) {
669
-            $msg = sprintf(
670
-                __(
671
-                    '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).',
672
-                    'event_espresso'
673
-                ),
674
-                $this->page_slug,
675
-                $this->_req_action,
676
-                get_class($this)
677
-            );
678
-            throw new EE_Error($msg);
679
-        }
680
-        if ($this->_cpt_route) {
681
-            $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
682
-            $this->_set_model_object($id);
683
-        }
684
-    }
685
-
686
-
687
-    /**
688
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
689
-     *
690
-     * @access protected
691
-     * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
692
-     * @param bool   $ignore_route_check
693
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
694
-     * @throws EE_Error
695
-     * @throws InvalidArgumentException
696
-     * @throws InvalidDataTypeException
697
-     * @throws InvalidInterfaceException
698
-     * @throws ReflectionException
699
-     */
700
-    protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
701
-    {
702
-        $model = null;
703
-        if (empty($this->_cpt_model_names)
704
-            || (
705
-                ! $ignore_route_check
706
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
707
-            ) || (
708
-                $this->_cpt_model_obj instanceof EE_CPT_Base
709
-                && $this->_cpt_model_obj->ID() === $id
710
-            )
711
-        ) {
712
-            // 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.
713
-            return;
714
-        }
715
-        // if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
716
-        if ($ignore_route_check) {
717
-            $post_type = get_post_type($id);
718
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
719
-            $custom_post_types = $this->loader->getShared(
720
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
721
-            );
722
-            $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
723
-            if (isset($model_names[ $post_type ])) {
724
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
725
-            }
726
-        } else {
727
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
728
-        }
729
-        if ($model instanceof EEM_Base) {
730
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
731
-        }
732
-        do_action(
733
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
734
-            $this->_cpt_model_obj,
735
-            $req_type
736
-        );
737
-    }
738
-
739
-
740
-    /**
741
-     * admin_init_global
742
-     * This runs all the code that we want executed within the WP admin_init hook.
743
-     * This method executes for ALL EE Admin pages.
744
-     *
745
-     * @access public
746
-     * @return void
747
-     */
748
-    public function admin_init_global()
749
-    {
750
-        $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
751
-        // its possible this is a new save so let's catch that instead
752
-        $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
753
-        $post_type = $post ? $post->post_type : false;
754
-        $current_route = isset($this->_req_data['current_route'])
755
-            ? $this->_req_data['current_route']
756
-            : 'shouldneverwork';
757
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
758
-            ? $this->_cpt_routes[ $current_route ]
759
-            : '';
760
-        add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
761
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
762
-        if ($post_type === $route_to_check) {
763
-            add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
764
-        }
765
-        // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
766
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
767
-        if (! empty($revision)) {
768
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
769
-            // doing a restore?
770
-            if (! empty($action) && $action === 'restore') {
771
-                // get post for revision
772
-                $rev_post = get_post($revision);
773
-                $rev_parent = get_post($rev_post->post_parent);
774
-                // only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
775
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
776
-                    add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
777
-                    // restores of revisions
778
-                    add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
779
-                }
780
-            }
781
-        }
782
-        // 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!
783
-        if ($post_type && $post_type === $route_to_check) {
784
-            // $post_id, $post
785
-            add_action('save_post', array($this, 'insert_update'), 10, 3);
786
-            // $post_id
787
-            add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
788
-            add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
789
-            add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
790
-            add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
791
-        }
792
-    }
793
-
794
-
795
-    /**
796
-     * Callback for the WordPress trashed_post hook.
797
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
798
-     *
799
-     * @param int $post_id
800
-     * @throws EE_Error
801
-     * @throws ReflectionException
802
-     */
803
-    public function before_trash_cpt_item($post_id)
804
-    {
805
-        $this->_set_model_object($post_id, true, 'trash');
806
-        // if our cpt object isn't existent then get out immediately.
807
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
808
-            return;
809
-        }
810
-        $this->trash_cpt_item($post_id);
811
-    }
812
-
813
-
814
-    /**
815
-     * Callback for the WordPress untrashed_post hook.
816
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
817
-     *
818
-     * @param $post_id
819
-     * @throws EE_Error
820
-     * @throws ReflectionException
821
-     */
822
-    public function before_restore_cpt_item($post_id)
823
-    {
824
-        $this->_set_model_object($post_id, true, 'restore');
825
-        // if our cpt object isn't existent then get out immediately.
826
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
827
-            return;
828
-        }
829
-        $this->restore_cpt_item($post_id);
830
-    }
831
-
832
-
833
-    /**
834
-     * Callback for the WordPress after_delete_post hook.
835
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
836
-     *
837
-     * @param $post_id
838
-     * @throws EE_Error
839
-     * @throws ReflectionException
840
-     */
841
-    public function before_delete_cpt_item($post_id)
842
-    {
843
-        $this->_set_model_object($post_id, true, 'delete');
844
-        // if our cpt object isn't existent then get out immediately.
845
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
846
-            return;
847
-        }
848
-        $this->delete_cpt_item($post_id);
849
-    }
850
-
851
-
852
-    /**
853
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
854
-     * accordingly.
855
-     *
856
-     * @return void
857
-     * @throws EE_Error
858
-     * @throws InvalidArgumentException
859
-     * @throws InvalidDataTypeException
860
-     * @throws InvalidInterfaceException
861
-     * @throws ReflectionException
862
-     */
863
-    public function verify_cpt_object()
864
-    {
865
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
866
-        // verify event object
867
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
868
-            throw new EE_Error(
869
-                sprintf(
870
-                    __(
871
-                        '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',
872
-                        'event_espresso'
873
-                    ),
874
-                    $label
875
-                )
876
-            );
877
-        }
878
-        // if auto-draft then throw an error
879
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
880
-            EE_Error::overwrite_errors();
881
-            EE_Error::add_error(
882
-                sprintf(
883
-                    __(
884
-                        '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.',
885
-                        'event_espresso'
886
-                    ),
887
-                    $label
888
-                ),
889
-                __FILE__,
890
-                __FUNCTION__,
891
-                __LINE__
892
-            );
893
-        }
894
-        $admin_config = $this->loader->getShared('EE_Admin_Config');
895
-        if ($admin_config->useAdvancedEditor()) {
896
-            $this->loadEspressoEditorAssetManager();
897
-        } else {
898
-            $this->loadLegacyEditorAssetManager();
899
-        }
900
-    }
901
-
902
-
903
-    /**
904
-     * admin_footer_scripts_global
905
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
906
-     * will apply on ALL EE_Admin pages.
907
-     *
908
-     * @access public
909
-     * @return void
910
-     */
911
-    public function admin_footer_scripts_global()
912
-    {
913
-        $this->_add_admin_page_ajax_loading_img();
914
-        $this->_add_admin_page_overlay();
915
-    }
916
-
917
-
918
-    /**
919
-     * add in any global scripts for cpt routes
920
-     *
921
-     * @return void
922
-     * @throws EE_Error
923
-     */
924
-    public function load_global_scripts_styles()
925
-    {
926
-        parent::load_global_scripts_styles();
927
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
928
-            // setup custom post status object for localize script but only if we've got a cpt object
929
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
930
-            if (! empty($statuses)) {
931
-                // get ALL statuses!
932
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
933
-                // setup object
934
-                $ee_cpt_statuses = array();
935
-                foreach ($statuses as $status => $label) {
936
-                    $ee_cpt_statuses[ $status ] = array(
937
-                        'label'      => $label,
938
-                        'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
939
-                    );
940
-                }
941
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
942
-            }
943
-        }
944
-    }
945
-
946
-
947
-    /**
948
-     * @throws InvalidArgumentException
949
-     * @throws InvalidDataTypeException
950
-     * @throws InvalidInterfaceException
951
-     */
952
-    private function loadEspressoEditorAssetManager()
953
-    {
954
-        EE_Dependency_Map::register_dependencies(
955
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
956
-            array(
957
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
958
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
959
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
960
-            )
961
-        );
962
-        $this->asset_manager = $this->loader->getShared(
963
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
964
-        );
965
-        add_action('admin_enqueue_scripts', [$this, 'enqueueEspressoEditorAssets'], 100);
966
-    }
967
-
968
-
969
-    /**
970
-     * @throws InvalidArgumentException
971
-     * @throws InvalidDataTypeException
972
-     * @throws InvalidInterfaceException
973
-     */
974
-    private function loadLegacyEditorAssetManager()
975
-    {
976
-        EE_Dependency_Map::register_dependencies(
977
-            'EventEspresso\core\domain\services\assets\LegacyEditorAssetManager',
978
-            array(
979
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
980
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
981
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
982
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
983
-            )
984
-        );
985
-        $this->asset_manager = $this->loader->getShared(
986
-            'EventEspresso\core\domain\services\assets\LegacyEditorAssetManager'
987
-        );
988
-        add_action('admin_enqueue_scripts', [$this, 'enqueueLegacyEditorAssets'], 100);
989
-    }
990
-
991
-
992
-    /**
993
-     * enqueue_scripts - Load the scripts and css
994
-     *
995
-     * @return void
996
-     * @throws DomainException
997
-     */
998
-    public function enqueueEspressoEditorAssets()
999
-    {
1000
-        $this->asset_manager->enqueueBrowserAssets();
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * enqueue_scripts - Load the scripts and css
1006
-     *
1007
-     * @return void
1008
-     * @throws DomainException
1009
-     */
1010
-    public function enqueueLegacyEditorAssets()
1011
-    {
1012
-        $this->asset_manager->enqueueBrowserAssets();
1013
-        wp_enqueue_script('ee-accounting');
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
1019
-     * insert/updates
1020
-     *
1021
-     * @param int     $post_id ID of post being updated
1022
-     * @param WP_Post $post    Post object from WP
1023
-     * @param bool    $update  Whether this is an update or a new save.
1024
-     * @return void
1025
-     * @throws EE_Error
1026
-     * @throws ReflectionException
1027
-     */
1028
-    public function insert_update($post_id, $post, $update)
1029
-    {
1030
-        // make sure that if this is a revision OR trash action that we don't do any updates!
1031
-        if (isset($this->_req_data['action'])
1032
-            && (
1033
-                $this->_req_data['action'] === 'restore'
1034
-                || $this->_req_data['action'] === 'trash'
1035
-            )
1036
-        ) {
1037
-            return;
1038
-        }
1039
-        $this->_set_model_object($post_id, true, 'insert_update');
1040
-        // if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
1041
-        if ($update
1042
-            && (
1043
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
1044
-                || $this->_cpt_model_obj->ID() !== $post_id
1045
-            )
1046
-        ) {
1047
-            return;
1048
-        }
1049
-        // check for autosave and update our req_data property accordingly.
1050
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
503
+	}
504
+
505
+
506
+	/**
507
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
508
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
509
+	 *
510
+	 * @param  string $return    the current html
511
+	 * @param  int    $id        the post id for the page
512
+	 * @param  string $new_title What the title is
513
+	 * @param  string $new_slug  what the slug is
514
+	 * @return string            The new html string for the permalink area
515
+	 */
516
+	public function preview_button_html($return, $id, $new_title, $new_slug)
517
+	{
518
+		$post = get_post($id);
519
+		if ('publish' !== get_post_status($post)) {
520
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
521
+					   . get_preview_post_link($id)
522
+					   . '" class="button button-small">'
523
+					   . __('Preview', 'event_espresso')
524
+					   . '</a></span>'
525
+					   . "\n";
526
+		}
527
+		return $return;
528
+	}
529
+
530
+
531
+	/**
532
+	 * add our custom post stati dropdown on the wp post page for this cpt
533
+	 *
534
+	 * @return void
535
+	 */
536
+	public function custom_post_stati_dropdown()
537
+	{
538
+
539
+		$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
540
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
541
+			? $statuses[ $this->_cpt_model_obj->status() ]
542
+			: '';
543
+		$template_args = array(
544
+			'cur_status'            => $this->_cpt_model_obj->status(),
545
+			'statuses'              => $statuses,
546
+			'cur_status_label'      => $cur_status_label,
547
+			'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
548
+		);
549
+		// we'll add a trash post status (WP doesn't add one for some reason)
550
+		if ($this->_cpt_model_obj->status() === 'trash') {
551
+			$template_args['cur_status_label'] = __('Trashed', 'event_espresso');
552
+			$statuses['trash'] = __('Trashed', 'event_espresso');
553
+			$template_args['statuses'] = $statuses;
554
+		}
555
+
556
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
557
+		EEH_Template::display_template($template, $template_args);
558
+	}
559
+
560
+
561
+	public function setup_autosave_hooks()
562
+	{
563
+		$this->_set_autosave_containers();
564
+		$this->_load_autosave_scripts_styles();
565
+	}
566
+
567
+
568
+	/**
569
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
570
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
571
+	 * for the nonce in here, but then this method looks for two things:
572
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
573
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
574
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
575
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
576
+	 * template args.
577
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
578
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
579
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
580
+	 *    $this->_template_args['data']['items'] = array(
581
+	 *        'event-datetime-ids' => '1,2,3';
582
+	 *    );
583
+	 *    Keep in mind the following things:
584
+	 *    - "where" index is for the input with the id as that string.
585
+	 *    - "what" index is what will be used for the value of that input.
586
+	 *
587
+	 * @return void
588
+	 * @throws EE_Error
589
+	 */
590
+	public function do_extra_autosave_stuff()
591
+	{
592
+		// next let's check for the autosave nonce (we'll use _verify_nonce )
593
+		$nonce = isset($this->_req_data['autosavenonce'])
594
+			? $this->_req_data['autosavenonce']
595
+			: null;
596
+		$this->_verify_nonce($nonce, 'autosave');
597
+		// make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
598
+		if (! defined('DOING_AUTOSAVE')) {
599
+			define('DOING_AUTOSAVE', true);
600
+		}
601
+		// if we made it here then the nonce checked out.  Let's run our methods and actions
602
+		$autosave = "_ee_autosave_{$this->_current_view}";
603
+		if (method_exists($this, $autosave)) {
604
+			$this->$autosave();
605
+		} else {
606
+			$this->_template_args['success'] = true;
607
+		}
608
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
609
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
610
+		// now let's return json
611
+		$this->_return_json();
612
+	}
613
+
614
+
615
+	/**
616
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
617
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
618
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
619
+	 *
620
+	 * @access protected
621
+	 * @return void
622
+	 * @throws ReflectionException
623
+	 * @throws EE_Error
624
+	 */
625
+	protected function _extend_page_config_for_cpt()
626
+	{
627
+		// before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
628
+		if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
629
+			return;
630
+		}
631
+		// set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
632
+		if (! empty($this->_cpt_object)) {
633
+			$this->_page_routes = array_merge(
634
+				array(
635
+					'create_new' => '_create_new_cpt_item',
636
+					'edit'       => '_edit_cpt_item',
637
+				),
638
+				$this->_page_routes
639
+			);
640
+			$this->_page_config = array_merge(
641
+				array(
642
+					'create_new' => array(
643
+						'nav'           => array(
644
+							'label' => $this->_cpt_object->labels->add_new_item,
645
+							'order' => 5,
646
+						),
647
+						'require_nonce' => false,
648
+					),
649
+					'edit'       => array(
650
+						'nav'           => array(
651
+							'label'      => $this->_cpt_object->labels->edit_item,
652
+							'order'      => 5,
653
+							'persistent' => false,
654
+							'url'        => '',
655
+						),
656
+						'require_nonce' => false,
657
+					),
658
+				),
659
+				$this->_page_config
660
+			);
661
+		}
662
+		// load the next section only if this is a matching cpt route as set in the cpt routes array.
663
+		if (! isset($this->_cpt_routes[ $this->_req_action ])) {
664
+			return;
665
+		}
666
+		$this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
667
+		// add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
668
+		if (empty($this->_cpt_object)) {
669
+			$msg = sprintf(
670
+				__(
671
+					'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).',
672
+					'event_espresso'
673
+				),
674
+				$this->page_slug,
675
+				$this->_req_action,
676
+				get_class($this)
677
+			);
678
+			throw new EE_Error($msg);
679
+		}
680
+		if ($this->_cpt_route) {
681
+			$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
682
+			$this->_set_model_object($id);
683
+		}
684
+	}
685
+
686
+
687
+	/**
688
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
689
+	 *
690
+	 * @access protected
691
+	 * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
692
+	 * @param bool   $ignore_route_check
693
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
694
+	 * @throws EE_Error
695
+	 * @throws InvalidArgumentException
696
+	 * @throws InvalidDataTypeException
697
+	 * @throws InvalidInterfaceException
698
+	 * @throws ReflectionException
699
+	 */
700
+	protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
701
+	{
702
+		$model = null;
703
+		if (empty($this->_cpt_model_names)
704
+			|| (
705
+				! $ignore_route_check
706
+				&& ! isset($this->_cpt_routes[ $this->_req_action ])
707
+			) || (
708
+				$this->_cpt_model_obj instanceof EE_CPT_Base
709
+				&& $this->_cpt_model_obj->ID() === $id
710
+			)
711
+		) {
712
+			// 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.
713
+			return;
714
+		}
715
+		// if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
716
+		if ($ignore_route_check) {
717
+			$post_type = get_post_type($id);
718
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
719
+			$custom_post_types = $this->loader->getShared(
720
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
721
+			);
722
+			$model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
723
+			if (isset($model_names[ $post_type ])) {
724
+				$model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
725
+			}
726
+		} else {
727
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
728
+		}
729
+		if ($model instanceof EEM_Base) {
730
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
731
+		}
732
+		do_action(
733
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
734
+			$this->_cpt_model_obj,
735
+			$req_type
736
+		);
737
+	}
738
+
739
+
740
+	/**
741
+	 * admin_init_global
742
+	 * This runs all the code that we want executed within the WP admin_init hook.
743
+	 * This method executes for ALL EE Admin pages.
744
+	 *
745
+	 * @access public
746
+	 * @return void
747
+	 */
748
+	public function admin_init_global()
749
+	{
750
+		$post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
751
+		// its possible this is a new save so let's catch that instead
752
+		$post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
753
+		$post_type = $post ? $post->post_type : false;
754
+		$current_route = isset($this->_req_data['current_route'])
755
+			? $this->_req_data['current_route']
756
+			: 'shouldneverwork';
757
+		$route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
758
+			? $this->_cpt_routes[ $current_route ]
759
+			: '';
760
+		add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
761
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
762
+		if ($post_type === $route_to_check) {
763
+			add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
764
+		}
765
+		// now let's filter redirect if we're on a revision page and the revision is for an event CPT.
766
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
767
+		if (! empty($revision)) {
768
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
769
+			// doing a restore?
770
+			if (! empty($action) && $action === 'restore') {
771
+				// get post for revision
772
+				$rev_post = get_post($revision);
773
+				$rev_parent = get_post($rev_post->post_parent);
774
+				// only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
775
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
776
+					add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
777
+					// restores of revisions
778
+					add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
779
+				}
780
+			}
781
+		}
782
+		// 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!
783
+		if ($post_type && $post_type === $route_to_check) {
784
+			// $post_id, $post
785
+			add_action('save_post', array($this, 'insert_update'), 10, 3);
786
+			// $post_id
787
+			add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
788
+			add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
789
+			add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
790
+			add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
791
+		}
792
+	}
793
+
794
+
795
+	/**
796
+	 * Callback for the WordPress trashed_post hook.
797
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
798
+	 *
799
+	 * @param int $post_id
800
+	 * @throws EE_Error
801
+	 * @throws ReflectionException
802
+	 */
803
+	public function before_trash_cpt_item($post_id)
804
+	{
805
+		$this->_set_model_object($post_id, true, 'trash');
806
+		// if our cpt object isn't existent then get out immediately.
807
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
808
+			return;
809
+		}
810
+		$this->trash_cpt_item($post_id);
811
+	}
812
+
813
+
814
+	/**
815
+	 * Callback for the WordPress untrashed_post hook.
816
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
817
+	 *
818
+	 * @param $post_id
819
+	 * @throws EE_Error
820
+	 * @throws ReflectionException
821
+	 */
822
+	public function before_restore_cpt_item($post_id)
823
+	{
824
+		$this->_set_model_object($post_id, true, 'restore');
825
+		// if our cpt object isn't existent then get out immediately.
826
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
827
+			return;
828
+		}
829
+		$this->restore_cpt_item($post_id);
830
+	}
831
+
832
+
833
+	/**
834
+	 * Callback for the WordPress after_delete_post hook.
835
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
836
+	 *
837
+	 * @param $post_id
838
+	 * @throws EE_Error
839
+	 * @throws ReflectionException
840
+	 */
841
+	public function before_delete_cpt_item($post_id)
842
+	{
843
+		$this->_set_model_object($post_id, true, 'delete');
844
+		// if our cpt object isn't existent then get out immediately.
845
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
846
+			return;
847
+		}
848
+		$this->delete_cpt_item($post_id);
849
+	}
850
+
851
+
852
+	/**
853
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
854
+	 * accordingly.
855
+	 *
856
+	 * @return void
857
+	 * @throws EE_Error
858
+	 * @throws InvalidArgumentException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws InvalidInterfaceException
861
+	 * @throws ReflectionException
862
+	 */
863
+	public function verify_cpt_object()
864
+	{
865
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
866
+		// verify event object
867
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
868
+			throw new EE_Error(
869
+				sprintf(
870
+					__(
871
+						'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',
872
+						'event_espresso'
873
+					),
874
+					$label
875
+				)
876
+			);
877
+		}
878
+		// if auto-draft then throw an error
879
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
880
+			EE_Error::overwrite_errors();
881
+			EE_Error::add_error(
882
+				sprintf(
883
+					__(
884
+						'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.',
885
+						'event_espresso'
886
+					),
887
+					$label
888
+				),
889
+				__FILE__,
890
+				__FUNCTION__,
891
+				__LINE__
892
+			);
893
+		}
894
+		$admin_config = $this->loader->getShared('EE_Admin_Config');
895
+		if ($admin_config->useAdvancedEditor()) {
896
+			$this->loadEspressoEditorAssetManager();
897
+		} else {
898
+			$this->loadLegacyEditorAssetManager();
899
+		}
900
+	}
901
+
902
+
903
+	/**
904
+	 * admin_footer_scripts_global
905
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
906
+	 * will apply on ALL EE_Admin pages.
907
+	 *
908
+	 * @access public
909
+	 * @return void
910
+	 */
911
+	public function admin_footer_scripts_global()
912
+	{
913
+		$this->_add_admin_page_ajax_loading_img();
914
+		$this->_add_admin_page_overlay();
915
+	}
916
+
917
+
918
+	/**
919
+	 * add in any global scripts for cpt routes
920
+	 *
921
+	 * @return void
922
+	 * @throws EE_Error
923
+	 */
924
+	public function load_global_scripts_styles()
925
+	{
926
+		parent::load_global_scripts_styles();
927
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
928
+			// setup custom post status object for localize script but only if we've got a cpt object
929
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
930
+			if (! empty($statuses)) {
931
+				// get ALL statuses!
932
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
933
+				// setup object
934
+				$ee_cpt_statuses = array();
935
+				foreach ($statuses as $status => $label) {
936
+					$ee_cpt_statuses[ $status ] = array(
937
+						'label'      => $label,
938
+						'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
939
+					);
940
+				}
941
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
942
+			}
943
+		}
944
+	}
945
+
946
+
947
+	/**
948
+	 * @throws InvalidArgumentException
949
+	 * @throws InvalidDataTypeException
950
+	 * @throws InvalidInterfaceException
951
+	 */
952
+	private function loadEspressoEditorAssetManager()
953
+	{
954
+		EE_Dependency_Map::register_dependencies(
955
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
956
+			array(
957
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
958
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
959
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
960
+			)
961
+		);
962
+		$this->asset_manager = $this->loader->getShared(
963
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
964
+		);
965
+		add_action('admin_enqueue_scripts', [$this, 'enqueueEspressoEditorAssets'], 100);
966
+	}
967
+
968
+
969
+	/**
970
+	 * @throws InvalidArgumentException
971
+	 * @throws InvalidDataTypeException
972
+	 * @throws InvalidInterfaceException
973
+	 */
974
+	private function loadLegacyEditorAssetManager()
975
+	{
976
+		EE_Dependency_Map::register_dependencies(
977
+			'EventEspresso\core\domain\services\assets\LegacyEditorAssetManager',
978
+			array(
979
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
980
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
981
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
982
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
983
+			)
984
+		);
985
+		$this->asset_manager = $this->loader->getShared(
986
+			'EventEspresso\core\domain\services\assets\LegacyEditorAssetManager'
987
+		);
988
+		add_action('admin_enqueue_scripts', [$this, 'enqueueLegacyEditorAssets'], 100);
989
+	}
990
+
991
+
992
+	/**
993
+	 * enqueue_scripts - Load the scripts and css
994
+	 *
995
+	 * @return void
996
+	 * @throws DomainException
997
+	 */
998
+	public function enqueueEspressoEditorAssets()
999
+	{
1000
+		$this->asset_manager->enqueueBrowserAssets();
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * enqueue_scripts - Load the scripts and css
1006
+	 *
1007
+	 * @return void
1008
+	 * @throws DomainException
1009
+	 */
1010
+	public function enqueueLegacyEditorAssets()
1011
+	{
1012
+		$this->asset_manager->enqueueBrowserAssets();
1013
+		wp_enqueue_script('ee-accounting');
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
1019
+	 * insert/updates
1020
+	 *
1021
+	 * @param int     $post_id ID of post being updated
1022
+	 * @param WP_Post $post    Post object from WP
1023
+	 * @param bool    $update  Whether this is an update or a new save.
1024
+	 * @return void
1025
+	 * @throws EE_Error
1026
+	 * @throws ReflectionException
1027
+	 */
1028
+	public function insert_update($post_id, $post, $update)
1029
+	{
1030
+		// make sure that if this is a revision OR trash action that we don't do any updates!
1031
+		if (isset($this->_req_data['action'])
1032
+			&& (
1033
+				$this->_req_data['action'] === 'restore'
1034
+				|| $this->_req_data['action'] === 'trash'
1035
+			)
1036
+		) {
1037
+			return;
1038
+		}
1039
+		$this->_set_model_object($post_id, true, 'insert_update');
1040
+		// if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
1041
+		if ($update
1042
+			&& (
1043
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
1044
+				|| $this->_cpt_model_obj->ID() !== $post_id
1045
+			)
1046
+		) {
1047
+			return;
1048
+		}
1049
+		// check for autosave and update our req_data property accordingly.
1050
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
1051 1051
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
1052 1052
 
1053 1053
                 foreach ( (array) $values as $key => $value ) {
@@ -1057,537 +1057,537 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
         }/**/ // TODO reactivate after autosave is implemented in 4.2
1059 1059
 
1060
-        // take care of updating any selected page_template IF this cpt supports it.
1061
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1062
-            // wp version aware.
1063
-            if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1064
-                $page_templates = wp_get_theme()->get_page_templates();
1065
-            } else {
1066
-                $post->page_template = $this->_req_data['page_template'];
1067
-                $page_templates = wp_get_theme()->get_page_templates($post);
1068
-            }
1069
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1070
-                EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1071
-            } else {
1072
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1073
-            }
1074
-        }
1075
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1076
-            return;
1077
-        } //TODO we'll remove this after reimplementing autosave in 4.2
1078
-        $this->_insert_update_cpt_item($post_id, $post);
1079
-    }
1080
-
1081
-
1082
-    /**
1083
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1084
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1085
-     * so we don't have to check for our CPT.
1086
-     *
1087
-     * @param  int $post_id ID of the post
1088
-     * @return void
1089
-     */
1090
-    public function dont_permanently_delete_ee_cpts($post_id)
1091
-    {
1092
-        // only do this if we're actually processing one of our CPTs
1093
-        // if our cpt object isn't existent then get out immediately.
1094
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1095
-            return;
1096
-        }
1097
-        delete_post_meta($post_id, '_wp_trash_meta_status');
1098
-        delete_post_meta($post_id, '_wp_trash_meta_time');
1099
-        // our cpts may have comments so let's take care of that too
1100
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1106
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1107
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1108
-     *
1109
-     * @param  int $post_id     ID of cpt item
1110
-     * @param  int $revision_id ID of revision being restored
1111
-     * @return void
1112
-     */
1113
-    public function restore_revision($post_id, $revision_id)
1114
-    {
1115
-        $this->_restore_cpt_item($post_id, $revision_id);
1116
-        // global action
1117
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1118
-        // class specific action so you can limit hooking into a specific page.
1119
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1120
-    }
1121
-
1122
-
1123
-    /**
1124
-     * @see restore_revision() for details
1125
-     * @param  int $post_id     ID of cpt item
1126
-     * @param  int $revision_id ID of revision for item
1127
-     * @return void
1128
-     */
1129
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
1130
-
1131
-
1132
-    /**
1133
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1134
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1135
-     * To fix we have to reset the current_screen using the page_slug
1136
-     * (which is identical - or should be - to our registered_post_type id.)
1137
-     * Also, since the core WP file loads the admin_header.php for WP
1138
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1139
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1140
-     *
1141
-     * @return void
1142
-     * @throws EE_Error
1143
-     */
1144
-    public function modify_current_screen()
1145
-    {
1146
-        // ONLY do this if the current page_route IS a cpt route
1147
-        if (! $this->_cpt_route) {
1148
-            return;
1149
-        }
1150
-        // routing things REALLY early b/c this is a cpt admin page
1151
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1152
-        $this->_current_screen = get_current_screen();
1153
-        $this->_current_screen->base = 'event-espresso';
1154
-        $this->_add_help_tabs(); // we make sure we add any help tabs back in!
1155
-        /*try {
1060
+		// take care of updating any selected page_template IF this cpt supports it.
1061
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1062
+			// wp version aware.
1063
+			if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1064
+				$page_templates = wp_get_theme()->get_page_templates();
1065
+			} else {
1066
+				$post->page_template = $this->_req_data['page_template'];
1067
+				$page_templates = wp_get_theme()->get_page_templates($post);
1068
+			}
1069
+			if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1070
+				EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1071
+			} else {
1072
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1073
+			}
1074
+		}
1075
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1076
+			return;
1077
+		} //TODO we'll remove this after reimplementing autosave in 4.2
1078
+		$this->_insert_update_cpt_item($post_id, $post);
1079
+	}
1080
+
1081
+
1082
+	/**
1083
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1084
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1085
+	 * so we don't have to check for our CPT.
1086
+	 *
1087
+	 * @param  int $post_id ID of the post
1088
+	 * @return void
1089
+	 */
1090
+	public function dont_permanently_delete_ee_cpts($post_id)
1091
+	{
1092
+		// only do this if we're actually processing one of our CPTs
1093
+		// if our cpt object isn't existent then get out immediately.
1094
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1095
+			return;
1096
+		}
1097
+		delete_post_meta($post_id, '_wp_trash_meta_status');
1098
+		delete_post_meta($post_id, '_wp_trash_meta_time');
1099
+		// our cpts may have comments so let's take care of that too
1100
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1106
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1107
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1108
+	 *
1109
+	 * @param  int $post_id     ID of cpt item
1110
+	 * @param  int $revision_id ID of revision being restored
1111
+	 * @return void
1112
+	 */
1113
+	public function restore_revision($post_id, $revision_id)
1114
+	{
1115
+		$this->_restore_cpt_item($post_id, $revision_id);
1116
+		// global action
1117
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1118
+		// class specific action so you can limit hooking into a specific page.
1119
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1120
+	}
1121
+
1122
+
1123
+	/**
1124
+	 * @see restore_revision() for details
1125
+	 * @param  int $post_id     ID of cpt item
1126
+	 * @param  int $revision_id ID of revision for item
1127
+	 * @return void
1128
+	 */
1129
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
1130
+
1131
+
1132
+	/**
1133
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1134
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1135
+	 * To fix we have to reset the current_screen using the page_slug
1136
+	 * (which is identical - or should be - to our registered_post_type id.)
1137
+	 * Also, since the core WP file loads the admin_header.php for WP
1138
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1139
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1140
+	 *
1141
+	 * @return void
1142
+	 * @throws EE_Error
1143
+	 */
1144
+	public function modify_current_screen()
1145
+	{
1146
+		// ONLY do this if the current page_route IS a cpt route
1147
+		if (! $this->_cpt_route) {
1148
+			return;
1149
+		}
1150
+		// routing things REALLY early b/c this is a cpt admin page
1151
+		set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1152
+		$this->_current_screen = get_current_screen();
1153
+		$this->_current_screen->base = 'event-espresso';
1154
+		$this->_add_help_tabs(); // we make sure we add any help tabs back in!
1155
+		/*try {
1156 1156
             $this->_route_admin_request();
1157 1157
         } catch ( EE_Error $e ) {
1158 1158
             $e->get_error();
1159 1159
         }/**/
1160
-    }
1161
-
1162
-
1163
-    /**
1164
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1165
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1166
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1167
-     * default to be.
1168
-     *
1169
-     * @param string $title The new title (or existing if there is no editor_title defined)
1170
-     * @return string
1171
-     */
1172
-    public function add_custom_editor_default_title($title)
1173
-    {
1174
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1175
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1176
-            : $title;
1177
-    }
1178
-
1179
-
1180
-    /**
1181
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1182
-     *
1183
-     * @param string $shortlink   The already generated shortlink
1184
-     * @param int    $id          Post ID for this item
1185
-     * @param string $context     The context for the link
1186
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1187
-     * @return string
1188
-     */
1189
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1190
-    {
1191
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1192
-            $post = get_post($id);
1193
-            if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1194
-                $shortlink = home_url('?p=' . $post->ID);
1195
-            }
1196
-        }
1197
-        return $shortlink;
1198
-    }
1199
-
1200
-
1201
-    /**
1202
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1203
-     * already run in modify_current_screen())
1204
-     *
1205
-     * @return void
1206
-     * @throws EE_Error
1207
-     * @throws ReflectionException
1208
-     */
1209
-    public function route_admin_request()
1210
-    {
1211
-        if ($this->_cpt_route) {
1212
-            return;
1213
-        }
1214
-        try {
1215
-            $this->_route_admin_request();
1216
-        } catch (EE_Error $e) {
1217
-            $e->get_error();
1218
-        }
1219
-    }
1220
-
1221
-
1222
-    /**
1223
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1224
-     *
1225
-     * @return void
1226
-     */
1227
-    public function cpt_post_form_hidden_input()
1228
-    {
1229
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1230
-        // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1231
-        echo '<div id="ee-cpt-hidden-inputs">';
1232
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1233
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1234
-        echo '</div>';
1235
-    }
1236
-
1237
-
1238
-    /**
1239
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1240
-     *
1241
-     * @param string $location Original location url
1242
-     * @param int    $status   Status for http header
1243
-     * @return string           new (or original) url to redirect to.
1244
-     * @throws EE_Error
1245
-     */
1246
-    public function revision_redirect($location, $status)
1247
-    {
1248
-        // get revision
1249
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1250
-        // can't do anything without revision so let's get out if not present
1251
-        if (empty($rev_id)) {
1252
-            return $location;
1253
-        }
1254
-        // get rev_post_data
1255
-        $rev = get_post($rev_id);
1256
-        $admin_url = $this->_admin_base_url;
1257
-        $query_args = array(
1258
-            'action'   => 'edit',
1259
-            'post'     => $rev->post_parent,
1260
-            'revision' => $rev_id,
1261
-            'message'  => 5,
1262
-        );
1263
-        $this->_process_notices($query_args, true);
1264
-        return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $admin_url);
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1270
-     *
1271
-     * @param  string $link    the original generated link
1272
-     * @param  int    $id      post id
1273
-     * @param  string $context optional, defaults to display.  How to write the '&'
1274
-     * @return string          the link
1275
-     */
1276
-    public function modify_edit_post_link($link, $id, $context)
1277
-    {
1278
-        $post = get_post($id);
1279
-        if (! isset($this->_req_data['action'])
1280
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1281
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1282
-        ) {
1283
-            return $link;
1284
-        }
1285
-        $query_args = array(
1286
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1287
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1288
-                : 'edit',
1289
-            'post'   => $id,
1290
-        );
1291
-        return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1292
-    }
1293
-
1294
-
1295
-    /**
1296
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1297
-     * our routes.
1298
-     *
1299
-     * @param string $delete_link  original delete link
1300
-     * @param int    $post_id      id of cpt object
1301
-     * @param bool   $force_delete whether this is forcing a hard delete instead of trash
1302
-     * @return string new delete link
1303
-     * @throws EE_Error
1304
-     * @throws ReflectionException
1305
-     */
1306
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1307
-    {
1308
-        $post = get_post($post_id);
1309
-
1310
-        if (empty($this->_req_data['action'])
1311
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1312
-            || ! $post instanceof WP_Post
1313
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1314
-        ) {
1315
-            return $delete_link;
1316
-        }
1317
-        $this->_set_model_object($post->ID, true);
1318
-
1319
-        // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1320
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1321
-
1322
-        return EE_Admin_Page::add_query_args_and_nonce(
1323
-            array(
1324
-                'page'   => $this->_req_data['page'],
1325
-                'action' => $action,
1326
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1327
-                         => $post->ID,
1328
-            ),
1329
-            admin_url()
1330
-        );
1331
-    }
1332
-
1333
-
1334
-    /**
1335
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1336
-     * so that we can hijack the default redirect locations for wp custom post types
1337
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1338
-     *
1339
-     * @param string $location This is the incoming currently set redirect location
1340
-     * @param string $post_id  This is the 'ID' value of the wp_posts table
1341
-     * @return string           the new location to redirect to
1342
-     * @throws EE_Error
1343
-     */
1344
-    public function cpt_post_location_redirect($location, $post_id)
1345
-    {
1346
-        // we DO have a match so let's setup the url
1347
-        // we have to get the post to determine our route
1348
-        $post = get_post($post_id);
1349
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1350
-        // shared query_args
1351
-        $query_args = array('action' => $edit_route, 'post' => $post_id);
1352
-        $admin_url = $this->_admin_base_url;
1353
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1354
-            $status = get_post_status($post_id);
1355
-            if (isset($this->_req_data['publish'])) {
1356
-                switch ($status) {
1357
-                    case 'pending':
1358
-                        $message = 8;
1359
-                        break;
1360
-                    case 'future':
1361
-                        $message = 9;
1362
-                        break;
1363
-                    default:
1364
-                        $message = 6;
1365
-                }
1366
-            } else {
1367
-                $message = 'draft' === $status ? 10 : 1;
1368
-            }
1369
-        } elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1370
-            $message = 2;
1371
-        } elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1372
-            $message = 3;
1373
-        } elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1374
-            $message = 7;
1375
-        } else {
1376
-            $message = 4;
1377
-        }
1378
-        // change the message if the post type is not viewable on the frontend
1379
-        $this->_cpt_object = get_post_type_object($post->post_type);
1380
-        $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1381
-        $query_args = array_merge(array('message' => $message), $query_args);
1382
-        $this->_process_notices($query_args, true);
1383
-        return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $admin_url);
1384
-    }
1385
-
1386
-
1387
-    /**
1388
-     * This method is called to inject nav tabs on core WP cpt pages
1389
-     *
1390
-     * @access public
1391
-     * @return void
1392
-     * @throws EE_Error
1393
-     */
1394
-    public function inject_nav_tabs()
1395
-    {
1396
-        // can we hijack and insert the nav_tabs?
1397
-        $nav_tabs = $this->_get_main_nav_tabs();
1398
-        // first close off existing form tag
1399
-        $html = '>';
1400
-        $html .= $nav_tabs;
1401
-        // now let's handle the remaining tag ( missing ">" is CORRECT )
1402
-        $html .= '<span></span';
1403
-        echo $html;
1404
-    }
1405
-
1406
-
1407
-    /**
1408
-     * This just sets up the post update messages when an update form is loaded
1409
-     *
1410
-     * @access public
1411
-     * @param  array $messages the original messages array
1412
-     * @return array           the new messages array
1413
-     */
1414
-    public function post_update_messages($messages)
1415
-    {
1416
-        global $post;
1417
-        $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1418
-        $id = empty($id) && is_object($post) ? $post->ID : null;
1419
-        /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1160
+	}
1161
+
1162
+
1163
+	/**
1164
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1165
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1166
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1167
+	 * default to be.
1168
+	 *
1169
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1170
+	 * @return string
1171
+	 */
1172
+	public function add_custom_editor_default_title($title)
1173
+	{
1174
+		return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1175
+			? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1176
+			: $title;
1177
+	}
1178
+
1179
+
1180
+	/**
1181
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1182
+	 *
1183
+	 * @param string $shortlink   The already generated shortlink
1184
+	 * @param int    $id          Post ID for this item
1185
+	 * @param string $context     The context for the link
1186
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1187
+	 * @return string
1188
+	 */
1189
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1190
+	{
1191
+		if (! empty($id) && get_option('permalink_structure') !== '') {
1192
+			$post = get_post($id);
1193
+			if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1194
+				$shortlink = home_url('?p=' . $post->ID);
1195
+			}
1196
+		}
1197
+		return $shortlink;
1198
+	}
1199
+
1200
+
1201
+	/**
1202
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1203
+	 * already run in modify_current_screen())
1204
+	 *
1205
+	 * @return void
1206
+	 * @throws EE_Error
1207
+	 * @throws ReflectionException
1208
+	 */
1209
+	public function route_admin_request()
1210
+	{
1211
+		if ($this->_cpt_route) {
1212
+			return;
1213
+		}
1214
+		try {
1215
+			$this->_route_admin_request();
1216
+		} catch (EE_Error $e) {
1217
+			$e->get_error();
1218
+		}
1219
+	}
1220
+
1221
+
1222
+	/**
1223
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1224
+	 *
1225
+	 * @return void
1226
+	 */
1227
+	public function cpt_post_form_hidden_input()
1228
+	{
1229
+		echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1230
+		// we're also going to add the route value and the current page so we can direct autosave parsing correctly
1231
+		echo '<div id="ee-cpt-hidden-inputs">';
1232
+		echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1233
+		echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1234
+		echo '</div>';
1235
+	}
1236
+
1237
+
1238
+	/**
1239
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1240
+	 *
1241
+	 * @param string $location Original location url
1242
+	 * @param int    $status   Status for http header
1243
+	 * @return string           new (or original) url to redirect to.
1244
+	 * @throws EE_Error
1245
+	 */
1246
+	public function revision_redirect($location, $status)
1247
+	{
1248
+		// get revision
1249
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1250
+		// can't do anything without revision so let's get out if not present
1251
+		if (empty($rev_id)) {
1252
+			return $location;
1253
+		}
1254
+		// get rev_post_data
1255
+		$rev = get_post($rev_id);
1256
+		$admin_url = $this->_admin_base_url;
1257
+		$query_args = array(
1258
+			'action'   => 'edit',
1259
+			'post'     => $rev->post_parent,
1260
+			'revision' => $rev_id,
1261
+			'message'  => 5,
1262
+		);
1263
+		$this->_process_notices($query_args, true);
1264
+		return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $admin_url);
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1270
+	 *
1271
+	 * @param  string $link    the original generated link
1272
+	 * @param  int    $id      post id
1273
+	 * @param  string $context optional, defaults to display.  How to write the '&'
1274
+	 * @return string          the link
1275
+	 */
1276
+	public function modify_edit_post_link($link, $id, $context)
1277
+	{
1278
+		$post = get_post($id);
1279
+		if (! isset($this->_req_data['action'])
1280
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1281
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1282
+		) {
1283
+			return $link;
1284
+		}
1285
+		$query_args = array(
1286
+			'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1287
+				? $this->_cpt_edit_routes[ $post->post_type ]
1288
+				: 'edit',
1289
+			'post'   => $id,
1290
+		);
1291
+		return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1292
+	}
1293
+
1294
+
1295
+	/**
1296
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1297
+	 * our routes.
1298
+	 *
1299
+	 * @param string $delete_link  original delete link
1300
+	 * @param int    $post_id      id of cpt object
1301
+	 * @param bool   $force_delete whether this is forcing a hard delete instead of trash
1302
+	 * @return string new delete link
1303
+	 * @throws EE_Error
1304
+	 * @throws ReflectionException
1305
+	 */
1306
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1307
+	{
1308
+		$post = get_post($post_id);
1309
+
1310
+		if (empty($this->_req_data['action'])
1311
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1312
+			|| ! $post instanceof WP_Post
1313
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1314
+		) {
1315
+			return $delete_link;
1316
+		}
1317
+		$this->_set_model_object($post->ID, true);
1318
+
1319
+		// returns something like `trash_event` or `trash_attendee` or `trash_venue`
1320
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1321
+
1322
+		return EE_Admin_Page::add_query_args_and_nonce(
1323
+			array(
1324
+				'page'   => $this->_req_data['page'],
1325
+				'action' => $action,
1326
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1327
+						 => $post->ID,
1328
+			),
1329
+			admin_url()
1330
+		);
1331
+	}
1332
+
1333
+
1334
+	/**
1335
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1336
+	 * so that we can hijack the default redirect locations for wp custom post types
1337
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1338
+	 *
1339
+	 * @param string $location This is the incoming currently set redirect location
1340
+	 * @param string $post_id  This is the 'ID' value of the wp_posts table
1341
+	 * @return string           the new location to redirect to
1342
+	 * @throws EE_Error
1343
+	 */
1344
+	public function cpt_post_location_redirect($location, $post_id)
1345
+	{
1346
+		// we DO have a match so let's setup the url
1347
+		// we have to get the post to determine our route
1348
+		$post = get_post($post_id);
1349
+		$edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1350
+		// shared query_args
1351
+		$query_args = array('action' => $edit_route, 'post' => $post_id);
1352
+		$admin_url = $this->_admin_base_url;
1353
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1354
+			$status = get_post_status($post_id);
1355
+			if (isset($this->_req_data['publish'])) {
1356
+				switch ($status) {
1357
+					case 'pending':
1358
+						$message = 8;
1359
+						break;
1360
+					case 'future':
1361
+						$message = 9;
1362
+						break;
1363
+					default:
1364
+						$message = 6;
1365
+				}
1366
+			} else {
1367
+				$message = 'draft' === $status ? 10 : 1;
1368
+			}
1369
+		} elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1370
+			$message = 2;
1371
+		} elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1372
+			$message = 3;
1373
+		} elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1374
+			$message = 7;
1375
+		} else {
1376
+			$message = 4;
1377
+		}
1378
+		// change the message if the post type is not viewable on the frontend
1379
+		$this->_cpt_object = get_post_type_object($post->post_type);
1380
+		$message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1381
+		$query_args = array_merge(array('message' => $message), $query_args);
1382
+		$this->_process_notices($query_args, true);
1383
+		return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $admin_url);
1384
+	}
1385
+
1386
+
1387
+	/**
1388
+	 * This method is called to inject nav tabs on core WP cpt pages
1389
+	 *
1390
+	 * @access public
1391
+	 * @return void
1392
+	 * @throws EE_Error
1393
+	 */
1394
+	public function inject_nav_tabs()
1395
+	{
1396
+		// can we hijack and insert the nav_tabs?
1397
+		$nav_tabs = $this->_get_main_nav_tabs();
1398
+		// first close off existing form tag
1399
+		$html = '>';
1400
+		$html .= $nav_tabs;
1401
+		// now let's handle the remaining tag ( missing ">" is CORRECT )
1402
+		$html .= '<span></span';
1403
+		echo $html;
1404
+	}
1405
+
1406
+
1407
+	/**
1408
+	 * This just sets up the post update messages when an update form is loaded
1409
+	 *
1410
+	 * @access public
1411
+	 * @param  array $messages the original messages array
1412
+	 * @return array           the new messages array
1413
+	 */
1414
+	public function post_update_messages($messages)
1415
+	{
1416
+		global $post;
1417
+		$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1418
+		$id = empty($id) && is_object($post) ? $post->ID : null;
1419
+		/*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1420 1420
 
1421 1421
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1422
-        $messages[ $post->post_type ] = array(
1423
-            0  => '', // Unused. Messages start at index 1.
1424
-            1  => sprintf(
1425
-                __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1426
-                $this->_cpt_object->labels->singular_name,
1427
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1428
-                '</a>'
1429
-            ),
1430
-            2  => __('Custom field updated', 'event_espresso'),
1431
-            3  => __('Custom field deleted.', 'event_espresso'),
1432
-            4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1433
-            5  => isset($_GET['revision']) ? sprintf(
1434
-                __('%s restored to revision from %s', 'event_espresso'),
1435
-                $this->_cpt_object->labels->singular_name,
1436
-                wp_post_revision_title((int) $_GET['revision'], false)
1437
-            )
1438
-                : false,
1439
-            6  => sprintf(
1440
-                __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1441
-                $this->_cpt_object->labels->singular_name,
1442
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1443
-                '</a>'
1444
-            ),
1445
-            7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1446
-            8  => sprintf(
1447
-                __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1448
-                $this->_cpt_object->labels->singular_name,
1449
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1450
-                '</a>'
1451
-            ),
1452
-            9  => sprintf(
1453
-                __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1454
-                $this->_cpt_object->labels->singular_name,
1455
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1456
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1457
-                '</a>'
1458
-            ),
1459
-            10 => sprintf(
1460
-                __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1461
-                $this->_cpt_object->labels->singular_name,
1462
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1463
-                '</a>'
1464
-            ),
1465
-        );
1466
-        return $messages;
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * default method for the 'create_new' route for cpt admin pages.
1472
-     * For reference what to include in here, see wp-admin/post-new.php
1473
-     *
1474
-     * @access  protected
1475
-     * @return void
1476
-     */
1477
-    protected function _create_new_cpt_item()
1478
-    {
1479
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1480
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1481
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1482
-        $post_type_object = $this->_cpt_object;
1483
-        $title = $post_type_object->labels->add_new_item;
1484
-        $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1485
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1486
-        // modify the default editor title field with default title.
1487
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1488
-        $this->loadEditorTemplate(true);
1489
-    }
1490
-
1491
-
1492
-    /**
1493
-     * Enqueues auto-save and loads the editor template
1494
-     *
1495
-     * @param bool $creating
1496
-     */
1497
-    private function loadEditorTemplate($creating = true)
1498
-    {
1499
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1500
-        // these vars are used by the template
1501
-        $editing = true;
1502
-        $post_ID = $post->ID;
1503
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1504
-            // only enqueue autosave when creating event (necessary to get permalink/url generated)
1505
-            // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1506
-            if ($creating) {
1507
-                wp_enqueue_script('autosave');
1508
-            } elseif (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1509
-                && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1510
-            ) {
1511
-                $create_new_action = apply_filters(
1512
-                    'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1513
-                    'create_new',
1514
-                    $this
1515
-                );
1516
-                $post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1517
-                    array(
1518
-                        'action' => $create_new_action,
1519
-                        'page'   => $this->page_slug,
1520
-                    ),
1521
-                    'admin.php'
1522
-                );
1523
-            }
1524
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1525
-        }
1526
-    }
1527
-
1528
-
1529
-    public function add_new_admin_page_global()
1530
-    {
1531
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1532
-        ?>
1422
+		$messages[ $post->post_type ] = array(
1423
+			0  => '', // Unused. Messages start at index 1.
1424
+			1  => sprintf(
1425
+				__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1426
+				$this->_cpt_object->labels->singular_name,
1427
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1428
+				'</a>'
1429
+			),
1430
+			2  => __('Custom field updated', 'event_espresso'),
1431
+			3  => __('Custom field deleted.', 'event_espresso'),
1432
+			4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1433
+			5  => isset($_GET['revision']) ? sprintf(
1434
+				__('%s restored to revision from %s', 'event_espresso'),
1435
+				$this->_cpt_object->labels->singular_name,
1436
+				wp_post_revision_title((int) $_GET['revision'], false)
1437
+			)
1438
+				: false,
1439
+			6  => sprintf(
1440
+				__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1441
+				$this->_cpt_object->labels->singular_name,
1442
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1443
+				'</a>'
1444
+			),
1445
+			7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1446
+			8  => sprintf(
1447
+				__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1448
+				$this->_cpt_object->labels->singular_name,
1449
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1450
+				'</a>'
1451
+			),
1452
+			9  => sprintf(
1453
+				__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1454
+				$this->_cpt_object->labels->singular_name,
1455
+				'<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1456
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1457
+				'</a>'
1458
+			),
1459
+			10 => sprintf(
1460
+				__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1461
+				$this->_cpt_object->labels->singular_name,
1462
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1463
+				'</a>'
1464
+			),
1465
+		);
1466
+		return $messages;
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * default method for the 'create_new' route for cpt admin pages.
1472
+	 * For reference what to include in here, see wp-admin/post-new.php
1473
+	 *
1474
+	 * @access  protected
1475
+	 * @return void
1476
+	 */
1477
+	protected function _create_new_cpt_item()
1478
+	{
1479
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1480
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1481
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1482
+		$post_type_object = $this->_cpt_object;
1483
+		$title = $post_type_object->labels->add_new_item;
1484
+		$post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1485
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1486
+		// modify the default editor title field with default title.
1487
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1488
+		$this->loadEditorTemplate(true);
1489
+	}
1490
+
1491
+
1492
+	/**
1493
+	 * Enqueues auto-save and loads the editor template
1494
+	 *
1495
+	 * @param bool $creating
1496
+	 */
1497
+	private function loadEditorTemplate($creating = true)
1498
+	{
1499
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1500
+		// these vars are used by the template
1501
+		$editing = true;
1502
+		$post_ID = $post->ID;
1503
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1504
+			// only enqueue autosave when creating event (necessary to get permalink/url generated)
1505
+			// otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1506
+			if ($creating) {
1507
+				wp_enqueue_script('autosave');
1508
+			} elseif (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1509
+				&& ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1510
+			) {
1511
+				$create_new_action = apply_filters(
1512
+					'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1513
+					'create_new',
1514
+					$this
1515
+				);
1516
+				$post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1517
+					array(
1518
+						'action' => $create_new_action,
1519
+						'page'   => $this->page_slug,
1520
+					),
1521
+					'admin.php'
1522
+				);
1523
+			}
1524
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1525
+		}
1526
+	}
1527
+
1528
+
1529
+	public function add_new_admin_page_global()
1530
+	{
1531
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1532
+		?>
1533 1533
         <script type="text/javascript">
1534 1534
             adminpage = '<?php echo $admin_page; ?>';
1535 1535
         </script>
1536 1536
         <?php
1537
-    }
1538
-
1539
-
1540
-    /**
1541
-     * default method for the 'edit' route for cpt admin pages
1542
-     * For reference on what to put in here, refer to wp-admin/post.php
1543
-     *
1544
-     * @access protected
1545
-     * @return string   template for edit cpt form
1546
-     */
1547
-    protected function _edit_cpt_item()
1548
-    {
1549
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1550
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1551
-        $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1552
-        if (empty($post)) {
1553
-            wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1554
-        }
1555
-        if (! empty($_GET['get-post-lock'])) {
1556
-            wp_set_post_lock($post_id);
1557
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1558
-            exit();
1559
-        }
1560
-
1561
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1562
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1563
-        $post_type_object = $this->_cpt_object;
1564
-
1565
-        if (! wp_check_post_lock($post->ID)) {
1566
-            wp_set_post_lock($post->ID);
1567
-        }
1568
-        add_action('admin_footer', '_admin_notice_post_locked');
1569
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1570
-            wp_enqueue_script('admin-comments');
1571
-            enqueue_comment_hotkeys_js();
1572
-        }
1573
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1574
-        // modify the default editor title field with default title.
1575
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1576
-        $this->loadEditorTemplate(false);
1577
-    }
1578
-
1579
-
1580
-
1581
-    /**
1582
-     * some getters
1583
-     */
1584
-    /**
1585
-     * This returns the protected _cpt_model_obj property
1586
-     *
1587
-     * @return EE_CPT_Base
1588
-     */
1589
-    public function get_cpt_model_obj()
1590
-    {
1591
-        return $this->_cpt_model_obj;
1592
-    }
1537
+	}
1538
+
1539
+
1540
+	/**
1541
+	 * default method for the 'edit' route for cpt admin pages
1542
+	 * For reference on what to put in here, refer to wp-admin/post.php
1543
+	 *
1544
+	 * @access protected
1545
+	 * @return string   template for edit cpt form
1546
+	 */
1547
+	protected function _edit_cpt_item()
1548
+	{
1549
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1550
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1551
+		$post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1552
+		if (empty($post)) {
1553
+			wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1554
+		}
1555
+		if (! empty($_GET['get-post-lock'])) {
1556
+			wp_set_post_lock($post_id);
1557
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1558
+			exit();
1559
+		}
1560
+
1561
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1562
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1563
+		$post_type_object = $this->_cpt_object;
1564
+
1565
+		if (! wp_check_post_lock($post->ID)) {
1566
+			wp_set_post_lock($post->ID);
1567
+		}
1568
+		add_action('admin_footer', '_admin_notice_post_locked');
1569
+		if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1570
+			wp_enqueue_script('admin-comments');
1571
+			enqueue_comment_hotkeys_js();
1572
+		}
1573
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1574
+		// modify the default editor title field with default title.
1575
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1576
+		$this->loadEditorTemplate(false);
1577
+	}
1578
+
1579
+
1580
+
1581
+	/**
1582
+	 * some getters
1583
+	 */
1584
+	/**
1585
+	 * This returns the protected _cpt_model_obj property
1586
+	 *
1587
+	 * @return EE_CPT_Base
1588
+	 */
1589
+	public function get_cpt_model_obj()
1590
+	{
1591
+		return $this->_cpt_model_obj;
1592
+	}
1593 1593
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
             $this->_cpt_routes
176 176
         );
177 177
         // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
178
-        $this->_cpt_object = isset($this->_req_data['action'], $this->_cpt_routes[ $this->_req_data['action'] ])
179
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
178
+        $this->_cpt_object = isset($this->_req_data['action'], $this->_cpt_routes[$this->_req_data['action']])
179
+            ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
180 180
             : get_post_type_object($page);
181 181
         // tweak pagenow for page loading.
182
-        if (! $this->_pagenow_map) {
182
+        if ( ! $this->_pagenow_map) {
183 183
             $this->_pagenow_map = array(
184 184
                 'create_new' => 'post-new.php',
185 185
                 'edit'       => 'post.php',
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
     {
214 214
         global $pagenow, $hook_suffix;
215 215
         // possibly reset pagenow.
216
-        if (! empty($this->_req_data['page'])
216
+        if ( ! empty($this->_req_data['page'])
217 217
             && $this->_req_data['page'] === $this->page_slug
218 218
             && ! empty($this->_req_data['action'])
219
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
219
+            && isset($this->_pagenow_map[$this->_req_data['action']])
220 220
         ) {
221
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
221
+            $pagenow = $this->_pagenow_map[$this->_req_data['action']];
222 222
             $hook_suffix = $pagenow;
223 223
         }
224 224
     }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         if (empty($wp_meta_boxes)) {
251 251
             return;
252 252
         }
253
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
253
+        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
254 254
         foreach ($current_metaboxes as $box_context) {
255 255
             foreach ($box_context as $box_details) {
256 256
                 foreach ($box_details as $box) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             $this
284 284
         );
285 285
         $containers = apply_filters(
286
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
286
+            'FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
287 287
             $containers,
288 288
             $this
289 289
         );
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     protected function _load_page_dependencies()
320 320
     {
321 321
         // we only add stuff if this is a cpt_route!
322
-        if (! $this->_cpt_route) {
322
+        if ( ! $this->_cpt_route) {
323 323
             parent::_load_page_dependencies();
324 324
             return;
325 325
         }
@@ -343,16 +343,16 @@  discard block
 block discarded – undo
343 343
         add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
344 344
         // This basically allows us to change the title of the "publish" metabox area
345 345
         // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
346
-        if (! empty($this->_labels['publishbox'])) {
346
+        if ( ! empty($this->_labels['publishbox'])) {
347 347
             $box_label = is_array($this->_labels['publishbox'])
348
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
349
-                ? $this->_labels['publishbox'][ $this->_req_action ]
348
+                         && isset($this->_labels['publishbox'][$this->_req_action])
349
+                ? $this->_labels['publishbox'][$this->_req_action]
350 350
                 : $this->_labels['publishbox'];
351 351
             add_meta_box(
352 352
                 'submitdiv',
353 353
                 $box_label,
354 354
                 'post_submit_meta_box',
355
-                $this->_cpt_routes[ $this->_req_action ],
355
+                $this->_cpt_routes[$this->_req_action],
356 356
                 'side',
357 357
                 'core'
358 358
             );
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                 'page_templates',
364 364
                 __('Page Template', 'event_espresso'),
365 365
                 array($this, 'page_template_meta_box'),
366
-                $this->_cpt_routes[ $this->_req_action ],
366
+                $this->_cpt_routes[$this->_req_action],
367 367
                 'side',
368 368
                 'default'
369 369
             );
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
         // This is for any plugins that are doing things properly
396 396
         // and hooking into the load page hook for core wp cpt routes.
397 397
         global $pagenow;
398
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
399
-        do_action('load-' . $pagenow);
398
+        add_action('load-'.$pagenow, array($this, 'modify_current_screen'), 20);
399
+        do_action('load-'.$pagenow);
400 400
         add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
401 401
         // we route REALLY early.
402 402
         try {
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
                 'admin.php?page=espresso_registrations&action=contact_list',
426 426
             ),
427 427
             1 => array(
428
-                'edit.php?post_type=' . $this->_cpt_object->name,
429
-                'admin.php?page=' . $this->_cpt_object->name,
428
+                'edit.php?post_type='.$this->_cpt_object->name,
429
+                'admin.php?page='.$this->_cpt_object->name,
430 430
             ),
431 431
         );
432 432
         foreach ($routes_to_match as $route_matches) {
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
456 456
         );
457 457
         $cpt_args = $custom_post_types->getDefinitions();
458
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
458
+        $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
459 459
         $cpt_has_support = ! empty($cpt_args['page_templates']);
460 460
 
461 461
         // if the installed version of WP is > 4.7 we do some additional checks.
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
             // if there are $post_templates for this cpt, then we return false for this method because
465 465
             // that means we aren't going to load our page template manager and leave that up to the native
466 466
             // cpt template manager.
467
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
467
+            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
468 468
         }
469 469
 
470 470
         return $cpt_has_support;
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
         $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
540 540
         $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
541
-            ? $statuses[ $this->_cpt_model_obj->status() ]
541
+            ? $statuses[$this->_cpt_model_obj->status()]
542 542
             : '';
543 543
         $template_args = array(
544 544
             'cur_status'            => $this->_cpt_model_obj->status(),
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
             $template_args['statuses'] = $statuses;
554 554
         }
555 555
 
556
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
556
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
557 557
         EEH_Template::display_template($template, $template_args);
558 558
     }
559 559
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
             : null;
596 596
         $this->_verify_nonce($nonce, 'autosave');
597 597
         // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
598
-        if (! defined('DOING_AUTOSAVE')) {
598
+        if ( ! defined('DOING_AUTOSAVE')) {
599 599
             define('DOING_AUTOSAVE', true);
600 600
         }
601 601
         // if we made it here then the nonce checked out.  Let's run our methods and actions
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
             $this->_template_args['success'] = true;
607 607
         }
608 608
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
609
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
609
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
610 610
         // now let's return json
611 611
         $this->_return_json();
612 612
     }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
             return;
630 630
         }
631 631
         // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
632
-        if (! empty($this->_cpt_object)) {
632
+        if ( ! empty($this->_cpt_object)) {
633 633
             $this->_page_routes = array_merge(
634 634
                 array(
635 635
                     'create_new' => '_create_new_cpt_item',
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
             );
661 661
         }
662 662
         // load the next section only if this is a matching cpt route as set in the cpt routes array.
663
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
663
+        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
664 664
             return;
665 665
         }
666
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
666
+        $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
667 667
         // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
668 668
         if (empty($this->_cpt_object)) {
669 669
             $msg = sprintf(
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
         if (empty($this->_cpt_model_names)
704 704
             || (
705 705
                 ! $ignore_route_check
706
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
706
+                && ! isset($this->_cpt_routes[$this->_req_action])
707 707
             ) || (
708 708
                 $this->_cpt_model_obj instanceof EE_CPT_Base
709 709
                 && $this->_cpt_model_obj->ID() === $id
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
                 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
721 721
             );
722 722
             $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
723
-            if (isset($model_names[ $post_type ])) {
724
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
723
+            if (isset($model_names[$post_type])) {
724
+                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
725 725
             }
726 726
         } else {
727
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
727
+            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
728 728
         }
729 729
         if ($model instanceof EEM_Base) {
730 730
             $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
         $current_route = isset($this->_req_data['current_route'])
755 755
             ? $this->_req_data['current_route']
756 756
             : 'shouldneverwork';
757
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
758
-            ? $this->_cpt_routes[ $current_route ]
757
+        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
758
+            ? $this->_cpt_routes[$current_route]
759 759
             : '';
760 760
         add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
761 761
         add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
         }
765 765
         // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
766 766
         $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
767
-        if (! empty($revision)) {
767
+        if ( ! empty($revision)) {
768 768
             $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
769 769
             // doing a restore?
770
-            if (! empty($action) && $action === 'restore') {
770
+            if ( ! empty($action) && $action === 'restore') {
771 771
                 // get post for revision
772 772
                 $rev_post = get_post($revision);
773 773
                 $rev_parent = get_post($rev_post->post_parent);
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
     {
805 805
         $this->_set_model_object($post_id, true, 'trash');
806 806
         // if our cpt object isn't existent then get out immediately.
807
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
807
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
808 808
             return;
809 809
         }
810 810
         $this->trash_cpt_item($post_id);
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
     {
824 824
         $this->_set_model_object($post_id, true, 'restore');
825 825
         // if our cpt object isn't existent then get out immediately.
826
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
827 827
             return;
828 828
         }
829 829
         $this->restore_cpt_item($post_id);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
     {
843 843
         $this->_set_model_object($post_id, true, 'delete');
844 844
         // if our cpt object isn't existent then get out immediately.
845
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
845
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
846 846
             return;
847 847
         }
848 848
         $this->delete_cpt_item($post_id);
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
     {
865 865
         $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
866 866
         // verify event object
867
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
867
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
868 868
             throw new EE_Error(
869 869
                 sprintf(
870 870
                     __(
@@ -927,13 +927,13 @@  discard block
 block discarded – undo
927 927
         if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
928 928
             // setup custom post status object for localize script but only if we've got a cpt object
929 929
             $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
930
-            if (! empty($statuses)) {
930
+            if ( ! empty($statuses)) {
931 931
                 // get ALL statuses!
932 932
                 $statuses = $this->_cpt_model_obj->get_all_post_statuses();
933 933
                 // setup object
934 934
                 $ee_cpt_statuses = array();
935 935
                 foreach ($statuses as $status => $label) {
936
-                    $ee_cpt_statuses[ $status ] = array(
936
+                    $ee_cpt_statuses[$status] = array(
937 937
                         'label'      => $label,
938 938
                         'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
939 939
                     );
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
                 $post->page_template = $this->_req_data['page_template'];
1067 1067
                 $page_templates = wp_get_theme()->get_page_templates($post);
1068 1068
             }
1069
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1069
+            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
1070 1070
                 EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1071 1071
             } else {
1072 1072
                 update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
     {
1092 1092
         // only do this if we're actually processing one of our CPTs
1093 1093
         // if our cpt object isn't existent then get out immediately.
1094
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1094
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1095 1095
             return;
1096 1096
         }
1097 1097
         delete_post_meta($post_id, '_wp_trash_meta_status');
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
         // global action
1117 1117
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1118 1118
         // class specific action so you can limit hooking into a specific page.
1119
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1119
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
1120 1120
     }
1121 1121
 
1122 1122
 
@@ -1144,11 +1144,11 @@  discard block
 block discarded – undo
1144 1144
     public function modify_current_screen()
1145 1145
     {
1146 1146
         // ONLY do this if the current page_route IS a cpt route
1147
-        if (! $this->_cpt_route) {
1147
+        if ( ! $this->_cpt_route) {
1148 1148
             return;
1149 1149
         }
1150 1150
         // routing things REALLY early b/c this is a cpt admin page
1151
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1151
+        set_current_screen($this->_cpt_routes[$this->_req_action]);
1152 1152
         $this->_current_screen = get_current_screen();
1153 1153
         $this->_current_screen->base = 'event-espresso';
1154 1154
         $this->_add_help_tabs(); // we make sure we add any help tabs back in!
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
      */
1172 1172
     public function add_custom_editor_default_title($title)
1173 1173
     {
1174
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1175
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1174
+        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1175
+            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1176 1176
             : $title;
1177 1177
     }
1178 1178
 
@@ -1188,10 +1188,10 @@  discard block
 block discarded – undo
1188 1188
      */
1189 1189
     public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1190 1190
     {
1191
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1191
+        if ( ! empty($id) && get_option('permalink_structure') !== '') {
1192 1192
             $post = get_post($id);
1193 1193
             if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1194
-                $shortlink = home_url('?p=' . $post->ID);
1194
+                $shortlink = home_url('?p='.$post->ID);
1195 1195
             }
1196 1196
         }
1197 1197
         return $shortlink;
@@ -1226,11 +1226,11 @@  discard block
 block discarded – undo
1226 1226
      */
1227 1227
     public function cpt_post_form_hidden_input()
1228 1228
     {
1229
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1229
+        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />';
1230 1230
         // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1231 1231
         echo '<div id="ee-cpt-hidden-inputs">';
1232
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1233
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1232
+        echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />';
1233
+        echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />';
1234 1234
         echo '</div>';
1235 1235
     }
1236 1236
 
@@ -1276,15 +1276,15 @@  discard block
 block discarded – undo
1276 1276
     public function modify_edit_post_link($link, $id, $context)
1277 1277
     {
1278 1278
         $post = get_post($id);
1279
-        if (! isset($this->_req_data['action'])
1280
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1281
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1279
+        if ( ! isset($this->_req_data['action'])
1280
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1281
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1282 1282
         ) {
1283 1283
             return $link;
1284 1284
         }
1285 1285
         $query_args = array(
1286
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1287
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1286
+            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1287
+                ? $this->_cpt_edit_routes[$post->post_type]
1288 1288
                 : 'edit',
1289 1289
             'post'   => $id,
1290 1290
         );
@@ -1308,16 +1308,16 @@  discard block
 block discarded – undo
1308 1308
         $post = get_post($post_id);
1309 1309
 
1310 1310
         if (empty($this->_req_data['action'])
1311
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1311
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1312 1312
             || ! $post instanceof WP_Post
1313
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1313
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1314 1314
         ) {
1315 1315
             return $delete_link;
1316 1316
         }
1317 1317
         $this->_set_model_object($post->ID, true);
1318 1318
 
1319 1319
         // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1320
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1320
+        $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1321 1321
 
1322 1322
         return EE_Admin_Page::add_query_args_and_nonce(
1323 1323
             array(
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
         // we DO have a match so let's setup the url
1347 1347
         // we have to get the post to determine our route
1348 1348
         $post = get_post($post_id);
1349
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1349
+        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1350 1350
         // shared query_args
1351 1351
         $query_args = array('action' => $edit_route, 'post' => $post_id);
1352 1352
         $admin_url = $this->_admin_base_url;
@@ -1419,12 +1419,12 @@  discard block
 block discarded – undo
1419 1419
         /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1420 1420
 
1421 1421
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1422
-        $messages[ $post->post_type ] = array(
1422
+        $messages[$post->post_type] = array(
1423 1423
             0  => '', // Unused. Messages start at index 1.
1424 1424
             1  => sprintf(
1425 1425
                 __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1426 1426
                 $this->_cpt_object->labels->singular_name,
1427
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1427
+                '<a href="'.esc_url(get_permalink($id)).'">',
1428 1428
                 '</a>'
1429 1429
             ),
1430 1430
             2  => __('Custom field updated', 'event_espresso'),
@@ -1439,27 +1439,27 @@  discard block
 block discarded – undo
1439 1439
             6  => sprintf(
1440 1440
                 __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1441 1441
                 $this->_cpt_object->labels->singular_name,
1442
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1442
+                '<a href="'.esc_url(get_permalink($id)).'">',
1443 1443
                 '</a>'
1444 1444
             ),
1445 1445
             7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1446 1446
             8  => sprintf(
1447 1447
                 __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1448 1448
                 $this->_cpt_object->labels->singular_name,
1449
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1449
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1450 1450
                 '</a>'
1451 1451
             ),
1452 1452
             9  => sprintf(
1453 1453
                 __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1454 1454
                 $this->_cpt_object->labels->singular_name,
1455
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1456
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1455
+                '<strong>'.date_i18n('M j, Y @ G:i', strtotime($post->post_date)).'</strong>',
1456
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1457 1457
                 '</a>'
1458 1458
             ),
1459 1459
             10 => sprintf(
1460 1460
                 __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1461 1461
                 $this->_cpt_object->labels->singular_name,
1462
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1462
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1463 1463
                 '</a>'
1464 1464
             ),
1465 1465
         );
@@ -1478,10 +1478,10 @@  discard block
 block discarded – undo
1478 1478
     {
1479 1479
         // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1480 1480
         global $post, $title, $is_IE, $post_type, $post_type_object;
1481
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1481
+        $post_type = $this->_cpt_routes[$this->_req_action];
1482 1482
         $post_type_object = $this->_cpt_object;
1483 1483
         $title = $post_type_object->labels->add_new_item;
1484
-        $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1484
+        $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1485 1485
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1486 1486
         // modify the default editor title field with default title.
1487 1487
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
@@ -1505,8 +1505,8 @@  discard block
 block discarded – undo
1505 1505
             // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1506 1506
             if ($creating) {
1507 1507
                 wp_enqueue_script('autosave');
1508
-            } elseif (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1509
-                && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1508
+            } elseif (isset($this->_cpt_routes[$this->_req_data['action']])
1509
+                && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1510 1510
             ) {
1511 1511
                 $create_new_action = apply_filters(
1512 1512
                     'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
@@ -1521,7 +1521,7 @@  discard block
 block discarded – undo
1521 1521
                     'admin.php'
1522 1522
                 );
1523 1523
             }
1524
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1524
+            include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1525 1525
         }
1526 1526
     }
1527 1527
 
@@ -1552,21 +1552,21 @@  discard block
 block discarded – undo
1552 1552
         if (empty($post)) {
1553 1553
             wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1554 1554
         }
1555
-        if (! empty($_GET['get-post-lock'])) {
1555
+        if ( ! empty($_GET['get-post-lock'])) {
1556 1556
             wp_set_post_lock($post_id);
1557 1557
             wp_redirect(get_edit_post_link($post_id, 'url'));
1558 1558
             exit();
1559 1559
         }
1560 1560
 
1561 1561
         // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1562
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1562
+        $post_type = $this->_cpt_routes[$this->_req_action];
1563 1563
         $post_type_object = $this->_cpt_object;
1564 1564
 
1565
-        if (! wp_check_post_lock($post->ID)) {
1565
+        if ( ! wp_check_post_lock($post->ID)) {
1566 1566
             wp_set_post_lock($post->ID);
1567 1567
         }
1568 1568
         add_action('admin_footer', '_admin_notice_post_locked');
1569
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1569
+        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1570 1570
             wp_enqueue_script('admin-comments');
1571 1571
             enqueue_comment_hotkeys_js();
1572 1572
         }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4126 added lines, -4126 removed lines patch added patch discarded remove patch
@@ -17,4194 +17,4194 @@
 block discarded – undo
17 17
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    protected $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	protected $loader;
24 24
 
25
-    // set in _init_page_props()
26
-    public $page_slug;
25
+	// set in _init_page_props()
26
+	public $page_slug;
27 27
 
28
-    public $page_label;
28
+	public $page_label;
29 29
 
30
-    public $page_folder;
30
+	public $page_folder;
31 31
 
32
-    // set in define_page_props()
33
-    protected $_admin_base_url;
32
+	// set in define_page_props()
33
+	protected $_admin_base_url;
34 34
 
35
-    protected $_admin_base_path;
35
+	protected $_admin_base_path;
36 36
 
37
-    protected $_admin_page_title;
37
+	protected $_admin_page_title;
38 38
 
39
-    protected $_labels;
39
+	protected $_labels;
40 40
 
41 41
 
42
-    // set early within EE_Admin_Init
43
-    protected $_wp_page_slug;
42
+	// set early within EE_Admin_Init
43
+	protected $_wp_page_slug;
44 44
 
45
-    // nav tabs
46
-    protected $_nav_tabs;
45
+	// nav tabs
46
+	protected $_nav_tabs;
47 47
 
48
-    protected $_default_nav_tab_name;
48
+	protected $_default_nav_tab_name;
49 49
 
50
-    /**
51
-     * @var array $_help_tour
52
-     */
53
-    protected $_help_tour = array();
50
+	/**
51
+	 * @var array $_help_tour
52
+	 */
53
+	protected $_help_tour = array();
54 54
 
55 55
 
56
-    // template variables (used by templates)
57
-    protected $_template_path;
56
+	// template variables (used by templates)
57
+	protected $_template_path;
58 58
 
59
-    protected $_column_template_path;
59
+	protected $_column_template_path;
60 60
 
61
-    /**
62
-     * @var array $_template_args
63
-     */
64
-    protected $_template_args = array();
61
+	/**
62
+	 * @var array $_template_args
63
+	 */
64
+	protected $_template_args = array();
65 65
 
66
-    /**
67
-     * this will hold the list table object for a given view.
68
-     *
69
-     * @var EE_Admin_List_Table $_list_table_object
70
-     */
71
-    protected $_list_table_object;
66
+	/**
67
+	 * this will hold the list table object for a given view.
68
+	 *
69
+	 * @var EE_Admin_List_Table $_list_table_object
70
+	 */
71
+	protected $_list_table_object;
72 72
 
73
-    // boolean
74
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
73
+	// boolean
74
+	protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
75 75
 
76
-    protected $_routing;
76
+	protected $_routing;
77 77
 
78
-    // list table args
79
-    protected $_view;
78
+	// list table args
79
+	protected $_view;
80 80
 
81
-    protected $_views;
81
+	protected $_views;
82 82
 
83 83
 
84
-    // action => method pairs used for routing incoming requests
85
-    protected $_page_routes;
84
+	// action => method pairs used for routing incoming requests
85
+	protected $_page_routes;
86 86
 
87
-    /**
88
-     * @var array $_page_config
89
-     */
90
-    protected $_page_config;
87
+	/**
88
+	 * @var array $_page_config
89
+	 */
90
+	protected $_page_config;
91 91
 
92
-    /**
93
-     * the current page route and route config
94
-     *
95
-     * @var string $_route
96
-     */
97
-    protected $_route;
92
+	/**
93
+	 * the current page route and route config
94
+	 *
95
+	 * @var string $_route
96
+	 */
97
+	protected $_route;
98 98
 
99
-    /**
100
-     * @var string $_cpt_route
101
-     */
102
-    protected $_cpt_route;
99
+	/**
100
+	 * @var string $_cpt_route
101
+	 */
102
+	protected $_cpt_route;
103 103
 
104
-    /**
105
-     * @var array $_route_config
106
-     */
107
-    protected $_route_config;
104
+	/**
105
+	 * @var array $_route_config
106
+	 */
107
+	protected $_route_config;
108 108
 
109
-    /**
110
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
-     * actions.
112
-     *
113
-     * @since 4.6.x
114
-     * @var array.
115
-     */
116
-    protected $_default_route_query_args;
117
-
118
-    // set via request page and action args.
119
-    protected $_current_page;
120
-
121
-    protected $_current_view;
122
-
123
-    protected $_current_page_view_url;
124
-
125
-    // sanitized request action (and nonce)
126
-
127
-    /**
128
-     * @var string $_req_action
129
-     */
130
-    protected $_req_action;
131
-
132
-    /**
133
-     * @var string $_req_nonce
134
-     */
135
-    protected $_req_nonce;
136
-
137
-    // search related
138
-    protected $_search_btn_label;
139
-
140
-    protected $_search_box_callback;
141
-
142
-    /**
143
-     * WP Current Screen object
144
-     *
145
-     * @var WP_Screen
146
-     */
147
-    protected $_current_screen;
148
-
149
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
-    protected $_hook_obj;
151
-
152
-    // for holding incoming request data
153
-    protected $_req_data;
154
-
155
-    // yes / no array for admin form fields
156
-    protected $_yes_no_values = array();
157
-
158
-    // some default things shared by all child classes
159
-    protected $_default_espresso_metaboxes;
160
-
161
-    /**
162
-     *    EE_Registry Object
163
-     *
164
-     * @var    EE_Registry
165
-     */
166
-    protected $EE;
167
-
168
-
169
-    /**
170
-     * This is just a property that flags whether the given route is a caffeinated route or not.
171
-     *
172
-     * @var boolean
173
-     */
174
-    protected $_is_caf = false;
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws InvalidArgumentException
181
-     * @throws InvalidDataTypeException
182
-     * @throws InvalidInterfaceException
183
-     */
184
-    public function __construct($routing = true)
185
-    {
186
-        $this->loader = LoaderFactory::getLoader();
187
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
188
-            $this->_is_caf = true;
189
-        }
190
-        $this->_yes_no_values = array(
191
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
192
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
193
-        );
194
-        // set the _req_data property.
195
-        $this->_req_data = array_merge($_GET, $_POST);
196
-        // routing enabled?
197
-        $this->_routing = $routing;
198
-    }
199
-
200
-
201
-    /**
202
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
203
-     * for child classes that needed to set properties prior to these methods getting called,
204
-     * but also needed the parent class to have its construction completed as well.
205
-     * Bottom line is that constructors should ONLY be used for setting initial properties
206
-     * and any complex initialization logic should only run after instantiation is complete.
207
-     *
208
-     * This method gets called immediately after construction from within
209
-     *      EE_Admin_Page_Init::_initialize_admin_page()
210
-     *
211
-     * @throws EE_Error
212
-     * @throws InvalidArgumentException
213
-     * @throws InvalidDataTypeException
214
-     * @throws InvalidInterfaceException
215
-     * @throws ReflectionException
216
-     * @since $VID:$
217
-     */
218
-    public function initializePage()
219
-    {
220
-        // set initial page props (child method)
221
-        $this->_init_page_props();
222
-        // set global defaults
223
-        $this->_set_defaults();
224
-        // set early because incoming requests could be ajax related and we need to register those hooks.
225
-        $this->_global_ajax_hooks();
226
-        $this->_ajax_hooks();
227
-        // other_page_hooks have to be early too.
228
-        $this->_do_other_page_hooks();
229
-        // This just allows us to have extending classes do something specific
230
-        // before the parent constructor runs _page_setup().
231
-        if (method_exists($this, '_before_page_setup')) {
232
-            $this->_before_page_setup();
233
-        }
234
-        // set up page dependencies
235
-        $this->_page_setup();
236
-    }
237
-
238
-
239
-    /**
240
-     * _init_page_props
241
-     * Child classes use to set at least the following properties:
242
-     * $page_slug.
243
-     * $page_label.
244
-     *
245
-     * @abstract
246
-     * @return void
247
-     */
248
-    abstract protected function _init_page_props();
249
-
250
-
251
-    /**
252
-     * _ajax_hooks
253
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
254
-     * Note: within the ajax callback methods.
255
-     *
256
-     * @abstract
257
-     * @return void
258
-     */
259
-    abstract protected function _ajax_hooks();
260
-
261
-
262
-    /**
263
-     * _define_page_props
264
-     * child classes define page properties in here.  Must include at least:
265
-     * $_admin_base_url = base_url for all admin pages
266
-     * $_admin_page_title = default admin_page_title for admin pages
267
-     * $_labels = array of default labels for various automatically generated elements:
268
-     *    array(
269
-     *        'buttons' => array(
270
-     *            'add' => esc_html__('label for add new button'),
271
-     *            'edit' => esc_html__('label for edit button'),
272
-     *            'delete' => esc_html__('label for delete button')
273
-     *            )
274
-     *        )
275
-     *
276
-     * @abstract
277
-     * @return void
278
-     */
279
-    abstract protected function _define_page_props();
280
-
281
-
282
-    /**
283
-     * _set_page_routes
284
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
285
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
286
-     * have a 'default' route. Here's the format
287
-     * $this->_page_routes = array(
288
-     *        'default' => array(
289
-     *            'func' => '_default_method_handling_route',
290
-     *            'args' => array('array','of','args'),
291
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
292
-     *            ajax request, backend processing)
293
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
294
-     *            headers route after.  The string you enter here should match the defined route reference for a
295
-     *            headers sent route.
296
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
297
-     *            this route.
298
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
299
-     *            checks).
300
-     *        ),
301
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
302
-     *        handling method.
303
-     *        )
304
-     * )
305
-     *
306
-     * @abstract
307
-     * @return void
308
-     */
309
-    abstract protected function _set_page_routes();
310
-
311
-
312
-    /**
313
-     * _set_page_config
314
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
315
-     * array corresponds to the page_route for the loaded page. Format:
316
-     * $this->_page_config = array(
317
-     *        'default' => array(
318
-     *            'labels' => array(
319
-     *                'buttons' => array(
320
-     *                    'add' => esc_html__('label for adding item'),
321
-     *                    'edit' => esc_html__('label for editing item'),
322
-     *                    'delete' => esc_html__('label for deleting item')
323
-     *                ),
324
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
325
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
326
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
327
-     *            _define_page_props() method
328
-     *            'nav' => array(
329
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
330
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
331
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
332
-     *                'order' => 10, //required to indicate tab position.
333
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
334
-     *                displayed then add this parameter.
335
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
336
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
337
-     *            metaboxes set for eventespresso admin pages.
338
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
339
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
340
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
341
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
342
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
343
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
344
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
345
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
346
-     *            want to display.
347
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
348
-     *                'tab_id' => array(
349
-     *                    'title' => 'tab_title',
350
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
351
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
352
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
353
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
354
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
355
-     *                    attempt to use the callback which should match the name of a method in the class
356
-     *                    ),
357
-     *                'tab2_id' => array(
358
-     *                    'title' => 'tab2 title',
359
-     *                    'filename' => 'file_name_2'
360
-     *                    'callback' => 'callback_method_for_content',
361
-     *                 ),
362
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
363
-     *            help tab area on an admin page. @link
364
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
365
-     *            'help_tour' => array(
366
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
367
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
368
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
369
-     *            ),
370
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
371
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
372
-     *            just set
373
-     *            'require_nonce' to FALSE
374
-     *            )
375
-     * )
376
-     *
377
-     * @abstract
378
-     * @return void
379
-     */
380
-    abstract protected function _set_page_config();
381
-
382
-
383
-
384
-
385
-
386
-    /** end sample help_tour methods **/
387
-    /**
388
-     * _add_screen_options
389
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
390
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
391
-     * to a particular view.
392
-     *
393
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
394
-     *         see also WP_Screen object documents...
395
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
396
-     * @abstract
397
-     * @return void
398
-     */
399
-    abstract protected function _add_screen_options();
400
-
401
-
402
-    /**
403
-     * _add_feature_pointers
404
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
405
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
406
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
407
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
408
-     * extended) also see:
409
-     *
410
-     * @link   http://eamann.com/tech/wordpress-portland/
411
-     * @abstract
412
-     * @return void
413
-     */
414
-    abstract protected function _add_feature_pointers();
415
-
416
-
417
-    /**
418
-     * load_scripts_styles
419
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
420
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
421
-     * scripts/styles per view by putting them in a dynamic function in this format
422
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
423
-     *
424
-     * @abstract
425
-     * @return void
426
-     */
427
-    abstract public function load_scripts_styles();
428
-
429
-
430
-    /**
431
-     * admin_init
432
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
433
-     * all pages/views loaded by child class.
434
-     *
435
-     * @abstract
436
-     * @return void
437
-     */
438
-    abstract public function admin_init();
439
-
440
-
441
-    /**
442
-     * admin_notices
443
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
444
-     * all pages/views loaded by child class.
445
-     *
446
-     * @abstract
447
-     * @return void
448
-     */
449
-    abstract public function admin_notices();
450
-
451
-
452
-    /**
453
-     * admin_footer_scripts
454
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
455
-     * will apply to all pages/views loaded by child class.
456
-     *
457
-     * @return void
458
-     */
459
-    abstract public function admin_footer_scripts();
460
-
461
-
462
-    /**
463
-     * admin_footer
464
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
465
-     * apply to all pages/views loaded by child class.
466
-     *
467
-     * @return void
468
-     */
469
-    public function admin_footer()
470
-    {
471
-    }
472
-
473
-
474
-    /**
475
-     * _global_ajax_hooks
476
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
477
-     * Note: within the ajax callback methods.
478
-     *
479
-     * @abstract
480
-     * @return void
481
-     */
482
-    protected function _global_ajax_hooks()
483
-    {
484
-        // for lazy loading of metabox content
485
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
486
-    }
487
-
488
-
489
-    public function ajax_metabox_content()
490
-    {
491
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
492
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
493
-        EE_Admin_Page::cached_rss_display($contentid, $url);
494
-        wp_die();
495
-    }
496
-
497
-
498
-    /**
499
-     * _page_setup
500
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
501
-     * doesn't match the object.
502
-     *
503
-     * @final
504
-     * @return void
505
-     * @throws EE_Error
506
-     * @throws InvalidArgumentException
507
-     * @throws ReflectionException
508
-     * @throws InvalidDataTypeException
509
-     * @throws InvalidInterfaceException
510
-     */
511
-    final protected function _page_setup()
512
-    {
513
-        // requires?
514
-        // admin_init stuff - global - we're setting this REALLY early
515
-        // so if EE_Admin pages have to hook into other WP pages they can.
516
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
517
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
518
-        // next verify if we need to load anything...
519
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
520
-        $this->page_folder = strtolower(
521
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
522
-        );
523
-        global $ee_menu_slugs;
524
-        $ee_menu_slugs = (array) $ee_menu_slugs;
525
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
526
-            return;
527
-        }
528
-        // 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
529
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
530
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
531
-                ? $this->_req_data['action2']
532
-                : $this->_req_data['action'];
533
-        }
534
-        // then set blank or -1 action values to 'default'
535
-        $this->_req_action = isset($this->_req_data['action'])
536
-                             && ! empty($this->_req_data['action'])
537
-                             && $this->_req_data['action'] !== '-1'
538
-            ? sanitize_key($this->_req_data['action'])
539
-            : 'default';
540
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
541
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
542
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
543
-            ? $this->_req_data['route'] : $this->_req_action;
544
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
545
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
546
-            ? $this->_req_data['route']
547
-            : $this->_req_action;
548
-        $this->_current_view = $this->_req_action;
549
-        $this->_req_nonce = $this->_req_action . '_nonce';
550
-        $this->_define_page_props();
551
-        $this->_current_page_view_url = add_query_arg(
552
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
553
-            $this->_admin_base_url
554
-        );
555
-        // default things
556
-        $this->_default_espresso_metaboxes = array(
557
-            '_espresso_news_post_box',
558
-            '_espresso_links_post_box',
559
-            '_espresso_ratings_request',
560
-            '_espresso_sponsors_post_box',
561
-        );
562
-        // set page configs
563
-        $this->_set_page_routes();
564
-        $this->_set_page_config();
565
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
566
-        if (isset($this->_req_data['wp_referer'])) {
567
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
568
-        }
569
-        // for caffeinated and other extended functionality.
570
-        //  If there is a _extend_page_config method
571
-        // then let's run that to modify the all the various page configuration arrays
572
-        if (method_exists($this, '_extend_page_config')) {
573
-            $this->_extend_page_config();
574
-        }
575
-        // for CPT and other extended functionality.
576
-        // If there is an _extend_page_config_for_cpt
577
-        // then let's run that to modify all the various page configuration arrays.
578
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
579
-            $this->_extend_page_config_for_cpt();
580
-        }
581
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
582
-        $this->_page_routes = apply_filters(
583
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
584
-            $this->_page_routes,
585
-            $this
586
-        );
587
-        $this->_page_config = apply_filters(
588
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
589
-            $this->_page_config,
590
-            $this
591
-        );
592
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
593
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
594
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
595
-            add_action(
596
-                'AHEE__EE_Admin_Page__route_admin_request',
597
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
598
-                10,
599
-                2
600
-            );
601
-        }
602
-        // next route only if routing enabled
603
-        if ($this->_routing && ! defined('DOING_AJAX')) {
604
-            $this->_verify_routes();
605
-            // next let's just check user_access and kill if no access
606
-            $this->check_user_access();
607
-            if ($this->_is_UI_request) {
608
-                // admin_init stuff - global, all views for this page class, specific view
609
-                add_action('admin_init', array($this, 'admin_init'), 10);
610
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
611
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
612
-                }
613
-            } else {
614
-                // hijack regular WP loading and route admin request immediately
615
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
616
-                $this->route_admin_request();
617
-            }
618
-        }
619
-    }
620
-
621
-
622
-    /**
623
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
624
-     *
625
-     * @return void
626
-     * @throws EE_Error
627
-     */
628
-    private function _do_other_page_hooks()
629
-    {
630
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
631
-        foreach ($registered_pages as $page) {
632
-            // now let's setup the file name and class that should be present
633
-            $classname = str_replace('.class.php', '', $page);
634
-            // autoloaders should take care of loading file
635
-            if (! class_exists($classname)) {
636
-                $error_msg[] = sprintf(
637
-                    esc_html__(
638
-                        'Something went wrong with loading the %s admin hooks page.',
639
-                        'event_espresso'
640
-                    ),
641
-                    $page
642
-                );
643
-                $error_msg[] = $error_msg[0]
644
-                               . "\r\n"
645
-                               . sprintf(
646
-                                   esc_html__(
647
-                                       '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',
648
-                                       'event_espresso'
649
-                                   ),
650
-                                   $page,
651
-                                   '<br />',
652
-                                   '<strong>' . $classname . '</strong>'
653
-                               );
654
-                throw new EE_Error(implode('||', $error_msg));
655
-            }
656
-            // // notice we are passing the instance of this class to the hook object.
657
-            $this->loader->getShared($classname, [$this]);
658
-        }
659
-    }
660
-
661
-
662
-    /**
663
-     * @throws DomainException
664
-     * @throws EE_Error
665
-     * @throws InvalidArgumentException
666
-     * @throws InvalidDataTypeException
667
-     * @throws InvalidInterfaceException
668
-     * @throws ReflectionException
669
-     * @since $VID:$
670
-     */
671
-    public function load_page_dependencies()
672
-    {
673
-        try {
674
-            $this->_load_page_dependencies();
675
-        } catch (EE_Error $e) {
676
-            $e->get_error();
677
-        }
678
-    }
679
-
680
-
681
-    /**
682
-     * load_page_dependencies
683
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
684
-     *
685
-     * @return void
686
-     * @throws DomainException
687
-     * @throws EE_Error
688
-     * @throws InvalidArgumentException
689
-     * @throws InvalidDataTypeException
690
-     * @throws InvalidInterfaceException
691
-     */
692
-    protected function _load_page_dependencies()
693
-    {
694
-        // let's set the current_screen and screen options to override what WP set
695
-        $this->_current_screen = get_current_screen();
696
-        // load admin_notices - global, page class, and view specific
697
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
698
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
699
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
700
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
701
-        }
702
-        // load network admin_notices - global, page class, and view specific
703
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
704
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
705
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
706
-        }
707
-        // this will save any per_page screen options if they are present
708
-        $this->_set_per_page_screen_options();
709
-        // setup list table properties
710
-        $this->_set_list_table();
711
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
712
-        // However in some cases the metaboxes will need to be added within a route handling callback.
713
-        $this->_add_registered_meta_boxes();
714
-        $this->_add_screen_columns();
715
-        // add screen options - global, page child class, and view specific
716
-        $this->_add_global_screen_options();
717
-        $this->_add_screen_options();
718
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
719
-        if (method_exists($this, $add_screen_options)) {
720
-            $this->{$add_screen_options}();
721
-        }
722
-        // add help tab(s) and tours- set via page_config and qtips.
723
-        $this->_add_help_tour();
724
-        $this->_add_help_tabs();
725
-        $this->_add_qtips();
726
-        // add feature_pointers - global, page child class, and view specific
727
-        $this->_add_feature_pointers();
728
-        $this->_add_global_feature_pointers();
729
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
730
-        if (method_exists($this, $add_feature_pointer)) {
731
-            $this->{$add_feature_pointer}();
732
-        }
733
-        // enqueue scripts/styles - global, page class, and view specific
734
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
735
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
736
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
737
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
738
-        }
739
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
740
-        // admin_print_footer_scripts - global, page child class, and view specific.
741
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
742
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
743
-        // is a good use case. Notice the late priority we're giving these
744
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
745
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
746
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
747
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
748
-        }
749
-        // admin footer scripts
750
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
751
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
752
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
753
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
754
-        }
755
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
756
-        // targeted hook
757
-        do_action(
758
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
759
-        );
760
-    }
761
-
762
-
763
-    /**
764
-     * _set_defaults
765
-     * This sets some global defaults for class properties.
766
-     */
767
-    private function _set_defaults()
768
-    {
769
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
770
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
771
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
772
-        $this->_page_config = $this->_default_route_query_args = array();
773
-        $this->_default_nav_tab_name = 'overview';
774
-        // init template args
775
-        $this->_template_args = array(
776
-            'admin_page_header'  => '',
777
-            'admin_page_content' => '',
778
-            'post_body_content'  => '',
779
-            'before_list_table'  => '',
780
-            'after_list_table'   => '',
781
-        );
782
-    }
783
-
784
-
785
-    /**
786
-     * route_admin_request
787
-     *
788
-     * @see    _route_admin_request()
789
-     * @return exception|void error
790
-     * @throws InvalidArgumentException
791
-     * @throws InvalidInterfaceException
792
-     * @throws InvalidDataTypeException
793
-     * @throws EE_Error
794
-     * @throws ReflectionException
795
-     */
796
-    public function route_admin_request()
797
-    {
798
-        try {
799
-            $this->_route_admin_request();
800
-        } catch (EE_Error $e) {
801
-            $e->get_error();
802
-        }
803
-    }
804
-
805
-
806
-    public function set_wp_page_slug($wp_page_slug)
807
-    {
808
-        $this->_wp_page_slug = $wp_page_slug;
809
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
810
-        if (is_network_admin()) {
811
-            $this->_wp_page_slug .= '-network';
812
-        }
813
-    }
814
-
815
-
816
-    /**
817
-     * _verify_routes
818
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
819
-     * we know if we need to drop out.
820
-     *
821
-     * @return bool
822
-     * @throws EE_Error
823
-     */
824
-    protected function _verify_routes()
825
-    {
826
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
827
-            return false;
828
-        }
829
-        $this->_route = false;
830
-        // check that the page_routes array is not empty
831
-        if (empty($this->_page_routes)) {
832
-            // user error msg
833
-            $error_msg = sprintf(
834
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
835
-                $this->_admin_page_title
836
-            );
837
-            // developer error msg
838
-            $error_msg .= '||' . $error_msg
839
-                          . esc_html__(
840
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
841
-                              'event_espresso'
842
-                          );
843
-            throw new EE_Error($error_msg);
844
-        }
845
-        // and that the requested page route exists
846
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
847
-            $this->_route = $this->_page_routes[ $this->_req_action ];
848
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
849
-                ? $this->_page_config[ $this->_req_action ] : array();
850
-        } else {
851
-            // user error msg
852
-            $error_msg = sprintf(
853
-                esc_html__(
854
-                    'The requested page route does not exist for the %s admin page.',
855
-                    'event_espresso'
856
-                ),
857
-                $this->_admin_page_title
858
-            );
859
-            // developer error msg
860
-            $error_msg .= '||' . $error_msg
861
-                          . sprintf(
862
-                              esc_html__(
863
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
864
-                                  'event_espresso'
865
-                              ),
866
-                              $this->_req_action
867
-                          );
868
-            throw new EE_Error($error_msg);
869
-        }
870
-        // and that a default route exists
871
-        if (! array_key_exists('default', $this->_page_routes)) {
872
-            // user error msg
873
-            $error_msg = sprintf(
874
-                esc_html__(
875
-                    'A default page route has not been set for the % admin page.',
876
-                    'event_espresso'
877
-                ),
878
-                $this->_admin_page_title
879
-            );
880
-            // developer error msg
881
-            $error_msg .= '||' . $error_msg
882
-                          . esc_html__(
883
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
884
-                              'event_espresso'
885
-                          );
886
-            throw new EE_Error($error_msg);
887
-        }
888
-
889
-        // first lets' catch if the UI request has EVER been set.
890
-        if ($this->_is_UI_request === null) {
891
-            // lets set if this is a UI request or not.
892
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
893
-            // wait a minute... we might have a noheader in the route array
894
-            $this->_is_UI_request = is_array($this->_route)
895
-                                    && isset($this->_route['noheader'])
896
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
897
-        }
898
-        $this->_set_current_labels();
899
-        return true;
900
-    }
901
-
902
-
903
-    /**
904
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
905
-     *
906
-     * @param  string $route the route name we're verifying
907
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
908
-     * @throws EE_Error
909
-     */
910
-    protected function _verify_route($route)
911
-    {
912
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
913
-            return true;
914
-        }
915
-        // user error msg
916
-        $error_msg = sprintf(
917
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
918
-            $this->_admin_page_title
919
-        );
920
-        // developer error msg
921
-        $error_msg .= '||' . $error_msg
922
-                      . sprintf(
923
-                          esc_html__(
924
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
925
-                              'event_espresso'
926
-                          ),
927
-                          $route
928
-                      );
929
-        throw new EE_Error($error_msg);
930
-    }
931
-
932
-
933
-    /**
934
-     * perform nonce verification
935
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
936
-     * using this method (and save retyping!)
937
-     *
938
-     * @param string $nonce     The nonce sent
939
-     * @param string $nonce_ref The nonce reference string (name0)
940
-     * @return void
941
-     * @throws EE_Error
942
-     * @throws InvalidArgumentException
943
-     * @throws InvalidDataTypeException
944
-     * @throws InvalidInterfaceException
945
-     */
946
-    protected function _verify_nonce($nonce, $nonce_ref)
947
-    {
948
-        // verify nonce against expected value
949
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
950
-            // these are not the droids you are looking for !!!
951
-            $msg = sprintf(
952
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
953
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
954
-                '</a>'
955
-            );
956
-            if (WP_DEBUG) {
957
-                $msg .= "\n  "
958
-                        . sprintf(
959
-                            esc_html__(
960
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
961
-                                'event_espresso'
962
-                            ),
963
-                            EE_Admin_Page::class
964
-                        );
965
-            }
966
-            if (! defined('DOING_AJAX')) {
967
-                wp_die($msg);
968
-            } else {
969
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
970
-                $this->_return_json();
971
-            }
972
-        }
973
-    }
974
-
975
-
976
-    /**
977
-     * _route_admin_request()
978
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
979
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
980
-     * in the page routes and then will try to load the corresponding method.
981
-     *
982
-     * @return void
983
-     * @throws EE_Error
984
-     * @throws InvalidArgumentException
985
-     * @throws InvalidDataTypeException
986
-     * @throws InvalidInterfaceException
987
-     * @throws ReflectionException
988
-     */
989
-    protected function _route_admin_request()
990
-    {
991
-        if (! $this->_is_UI_request) {
992
-            $this->_verify_routes();
993
-        }
994
-        $nonce_check = isset($this->_route_config['require_nonce'])
995
-            ? $this->_route_config['require_nonce']
996
-            : true;
997
-        if ($this->_req_action !== 'default' && $nonce_check) {
998
-            // set nonce from post data
999
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
1000
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1001
-                : '';
1002
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1003
-        }
1004
-        // set the nav_tabs array but ONLY if this is  UI_request
1005
-        if ($this->_is_UI_request) {
1006
-            $this->_set_nav_tabs();
1007
-        }
1008
-        // grab callback function
1009
-        $func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1010
-        // check if callback has args
1011
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1012
-        $error_msg = '';
1013
-        // action right before calling route
1014
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1015
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1016
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1017
-        }
1018
-        // right before calling the route, let's remove _wp_http_referer from the
1019
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1020
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
1021
-            '_wp_http_referer',
1022
-            wp_unslash($_SERVER['REQUEST_URI'])
1023
-        );
1024
-        if (! empty($func)) {
1025
-            if (is_array($func)) {
1026
-                list($class, $method) = $func;
1027
-            } elseif (strpos($func, '::') !== false) {
1028
-                list($class, $method) = explode('::', $func);
1029
-            } else {
1030
-                $class = $this;
1031
-                $method = $func;
1032
-            }
1033
-            if (! (is_object($class) && $class === $this)) {
1034
-                // send along this admin page object for access by addons.
1035
-                $args['admin_page_object'] = $this;
1036
-            }
1037
-            // is it a method on a class that doesn't work?
1038
-            if (((method_exists($class, $method)
1039
-                  && call_user_func_array(array($class, $method), $args) === false)
1040
-                 && (// is it a standalone function that doesn't work?
1041
-                     function_exists($method)
1042
-                     && call_user_func_array(
1043
-                         $func,
1044
-                         array_merge(array('admin_page_object' => $this), $args)
1045
-                     ) === false
1046
-                 )) || (// is it neither a class method NOR a standalone function?
1047
-                    ! function_exists($method)
1048
-                    && ! method_exists($class, $method)
1049
-                )
1050
-            ) {
1051
-                // user error msg
1052
-                $error_msg = esc_html__(
1053
-                    'An error occurred. The  requested page route could not be found.',
1054
-                    'event_espresso'
1055
-                );
1056
-                // developer error msg
1057
-                $error_msg .= '||';
1058
-                $error_msg .= sprintf(
1059
-                    esc_html__(
1060
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1061
-                        'event_espresso'
1062
-                    ),
1063
-                    $method
1064
-                );
1065
-            }
1066
-            if (! empty($error_msg)) {
1067
-                throw new EE_Error($error_msg);
1068
-            }
1069
-        }
1070
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1071
-        // then we need to reset the routing properties to the new route.
1072
-        // 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.
1073
-        if ($this->_is_UI_request === false
1074
-            && is_array($this->_route)
1075
-            && ! empty($this->_route['headers_sent_route'])
1076
-        ) {
1077
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1078
-        }
1079
-    }
1080
-
1081
-
1082
-    /**
1083
-     * This method just allows the resetting of page properties in the case where a no headers
1084
-     * route redirects to a headers route in its route config.
1085
-     *
1086
-     * @since   4.3.0
1087
-     * @param  string $new_route New (non header) route to redirect to.
1088
-     * @return   void
1089
-     * @throws ReflectionException
1090
-     * @throws InvalidArgumentException
1091
-     * @throws InvalidInterfaceException
1092
-     * @throws InvalidDataTypeException
1093
-     * @throws EE_Error
1094
-     */
1095
-    protected function _reset_routing_properties($new_route)
1096
-    {
1097
-        $this->_is_UI_request = true;
1098
-        // now we set the current route to whatever the headers_sent_route is set at
1099
-        $this->_req_data['action'] = $new_route;
1100
-        // rerun page setup
1101
-        $this->_page_setup();
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * _add_query_arg
1107
-     * adds nonce to array of arguments then calls WP add_query_arg function
1108
-     *(internally just uses EEH_URL's function with the same name)
1109
-     *
1110
-     * @param array  $args
1111
-     * @param string $url
1112
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1113
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1114
-     *                                        Example usage: If the current page is:
1115
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1116
-     *                                        &action=default&event_id=20&month_range=March%202015
1117
-     *                                        &_wpnonce=5467821
1118
-     *                                        and you call:
1119
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1120
-     *                                        array(
1121
-     *                                        'action' => 'resend_something',
1122
-     *                                        'page=>espresso_registrations'
1123
-     *                                        ),
1124
-     *                                        $some_url,
1125
-     *                                        true
1126
-     *                                        );
1127
-     *                                        It will produce a url in this structure:
1128
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1129
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1130
-     *                                        month_range]=March%202015
1131
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1132
-     * @return string
1133
-     */
1134
-    public static function add_query_args_and_nonce(
1135
-        $args = array(),
1136
-        $url = '',
1137
-        $sticky = false,
1138
-        $exclude_nonce = false
1139
-    ) {
1140
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1141
-        if ($sticky) {
1142
-            $request = $_REQUEST;
1143
-            unset($request['_wp_http_referer'], $request['wp_referer']);
1144
-            foreach ($request as $key => $value) {
1145
-                // do not add nonces
1146
-                if (strpos($key, 'nonce') !== false) {
1147
-                    continue;
1148
-                }
1149
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1150
-            }
1151
-        }
1152
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1153
-    }
1154
-
1155
-
1156
-    /**
1157
-     * This returns a generated link that will load the related help tab.
1158
-     *
1159
-     * @param  string $help_tab_id the id for the connected help tab
1160
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1161
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1162
-     * @uses EEH_Template::get_help_tab_link()
1163
-     * @return string              generated link
1164
-     */
1165
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1166
-    {
1167
-        return EEH_Template::get_help_tab_link(
1168
-            $help_tab_id,
1169
-            $this->page_slug,
1170
-            $this->_req_action,
1171
-            $icon_style,
1172
-            $help_text
1173
-        );
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     * _add_help_tabs
1179
-     * Note child classes define their help tabs within the page_config array.
1180
-     *
1181
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1182
-     * @return void
1183
-     * @throws DomainException
1184
-     * @throws EE_Error
1185
-     */
1186
-    protected function _add_help_tabs()
1187
-    {
1188
-        $tour_buttons = '';
1189
-        if (isset($this->_page_config[ $this->_req_action ])) {
1190
-            $config = $this->_page_config[ $this->_req_action ];
1191
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1192
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1193
-                $tb = array();
1194
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1195
-                foreach ($this->_help_tour['tours'] as $tour) {
1196
-                    // if this is the end tour then we don't need to setup a button
1197
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1198
-                        continue;
1199
-                    }
1200
-                    $tb[] = '<button id="trigger-tour-'
1201
-                            . $tour->get_slug()
1202
-                            . '" class="button-primary trigger-ee-help-tour">'
1203
-                            . $tour->get_label()
1204
-                            . '</button>';
1205
-                }
1206
-                $tour_buttons .= implode('<br />', $tb);
1207
-                $tour_buttons .= '</div></div>';
1208
-            }
1209
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1210
-            if (is_array($config) && isset($config['help_sidebar'])) {
1211
-                // check that the callback given is valid
1212
-                if (! method_exists($this, $config['help_sidebar'])) {
1213
-                    throw new EE_Error(
1214
-                        sprintf(
1215
-                            esc_html__(
1216
-                                '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',
1217
-                                'event_espresso'
1218
-                            ),
1219
-                            $config['help_sidebar'],
1220
-                            get_class($this)
1221
-                        )
1222
-                    );
1223
-                }
1224
-                $content = apply_filters(
1225
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1226
-                    $this->{$config['help_sidebar']}()
1227
-                );
1228
-                $content .= $tour_buttons; // add help tour buttons.
1229
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1230
-                $this->_current_screen->set_help_sidebar($content);
1231
-            }
1232
-            // if there ARE tour buttons...
1233
-            if (! empty($tour_buttons)) {
1234
-                // if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1235
-                if (! isset($config['help_sidebar'])) {
1236
-                    $this->_current_screen->set_help_sidebar($tour_buttons);
1237
-                }
1238
-                // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1239
-                if (! isset($config['help_tabs'])) {
1240
-                    $_ht['id'] = $this->page_slug;
1241
-                    $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1242
-                    $_ht['content'] = '<p>'
1243
-                                      . esc_html__(
1244
-                                          'The buttons to the right allow you to start/restart any help tours available for this page',
1245
-                                          'event_espresso'
1246
-                                      ) . '</p>';
1247
-                    $this->_current_screen->add_help_tab($_ht);
1248
-                }
1249
-            }
1250
-            if (! isset($config['help_tabs'])) {
1251
-                return;
1252
-            } //no help tabs for this route
1253
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1254
-                // we're here so there ARE help tabs!
1255
-                // make sure we've got what we need
1256
-                if (! isset($cfg['title'])) {
1257
-                    throw new EE_Error(
1258
-                        esc_html__(
1259
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1260
-                            'event_espresso'
1261
-                        )
1262
-                    );
1263
-                }
1264
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1265
-                    throw new EE_Error(
1266
-                        esc_html__(
1267
-                            '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',
1268
-                            'event_espresso'
1269
-                        )
1270
-                    );
1271
-                }
1272
-                // first priority goes to content.
1273
-                if (! empty($cfg['content'])) {
1274
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1275
-                    // second priority goes to filename
1276
-                } elseif (! empty($cfg['filename'])) {
1277
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1278
-                    // 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)
1279
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1280
-                                                             . basename($this->_get_dir())
1281
-                                                             . '/help_tabs/'
1282
-                                                             . $cfg['filename']
1283
-                                                             . '.help_tab.php' : $file_path;
1284
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1285
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1286
-                        EE_Error::add_error(
1287
-                            sprintf(
1288
-                                esc_html__(
1289
-                                    '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',
1290
-                                    'event_espresso'
1291
-                                ),
1292
-                                $tab_id,
1293
-                                key($config),
1294
-                                $file_path
1295
-                            ),
1296
-                            __FILE__,
1297
-                            __FUNCTION__,
1298
-                            __LINE__
1299
-                        );
1300
-                        return;
1301
-                    }
1302
-                    $template_args['admin_page_obj'] = $this;
1303
-                    $content = EEH_Template::display_template(
1304
-                        $file_path,
1305
-                        $template_args,
1306
-                        true
1307
-                    );
1308
-                } else {
1309
-                    $content = '';
1310
-                }
1311
-                // check if callback is valid
1312
-                if (empty($content) && (
1313
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1314
-                    )
1315
-                ) {
1316
-                    EE_Error::add_error(
1317
-                        sprintf(
1318
-                            esc_html__(
1319
-                                '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.',
1320
-                                'event_espresso'
1321
-                            ),
1322
-                            $cfg['title']
1323
-                        ),
1324
-                        __FILE__,
1325
-                        __FUNCTION__,
1326
-                        __LINE__
1327
-                    );
1328
-                    return;
1329
-                }
1330
-                // setup config array for help tab method
1331
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1332
-                $_ht = array(
1333
-                    'id'       => $id,
1334
-                    'title'    => $cfg['title'],
1335
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1336
-                    'content'  => $content,
1337
-                );
1338
-                $this->_current_screen->add_help_tab($_ht);
1339
-            }
1340
-        }
1341
-    }
1342
-
1343
-
1344
-    /**
1345
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1346
-     * an array with properties for setting up usage of the joyride plugin
1347
-     *
1348
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1349
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1350
-     *         _set_page_config() comments
1351
-     * @return void
1352
-     * @throws EE_Error
1353
-     * @throws InvalidArgumentException
1354
-     * @throws InvalidDataTypeException
1355
-     * @throws InvalidInterfaceException
1356
-     */
1357
-    protected function _add_help_tour()
1358
-    {
1359
-        $tours = array();
1360
-        $this->_help_tour = array();
1361
-        // exit early if help tours are turned off globally
1362
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1363
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1364
-        ) {
1365
-            return;
1366
-        }
1367
-        // loop through _page_config to find any help_tour defined
1368
-        foreach ($this->_page_config as $route => $config) {
1369
-            // we're only going to set things up for this route
1370
-            if ($route !== $this->_req_action) {
1371
-                continue;
1372
-            }
1373
-            if (isset($config['help_tour'])) {
1374
-                foreach ($config['help_tour'] as $tour) {
1375
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1376
-                    // let's see if we can get that file...
1377
-                    // if not its possible this is a decaf route not set in caffeinated
1378
-                    // so lets try and get the caffeinated equivalent
1379
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1380
-                                                             . basename($this->_get_dir())
1381
-                                                             . '/help_tours/'
1382
-                                                             . $tour
1383
-                                                             . '.class.php' : $file_path;
1384
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1385
-                    if (! is_readable($file_path)) {
1386
-                        EE_Error::add_error(
1387
-                            sprintf(
1388
-                                esc_html__(
1389
-                                    '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',
1390
-                                    'event_espresso'
1391
-                                ),
1392
-                                $file_path,
1393
-                                $tour
1394
-                            ),
1395
-                            __FILE__,
1396
-                            __FUNCTION__,
1397
-                            __LINE__
1398
-                        );
1399
-                        return;
1400
-                    }
1401
-                    require_once $file_path;
1402
-                    if (! class_exists($tour)) {
1403
-                        $error_msg = [];
1404
-                        $error_msg[] = sprintf(
1405
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1406
-                            $tour
1407
-                        );
1408
-                        $error_msg[] = $error_msg[0] . "\r\n"
1409
-                                       . sprintf(
1410
-                                           esc_html__(
1411
-                                               '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.',
1412
-                                               'event_espresso'
1413
-                                           ),
1414
-                                           $tour,
1415
-                                           '<br />',
1416
-                                           $tour,
1417
-                                           $this->_req_action,
1418
-                                           get_class($this)
1419
-                                       );
1420
-                        throw new EE_Error(implode('||', $error_msg));
1421
-                    }
1422
-                    $tour_obj = new $tour($this->_is_caf);
1423
-                    $tours[] = $tour_obj;
1424
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1425
-                }
1426
-                // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1427
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1428
-                $tours[] = $end_stop_tour;
1429
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1430
-            }
1431
-        }
1432
-
1433
-        if (! empty($tours)) {
1434
-            $this->_help_tour['tours'] = $tours;
1435
-        }
1436
-        // that's it!  Now that the $_help_tours property is set (or not)
1437
-        // the scripts and html should be taken care of automatically.
1438
-
1439
-        /**
1440
-         * Allow extending the help tours variable.
1441
-         *
1442
-         * @param Array $_help_tour The array containing all help tour information to be displayed.
1443
-         */
1444
-        $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1445
-    }
1446
-
1447
-
1448
-    /**
1449
-     * This simply sets up any qtips that have been defined in the page config
1450
-     *
1451
-     * @return void
1452
-     */
1453
-    protected function _add_qtips()
1454
-    {
1455
-        if (isset($this->_route_config['qtips'])) {
1456
-            $qtips = (array) $this->_route_config['qtips'];
1457
-            // load qtip loader
1458
-            $path = array(
1459
-                $this->_get_dir() . '/qtips/',
1460
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1461
-            );
1462
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1463
-        }
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * _set_nav_tabs
1469
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1470
-     * wish to add additional tabs or modify accordingly.
1471
-     *
1472
-     * @return void
1473
-     * @throws InvalidArgumentException
1474
-     * @throws InvalidInterfaceException
1475
-     * @throws InvalidDataTypeException
1476
-     */
1477
-    protected function _set_nav_tabs()
1478
-    {
1479
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1480
-        $i = 0;
1481
-        foreach ($this->_page_config as $slug => $config) {
1482
-            if (! is_array($config)
1483
-                || (
1484
-                    is_array($config)
1485
-                    && (
1486
-                        (isset($config['nav']) && ! $config['nav'])
1487
-                        || ! isset($config['nav'])
1488
-                    )
1489
-                )
1490
-            ) {
1491
-                continue;
1492
-            }
1493
-            // no nav tab for this config
1494
-            // check for persistent flag
1495
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1496
-                // nav tab is only to appear when route requested.
1497
-                continue;
1498
-            }
1499
-            if (! $this->check_user_access($slug, true)) {
1500
-                // no nav tab because current user does not have access.
1501
-                continue;
1502
-            }
1503
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1504
-            $this->_nav_tabs[ $slug ] = array(
1505
-                'url'       => isset($config['nav']['url'])
1506
-                    ? $config['nav']['url']
1507
-                    : EE_Admin_Page::add_query_args_and_nonce(
1508
-                        array('action' => $slug),
1509
-                        $this->_admin_base_url
1510
-                    ),
1511
-                'link_text' => isset($config['nav']['label'])
1512
-                    ? $config['nav']['label']
1513
-                    : ucwords(
1514
-                        str_replace('_', ' ', $slug)
1515
-                    ),
1516
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1517
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1518
-            );
1519
-            $i++;
1520
-        }
1521
-        // if $this->_nav_tabs is empty then lets set the default
1522
-        if (empty($this->_nav_tabs)) {
1523
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1524
-                'url'       => $this->_admin_base_url,
1525
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1526
-                'css_class' => 'nav-tab-active',
1527
-                'order'     => 10,
1528
-            );
1529
-        }
1530
-        // now let's sort the tabs according to order
1531
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1532
-    }
1533
-
1534
-
1535
-    /**
1536
-     * _set_current_labels
1537
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1538
-     * property array
1539
-     *
1540
-     * @return void
1541
-     */
1542
-    private function _set_current_labels()
1543
-    {
1544
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1545
-            foreach ($this->_route_config['labels'] as $label => $text) {
1546
-                if (is_array($text)) {
1547
-                    foreach ($text as $sublabel => $subtext) {
1548
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1549
-                    }
1550
-                } else {
1551
-                    $this->_labels[ $label ] = $text;
1552
-                }
1553
-            }
1554
-        }
1555
-    }
1556
-
1557
-
1558
-    /**
1559
-     *        verifies user access for this admin page
1560
-     *
1561
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1562
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1563
-     *                               return false if verify fail.
1564
-     * @return bool
1565
-     * @throws InvalidArgumentException
1566
-     * @throws InvalidDataTypeException
1567
-     * @throws InvalidInterfaceException
1568
-     */
1569
-    public function check_user_access($route_to_check = '', $verify_only = false)
1570
-    {
1571
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1572
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1573
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1574
-                      && is_array(
1575
-                          $this->_page_routes[ $route_to_check ]
1576
-                      )
1577
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1578
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1579
-        if (empty($capability) && empty($route_to_check)) {
1580
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1581
-                : $this->_route['capability'];
1582
-        } else {
1583
-            $capability = empty($capability) ? 'manage_options' : $capability;
1584
-        }
1585
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1586
-        if (! defined('DOING_AJAX')
1587
-            && (
1588
-                ! function_exists('is_admin')
1589
-                || ! EE_Registry::instance()->CAP->current_user_can(
1590
-                    $capability,
1591
-                    $this->page_slug
1592
-                    . '_'
1593
-                    . $route_to_check,
1594
-                    $id
1595
-                )
1596
-            )
1597
-        ) {
1598
-            if ($verify_only) {
1599
-                return false;
1600
-            }
1601
-            if (is_user_logged_in()) {
1602
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1603
-            } else {
1604
-                return false;
1605
-            }
1606
-        }
1607
-        return true;
1608
-    }
1609
-
1610
-
1611
-    /**
1612
-     * admin_init_global
1613
-     * This runs all the code that we want executed within the WP admin_init hook.
1614
-     * This method executes for ALL EE Admin pages.
1615
-     *
1616
-     * @return void
1617
-     */
1618
-    public function admin_init_global()
1619
-    {
1620
-    }
1621
-
1622
-
1623
-    /**
1624
-     * wp_loaded_global
1625
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1626
-     * EE_Admin page and will execute on every EE Admin Page load
1627
-     *
1628
-     * @return void
1629
-     */
1630
-    public function wp_loaded()
1631
-    {
1632
-    }
1633
-
1634
-
1635
-    /**
1636
-     * admin_notices
1637
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1638
-     * ALL EE_Admin pages.
1639
-     *
1640
-     * @return void
1641
-     */
1642
-    public function admin_notices_global()
1643
-    {
1644
-        $this->_display_no_javascript_warning();
1645
-        $this->_display_espresso_notices();
1646
-    }
1647
-
1648
-
1649
-    public function network_admin_notices_global()
1650
-    {
1651
-        $this->_display_no_javascript_warning();
1652
-        $this->_display_espresso_notices();
1653
-    }
1654
-
1655
-
1656
-    /**
1657
-     * admin_footer_scripts_global
1658
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1659
-     * will apply on ALL EE_Admin pages.
1660
-     *
1661
-     * @return void
1662
-     */
1663
-    public function admin_footer_scripts_global()
1664
-    {
1665
-        $this->_add_admin_page_ajax_loading_img();
1666
-        $this->_add_admin_page_overlay();
1667
-        // if metaboxes are present we need to add the nonce field
1668
-        if (isset($this->_route_config['metaboxes'])
1669
-            || isset($this->_route_config['list_table'])
1670
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1671
-        ) {
1672
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1673
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1674
-        }
1675
-    }
1676
-
1677
-
1678
-    /**
1679
-     * admin_footer_global
1680
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1681
-     * This particular method will apply on ALL EE_Admin Pages.
1682
-     *
1683
-     * @return void
1684
-     * @throws InvalidArgumentException
1685
-     * @throws InvalidDataTypeException
1686
-     * @throws InvalidInterfaceException
1687
-     */
1688
-    public function admin_footer_global()
1689
-    {
1690
-        // dialog container for dialog helper
1691
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1692
-        $d_cont .= '<div class="ee-notices"></div>';
1693
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1694
-        $d_cont .= '</div>';
1695
-        echo $d_cont;
1696
-        // help tour stuff?
1697
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1698
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1699
-        }
1700
-        // current set timezone for timezone js
1701
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1702
-    }
1703
-
1704
-
1705
-    /**
1706
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1707
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1708
-     * help popups then in your templates or your content you set "triggers" for the content using the
1709
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1710
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1711
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1712
-     * for the
1713
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1714
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1715
-     *    'help_trigger_id' => array(
1716
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1717
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1718
-     *    )
1719
-     * );
1720
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1721
-     *
1722
-     * @param array $help_array
1723
-     * @param bool  $display
1724
-     * @return string content
1725
-     * @throws DomainException
1726
-     * @throws EE_Error
1727
-     */
1728
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1729
-    {
1730
-        $content = '';
1731
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1732
-        // loop through the array and setup content
1733
-        foreach ($help_array as $trigger => $help) {
1734
-            // make sure the array is setup properly
1735
-            if (! isset($help['title'], $help['content'])) {
1736
-                throw new EE_Error(
1737
-                    esc_html__(
1738
-                        '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',
1739
-                        'event_espresso'
1740
-                    )
1741
-                );
1742
-            }
1743
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1744
-            $template_args = array(
1745
-                'help_popup_id'      => $trigger,
1746
-                'help_popup_title'   => $help['title'],
1747
-                'help_popup_content' => $help['content'],
1748
-            );
1749
-            $content .= EEH_Template::display_template(
1750
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1751
-                $template_args,
1752
-                true
1753
-            );
1754
-        }
1755
-        if ($display) {
1756
-            echo $content;
1757
-            return '';
1758
-        }
1759
-        return $content;
1760
-    }
1761
-
1762
-
1763
-    /**
1764
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1765
-     *
1766
-     * @return array properly formatted array for help popup content
1767
-     * @throws EE_Error
1768
-     */
1769
-    private function _get_help_content()
1770
-    {
1771
-        // what is the method we're looking for?
1772
-        $method_name = '_help_popup_content_' . $this->_req_action;
1773
-        // if method doesn't exist let's get out.
1774
-        if (! method_exists($this, $method_name)) {
1775
-            return array();
1776
-        }
1777
-        // k we're good to go let's retrieve the help array
1778
-        $help_array = $this->{$method_name}();
1779
-        // make sure we've got an array!
1780
-        if (! is_array($help_array)) {
1781
-            throw new EE_Error(
1782
-                esc_html__(
1783
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1784
-                    'event_espresso'
1785
-                )
1786
-            );
1787
-        }
1788
-        return $help_array;
1789
-    }
1790
-
1791
-
1792
-    /**
1793
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1794
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1795
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1796
-     *
1797
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1798
-     * @param boolean $display    if false then we return the trigger string
1799
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1800
-     * @return string
1801
-     * @throws DomainException
1802
-     * @throws EE_Error
1803
-     */
1804
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1805
-    {
1806
-        if (defined('DOING_AJAX')) {
1807
-            return '';
1808
-        }
1809
-        // 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
1810
-        $help_array = $this->_get_help_content();
1811
-        $help_content = '';
1812
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1813
-            $help_array[ $trigger_id ] = array(
1814
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1815
-                'content' => esc_html__(
1816
-                    '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.)',
1817
-                    'event_espresso'
1818
-                ),
1819
-            );
1820
-            $help_content = $this->_set_help_popup_content($help_array);
1821
-        }
1822
-        // let's setup the trigger
1823
-        $content = '<a class="ee-dialog" href="?height='
1824
-                   . $dimensions[0]
1825
-                   . '&width='
1826
-                   . $dimensions[1]
1827
-                   . '&inlineId='
1828
-                   . $trigger_id
1829
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1830
-        $content .= $help_content;
1831
-        if ($display) {
1832
-            echo $content;
1833
-            return '';
1834
-        }
1835
-        return $content;
1836
-    }
1837
-
1838
-
1839
-    /**
1840
-     * _add_global_screen_options
1841
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1842
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1843
-     *
1844
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1845
-     *         see also WP_Screen object documents...
1846
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1847
-     * @abstract
1848
-     * @return void
1849
-     */
1850
-    private function _add_global_screen_options()
1851
-    {
1852
-    }
1853
-
1854
-
1855
-    /**
1856
-     * _add_global_feature_pointers
1857
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1858
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1859
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1860
-     *
1861
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1862
-     *         extended) also see:
1863
-     * @link   http://eamann.com/tech/wordpress-portland/
1864
-     * @abstract
1865
-     * @return void
1866
-     */
1867
-    private function _add_global_feature_pointers()
1868
-    {
1869
-    }
1870
-
1871
-
1872
-    /**
1873
-     * load_global_scripts_styles
1874
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1875
-     *
1876
-     * @return void
1877
-     * @throws EE_Error
1878
-     */
1879
-    public function load_global_scripts_styles()
1880
-    {
1881
-        /** STYLES **/
1882
-        // add debugging styles
1883
-        if (WP_DEBUG) {
1884
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1885
-        }
1886
-        // register all styles
1887
-        wp_register_style(
1888
-            'espresso-ui-theme',
1889
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1890
-            array(),
1891
-            EVENT_ESPRESSO_VERSION
1892
-        );
1893
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1894
-        // helpers styles
1895
-        wp_register_style(
1896
-            'ee-text-links',
1897
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1898
-            array(),
1899
-            EVENT_ESPRESSO_VERSION
1900
-        );
1901
-        /** SCRIPTS **/
1902
-        // register all scripts
1903
-        wp_register_script(
1904
-            'ee-dialog',
1905
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1906
-            array('jquery', 'jquery-ui-draggable'),
1907
-            EVENT_ESPRESSO_VERSION,
1908
-            true
1909
-        );
1910
-        wp_register_script(
1911
-            'ee_admin_js',
1912
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1913
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1914
-            EVENT_ESPRESSO_VERSION,
1915
-            true
1916
-        );
1917
-        wp_register_script(
1918
-            'jquery-ui-timepicker-addon',
1919
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1920
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1921
-            EVENT_ESPRESSO_VERSION,
1922
-            true
1923
-        );
1924
-        if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1925
-            add_filter('FHEE_load_joyride', '__return_true');
1926
-        }
1927
-        // script for sorting tables
1928
-        wp_register_script(
1929
-            'espresso_ajax_table_sorting',
1930
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1931
-            array('ee_admin_js', 'jquery-ui-sortable'),
1932
-            EVENT_ESPRESSO_VERSION,
1933
-            true
1934
-        );
1935
-        // script for parsing uri's
1936
-        wp_register_script(
1937
-            'ee-parse-uri',
1938
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1939
-            array(),
1940
-            EVENT_ESPRESSO_VERSION,
1941
-            true
1942
-        );
1943
-        // and parsing associative serialized form elements
1944
-        wp_register_script(
1945
-            'ee-serialize-full-array',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1947
-            array('jquery'),
1948
-            EVENT_ESPRESSO_VERSION,
1949
-            true
1950
-        );
1951
-        // helpers scripts
1952
-        wp_register_script(
1953
-            'ee-text-links',
1954
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1955
-            array('jquery'),
1956
-            EVENT_ESPRESSO_VERSION,
1957
-            true
1958
-        );
1959
-        wp_register_script(
1960
-            'ee-moment-core',
1961
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1962
-            array(),
1963
-            EVENT_ESPRESSO_VERSION,
1964
-            true
1965
-        );
1966
-        wp_register_script(
1967
-            'ee-moment',
1968
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1969
-            array('ee-moment-core'),
1970
-            EVENT_ESPRESSO_VERSION,
1971
-            true
1972
-        );
1973
-        wp_register_script(
1974
-            'ee-datepicker',
1975
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1976
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1977
-            EVENT_ESPRESSO_VERSION,
1978
-            true
1979
-        );
1980
-        // google charts
1981
-        wp_register_script(
1982
-            'google-charts',
1983
-            'https://www.gstatic.com/charts/loader.js',
1984
-            array(),
1985
-            EVENT_ESPRESSO_VERSION
1986
-        );
1987
-        // ENQUEUE ALL BASICS BY DEFAULT
1988
-        wp_enqueue_style('ee-admin-css');
1989
-        wp_enqueue_script('ee_admin_js');
1990
-        wp_enqueue_script('jquery-validate');
1991
-        // taking care of metaboxes
1992
-        if (empty($this->_cpt_route)
1993
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1994
-        ) {
1995
-            wp_enqueue_script('dashboard');
1996
-        }
1997
-        // LOCALIZED DATA
1998
-        // localize script for ajax lazy loading
1999
-        $lazy_loader_container_ids = apply_filters(
2000
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2001
-            array('espresso_news_post_box_content')
2002
-        );
2003
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2004
-        /**
2005
-         * help tour stuff
2006
-         */
2007
-        if (! empty($this->_help_tour)) {
2008
-            // register the js for kicking things off
2009
-            wp_enqueue_script(
2010
-                'ee-help-tour',
2011
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
2012
-                array('jquery-joyride'),
2013
-                EVENT_ESPRESSO_VERSION,
2014
-                true
2015
-            );
2016
-            $tours = array();
2017
-            // setup tours for the js tour object
2018
-            foreach ($this->_help_tour['tours'] as $tour) {
2019
-                if ($tour instanceof EE_Help_Tour) {
2020
-                    $tours[] = array(
2021
-                        'id'      => $tour->get_slug(),
2022
-                        'options' => $tour->get_options(),
2023
-                    );
2024
-                }
2025
-            }
2026
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2027
-            // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2028
-        }
2029
-    }
2030
-
2031
-
2032
-    /**
2033
-     *        admin_footer_scripts_eei18n_js_strings
2034
-     *
2035
-     * @return        void
2036
-     */
2037
-    public function admin_footer_scripts_eei18n_js_strings()
2038
-    {
2039
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2040
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2041
-            '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!!!',
2042
-            'event_espresso'
2043
-        );
2044
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2045
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2046
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2047
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2048
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2049
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2050
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2051
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2052
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2053
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2054
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2055
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2056
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2057
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2058
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2059
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2060
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2061
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2062
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2063
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2064
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2065
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2066
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2067
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2068
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2069
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2070
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2071
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2072
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2073
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2074
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2075
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2076
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2077
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2078
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2079
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2080
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2081
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2082
-    }
2083
-
2084
-
2085
-    /**
2086
-     *        load enhanced xdebug styles for ppl with failing eyesight
2087
-     *
2088
-     * @return        void
2089
-     */
2090
-    public function add_xdebug_style()
2091
-    {
2092
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2093
-    }
2094
-
2095
-
2096
-    /************************/
2097
-    /** LIST TABLE METHODS **/
2098
-    /************************/
2099
-    /**
2100
-     * this sets up the list table if the current view requires it.
2101
-     *
2102
-     * @return void
2103
-     * @throws EE_Error
2104
-     * @throws InvalidArgumentException
2105
-     * @throws InvalidDataTypeException
2106
-     * @throws InvalidInterfaceException
2107
-     */
2108
-    protected function _set_list_table()
2109
-    {
2110
-        // first is this a list_table view?
2111
-        if (! isset($this->_route_config['list_table'])) {
2112
-            return;
2113
-        } //not a list_table view so get out.
2114
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2115
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2116
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2117
-            // user error msg
2118
-            $error_msg = esc_html__(
2119
-                'An error occurred. The requested list table views could not be found.',
2120
-                'event_espresso'
2121
-            );
2122
-            // developer error msg
2123
-            $error_msg .= '||'
2124
-                          . sprintf(
2125
-                              esc_html__(
2126
-                                  '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.',
2127
-                                  'event_espresso'
2128
-                              ),
2129
-                              $this->_req_action,
2130
-                              $list_table_view
2131
-                          );
2132
-            throw new EE_Error($error_msg);
2133
-        }
2134
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2135
-        $this->_views = apply_filters(
2136
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2137
-            $this->_views
2138
-        );
2139
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2140
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2141
-        $this->_set_list_table_view();
2142
-        $this->_set_list_table_object();
2143
-    }
2144
-
2145
-
2146
-    /**
2147
-     * set current view for List Table
2148
-     *
2149
-     * @return void
2150
-     */
2151
-    protected function _set_list_table_view()
2152
-    {
2153
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2154
-        // looking at active items or dumpster diving ?
2155
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2156
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2157
-        } else {
2158
-            $this->_view = sanitize_key($this->_req_data['status']);
2159
-        }
2160
-    }
2161
-
2162
-
2163
-    /**
2164
-     * _set_list_table_object
2165
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2166
-     *
2167
-     * @throws InvalidInterfaceException
2168
-     * @throws InvalidArgumentException
2169
-     * @throws InvalidDataTypeException
2170
-     * @throws EE_Error
2171
-     * @throws InvalidInterfaceException
2172
-     */
2173
-    protected function _set_list_table_object()
2174
-    {
2175
-        if (isset($this->_route_config['list_table'])) {
2176
-            if (! class_exists($this->_route_config['list_table'])) {
2177
-                throw new EE_Error(
2178
-                    sprintf(
2179
-                        esc_html__(
2180
-                            '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.',
2181
-                            'event_espresso'
2182
-                        ),
2183
-                        $this->_route_config['list_table'],
2184
-                        get_class($this)
2185
-                    )
2186
-                );
2187
-            }
2188
-            $this->_list_table_object = $this->loader->getShared(
2189
-                $this->_route_config['list_table'],
2190
-                array($this)
2191
-            );
2192
-        }
2193
-    }
2194
-
2195
-
2196
-    /**
2197
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2198
-     *
2199
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2200
-     *                                                    urls.  The array should be indexed by the view it is being
2201
-     *                                                    added to.
2202
-     * @return array
2203
-     */
2204
-    public function get_list_table_view_RLs($extra_query_args = array())
2205
-    {
2206
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2207
-        if (empty($this->_views)) {
2208
-            $this->_views = array();
2209
-        }
2210
-        // cycle thru views
2211
-        foreach ($this->_views as $key => $view) {
2212
-            $query_args = array();
2213
-            // check for current view
2214
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2215
-            $query_args['action'] = $this->_req_action;
2216
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2217
-            $query_args['status'] = $view['slug'];
2218
-            // merge any other arguments sent in.
2219
-            if (isset($extra_query_args[ $view['slug'] ])) {
2220
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2221
-                    $query_args[] = $extra_query_arg;
2222
-                }
2223
-            }
2224
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2225
-        }
2226
-        return $this->_views;
2227
-    }
2228
-
2229
-
2230
-    /**
2231
-     * _entries_per_page_dropdown
2232
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2233
-     *
2234
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2235
-     *         WP does it.
2236
-     * @param int $max_entries total number of rows in the table
2237
-     * @return string
2238
-     */
2239
-    protected function _entries_per_page_dropdown($max_entries = 0)
2240
-    {
2241
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2242
-        $values = array(10, 25, 50, 100);
2243
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2244
-        if ($max_entries) {
2245
-            $values[] = $max_entries;
2246
-            sort($values);
2247
-        }
2248
-        $entries_per_page_dropdown = '
109
+	/**
110
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
+	 * actions.
112
+	 *
113
+	 * @since 4.6.x
114
+	 * @var array.
115
+	 */
116
+	protected $_default_route_query_args;
117
+
118
+	// set via request page and action args.
119
+	protected $_current_page;
120
+
121
+	protected $_current_view;
122
+
123
+	protected $_current_page_view_url;
124
+
125
+	// sanitized request action (and nonce)
126
+
127
+	/**
128
+	 * @var string $_req_action
129
+	 */
130
+	protected $_req_action;
131
+
132
+	/**
133
+	 * @var string $_req_nonce
134
+	 */
135
+	protected $_req_nonce;
136
+
137
+	// search related
138
+	protected $_search_btn_label;
139
+
140
+	protected $_search_box_callback;
141
+
142
+	/**
143
+	 * WP Current Screen object
144
+	 *
145
+	 * @var WP_Screen
146
+	 */
147
+	protected $_current_screen;
148
+
149
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
+	protected $_hook_obj;
151
+
152
+	// for holding incoming request data
153
+	protected $_req_data;
154
+
155
+	// yes / no array for admin form fields
156
+	protected $_yes_no_values = array();
157
+
158
+	// some default things shared by all child classes
159
+	protected $_default_espresso_metaboxes;
160
+
161
+	/**
162
+	 *    EE_Registry Object
163
+	 *
164
+	 * @var    EE_Registry
165
+	 */
166
+	protected $EE;
167
+
168
+
169
+	/**
170
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
171
+	 *
172
+	 * @var boolean
173
+	 */
174
+	protected $_is_caf = false;
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws InvalidArgumentException
181
+	 * @throws InvalidDataTypeException
182
+	 * @throws InvalidInterfaceException
183
+	 */
184
+	public function __construct($routing = true)
185
+	{
186
+		$this->loader = LoaderFactory::getLoader();
187
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
188
+			$this->_is_caf = true;
189
+		}
190
+		$this->_yes_no_values = array(
191
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
192
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
193
+		);
194
+		// set the _req_data property.
195
+		$this->_req_data = array_merge($_GET, $_POST);
196
+		// routing enabled?
197
+		$this->_routing = $routing;
198
+	}
199
+
200
+
201
+	/**
202
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
203
+	 * for child classes that needed to set properties prior to these methods getting called,
204
+	 * but also needed the parent class to have its construction completed as well.
205
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
206
+	 * and any complex initialization logic should only run after instantiation is complete.
207
+	 *
208
+	 * This method gets called immediately after construction from within
209
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
210
+	 *
211
+	 * @throws EE_Error
212
+	 * @throws InvalidArgumentException
213
+	 * @throws InvalidDataTypeException
214
+	 * @throws InvalidInterfaceException
215
+	 * @throws ReflectionException
216
+	 * @since $VID:$
217
+	 */
218
+	public function initializePage()
219
+	{
220
+		// set initial page props (child method)
221
+		$this->_init_page_props();
222
+		// set global defaults
223
+		$this->_set_defaults();
224
+		// set early because incoming requests could be ajax related and we need to register those hooks.
225
+		$this->_global_ajax_hooks();
226
+		$this->_ajax_hooks();
227
+		// other_page_hooks have to be early too.
228
+		$this->_do_other_page_hooks();
229
+		// This just allows us to have extending classes do something specific
230
+		// before the parent constructor runs _page_setup().
231
+		if (method_exists($this, '_before_page_setup')) {
232
+			$this->_before_page_setup();
233
+		}
234
+		// set up page dependencies
235
+		$this->_page_setup();
236
+	}
237
+
238
+
239
+	/**
240
+	 * _init_page_props
241
+	 * Child classes use to set at least the following properties:
242
+	 * $page_slug.
243
+	 * $page_label.
244
+	 *
245
+	 * @abstract
246
+	 * @return void
247
+	 */
248
+	abstract protected function _init_page_props();
249
+
250
+
251
+	/**
252
+	 * _ajax_hooks
253
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
254
+	 * Note: within the ajax callback methods.
255
+	 *
256
+	 * @abstract
257
+	 * @return void
258
+	 */
259
+	abstract protected function _ajax_hooks();
260
+
261
+
262
+	/**
263
+	 * _define_page_props
264
+	 * child classes define page properties in here.  Must include at least:
265
+	 * $_admin_base_url = base_url for all admin pages
266
+	 * $_admin_page_title = default admin_page_title for admin pages
267
+	 * $_labels = array of default labels for various automatically generated elements:
268
+	 *    array(
269
+	 *        'buttons' => array(
270
+	 *            'add' => esc_html__('label for add new button'),
271
+	 *            'edit' => esc_html__('label for edit button'),
272
+	 *            'delete' => esc_html__('label for delete button')
273
+	 *            )
274
+	 *        )
275
+	 *
276
+	 * @abstract
277
+	 * @return void
278
+	 */
279
+	abstract protected function _define_page_props();
280
+
281
+
282
+	/**
283
+	 * _set_page_routes
284
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
285
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
286
+	 * have a 'default' route. Here's the format
287
+	 * $this->_page_routes = array(
288
+	 *        'default' => array(
289
+	 *            'func' => '_default_method_handling_route',
290
+	 *            'args' => array('array','of','args'),
291
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
292
+	 *            ajax request, backend processing)
293
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
294
+	 *            headers route after.  The string you enter here should match the defined route reference for a
295
+	 *            headers sent route.
296
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
297
+	 *            this route.
298
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
299
+	 *            checks).
300
+	 *        ),
301
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
302
+	 *        handling method.
303
+	 *        )
304
+	 * )
305
+	 *
306
+	 * @abstract
307
+	 * @return void
308
+	 */
309
+	abstract protected function _set_page_routes();
310
+
311
+
312
+	/**
313
+	 * _set_page_config
314
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
315
+	 * array corresponds to the page_route for the loaded page. Format:
316
+	 * $this->_page_config = array(
317
+	 *        'default' => array(
318
+	 *            'labels' => array(
319
+	 *                'buttons' => array(
320
+	 *                    'add' => esc_html__('label for adding item'),
321
+	 *                    'edit' => esc_html__('label for editing item'),
322
+	 *                    'delete' => esc_html__('label for deleting item')
323
+	 *                ),
324
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
325
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
326
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
327
+	 *            _define_page_props() method
328
+	 *            'nav' => array(
329
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
330
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
331
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
332
+	 *                'order' => 10, //required to indicate tab position.
333
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
334
+	 *                displayed then add this parameter.
335
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
336
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
337
+	 *            metaboxes set for eventespresso admin pages.
338
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
339
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
340
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
341
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
342
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
343
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
344
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
345
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
346
+	 *            want to display.
347
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
348
+	 *                'tab_id' => array(
349
+	 *                    'title' => 'tab_title',
350
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
351
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
352
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
353
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
354
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
355
+	 *                    attempt to use the callback which should match the name of a method in the class
356
+	 *                    ),
357
+	 *                'tab2_id' => array(
358
+	 *                    'title' => 'tab2 title',
359
+	 *                    'filename' => 'file_name_2'
360
+	 *                    'callback' => 'callback_method_for_content',
361
+	 *                 ),
362
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
363
+	 *            help tab area on an admin page. @link
364
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
365
+	 *            'help_tour' => array(
366
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
367
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
368
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
369
+	 *            ),
370
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
371
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
372
+	 *            just set
373
+	 *            'require_nonce' to FALSE
374
+	 *            )
375
+	 * )
376
+	 *
377
+	 * @abstract
378
+	 * @return void
379
+	 */
380
+	abstract protected function _set_page_config();
381
+
382
+
383
+
384
+
385
+
386
+	/** end sample help_tour methods **/
387
+	/**
388
+	 * _add_screen_options
389
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
390
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
391
+	 * to a particular view.
392
+	 *
393
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
394
+	 *         see also WP_Screen object documents...
395
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
396
+	 * @abstract
397
+	 * @return void
398
+	 */
399
+	abstract protected function _add_screen_options();
400
+
401
+
402
+	/**
403
+	 * _add_feature_pointers
404
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
405
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
406
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
407
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
408
+	 * extended) also see:
409
+	 *
410
+	 * @link   http://eamann.com/tech/wordpress-portland/
411
+	 * @abstract
412
+	 * @return void
413
+	 */
414
+	abstract protected function _add_feature_pointers();
415
+
416
+
417
+	/**
418
+	 * load_scripts_styles
419
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
420
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
421
+	 * scripts/styles per view by putting them in a dynamic function in this format
422
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
423
+	 *
424
+	 * @abstract
425
+	 * @return void
426
+	 */
427
+	abstract public function load_scripts_styles();
428
+
429
+
430
+	/**
431
+	 * admin_init
432
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
433
+	 * all pages/views loaded by child class.
434
+	 *
435
+	 * @abstract
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_init();
439
+
440
+
441
+	/**
442
+	 * admin_notices
443
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
444
+	 * all pages/views loaded by child class.
445
+	 *
446
+	 * @abstract
447
+	 * @return void
448
+	 */
449
+	abstract public function admin_notices();
450
+
451
+
452
+	/**
453
+	 * admin_footer_scripts
454
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
455
+	 * will apply to all pages/views loaded by child class.
456
+	 *
457
+	 * @return void
458
+	 */
459
+	abstract public function admin_footer_scripts();
460
+
461
+
462
+	/**
463
+	 * admin_footer
464
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
465
+	 * apply to all pages/views loaded by child class.
466
+	 *
467
+	 * @return void
468
+	 */
469
+	public function admin_footer()
470
+	{
471
+	}
472
+
473
+
474
+	/**
475
+	 * _global_ajax_hooks
476
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
477
+	 * Note: within the ajax callback methods.
478
+	 *
479
+	 * @abstract
480
+	 * @return void
481
+	 */
482
+	protected function _global_ajax_hooks()
483
+	{
484
+		// for lazy loading of metabox content
485
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
486
+	}
487
+
488
+
489
+	public function ajax_metabox_content()
490
+	{
491
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
492
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
493
+		EE_Admin_Page::cached_rss_display($contentid, $url);
494
+		wp_die();
495
+	}
496
+
497
+
498
+	/**
499
+	 * _page_setup
500
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
501
+	 * doesn't match the object.
502
+	 *
503
+	 * @final
504
+	 * @return void
505
+	 * @throws EE_Error
506
+	 * @throws InvalidArgumentException
507
+	 * @throws ReflectionException
508
+	 * @throws InvalidDataTypeException
509
+	 * @throws InvalidInterfaceException
510
+	 */
511
+	final protected function _page_setup()
512
+	{
513
+		// requires?
514
+		// admin_init stuff - global - we're setting this REALLY early
515
+		// so if EE_Admin pages have to hook into other WP pages they can.
516
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
517
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
518
+		// next verify if we need to load anything...
519
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
520
+		$this->page_folder = strtolower(
521
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
522
+		);
523
+		global $ee_menu_slugs;
524
+		$ee_menu_slugs = (array) $ee_menu_slugs;
525
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
526
+			return;
527
+		}
528
+		// 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
529
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
530
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
531
+				? $this->_req_data['action2']
532
+				: $this->_req_data['action'];
533
+		}
534
+		// then set blank or -1 action values to 'default'
535
+		$this->_req_action = isset($this->_req_data['action'])
536
+							 && ! empty($this->_req_data['action'])
537
+							 && $this->_req_data['action'] !== '-1'
538
+			? sanitize_key($this->_req_data['action'])
539
+			: 'default';
540
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
541
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
542
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
543
+			? $this->_req_data['route'] : $this->_req_action;
544
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
545
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
546
+			? $this->_req_data['route']
547
+			: $this->_req_action;
548
+		$this->_current_view = $this->_req_action;
549
+		$this->_req_nonce = $this->_req_action . '_nonce';
550
+		$this->_define_page_props();
551
+		$this->_current_page_view_url = add_query_arg(
552
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
553
+			$this->_admin_base_url
554
+		);
555
+		// default things
556
+		$this->_default_espresso_metaboxes = array(
557
+			'_espresso_news_post_box',
558
+			'_espresso_links_post_box',
559
+			'_espresso_ratings_request',
560
+			'_espresso_sponsors_post_box',
561
+		);
562
+		// set page configs
563
+		$this->_set_page_routes();
564
+		$this->_set_page_config();
565
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
566
+		if (isset($this->_req_data['wp_referer'])) {
567
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
568
+		}
569
+		// for caffeinated and other extended functionality.
570
+		//  If there is a _extend_page_config method
571
+		// then let's run that to modify the all the various page configuration arrays
572
+		if (method_exists($this, '_extend_page_config')) {
573
+			$this->_extend_page_config();
574
+		}
575
+		// for CPT and other extended functionality.
576
+		// If there is an _extend_page_config_for_cpt
577
+		// then let's run that to modify all the various page configuration arrays.
578
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
579
+			$this->_extend_page_config_for_cpt();
580
+		}
581
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
582
+		$this->_page_routes = apply_filters(
583
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
584
+			$this->_page_routes,
585
+			$this
586
+		);
587
+		$this->_page_config = apply_filters(
588
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
589
+			$this->_page_config,
590
+			$this
591
+		);
592
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
593
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
594
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
595
+			add_action(
596
+				'AHEE__EE_Admin_Page__route_admin_request',
597
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
598
+				10,
599
+				2
600
+			);
601
+		}
602
+		// next route only if routing enabled
603
+		if ($this->_routing && ! defined('DOING_AJAX')) {
604
+			$this->_verify_routes();
605
+			// next let's just check user_access and kill if no access
606
+			$this->check_user_access();
607
+			if ($this->_is_UI_request) {
608
+				// admin_init stuff - global, all views for this page class, specific view
609
+				add_action('admin_init', array($this, 'admin_init'), 10);
610
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
611
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
612
+				}
613
+			} else {
614
+				// hijack regular WP loading and route admin request immediately
615
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
616
+				$this->route_admin_request();
617
+			}
618
+		}
619
+	}
620
+
621
+
622
+	/**
623
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
624
+	 *
625
+	 * @return void
626
+	 * @throws EE_Error
627
+	 */
628
+	private function _do_other_page_hooks()
629
+	{
630
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
631
+		foreach ($registered_pages as $page) {
632
+			// now let's setup the file name and class that should be present
633
+			$classname = str_replace('.class.php', '', $page);
634
+			// autoloaders should take care of loading file
635
+			if (! class_exists($classname)) {
636
+				$error_msg[] = sprintf(
637
+					esc_html__(
638
+						'Something went wrong with loading the %s admin hooks page.',
639
+						'event_espresso'
640
+					),
641
+					$page
642
+				);
643
+				$error_msg[] = $error_msg[0]
644
+							   . "\r\n"
645
+							   . sprintf(
646
+								   esc_html__(
647
+									   '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',
648
+									   'event_espresso'
649
+								   ),
650
+								   $page,
651
+								   '<br />',
652
+								   '<strong>' . $classname . '</strong>'
653
+							   );
654
+				throw new EE_Error(implode('||', $error_msg));
655
+			}
656
+			// // notice we are passing the instance of this class to the hook object.
657
+			$this->loader->getShared($classname, [$this]);
658
+		}
659
+	}
660
+
661
+
662
+	/**
663
+	 * @throws DomainException
664
+	 * @throws EE_Error
665
+	 * @throws InvalidArgumentException
666
+	 * @throws InvalidDataTypeException
667
+	 * @throws InvalidInterfaceException
668
+	 * @throws ReflectionException
669
+	 * @since $VID:$
670
+	 */
671
+	public function load_page_dependencies()
672
+	{
673
+		try {
674
+			$this->_load_page_dependencies();
675
+		} catch (EE_Error $e) {
676
+			$e->get_error();
677
+		}
678
+	}
679
+
680
+
681
+	/**
682
+	 * load_page_dependencies
683
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
684
+	 *
685
+	 * @return void
686
+	 * @throws DomainException
687
+	 * @throws EE_Error
688
+	 * @throws InvalidArgumentException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws InvalidInterfaceException
691
+	 */
692
+	protected function _load_page_dependencies()
693
+	{
694
+		// let's set the current_screen and screen options to override what WP set
695
+		$this->_current_screen = get_current_screen();
696
+		// load admin_notices - global, page class, and view specific
697
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
698
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
699
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
700
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
701
+		}
702
+		// load network admin_notices - global, page class, and view specific
703
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
704
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
705
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
706
+		}
707
+		// this will save any per_page screen options if they are present
708
+		$this->_set_per_page_screen_options();
709
+		// setup list table properties
710
+		$this->_set_list_table();
711
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
712
+		// However in some cases the metaboxes will need to be added within a route handling callback.
713
+		$this->_add_registered_meta_boxes();
714
+		$this->_add_screen_columns();
715
+		// add screen options - global, page child class, and view specific
716
+		$this->_add_global_screen_options();
717
+		$this->_add_screen_options();
718
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
719
+		if (method_exists($this, $add_screen_options)) {
720
+			$this->{$add_screen_options}();
721
+		}
722
+		// add help tab(s) and tours- set via page_config and qtips.
723
+		$this->_add_help_tour();
724
+		$this->_add_help_tabs();
725
+		$this->_add_qtips();
726
+		// add feature_pointers - global, page child class, and view specific
727
+		$this->_add_feature_pointers();
728
+		$this->_add_global_feature_pointers();
729
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
730
+		if (method_exists($this, $add_feature_pointer)) {
731
+			$this->{$add_feature_pointer}();
732
+		}
733
+		// enqueue scripts/styles - global, page class, and view specific
734
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
735
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
736
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
737
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
738
+		}
739
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
740
+		// admin_print_footer_scripts - global, page child class, and view specific.
741
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
742
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
743
+		// is a good use case. Notice the late priority we're giving these
744
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
745
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
746
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
747
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
748
+		}
749
+		// admin footer scripts
750
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
751
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
752
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
753
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
754
+		}
755
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
756
+		// targeted hook
757
+		do_action(
758
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
759
+		);
760
+	}
761
+
762
+
763
+	/**
764
+	 * _set_defaults
765
+	 * This sets some global defaults for class properties.
766
+	 */
767
+	private function _set_defaults()
768
+	{
769
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
770
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
771
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
772
+		$this->_page_config = $this->_default_route_query_args = array();
773
+		$this->_default_nav_tab_name = 'overview';
774
+		// init template args
775
+		$this->_template_args = array(
776
+			'admin_page_header'  => '',
777
+			'admin_page_content' => '',
778
+			'post_body_content'  => '',
779
+			'before_list_table'  => '',
780
+			'after_list_table'   => '',
781
+		);
782
+	}
783
+
784
+
785
+	/**
786
+	 * route_admin_request
787
+	 *
788
+	 * @see    _route_admin_request()
789
+	 * @return exception|void error
790
+	 * @throws InvalidArgumentException
791
+	 * @throws InvalidInterfaceException
792
+	 * @throws InvalidDataTypeException
793
+	 * @throws EE_Error
794
+	 * @throws ReflectionException
795
+	 */
796
+	public function route_admin_request()
797
+	{
798
+		try {
799
+			$this->_route_admin_request();
800
+		} catch (EE_Error $e) {
801
+			$e->get_error();
802
+		}
803
+	}
804
+
805
+
806
+	public function set_wp_page_slug($wp_page_slug)
807
+	{
808
+		$this->_wp_page_slug = $wp_page_slug;
809
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
810
+		if (is_network_admin()) {
811
+			$this->_wp_page_slug .= '-network';
812
+		}
813
+	}
814
+
815
+
816
+	/**
817
+	 * _verify_routes
818
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
819
+	 * we know if we need to drop out.
820
+	 *
821
+	 * @return bool
822
+	 * @throws EE_Error
823
+	 */
824
+	protected function _verify_routes()
825
+	{
826
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
827
+			return false;
828
+		}
829
+		$this->_route = false;
830
+		// check that the page_routes array is not empty
831
+		if (empty($this->_page_routes)) {
832
+			// user error msg
833
+			$error_msg = sprintf(
834
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
835
+				$this->_admin_page_title
836
+			);
837
+			// developer error msg
838
+			$error_msg .= '||' . $error_msg
839
+						  . esc_html__(
840
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
841
+							  'event_espresso'
842
+						  );
843
+			throw new EE_Error($error_msg);
844
+		}
845
+		// and that the requested page route exists
846
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
847
+			$this->_route = $this->_page_routes[ $this->_req_action ];
848
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
849
+				? $this->_page_config[ $this->_req_action ] : array();
850
+		} else {
851
+			// user error msg
852
+			$error_msg = sprintf(
853
+				esc_html__(
854
+					'The requested page route does not exist for the %s admin page.',
855
+					'event_espresso'
856
+				),
857
+				$this->_admin_page_title
858
+			);
859
+			// developer error msg
860
+			$error_msg .= '||' . $error_msg
861
+						  . sprintf(
862
+							  esc_html__(
863
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
864
+								  'event_espresso'
865
+							  ),
866
+							  $this->_req_action
867
+						  );
868
+			throw new EE_Error($error_msg);
869
+		}
870
+		// and that a default route exists
871
+		if (! array_key_exists('default', $this->_page_routes)) {
872
+			// user error msg
873
+			$error_msg = sprintf(
874
+				esc_html__(
875
+					'A default page route has not been set for the % admin page.',
876
+					'event_espresso'
877
+				),
878
+				$this->_admin_page_title
879
+			);
880
+			// developer error msg
881
+			$error_msg .= '||' . $error_msg
882
+						  . esc_html__(
883
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
884
+							  'event_espresso'
885
+						  );
886
+			throw new EE_Error($error_msg);
887
+		}
888
+
889
+		// first lets' catch if the UI request has EVER been set.
890
+		if ($this->_is_UI_request === null) {
891
+			// lets set if this is a UI request or not.
892
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
893
+			// wait a minute... we might have a noheader in the route array
894
+			$this->_is_UI_request = is_array($this->_route)
895
+									&& isset($this->_route['noheader'])
896
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
897
+		}
898
+		$this->_set_current_labels();
899
+		return true;
900
+	}
901
+
902
+
903
+	/**
904
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
905
+	 *
906
+	 * @param  string $route the route name we're verifying
907
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
908
+	 * @throws EE_Error
909
+	 */
910
+	protected function _verify_route($route)
911
+	{
912
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
913
+			return true;
914
+		}
915
+		// user error msg
916
+		$error_msg = sprintf(
917
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
918
+			$this->_admin_page_title
919
+		);
920
+		// developer error msg
921
+		$error_msg .= '||' . $error_msg
922
+					  . sprintf(
923
+						  esc_html__(
924
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
925
+							  'event_espresso'
926
+						  ),
927
+						  $route
928
+					  );
929
+		throw new EE_Error($error_msg);
930
+	}
931
+
932
+
933
+	/**
934
+	 * perform nonce verification
935
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
936
+	 * using this method (and save retyping!)
937
+	 *
938
+	 * @param string $nonce     The nonce sent
939
+	 * @param string $nonce_ref The nonce reference string (name0)
940
+	 * @return void
941
+	 * @throws EE_Error
942
+	 * @throws InvalidArgumentException
943
+	 * @throws InvalidDataTypeException
944
+	 * @throws InvalidInterfaceException
945
+	 */
946
+	protected function _verify_nonce($nonce, $nonce_ref)
947
+	{
948
+		// verify nonce against expected value
949
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
950
+			// these are not the droids you are looking for !!!
951
+			$msg = sprintf(
952
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
953
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
954
+				'</a>'
955
+			);
956
+			if (WP_DEBUG) {
957
+				$msg .= "\n  "
958
+						. sprintf(
959
+							esc_html__(
960
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
961
+								'event_espresso'
962
+							),
963
+							EE_Admin_Page::class
964
+						);
965
+			}
966
+			if (! defined('DOING_AJAX')) {
967
+				wp_die($msg);
968
+			} else {
969
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
970
+				$this->_return_json();
971
+			}
972
+		}
973
+	}
974
+
975
+
976
+	/**
977
+	 * _route_admin_request()
978
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
979
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
980
+	 * in the page routes and then will try to load the corresponding method.
981
+	 *
982
+	 * @return void
983
+	 * @throws EE_Error
984
+	 * @throws InvalidArgumentException
985
+	 * @throws InvalidDataTypeException
986
+	 * @throws InvalidInterfaceException
987
+	 * @throws ReflectionException
988
+	 */
989
+	protected function _route_admin_request()
990
+	{
991
+		if (! $this->_is_UI_request) {
992
+			$this->_verify_routes();
993
+		}
994
+		$nonce_check = isset($this->_route_config['require_nonce'])
995
+			? $this->_route_config['require_nonce']
996
+			: true;
997
+		if ($this->_req_action !== 'default' && $nonce_check) {
998
+			// set nonce from post data
999
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
1000
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1001
+				: '';
1002
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1003
+		}
1004
+		// set the nav_tabs array but ONLY if this is  UI_request
1005
+		if ($this->_is_UI_request) {
1006
+			$this->_set_nav_tabs();
1007
+		}
1008
+		// grab callback function
1009
+		$func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1010
+		// check if callback has args
1011
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1012
+		$error_msg = '';
1013
+		// action right before calling route
1014
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1015
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1016
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1017
+		}
1018
+		// right before calling the route, let's remove _wp_http_referer from the
1019
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1020
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
1021
+			'_wp_http_referer',
1022
+			wp_unslash($_SERVER['REQUEST_URI'])
1023
+		);
1024
+		if (! empty($func)) {
1025
+			if (is_array($func)) {
1026
+				list($class, $method) = $func;
1027
+			} elseif (strpos($func, '::') !== false) {
1028
+				list($class, $method) = explode('::', $func);
1029
+			} else {
1030
+				$class = $this;
1031
+				$method = $func;
1032
+			}
1033
+			if (! (is_object($class) && $class === $this)) {
1034
+				// send along this admin page object for access by addons.
1035
+				$args['admin_page_object'] = $this;
1036
+			}
1037
+			// is it a method on a class that doesn't work?
1038
+			if (((method_exists($class, $method)
1039
+				  && call_user_func_array(array($class, $method), $args) === false)
1040
+				 && (// is it a standalone function that doesn't work?
1041
+					 function_exists($method)
1042
+					 && call_user_func_array(
1043
+						 $func,
1044
+						 array_merge(array('admin_page_object' => $this), $args)
1045
+					 ) === false
1046
+				 )) || (// is it neither a class method NOR a standalone function?
1047
+					! function_exists($method)
1048
+					&& ! method_exists($class, $method)
1049
+				)
1050
+			) {
1051
+				// user error msg
1052
+				$error_msg = esc_html__(
1053
+					'An error occurred. The  requested page route could not be found.',
1054
+					'event_espresso'
1055
+				);
1056
+				// developer error msg
1057
+				$error_msg .= '||';
1058
+				$error_msg .= sprintf(
1059
+					esc_html__(
1060
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1061
+						'event_espresso'
1062
+					),
1063
+					$method
1064
+				);
1065
+			}
1066
+			if (! empty($error_msg)) {
1067
+				throw new EE_Error($error_msg);
1068
+			}
1069
+		}
1070
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1071
+		// then we need to reset the routing properties to the new route.
1072
+		// 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.
1073
+		if ($this->_is_UI_request === false
1074
+			&& is_array($this->_route)
1075
+			&& ! empty($this->_route['headers_sent_route'])
1076
+		) {
1077
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1078
+		}
1079
+	}
1080
+
1081
+
1082
+	/**
1083
+	 * This method just allows the resetting of page properties in the case where a no headers
1084
+	 * route redirects to a headers route in its route config.
1085
+	 *
1086
+	 * @since   4.3.0
1087
+	 * @param  string $new_route New (non header) route to redirect to.
1088
+	 * @return   void
1089
+	 * @throws ReflectionException
1090
+	 * @throws InvalidArgumentException
1091
+	 * @throws InvalidInterfaceException
1092
+	 * @throws InvalidDataTypeException
1093
+	 * @throws EE_Error
1094
+	 */
1095
+	protected function _reset_routing_properties($new_route)
1096
+	{
1097
+		$this->_is_UI_request = true;
1098
+		// now we set the current route to whatever the headers_sent_route is set at
1099
+		$this->_req_data['action'] = $new_route;
1100
+		// rerun page setup
1101
+		$this->_page_setup();
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * _add_query_arg
1107
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1108
+	 *(internally just uses EEH_URL's function with the same name)
1109
+	 *
1110
+	 * @param array  $args
1111
+	 * @param string $url
1112
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1113
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1114
+	 *                                        Example usage: If the current page is:
1115
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1116
+	 *                                        &action=default&event_id=20&month_range=March%202015
1117
+	 *                                        &_wpnonce=5467821
1118
+	 *                                        and you call:
1119
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1120
+	 *                                        array(
1121
+	 *                                        'action' => 'resend_something',
1122
+	 *                                        'page=>espresso_registrations'
1123
+	 *                                        ),
1124
+	 *                                        $some_url,
1125
+	 *                                        true
1126
+	 *                                        );
1127
+	 *                                        It will produce a url in this structure:
1128
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1129
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1130
+	 *                                        month_range]=March%202015
1131
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1132
+	 * @return string
1133
+	 */
1134
+	public static function add_query_args_and_nonce(
1135
+		$args = array(),
1136
+		$url = '',
1137
+		$sticky = false,
1138
+		$exclude_nonce = false
1139
+	) {
1140
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1141
+		if ($sticky) {
1142
+			$request = $_REQUEST;
1143
+			unset($request['_wp_http_referer'], $request['wp_referer']);
1144
+			foreach ($request as $key => $value) {
1145
+				// do not add nonces
1146
+				if (strpos($key, 'nonce') !== false) {
1147
+					continue;
1148
+				}
1149
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1150
+			}
1151
+		}
1152
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1153
+	}
1154
+
1155
+
1156
+	/**
1157
+	 * This returns a generated link that will load the related help tab.
1158
+	 *
1159
+	 * @param  string $help_tab_id the id for the connected help tab
1160
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1161
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1162
+	 * @uses EEH_Template::get_help_tab_link()
1163
+	 * @return string              generated link
1164
+	 */
1165
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1166
+	{
1167
+		return EEH_Template::get_help_tab_link(
1168
+			$help_tab_id,
1169
+			$this->page_slug,
1170
+			$this->_req_action,
1171
+			$icon_style,
1172
+			$help_text
1173
+		);
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 * _add_help_tabs
1179
+	 * Note child classes define their help tabs within the page_config array.
1180
+	 *
1181
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1182
+	 * @return void
1183
+	 * @throws DomainException
1184
+	 * @throws EE_Error
1185
+	 */
1186
+	protected function _add_help_tabs()
1187
+	{
1188
+		$tour_buttons = '';
1189
+		if (isset($this->_page_config[ $this->_req_action ])) {
1190
+			$config = $this->_page_config[ $this->_req_action ];
1191
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1192
+			if (isset($this->_help_tour[ $this->_req_action ])) {
1193
+				$tb = array();
1194
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1195
+				foreach ($this->_help_tour['tours'] as $tour) {
1196
+					// if this is the end tour then we don't need to setup a button
1197
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1198
+						continue;
1199
+					}
1200
+					$tb[] = '<button id="trigger-tour-'
1201
+							. $tour->get_slug()
1202
+							. '" class="button-primary trigger-ee-help-tour">'
1203
+							. $tour->get_label()
1204
+							. '</button>';
1205
+				}
1206
+				$tour_buttons .= implode('<br />', $tb);
1207
+				$tour_buttons .= '</div></div>';
1208
+			}
1209
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1210
+			if (is_array($config) && isset($config['help_sidebar'])) {
1211
+				// check that the callback given is valid
1212
+				if (! method_exists($this, $config['help_sidebar'])) {
1213
+					throw new EE_Error(
1214
+						sprintf(
1215
+							esc_html__(
1216
+								'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',
1217
+								'event_espresso'
1218
+							),
1219
+							$config['help_sidebar'],
1220
+							get_class($this)
1221
+						)
1222
+					);
1223
+				}
1224
+				$content = apply_filters(
1225
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1226
+					$this->{$config['help_sidebar']}()
1227
+				);
1228
+				$content .= $tour_buttons; // add help tour buttons.
1229
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1230
+				$this->_current_screen->set_help_sidebar($content);
1231
+			}
1232
+			// if there ARE tour buttons...
1233
+			if (! empty($tour_buttons)) {
1234
+				// if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1235
+				if (! isset($config['help_sidebar'])) {
1236
+					$this->_current_screen->set_help_sidebar($tour_buttons);
1237
+				}
1238
+				// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1239
+				if (! isset($config['help_tabs'])) {
1240
+					$_ht['id'] = $this->page_slug;
1241
+					$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1242
+					$_ht['content'] = '<p>'
1243
+									  . esc_html__(
1244
+										  'The buttons to the right allow you to start/restart any help tours available for this page',
1245
+										  'event_espresso'
1246
+									  ) . '</p>';
1247
+					$this->_current_screen->add_help_tab($_ht);
1248
+				}
1249
+			}
1250
+			if (! isset($config['help_tabs'])) {
1251
+				return;
1252
+			} //no help tabs for this route
1253
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1254
+				// we're here so there ARE help tabs!
1255
+				// make sure we've got what we need
1256
+				if (! isset($cfg['title'])) {
1257
+					throw new EE_Error(
1258
+						esc_html__(
1259
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1260
+							'event_espresso'
1261
+						)
1262
+					);
1263
+				}
1264
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1265
+					throw new EE_Error(
1266
+						esc_html__(
1267
+							'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',
1268
+							'event_espresso'
1269
+						)
1270
+					);
1271
+				}
1272
+				// first priority goes to content.
1273
+				if (! empty($cfg['content'])) {
1274
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1275
+					// second priority goes to filename
1276
+				} elseif (! empty($cfg['filename'])) {
1277
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1278
+					// 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)
1279
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1280
+															 . basename($this->_get_dir())
1281
+															 . '/help_tabs/'
1282
+															 . $cfg['filename']
1283
+															 . '.help_tab.php' : $file_path;
1284
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1285
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1286
+						EE_Error::add_error(
1287
+							sprintf(
1288
+								esc_html__(
1289
+									'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',
1290
+									'event_espresso'
1291
+								),
1292
+								$tab_id,
1293
+								key($config),
1294
+								$file_path
1295
+							),
1296
+							__FILE__,
1297
+							__FUNCTION__,
1298
+							__LINE__
1299
+						);
1300
+						return;
1301
+					}
1302
+					$template_args['admin_page_obj'] = $this;
1303
+					$content = EEH_Template::display_template(
1304
+						$file_path,
1305
+						$template_args,
1306
+						true
1307
+					);
1308
+				} else {
1309
+					$content = '';
1310
+				}
1311
+				// check if callback is valid
1312
+				if (empty($content) && (
1313
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1314
+					)
1315
+				) {
1316
+					EE_Error::add_error(
1317
+						sprintf(
1318
+							esc_html__(
1319
+								'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.',
1320
+								'event_espresso'
1321
+							),
1322
+							$cfg['title']
1323
+						),
1324
+						__FILE__,
1325
+						__FUNCTION__,
1326
+						__LINE__
1327
+					);
1328
+					return;
1329
+				}
1330
+				// setup config array for help tab method
1331
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1332
+				$_ht = array(
1333
+					'id'       => $id,
1334
+					'title'    => $cfg['title'],
1335
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1336
+					'content'  => $content,
1337
+				);
1338
+				$this->_current_screen->add_help_tab($_ht);
1339
+			}
1340
+		}
1341
+	}
1342
+
1343
+
1344
+	/**
1345
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1346
+	 * an array with properties for setting up usage of the joyride plugin
1347
+	 *
1348
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1349
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1350
+	 *         _set_page_config() comments
1351
+	 * @return void
1352
+	 * @throws EE_Error
1353
+	 * @throws InvalidArgumentException
1354
+	 * @throws InvalidDataTypeException
1355
+	 * @throws InvalidInterfaceException
1356
+	 */
1357
+	protected function _add_help_tour()
1358
+	{
1359
+		$tours = array();
1360
+		$this->_help_tour = array();
1361
+		// exit early if help tours are turned off globally
1362
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1363
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1364
+		) {
1365
+			return;
1366
+		}
1367
+		// loop through _page_config to find any help_tour defined
1368
+		foreach ($this->_page_config as $route => $config) {
1369
+			// we're only going to set things up for this route
1370
+			if ($route !== $this->_req_action) {
1371
+				continue;
1372
+			}
1373
+			if (isset($config['help_tour'])) {
1374
+				foreach ($config['help_tour'] as $tour) {
1375
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1376
+					// let's see if we can get that file...
1377
+					// if not its possible this is a decaf route not set in caffeinated
1378
+					// so lets try and get the caffeinated equivalent
1379
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1380
+															 . basename($this->_get_dir())
1381
+															 . '/help_tours/'
1382
+															 . $tour
1383
+															 . '.class.php' : $file_path;
1384
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1385
+					if (! is_readable($file_path)) {
1386
+						EE_Error::add_error(
1387
+							sprintf(
1388
+								esc_html__(
1389
+									'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',
1390
+									'event_espresso'
1391
+								),
1392
+								$file_path,
1393
+								$tour
1394
+							),
1395
+							__FILE__,
1396
+							__FUNCTION__,
1397
+							__LINE__
1398
+						);
1399
+						return;
1400
+					}
1401
+					require_once $file_path;
1402
+					if (! class_exists($tour)) {
1403
+						$error_msg = [];
1404
+						$error_msg[] = sprintf(
1405
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1406
+							$tour
1407
+						);
1408
+						$error_msg[] = $error_msg[0] . "\r\n"
1409
+									   . sprintf(
1410
+										   esc_html__(
1411
+											   '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.',
1412
+											   'event_espresso'
1413
+										   ),
1414
+										   $tour,
1415
+										   '<br />',
1416
+										   $tour,
1417
+										   $this->_req_action,
1418
+										   get_class($this)
1419
+									   );
1420
+						throw new EE_Error(implode('||', $error_msg));
1421
+					}
1422
+					$tour_obj = new $tour($this->_is_caf);
1423
+					$tours[] = $tour_obj;
1424
+					$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1425
+				}
1426
+				// let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1427
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1428
+				$tours[] = $end_stop_tour;
1429
+				$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1430
+			}
1431
+		}
1432
+
1433
+		if (! empty($tours)) {
1434
+			$this->_help_tour['tours'] = $tours;
1435
+		}
1436
+		// that's it!  Now that the $_help_tours property is set (or not)
1437
+		// the scripts and html should be taken care of automatically.
1438
+
1439
+		/**
1440
+		 * Allow extending the help tours variable.
1441
+		 *
1442
+		 * @param Array $_help_tour The array containing all help tour information to be displayed.
1443
+		 */
1444
+		$this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1445
+	}
1446
+
1447
+
1448
+	/**
1449
+	 * This simply sets up any qtips that have been defined in the page config
1450
+	 *
1451
+	 * @return void
1452
+	 */
1453
+	protected function _add_qtips()
1454
+	{
1455
+		if (isset($this->_route_config['qtips'])) {
1456
+			$qtips = (array) $this->_route_config['qtips'];
1457
+			// load qtip loader
1458
+			$path = array(
1459
+				$this->_get_dir() . '/qtips/',
1460
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1461
+			);
1462
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1463
+		}
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * _set_nav_tabs
1469
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1470
+	 * wish to add additional tabs or modify accordingly.
1471
+	 *
1472
+	 * @return void
1473
+	 * @throws InvalidArgumentException
1474
+	 * @throws InvalidInterfaceException
1475
+	 * @throws InvalidDataTypeException
1476
+	 */
1477
+	protected function _set_nav_tabs()
1478
+	{
1479
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1480
+		$i = 0;
1481
+		foreach ($this->_page_config as $slug => $config) {
1482
+			if (! is_array($config)
1483
+				|| (
1484
+					is_array($config)
1485
+					&& (
1486
+						(isset($config['nav']) && ! $config['nav'])
1487
+						|| ! isset($config['nav'])
1488
+					)
1489
+				)
1490
+			) {
1491
+				continue;
1492
+			}
1493
+			// no nav tab for this config
1494
+			// check for persistent flag
1495
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1496
+				// nav tab is only to appear when route requested.
1497
+				continue;
1498
+			}
1499
+			if (! $this->check_user_access($slug, true)) {
1500
+				// no nav tab because current user does not have access.
1501
+				continue;
1502
+			}
1503
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1504
+			$this->_nav_tabs[ $slug ] = array(
1505
+				'url'       => isset($config['nav']['url'])
1506
+					? $config['nav']['url']
1507
+					: EE_Admin_Page::add_query_args_and_nonce(
1508
+						array('action' => $slug),
1509
+						$this->_admin_base_url
1510
+					),
1511
+				'link_text' => isset($config['nav']['label'])
1512
+					? $config['nav']['label']
1513
+					: ucwords(
1514
+						str_replace('_', ' ', $slug)
1515
+					),
1516
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1517
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1518
+			);
1519
+			$i++;
1520
+		}
1521
+		// if $this->_nav_tabs is empty then lets set the default
1522
+		if (empty($this->_nav_tabs)) {
1523
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1524
+				'url'       => $this->_admin_base_url,
1525
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1526
+				'css_class' => 'nav-tab-active',
1527
+				'order'     => 10,
1528
+			);
1529
+		}
1530
+		// now let's sort the tabs according to order
1531
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1532
+	}
1533
+
1534
+
1535
+	/**
1536
+	 * _set_current_labels
1537
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1538
+	 * property array
1539
+	 *
1540
+	 * @return void
1541
+	 */
1542
+	private function _set_current_labels()
1543
+	{
1544
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1545
+			foreach ($this->_route_config['labels'] as $label => $text) {
1546
+				if (is_array($text)) {
1547
+					foreach ($text as $sublabel => $subtext) {
1548
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1549
+					}
1550
+				} else {
1551
+					$this->_labels[ $label ] = $text;
1552
+				}
1553
+			}
1554
+		}
1555
+	}
1556
+
1557
+
1558
+	/**
1559
+	 *        verifies user access for this admin page
1560
+	 *
1561
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1562
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1563
+	 *                               return false if verify fail.
1564
+	 * @return bool
1565
+	 * @throws InvalidArgumentException
1566
+	 * @throws InvalidDataTypeException
1567
+	 * @throws InvalidInterfaceException
1568
+	 */
1569
+	public function check_user_access($route_to_check = '', $verify_only = false)
1570
+	{
1571
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1572
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1573
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1574
+					  && is_array(
1575
+						  $this->_page_routes[ $route_to_check ]
1576
+					  )
1577
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1578
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1579
+		if (empty($capability) && empty($route_to_check)) {
1580
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1581
+				: $this->_route['capability'];
1582
+		} else {
1583
+			$capability = empty($capability) ? 'manage_options' : $capability;
1584
+		}
1585
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1586
+		if (! defined('DOING_AJAX')
1587
+			&& (
1588
+				! function_exists('is_admin')
1589
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1590
+					$capability,
1591
+					$this->page_slug
1592
+					. '_'
1593
+					. $route_to_check,
1594
+					$id
1595
+				)
1596
+			)
1597
+		) {
1598
+			if ($verify_only) {
1599
+				return false;
1600
+			}
1601
+			if (is_user_logged_in()) {
1602
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1603
+			} else {
1604
+				return false;
1605
+			}
1606
+		}
1607
+		return true;
1608
+	}
1609
+
1610
+
1611
+	/**
1612
+	 * admin_init_global
1613
+	 * This runs all the code that we want executed within the WP admin_init hook.
1614
+	 * This method executes for ALL EE Admin pages.
1615
+	 *
1616
+	 * @return void
1617
+	 */
1618
+	public function admin_init_global()
1619
+	{
1620
+	}
1621
+
1622
+
1623
+	/**
1624
+	 * wp_loaded_global
1625
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1626
+	 * EE_Admin page and will execute on every EE Admin Page load
1627
+	 *
1628
+	 * @return void
1629
+	 */
1630
+	public function wp_loaded()
1631
+	{
1632
+	}
1633
+
1634
+
1635
+	/**
1636
+	 * admin_notices
1637
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1638
+	 * ALL EE_Admin pages.
1639
+	 *
1640
+	 * @return void
1641
+	 */
1642
+	public function admin_notices_global()
1643
+	{
1644
+		$this->_display_no_javascript_warning();
1645
+		$this->_display_espresso_notices();
1646
+	}
1647
+
1648
+
1649
+	public function network_admin_notices_global()
1650
+	{
1651
+		$this->_display_no_javascript_warning();
1652
+		$this->_display_espresso_notices();
1653
+	}
1654
+
1655
+
1656
+	/**
1657
+	 * admin_footer_scripts_global
1658
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1659
+	 * will apply on ALL EE_Admin pages.
1660
+	 *
1661
+	 * @return void
1662
+	 */
1663
+	public function admin_footer_scripts_global()
1664
+	{
1665
+		$this->_add_admin_page_ajax_loading_img();
1666
+		$this->_add_admin_page_overlay();
1667
+		// if metaboxes are present we need to add the nonce field
1668
+		if (isset($this->_route_config['metaboxes'])
1669
+			|| isset($this->_route_config['list_table'])
1670
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1671
+		) {
1672
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1673
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1674
+		}
1675
+	}
1676
+
1677
+
1678
+	/**
1679
+	 * admin_footer_global
1680
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1681
+	 * This particular method will apply on ALL EE_Admin Pages.
1682
+	 *
1683
+	 * @return void
1684
+	 * @throws InvalidArgumentException
1685
+	 * @throws InvalidDataTypeException
1686
+	 * @throws InvalidInterfaceException
1687
+	 */
1688
+	public function admin_footer_global()
1689
+	{
1690
+		// dialog container for dialog helper
1691
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1692
+		$d_cont .= '<div class="ee-notices"></div>';
1693
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1694
+		$d_cont .= '</div>';
1695
+		echo $d_cont;
1696
+		// help tour stuff?
1697
+		if (isset($this->_help_tour[ $this->_req_action ])) {
1698
+			echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1699
+		}
1700
+		// current set timezone for timezone js
1701
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1702
+	}
1703
+
1704
+
1705
+	/**
1706
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1707
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1708
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1709
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1710
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1711
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1712
+	 * for the
1713
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1714
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1715
+	 *    'help_trigger_id' => array(
1716
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1717
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1718
+	 *    )
1719
+	 * );
1720
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1721
+	 *
1722
+	 * @param array $help_array
1723
+	 * @param bool  $display
1724
+	 * @return string content
1725
+	 * @throws DomainException
1726
+	 * @throws EE_Error
1727
+	 */
1728
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1729
+	{
1730
+		$content = '';
1731
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1732
+		// loop through the array and setup content
1733
+		foreach ($help_array as $trigger => $help) {
1734
+			// make sure the array is setup properly
1735
+			if (! isset($help['title'], $help['content'])) {
1736
+				throw new EE_Error(
1737
+					esc_html__(
1738
+						'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',
1739
+						'event_espresso'
1740
+					)
1741
+				);
1742
+			}
1743
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1744
+			$template_args = array(
1745
+				'help_popup_id'      => $trigger,
1746
+				'help_popup_title'   => $help['title'],
1747
+				'help_popup_content' => $help['content'],
1748
+			);
1749
+			$content .= EEH_Template::display_template(
1750
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1751
+				$template_args,
1752
+				true
1753
+			);
1754
+		}
1755
+		if ($display) {
1756
+			echo $content;
1757
+			return '';
1758
+		}
1759
+		return $content;
1760
+	}
1761
+
1762
+
1763
+	/**
1764
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1765
+	 *
1766
+	 * @return array properly formatted array for help popup content
1767
+	 * @throws EE_Error
1768
+	 */
1769
+	private function _get_help_content()
1770
+	{
1771
+		// what is the method we're looking for?
1772
+		$method_name = '_help_popup_content_' . $this->_req_action;
1773
+		// if method doesn't exist let's get out.
1774
+		if (! method_exists($this, $method_name)) {
1775
+			return array();
1776
+		}
1777
+		// k we're good to go let's retrieve the help array
1778
+		$help_array = $this->{$method_name}();
1779
+		// make sure we've got an array!
1780
+		if (! is_array($help_array)) {
1781
+			throw new EE_Error(
1782
+				esc_html__(
1783
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1784
+					'event_espresso'
1785
+				)
1786
+			);
1787
+		}
1788
+		return $help_array;
1789
+	}
1790
+
1791
+
1792
+	/**
1793
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1794
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1795
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1796
+	 *
1797
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1798
+	 * @param boolean $display    if false then we return the trigger string
1799
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1800
+	 * @return string
1801
+	 * @throws DomainException
1802
+	 * @throws EE_Error
1803
+	 */
1804
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1805
+	{
1806
+		if (defined('DOING_AJAX')) {
1807
+			return '';
1808
+		}
1809
+		// 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
1810
+		$help_array = $this->_get_help_content();
1811
+		$help_content = '';
1812
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1813
+			$help_array[ $trigger_id ] = array(
1814
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1815
+				'content' => esc_html__(
1816
+					'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.)',
1817
+					'event_espresso'
1818
+				),
1819
+			);
1820
+			$help_content = $this->_set_help_popup_content($help_array);
1821
+		}
1822
+		// let's setup the trigger
1823
+		$content = '<a class="ee-dialog" href="?height='
1824
+				   . $dimensions[0]
1825
+				   . '&width='
1826
+				   . $dimensions[1]
1827
+				   . '&inlineId='
1828
+				   . $trigger_id
1829
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1830
+		$content .= $help_content;
1831
+		if ($display) {
1832
+			echo $content;
1833
+			return '';
1834
+		}
1835
+		return $content;
1836
+	}
1837
+
1838
+
1839
+	/**
1840
+	 * _add_global_screen_options
1841
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1842
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1843
+	 *
1844
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1845
+	 *         see also WP_Screen object documents...
1846
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1847
+	 * @abstract
1848
+	 * @return void
1849
+	 */
1850
+	private function _add_global_screen_options()
1851
+	{
1852
+	}
1853
+
1854
+
1855
+	/**
1856
+	 * _add_global_feature_pointers
1857
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1858
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1859
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1860
+	 *
1861
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1862
+	 *         extended) also see:
1863
+	 * @link   http://eamann.com/tech/wordpress-portland/
1864
+	 * @abstract
1865
+	 * @return void
1866
+	 */
1867
+	private function _add_global_feature_pointers()
1868
+	{
1869
+	}
1870
+
1871
+
1872
+	/**
1873
+	 * load_global_scripts_styles
1874
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1875
+	 *
1876
+	 * @return void
1877
+	 * @throws EE_Error
1878
+	 */
1879
+	public function load_global_scripts_styles()
1880
+	{
1881
+		/** STYLES **/
1882
+		// add debugging styles
1883
+		if (WP_DEBUG) {
1884
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1885
+		}
1886
+		// register all styles
1887
+		wp_register_style(
1888
+			'espresso-ui-theme',
1889
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1890
+			array(),
1891
+			EVENT_ESPRESSO_VERSION
1892
+		);
1893
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1894
+		// helpers styles
1895
+		wp_register_style(
1896
+			'ee-text-links',
1897
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1898
+			array(),
1899
+			EVENT_ESPRESSO_VERSION
1900
+		);
1901
+		/** SCRIPTS **/
1902
+		// register all scripts
1903
+		wp_register_script(
1904
+			'ee-dialog',
1905
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1906
+			array('jquery', 'jquery-ui-draggable'),
1907
+			EVENT_ESPRESSO_VERSION,
1908
+			true
1909
+		);
1910
+		wp_register_script(
1911
+			'ee_admin_js',
1912
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1913
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1914
+			EVENT_ESPRESSO_VERSION,
1915
+			true
1916
+		);
1917
+		wp_register_script(
1918
+			'jquery-ui-timepicker-addon',
1919
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1920
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1921
+			EVENT_ESPRESSO_VERSION,
1922
+			true
1923
+		);
1924
+		if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1925
+			add_filter('FHEE_load_joyride', '__return_true');
1926
+		}
1927
+		// script for sorting tables
1928
+		wp_register_script(
1929
+			'espresso_ajax_table_sorting',
1930
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1931
+			array('ee_admin_js', 'jquery-ui-sortable'),
1932
+			EVENT_ESPRESSO_VERSION,
1933
+			true
1934
+		);
1935
+		// script for parsing uri's
1936
+		wp_register_script(
1937
+			'ee-parse-uri',
1938
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1939
+			array(),
1940
+			EVENT_ESPRESSO_VERSION,
1941
+			true
1942
+		);
1943
+		// and parsing associative serialized form elements
1944
+		wp_register_script(
1945
+			'ee-serialize-full-array',
1946
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1947
+			array('jquery'),
1948
+			EVENT_ESPRESSO_VERSION,
1949
+			true
1950
+		);
1951
+		// helpers scripts
1952
+		wp_register_script(
1953
+			'ee-text-links',
1954
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1955
+			array('jquery'),
1956
+			EVENT_ESPRESSO_VERSION,
1957
+			true
1958
+		);
1959
+		wp_register_script(
1960
+			'ee-moment-core',
1961
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1962
+			array(),
1963
+			EVENT_ESPRESSO_VERSION,
1964
+			true
1965
+		);
1966
+		wp_register_script(
1967
+			'ee-moment',
1968
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1969
+			array('ee-moment-core'),
1970
+			EVENT_ESPRESSO_VERSION,
1971
+			true
1972
+		);
1973
+		wp_register_script(
1974
+			'ee-datepicker',
1975
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1976
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1977
+			EVENT_ESPRESSO_VERSION,
1978
+			true
1979
+		);
1980
+		// google charts
1981
+		wp_register_script(
1982
+			'google-charts',
1983
+			'https://www.gstatic.com/charts/loader.js',
1984
+			array(),
1985
+			EVENT_ESPRESSO_VERSION
1986
+		);
1987
+		// ENQUEUE ALL BASICS BY DEFAULT
1988
+		wp_enqueue_style('ee-admin-css');
1989
+		wp_enqueue_script('ee_admin_js');
1990
+		wp_enqueue_script('jquery-validate');
1991
+		// taking care of metaboxes
1992
+		if (empty($this->_cpt_route)
1993
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1994
+		) {
1995
+			wp_enqueue_script('dashboard');
1996
+		}
1997
+		// LOCALIZED DATA
1998
+		// localize script for ajax lazy loading
1999
+		$lazy_loader_container_ids = apply_filters(
2000
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2001
+			array('espresso_news_post_box_content')
2002
+		);
2003
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2004
+		/**
2005
+		 * help tour stuff
2006
+		 */
2007
+		if (! empty($this->_help_tour)) {
2008
+			// register the js for kicking things off
2009
+			wp_enqueue_script(
2010
+				'ee-help-tour',
2011
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
2012
+				array('jquery-joyride'),
2013
+				EVENT_ESPRESSO_VERSION,
2014
+				true
2015
+			);
2016
+			$tours = array();
2017
+			// setup tours for the js tour object
2018
+			foreach ($this->_help_tour['tours'] as $tour) {
2019
+				if ($tour instanceof EE_Help_Tour) {
2020
+					$tours[] = array(
2021
+						'id'      => $tour->get_slug(),
2022
+						'options' => $tour->get_options(),
2023
+					);
2024
+				}
2025
+			}
2026
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2027
+			// admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2028
+		}
2029
+	}
2030
+
2031
+
2032
+	/**
2033
+	 *        admin_footer_scripts_eei18n_js_strings
2034
+	 *
2035
+	 * @return        void
2036
+	 */
2037
+	public function admin_footer_scripts_eei18n_js_strings()
2038
+	{
2039
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2040
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2041
+			'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!!!',
2042
+			'event_espresso'
2043
+		);
2044
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2045
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2046
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2047
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2048
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2049
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2050
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2051
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2052
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2053
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2054
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2055
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2056
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2057
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2058
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2059
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2060
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2061
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2062
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2063
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2064
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2065
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2066
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2067
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2068
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2069
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2070
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2071
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2072
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2073
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2074
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2075
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2076
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2077
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2078
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2079
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2080
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2081
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2082
+	}
2083
+
2084
+
2085
+	/**
2086
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2087
+	 *
2088
+	 * @return        void
2089
+	 */
2090
+	public function add_xdebug_style()
2091
+	{
2092
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2093
+	}
2094
+
2095
+
2096
+	/************************/
2097
+	/** LIST TABLE METHODS **/
2098
+	/************************/
2099
+	/**
2100
+	 * this sets up the list table if the current view requires it.
2101
+	 *
2102
+	 * @return void
2103
+	 * @throws EE_Error
2104
+	 * @throws InvalidArgumentException
2105
+	 * @throws InvalidDataTypeException
2106
+	 * @throws InvalidInterfaceException
2107
+	 */
2108
+	protected function _set_list_table()
2109
+	{
2110
+		// first is this a list_table view?
2111
+		if (! isset($this->_route_config['list_table'])) {
2112
+			return;
2113
+		} //not a list_table view so get out.
2114
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2115
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2116
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2117
+			// user error msg
2118
+			$error_msg = esc_html__(
2119
+				'An error occurred. The requested list table views could not be found.',
2120
+				'event_espresso'
2121
+			);
2122
+			// developer error msg
2123
+			$error_msg .= '||'
2124
+						  . sprintf(
2125
+							  esc_html__(
2126
+								  '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.',
2127
+								  'event_espresso'
2128
+							  ),
2129
+							  $this->_req_action,
2130
+							  $list_table_view
2131
+						  );
2132
+			throw new EE_Error($error_msg);
2133
+		}
2134
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2135
+		$this->_views = apply_filters(
2136
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2137
+			$this->_views
2138
+		);
2139
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2140
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2141
+		$this->_set_list_table_view();
2142
+		$this->_set_list_table_object();
2143
+	}
2144
+
2145
+
2146
+	/**
2147
+	 * set current view for List Table
2148
+	 *
2149
+	 * @return void
2150
+	 */
2151
+	protected function _set_list_table_view()
2152
+	{
2153
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2154
+		// looking at active items or dumpster diving ?
2155
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2156
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2157
+		} else {
2158
+			$this->_view = sanitize_key($this->_req_data['status']);
2159
+		}
2160
+	}
2161
+
2162
+
2163
+	/**
2164
+	 * _set_list_table_object
2165
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2166
+	 *
2167
+	 * @throws InvalidInterfaceException
2168
+	 * @throws InvalidArgumentException
2169
+	 * @throws InvalidDataTypeException
2170
+	 * @throws EE_Error
2171
+	 * @throws InvalidInterfaceException
2172
+	 */
2173
+	protected function _set_list_table_object()
2174
+	{
2175
+		if (isset($this->_route_config['list_table'])) {
2176
+			if (! class_exists($this->_route_config['list_table'])) {
2177
+				throw new EE_Error(
2178
+					sprintf(
2179
+						esc_html__(
2180
+							'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.',
2181
+							'event_espresso'
2182
+						),
2183
+						$this->_route_config['list_table'],
2184
+						get_class($this)
2185
+					)
2186
+				);
2187
+			}
2188
+			$this->_list_table_object = $this->loader->getShared(
2189
+				$this->_route_config['list_table'],
2190
+				array($this)
2191
+			);
2192
+		}
2193
+	}
2194
+
2195
+
2196
+	/**
2197
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2198
+	 *
2199
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2200
+	 *                                                    urls.  The array should be indexed by the view it is being
2201
+	 *                                                    added to.
2202
+	 * @return array
2203
+	 */
2204
+	public function get_list_table_view_RLs($extra_query_args = array())
2205
+	{
2206
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2207
+		if (empty($this->_views)) {
2208
+			$this->_views = array();
2209
+		}
2210
+		// cycle thru views
2211
+		foreach ($this->_views as $key => $view) {
2212
+			$query_args = array();
2213
+			// check for current view
2214
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2215
+			$query_args['action'] = $this->_req_action;
2216
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2217
+			$query_args['status'] = $view['slug'];
2218
+			// merge any other arguments sent in.
2219
+			if (isset($extra_query_args[ $view['slug'] ])) {
2220
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2221
+					$query_args[] = $extra_query_arg;
2222
+				}
2223
+			}
2224
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2225
+		}
2226
+		return $this->_views;
2227
+	}
2228
+
2229
+
2230
+	/**
2231
+	 * _entries_per_page_dropdown
2232
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2233
+	 *
2234
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2235
+	 *         WP does it.
2236
+	 * @param int $max_entries total number of rows in the table
2237
+	 * @return string
2238
+	 */
2239
+	protected function _entries_per_page_dropdown($max_entries = 0)
2240
+	{
2241
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2242
+		$values = array(10, 25, 50, 100);
2243
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2244
+		if ($max_entries) {
2245
+			$values[] = $max_entries;
2246
+			sort($values);
2247
+		}
2248
+		$entries_per_page_dropdown = '
2249 2249
 			<div id="entries-per-page-dv" class="alignleft actions">
2250 2250
 				<label class="hide-if-no-js">
2251 2251
 					Show
2252 2252
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2253
-        foreach ($values as $value) {
2254
-            if ($value < $max_entries) {
2255
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2256
-                $entries_per_page_dropdown .= '
2253
+		foreach ($values as $value) {
2254
+			if ($value < $max_entries) {
2255
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2256
+				$entries_per_page_dropdown .= '
2257 2257
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2258
-            }
2259
-        }
2260
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2261
-        $entries_per_page_dropdown .= '
2258
+			}
2259
+		}
2260
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2261
+		$entries_per_page_dropdown .= '
2262 2262
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2263
-        $entries_per_page_dropdown .= '
2263
+		$entries_per_page_dropdown .= '
2264 2264
 					</select>
2265 2265
 					entries
2266 2266
 				</label>
2267 2267
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2268 2268
 			</div>
2269 2269
 		';
2270
-        return $entries_per_page_dropdown;
2271
-    }
2272
-
2273
-
2274
-    /**
2275
-     *        _set_search_attributes
2276
-     *
2277
-     * @return        void
2278
-     */
2279
-    public function _set_search_attributes()
2280
-    {
2281
-        $this->_template_args['search']['btn_label'] = sprintf(
2282
-            esc_html__('Search %s', 'event_espresso'),
2283
-            empty($this->_search_btn_label) ? $this->page_label
2284
-                : $this->_search_btn_label
2285
-        );
2286
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2287
-    }
2288
-
2289
-
2290
-
2291
-    /*** END LIST TABLE METHODS **/
2292
-
2293
-
2294
-    /**
2295
-     * _add_registered_metaboxes
2296
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2297
-     *
2298
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2299
-     * @return void
2300
-     * @throws EE_Error
2301
-     */
2302
-    private function _add_registered_meta_boxes()
2303
-    {
2304
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2305
-        // we only add meta boxes if the page_route calls for it
2306
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2307
-            && is_array(
2308
-                $this->_route_config['metaboxes']
2309
-            )
2310
-        ) {
2311
-            // this simply loops through the callbacks provided
2312
-            // and checks if there is a corresponding callback registered by the child
2313
-            // if there is then we go ahead and process the metabox loader.
2314
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2315
-                // first check for Closures
2316
-                if ($metabox_callback instanceof Closure) {
2317
-                    $result = $metabox_callback();
2318
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2319
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2320
-                } else {
2321
-                    $result = $this->{$metabox_callback}();
2322
-                }
2323
-                if ($result === false) {
2324
-                    // user error msg
2325
-                    $error_msg = esc_html__(
2326
-                        'An error occurred. The  requested metabox could not be found.',
2327
-                        'event_espresso'
2328
-                    );
2329
-                    // developer error msg
2330
-                    $error_msg .= '||'
2331
-                                  . sprintf(
2332
-                                      esc_html__(
2333
-                                          '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.',
2334
-                                          'event_espresso'
2335
-                                      ),
2336
-                                      $metabox_callback
2337
-                                  );
2338
-                    throw new EE_Error($error_msg);
2339
-                }
2340
-            }
2341
-        }
2342
-    }
2343
-
2344
-
2345
-    /**
2346
-     * _add_screen_columns
2347
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2348
-     * the dynamic column template and we'll setup the column options for the page.
2349
-     *
2350
-     * @return void
2351
-     */
2352
-    private function _add_screen_columns()
2353
-    {
2354
-        if (is_array($this->_route_config)
2355
-            && isset($this->_route_config['columns'])
2356
-            && is_array($this->_route_config['columns'])
2357
-            && count($this->_route_config['columns']) === 2
2358
-        ) {
2359
-            add_screen_option(
2360
-                'layout_columns',
2361
-                array(
2362
-                    'max'     => (int) $this->_route_config['columns'][0],
2363
-                    'default' => (int) $this->_route_config['columns'][1],
2364
-                )
2365
-            );
2366
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2367
-            $screen_id = $this->_current_screen->id;
2368
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2369
-            $total_columns = ! empty($screen_columns)
2370
-                ? $screen_columns
2371
-                : $this->_route_config['columns'][1];
2372
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2373
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2374
-            $this->_template_args['screen'] = $this->_current_screen;
2375
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2376
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2377
-            // finally if we don't have has_metaboxes set in the route config
2378
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2379
-            $this->_route_config['has_metaboxes'] = true;
2380
-        }
2381
-    }
2382
-
2383
-
2384
-
2385
-    /** GLOBALLY AVAILABLE METABOXES **/
2386
-
2387
-
2388
-    /**
2389
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2390
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2391
-     * these get loaded on.
2392
-     */
2393
-    private function _espresso_news_post_box()
2394
-    {
2395
-        $news_box_title = apply_filters(
2396
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2397
-            esc_html__('New @ Event Espresso', 'event_espresso')
2398
-        );
2399
-        add_meta_box(
2400
-            'espresso_news_post_box',
2401
-            $news_box_title,
2402
-            array(
2403
-                $this,
2404
-                'espresso_news_post_box',
2405
-            ),
2406
-            $this->_wp_page_slug,
2407
-            'side'
2408
-        );
2409
-    }
2410
-
2411
-
2412
-    /**
2413
-     * Code for setting up espresso ratings request metabox.
2414
-     */
2415
-    protected function _espresso_ratings_request()
2416
-    {
2417
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2418
-            return;
2419
-        }
2420
-        $ratings_box_title = apply_filters(
2421
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2422
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2423
-        );
2424
-        add_meta_box(
2425
-            'espresso_ratings_request',
2426
-            $ratings_box_title,
2427
-            array(
2428
-                $this,
2429
-                'espresso_ratings_request',
2430
-            ),
2431
-            $this->_wp_page_slug,
2432
-            'side'
2433
-        );
2434
-    }
2435
-
2436
-
2437
-    /**
2438
-     * Code for setting up espresso ratings request metabox content.
2439
-     *
2440
-     * @throws DomainException
2441
-     */
2442
-    public function espresso_ratings_request()
2443
-    {
2444
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2445
-    }
2446
-
2447
-
2448
-    public static function cached_rss_display($rss_id, $url)
2449
-    {
2450
-        $loading = '<p class="widget-loading hide-if-no-js">'
2451
-                   . __('Loading&#8230;', 'event_espresso')
2452
-                   . '</p><p class="hide-if-js">'
2453
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2454
-                   . '</p>';
2455
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2456
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2457
-        $post = '</div>' . "\n";
2458
-        $cache_key = 'ee_rss_' . md5($rss_id);
2459
-        $output = get_transient($cache_key);
2460
-        if ($output !== false) {
2461
-            echo $pre . $output . $post;
2462
-            return true;
2463
-        }
2464
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2465
-            echo $pre . $loading . $post;
2466
-            return false;
2467
-        }
2468
-        ob_start();
2469
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2470
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2471
-        return true;
2472
-    }
2473
-
2474
-
2475
-    public function espresso_news_post_box()
2476
-    {
2477
-        ?>
2270
+		return $entries_per_page_dropdown;
2271
+	}
2272
+
2273
+
2274
+	/**
2275
+	 *        _set_search_attributes
2276
+	 *
2277
+	 * @return        void
2278
+	 */
2279
+	public function _set_search_attributes()
2280
+	{
2281
+		$this->_template_args['search']['btn_label'] = sprintf(
2282
+			esc_html__('Search %s', 'event_espresso'),
2283
+			empty($this->_search_btn_label) ? $this->page_label
2284
+				: $this->_search_btn_label
2285
+		);
2286
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2287
+	}
2288
+
2289
+
2290
+
2291
+	/*** END LIST TABLE METHODS **/
2292
+
2293
+
2294
+	/**
2295
+	 * _add_registered_metaboxes
2296
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2297
+	 *
2298
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2299
+	 * @return void
2300
+	 * @throws EE_Error
2301
+	 */
2302
+	private function _add_registered_meta_boxes()
2303
+	{
2304
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2305
+		// we only add meta boxes if the page_route calls for it
2306
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2307
+			&& is_array(
2308
+				$this->_route_config['metaboxes']
2309
+			)
2310
+		) {
2311
+			// this simply loops through the callbacks provided
2312
+			// and checks if there is a corresponding callback registered by the child
2313
+			// if there is then we go ahead and process the metabox loader.
2314
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2315
+				// first check for Closures
2316
+				if ($metabox_callback instanceof Closure) {
2317
+					$result = $metabox_callback();
2318
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2319
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2320
+				} else {
2321
+					$result = $this->{$metabox_callback}();
2322
+				}
2323
+				if ($result === false) {
2324
+					// user error msg
2325
+					$error_msg = esc_html__(
2326
+						'An error occurred. The  requested metabox could not be found.',
2327
+						'event_espresso'
2328
+					);
2329
+					// developer error msg
2330
+					$error_msg .= '||'
2331
+								  . sprintf(
2332
+									  esc_html__(
2333
+										  '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.',
2334
+										  'event_espresso'
2335
+									  ),
2336
+									  $metabox_callback
2337
+								  );
2338
+					throw new EE_Error($error_msg);
2339
+				}
2340
+			}
2341
+		}
2342
+	}
2343
+
2344
+
2345
+	/**
2346
+	 * _add_screen_columns
2347
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2348
+	 * the dynamic column template and we'll setup the column options for the page.
2349
+	 *
2350
+	 * @return void
2351
+	 */
2352
+	private function _add_screen_columns()
2353
+	{
2354
+		if (is_array($this->_route_config)
2355
+			&& isset($this->_route_config['columns'])
2356
+			&& is_array($this->_route_config['columns'])
2357
+			&& count($this->_route_config['columns']) === 2
2358
+		) {
2359
+			add_screen_option(
2360
+				'layout_columns',
2361
+				array(
2362
+					'max'     => (int) $this->_route_config['columns'][0],
2363
+					'default' => (int) $this->_route_config['columns'][1],
2364
+				)
2365
+			);
2366
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2367
+			$screen_id = $this->_current_screen->id;
2368
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2369
+			$total_columns = ! empty($screen_columns)
2370
+				? $screen_columns
2371
+				: $this->_route_config['columns'][1];
2372
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2373
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2374
+			$this->_template_args['screen'] = $this->_current_screen;
2375
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2376
+										   . 'admin_details_metabox_column_wrapper.template.php';
2377
+			// finally if we don't have has_metaboxes set in the route config
2378
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2379
+			$this->_route_config['has_metaboxes'] = true;
2380
+		}
2381
+	}
2382
+
2383
+
2384
+
2385
+	/** GLOBALLY AVAILABLE METABOXES **/
2386
+
2387
+
2388
+	/**
2389
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2390
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2391
+	 * these get loaded on.
2392
+	 */
2393
+	private function _espresso_news_post_box()
2394
+	{
2395
+		$news_box_title = apply_filters(
2396
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2397
+			esc_html__('New @ Event Espresso', 'event_espresso')
2398
+		);
2399
+		add_meta_box(
2400
+			'espresso_news_post_box',
2401
+			$news_box_title,
2402
+			array(
2403
+				$this,
2404
+				'espresso_news_post_box',
2405
+			),
2406
+			$this->_wp_page_slug,
2407
+			'side'
2408
+		);
2409
+	}
2410
+
2411
+
2412
+	/**
2413
+	 * Code for setting up espresso ratings request metabox.
2414
+	 */
2415
+	protected function _espresso_ratings_request()
2416
+	{
2417
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2418
+			return;
2419
+		}
2420
+		$ratings_box_title = apply_filters(
2421
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2422
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2423
+		);
2424
+		add_meta_box(
2425
+			'espresso_ratings_request',
2426
+			$ratings_box_title,
2427
+			array(
2428
+				$this,
2429
+				'espresso_ratings_request',
2430
+			),
2431
+			$this->_wp_page_slug,
2432
+			'side'
2433
+		);
2434
+	}
2435
+
2436
+
2437
+	/**
2438
+	 * Code for setting up espresso ratings request metabox content.
2439
+	 *
2440
+	 * @throws DomainException
2441
+	 */
2442
+	public function espresso_ratings_request()
2443
+	{
2444
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2445
+	}
2446
+
2447
+
2448
+	public static function cached_rss_display($rss_id, $url)
2449
+	{
2450
+		$loading = '<p class="widget-loading hide-if-no-js">'
2451
+				   . __('Loading&#8230;', 'event_espresso')
2452
+				   . '</p><p class="hide-if-js">'
2453
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2454
+				   . '</p>';
2455
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2456
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2457
+		$post = '</div>' . "\n";
2458
+		$cache_key = 'ee_rss_' . md5($rss_id);
2459
+		$output = get_transient($cache_key);
2460
+		if ($output !== false) {
2461
+			echo $pre . $output . $post;
2462
+			return true;
2463
+		}
2464
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2465
+			echo $pre . $loading . $post;
2466
+			return false;
2467
+		}
2468
+		ob_start();
2469
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2470
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2471
+		return true;
2472
+	}
2473
+
2474
+
2475
+	public function espresso_news_post_box()
2476
+	{
2477
+		?>
2478 2478
         <div class="padding">
2479 2479
             <div id="espresso_news_post_box_content" class="infolinks">
2480 2480
                 <?php
2481
-                // Get RSS Feed(s)
2482
-                EE_Admin_Page::cached_rss_display(
2483
-                    'espresso_news_post_box_content',
2484
-                    urlencode(
2485
-                        apply_filters(
2486
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2487
-                            'http://eventespresso.com/feed/'
2488
-                        )
2489
-                    )
2490
-                );
2491
-                ?>
2481
+				// Get RSS Feed(s)
2482
+				EE_Admin_Page::cached_rss_display(
2483
+					'espresso_news_post_box_content',
2484
+					urlencode(
2485
+						apply_filters(
2486
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2487
+							'http://eventespresso.com/feed/'
2488
+						)
2489
+					)
2490
+				);
2491
+				?>
2492 2492
             </div>
2493 2493
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2494 2494
         </div>
2495 2495
         <?php
2496
-    }
2497
-
2498
-
2499
-    private function _espresso_links_post_box()
2500
-    {
2501
-        // Hiding until we actually have content to put in here...
2502
-        // 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');
2503
-    }
2504
-
2505
-
2506
-    public function espresso_links_post_box()
2507
-    {
2508
-        // Hiding until we actually have content to put in here...
2509
-        // EEH_Template::display_template(
2510
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2511
-        // );
2512
-    }
2513
-
2514
-
2515
-    protected function _espresso_sponsors_post_box()
2516
-    {
2517
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2518
-            add_meta_box(
2519
-                'espresso_sponsors_post_box',
2520
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2521
-                array($this, 'espresso_sponsors_post_box'),
2522
-                $this->_wp_page_slug,
2523
-                'side'
2524
-            );
2525
-        }
2526
-    }
2527
-
2528
-
2529
-    public function espresso_sponsors_post_box()
2530
-    {
2531
-        EEH_Template::display_template(
2532
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2533
-        );
2534
-    }
2535
-
2536
-
2537
-    private function _publish_post_box()
2538
-    {
2539
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2540
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2541
-        // then we'll use that for the metabox label.
2542
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2543
-        if (! empty($this->_labels['publishbox'])) {
2544
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2545
-                : $this->_labels['publishbox'];
2546
-        } else {
2547
-            $box_label = esc_html__('Publish', 'event_espresso');
2548
-        }
2549
-        $box_label = apply_filters(
2550
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2551
-            $box_label,
2552
-            $this->_req_action,
2553
-            $this
2554
-        );
2555
-        add_meta_box(
2556
-            $meta_box_ref,
2557
-            $box_label,
2558
-            array($this, 'editor_overview'),
2559
-            $this->_current_screen->id,
2560
-            'side',
2561
-            'high'
2562
-        );
2563
-    }
2564
-
2565
-
2566
-    public function editor_overview()
2567
-    {
2568
-        // if we have extra content set let's add it in if not make sure its empty
2569
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2570
-            ? $this->_template_args['publish_box_extra_content']
2571
-            : '';
2572
-        echo EEH_Template::display_template(
2573
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2574
-            $this->_template_args,
2575
-            true
2576
-        );
2577
-    }
2578
-
2579
-
2580
-    /** end of globally available metaboxes section **/
2581
-
2582
-
2583
-    /**
2584
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2585
-     * protected method.
2586
-     *
2587
-     * @see   $this->_set_publish_post_box_vars for param details
2588
-     * @since 4.6.0
2589
-     * @param string $name
2590
-     * @param int    $id
2591
-     * @param bool   $delete
2592
-     * @param string $save_close_redirect_URL
2593
-     * @param bool   $both_btns
2594
-     * @throws EE_Error
2595
-     * @throws InvalidArgumentException
2596
-     * @throws InvalidDataTypeException
2597
-     * @throws InvalidInterfaceException
2598
-     */
2599
-    public function set_publish_post_box_vars(
2600
-        $name = '',
2601
-        $id = 0,
2602
-        $delete = false,
2603
-        $save_close_redirect_URL = '',
2604
-        $both_btns = true
2605
-    ) {
2606
-        $this->_set_publish_post_box_vars(
2607
-            $name,
2608
-            $id,
2609
-            $delete,
2610
-            $save_close_redirect_URL,
2611
-            $both_btns
2612
-        );
2613
-    }
2614
-
2615
-
2616
-    /**
2617
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2618
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2619
-     * save, and save and close buttons to work properly, then you will want to include a
2620
-     * values for the name and id arguments.
2621
-     *
2622
-     * @todo  Add in validation for name/id arguments.
2623
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2624
-     * @param    int     $id                      id attached to the item published
2625
-     * @param    string  $delete                  page route callback for the delete action
2626
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2627
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2628
-     *                                            the Save button
2629
-     * @throws EE_Error
2630
-     * @throws InvalidArgumentException
2631
-     * @throws InvalidDataTypeException
2632
-     * @throws InvalidInterfaceException
2633
-     */
2634
-    protected function _set_publish_post_box_vars(
2635
-        $name = '',
2636
-        $id = 0,
2637
-        $delete = '',
2638
-        $save_close_redirect_URL = '',
2639
-        $both_btns = true
2640
-    ) {
2641
-        // if Save & Close, use a custom redirect URL or default to the main page?
2642
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2643
-            ? $save_close_redirect_URL
2644
-            : $this->_admin_base_url;
2645
-        // create the Save & Close and Save buttons
2646
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2647
-        // if we have extra content set let's add it in if not make sure its empty
2648
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2649
-            ? $this->_template_args['publish_box_extra_content']
2650
-            : '';
2651
-        if ($delete && ! empty($id)) {
2652
-            // make sure we have a default if just true is sent.
2653
-            $delete = ! empty($delete) ? $delete : 'delete';
2654
-            $delete_link_args = array($name => $id);
2655
-            $delete = $this->get_action_link_or_button(
2656
-                $delete,
2657
-                $delete,
2658
-                $delete_link_args,
2659
-                'submitdelete deletion'
2660
-            );
2661
-        }
2662
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2663
-        if (! empty($name) && ! empty($id)) {
2664
-            $hidden_field_arr[ $name ] = array(
2665
-                'type'  => 'hidden',
2666
-                'value' => $id,
2667
-            );
2668
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2669
-        } else {
2670
-            $hf = '';
2671
-        }
2672
-        // add hidden field
2673
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2674
-            ? $hf[ $name ]['field']
2675
-            : $hf;
2676
-    }
2677
-
2678
-
2679
-    /**
2680
-     * displays an error message to ppl who have javascript disabled
2681
-     *
2682
-     * @return void
2683
-     */
2684
-    private function _display_no_javascript_warning()
2685
-    {
2686
-        ?>
2496
+	}
2497
+
2498
+
2499
+	private function _espresso_links_post_box()
2500
+	{
2501
+		// Hiding until we actually have content to put in here...
2502
+		// 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');
2503
+	}
2504
+
2505
+
2506
+	public function espresso_links_post_box()
2507
+	{
2508
+		// Hiding until we actually have content to put in here...
2509
+		// EEH_Template::display_template(
2510
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2511
+		// );
2512
+	}
2513
+
2514
+
2515
+	protected function _espresso_sponsors_post_box()
2516
+	{
2517
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2518
+			add_meta_box(
2519
+				'espresso_sponsors_post_box',
2520
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2521
+				array($this, 'espresso_sponsors_post_box'),
2522
+				$this->_wp_page_slug,
2523
+				'side'
2524
+			);
2525
+		}
2526
+	}
2527
+
2528
+
2529
+	public function espresso_sponsors_post_box()
2530
+	{
2531
+		EEH_Template::display_template(
2532
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2533
+		);
2534
+	}
2535
+
2536
+
2537
+	private function _publish_post_box()
2538
+	{
2539
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2540
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2541
+		// then we'll use that for the metabox label.
2542
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2543
+		if (! empty($this->_labels['publishbox'])) {
2544
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2545
+				: $this->_labels['publishbox'];
2546
+		} else {
2547
+			$box_label = esc_html__('Publish', 'event_espresso');
2548
+		}
2549
+		$box_label = apply_filters(
2550
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2551
+			$box_label,
2552
+			$this->_req_action,
2553
+			$this
2554
+		);
2555
+		add_meta_box(
2556
+			$meta_box_ref,
2557
+			$box_label,
2558
+			array($this, 'editor_overview'),
2559
+			$this->_current_screen->id,
2560
+			'side',
2561
+			'high'
2562
+		);
2563
+	}
2564
+
2565
+
2566
+	public function editor_overview()
2567
+	{
2568
+		// if we have extra content set let's add it in if not make sure its empty
2569
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2570
+			? $this->_template_args['publish_box_extra_content']
2571
+			: '';
2572
+		echo EEH_Template::display_template(
2573
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2574
+			$this->_template_args,
2575
+			true
2576
+		);
2577
+	}
2578
+
2579
+
2580
+	/** end of globally available metaboxes section **/
2581
+
2582
+
2583
+	/**
2584
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2585
+	 * protected method.
2586
+	 *
2587
+	 * @see   $this->_set_publish_post_box_vars for param details
2588
+	 * @since 4.6.0
2589
+	 * @param string $name
2590
+	 * @param int    $id
2591
+	 * @param bool   $delete
2592
+	 * @param string $save_close_redirect_URL
2593
+	 * @param bool   $both_btns
2594
+	 * @throws EE_Error
2595
+	 * @throws InvalidArgumentException
2596
+	 * @throws InvalidDataTypeException
2597
+	 * @throws InvalidInterfaceException
2598
+	 */
2599
+	public function set_publish_post_box_vars(
2600
+		$name = '',
2601
+		$id = 0,
2602
+		$delete = false,
2603
+		$save_close_redirect_URL = '',
2604
+		$both_btns = true
2605
+	) {
2606
+		$this->_set_publish_post_box_vars(
2607
+			$name,
2608
+			$id,
2609
+			$delete,
2610
+			$save_close_redirect_URL,
2611
+			$both_btns
2612
+		);
2613
+	}
2614
+
2615
+
2616
+	/**
2617
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2618
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2619
+	 * save, and save and close buttons to work properly, then you will want to include a
2620
+	 * values for the name and id arguments.
2621
+	 *
2622
+	 * @todo  Add in validation for name/id arguments.
2623
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2624
+	 * @param    int     $id                      id attached to the item published
2625
+	 * @param    string  $delete                  page route callback for the delete action
2626
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2627
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2628
+	 *                                            the Save button
2629
+	 * @throws EE_Error
2630
+	 * @throws InvalidArgumentException
2631
+	 * @throws InvalidDataTypeException
2632
+	 * @throws InvalidInterfaceException
2633
+	 */
2634
+	protected function _set_publish_post_box_vars(
2635
+		$name = '',
2636
+		$id = 0,
2637
+		$delete = '',
2638
+		$save_close_redirect_URL = '',
2639
+		$both_btns = true
2640
+	) {
2641
+		// if Save & Close, use a custom redirect URL or default to the main page?
2642
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2643
+			? $save_close_redirect_URL
2644
+			: $this->_admin_base_url;
2645
+		// create the Save & Close and Save buttons
2646
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2647
+		// if we have extra content set let's add it in if not make sure its empty
2648
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2649
+			? $this->_template_args['publish_box_extra_content']
2650
+			: '';
2651
+		if ($delete && ! empty($id)) {
2652
+			// make sure we have a default if just true is sent.
2653
+			$delete = ! empty($delete) ? $delete : 'delete';
2654
+			$delete_link_args = array($name => $id);
2655
+			$delete = $this->get_action_link_or_button(
2656
+				$delete,
2657
+				$delete,
2658
+				$delete_link_args,
2659
+				'submitdelete deletion'
2660
+			);
2661
+		}
2662
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2663
+		if (! empty($name) && ! empty($id)) {
2664
+			$hidden_field_arr[ $name ] = array(
2665
+				'type'  => 'hidden',
2666
+				'value' => $id,
2667
+			);
2668
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2669
+		} else {
2670
+			$hf = '';
2671
+		}
2672
+		// add hidden field
2673
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2674
+			? $hf[ $name ]['field']
2675
+			: $hf;
2676
+	}
2677
+
2678
+
2679
+	/**
2680
+	 * displays an error message to ppl who have javascript disabled
2681
+	 *
2682
+	 * @return void
2683
+	 */
2684
+	private function _display_no_javascript_warning()
2685
+	{
2686
+		?>
2687 2687
         <noscript>
2688 2688
             <div id="no-js-message" class="error">
2689 2689
                 <p style="font-size:1.3em;">
2690 2690
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2691 2691
                     <?php esc_html_e(
2692
-                        '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.',
2693
-                        'event_espresso'
2694
-                    ); ?>
2692
+						'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.',
2693
+						'event_espresso'
2694
+					); ?>
2695 2695
                 </p>
2696 2696
             </div>
2697 2697
         </noscript>
2698 2698
         <?php
2699
-    }
2700
-
2701
-
2702
-    /**
2703
-     * displays espresso success and/or error notices
2704
-     *
2705
-     * @return void
2706
-     */
2707
-    private function _display_espresso_notices()
2708
-    {
2709
-        $notices = $this->_get_transient(true);
2710
-        echo stripslashes($notices);
2711
-    }
2712
-
2713
-
2714
-    /**
2715
-     * spinny things pacify the masses
2716
-     *
2717
-     * @return void
2718
-     */
2719
-    protected function _add_admin_page_ajax_loading_img()
2720
-    {
2721
-        ?>
2699
+	}
2700
+
2701
+
2702
+	/**
2703
+	 * displays espresso success and/or error notices
2704
+	 *
2705
+	 * @return void
2706
+	 */
2707
+	private function _display_espresso_notices()
2708
+	{
2709
+		$notices = $this->_get_transient(true);
2710
+		echo stripslashes($notices);
2711
+	}
2712
+
2713
+
2714
+	/**
2715
+	 * spinny things pacify the masses
2716
+	 *
2717
+	 * @return void
2718
+	 */
2719
+	protected function _add_admin_page_ajax_loading_img()
2720
+	{
2721
+		?>
2722 2722
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2723 2723
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2724
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2724
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2725 2725
         </div>
2726 2726
         <?php
2727
-    }
2727
+	}
2728 2728
 
2729 2729
 
2730
-    /**
2731
-     * add admin page overlay for modal boxes
2732
-     *
2733
-     * @return void
2734
-     */
2735
-    protected function _add_admin_page_overlay()
2736
-    {
2737
-        ?>
2730
+	/**
2731
+	 * add admin page overlay for modal boxes
2732
+	 *
2733
+	 * @return void
2734
+	 */
2735
+	protected function _add_admin_page_overlay()
2736
+	{
2737
+		?>
2738 2738
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2739 2739
         <?php
2740
-    }
2741
-
2742
-
2743
-    /**
2744
-     * facade for add_meta_box
2745
-     *
2746
-     * @param string  $action        where the metabox get's displayed
2747
-     * @param string  $title         Title of Metabox (output in metabox header)
2748
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2749
-     *                               instead of the one created in here.
2750
-     * @param array   $callback_args an array of args supplied for the metabox
2751
-     * @param string  $column        what metabox column
2752
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2753
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2754
-     *                               created but just set our own callback for wp's add_meta_box.
2755
-     * @throws DomainException
2756
-     */
2757
-    public function _add_admin_page_meta_box(
2758
-        $action,
2759
-        $title,
2760
-        $callback,
2761
-        $callback_args,
2762
-        $column = 'normal',
2763
-        $priority = 'high',
2764
-        $create_func = true
2765
-    ) {
2766
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2767
-        // 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.
2768
-        if (empty($callback_args) && $create_func) {
2769
-            $callback_args = array(
2770
-                'template_path' => $this->_template_path,
2771
-                'template_args' => $this->_template_args,
2772
-            );
2773
-        }
2774
-        // 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)
2775
-        $call_back_func = $create_func
2776
-            ? static function ($post, $metabox) {
2777
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2778
-                echo EEH_Template::display_template(
2779
-                    $metabox['args']['template_path'],
2780
-                    $metabox['args']['template_args'],
2781
-                    true
2782
-                );
2783
-            }
2784
-            : $callback;
2785
-        add_meta_box(
2786
-            str_replace('_', '-', $action) . '-mbox',
2787
-            $title,
2788
-            $call_back_func,
2789
-            $this->_wp_page_slug,
2790
-            $column,
2791
-            $priority,
2792
-            $callback_args
2793
-        );
2794
-    }
2795
-
2796
-
2797
-    /**
2798
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2799
-     *
2800
-     * @throws DomainException
2801
-     * @throws EE_Error
2802
-     * @throws InvalidArgumentException
2803
-     * @throws InvalidDataTypeException
2804
-     * @throws InvalidInterfaceException
2805
-     */
2806
-    public function display_admin_page_with_metabox_columns()
2807
-    {
2808
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2809
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2810
-            $this->_column_template_path,
2811
-            $this->_template_args,
2812
-            true
2813
-        );
2814
-        // the final wrapper
2815
-        $this->admin_page_wrapper();
2816
-    }
2817
-
2818
-
2819
-    /**
2820
-     * generates  HTML wrapper for an admin details page
2821
-     *
2822
-     * @return void
2823
-     * @throws DomainException
2824
-     * @throws EE_Error
2825
-     * @throws InvalidArgumentException
2826
-     * @throws InvalidDataTypeException
2827
-     * @throws InvalidInterfaceException
2828
-     */
2829
-    public function display_admin_page_with_sidebar()
2830
-    {
2831
-        $this->_display_admin_page(true);
2832
-    }
2833
-
2834
-
2835
-    /**
2836
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2837
-     *
2838
-     * @return void
2839
-     * @throws DomainException
2840
-     * @throws EE_Error
2841
-     * @throws InvalidArgumentException
2842
-     * @throws InvalidDataTypeException
2843
-     * @throws InvalidInterfaceException
2844
-     */
2845
-    public function display_admin_page_with_no_sidebar()
2846
-    {
2847
-        $this->_display_admin_page();
2848
-    }
2849
-
2850
-
2851
-    /**
2852
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2853
-     *
2854
-     * @return void
2855
-     * @throws DomainException
2856
-     * @throws EE_Error
2857
-     * @throws InvalidArgumentException
2858
-     * @throws InvalidDataTypeException
2859
-     * @throws InvalidInterfaceException
2860
-     */
2861
-    public function display_about_admin_page()
2862
-    {
2863
-        $this->_display_admin_page(false, true);
2864
-    }
2865
-
2866
-
2867
-    /**
2868
-     * display_admin_page
2869
-     * contains the code for actually displaying an admin page
2870
-     *
2871
-     * @param boolean $sidebar true with sidebar, false without
2872
-     * @param boolean $about   use the about admin wrapper instead of the default.
2873
-     * @return void
2874
-     * @throws DomainException
2875
-     * @throws EE_Error
2876
-     * @throws InvalidArgumentException
2877
-     * @throws InvalidDataTypeException
2878
-     * @throws InvalidInterfaceException
2879
-     */
2880
-    private function _display_admin_page($sidebar = false, $about = false)
2881
-    {
2882
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2883
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2884
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2885
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2886
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2887
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2888
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2889
-            ? 'poststuff'
2890
-            : 'espresso-default-admin';
2891
-        $template_path = $sidebar
2892
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2893
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2894
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2895
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2896
-        }
2897
-        $template_path = ! empty($this->_column_template_path)
2898
-            ? $this->_column_template_path : $template_path;
2899
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2900
-            ? $this->_template_args['admin_page_content']
2901
-            : '';
2902
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2903
-            ? $this->_template_args['before_admin_page_content']
2904
-            : '';
2905
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2906
-            ? $this->_template_args['after_admin_page_content']
2907
-            : '';
2908
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2909
-            $template_path,
2910
-            $this->_template_args,
2911
-            true
2912
-        );
2913
-        // the final template wrapper
2914
-        $this->admin_page_wrapper($about);
2915
-    }
2916
-
2917
-
2918
-    /**
2919
-     * This is used to display caf preview pages.
2920
-     *
2921
-     * @since 4.3.2
2922
-     * @param string $utm_campaign_source what is the key used for google analytics link
2923
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2924
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2925
-     * @return void
2926
-     * @throws DomainException
2927
-     * @throws EE_Error
2928
-     * @throws InvalidArgumentException
2929
-     * @throws InvalidDataTypeException
2930
-     * @throws InvalidInterfaceException
2931
-     */
2932
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2933
-    {
2934
-        // let's generate a default preview action button if there isn't one already present.
2935
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2936
-            'Upgrade to Event Espresso 4 Right Now',
2937
-            'event_espresso'
2938
-        );
2939
-        $buy_now_url = add_query_arg(
2940
-            array(
2941
-                'ee_ver'       => 'ee4',
2942
-                'utm_source'   => 'ee4_plugin_admin',
2943
-                'utm_medium'   => 'link',
2944
-                'utm_campaign' => $utm_campaign_source,
2945
-                'utm_content'  => 'buy_now_button',
2946
-            ),
2947
-            'http://eventespresso.com/pricing/'
2948
-        );
2949
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2950
-            ? $this->get_action_link_or_button(
2951
-                '',
2952
-                'buy_now',
2953
-                array(),
2954
-                'button-primary button-large',
2955
-                $buy_now_url,
2956
-                true
2957
-            )
2958
-            : $this->_template_args['preview_action_button'];
2959
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2960
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2961
-            $this->_template_args,
2962
-            true
2963
-        );
2964
-        $this->_display_admin_page($display_sidebar);
2965
-    }
2966
-
2967
-
2968
-    /**
2969
-     * display_admin_list_table_page_with_sidebar
2970
-     * generates HTML wrapper for an admin_page with list_table
2971
-     *
2972
-     * @return void
2973
-     * @throws DomainException
2974
-     * @throws EE_Error
2975
-     * @throws InvalidArgumentException
2976
-     * @throws InvalidDataTypeException
2977
-     * @throws InvalidInterfaceException
2978
-     */
2979
-    public function display_admin_list_table_page_with_sidebar()
2980
-    {
2981
-        $this->_display_admin_list_table_page(true);
2982
-    }
2983
-
2984
-
2985
-    /**
2986
-     * display_admin_list_table_page_with_no_sidebar
2987
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2988
-     *
2989
-     * @return void
2990
-     * @throws DomainException
2991
-     * @throws EE_Error
2992
-     * @throws InvalidArgumentException
2993
-     * @throws InvalidDataTypeException
2994
-     * @throws InvalidInterfaceException
2995
-     */
2996
-    public function display_admin_list_table_page_with_no_sidebar()
2997
-    {
2998
-        $this->_display_admin_list_table_page();
2999
-    }
3000
-
3001
-
3002
-    /**
3003
-     * generates html wrapper for an admin_list_table page
3004
-     *
3005
-     * @param boolean $sidebar whether to display with sidebar or not.
3006
-     * @return void
3007
-     * @throws DomainException
3008
-     * @throws EE_Error
3009
-     * @throws InvalidArgumentException
3010
-     * @throws InvalidDataTypeException
3011
-     * @throws InvalidInterfaceException
3012
-     */
3013
-    private function _display_admin_list_table_page($sidebar = false)
3014
-    {
3015
-        // setup search attributes
3016
-        $this->_set_search_attributes();
3017
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
3018
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
3020
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3021
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
3022
-        $this->_template_args['list_table'] = $this->_list_table_object;
3023
-        $this->_template_args['current_route'] = $this->_req_action;
3024
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
3026
-        if (! empty($ajax_sorting_callback)) {
3027
-            $sortable_list_table_form_fields = wp_nonce_field(
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                $ajax_sorting_callback . '_nonce',
3030
-                false,
3031
-                false
3032
-            );
3033
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
-                                                . $this->page_slug
3035
-                                                . '" />';
3036
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
-                                                . $ajax_sorting_callback
3038
-                                                . '" />';
3039
-        } else {
3040
-            $sortable_list_table_form_fields = '';
3041
-        }
3042
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
3044
-            ? $this->_template_args['list_table_hidden_fields']
3045
-            : '';
3046
-        $nonce_ref = $this->_req_action . '_nonce';
3047
-        $hidden_form_fields .= '<input type="hidden" name="'
3048
-                               . $nonce_ref
3049
-                               . '" value="'
3050
-                               . wp_create_nonce($nonce_ref)
3051
-                               . '">';
3052
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3053
-        // display message about search results?
3054
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3055
-            ? '<p class="ee-search-results">' . sprintf(
3056
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3057
-                trim($this->_req_data['s'], '%')
3058
-            ) . '</p>'
3059
-            : '';
3060
-        // filter before_list_table template arg
3061
-        $this->_template_args['before_list_table'] = apply_filters(
3062
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3063
-            $this->_template_args['before_list_table'],
3064
-            $this->page_slug,
3065
-            $this->_req_data,
3066
-            $this->_req_action
3067
-        );
3068
-        // convert to array and filter again
3069
-        // arrays are easier to inject new items in a specific location,
3070
-        // but would not be backwards compatible, so we have to add a new filter
3071
-        $this->_template_args['before_list_table'] = implode(
3072
-            " \n",
3073
-            (array) apply_filters(
3074
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3075
-                (array) $this->_template_args['before_list_table'],
3076
-                $this->page_slug,
3077
-                $this->_req_data,
3078
-                $this->_req_action
3079
-            )
3080
-        );
3081
-        // filter after_list_table template arg
3082
-        $this->_template_args['after_list_table'] = apply_filters(
3083
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3084
-            $this->_template_args['after_list_table'],
3085
-            $this->page_slug,
3086
-            $this->_req_data,
3087
-            $this->_req_action
3088
-        );
3089
-        // convert to array and filter again
3090
-        // arrays are easier to inject new items in a specific location,
3091
-        // but would not be backwards compatible, so we have to add a new filter
3092
-        $this->_template_args['after_list_table'] = implode(
3093
-            " \n",
3094
-            (array) apply_filters(
3095
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3096
-                (array) $this->_template_args['after_list_table'],
3097
-                $this->page_slug,
3098
-                $this->_req_data,
3099
-                $this->_req_action
3100
-            )
3101
-        );
3102
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3103
-            $template_path,
3104
-            $this->_template_args,
3105
-            true
3106
-        );
3107
-        // the final template wrapper
3108
-        if ($sidebar) {
3109
-            $this->display_admin_page_with_sidebar();
3110
-        } else {
3111
-            $this->display_admin_page_with_no_sidebar();
3112
-        }
3113
-    }
3114
-
3115
-
3116
-    /**
3117
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3118
-     * html string for the legend.
3119
-     * $items are expected in an array in the following format:
3120
-     * $legend_items = array(
3121
-     *        'item_id' => array(
3122
-     *            'icon' => 'http://url_to_icon_being_described.png',
3123
-     *            'desc' => esc_html__('localized description of item');
3124
-     *        )
3125
-     * );
3126
-     *
3127
-     * @param  array $items see above for format of array
3128
-     * @return string html string of legend
3129
-     * @throws DomainException
3130
-     */
3131
-    protected function _display_legend($items)
3132
-    {
3133
-        $this->_template_args['items'] = apply_filters(
3134
-            'FHEE__EE_Admin_Page___display_legend__items',
3135
-            (array) $items,
3136
-            $this
3137
-        );
3138
-        return EEH_Template::display_template(
3139
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3140
-            $this->_template_args,
3141
-            true
3142
-        );
3143
-    }
3144
-
3145
-
3146
-    /**
3147
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3148
-     * The returned json object is created from an array in the following format:
3149
-     * array(
3150
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3151
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3152
-     *  'notices' => '', // - contains any EE_Error formatted notices
3153
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3154
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3155
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3156
-     *  that might be included in here)
3157
-     * )
3158
-     * The json object is populated by whatever is set in the $_template_args property.
3159
-     *
3160
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3161
-     *                                 instead of displayed.
3162
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3163
-     * @return void
3164
-     * @throws EE_Error
3165
-     * @throws InvalidArgumentException
3166
-     * @throws InvalidDataTypeException
3167
-     * @throws InvalidInterfaceException
3168
-     */
3169
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3170
-    {
3171
-        // make sure any EE_Error notices have been handled.
3172
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3173
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3174
-        unset($this->_template_args['data']);
3175
-        $json = array(
3176
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3177
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3178
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3179
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3180
-            'notices'   => EE_Error::get_notices(),
3181
-            'content'   => isset($this->_template_args['admin_page_content'])
3182
-                ? $this->_template_args['admin_page_content'] : '',
3183
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3184
-            'isEEajax'  => true
3185
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3186
-        );
3187
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3188
-        if (null === error_get_last() || ! headers_sent()) {
3189
-            header('Content-Type: application/json; charset=UTF-8');
3190
-        }
3191
-        echo wp_json_encode($json);
3192
-        exit();
3193
-    }
3194
-
3195
-
3196
-    /**
3197
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3198
-     *
3199
-     * @return void
3200
-     * @throws EE_Error
3201
-     * @throws InvalidArgumentException
3202
-     * @throws InvalidDataTypeException
3203
-     * @throws InvalidInterfaceException
3204
-     */
3205
-    public function return_json()
3206
-    {
3207
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3208
-            $this->_return_json();
3209
-        } else {
3210
-            throw new EE_Error(
3211
-                sprintf(
3212
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3213
-                    __FUNCTION__
3214
-                )
3215
-            );
3216
-        }
3217
-    }
3218
-
3219
-
3220
-    /**
3221
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3222
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3223
-     *
3224
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3225
-     */
3226
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3227
-    {
3228
-        $this->_hook_obj = $hook_obj;
3229
-    }
3230
-
3231
-
3232
-    /**
3233
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3234
-     *
3235
-     * @param boolean $about whether to use the special about page wrapper or default.
3236
-     * @return void
3237
-     * @throws DomainException
3238
-     * @throws EE_Error
3239
-     * @throws InvalidArgumentException
3240
-     * @throws InvalidDataTypeException
3241
-     * @throws InvalidInterfaceException
3242
-     */
3243
-    public function admin_page_wrapper($about = false)
3244
-    {
3245
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3246
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3247
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3248
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3249
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3250
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3251
-            isset($this->_template_args['before_admin_page_content'])
3252
-                ? $this->_template_args['before_admin_page_content']
3253
-                : ''
3254
-        );
3255
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3256
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3257
-            isset($this->_template_args['after_admin_page_content'])
3258
-                ? $this->_template_args['after_admin_page_content']
3259
-                : ''
3260
-        );
3261
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3262
-        // load settings page wrapper template
3263
-        $template_path = ! defined('DOING_AJAX')
3264
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3265
-            : EE_ADMIN_TEMPLATE
3266
-              . 'admin_wrapper_ajax.template.php';
3267
-        // about page?
3268
-        $template_path = $about
3269
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3270
-            : $template_path;
3271
-        if (defined('DOING_AJAX')) {
3272
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3273
-                $template_path,
3274
-                $this->_template_args,
3275
-                true
3276
-            );
3277
-            $this->_return_json();
3278
-        } else {
3279
-            EEH_Template::display_template($template_path, $this->_template_args);
3280
-        }
3281
-    }
3282
-
3283
-
3284
-    /**
3285
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3286
-     *
3287
-     * @return string html
3288
-     * @throws EE_Error
3289
-     */
3290
-    protected function _get_main_nav_tabs()
3291
-    {
3292
-        // let's generate the html using the EEH_Tabbed_Content helper.
3293
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3294
-        // (rather than setting in the page_routes array)
3295
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3296
-    }
3297
-
3298
-
3299
-    /**
3300
-     *        sort nav tabs
3301
-     *
3302
-     * @param $a
3303
-     * @param $b
3304
-     * @return int
3305
-     */
3306
-    private function _sort_nav_tabs($a, $b)
3307
-    {
3308
-        if ($a['order'] === $b['order']) {
3309
-            return 0;
3310
-        }
3311
-        return ($a['order'] < $b['order']) ? -1 : 1;
3312
-    }
3313
-
3314
-
3315
-    /**
3316
-     *    generates HTML for the forms used on admin pages
3317
-     *
3318
-     * @param    array $input_vars - array of input field details
3319
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3320
-     *                             use)
3321
-     * @param bool     $id
3322
-     * @return string
3323
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3324
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3325
-     */
3326
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3327
-    {
3328
-        return $generator === 'string'
3329
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3330
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3331
-    }
3332
-
3333
-
3334
-    /**
3335
-     * generates the "Save" and "Save & Close" buttons for edit forms
3336
-     *
3337
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3338
-     *                                   Close" button.
3339
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3340
-     *                                   'Save', [1] => 'save & close')
3341
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3342
-     *                                   via the "name" value in the button).  We can also use this to just dump
3343
-     *                                   default actions by submitting some other value.
3344
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3345
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3346
-     *                                   close (normal form handling).
3347
-     */
3348
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3349
-    {
3350
-        // make sure $text and $actions are in an array
3351
-        $text = (array) $text;
3352
-        $actions = (array) $actions;
3353
-        $referrer_url = empty($referrer)
3354
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3355
-              . $_SERVER['REQUEST_URI']
3356
-              . '" />'
3357
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3358
-              . $referrer
3359
-              . '" />';
3360
-        $button_text = ! empty($text)
3361
-            ? $text
3362
-            : array(
3363
-                esc_html__('Save', 'event_espresso'),
3364
-                esc_html__('Save and Close', 'event_espresso'),
3365
-            );
3366
-        $default_names = array('save', 'save_and_close');
3367
-        // add in a hidden index for the current page (so save and close redirects properly)
3368
-        $this->_template_args['save_buttons'] = $referrer_url;
3369
-        foreach ($button_text as $key => $button) {
3370
-            $ref = $default_names[ $key ];
3371
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3372
-                                                     . $ref
3373
-                                                     . '" value="'
3374
-                                                     . $button
3375
-                                                     . '" name="'
3376
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3377
-                                                     . '" id="'
3378
-                                                     . $this->_current_view . '_' . $ref
3379
-                                                     . '" />';
3380
-            if (! $both) {
3381
-                break;
3382
-            }
3383
-        }
3384
-    }
3385
-
3386
-
3387
-    /**
3388
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3389
-     *
3390
-     * @see   $this->_set_add_edit_form_tags() for details on params
3391
-     * @since 4.6.0
3392
-     * @param string $route
3393
-     * @param array  $additional_hidden_fields
3394
-     */
3395
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3396
-    {
3397
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3398
-    }
3399
-
3400
-
3401
-    /**
3402
-     * set form open and close tags on add/edit pages.
3403
-     *
3404
-     * @param string $route                    the route you want the form to direct to
3405
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3406
-     * @return void
3407
-     */
3408
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3409
-    {
3410
-        if (empty($route)) {
3411
-            $user_msg = esc_html__(
3412
-                'An error occurred. No action was set for this page\'s form.',
3413
-                'event_espresso'
3414
-            );
3415
-            $dev_msg = $user_msg . "\n"
3416
-                       . sprintf(
3417
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3418
-                           __FUNCTION__,
3419
-                           EE_Admin_Page::class
3420
-                       );
3421
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3422
-        }
3423
-        // open form
3424
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3425
-                                                             . $this->_admin_base_url
3426
-                                                             . '" id="'
3427
-                                                             . $route
3428
-                                                             . '_event_form" >';
3429
-        // add nonce
3430
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3431
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3432
-        // add REQUIRED form action
3433
-        $hidden_fields = array(
3434
-            'action' => array('type' => 'hidden', 'value' => $route),
3435
-        );
3436
-        // merge arrays
3437
-        $hidden_fields = is_array($additional_hidden_fields)
3438
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3439
-            : $hidden_fields;
3440
-        // generate form fields
3441
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3442
-        // add fields to form
3443
-        foreach ((array) $form_fields as $field_name => $form_field) {
3444
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3445
-        }
3446
-        // close form
3447
-        $this->_template_args['after_admin_page_content'] = '</form>';
3448
-    }
3449
-
3450
-
3451
-    /**
3452
-     * Public Wrapper for _redirect_after_action() method since its
3453
-     * discovered it would be useful for external code to have access.
3454
-     *
3455
-     * @param bool   $success
3456
-     * @param string $what
3457
-     * @param string $action_desc
3458
-     * @param array  $query_args
3459
-     * @param bool   $override_overwrite
3460
-     * @throws EE_Error
3461
-     * @throws InvalidArgumentException
3462
-     * @throws InvalidDataTypeException
3463
-     * @throws InvalidInterfaceException
3464
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3465
-     * @since 4.5.0
3466
-     */
3467
-    public function redirect_after_action(
3468
-        $success = false,
3469
-        $what = 'item',
3470
-        $action_desc = 'processed',
3471
-        $query_args = array(),
3472
-        $override_overwrite = false
3473
-    ) {
3474
-        $this->_redirect_after_action(
3475
-            $success,
3476
-            $what,
3477
-            $action_desc,
3478
-            $query_args,
3479
-            $override_overwrite
3480
-        );
3481
-    }
3482
-
3483
-
3484
-    /**
3485
-     * Helper method for merging existing request data with the returned redirect url.
3486
-     *
3487
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3488
-     * filters are still applied.
3489
-     *
3490
-     * @param array $new_route_data
3491
-     * @return array
3492
-     */
3493
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3494
-    {
3495
-        foreach ($this->_req_data as $ref => $value) {
3496
-            // unset nonces
3497
-            if (strpos($ref, 'nonce') !== false) {
3498
-                unset($this->_req_data[ $ref ]);
3499
-                continue;
3500
-            }
3501
-            // urlencode values.
3502
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3503
-            $this->_req_data[ $ref ] = $value;
3504
-        }
3505
-        return array_merge($this->_req_data, $new_route_data);
3506
-    }
3507
-
3508
-
3509
-    /**
3510
-     *    _redirect_after_action
3511
-     *
3512
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3513
-     * @param string $what               - what the action was performed on
3514
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3515
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3516
-     *                                   action is completed
3517
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3518
-     *                                   override this so that they show.
3519
-     * @return void
3520
-     * @throws EE_Error
3521
-     * @throws InvalidArgumentException
3522
-     * @throws InvalidDataTypeException
3523
-     * @throws InvalidInterfaceException
3524
-     */
3525
-    protected function _redirect_after_action(
3526
-        $success = 0,
3527
-        $what = 'item',
3528
-        $action_desc = 'processed',
3529
-        $query_args = array(),
3530
-        $override_overwrite = false
3531
-    ) {
3532
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3533
-        // class name for actions/filters.
3534
-        $classname = get_class($this);
3535
-        // set redirect url.
3536
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3537
-        // otherwise we go with whatever is set as the _admin_base_url
3538
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3539
-        $notices = EE_Error::get_notices(false);
3540
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3541
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3542
-            EE_Error::overwrite_success();
3543
-        }
3544
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3545
-            // how many records affected ? more than one record ? or just one ?
3546
-            if ($success > 1) {
3547
-                // set plural msg
3548
-                EE_Error::add_success(
3549
-                    sprintf(
3550
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3551
-                        $what,
3552
-                        $action_desc
3553
-                    ),
3554
-                    __FILE__,
3555
-                    __FUNCTION__,
3556
-                    __LINE__
3557
-                );
3558
-            } elseif ($success === 1) {
3559
-                // set singular msg
3560
-                EE_Error::add_success(
3561
-                    sprintf(
3562
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3563
-                        $what,
3564
-                        $action_desc
3565
-                    ),
3566
-                    __FILE__,
3567
-                    __FUNCTION__,
3568
-                    __LINE__
3569
-                );
3570
-            }
3571
-        }
3572
-        // check that $query_args isn't something crazy
3573
-        if (! is_array($query_args)) {
3574
-            $query_args = array();
3575
-        }
3576
-        /**
3577
-         * Allow injecting actions before the query_args are modified for possible different
3578
-         * redirections on save and close actions
3579
-         *
3580
-         * @since 4.2.0
3581
-         * @param array $query_args       The original query_args array coming into the
3582
-         *                                method.
3583
-         */
3584
-        do_action(
3585
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3586
-            $query_args
3587
-        );
3588
-        // calculate where we're going (if we have a "save and close" button pushed)
3589
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3590
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3591
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3592
-            // regenerate query args array from referrer URL
3593
-            parse_str($parsed_url['query'], $query_args);
3594
-            // correct page and action will be in the query args now
3595
-            $redirect_url = admin_url('admin.php');
3596
-        }
3597
-        // merge any default query_args set in _default_route_query_args property
3598
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3599
-            $args_to_merge = array();
3600
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3601
-                // is there a wp_referer array in our _default_route_query_args property?
3602
-                if ($query_param === 'wp_referer') {
3603
-                    $query_value = (array) $query_value;
3604
-                    foreach ($query_value as $reference => $value) {
3605
-                        if (strpos($reference, 'nonce') !== false) {
3606
-                            continue;
3607
-                        }
3608
-                        // finally we will override any arguments in the referer with
3609
-                        // what might be set on the _default_route_query_args array.
3610
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3611
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3612
-                        } else {
3613
-                            $args_to_merge[ $reference ] = urlencode($value);
3614
-                        }
3615
-                    }
3616
-                    continue;
3617
-                }
3618
-                $args_to_merge[ $query_param ] = $query_value;
3619
-            }
3620
-            // now let's merge these arguments but override with what was specifically sent in to the
3621
-            // redirect.
3622
-            $query_args = array_merge($args_to_merge, $query_args);
3623
-        }
3624
-        $this->_process_notices($query_args);
3625
-        // generate redirect url
3626
-        // if redirecting to anything other than the main page, add a nonce
3627
-        if (isset($query_args['action'])) {
3628
-            // manually generate wp_nonce and merge that with the query vars
3629
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3630
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3631
-        }
3632
-        // we're adding some hooks and filters in here for processing any things just before redirects
3633
-        // (example: an admin page has done an insert or update and we want to run something after that).
3634
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3635
-        $redirect_url = apply_filters(
3636
-            'FHEE_redirect_' . $classname . $this->_req_action,
3637
-            EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3638
-            $query_args
3639
-        );
3640
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3641
-        if (defined('DOING_AJAX')) {
3642
-            $default_data = array(
3643
-                'close'        => true,
3644
-                'redirect_url' => $redirect_url,
3645
-                'where'        => 'main',
3646
-                'what'         => 'append',
3647
-            );
3648
-            $this->_template_args['success'] = $success;
3649
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3650
-                $default_data,
3651
-                $this->_template_args['data']
3652
-            ) : $default_data;
3653
-            $this->_return_json();
3654
-        }
3655
-        wp_safe_redirect($redirect_url);
3656
-        exit();
3657
-    }
3658
-
3659
-
3660
-    /**
3661
-     * process any notices before redirecting (or returning ajax request)
3662
-     * This method sets the $this->_template_args['notices'] attribute;
3663
-     *
3664
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3665
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3666
-     *                                  page_routes haven't been defined yet.
3667
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3668
-     *                                  still save a transient for the notice.
3669
-     * @return void
3670
-     * @throws EE_Error
3671
-     * @throws InvalidArgumentException
3672
-     * @throws InvalidDataTypeException
3673
-     * @throws InvalidInterfaceException
3674
-     */
3675
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3676
-    {
3677
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3678
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3679
-            $notices = EE_Error::get_notices(false);
3680
-            if (empty($this->_template_args['success'])) {
3681
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3682
-            }
3683
-            if (empty($this->_template_args['errors'])) {
3684
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3685
-            }
3686
-            if (empty($this->_template_args['attention'])) {
3687
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3688
-            }
3689
-        }
3690
-        $this->_template_args['notices'] = EE_Error::get_notices();
3691
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3692
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3693
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3694
-            $this->_add_transient(
3695
-                $route,
3696
-                $this->_template_args['notices'],
3697
-                true,
3698
-                $skip_route_verify
3699
-            );
3700
-        }
3701
-    }
3702
-
3703
-
3704
-    /**
3705
-     * get_action_link_or_button
3706
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3707
-     *
3708
-     * @param string $action        use this to indicate which action the url is generated with.
3709
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3710
-     *                              property.
3711
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3712
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3713
-     * @param string $base_url      If this is not provided
3714
-     *                              the _admin_base_url will be used as the default for the button base_url.
3715
-     *                              Otherwise this value will be used.
3716
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3717
-     * @return string
3718
-     * @throws InvalidArgumentException
3719
-     * @throws InvalidInterfaceException
3720
-     * @throws InvalidDataTypeException
3721
-     * @throws EE_Error
3722
-     */
3723
-    public function get_action_link_or_button(
3724
-        $action,
3725
-        $type = 'add',
3726
-        $extra_request = array(),
3727
-        $class = 'button-primary',
3728
-        $base_url = '',
3729
-        $exclude_nonce = false
3730
-    ) {
3731
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3732
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3733
-            throw new EE_Error(
3734
-                sprintf(
3735
-                    esc_html__(
3736
-                        'There is no page route for given action for the button.  This action was given: %s',
3737
-                        'event_espresso'
3738
-                    ),
3739
-                    $action
3740
-                )
3741
-            );
3742
-        }
3743
-        if (! isset($this->_labels['buttons'][ $type ])) {
3744
-            throw new EE_Error(
3745
-                sprintf(
3746
-                    __(
3747
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3748
-                        'event_espresso'
3749
-                    ),
3750
-                    $type
3751
-                )
3752
-            );
3753
-        }
3754
-        // finally check user access for this button.
3755
-        $has_access = $this->check_user_access($action, true);
3756
-        if (! $has_access) {
3757
-            return '';
3758
-        }
3759
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3760
-        $query_args = array(
3761
-            'action' => $action,
3762
-        );
3763
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3764
-        if (! empty($extra_request)) {
3765
-            $query_args = array_merge($extra_request, $query_args);
3766
-        }
3767
-        $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3768
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3769
-    }
3770
-
3771
-
3772
-    /**
3773
-     * _per_page_screen_option
3774
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3775
-     *
3776
-     * @return void
3777
-     * @throws InvalidArgumentException
3778
-     * @throws InvalidInterfaceException
3779
-     * @throws InvalidDataTypeException
3780
-     */
3781
-    protected function _per_page_screen_option()
3782
-    {
3783
-        $option = 'per_page';
3784
-        $args = array(
3785
-            'label'   => apply_filters(
3786
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3787
-                $this->_admin_page_title,
3788
-                $this
3789
-            ),
3790
-            'default' => (int) apply_filters(
3791
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3792
-                20
3793
-            ),
3794
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3795
-        );
3796
-        // ONLY add the screen option if the user has access to it.
3797
-        if ($this->check_user_access($this->_current_view, true)) {
3798
-            add_screen_option($option, $args);
3799
-        }
3800
-    }
3801
-
3802
-
3803
-    /**
3804
-     * set_per_page_screen_option
3805
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3806
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3807
-     * admin_menu.
3808
-     *
3809
-     * @return void
3810
-     */
3811
-    private function _set_per_page_screen_options()
3812
-    {
3813
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3814
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3815
-            if (! $user = wp_get_current_user()) {
3816
-                return;
3817
-            }
3818
-            $option = $_POST['wp_screen_options']['option'];
3819
-            $value = $_POST['wp_screen_options']['value'];
3820
-            if ($option !== sanitize_key($option)) {
3821
-                return;
3822
-            }
3823
-            $map_option = $option;
3824
-            $option = str_replace('-', '_', $option);
3825
-            switch ($map_option) {
3826
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3827
-                    $value = (int) $value;
3828
-                    $max_value = apply_filters(
3829
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3830
-                        999,
3831
-                        $this->_current_page,
3832
-                        $this->_current_view
3833
-                    );
3834
-                    if ($value < 1) {
3835
-                        return;
3836
-                    }
3837
-                    $value = min($value, $max_value);
3838
-                    break;
3839
-                default:
3840
-                    $value = apply_filters(
3841
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3842
-                        false,
3843
-                        $option,
3844
-                        $value
3845
-                    );
3846
-                    if (false === $value) {
3847
-                        return;
3848
-                    }
3849
-                    break;
3850
-            }
3851
-            update_user_meta($user->ID, $option, $value);
3852
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3853
-            exit;
3854
-        }
3855
-    }
3856
-
3857
-
3858
-    /**
3859
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3860
-     *
3861
-     * @param array $data array that will be assigned to template args.
3862
-     */
3863
-    public function set_template_args($data)
3864
-    {
3865
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3866
-    }
3867
-
3868
-
3869
-    /**
3870
-     * This makes available the WP transient system for temporarily moving data between routes
3871
-     *
3872
-     * @param string $route             the route that should receive the transient
3873
-     * @param array  $data              the data that gets sent
3874
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3875
-     *                                  normal route transient.
3876
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3877
-     *                                  when we are adding a transient before page_routes have been defined.
3878
-     * @return void
3879
-     * @throws EE_Error
3880
-     */
3881
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3882
-    {
3883
-        $user_id = get_current_user_id();
3884
-        if (! $skip_route_verify) {
3885
-            $this->_verify_route($route);
3886
-        }
3887
-        // now let's set the string for what kind of transient we're setting
3888
-        $transient = $notices
3889
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3890
-            : 'rte_tx_' . $route . '_' . $user_id;
3891
-        $data = $notices ? array('notices' => $data) : $data;
3892
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3893
-        $existing = is_multisite() && is_network_admin()
3894
-            ? get_site_transient($transient)
3895
-            : get_transient($transient);
3896
-        if ($existing) {
3897
-            $data = array_merge((array) $data, (array) $existing);
3898
-        }
3899
-        if (is_multisite() && is_network_admin()) {
3900
-            set_site_transient($transient, $data, 8);
3901
-        } else {
3902
-            set_transient($transient, $data, 8);
3903
-        }
3904
-    }
3905
-
3906
-
3907
-    /**
3908
-     * this retrieves the temporary transient that has been set for moving data between routes.
3909
-     *
3910
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3911
-     * @param string $route
3912
-     * @return mixed data
3913
-     */
3914
-    protected function _get_transient($notices = false, $route = '')
3915
-    {
3916
-        $user_id = get_current_user_id();
3917
-        $route = ! $route ? $this->_req_action : $route;
3918
-        $transient = $notices
3919
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3920
-            : 'rte_tx_' . $route . '_' . $user_id;
3921
-        $data = is_multisite() && is_network_admin()
3922
-            ? get_site_transient($transient)
3923
-            : get_transient($transient);
3924
-        // delete transient after retrieval (just in case it hasn't expired);
3925
-        if (is_multisite() && is_network_admin()) {
3926
-            delete_site_transient($transient);
3927
-        } else {
3928
-            delete_transient($transient);
3929
-        }
3930
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3931
-    }
3932
-
3933
-
3934
-    /**
3935
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3936
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3937
-     * default route callback on the EE_Admin page you want it run.)
3938
-     *
3939
-     * @return void
3940
-     */
3941
-    protected function _transient_garbage_collection()
3942
-    {
3943
-        global $wpdb;
3944
-        // retrieve all existing transients
3945
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3946
-        if ($results = $wpdb->get_results($query)) {
3947
-            foreach ($results as $result) {
3948
-                $transient = str_replace('_transient_', '', $result->option_name);
3949
-                get_transient($transient);
3950
-                if (is_multisite() && is_network_admin()) {
3951
-                    get_site_transient($transient);
3952
-                }
3953
-            }
3954
-        }
3955
-    }
3956
-
3957
-
3958
-    /**
3959
-     * get_view
3960
-     *
3961
-     * @return string content of _view property
3962
-     */
3963
-    public function get_view()
3964
-    {
3965
-        return $this->_view;
3966
-    }
3967
-
3968
-
3969
-    /**
3970
-     * getter for the protected $_views property
3971
-     *
3972
-     * @return array
3973
-     */
3974
-    public function get_views()
3975
-    {
3976
-        return $this->_views;
3977
-    }
3978
-
3979
-
3980
-    /**
3981
-     * get_current_page
3982
-     *
3983
-     * @return string _current_page property value
3984
-     */
3985
-    public function get_current_page()
3986
-    {
3987
-        return $this->_current_page;
3988
-    }
3989
-
3990
-
3991
-    /**
3992
-     * get_current_view
3993
-     *
3994
-     * @return string _current_view property value
3995
-     */
3996
-    public function get_current_view()
3997
-    {
3998
-        return $this->_current_view;
3999
-    }
4000
-
4001
-
4002
-    /**
4003
-     * get_current_screen
4004
-     *
4005
-     * @return object The current WP_Screen object
4006
-     */
4007
-    public function get_current_screen()
4008
-    {
4009
-        return $this->_current_screen;
4010
-    }
4011
-
4012
-
4013
-    /**
4014
-     * get_current_page_view_url
4015
-     *
4016
-     * @return string This returns the url for the current_page_view.
4017
-     */
4018
-    public function get_current_page_view_url()
4019
-    {
4020
-        return $this->_current_page_view_url;
4021
-    }
4022
-
4023
-
4024
-    /**
4025
-     * just returns the _req_data property
4026
-     *
4027
-     * @return array
4028
-     */
4029
-    public function get_request_data()
4030
-    {
4031
-        return $this->_req_data;
4032
-    }
4033
-
4034
-
4035
-    /**
4036
-     * returns the _req_data protected property
4037
-     *
4038
-     * @return string
4039
-     */
4040
-    public function get_req_action()
4041
-    {
4042
-        return $this->_req_action;
4043
-    }
4044
-
4045
-
4046
-    /**
4047
-     * @return bool  value of $_is_caf property
4048
-     */
4049
-    public function is_caf()
4050
-    {
4051
-        return $this->_is_caf;
4052
-    }
4053
-
4054
-
4055
-    /**
4056
-     * @return mixed
4057
-     */
4058
-    public function default_espresso_metaboxes()
4059
-    {
4060
-        return $this->_default_espresso_metaboxes;
4061
-    }
4062
-
4063
-
4064
-    /**
4065
-     * @return mixed
4066
-     */
4067
-    public function admin_base_url()
4068
-    {
4069
-        return $this->_admin_base_url;
4070
-    }
4071
-
4072
-
4073
-    /**
4074
-     * @return mixed
4075
-     */
4076
-    public function wp_page_slug()
4077
-    {
4078
-        return $this->_wp_page_slug;
4079
-    }
4080
-
4081
-
4082
-    /**
4083
-     * updates  espresso configuration settings
4084
-     *
4085
-     * @param string                   $tab
4086
-     * @param EE_Config_Base|EE_Config $config
4087
-     * @param string                   $file file where error occurred
4088
-     * @param string                   $func function  where error occurred
4089
-     * @param string                   $line line no where error occurred
4090
-     * @return boolean
4091
-     */
4092
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4093
-    {
4094
-        // remove any options that are NOT going to be saved with the config settings.
4095
-        if (isset($config->core->ee_ueip_optin)) {
4096
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4097
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4098
-            update_option('ee_ueip_has_notified', true);
4099
-        }
4100
-        // and save it (note we're also doing the network save here)
4101
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4102
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4103
-        if ($config_saved && $net_saved) {
4104
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4105
-            return true;
4106
-        }
4107
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4108
-        return false;
4109
-    }
4110
-
4111
-
4112
-    /**
4113
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4114
-     *
4115
-     * @return array
4116
-     */
4117
-    public function get_yes_no_values()
4118
-    {
4119
-        return $this->_yes_no_values;
4120
-    }
4121
-
4122
-
4123
-    /**
4124
-     * @return string
4125
-     * @throws ReflectionException
4126
-     * @since $VID:$
4127
-     */
4128
-    protected function _get_dir()
4129
-    {
4130
-        $reflector = new ReflectionClass(get_class($this));
4131
-        return dirname($reflector->getFileName());
4132
-    }
4133
-
4134
-
4135
-    /**
4136
-     * A helper for getting a "next link".
4137
-     *
4138
-     * @param string $url   The url to link to
4139
-     * @param string $class The class to use.
4140
-     * @return string
4141
-     */
4142
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4143
-    {
4144
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4145
-    }
4146
-
4147
-
4148
-    /**
4149
-     * A helper for getting a "previous link".
4150
-     *
4151
-     * @param string $url   The url to link to
4152
-     * @param string $class The class to use.
4153
-     * @return string
4154
-     */
4155
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4156
-    {
4157
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4158
-    }
4159
-
4160
-
4161
-
4162
-
4163
-
4164
-
4165
-
4166
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4167
-
4168
-
4169
-    /**
4170
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4171
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4172
-     * _req_data array.
4173
-     *
4174
-     * @return bool success/fail
4175
-     * @throws EE_Error
4176
-     * @throws InvalidArgumentException
4177
-     * @throws ReflectionException
4178
-     * @throws InvalidDataTypeException
4179
-     * @throws InvalidInterfaceException
4180
-     */
4181
-    protected function _process_resend_registration()
4182
-    {
4183
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4184
-        do_action(
4185
-            'AHEE__EE_Admin_Page___process_resend_registration',
4186
-            $this->_template_args['success'],
4187
-            $this->_req_data
4188
-        );
4189
-        return $this->_template_args['success'];
4190
-    }
4191
-
4192
-
4193
-    /**
4194
-     * This automatically processes any payment message notifications when manual payment has been applied.
4195
-     *
4196
-     * @param EE_Payment $payment
4197
-     * @return bool success/fail
4198
-     */
4199
-    protected function _process_payment_notification(EE_Payment $payment)
4200
-    {
4201
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4202
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4203
-        $this->_template_args['success'] = apply_filters(
4204
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4205
-            false,
4206
-            $payment
4207
-        );
4208
-        return $this->_template_args['success'];
4209
-    }
2740
+	}
2741
+
2742
+
2743
+	/**
2744
+	 * facade for add_meta_box
2745
+	 *
2746
+	 * @param string  $action        where the metabox get's displayed
2747
+	 * @param string  $title         Title of Metabox (output in metabox header)
2748
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2749
+	 *                               instead of the one created in here.
2750
+	 * @param array   $callback_args an array of args supplied for the metabox
2751
+	 * @param string  $column        what metabox column
2752
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2753
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2754
+	 *                               created but just set our own callback for wp's add_meta_box.
2755
+	 * @throws DomainException
2756
+	 */
2757
+	public function _add_admin_page_meta_box(
2758
+		$action,
2759
+		$title,
2760
+		$callback,
2761
+		$callback_args,
2762
+		$column = 'normal',
2763
+		$priority = 'high',
2764
+		$create_func = true
2765
+	) {
2766
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2767
+		// 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.
2768
+		if (empty($callback_args) && $create_func) {
2769
+			$callback_args = array(
2770
+				'template_path' => $this->_template_path,
2771
+				'template_args' => $this->_template_args,
2772
+			);
2773
+		}
2774
+		// 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)
2775
+		$call_back_func = $create_func
2776
+			? static function ($post, $metabox) {
2777
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2778
+				echo EEH_Template::display_template(
2779
+					$metabox['args']['template_path'],
2780
+					$metabox['args']['template_args'],
2781
+					true
2782
+				);
2783
+			}
2784
+			: $callback;
2785
+		add_meta_box(
2786
+			str_replace('_', '-', $action) . '-mbox',
2787
+			$title,
2788
+			$call_back_func,
2789
+			$this->_wp_page_slug,
2790
+			$column,
2791
+			$priority,
2792
+			$callback_args
2793
+		);
2794
+	}
2795
+
2796
+
2797
+	/**
2798
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2799
+	 *
2800
+	 * @throws DomainException
2801
+	 * @throws EE_Error
2802
+	 * @throws InvalidArgumentException
2803
+	 * @throws InvalidDataTypeException
2804
+	 * @throws InvalidInterfaceException
2805
+	 */
2806
+	public function display_admin_page_with_metabox_columns()
2807
+	{
2808
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2809
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2810
+			$this->_column_template_path,
2811
+			$this->_template_args,
2812
+			true
2813
+		);
2814
+		// the final wrapper
2815
+		$this->admin_page_wrapper();
2816
+	}
2817
+
2818
+
2819
+	/**
2820
+	 * generates  HTML wrapper for an admin details page
2821
+	 *
2822
+	 * @return void
2823
+	 * @throws DomainException
2824
+	 * @throws EE_Error
2825
+	 * @throws InvalidArgumentException
2826
+	 * @throws InvalidDataTypeException
2827
+	 * @throws InvalidInterfaceException
2828
+	 */
2829
+	public function display_admin_page_with_sidebar()
2830
+	{
2831
+		$this->_display_admin_page(true);
2832
+	}
2833
+
2834
+
2835
+	/**
2836
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2837
+	 *
2838
+	 * @return void
2839
+	 * @throws DomainException
2840
+	 * @throws EE_Error
2841
+	 * @throws InvalidArgumentException
2842
+	 * @throws InvalidDataTypeException
2843
+	 * @throws InvalidInterfaceException
2844
+	 */
2845
+	public function display_admin_page_with_no_sidebar()
2846
+	{
2847
+		$this->_display_admin_page();
2848
+	}
2849
+
2850
+
2851
+	/**
2852
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2853
+	 *
2854
+	 * @return void
2855
+	 * @throws DomainException
2856
+	 * @throws EE_Error
2857
+	 * @throws InvalidArgumentException
2858
+	 * @throws InvalidDataTypeException
2859
+	 * @throws InvalidInterfaceException
2860
+	 */
2861
+	public function display_about_admin_page()
2862
+	{
2863
+		$this->_display_admin_page(false, true);
2864
+	}
2865
+
2866
+
2867
+	/**
2868
+	 * display_admin_page
2869
+	 * contains the code for actually displaying an admin page
2870
+	 *
2871
+	 * @param boolean $sidebar true with sidebar, false without
2872
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2873
+	 * @return void
2874
+	 * @throws DomainException
2875
+	 * @throws EE_Error
2876
+	 * @throws InvalidArgumentException
2877
+	 * @throws InvalidDataTypeException
2878
+	 * @throws InvalidInterfaceException
2879
+	 */
2880
+	private function _display_admin_page($sidebar = false, $about = false)
2881
+	{
2882
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2883
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2884
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2885
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2886
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2887
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2888
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2889
+			? 'poststuff'
2890
+			: 'espresso-default-admin';
2891
+		$template_path = $sidebar
2892
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2893
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2894
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2895
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2896
+		}
2897
+		$template_path = ! empty($this->_column_template_path)
2898
+			? $this->_column_template_path : $template_path;
2899
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2900
+			? $this->_template_args['admin_page_content']
2901
+			: '';
2902
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2903
+			? $this->_template_args['before_admin_page_content']
2904
+			: '';
2905
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2906
+			? $this->_template_args['after_admin_page_content']
2907
+			: '';
2908
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2909
+			$template_path,
2910
+			$this->_template_args,
2911
+			true
2912
+		);
2913
+		// the final template wrapper
2914
+		$this->admin_page_wrapper($about);
2915
+	}
2916
+
2917
+
2918
+	/**
2919
+	 * This is used to display caf preview pages.
2920
+	 *
2921
+	 * @since 4.3.2
2922
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2923
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2924
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2925
+	 * @return void
2926
+	 * @throws DomainException
2927
+	 * @throws EE_Error
2928
+	 * @throws InvalidArgumentException
2929
+	 * @throws InvalidDataTypeException
2930
+	 * @throws InvalidInterfaceException
2931
+	 */
2932
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2933
+	{
2934
+		// let's generate a default preview action button if there isn't one already present.
2935
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2936
+			'Upgrade to Event Espresso 4 Right Now',
2937
+			'event_espresso'
2938
+		);
2939
+		$buy_now_url = add_query_arg(
2940
+			array(
2941
+				'ee_ver'       => 'ee4',
2942
+				'utm_source'   => 'ee4_plugin_admin',
2943
+				'utm_medium'   => 'link',
2944
+				'utm_campaign' => $utm_campaign_source,
2945
+				'utm_content'  => 'buy_now_button',
2946
+			),
2947
+			'http://eventespresso.com/pricing/'
2948
+		);
2949
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2950
+			? $this->get_action_link_or_button(
2951
+				'',
2952
+				'buy_now',
2953
+				array(),
2954
+				'button-primary button-large',
2955
+				$buy_now_url,
2956
+				true
2957
+			)
2958
+			: $this->_template_args['preview_action_button'];
2959
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2960
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2961
+			$this->_template_args,
2962
+			true
2963
+		);
2964
+		$this->_display_admin_page($display_sidebar);
2965
+	}
2966
+
2967
+
2968
+	/**
2969
+	 * display_admin_list_table_page_with_sidebar
2970
+	 * generates HTML wrapper for an admin_page with list_table
2971
+	 *
2972
+	 * @return void
2973
+	 * @throws DomainException
2974
+	 * @throws EE_Error
2975
+	 * @throws InvalidArgumentException
2976
+	 * @throws InvalidDataTypeException
2977
+	 * @throws InvalidInterfaceException
2978
+	 */
2979
+	public function display_admin_list_table_page_with_sidebar()
2980
+	{
2981
+		$this->_display_admin_list_table_page(true);
2982
+	}
2983
+
2984
+
2985
+	/**
2986
+	 * display_admin_list_table_page_with_no_sidebar
2987
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2988
+	 *
2989
+	 * @return void
2990
+	 * @throws DomainException
2991
+	 * @throws EE_Error
2992
+	 * @throws InvalidArgumentException
2993
+	 * @throws InvalidDataTypeException
2994
+	 * @throws InvalidInterfaceException
2995
+	 */
2996
+	public function display_admin_list_table_page_with_no_sidebar()
2997
+	{
2998
+		$this->_display_admin_list_table_page();
2999
+	}
3000
+
3001
+
3002
+	/**
3003
+	 * generates html wrapper for an admin_list_table page
3004
+	 *
3005
+	 * @param boolean $sidebar whether to display with sidebar or not.
3006
+	 * @return void
3007
+	 * @throws DomainException
3008
+	 * @throws EE_Error
3009
+	 * @throws InvalidArgumentException
3010
+	 * @throws InvalidDataTypeException
3011
+	 * @throws InvalidInterfaceException
3012
+	 */
3013
+	private function _display_admin_list_table_page($sidebar = false)
3014
+	{
3015
+		// setup search attributes
3016
+		$this->_set_search_attributes();
3017
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
3018
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
3020
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3021
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
3022
+		$this->_template_args['list_table'] = $this->_list_table_object;
3023
+		$this->_template_args['current_route'] = $this->_req_action;
3024
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
3026
+		if (! empty($ajax_sorting_callback)) {
3027
+			$sortable_list_table_form_fields = wp_nonce_field(
3028
+				$ajax_sorting_callback . '_nonce',
3029
+				$ajax_sorting_callback . '_nonce',
3030
+				false,
3031
+				false
3032
+			);
3033
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
+												. $this->page_slug
3035
+												. '" />';
3036
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
+												. $ajax_sorting_callback
3038
+												. '" />';
3039
+		} else {
3040
+			$sortable_list_table_form_fields = '';
3041
+		}
3042
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
3044
+			? $this->_template_args['list_table_hidden_fields']
3045
+			: '';
3046
+		$nonce_ref = $this->_req_action . '_nonce';
3047
+		$hidden_form_fields .= '<input type="hidden" name="'
3048
+							   . $nonce_ref
3049
+							   . '" value="'
3050
+							   . wp_create_nonce($nonce_ref)
3051
+							   . '">';
3052
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3053
+		// display message about search results?
3054
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3055
+			? '<p class="ee-search-results">' . sprintf(
3056
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3057
+				trim($this->_req_data['s'], '%')
3058
+			) . '</p>'
3059
+			: '';
3060
+		// filter before_list_table template arg
3061
+		$this->_template_args['before_list_table'] = apply_filters(
3062
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3063
+			$this->_template_args['before_list_table'],
3064
+			$this->page_slug,
3065
+			$this->_req_data,
3066
+			$this->_req_action
3067
+		);
3068
+		// convert to array and filter again
3069
+		// arrays are easier to inject new items in a specific location,
3070
+		// but would not be backwards compatible, so we have to add a new filter
3071
+		$this->_template_args['before_list_table'] = implode(
3072
+			" \n",
3073
+			(array) apply_filters(
3074
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3075
+				(array) $this->_template_args['before_list_table'],
3076
+				$this->page_slug,
3077
+				$this->_req_data,
3078
+				$this->_req_action
3079
+			)
3080
+		);
3081
+		// filter after_list_table template arg
3082
+		$this->_template_args['after_list_table'] = apply_filters(
3083
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3084
+			$this->_template_args['after_list_table'],
3085
+			$this->page_slug,
3086
+			$this->_req_data,
3087
+			$this->_req_action
3088
+		);
3089
+		// convert to array and filter again
3090
+		// arrays are easier to inject new items in a specific location,
3091
+		// but would not be backwards compatible, so we have to add a new filter
3092
+		$this->_template_args['after_list_table'] = implode(
3093
+			" \n",
3094
+			(array) apply_filters(
3095
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3096
+				(array) $this->_template_args['after_list_table'],
3097
+				$this->page_slug,
3098
+				$this->_req_data,
3099
+				$this->_req_action
3100
+			)
3101
+		);
3102
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3103
+			$template_path,
3104
+			$this->_template_args,
3105
+			true
3106
+		);
3107
+		// the final template wrapper
3108
+		if ($sidebar) {
3109
+			$this->display_admin_page_with_sidebar();
3110
+		} else {
3111
+			$this->display_admin_page_with_no_sidebar();
3112
+		}
3113
+	}
3114
+
3115
+
3116
+	/**
3117
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3118
+	 * html string for the legend.
3119
+	 * $items are expected in an array in the following format:
3120
+	 * $legend_items = array(
3121
+	 *        'item_id' => array(
3122
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3123
+	 *            'desc' => esc_html__('localized description of item');
3124
+	 *        )
3125
+	 * );
3126
+	 *
3127
+	 * @param  array $items see above for format of array
3128
+	 * @return string html string of legend
3129
+	 * @throws DomainException
3130
+	 */
3131
+	protected function _display_legend($items)
3132
+	{
3133
+		$this->_template_args['items'] = apply_filters(
3134
+			'FHEE__EE_Admin_Page___display_legend__items',
3135
+			(array) $items,
3136
+			$this
3137
+		);
3138
+		return EEH_Template::display_template(
3139
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3140
+			$this->_template_args,
3141
+			true
3142
+		);
3143
+	}
3144
+
3145
+
3146
+	/**
3147
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3148
+	 * The returned json object is created from an array in the following format:
3149
+	 * array(
3150
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3151
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3152
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3153
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3154
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3155
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3156
+	 *  that might be included in here)
3157
+	 * )
3158
+	 * The json object is populated by whatever is set in the $_template_args property.
3159
+	 *
3160
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3161
+	 *                                 instead of displayed.
3162
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3163
+	 * @return void
3164
+	 * @throws EE_Error
3165
+	 * @throws InvalidArgumentException
3166
+	 * @throws InvalidDataTypeException
3167
+	 * @throws InvalidInterfaceException
3168
+	 */
3169
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3170
+	{
3171
+		// make sure any EE_Error notices have been handled.
3172
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3173
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3174
+		unset($this->_template_args['data']);
3175
+		$json = array(
3176
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3177
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3178
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3179
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3180
+			'notices'   => EE_Error::get_notices(),
3181
+			'content'   => isset($this->_template_args['admin_page_content'])
3182
+				? $this->_template_args['admin_page_content'] : '',
3183
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3184
+			'isEEajax'  => true
3185
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3186
+		);
3187
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3188
+		if (null === error_get_last() || ! headers_sent()) {
3189
+			header('Content-Type: application/json; charset=UTF-8');
3190
+		}
3191
+		echo wp_json_encode($json);
3192
+		exit();
3193
+	}
3194
+
3195
+
3196
+	/**
3197
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3198
+	 *
3199
+	 * @return void
3200
+	 * @throws EE_Error
3201
+	 * @throws InvalidArgumentException
3202
+	 * @throws InvalidDataTypeException
3203
+	 * @throws InvalidInterfaceException
3204
+	 */
3205
+	public function return_json()
3206
+	{
3207
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3208
+			$this->_return_json();
3209
+		} else {
3210
+			throw new EE_Error(
3211
+				sprintf(
3212
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3213
+					__FUNCTION__
3214
+				)
3215
+			);
3216
+		}
3217
+	}
3218
+
3219
+
3220
+	/**
3221
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3222
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3223
+	 *
3224
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3225
+	 */
3226
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3227
+	{
3228
+		$this->_hook_obj = $hook_obj;
3229
+	}
3230
+
3231
+
3232
+	/**
3233
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3234
+	 *
3235
+	 * @param boolean $about whether to use the special about page wrapper or default.
3236
+	 * @return void
3237
+	 * @throws DomainException
3238
+	 * @throws EE_Error
3239
+	 * @throws InvalidArgumentException
3240
+	 * @throws InvalidDataTypeException
3241
+	 * @throws InvalidInterfaceException
3242
+	 */
3243
+	public function admin_page_wrapper($about = false)
3244
+	{
3245
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3246
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3247
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3248
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3249
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3250
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3251
+			isset($this->_template_args['before_admin_page_content'])
3252
+				? $this->_template_args['before_admin_page_content']
3253
+				: ''
3254
+		);
3255
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3256
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3257
+			isset($this->_template_args['after_admin_page_content'])
3258
+				? $this->_template_args['after_admin_page_content']
3259
+				: ''
3260
+		);
3261
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3262
+		// load settings page wrapper template
3263
+		$template_path = ! defined('DOING_AJAX')
3264
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3265
+			: EE_ADMIN_TEMPLATE
3266
+			  . 'admin_wrapper_ajax.template.php';
3267
+		// about page?
3268
+		$template_path = $about
3269
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3270
+			: $template_path;
3271
+		if (defined('DOING_AJAX')) {
3272
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3273
+				$template_path,
3274
+				$this->_template_args,
3275
+				true
3276
+			);
3277
+			$this->_return_json();
3278
+		} else {
3279
+			EEH_Template::display_template($template_path, $this->_template_args);
3280
+		}
3281
+	}
3282
+
3283
+
3284
+	/**
3285
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3286
+	 *
3287
+	 * @return string html
3288
+	 * @throws EE_Error
3289
+	 */
3290
+	protected function _get_main_nav_tabs()
3291
+	{
3292
+		// let's generate the html using the EEH_Tabbed_Content helper.
3293
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3294
+		// (rather than setting in the page_routes array)
3295
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3296
+	}
3297
+
3298
+
3299
+	/**
3300
+	 *        sort nav tabs
3301
+	 *
3302
+	 * @param $a
3303
+	 * @param $b
3304
+	 * @return int
3305
+	 */
3306
+	private function _sort_nav_tabs($a, $b)
3307
+	{
3308
+		if ($a['order'] === $b['order']) {
3309
+			return 0;
3310
+		}
3311
+		return ($a['order'] < $b['order']) ? -1 : 1;
3312
+	}
3313
+
3314
+
3315
+	/**
3316
+	 *    generates HTML for the forms used on admin pages
3317
+	 *
3318
+	 * @param    array $input_vars - array of input field details
3319
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3320
+	 *                             use)
3321
+	 * @param bool     $id
3322
+	 * @return string
3323
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3324
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3325
+	 */
3326
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3327
+	{
3328
+		return $generator === 'string'
3329
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3330
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3331
+	}
3332
+
3333
+
3334
+	/**
3335
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3336
+	 *
3337
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3338
+	 *                                   Close" button.
3339
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3340
+	 *                                   'Save', [1] => 'save & close')
3341
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3342
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3343
+	 *                                   default actions by submitting some other value.
3344
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3345
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3346
+	 *                                   close (normal form handling).
3347
+	 */
3348
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3349
+	{
3350
+		// make sure $text and $actions are in an array
3351
+		$text = (array) $text;
3352
+		$actions = (array) $actions;
3353
+		$referrer_url = empty($referrer)
3354
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3355
+			  . $_SERVER['REQUEST_URI']
3356
+			  . '" />'
3357
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3358
+			  . $referrer
3359
+			  . '" />';
3360
+		$button_text = ! empty($text)
3361
+			? $text
3362
+			: array(
3363
+				esc_html__('Save', 'event_espresso'),
3364
+				esc_html__('Save and Close', 'event_espresso'),
3365
+			);
3366
+		$default_names = array('save', 'save_and_close');
3367
+		// add in a hidden index for the current page (so save and close redirects properly)
3368
+		$this->_template_args['save_buttons'] = $referrer_url;
3369
+		foreach ($button_text as $key => $button) {
3370
+			$ref = $default_names[ $key ];
3371
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3372
+													 . $ref
3373
+													 . '" value="'
3374
+													 . $button
3375
+													 . '" name="'
3376
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3377
+													 . '" id="'
3378
+													 . $this->_current_view . '_' . $ref
3379
+													 . '" />';
3380
+			if (! $both) {
3381
+				break;
3382
+			}
3383
+		}
3384
+	}
3385
+
3386
+
3387
+	/**
3388
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3389
+	 *
3390
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3391
+	 * @since 4.6.0
3392
+	 * @param string $route
3393
+	 * @param array  $additional_hidden_fields
3394
+	 */
3395
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3396
+	{
3397
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3398
+	}
3399
+
3400
+
3401
+	/**
3402
+	 * set form open and close tags on add/edit pages.
3403
+	 *
3404
+	 * @param string $route                    the route you want the form to direct to
3405
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3406
+	 * @return void
3407
+	 */
3408
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3409
+	{
3410
+		if (empty($route)) {
3411
+			$user_msg = esc_html__(
3412
+				'An error occurred. No action was set for this page\'s form.',
3413
+				'event_espresso'
3414
+			);
3415
+			$dev_msg = $user_msg . "\n"
3416
+					   . sprintf(
3417
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3418
+						   __FUNCTION__,
3419
+						   EE_Admin_Page::class
3420
+					   );
3421
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3422
+		}
3423
+		// open form
3424
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3425
+															 . $this->_admin_base_url
3426
+															 . '" id="'
3427
+															 . $route
3428
+															 . '_event_form" >';
3429
+		// add nonce
3430
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3431
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3432
+		// add REQUIRED form action
3433
+		$hidden_fields = array(
3434
+			'action' => array('type' => 'hidden', 'value' => $route),
3435
+		);
3436
+		// merge arrays
3437
+		$hidden_fields = is_array($additional_hidden_fields)
3438
+			? array_merge($hidden_fields, $additional_hidden_fields)
3439
+			: $hidden_fields;
3440
+		// generate form fields
3441
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3442
+		// add fields to form
3443
+		foreach ((array) $form_fields as $field_name => $form_field) {
3444
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3445
+		}
3446
+		// close form
3447
+		$this->_template_args['after_admin_page_content'] = '</form>';
3448
+	}
3449
+
3450
+
3451
+	/**
3452
+	 * Public Wrapper for _redirect_after_action() method since its
3453
+	 * discovered it would be useful for external code to have access.
3454
+	 *
3455
+	 * @param bool   $success
3456
+	 * @param string $what
3457
+	 * @param string $action_desc
3458
+	 * @param array  $query_args
3459
+	 * @param bool   $override_overwrite
3460
+	 * @throws EE_Error
3461
+	 * @throws InvalidArgumentException
3462
+	 * @throws InvalidDataTypeException
3463
+	 * @throws InvalidInterfaceException
3464
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3465
+	 * @since 4.5.0
3466
+	 */
3467
+	public function redirect_after_action(
3468
+		$success = false,
3469
+		$what = 'item',
3470
+		$action_desc = 'processed',
3471
+		$query_args = array(),
3472
+		$override_overwrite = false
3473
+	) {
3474
+		$this->_redirect_after_action(
3475
+			$success,
3476
+			$what,
3477
+			$action_desc,
3478
+			$query_args,
3479
+			$override_overwrite
3480
+		);
3481
+	}
3482
+
3483
+
3484
+	/**
3485
+	 * Helper method for merging existing request data with the returned redirect url.
3486
+	 *
3487
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3488
+	 * filters are still applied.
3489
+	 *
3490
+	 * @param array $new_route_data
3491
+	 * @return array
3492
+	 */
3493
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3494
+	{
3495
+		foreach ($this->_req_data as $ref => $value) {
3496
+			// unset nonces
3497
+			if (strpos($ref, 'nonce') !== false) {
3498
+				unset($this->_req_data[ $ref ]);
3499
+				continue;
3500
+			}
3501
+			// urlencode values.
3502
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3503
+			$this->_req_data[ $ref ] = $value;
3504
+		}
3505
+		return array_merge($this->_req_data, $new_route_data);
3506
+	}
3507
+
3508
+
3509
+	/**
3510
+	 *    _redirect_after_action
3511
+	 *
3512
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3513
+	 * @param string $what               - what the action was performed on
3514
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3515
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3516
+	 *                                   action is completed
3517
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3518
+	 *                                   override this so that they show.
3519
+	 * @return void
3520
+	 * @throws EE_Error
3521
+	 * @throws InvalidArgumentException
3522
+	 * @throws InvalidDataTypeException
3523
+	 * @throws InvalidInterfaceException
3524
+	 */
3525
+	protected function _redirect_after_action(
3526
+		$success = 0,
3527
+		$what = 'item',
3528
+		$action_desc = 'processed',
3529
+		$query_args = array(),
3530
+		$override_overwrite = false
3531
+	) {
3532
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3533
+		// class name for actions/filters.
3534
+		$classname = get_class($this);
3535
+		// set redirect url.
3536
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3537
+		// otherwise we go with whatever is set as the _admin_base_url
3538
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3539
+		$notices = EE_Error::get_notices(false);
3540
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3541
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3542
+			EE_Error::overwrite_success();
3543
+		}
3544
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3545
+			// how many records affected ? more than one record ? or just one ?
3546
+			if ($success > 1) {
3547
+				// set plural msg
3548
+				EE_Error::add_success(
3549
+					sprintf(
3550
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3551
+						$what,
3552
+						$action_desc
3553
+					),
3554
+					__FILE__,
3555
+					__FUNCTION__,
3556
+					__LINE__
3557
+				);
3558
+			} elseif ($success === 1) {
3559
+				// set singular msg
3560
+				EE_Error::add_success(
3561
+					sprintf(
3562
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3563
+						$what,
3564
+						$action_desc
3565
+					),
3566
+					__FILE__,
3567
+					__FUNCTION__,
3568
+					__LINE__
3569
+				);
3570
+			}
3571
+		}
3572
+		// check that $query_args isn't something crazy
3573
+		if (! is_array($query_args)) {
3574
+			$query_args = array();
3575
+		}
3576
+		/**
3577
+		 * Allow injecting actions before the query_args are modified for possible different
3578
+		 * redirections on save and close actions
3579
+		 *
3580
+		 * @since 4.2.0
3581
+		 * @param array $query_args       The original query_args array coming into the
3582
+		 *                                method.
3583
+		 */
3584
+		do_action(
3585
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3586
+			$query_args
3587
+		);
3588
+		// calculate where we're going (if we have a "save and close" button pushed)
3589
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3590
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3591
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3592
+			// regenerate query args array from referrer URL
3593
+			parse_str($parsed_url['query'], $query_args);
3594
+			// correct page and action will be in the query args now
3595
+			$redirect_url = admin_url('admin.php');
3596
+		}
3597
+		// merge any default query_args set in _default_route_query_args property
3598
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3599
+			$args_to_merge = array();
3600
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3601
+				// is there a wp_referer array in our _default_route_query_args property?
3602
+				if ($query_param === 'wp_referer') {
3603
+					$query_value = (array) $query_value;
3604
+					foreach ($query_value as $reference => $value) {
3605
+						if (strpos($reference, 'nonce') !== false) {
3606
+							continue;
3607
+						}
3608
+						// finally we will override any arguments in the referer with
3609
+						// what might be set on the _default_route_query_args array.
3610
+						if (isset($this->_default_route_query_args[ $reference ])) {
3611
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3612
+						} else {
3613
+							$args_to_merge[ $reference ] = urlencode($value);
3614
+						}
3615
+					}
3616
+					continue;
3617
+				}
3618
+				$args_to_merge[ $query_param ] = $query_value;
3619
+			}
3620
+			// now let's merge these arguments but override with what was specifically sent in to the
3621
+			// redirect.
3622
+			$query_args = array_merge($args_to_merge, $query_args);
3623
+		}
3624
+		$this->_process_notices($query_args);
3625
+		// generate redirect url
3626
+		// if redirecting to anything other than the main page, add a nonce
3627
+		if (isset($query_args['action'])) {
3628
+			// manually generate wp_nonce and merge that with the query vars
3629
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3630
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3631
+		}
3632
+		// we're adding some hooks and filters in here for processing any things just before redirects
3633
+		// (example: an admin page has done an insert or update and we want to run something after that).
3634
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3635
+		$redirect_url = apply_filters(
3636
+			'FHEE_redirect_' . $classname . $this->_req_action,
3637
+			EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3638
+			$query_args
3639
+		);
3640
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3641
+		if (defined('DOING_AJAX')) {
3642
+			$default_data = array(
3643
+				'close'        => true,
3644
+				'redirect_url' => $redirect_url,
3645
+				'where'        => 'main',
3646
+				'what'         => 'append',
3647
+			);
3648
+			$this->_template_args['success'] = $success;
3649
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3650
+				$default_data,
3651
+				$this->_template_args['data']
3652
+			) : $default_data;
3653
+			$this->_return_json();
3654
+		}
3655
+		wp_safe_redirect($redirect_url);
3656
+		exit();
3657
+	}
3658
+
3659
+
3660
+	/**
3661
+	 * process any notices before redirecting (or returning ajax request)
3662
+	 * This method sets the $this->_template_args['notices'] attribute;
3663
+	 *
3664
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3665
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3666
+	 *                                  page_routes haven't been defined yet.
3667
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3668
+	 *                                  still save a transient for the notice.
3669
+	 * @return void
3670
+	 * @throws EE_Error
3671
+	 * @throws InvalidArgumentException
3672
+	 * @throws InvalidDataTypeException
3673
+	 * @throws InvalidInterfaceException
3674
+	 */
3675
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3676
+	{
3677
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3678
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3679
+			$notices = EE_Error::get_notices(false);
3680
+			if (empty($this->_template_args['success'])) {
3681
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3682
+			}
3683
+			if (empty($this->_template_args['errors'])) {
3684
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3685
+			}
3686
+			if (empty($this->_template_args['attention'])) {
3687
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3688
+			}
3689
+		}
3690
+		$this->_template_args['notices'] = EE_Error::get_notices();
3691
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3692
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3693
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3694
+			$this->_add_transient(
3695
+				$route,
3696
+				$this->_template_args['notices'],
3697
+				true,
3698
+				$skip_route_verify
3699
+			);
3700
+		}
3701
+	}
3702
+
3703
+
3704
+	/**
3705
+	 * get_action_link_or_button
3706
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3707
+	 *
3708
+	 * @param string $action        use this to indicate which action the url is generated with.
3709
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3710
+	 *                              property.
3711
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3712
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3713
+	 * @param string $base_url      If this is not provided
3714
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3715
+	 *                              Otherwise this value will be used.
3716
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3717
+	 * @return string
3718
+	 * @throws InvalidArgumentException
3719
+	 * @throws InvalidInterfaceException
3720
+	 * @throws InvalidDataTypeException
3721
+	 * @throws EE_Error
3722
+	 */
3723
+	public function get_action_link_or_button(
3724
+		$action,
3725
+		$type = 'add',
3726
+		$extra_request = array(),
3727
+		$class = 'button-primary',
3728
+		$base_url = '',
3729
+		$exclude_nonce = false
3730
+	) {
3731
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3732
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3733
+			throw new EE_Error(
3734
+				sprintf(
3735
+					esc_html__(
3736
+						'There is no page route for given action for the button.  This action was given: %s',
3737
+						'event_espresso'
3738
+					),
3739
+					$action
3740
+				)
3741
+			);
3742
+		}
3743
+		if (! isset($this->_labels['buttons'][ $type ])) {
3744
+			throw new EE_Error(
3745
+				sprintf(
3746
+					__(
3747
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3748
+						'event_espresso'
3749
+					),
3750
+					$type
3751
+				)
3752
+			);
3753
+		}
3754
+		// finally check user access for this button.
3755
+		$has_access = $this->check_user_access($action, true);
3756
+		if (! $has_access) {
3757
+			return '';
3758
+		}
3759
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3760
+		$query_args = array(
3761
+			'action' => $action,
3762
+		);
3763
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3764
+		if (! empty($extra_request)) {
3765
+			$query_args = array_merge($extra_request, $query_args);
3766
+		}
3767
+		$url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3768
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3769
+	}
3770
+
3771
+
3772
+	/**
3773
+	 * _per_page_screen_option
3774
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3775
+	 *
3776
+	 * @return void
3777
+	 * @throws InvalidArgumentException
3778
+	 * @throws InvalidInterfaceException
3779
+	 * @throws InvalidDataTypeException
3780
+	 */
3781
+	protected function _per_page_screen_option()
3782
+	{
3783
+		$option = 'per_page';
3784
+		$args = array(
3785
+			'label'   => apply_filters(
3786
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3787
+				$this->_admin_page_title,
3788
+				$this
3789
+			),
3790
+			'default' => (int) apply_filters(
3791
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3792
+				20
3793
+			),
3794
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3795
+		);
3796
+		// ONLY add the screen option if the user has access to it.
3797
+		if ($this->check_user_access($this->_current_view, true)) {
3798
+			add_screen_option($option, $args);
3799
+		}
3800
+	}
3801
+
3802
+
3803
+	/**
3804
+	 * set_per_page_screen_option
3805
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3806
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3807
+	 * admin_menu.
3808
+	 *
3809
+	 * @return void
3810
+	 */
3811
+	private function _set_per_page_screen_options()
3812
+	{
3813
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3814
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3815
+			if (! $user = wp_get_current_user()) {
3816
+				return;
3817
+			}
3818
+			$option = $_POST['wp_screen_options']['option'];
3819
+			$value = $_POST['wp_screen_options']['value'];
3820
+			if ($option !== sanitize_key($option)) {
3821
+				return;
3822
+			}
3823
+			$map_option = $option;
3824
+			$option = str_replace('-', '_', $option);
3825
+			switch ($map_option) {
3826
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3827
+					$value = (int) $value;
3828
+					$max_value = apply_filters(
3829
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3830
+						999,
3831
+						$this->_current_page,
3832
+						$this->_current_view
3833
+					);
3834
+					if ($value < 1) {
3835
+						return;
3836
+					}
3837
+					$value = min($value, $max_value);
3838
+					break;
3839
+				default:
3840
+					$value = apply_filters(
3841
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3842
+						false,
3843
+						$option,
3844
+						$value
3845
+					);
3846
+					if (false === $value) {
3847
+						return;
3848
+					}
3849
+					break;
3850
+			}
3851
+			update_user_meta($user->ID, $option, $value);
3852
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3853
+			exit;
3854
+		}
3855
+	}
3856
+
3857
+
3858
+	/**
3859
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3860
+	 *
3861
+	 * @param array $data array that will be assigned to template args.
3862
+	 */
3863
+	public function set_template_args($data)
3864
+	{
3865
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3866
+	}
3867
+
3868
+
3869
+	/**
3870
+	 * This makes available the WP transient system for temporarily moving data between routes
3871
+	 *
3872
+	 * @param string $route             the route that should receive the transient
3873
+	 * @param array  $data              the data that gets sent
3874
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3875
+	 *                                  normal route transient.
3876
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3877
+	 *                                  when we are adding a transient before page_routes have been defined.
3878
+	 * @return void
3879
+	 * @throws EE_Error
3880
+	 */
3881
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3882
+	{
3883
+		$user_id = get_current_user_id();
3884
+		if (! $skip_route_verify) {
3885
+			$this->_verify_route($route);
3886
+		}
3887
+		// now let's set the string for what kind of transient we're setting
3888
+		$transient = $notices
3889
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3890
+			: 'rte_tx_' . $route . '_' . $user_id;
3891
+		$data = $notices ? array('notices' => $data) : $data;
3892
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3893
+		$existing = is_multisite() && is_network_admin()
3894
+			? get_site_transient($transient)
3895
+			: get_transient($transient);
3896
+		if ($existing) {
3897
+			$data = array_merge((array) $data, (array) $existing);
3898
+		}
3899
+		if (is_multisite() && is_network_admin()) {
3900
+			set_site_transient($transient, $data, 8);
3901
+		} else {
3902
+			set_transient($transient, $data, 8);
3903
+		}
3904
+	}
3905
+
3906
+
3907
+	/**
3908
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3909
+	 *
3910
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3911
+	 * @param string $route
3912
+	 * @return mixed data
3913
+	 */
3914
+	protected function _get_transient($notices = false, $route = '')
3915
+	{
3916
+		$user_id = get_current_user_id();
3917
+		$route = ! $route ? $this->_req_action : $route;
3918
+		$transient = $notices
3919
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3920
+			: 'rte_tx_' . $route . '_' . $user_id;
3921
+		$data = is_multisite() && is_network_admin()
3922
+			? get_site_transient($transient)
3923
+			: get_transient($transient);
3924
+		// delete transient after retrieval (just in case it hasn't expired);
3925
+		if (is_multisite() && is_network_admin()) {
3926
+			delete_site_transient($transient);
3927
+		} else {
3928
+			delete_transient($transient);
3929
+		}
3930
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3931
+	}
3932
+
3933
+
3934
+	/**
3935
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3936
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3937
+	 * default route callback on the EE_Admin page you want it run.)
3938
+	 *
3939
+	 * @return void
3940
+	 */
3941
+	protected function _transient_garbage_collection()
3942
+	{
3943
+		global $wpdb;
3944
+		// retrieve all existing transients
3945
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3946
+		if ($results = $wpdb->get_results($query)) {
3947
+			foreach ($results as $result) {
3948
+				$transient = str_replace('_transient_', '', $result->option_name);
3949
+				get_transient($transient);
3950
+				if (is_multisite() && is_network_admin()) {
3951
+					get_site_transient($transient);
3952
+				}
3953
+			}
3954
+		}
3955
+	}
3956
+
3957
+
3958
+	/**
3959
+	 * get_view
3960
+	 *
3961
+	 * @return string content of _view property
3962
+	 */
3963
+	public function get_view()
3964
+	{
3965
+		return $this->_view;
3966
+	}
3967
+
3968
+
3969
+	/**
3970
+	 * getter for the protected $_views property
3971
+	 *
3972
+	 * @return array
3973
+	 */
3974
+	public function get_views()
3975
+	{
3976
+		return $this->_views;
3977
+	}
3978
+
3979
+
3980
+	/**
3981
+	 * get_current_page
3982
+	 *
3983
+	 * @return string _current_page property value
3984
+	 */
3985
+	public function get_current_page()
3986
+	{
3987
+		return $this->_current_page;
3988
+	}
3989
+
3990
+
3991
+	/**
3992
+	 * get_current_view
3993
+	 *
3994
+	 * @return string _current_view property value
3995
+	 */
3996
+	public function get_current_view()
3997
+	{
3998
+		return $this->_current_view;
3999
+	}
4000
+
4001
+
4002
+	/**
4003
+	 * get_current_screen
4004
+	 *
4005
+	 * @return object The current WP_Screen object
4006
+	 */
4007
+	public function get_current_screen()
4008
+	{
4009
+		return $this->_current_screen;
4010
+	}
4011
+
4012
+
4013
+	/**
4014
+	 * get_current_page_view_url
4015
+	 *
4016
+	 * @return string This returns the url for the current_page_view.
4017
+	 */
4018
+	public function get_current_page_view_url()
4019
+	{
4020
+		return $this->_current_page_view_url;
4021
+	}
4022
+
4023
+
4024
+	/**
4025
+	 * just returns the _req_data property
4026
+	 *
4027
+	 * @return array
4028
+	 */
4029
+	public function get_request_data()
4030
+	{
4031
+		return $this->_req_data;
4032
+	}
4033
+
4034
+
4035
+	/**
4036
+	 * returns the _req_data protected property
4037
+	 *
4038
+	 * @return string
4039
+	 */
4040
+	public function get_req_action()
4041
+	{
4042
+		return $this->_req_action;
4043
+	}
4044
+
4045
+
4046
+	/**
4047
+	 * @return bool  value of $_is_caf property
4048
+	 */
4049
+	public function is_caf()
4050
+	{
4051
+		return $this->_is_caf;
4052
+	}
4053
+
4054
+
4055
+	/**
4056
+	 * @return mixed
4057
+	 */
4058
+	public function default_espresso_metaboxes()
4059
+	{
4060
+		return $this->_default_espresso_metaboxes;
4061
+	}
4062
+
4063
+
4064
+	/**
4065
+	 * @return mixed
4066
+	 */
4067
+	public function admin_base_url()
4068
+	{
4069
+		return $this->_admin_base_url;
4070
+	}
4071
+
4072
+
4073
+	/**
4074
+	 * @return mixed
4075
+	 */
4076
+	public function wp_page_slug()
4077
+	{
4078
+		return $this->_wp_page_slug;
4079
+	}
4080
+
4081
+
4082
+	/**
4083
+	 * updates  espresso configuration settings
4084
+	 *
4085
+	 * @param string                   $tab
4086
+	 * @param EE_Config_Base|EE_Config $config
4087
+	 * @param string                   $file file where error occurred
4088
+	 * @param string                   $func function  where error occurred
4089
+	 * @param string                   $line line no where error occurred
4090
+	 * @return boolean
4091
+	 */
4092
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4093
+	{
4094
+		// remove any options that are NOT going to be saved with the config settings.
4095
+		if (isset($config->core->ee_ueip_optin)) {
4096
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4097
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4098
+			update_option('ee_ueip_has_notified', true);
4099
+		}
4100
+		// and save it (note we're also doing the network save here)
4101
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4102
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4103
+		if ($config_saved && $net_saved) {
4104
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4105
+			return true;
4106
+		}
4107
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4108
+		return false;
4109
+	}
4110
+
4111
+
4112
+	/**
4113
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4114
+	 *
4115
+	 * @return array
4116
+	 */
4117
+	public function get_yes_no_values()
4118
+	{
4119
+		return $this->_yes_no_values;
4120
+	}
4121
+
4122
+
4123
+	/**
4124
+	 * @return string
4125
+	 * @throws ReflectionException
4126
+	 * @since $VID:$
4127
+	 */
4128
+	protected function _get_dir()
4129
+	{
4130
+		$reflector = new ReflectionClass(get_class($this));
4131
+		return dirname($reflector->getFileName());
4132
+	}
4133
+
4134
+
4135
+	/**
4136
+	 * A helper for getting a "next link".
4137
+	 *
4138
+	 * @param string $url   The url to link to
4139
+	 * @param string $class The class to use.
4140
+	 * @return string
4141
+	 */
4142
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4143
+	{
4144
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4145
+	}
4146
+
4147
+
4148
+	/**
4149
+	 * A helper for getting a "previous link".
4150
+	 *
4151
+	 * @param string $url   The url to link to
4152
+	 * @param string $class The class to use.
4153
+	 * @return string
4154
+	 */
4155
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4156
+	{
4157
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4158
+	}
4159
+
4160
+
4161
+
4162
+
4163
+
4164
+
4165
+
4166
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4167
+
4168
+
4169
+	/**
4170
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4171
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4172
+	 * _req_data array.
4173
+	 *
4174
+	 * @return bool success/fail
4175
+	 * @throws EE_Error
4176
+	 * @throws InvalidArgumentException
4177
+	 * @throws ReflectionException
4178
+	 * @throws InvalidDataTypeException
4179
+	 * @throws InvalidInterfaceException
4180
+	 */
4181
+	protected function _process_resend_registration()
4182
+	{
4183
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4184
+		do_action(
4185
+			'AHEE__EE_Admin_Page___process_resend_registration',
4186
+			$this->_template_args['success'],
4187
+			$this->_req_data
4188
+		);
4189
+		return $this->_template_args['success'];
4190
+	}
4191
+
4192
+
4193
+	/**
4194
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4195
+	 *
4196
+	 * @param EE_Payment $payment
4197
+	 * @return bool success/fail
4198
+	 */
4199
+	protected function _process_payment_notification(EE_Payment $payment)
4200
+	{
4201
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4202
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4203
+		$this->_template_args['success'] = apply_filters(
4204
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4205
+			false,
4206
+			$payment
4207
+		);
4208
+		return $this->_template_args['success'];
4209
+	}
4210 4210
 }
Please login to merge, or discard this patch.
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         );
523 523
         global $ee_menu_slugs;
524 524
         $ee_menu_slugs = (array) $ee_menu_slugs;
525
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
525
+        if ( ! defined('DOING_AJAX') && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))) {
526 526
             return;
527 527
         }
528 528
         // 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
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             ? $this->_req_data['route']
547 547
             : $this->_req_action;
548 548
         $this->_current_view = $this->_req_action;
549
-        $this->_req_nonce = $this->_req_action . '_nonce';
549
+        $this->_req_nonce = $this->_req_action.'_nonce';
550 550
         $this->_define_page_props();
551 551
         $this->_current_page_view_url = add_query_arg(
552 552
             array('page' => $this->_current_page, 'action' => $this->_current_view),
@@ -580,21 +580,21 @@  discard block
 block discarded – undo
580 580
         }
581 581
         // filter routes and page_config so addons can add their stuff. Filtering done per class
582 582
         $this->_page_routes = apply_filters(
583
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
583
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
584 584
             $this->_page_routes,
585 585
             $this
586 586
         );
587 587
         $this->_page_config = apply_filters(
588
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
588
+            'FHEE__'.get_class($this).'__page_setup__page_config',
589 589
             $this->_page_config,
590 590
             $this
591 591
         );
592 592
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
593 593
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
594
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
594
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
595 595
             add_action(
596 596
                 'AHEE__EE_Admin_Page__route_admin_request',
597
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
597
+                array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view),
598 598
                 10,
599 599
                 2
600 600
             );
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
             if ($this->_is_UI_request) {
608 608
                 // admin_init stuff - global, all views for this page class, specific view
609 609
                 add_action('admin_init', array($this, 'admin_init'), 10);
610
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
611
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
610
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
611
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
612 612
                 }
613 613
             } else {
614 614
                 // hijack regular WP loading and route admin request immediately
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
      */
628 628
     private function _do_other_page_hooks()
629 629
     {
630
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
630
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
631 631
         foreach ($registered_pages as $page) {
632 632
             // now let's setup the file name and class that should be present
633 633
             $classname = str_replace('.class.php', '', $page);
634 634
             // autoloaders should take care of loading file
635
-            if (! class_exists($classname)) {
635
+            if ( ! class_exists($classname)) {
636 636
                 $error_msg[] = sprintf(
637 637
                     esc_html__(
638 638
                         'Something went wrong with loading the %s admin hooks page.',
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
                                    ),
650 650
                                    $page,
651 651
                                    '<br />',
652
-                                   '<strong>' . $classname . '</strong>'
652
+                                   '<strong>'.$classname.'</strong>'
653 653
                                );
654 654
                 throw new EE_Error(implode('||', $error_msg));
655 655
             }
@@ -696,13 +696,13 @@  discard block
 block discarded – undo
696 696
         // load admin_notices - global, page class, and view specific
697 697
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
698 698
         add_action('admin_notices', array($this, 'admin_notices'), 10);
699
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
700
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
699
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
700
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
701 701
         }
702 702
         // load network admin_notices - global, page class, and view specific
703 703
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
704
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
705
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
704
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
705
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
706 706
         }
707 707
         // this will save any per_page screen options if they are present
708 708
         $this->_set_per_page_screen_options();
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
      */
824 824
     protected function _verify_routes()
825 825
     {
826
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
826
+        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
827 827
             return false;
828 828
         }
829 829
         $this->_route = false;
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
                 $this->_admin_page_title
836 836
             );
837 837
             // developer error msg
838
-            $error_msg .= '||' . $error_msg
838
+            $error_msg .= '||'.$error_msg
839 839
                           . esc_html__(
840 840
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
841 841
                               'event_espresso'
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
         }
845 845
         // and that the requested page route exists
846 846
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
847
-            $this->_route = $this->_page_routes[ $this->_req_action ];
848
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
849
-                ? $this->_page_config[ $this->_req_action ] : array();
847
+            $this->_route = $this->_page_routes[$this->_req_action];
848
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
849
+                ? $this->_page_config[$this->_req_action] : array();
850 850
         } else {
851 851
             // user error msg
852 852
             $error_msg = sprintf(
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
                 $this->_admin_page_title
858 858
             );
859 859
             // developer error msg
860
-            $error_msg .= '||' . $error_msg
860
+            $error_msg .= '||'.$error_msg
861 861
                           . sprintf(
862 862
                               esc_html__(
863 863
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
             throw new EE_Error($error_msg);
869 869
         }
870 870
         // and that a default route exists
871
-        if (! array_key_exists('default', $this->_page_routes)) {
871
+        if ( ! array_key_exists('default', $this->_page_routes)) {
872 872
             // user error msg
873 873
             $error_msg = sprintf(
874 874
                 esc_html__(
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
                 $this->_admin_page_title
879 879
             );
880 880
             // developer error msg
881
-            $error_msg .= '||' . $error_msg
881
+            $error_msg .= '||'.$error_msg
882 882
                           . esc_html__(
883 883
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
884 884
                               'event_espresso'
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
             $this->_admin_page_title
919 919
         );
920 920
         // developer error msg
921
-        $error_msg .= '||' . $error_msg
921
+        $error_msg .= '||'.$error_msg
922 922
                       . sprintf(
923 923
                           esc_html__(
924 924
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
     protected function _verify_nonce($nonce, $nonce_ref)
947 947
     {
948 948
         // verify nonce against expected value
949
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
949
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
950 950
             // these are not the droids you are looking for !!!
951 951
             $msg = sprintf(
952 952
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                             EE_Admin_Page::class
964 964
                         );
965 965
             }
966
-            if (! defined('DOING_AJAX')) {
966
+            if ( ! defined('DOING_AJAX')) {
967 967
                 wp_die($msg);
968 968
             } else {
969 969
                 EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
      */
989 989
     protected function _route_admin_request()
990 990
     {
991
-        if (! $this->_is_UI_request) {
991
+        if ( ! $this->_is_UI_request) {
992 992
             $this->_verify_routes();
993 993
         }
994 994
         $nonce_check = isset($this->_route_config['require_nonce'])
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
             : true;
997 997
         if ($this->_req_action !== 'default' && $nonce_check) {
998 998
             // set nonce from post data
999
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
1000
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
999
+            $nonce = isset($this->_req_data[$this->_req_nonce])
1000
+                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
1001 1001
                 : '';
1002 1002
             $this->_verify_nonce($nonce, $this->_req_nonce);
1003 1003
         }
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
         $error_msg = '';
1013 1013
         // action right before calling route
1014 1014
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1015
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1015
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1016 1016
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1017 1017
         }
1018 1018
         // right before calling the route, let's remove _wp_http_referer from the
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
             '_wp_http_referer',
1022 1022
             wp_unslash($_SERVER['REQUEST_URI'])
1023 1023
         );
1024
-        if (! empty($func)) {
1024
+        if ( ! empty($func)) {
1025 1025
             if (is_array($func)) {
1026 1026
                 list($class, $method) = $func;
1027 1027
             } elseif (strpos($func, '::') !== false) {
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
                 $class = $this;
1031 1031
                 $method = $func;
1032 1032
             }
1033
-            if (! (is_object($class) && $class === $this)) {
1033
+            if ( ! (is_object($class) && $class === $this)) {
1034 1034
                 // send along this admin page object for access by addons.
1035 1035
                 $args['admin_page_object'] = $this;
1036 1036
             }
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
                     $method
1064 1064
                 );
1065 1065
             }
1066
-            if (! empty($error_msg)) {
1066
+            if ( ! empty($error_msg)) {
1067 1067
                 throw new EE_Error($error_msg);
1068 1068
             }
1069 1069
         }
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
                 if (strpos($key, 'nonce') !== false) {
1147 1147
                     continue;
1148 1148
                 }
1149
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1149
+                $args['wp_referer['.$key.']'] = $value;
1150 1150
             }
1151 1151
         }
1152 1152
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1186,10 +1186,10 @@  discard block
 block discarded – undo
1186 1186
     protected function _add_help_tabs()
1187 1187
     {
1188 1188
         $tour_buttons = '';
1189
-        if (isset($this->_page_config[ $this->_req_action ])) {
1190
-            $config = $this->_page_config[ $this->_req_action ];
1189
+        if (isset($this->_page_config[$this->_req_action])) {
1190
+            $config = $this->_page_config[$this->_req_action];
1191 1191
             // is there a help tour for the current route?  if there is let's setup the tour buttons
1192
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1192
+            if (isset($this->_help_tour[$this->_req_action])) {
1193 1193
                 $tb = array();
1194 1194
                 $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1195 1195
                 foreach ($this->_help_tour['tours'] as $tour) {
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1210 1210
             if (is_array($config) && isset($config['help_sidebar'])) {
1211 1211
                 // check that the callback given is valid
1212
-                if (! method_exists($this, $config['help_sidebar'])) {
1212
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1213 1213
                     throw new EE_Error(
1214 1214
                         sprintf(
1215 1215
                             esc_html__(
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
                     );
1223 1223
                 }
1224 1224
                 $content = apply_filters(
1225
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1225
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1226 1226
                     $this->{$config['help_sidebar']}()
1227 1227
                 );
1228 1228
                 $content .= $tour_buttons; // add help tour buttons.
@@ -1230,30 +1230,30 @@  discard block
 block discarded – undo
1230 1230
                 $this->_current_screen->set_help_sidebar($content);
1231 1231
             }
1232 1232
             // if there ARE tour buttons...
1233
-            if (! empty($tour_buttons)) {
1233
+            if ( ! empty($tour_buttons)) {
1234 1234
                 // if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1235
-                if (! isset($config['help_sidebar'])) {
1235
+                if ( ! isset($config['help_sidebar'])) {
1236 1236
                     $this->_current_screen->set_help_sidebar($tour_buttons);
1237 1237
                 }
1238 1238
                 // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1239
-                if (! isset($config['help_tabs'])) {
1239
+                if ( ! isset($config['help_tabs'])) {
1240 1240
                     $_ht['id'] = $this->page_slug;
1241 1241
                     $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1242 1242
                     $_ht['content'] = '<p>'
1243 1243
                                       . esc_html__(
1244 1244
                                           'The buttons to the right allow you to start/restart any help tours available for this page',
1245 1245
                                           'event_espresso'
1246
-                                      ) . '</p>';
1246
+                                      ).'</p>';
1247 1247
                     $this->_current_screen->add_help_tab($_ht);
1248 1248
                 }
1249 1249
             }
1250
-            if (! isset($config['help_tabs'])) {
1250
+            if ( ! isset($config['help_tabs'])) {
1251 1251
                 return;
1252 1252
             } //no help tabs for this route
1253 1253
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1254 1254
                 // we're here so there ARE help tabs!
1255 1255
                 // make sure we've got what we need
1256
-                if (! isset($cfg['title'])) {
1256
+                if ( ! isset($cfg['title'])) {
1257 1257
                     throw new EE_Error(
1258 1258
                         esc_html__(
1259 1259
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
                         )
1262 1262
                     );
1263 1263
                 }
1264
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1264
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1265 1265
                     throw new EE_Error(
1266 1266
                         esc_html__(
1267 1267
                             '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',
@@ -1270,11 +1270,11 @@  discard block
 block discarded – undo
1270 1270
                     );
1271 1271
                 }
1272 1272
                 // first priority goes to content.
1273
-                if (! empty($cfg['content'])) {
1273
+                if ( ! empty($cfg['content'])) {
1274 1274
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1275 1275
                     // second priority goes to filename
1276
-                } elseif (! empty($cfg['filename'])) {
1277
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1276
+                } elseif ( ! empty($cfg['filename'])) {
1277
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1278 1278
                     // 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)
1279 1279
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1280 1280
                                                              . basename($this->_get_dir())
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
                                                              . $cfg['filename']
1283 1283
                                                              . '.help_tab.php' : $file_path;
1284 1284
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1285
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1285
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1286 1286
                         EE_Error::add_error(
1287 1287
                             sprintf(
1288 1288
                                 esc_html__(
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
                     return;
1329 1329
                 }
1330 1330
                 // setup config array for help tab method
1331
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1331
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1332 1332
                 $_ht = array(
1333 1333
                     'id'       => $id,
1334 1334
                     'title'    => $cfg['title'],
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
             }
1373 1373
             if (isset($config['help_tour'])) {
1374 1374
                 foreach ($config['help_tour'] as $tour) {
1375
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1375
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1376 1376
                     // let's see if we can get that file...
1377 1377
                     // if not its possible this is a decaf route not set in caffeinated
1378 1378
                     // so lets try and get the caffeinated equivalent
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
                                                              . $tour
1383 1383
                                                              . '.class.php' : $file_path;
1384 1384
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1385
-                    if (! is_readable($file_path)) {
1385
+                    if ( ! is_readable($file_path)) {
1386 1386
                         EE_Error::add_error(
1387 1387
                             sprintf(
1388 1388
                                 esc_html__(
@@ -1399,13 +1399,13 @@  discard block
 block discarded – undo
1399 1399
                         return;
1400 1400
                     }
1401 1401
                     require_once $file_path;
1402
-                    if (! class_exists($tour)) {
1402
+                    if ( ! class_exists($tour)) {
1403 1403
                         $error_msg = [];
1404 1404
                         $error_msg[] = sprintf(
1405 1405
                             esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1406 1406
                             $tour
1407 1407
                         );
1408
-                        $error_msg[] = $error_msg[0] . "\r\n"
1408
+                        $error_msg[] = $error_msg[0]."\r\n"
1409 1409
                                        . sprintf(
1410 1410
                                            esc_html__(
1411 1411
                                                '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.',
@@ -1421,16 +1421,16 @@  discard block
 block discarded – undo
1421 1421
                     }
1422 1422
                     $tour_obj = new $tour($this->_is_caf);
1423 1423
                     $tours[] = $tour_obj;
1424
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1424
+                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1425 1425
                 }
1426 1426
                 // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1427 1427
                 $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1428 1428
                 $tours[] = $end_stop_tour;
1429
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1429
+                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1430 1430
             }
1431 1431
         }
1432 1432
 
1433
-        if (! empty($tours)) {
1433
+        if ( ! empty($tours)) {
1434 1434
             $this->_help_tour['tours'] = $tours;
1435 1435
         }
1436 1436
         // that's it!  Now that the $_help_tours property is set (or not)
@@ -1456,8 +1456,8 @@  discard block
 block discarded – undo
1456 1456
             $qtips = (array) $this->_route_config['qtips'];
1457 1457
             // load qtip loader
1458 1458
             $path = array(
1459
-                $this->_get_dir() . '/qtips/',
1460
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1459
+                $this->_get_dir().'/qtips/',
1460
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1461 1461
             );
1462 1462
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1463 1463
         }
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1480 1480
         $i = 0;
1481 1481
         foreach ($this->_page_config as $slug => $config) {
1482
-            if (! is_array($config)
1482
+            if ( ! is_array($config)
1483 1483
                 || (
1484 1484
                     is_array($config)
1485 1485
                     && (
@@ -1496,12 +1496,12 @@  discard block
 block discarded – undo
1496 1496
                 // nav tab is only to appear when route requested.
1497 1497
                 continue;
1498 1498
             }
1499
-            if (! $this->check_user_access($slug, true)) {
1499
+            if ( ! $this->check_user_access($slug, true)) {
1500 1500
                 // no nav tab because current user does not have access.
1501 1501
                 continue;
1502 1502
             }
1503
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1504
-            $this->_nav_tabs[ $slug ] = array(
1503
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1504
+            $this->_nav_tabs[$slug] = array(
1505 1505
                 'url'       => isset($config['nav']['url'])
1506 1506
                     ? $config['nav']['url']
1507 1507
                     : EE_Admin_Page::add_query_args_and_nonce(
@@ -1513,14 +1513,14 @@  discard block
 block discarded – undo
1513 1513
                     : ucwords(
1514 1514
                         str_replace('_', ' ', $slug)
1515 1515
                     ),
1516
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1516
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1517 1517
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1518 1518
             );
1519 1519
             $i++;
1520 1520
         }
1521 1521
         // if $this->_nav_tabs is empty then lets set the default
1522 1522
         if (empty($this->_nav_tabs)) {
1523
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1523
+            $this->_nav_tabs[$this->_default_nav_tab_name] = array(
1524 1524
                 'url'       => $this->_admin_base_url,
1525 1525
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1526 1526
                 'css_class' => 'nav-tab-active',
@@ -1545,10 +1545,10 @@  discard block
 block discarded – undo
1545 1545
             foreach ($this->_route_config['labels'] as $label => $text) {
1546 1546
                 if (is_array($text)) {
1547 1547
                     foreach ($text as $sublabel => $subtext) {
1548
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1548
+                        $this->_labels[$label][$sublabel] = $subtext;
1549 1549
                     }
1550 1550
                 } else {
1551
-                    $this->_labels[ $label ] = $text;
1551
+                    $this->_labels[$label] = $text;
1552 1552
                 }
1553 1553
             }
1554 1554
         }
@@ -1570,12 +1570,12 @@  discard block
 block discarded – undo
1570 1570
     {
1571 1571
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1572 1572
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1573
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1573
+        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1574 1574
                       && is_array(
1575
-                          $this->_page_routes[ $route_to_check ]
1575
+                          $this->_page_routes[$route_to_check]
1576 1576
                       )
1577
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1578
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1577
+                      && ! empty($this->_page_routes[$route_to_check]['capability'])
1578
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1579 1579
         if (empty($capability) && empty($route_to_check)) {
1580 1580
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1581 1581
                 : $this->_route['capability'];
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
             $capability = empty($capability) ? 'manage_options' : $capability;
1584 1584
         }
1585 1585
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1586
-        if (! defined('DOING_AJAX')
1586
+        if ( ! defined('DOING_AJAX')
1587 1587
             && (
1588 1588
                 ! function_exists('is_admin')
1589 1589
                 || ! EE_Registry::instance()->CAP->current_user_can(
@@ -1688,17 +1688,17 @@  discard block
 block discarded – undo
1688 1688
     public function admin_footer_global()
1689 1689
     {
1690 1690
         // dialog container for dialog helper
1691
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1691
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1692 1692
         $d_cont .= '<div class="ee-notices"></div>';
1693 1693
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1694 1694
         $d_cont .= '</div>';
1695 1695
         echo $d_cont;
1696 1696
         // help tour stuff?
1697
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1698
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1697
+        if (isset($this->_help_tour[$this->_req_action])) {
1698
+            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1699 1699
         }
1700 1700
         // current set timezone for timezone js
1701
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1701
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1702 1702
     }
1703 1703
 
1704 1704
 
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
         // loop through the array and setup content
1733 1733
         foreach ($help_array as $trigger => $help) {
1734 1734
             // make sure the array is setup properly
1735
-            if (! isset($help['title'], $help['content'])) {
1735
+            if ( ! isset($help['title'], $help['content'])) {
1736 1736
                 throw new EE_Error(
1737 1737
                     esc_html__(
1738 1738
                         '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',
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
                 'help_popup_content' => $help['content'],
1748 1748
             );
1749 1749
             $content .= EEH_Template::display_template(
1750
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1750
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1751 1751
                 $template_args,
1752 1752
                 true
1753 1753
             );
@@ -1769,15 +1769,15 @@  discard block
 block discarded – undo
1769 1769
     private function _get_help_content()
1770 1770
     {
1771 1771
         // what is the method we're looking for?
1772
-        $method_name = '_help_popup_content_' . $this->_req_action;
1772
+        $method_name = '_help_popup_content_'.$this->_req_action;
1773 1773
         // if method doesn't exist let's get out.
1774
-        if (! method_exists($this, $method_name)) {
1774
+        if ( ! method_exists($this, $method_name)) {
1775 1775
             return array();
1776 1776
         }
1777 1777
         // k we're good to go let's retrieve the help array
1778 1778
         $help_array = $this->{$method_name}();
1779 1779
         // make sure we've got an array!
1780
-        if (! is_array($help_array)) {
1780
+        if ( ! is_array($help_array)) {
1781 1781
             throw new EE_Error(
1782 1782
                 esc_html__(
1783 1783
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1809,8 +1809,8 @@  discard block
 block discarded – undo
1809 1809
         // 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
1810 1810
         $help_array = $this->_get_help_content();
1811 1811
         $help_content = '';
1812
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1813
-            $help_array[ $trigger_id ] = array(
1812
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1813
+            $help_array[$trigger_id] = array(
1814 1814
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1815 1815
                 'content' => esc_html__(
1816 1816
                     '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.)',
@@ -1886,15 +1886,15 @@  discard block
 block discarded – undo
1886 1886
         // register all styles
1887 1887
         wp_register_style(
1888 1888
             'espresso-ui-theme',
1889
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1889
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1890 1890
             array(),
1891 1891
             EVENT_ESPRESSO_VERSION
1892 1892
         );
1893
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1893
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1894 1894
         // helpers styles
1895 1895
         wp_register_style(
1896 1896
             'ee-text-links',
1897
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1897
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1898 1898
             array(),
1899 1899
             EVENT_ESPRESSO_VERSION
1900 1900
         );
@@ -1902,21 +1902,21 @@  discard block
 block discarded – undo
1902 1902
         // register all scripts
1903 1903
         wp_register_script(
1904 1904
             'ee-dialog',
1905
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1905
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1906 1906
             array('jquery', 'jquery-ui-draggable'),
1907 1907
             EVENT_ESPRESSO_VERSION,
1908 1908
             true
1909 1909
         );
1910 1910
         wp_register_script(
1911 1911
             'ee_admin_js',
1912
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1912
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1913 1913
             array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1914 1914
             EVENT_ESPRESSO_VERSION,
1915 1915
             true
1916 1916
         );
1917 1917
         wp_register_script(
1918 1918
             'jquery-ui-timepicker-addon',
1919
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1919
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1920 1920
             array('jquery-ui-datepicker', 'jquery-ui-slider'),
1921 1921
             EVENT_ESPRESSO_VERSION,
1922 1922
             true
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
         // script for sorting tables
1928 1928
         wp_register_script(
1929 1929
             'espresso_ajax_table_sorting',
1930
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1930
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1931 1931
             array('ee_admin_js', 'jquery-ui-sortable'),
1932 1932
             EVENT_ESPRESSO_VERSION,
1933 1933
             true
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
         // script for parsing uri's
1936 1936
         wp_register_script(
1937 1937
             'ee-parse-uri',
1938
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1938
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1939 1939
             array(),
1940 1940
             EVENT_ESPRESSO_VERSION,
1941 1941
             true
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
         // and parsing associative serialized form elements
1944 1944
         wp_register_script(
1945 1945
             'ee-serialize-full-array',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1946
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1947 1947
             array('jquery'),
1948 1948
             EVENT_ESPRESSO_VERSION,
1949 1949
             true
@@ -1951,28 +1951,28 @@  discard block
 block discarded – undo
1951 1951
         // helpers scripts
1952 1952
         wp_register_script(
1953 1953
             'ee-text-links',
1954
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1954
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1955 1955
             array('jquery'),
1956 1956
             EVENT_ESPRESSO_VERSION,
1957 1957
             true
1958 1958
         );
1959 1959
         wp_register_script(
1960 1960
             'ee-moment-core',
1961
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1961
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1962 1962
             array(),
1963 1963
             EVENT_ESPRESSO_VERSION,
1964 1964
             true
1965 1965
         );
1966 1966
         wp_register_script(
1967 1967
             'ee-moment',
1968
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1968
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1969 1969
             array('ee-moment-core'),
1970 1970
             EVENT_ESPRESSO_VERSION,
1971 1971
             true
1972 1972
         );
1973 1973
         wp_register_script(
1974 1974
             'ee-datepicker',
1975
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1975
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1976 1976
             array('jquery-ui-timepicker-addon', 'ee-moment'),
1977 1977
             EVENT_ESPRESSO_VERSION,
1978 1978
             true
@@ -2004,11 +2004,11 @@  discard block
 block discarded – undo
2004 2004
         /**
2005 2005
          * help tour stuff
2006 2006
          */
2007
-        if (! empty($this->_help_tour)) {
2007
+        if ( ! empty($this->_help_tour)) {
2008 2008
             // register the js for kicking things off
2009 2009
             wp_enqueue_script(
2010 2010
                 'ee-help-tour',
2011
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
2011
+                EE_ADMIN_URL.'assets/ee-help-tour.js',
2012 2012
                 array('jquery-joyride'),
2013 2013
                 EVENT_ESPRESSO_VERSION,
2014 2014
                 true
@@ -2108,12 +2108,12 @@  discard block
 block discarded – undo
2108 2108
     protected function _set_list_table()
2109 2109
     {
2110 2110
         // first is this a list_table view?
2111
-        if (! isset($this->_route_config['list_table'])) {
2111
+        if ( ! isset($this->_route_config['list_table'])) {
2112 2112
             return;
2113 2113
         } //not a list_table view so get out.
2114 2114
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2115
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2116
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2115
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2116
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2117 2117
             // user error msg
2118 2118
             $error_msg = esc_html__(
2119 2119
                 'An error occurred. The requested list table views could not be found.',
@@ -2133,10 +2133,10 @@  discard block
 block discarded – undo
2133 2133
         }
2134 2134
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2135 2135
         $this->_views = apply_filters(
2136
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2136
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2137 2137
             $this->_views
2138 2138
         );
2139
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2139
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2140 2140
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2141 2141
         $this->_set_list_table_view();
2142 2142
         $this->_set_list_table_object();
@@ -2152,7 +2152,7 @@  discard block
 block discarded – undo
2152 2152
     {
2153 2153
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2154 2154
         // looking at active items or dumpster diving ?
2155
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2155
+        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2156 2156
             $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2157 2157
         } else {
2158 2158
             $this->_view = sanitize_key($this->_req_data['status']);
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
     protected function _set_list_table_object()
2174 2174
     {
2175 2175
         if (isset($this->_route_config['list_table'])) {
2176
-            if (! class_exists($this->_route_config['list_table'])) {
2176
+            if ( ! class_exists($this->_route_config['list_table'])) {
2177 2177
                 throw new EE_Error(
2178 2178
                     sprintf(
2179 2179
                         esc_html__(
@@ -2211,17 +2211,17 @@  discard block
 block discarded – undo
2211 2211
         foreach ($this->_views as $key => $view) {
2212 2212
             $query_args = array();
2213 2213
             // check for current view
2214
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2214
+            $this->_views[$key]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2215 2215
             $query_args['action'] = $this->_req_action;
2216
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2216
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2217 2217
             $query_args['status'] = $view['slug'];
2218 2218
             // merge any other arguments sent in.
2219
-            if (isset($extra_query_args[ $view['slug'] ])) {
2220
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2219
+            if (isset($extra_query_args[$view['slug']])) {
2220
+                foreach ($extra_query_args[$view['slug']] as $extra_query_arg) {
2221 2221
                     $query_args[] = $extra_query_arg;
2222 2222
                 }
2223 2223
             }
2224
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2224
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2225 2225
         }
2226 2226
         return $this->_views;
2227 2227
     }
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
     {
2241 2241
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2242 2242
         $values = array(10, 25, 50, 100);
2243
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2243
+        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2244 2244
         if ($max_entries) {
2245 2245
             $values[] = $max_entries;
2246 2246
             sort($values);
@@ -2252,14 +2252,14 @@  discard block
 block discarded – undo
2252 2252
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2253 2253
         foreach ($values as $value) {
2254 2254
             if ($value < $max_entries) {
2255
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2255
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2256 2256
                 $entries_per_page_dropdown .= '
2257
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2257
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2258 2258
             }
2259 2259
         }
2260
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2260
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2261 2261
         $entries_per_page_dropdown .= '
2262
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2262
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2263 2263
         $entries_per_page_dropdown .= '
2264 2264
 					</select>
2265 2265
 					entries
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
             empty($this->_search_btn_label) ? $this->page_label
2284 2284
                 : $this->_search_btn_label
2285 2285
         );
2286
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2286
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2287 2287
     }
2288 2288
 
2289 2289
 
@@ -2369,7 +2369,7 @@  discard block
 block discarded – undo
2369 2369
             $total_columns = ! empty($screen_columns)
2370 2370
                 ? $screen_columns
2371 2371
                 : $this->_route_config['columns'][1];
2372
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2372
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2373 2373
             $this->_template_args['current_page'] = $this->_wp_page_slug;
2374 2374
             $this->_template_args['screen'] = $this->_current_screen;
2375 2375
             $this->_column_template_path = EE_ADMIN_TEMPLATE
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
      */
2415 2415
     protected function _espresso_ratings_request()
2416 2416
     {
2417
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2417
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2418 2418
             return;
2419 2419
         }
2420 2420
         $ratings_box_title = apply_filters(
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
      */
2442 2442
     public function espresso_ratings_request()
2443 2443
     {
2444
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2444
+        EEH_Template::display_template(EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php');
2445 2445
     }
2446 2446
 
2447 2447
 
@@ -2452,17 +2452,17 @@  discard block
 block discarded – undo
2452 2452
                    . '</p><p class="hide-if-js">'
2453 2453
                    . esc_html__('This widget requires JavaScript.', 'event_espresso')
2454 2454
                    . '</p>';
2455
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2456
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2457
-        $post = '</div>' . "\n";
2458
-        $cache_key = 'ee_rss_' . md5($rss_id);
2455
+        $pre = '<div class="espresso-rss-display">'."\n\t";
2456
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
2457
+        $post = '</div>'."\n";
2458
+        $cache_key = 'ee_rss_'.md5($rss_id);
2459 2459
         $output = get_transient($cache_key);
2460 2460
         if ($output !== false) {
2461
-            echo $pre . $output . $post;
2461
+            echo $pre.$output.$post;
2462 2462
             return true;
2463 2463
         }
2464
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2465
-            echo $pre . $loading . $post;
2464
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2465
+            echo $pre.$loading.$post;
2466 2466
             return false;
2467 2467
         }
2468 2468
         ob_start();
@@ -2529,19 +2529,19 @@  discard block
 block discarded – undo
2529 2529
     public function espresso_sponsors_post_box()
2530 2530
     {
2531 2531
         EEH_Template::display_template(
2532
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2532
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2533 2533
         );
2534 2534
     }
2535 2535
 
2536 2536
 
2537 2537
     private function _publish_post_box()
2538 2538
     {
2539
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2539
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2540 2540
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2541 2541
         // then we'll use that for the metabox label.
2542 2542
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2543
-        if (! empty($this->_labels['publishbox'])) {
2544
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2543
+        if ( ! empty($this->_labels['publishbox'])) {
2544
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2545 2545
                 : $this->_labels['publishbox'];
2546 2546
         } else {
2547 2547
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
             ? $this->_template_args['publish_box_extra_content']
2571 2571
             : '';
2572 2572
         echo EEH_Template::display_template(
2573
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2573
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2574 2574
             $this->_template_args,
2575 2575
             true
2576 2576
         );
@@ -2660,8 +2660,8 @@  discard block
 block discarded – undo
2660 2660
             );
2661 2661
         }
2662 2662
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2663
-        if (! empty($name) && ! empty($id)) {
2664
-            $hidden_field_arr[ $name ] = array(
2663
+        if ( ! empty($name) && ! empty($id)) {
2664
+            $hidden_field_arr[$name] = array(
2665 2665
                 'type'  => 'hidden',
2666 2666
                 'value' => $id,
2667 2667
             );
@@ -2671,7 +2671,7 @@  discard block
 block discarded – undo
2671 2671
         }
2672 2672
         // add hidden field
2673 2673
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2674
-            ? $hf[ $name ]['field']
2674
+            ? $hf[$name]['field']
2675 2675
             : $hf;
2676 2676
     }
2677 2677
 
@@ -2773,7 +2773,7 @@  discard block
 block discarded – undo
2773 2773
         }
2774 2774
         // 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)
2775 2775
         $call_back_func = $create_func
2776
-            ? static function ($post, $metabox) {
2776
+            ? static function($post, $metabox) {
2777 2777
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2778 2778
                 echo EEH_Template::display_template(
2779 2779
                     $metabox['args']['template_path'],
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
             }
2784 2784
             : $callback;
2785 2785
         add_meta_box(
2786
-            str_replace('_', '-', $action) . '-mbox',
2786
+            str_replace('_', '-', $action).'-mbox',
2787 2787
             $title,
2788 2788
             $call_back_func,
2789 2789
             $this->_wp_page_slug,
@@ -2890,9 +2890,9 @@  discard block
 block discarded – undo
2890 2890
             : 'espresso-default-admin';
2891 2891
         $template_path = $sidebar
2892 2892
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2893
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2893
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2894 2894
         if (defined('DOING_AJAX') && DOING_AJAX) {
2895
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2895
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2896 2896
         }
2897 2897
         $template_path = ! empty($this->_column_template_path)
2898 2898
             ? $this->_column_template_path : $template_path;
@@ -2957,7 +2957,7 @@  discard block
 block discarded – undo
2957 2957
             )
2958 2958
             : $this->_template_args['preview_action_button'];
2959 2959
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2960
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2960
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2961 2961
             $this->_template_args,
2962 2962
             true
2963 2963
         );
@@ -3015,7 +3015,7 @@  discard block
 block discarded – undo
3015 3015
         // setup search attributes
3016 3016
         $this->_set_search_attributes();
3017 3017
         $this->_template_args['current_page'] = $this->_wp_page_slug;
3018
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3018
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
3019 3019
         $this->_template_args['table_url'] = defined('DOING_AJAX')
3020 3020
             ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3021 3021
             : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -3023,10 +3023,10 @@  discard block
 block discarded – undo
3023 3023
         $this->_template_args['current_route'] = $this->_req_action;
3024 3024
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025 3025
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
3026
-        if (! empty($ajax_sorting_callback)) {
3026
+        if ( ! empty($ajax_sorting_callback)) {
3027 3027
             $sortable_list_table_form_fields = wp_nonce_field(
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                $ajax_sorting_callback . '_nonce',
3028
+                $ajax_sorting_callback.'_nonce',
3029
+                $ajax_sorting_callback.'_nonce',
3030 3030
                 false,
3031 3031
                 false
3032 3032
             );
@@ -3043,7 +3043,7 @@  discard block
 block discarded – undo
3043 3043
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
3044 3044
             ? $this->_template_args['list_table_hidden_fields']
3045 3045
             : '';
3046
-        $nonce_ref = $this->_req_action . '_nonce';
3046
+        $nonce_ref = $this->_req_action.'_nonce';
3047 3047
         $hidden_form_fields .= '<input type="hidden" name="'
3048 3048
                                . $nonce_ref
3049 3049
                                . '" value="'
@@ -3052,10 +3052,10 @@  discard block
 block discarded – undo
3052 3052
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3053 3053
         // display message about search results?
3054 3054
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3055
-            ? '<p class="ee-search-results">' . sprintf(
3055
+            ? '<p class="ee-search-results">'.sprintf(
3056 3056
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3057 3057
                 trim($this->_req_data['s'], '%')
3058
-            ) . '</p>'
3058
+            ).'</p>'
3059 3059
             : '';
3060 3060
         // filter before_list_table template arg
3061 3061
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3136,7 +3136,7 @@  discard block
 block discarded – undo
3136 3136
             $this
3137 3137
         );
3138 3138
         return EEH_Template::display_template(
3139
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3139
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3140 3140
             $this->_template_args,
3141 3141
             true
3142 3142
         );
@@ -3367,17 +3367,17 @@  discard block
 block discarded – undo
3367 3367
         // add in a hidden index for the current page (so save and close redirects properly)
3368 3368
         $this->_template_args['save_buttons'] = $referrer_url;
3369 3369
         foreach ($button_text as $key => $button) {
3370
-            $ref = $default_names[ $key ];
3370
+            $ref = $default_names[$key];
3371 3371
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3372 3372
                                                      . $ref
3373 3373
                                                      . '" value="'
3374 3374
                                                      . $button
3375 3375
                                                      . '" name="'
3376
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3376
+                                                     . ( ! empty($actions) ? $actions[$key] : $ref)
3377 3377
                                                      . '" id="'
3378
-                                                     . $this->_current_view . '_' . $ref
3378
+                                                     . $this->_current_view.'_'.$ref
3379 3379
                                                      . '" />';
3380
-            if (! $both) {
3380
+            if ( ! $both) {
3381 3381
                 break;
3382 3382
             }
3383 3383
         }
@@ -3412,13 +3412,13 @@  discard block
 block discarded – undo
3412 3412
                 'An error occurred. No action was set for this page\'s form.',
3413 3413
                 'event_espresso'
3414 3414
             );
3415
-            $dev_msg = $user_msg . "\n"
3415
+            $dev_msg = $user_msg."\n"
3416 3416
                        . sprintf(
3417 3417
                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3418 3418
                            __FUNCTION__,
3419 3419
                            EE_Admin_Page::class
3420 3420
                        );
3421
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3421
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3422 3422
         }
3423 3423
         // open form
3424 3424
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3427,8 +3427,8 @@  discard block
 block discarded – undo
3427 3427
                                                              . $route
3428 3428
                                                              . '_event_form" >';
3429 3429
         // add nonce
3430
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3431
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3430
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3431
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3432 3432
         // add REQUIRED form action
3433 3433
         $hidden_fields = array(
3434 3434
             'action' => array('type' => 'hidden', 'value' => $route),
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3442 3442
         // add fields to form
3443 3443
         foreach ((array) $form_fields as $field_name => $form_field) {
3444
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3444
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3445 3445
         }
3446 3446
         // close form
3447 3447
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3495,12 +3495,12 @@  discard block
 block discarded – undo
3495 3495
         foreach ($this->_req_data as $ref => $value) {
3496 3496
             // unset nonces
3497 3497
             if (strpos($ref, 'nonce') !== false) {
3498
-                unset($this->_req_data[ $ref ]);
3498
+                unset($this->_req_data[$ref]);
3499 3499
                 continue;
3500 3500
             }
3501 3501
             // urlencode values.
3502 3502
             $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3503
-            $this->_req_data[ $ref ] = $value;
3503
+            $this->_req_data[$ref] = $value;
3504 3504
         }
3505 3505
         return array_merge($this->_req_data, $new_route_data);
3506 3506
     }
@@ -3538,10 +3538,10 @@  discard block
 block discarded – undo
3538 3538
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3539 3539
         $notices = EE_Error::get_notices(false);
3540 3540
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3541
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3541
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3542 3542
             EE_Error::overwrite_success();
3543 3543
         }
3544
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3544
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3545 3545
             // how many records affected ? more than one record ? or just one ?
3546 3546
             if ($success > 1) {
3547 3547
                 // set plural msg
@@ -3570,7 +3570,7 @@  discard block
 block discarded – undo
3570 3570
             }
3571 3571
         }
3572 3572
         // check that $query_args isn't something crazy
3573
-        if (! is_array($query_args)) {
3573
+        if ( ! is_array($query_args)) {
3574 3574
             $query_args = array();
3575 3575
         }
3576 3576
         /**
@@ -3595,7 +3595,7 @@  discard block
 block discarded – undo
3595 3595
             $redirect_url = admin_url('admin.php');
3596 3596
         }
3597 3597
         // merge any default query_args set in _default_route_query_args property
3598
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3598
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3599 3599
             $args_to_merge = array();
3600 3600
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3601 3601
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3607,15 +3607,15 @@  discard block
 block discarded – undo
3607 3607
                         }
3608 3608
                         // finally we will override any arguments in the referer with
3609 3609
                         // what might be set on the _default_route_query_args array.
3610
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3611
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3610
+                        if (isset($this->_default_route_query_args[$reference])) {
3611
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3612 3612
                         } else {
3613
-                            $args_to_merge[ $reference ] = urlencode($value);
3613
+                            $args_to_merge[$reference] = urlencode($value);
3614 3614
                         }
3615 3615
                     }
3616 3616
                     continue;
3617 3617
                 }
3618
-                $args_to_merge[ $query_param ] = $query_value;
3618
+                $args_to_merge[$query_param] = $query_value;
3619 3619
             }
3620 3620
             // now let's merge these arguments but override with what was specifically sent in to the
3621 3621
             // redirect.
@@ -3627,13 +3627,13 @@  discard block
 block discarded – undo
3627 3627
         if (isset($query_args['action'])) {
3628 3628
             // manually generate wp_nonce and merge that with the query vars
3629 3629
             // becuz the wp_nonce_url function wrecks havoc on some vars
3630
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3630
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3631 3631
         }
3632 3632
         // we're adding some hooks and filters in here for processing any things just before redirects
3633 3633
         // (example: an admin page has done an insert or update and we want to run something after that).
3634
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3634
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3635 3635
         $redirect_url = apply_filters(
3636
-            'FHEE_redirect_' . $classname . $this->_req_action,
3636
+            'FHEE_redirect_'.$classname.$this->_req_action,
3637 3637
             EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3638 3638
             $query_args
3639 3639
         );
@@ -3689,7 +3689,7 @@  discard block
 block discarded – undo
3689 3689
         }
3690 3690
         $this->_template_args['notices'] = EE_Error::get_notices();
3691 3691
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3692
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3692
+        if ( ! defined('DOING_AJAX') || $sticky_notices) {
3693 3693
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3694 3694
             $this->_add_transient(
3695 3695
                 $route,
@@ -3729,7 +3729,7 @@  discard block
 block discarded – undo
3729 3729
         $exclude_nonce = false
3730 3730
     ) {
3731 3731
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3732
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3732
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3733 3733
             throw new EE_Error(
3734 3734
                 sprintf(
3735 3735
                     esc_html__(
@@ -3740,7 +3740,7 @@  discard block
 block discarded – undo
3740 3740
                 )
3741 3741
             );
3742 3742
         }
3743
-        if (! isset($this->_labels['buttons'][ $type ])) {
3743
+        if ( ! isset($this->_labels['buttons'][$type])) {
3744 3744
             throw new EE_Error(
3745 3745
                 sprintf(
3746 3746
                     __(
@@ -3753,7 +3753,7 @@  discard block
 block discarded – undo
3753 3753
         }
3754 3754
         // finally check user access for this button.
3755 3755
         $has_access = $this->check_user_access($action, true);
3756
-        if (! $has_access) {
3756
+        if ( ! $has_access) {
3757 3757
             return '';
3758 3758
         }
3759 3759
         $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3761,11 +3761,11 @@  discard block
 block discarded – undo
3761 3761
             'action' => $action,
3762 3762
         );
3763 3763
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3764
-        if (! empty($extra_request)) {
3764
+        if ( ! empty($extra_request)) {
3765 3765
             $query_args = array_merge($extra_request, $query_args);
3766 3766
         }
3767 3767
         $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3768
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3768
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3769 3769
     }
3770 3770
 
3771 3771
 
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3792 3792
                 20
3793 3793
             ),
3794
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3794
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3795 3795
         );
3796 3796
         // ONLY add the screen option if the user has access to it.
3797 3797
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3812,7 +3812,7 @@  discard block
 block discarded – undo
3812 3812
     {
3813 3813
         if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3814 3814
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3815
-            if (! $user = wp_get_current_user()) {
3815
+            if ( ! $user = wp_get_current_user()) {
3816 3816
                 return;
3817 3817
             }
3818 3818
             $option = $_POST['wp_screen_options']['option'];
@@ -3823,7 +3823,7 @@  discard block
 block discarded – undo
3823 3823
             $map_option = $option;
3824 3824
             $option = str_replace('-', '_', $option);
3825 3825
             switch ($map_option) {
3826
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3826
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3827 3827
                     $value = (int) $value;
3828 3828
                     $max_value = apply_filters(
3829 3829
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
@@ -3881,13 +3881,13 @@  discard block
 block discarded – undo
3881 3881
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3882 3882
     {
3883 3883
         $user_id = get_current_user_id();
3884
-        if (! $skip_route_verify) {
3884
+        if ( ! $skip_route_verify) {
3885 3885
             $this->_verify_route($route);
3886 3886
         }
3887 3887
         // now let's set the string for what kind of transient we're setting
3888 3888
         $transient = $notices
3889
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3890
-            : 'rte_tx_' . $route . '_' . $user_id;
3889
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3890
+            : 'rte_tx_'.$route.'_'.$user_id;
3891 3891
         $data = $notices ? array('notices' => $data) : $data;
3892 3892
         // is there already a transient for this route?  If there is then let's ADD to that transient
3893 3893
         $existing = is_multisite() && is_network_admin()
@@ -3916,8 +3916,8 @@  discard block
 block discarded – undo
3916 3916
         $user_id = get_current_user_id();
3917 3917
         $route = ! $route ? $this->_req_action : $route;
3918 3918
         $transient = $notices
3919
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3920
-            : 'rte_tx_' . $route . '_' . $user_id;
3919
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3920
+            : 'rte_tx_'.$route.'_'.$user_id;
3921 3921
         $data = is_multisite() && is_network_admin()
3922 3922
             ? get_site_transient($transient)
3923 3923
             : get_transient($transient);
@@ -4141,7 +4141,7 @@  discard block
 block discarded – undo
4141 4141
      */
4142 4142
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4143 4143
     {
4144
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4144
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4145 4145
     }
4146 4146
 
4147 4147
 
@@ -4154,7 +4154,7 @@  discard block
 block discarded – undo
4154 4154
      */
4155 4155
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4156 4156
     {
4157
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4157
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4158 4158
     }
4159 4159
 
4160 4160
 
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1226 added lines, -1226 removed lines patch added patch discarded remove patch
@@ -21,1230 +21,1230 @@
 block discarded – undo
21 21
 class EE_Dependency_Map
22 22
 {
23 23
 
24
-    /**
25
-     * This means that the requested class dependency is not present in the dependency map
26
-     */
27
-    const not_registered = 0;
28
-
29
-    /**
30
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
-     */
32
-    const load_new_object = 1;
33
-
34
-    /**
35
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
-     */
38
-    const load_from_cache = 2;
39
-
40
-    /**
41
-     * When registering a dependency,
42
-     * this indicates to keep any existing dependencies that already exist,
43
-     * and simply discard any new dependencies declared in the incoming data
44
-     */
45
-    const KEEP_EXISTING_DEPENDENCIES = 0;
46
-
47
-    /**
48
-     * When registering a dependency,
49
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
-     */
51
-    const OVERWRITE_DEPENDENCIES = 1;
52
-
53
-
54
-    /**
55
-     * @type EE_Dependency_Map $_instance
56
-     */
57
-    protected static $_instance;
58
-
59
-    /**
60
-     * @var ClassInterfaceCache $class_cache
61
-     */
62
-    private $class_cache;
63
-
64
-    /**
65
-     * @type RequestInterface $request
66
-     */
67
-    protected $request;
68
-
69
-    /**
70
-     * @type LegacyRequestInterface $legacy_request
71
-     */
72
-    protected $legacy_request;
73
-
74
-    /**
75
-     * @type ResponseInterface $response
76
-     */
77
-    protected $response;
78
-
79
-    /**
80
-     * @type LoaderInterface $loader
81
-     */
82
-    protected $loader;
83
-
84
-    /**
85
-     * @type array $_dependency_map
86
-     */
87
-    protected $_dependency_map = array();
88
-
89
-    /**
90
-     * @type array $_class_loaders
91
-     */
92
-    protected $_class_loaders = array();
93
-
94
-
95
-    /**
96
-     * EE_Dependency_Map constructor.
97
-     *
98
-     * @param ClassInterfaceCache $class_cache
99
-     */
100
-    protected function __construct(ClassInterfaceCache $class_cache)
101
-    {
102
-        $this->class_cache = $class_cache;
103
-        do_action('EE_Dependency_Map____construct', $this);
104
-    }
105
-
106
-
107
-    /**
108
-     * @return void
109
-     * @throws EE_Error
110
-     * @throws InvalidAliasException
111
-     */
112
-    public function initialize()
113
-    {
114
-        $this->_register_core_dependencies();
115
-        $this->_register_core_class_loaders();
116
-        $this->_register_core_aliases();
117
-    }
118
-
119
-
120
-    /**
121
-     * @singleton method used to instantiate class object
122
-     * @param ClassInterfaceCache|null $class_cache
123
-     * @return EE_Dependency_Map
124
-     */
125
-    public static function instance(ClassInterfaceCache $class_cache = null)
126
-    {
127
-        // check if class object is instantiated, and instantiated properly
128
-        if (! self::$_instance instanceof EE_Dependency_Map
129
-            && $class_cache instanceof ClassInterfaceCache
130
-        ) {
131
-            self::$_instance = new EE_Dependency_Map($class_cache);
132
-        }
133
-        return self::$_instance;
134
-    }
135
-
136
-
137
-    /**
138
-     * @param RequestInterface $request
139
-     */
140
-    public function setRequest(RequestInterface $request)
141
-    {
142
-        $this->request = $request;
143
-    }
144
-
145
-
146
-    /**
147
-     * @param LegacyRequestInterface $legacy_request
148
-     */
149
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
150
-    {
151
-        $this->legacy_request = $legacy_request;
152
-    }
153
-
154
-
155
-    /**
156
-     * @param ResponseInterface $response
157
-     */
158
-    public function setResponse(ResponseInterface $response)
159
-    {
160
-        $this->response = $response;
161
-    }
162
-
163
-
164
-    /**
165
-     * @param LoaderInterface $loader
166
-     */
167
-    public function setLoader(LoaderInterface $loader)
168
-    {
169
-        $this->loader = $loader;
170
-    }
171
-
172
-
173
-    /**
174
-     * @param string $class
175
-     * @param array  $dependencies
176
-     * @param int    $overwrite
177
-     * @return bool
178
-     */
179
-    public static function register_dependencies(
180
-        $class,
181
-        array $dependencies,
182
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
183
-    ) {
184
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
185
-    }
186
-
187
-
188
-    /**
189
-     * Assigns an array of class names and corresponding load sources (new or cached)
190
-     * to the class specified by the first parameter.
191
-     * IMPORTANT !!!
192
-     * The order of elements in the incoming $dependencies array MUST match
193
-     * the order of the constructor parameters for the class in question.
194
-     * This is especially important when overriding any existing dependencies that are registered.
195
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
196
-     *
197
-     * @param string $class
198
-     * @param array  $dependencies
199
-     * @param int    $overwrite
200
-     * @return bool
201
-     */
202
-    public function registerDependencies(
203
-        $class,
204
-        array $dependencies,
205
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
206
-    ) {
207
-        $class = trim($class, '\\');
208
-        $registered = false;
209
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
210
-            self::$_instance->_dependency_map[ $class ] = array();
211
-        }
212
-        // we need to make sure that any aliases used when registering a dependency
213
-        // get resolved to the correct class name
214
-        foreach ($dependencies as $dependency => $load_source) {
215
-            $alias = self::$_instance->getFqnForAlias($dependency);
216
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
217
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
218
-            ) {
219
-                unset($dependencies[ $dependency ]);
220
-                $dependencies[ $alias ] = $load_source;
221
-                $registered = true;
222
-            }
223
-        }
224
-        // now add our two lists of dependencies together.
225
-        // using Union (+=) favours the arrays in precedence from left to right,
226
-        // so $dependencies is NOT overwritten because it is listed first
227
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
228
-        // Union is way faster than array_merge() but should be used with caution...
229
-        // especially with numerically indexed arrays
230
-        $dependencies += self::$_instance->_dependency_map[ $class ];
231
-        // now we need to ensure that the resulting dependencies
232
-        // array only has the entries that are required for the class
233
-        // so first count how many dependencies were originally registered for the class
234
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
235
-        // if that count is non-zero (meaning dependencies were already registered)
236
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
237
-            // then truncate the  final array to match that count
238
-            ? array_slice($dependencies, 0, $dependency_count)
239
-            // otherwise just take the incoming array because nothing previously existed
240
-            : $dependencies;
241
-        return $registered;
242
-    }
243
-
244
-
245
-    /**
246
-     * @param string $class_name
247
-     * @param string $loader
248
-     * @return bool
249
-     * @throws DomainException
250
-     */
251
-    public static function register_class_loader($class_name, $loader = 'load_core')
252
-    {
253
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
254
-            throw new DomainException(
255
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
256
-            );
257
-        }
258
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
259
-        if (! is_callable($loader)
260
-            && (
261
-                strpos($loader, 'load_') !== 0
262
-                || ! method_exists('EE_Registry', $loader)
263
-            )
264
-        ) {
265
-            throw new DomainException(
266
-                sprintf(
267
-                    esc_html__(
268
-                        '"%1$s" is not a valid loader method on EE_Registry.',
269
-                        'event_espresso'
270
-                    ),
271
-                    $loader
272
-                )
273
-            );
274
-        }
275
-        $class_name = self::$_instance->getFqnForAlias($class_name);
276
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
277
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
278
-            return true;
279
-        }
280
-        return false;
281
-    }
282
-
283
-
284
-    /**
285
-     * @return array
286
-     */
287
-    public function dependency_map()
288
-    {
289
-        return $this->_dependency_map;
290
-    }
291
-
292
-
293
-    /**
294
-     * returns TRUE if dependency map contains a listing for the provided class name
295
-     *
296
-     * @param string $class_name
297
-     * @return boolean
298
-     */
299
-    public function has($class_name = '')
300
-    {
301
-        // all legacy models have the same dependencies
302
-        if (strpos($class_name, 'EEM_') === 0) {
303
-            $class_name = 'LEGACY_MODELS';
304
-        }
305
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
306
-    }
307
-
308
-
309
-    /**
310
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
311
-     *
312
-     * @param string $class_name
313
-     * @param string $dependency
314
-     * @return bool
315
-     */
316
-    public function has_dependency_for_class($class_name = '', $dependency = '')
317
-    {
318
-        // all legacy models have the same dependencies
319
-        if (strpos($class_name, 'EEM_') === 0) {
320
-            $class_name = 'LEGACY_MODELS';
321
-        }
322
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
323
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
324
-            ? true
325
-            : false;
326
-    }
327
-
328
-
329
-    /**
330
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
331
-     *
332
-     * @param string $class_name
333
-     * @param string $dependency
334
-     * @return int
335
-     */
336
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
337
-    {
338
-        // all legacy models have the same dependencies
339
-        if (strpos($class_name, 'EEM_') === 0) {
340
-            $class_name = 'LEGACY_MODELS';
341
-        }
342
-        $dependency = $this->getFqnForAlias($dependency);
343
-        return $this->has_dependency_for_class($class_name, $dependency)
344
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
345
-            : EE_Dependency_Map::not_registered;
346
-    }
347
-
348
-
349
-    /**
350
-     * @param string $class_name
351
-     * @return string | Closure
352
-     */
353
-    public function class_loader($class_name)
354
-    {
355
-        // all legacy models use load_model()
356
-        if (strpos($class_name, 'EEM_') === 0) {
357
-            return 'load_model';
358
-        }
359
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
360
-        // perform strpos() first to avoid loading regex every time we load a class
361
-        if (strpos($class_name, 'EE_CPT_') === 0
362
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
363
-        ) {
364
-            return 'load_core';
365
-        }
366
-        $class_name = $this->getFqnForAlias($class_name);
367
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
368
-    }
369
-
370
-
371
-    /**
372
-     * @return array
373
-     */
374
-    public function class_loaders()
375
-    {
376
-        return $this->_class_loaders;
377
-    }
378
-
379
-
380
-    /**
381
-     * adds an alias for a classname
382
-     *
383
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
384
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
385
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
386
-     * @throws InvalidAliasException
387
-     */
388
-    public function add_alias($fqcn, $alias, $for_class = '')
389
-    {
390
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
391
-    }
392
-
393
-
394
-    /**
395
-     * Returns TRUE if the provided fully qualified name IS an alias
396
-     * WHY?
397
-     * Because if a class is type hinting for a concretion,
398
-     * then why would we need to find another class to supply it?
399
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
400
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
401
-     * Don't go looking for some substitute.
402
-     * Whereas if a class is type hinting for an interface...
403
-     * then we need to find an actual class to use.
404
-     * So the interface IS the alias for some other FQN,
405
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
406
-     * represents some other class.
407
-     *
408
-     * @param string $fqn
409
-     * @param string $for_class
410
-     * @return bool
411
-     */
412
-    public function isAlias($fqn = '', $for_class = '')
413
-    {
414
-        return $this->class_cache->isAlias($fqn, $for_class);
415
-    }
416
-
417
-
418
-    /**
419
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
420
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
421
-     *  for example:
422
-     *      if the following two entries were added to the _aliases array:
423
-     *          array(
424
-     *              'interface_alias'           => 'some\namespace\interface'
425
-     *              'some\namespace\interface'  => 'some\namespace\classname'
426
-     *          )
427
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
428
-     *      to load an instance of 'some\namespace\classname'
429
-     *
430
-     * @param string $alias
431
-     * @param string $for_class
432
-     * @return string
433
-     */
434
-    public function getFqnForAlias($alias = '', $for_class = '')
435
-    {
436
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
437
-    }
438
-
439
-
440
-    /**
441
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
442
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
443
-     * This is done by using the following class constants:
444
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
445
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
446
-     */
447
-    protected function _register_core_dependencies()
448
-    {
449
-        $this->_dependency_map = array(
450
-            'EE_Request_Handler'                                                                                          => array(
451
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
452
-            ),
453
-            'EE_System'                                                                                                   => array(
454
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
455
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
456
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
457
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
458
-            ),
459
-            'EE_Session'                                                                                                  => array(
460
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
461
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
462
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
463
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
464
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
465
-            ),
466
-            'EE_Cart'                                                                                                     => array(
467
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
468
-            ),
469
-            'EE_Front_Controller'                                                                                         => array(
470
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
471
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
472
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
473
-            ),
474
-            'EE_Messenger_Collection_Loader'                                                                              => array(
475
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
476
-            ),
477
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
478
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
479
-            ),
480
-            'EE_Message_Resource_Manager'                                                                                 => array(
481
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
482
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
483
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
484
-            ),
485
-            'EE_Message_Factory'                                                                                          => array(
486
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_messages'                                                                                                 => array(
489
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
490
-            ),
491
-            'EE_Messages_Generator'                                                                                       => array(
492
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
493
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
494
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
495
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
496
-            ),
497
-            'EE_Messages_Processor'                                                                                       => array(
498
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
499
-            ),
500
-            'EE_Messages_Queue'                                                                                           => array(
501
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
502
-            ),
503
-            'EE_Messages_Template_Defaults'                                                                               => array(
504
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
505
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
508
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
509
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
510
-            ),
511
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
512
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
515
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
516
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
517
-            ),
518
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
519
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
522
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
523
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
526
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
529
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
530
-            ),
531
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
532
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
533
-            ),
534
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
535
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
536
-            ),
537
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
538
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
539
-            ),
540
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
541
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
542
-            ),
543
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
544
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
545
-            ),
546
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
547
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
548
-            ),
549
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
550
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
551
-            ),
552
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
553
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
554
-            ),
555
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
556
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
557
-            ),
558
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
559
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
560
-            ),
561
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
562
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
563
-            ),
564
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
565
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_Data_Migration_Class_Base'                                                                                => 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_1_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_2_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_3_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_4_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_5_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_6_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_7_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_8_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_9_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
-            ),
607
-            'EE_DMS_Core_4_10_0' => array(
608
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
609
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
610
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
613
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
614
-                array(),
615
-            ),
616
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
617
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
618
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
619
-            ),
620
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
621
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
-            ),
623
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
624
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
-            ),
626
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
627
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
630
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
-            ),
632
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
633
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
634
-            ),
635
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
636
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
637
-            ),
638
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
639
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
640
-            ),
641
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
642
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
643
-            ),
644
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
645
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
646
-            ),
647
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
648
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
649
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
652
-                null,
653
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
654
-            ),
655
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
656
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'LEGACY_MODELS'                                                                                               => array(
659
-                null,
660
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
661
-            ),
662
-            'EE_Module_Request_Router'                                                                                    => array(
663
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
664
-            ),
665
-            'EE_Registration_Processor'                                                                                   => array(
666
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
667
-            ),
668
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
669
-                null,
670
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
671
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
674
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
675
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
678
-                null,
679
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
680
-            ),
681
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
682
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
683
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
684
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
685
-            ),
686
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
687
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
688
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
689
-            ),
690
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
691
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
692
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
693
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
694
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
695
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
696
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
697
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
698
-            ),
699
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
700
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
701
-            ),
702
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
703
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
704
-            ),
705
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
706
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
708
-            ),
709
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
710
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
711
-            ),
712
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
713
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
714
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
715
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
716
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
717
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
718
-            ),
719
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
720
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
723
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
724
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
725
-            ),
726
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
727
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
728
-            ),
729
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
730
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
-            ),
732
-            'EE_CPT_Strategy'                                                                                             => array(
733
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
734
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
735
-            ),
736
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
737
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
738
-            ),
739
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
740
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
741
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
742
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
743
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
744
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
745
-            ),
746
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
747
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
748
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
749
-            ),
750
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
751
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
754
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
755
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
756
-            ),
757
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
758
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
759
-            ),
760
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
761
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
762
-            ),
763
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
764
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
765
-            ),
766
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
767
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
768
-            ),
769
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
770
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
771
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
772
-            ),
773
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
774
-                null,
775
-                null,
776
-                null,
777
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
778
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
779
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
780
-            ),
781
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
782
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
783
-                'EE_Config' => EE_Dependency_Map::load_from_cache
784
-            ),
785
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
786
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
787
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
788
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
789
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
790
-            ),
791
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
792
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
793
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
794
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
797
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
798
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
799
-            ),
800
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
801
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
802
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
804
-            ),
805
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
806
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
807
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
808
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
809
-            ),
810
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
811
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
813
-            ),
814
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
815
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
816
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
817
-            ),
818
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
819
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
820
-            ),
821
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
822
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
823
-            ),
824
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
825
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
826
-            ),
827
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
828
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
829
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
-            ),
831
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
832
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
833
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
834
-            ),
835
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
836
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
837
-            ),
838
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
839
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
840
-            ),
841
-            'EE_URL_Validation_Strategy' => array(
842
-                null,
843
-                null,
844
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
845
-            ),
846
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
847
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
848
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
849
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
850
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
852
-            ),
853
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
854
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
856
-            ),
857
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
858
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
859
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
860
-            ),
861
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
862
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
863
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
864
-            ),
865
-            'EventEspresso\core\services\request\files\FilesDataHandler' => array(
866
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
867
-            ),
868
-            'EventEspressoBatchRequest\BatchRequestProcessor'                              => [
869
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
870
-            ],
871
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
872
-                null,
873
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
-                'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
875
-            ],
876
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
877
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
-                'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
879
-            ],
880
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
881
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
-                'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
883
-            ],
884
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
885
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
-                'EEM_Event'  => EE_Dependency_Map::load_from_cache,
887
-            ],
888
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
889
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
890
-                'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
891
-            ],
892
-            'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [
893
-                'WP_REST_Server' => EE_Dependency_Map::load_from_cache,
894
-                'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache,
895
-                'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
896
-                null
897
-            ],
898
-            'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'  => [
899
-                'EE_Admin_Config' => EE_Dependency_Map::load_from_cache
900
-            ],
901
-            'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorData'  => [
902
-                'EE_Event'        => EE_Dependency_Map::not_registered,
903
-                'EE_Admin_Config' => EE_Dependency_Map::load_from_cache,
904
-                'EEM_Datetime'    => EE_Dependency_Map::load_from_cache,
905
-                'EEM_Price'       => EE_Dependency_Map::load_from_cache,
906
-                'EEM_Ticket'      => EE_Dependency_Map::load_from_cache,
907
-            ],
908
-            'EventEspresso\core\services\graphql\GraphQLManager' => [
909
-                'EventEspresso\core\services\graphql\TypesManager'  => EE_Dependency_Map::load_from_cache,
910
-                'EventEspresso\core\services\graphql\InputsManager'  => EE_Dependency_Map::load_from_cache,
911
-                'EventEspresso\core\services\graphql\EnumsManager'  => EE_Dependency_Map::load_from_cache,
912
-                'EventEspresso\core\services\graphql\ConnectionsManager'  => EE_Dependency_Map::load_from_cache,
913
-            ],
914
-            'EventEspresso\core\services\graphql\TypesManager' => [
915
-                'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
916
-            ],
917
-            'EventEspresso\core\services\graphql\InputsManager' => [
918
-                'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
919
-            ],
920
-            'EventEspresso\core\services\graphql\EnumsManager' => [
921
-                'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
922
-            ],
923
-            'EventEspresso\core\services\graphql\ConnectionsManager' => [
924
-                'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
925
-            ],
926
-            'EventEspresso\core\domain\services\graphql\types\Datetime' => [
927
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
928
-            ],
929
-            'EventEspresso\core\domain\services\graphql\types\Attendee' => [
930
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
931
-            ],
932
-            'EventEspresso\core\domain\services\graphql\types\Event' => [
933
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
934
-            ],
935
-            'EventEspresso\core\domain\services\graphql\types\Ticket' => [
936
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
937
-            ],
938
-            'EventEspresso\core\domain\services\graphql\types\Price' => [
939
-                'EEM_Price' => EE_Dependency_Map::load_from_cache,
940
-            ],
941
-            'EventEspresso\core\domain\services\graphql\types\PriceType' => [
942
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
943
-            ],
944
-            'EventEspresso\core\domain\services\graphql\types\Venue' => [
945
-                'EEM_Venue' => EE_Dependency_Map::load_from_cache,
946
-            ],
947
-            'EventEspresso\core\domain\services\graphql\types\State' => [
948
-                'EEM_State' => EE_Dependency_Map::load_from_cache,
949
-            ],
950
-            'EventEspresso\core\domain\services\graphql\types\Country' => [
951
-                'EEM_Country' => EE_Dependency_Map::load_from_cache,
952
-            ],
953
-            'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection' => [
954
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
955
-            ],
956
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection' => [
957
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
958
-            ],
959
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection' => [
960
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
961
-            ],
962
-            'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection' => [
963
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
964
-            ],
965
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection' => [
966
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
967
-            ],
968
-            'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection' => [
969
-                'EEM_Price' => EE_Dependency_Map::load_from_cache,
970
-            ],
971
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection' => [
972
-                'EEM_Price' => EE_Dependency_Map::load_from_cache,
973
-            ],
974
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection' => [
975
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
976
-            ],
977
-            'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection' => [
978
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
979
-            ],
980
-            'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection' => [
981
-                'EEM_Venue' => EE_Dependency_Map::load_from_cache,
982
-            ],
983
-        );
984
-    }
985
-
986
-
987
-    /**
988
-     * Registers how core classes are loaded.
989
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
990
-     *        'EE_Request_Handler' => 'load_core'
991
-     *        'EE_Messages_Queue'  => 'load_lib'
992
-     *        'EEH_Debug_Tools'    => 'load_helper'
993
-     * or, if greater control is required, by providing a custom closure. For example:
994
-     *        'Some_Class' => function () {
995
-     *            return new Some_Class();
996
-     *        },
997
-     * This is required for instantiating dependencies
998
-     * where an interface has been type hinted in a class constructor. For example:
999
-     *        'Required_Interface' => function () {
1000
-     *            return new A_Class_That_Implements_Required_Interface();
1001
-     *        },
1002
-     */
1003
-    protected function _register_core_class_loaders()
1004
-    {
1005
-        $this->_class_loaders = array(
1006
-            // load_core
1007
-            'EE_Dependency_Map'                            => function () {
1008
-                return $this;
1009
-            },
1010
-            'EE_Capabilities'                              => 'load_core',
1011
-            'EE_Encryption'                                => 'load_core',
1012
-            'EE_Front_Controller'                          => 'load_core',
1013
-            'EE_Module_Request_Router'                     => 'load_core',
1014
-            'EE_Registry'                                  => 'load_core',
1015
-            'EE_Request'                                   => function () {
1016
-                return $this->legacy_request;
1017
-            },
1018
-            'EventEspresso\core\services\request\Request'  => function () {
1019
-                return $this->request;
1020
-            },
1021
-            'EventEspresso\core\services\request\Response' => function () {
1022
-                return $this->response;
1023
-            },
1024
-            'EE_Base'                                      => 'load_core',
1025
-            'EE_Request_Handler'                           => 'load_core',
1026
-            'EE_Session'                                   => 'load_core',
1027
-            'EE_Cron_Tasks'                                => 'load_core',
1028
-            'EE_System'                                    => 'load_core',
1029
-            'EE_Maintenance_Mode'                          => 'load_core',
1030
-            'EE_Register_CPTs'                             => 'load_core',
1031
-            'EE_Admin'                                     => 'load_core',
1032
-            'EE_CPT_Strategy'                              => 'load_core',
1033
-            // load_class
1034
-            'EE_Registration_Processor'                    => 'load_class',
1035
-            // load_lib
1036
-            'EE_Message_Resource_Manager'                  => 'load_lib',
1037
-            'EE_Message_Type_Collection'                   => 'load_lib',
1038
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
1039
-            'EE_Messenger_Collection'                      => 'load_lib',
1040
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
1041
-            'EE_Messages_Processor'                        => 'load_lib',
1042
-            'EE_Message_Repository'                        => 'load_lib',
1043
-            'EE_Messages_Queue'                            => 'load_lib',
1044
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
1045
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
1046
-            'EE_Payment_Method_Manager'                    => 'load_lib',
1047
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
1048
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
1049
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
1050
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
1051
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
1052
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
1053
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
1054
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
1055
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
1056
-            'EE_Messages_Generator'                        => static function () {
1057
-                return EE_Registry::instance()->load_lib(
1058
-                    'Messages_Generator',
1059
-                    array(),
1060
-                    false,
1061
-                    false
1062
-                );
1063
-            },
1064
-            'EE_Messages_Template_Defaults'                => static function ($arguments = array()) {
1065
-                return EE_Registry::instance()->load_lib(
1066
-                    'Messages_Template_Defaults',
1067
-                    $arguments,
1068
-                    false,
1069
-                    false
1070
-                );
1071
-            },
1072
-            // load_helper
1073
-            'EEH_Parse_Shortcodes'                         => static function () {
1074
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1075
-                    return new EEH_Parse_Shortcodes();
1076
-                }
1077
-                return null;
1078
-            },
1079
-            'EE_Template_Config'                           => static function () {
1080
-                return EE_Config::instance()->template_settings;
1081
-            },
1082
-            'EE_Currency_Config'                           => static function () {
1083
-                return EE_Config::instance()->currency;
1084
-            },
1085
-            'EE_Registration_Config'                       => static function () {
1086
-                return EE_Config::instance()->registration;
1087
-            },
1088
-            'EE_Core_Config'                               => static function () {
1089
-                return EE_Config::instance()->core;
1090
-            },
1091
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
1092
-                return LoaderFactory::getLoader();
1093
-            },
1094
-            'EE_Network_Config'                            => static function () {
1095
-                return EE_Network_Config::instance();
1096
-            },
1097
-            'EE_Config'                                    => static function () {
1098
-                return EE_Config::instance();
1099
-            },
1100
-            'EventEspresso\core\domain\Domain'             => static function () {
1101
-                return DomainFactory::getEventEspressoCoreDomain();
1102
-            },
1103
-            'EE_Admin_Config'                              => static function () {
1104
-                return EE_Config::instance()->admin;
1105
-            },
1106
-            'EE_Organization_Config'                       => static function () {
1107
-                return EE_Config::instance()->organization;
1108
-            },
1109
-            'EE_Network_Core_Config'                       => static function () {
1110
-                return EE_Network_Config::instance()->core;
1111
-            },
1112
-            'EE_Environment_Config'                        => static function () {
1113
-                return EE_Config::instance()->environment;
1114
-            },
1115
-            'EED_Core_Rest_Api'                            => static function () {
1116
-                return EED_Core_Rest_Api::instance();
1117
-            },
1118
-            'WP_REST_Server'                            => static function () {
1119
-                return rest_get_server();
1120
-            },
1121
-        );
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     * can be used for supplying alternate names for classes,
1127
-     * or for connecting interface names to instantiable classes
1128
-     *
1129
-     * @throws InvalidAliasException
1130
-     */
1131
-    protected function _register_core_aliases()
1132
-    {
1133
-        $aliases = array(
1134
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1135
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1136
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1137
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1138
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1139
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1140
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1141
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1142
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1143
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1144
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1145
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1146
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1147
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1148
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1149
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1150
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1151
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1152
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1153
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1154
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1155
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1156
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1157
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1158
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1159
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1160
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1161
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1162
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1163
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1164
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1165
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1166
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1167
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1168
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1169
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1170
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1171
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1172
-        );
1173
-        foreach ($aliases as $alias => $fqn) {
1174
-            if (is_array($fqn)) {
1175
-                foreach ($fqn as $class => $for_class) {
1176
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1177
-                }
1178
-                continue;
1179
-            }
1180
-            $this->class_cache->addAlias($fqn, $alias);
1181
-        }
1182
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1183
-            $this->class_cache->addAlias(
1184
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1185
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1186
-            );
1187
-        }
1188
-    }
1189
-
1190
-
1191
-    /**
1192
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1193
-     * request Primarily used by unit tests.
1194
-     */
1195
-    public function reset()
1196
-    {
1197
-        $this->_register_core_class_loaders();
1198
-        $this->_register_core_dependencies();
1199
-    }
1200
-
1201
-
1202
-    /**
1203
-     * PLZ NOTE: a better name for this method would be is_alias()
1204
-     * because it returns TRUE if the provided fully qualified name IS an alias
1205
-     * WHY?
1206
-     * Because if a class is type hinting for a concretion,
1207
-     * then why would we need to find another class to supply it?
1208
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1209
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1210
-     * Don't go looking for some substitute.
1211
-     * Whereas if a class is type hinting for an interface...
1212
-     * then we need to find an actual class to use.
1213
-     * So the interface IS the alias for some other FQN,
1214
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1215
-     * represents some other class.
1216
-     *
1217
-     * @deprecated 4.9.62.p
1218
-     * @param string $fqn
1219
-     * @param string $for_class
1220
-     * @return bool
1221
-     */
1222
-    public function has_alias($fqn = '', $for_class = '')
1223
-    {
1224
-        return $this->isAlias($fqn, $for_class);
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1230
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1231
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1232
-     *  for example:
1233
-     *      if the following two entries were added to the _aliases array:
1234
-     *          array(
1235
-     *              'interface_alias'           => 'some\namespace\interface'
1236
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1237
-     *          )
1238
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1239
-     *      to load an instance of 'some\namespace\classname'
1240
-     *
1241
-     * @deprecated 4.9.62.p
1242
-     * @param string $alias
1243
-     * @param string $for_class
1244
-     * @return string
1245
-     */
1246
-    public function get_alias($alias = '', $for_class = '')
1247
-    {
1248
-        return $this->getFqnForAlias($alias, $for_class);
1249
-    }
24
+	/**
25
+	 * This means that the requested class dependency is not present in the dependency map
26
+	 */
27
+	const not_registered = 0;
28
+
29
+	/**
30
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
+	 */
32
+	const load_new_object = 1;
33
+
34
+	/**
35
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
+	 */
38
+	const load_from_cache = 2;
39
+
40
+	/**
41
+	 * When registering a dependency,
42
+	 * this indicates to keep any existing dependencies that already exist,
43
+	 * and simply discard any new dependencies declared in the incoming data
44
+	 */
45
+	const KEEP_EXISTING_DEPENDENCIES = 0;
46
+
47
+	/**
48
+	 * When registering a dependency,
49
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
+	 */
51
+	const OVERWRITE_DEPENDENCIES = 1;
52
+
53
+
54
+	/**
55
+	 * @type EE_Dependency_Map $_instance
56
+	 */
57
+	protected static $_instance;
58
+
59
+	/**
60
+	 * @var ClassInterfaceCache $class_cache
61
+	 */
62
+	private $class_cache;
63
+
64
+	/**
65
+	 * @type RequestInterface $request
66
+	 */
67
+	protected $request;
68
+
69
+	/**
70
+	 * @type LegacyRequestInterface $legacy_request
71
+	 */
72
+	protected $legacy_request;
73
+
74
+	/**
75
+	 * @type ResponseInterface $response
76
+	 */
77
+	protected $response;
78
+
79
+	/**
80
+	 * @type LoaderInterface $loader
81
+	 */
82
+	protected $loader;
83
+
84
+	/**
85
+	 * @type array $_dependency_map
86
+	 */
87
+	protected $_dependency_map = array();
88
+
89
+	/**
90
+	 * @type array $_class_loaders
91
+	 */
92
+	protected $_class_loaders = array();
93
+
94
+
95
+	/**
96
+	 * EE_Dependency_Map constructor.
97
+	 *
98
+	 * @param ClassInterfaceCache $class_cache
99
+	 */
100
+	protected function __construct(ClassInterfaceCache $class_cache)
101
+	{
102
+		$this->class_cache = $class_cache;
103
+		do_action('EE_Dependency_Map____construct', $this);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return void
109
+	 * @throws EE_Error
110
+	 * @throws InvalidAliasException
111
+	 */
112
+	public function initialize()
113
+	{
114
+		$this->_register_core_dependencies();
115
+		$this->_register_core_class_loaders();
116
+		$this->_register_core_aliases();
117
+	}
118
+
119
+
120
+	/**
121
+	 * @singleton method used to instantiate class object
122
+	 * @param ClassInterfaceCache|null $class_cache
123
+	 * @return EE_Dependency_Map
124
+	 */
125
+	public static function instance(ClassInterfaceCache $class_cache = null)
126
+	{
127
+		// check if class object is instantiated, and instantiated properly
128
+		if (! self::$_instance instanceof EE_Dependency_Map
129
+			&& $class_cache instanceof ClassInterfaceCache
130
+		) {
131
+			self::$_instance = new EE_Dependency_Map($class_cache);
132
+		}
133
+		return self::$_instance;
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param RequestInterface $request
139
+	 */
140
+	public function setRequest(RequestInterface $request)
141
+	{
142
+		$this->request = $request;
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param LegacyRequestInterface $legacy_request
148
+	 */
149
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
150
+	{
151
+		$this->legacy_request = $legacy_request;
152
+	}
153
+
154
+
155
+	/**
156
+	 * @param ResponseInterface $response
157
+	 */
158
+	public function setResponse(ResponseInterface $response)
159
+	{
160
+		$this->response = $response;
161
+	}
162
+
163
+
164
+	/**
165
+	 * @param LoaderInterface $loader
166
+	 */
167
+	public function setLoader(LoaderInterface $loader)
168
+	{
169
+		$this->loader = $loader;
170
+	}
171
+
172
+
173
+	/**
174
+	 * @param string $class
175
+	 * @param array  $dependencies
176
+	 * @param int    $overwrite
177
+	 * @return bool
178
+	 */
179
+	public static function register_dependencies(
180
+		$class,
181
+		array $dependencies,
182
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
183
+	) {
184
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
185
+	}
186
+
187
+
188
+	/**
189
+	 * Assigns an array of class names and corresponding load sources (new or cached)
190
+	 * to the class specified by the first parameter.
191
+	 * IMPORTANT !!!
192
+	 * The order of elements in the incoming $dependencies array MUST match
193
+	 * the order of the constructor parameters for the class in question.
194
+	 * This is especially important when overriding any existing dependencies that are registered.
195
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
196
+	 *
197
+	 * @param string $class
198
+	 * @param array  $dependencies
199
+	 * @param int    $overwrite
200
+	 * @return bool
201
+	 */
202
+	public function registerDependencies(
203
+		$class,
204
+		array $dependencies,
205
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
206
+	) {
207
+		$class = trim($class, '\\');
208
+		$registered = false;
209
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
210
+			self::$_instance->_dependency_map[ $class ] = array();
211
+		}
212
+		// we need to make sure that any aliases used when registering a dependency
213
+		// get resolved to the correct class name
214
+		foreach ($dependencies as $dependency => $load_source) {
215
+			$alias = self::$_instance->getFqnForAlias($dependency);
216
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
217
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
218
+			) {
219
+				unset($dependencies[ $dependency ]);
220
+				$dependencies[ $alias ] = $load_source;
221
+				$registered = true;
222
+			}
223
+		}
224
+		// now add our two lists of dependencies together.
225
+		// using Union (+=) favours the arrays in precedence from left to right,
226
+		// so $dependencies is NOT overwritten because it is listed first
227
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
228
+		// Union is way faster than array_merge() but should be used with caution...
229
+		// especially with numerically indexed arrays
230
+		$dependencies += self::$_instance->_dependency_map[ $class ];
231
+		// now we need to ensure that the resulting dependencies
232
+		// array only has the entries that are required for the class
233
+		// so first count how many dependencies were originally registered for the class
234
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
235
+		// if that count is non-zero (meaning dependencies were already registered)
236
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
237
+			// then truncate the  final array to match that count
238
+			? array_slice($dependencies, 0, $dependency_count)
239
+			// otherwise just take the incoming array because nothing previously existed
240
+			: $dependencies;
241
+		return $registered;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @param string $class_name
247
+	 * @param string $loader
248
+	 * @return bool
249
+	 * @throws DomainException
250
+	 */
251
+	public static function register_class_loader($class_name, $loader = 'load_core')
252
+	{
253
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
254
+			throw new DomainException(
255
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
256
+			);
257
+		}
258
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
259
+		if (! is_callable($loader)
260
+			&& (
261
+				strpos($loader, 'load_') !== 0
262
+				|| ! method_exists('EE_Registry', $loader)
263
+			)
264
+		) {
265
+			throw new DomainException(
266
+				sprintf(
267
+					esc_html__(
268
+						'"%1$s" is not a valid loader method on EE_Registry.',
269
+						'event_espresso'
270
+					),
271
+					$loader
272
+				)
273
+			);
274
+		}
275
+		$class_name = self::$_instance->getFqnForAlias($class_name);
276
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
277
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
278
+			return true;
279
+		}
280
+		return false;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @return array
286
+	 */
287
+	public function dependency_map()
288
+	{
289
+		return $this->_dependency_map;
290
+	}
291
+
292
+
293
+	/**
294
+	 * returns TRUE if dependency map contains a listing for the provided class name
295
+	 *
296
+	 * @param string $class_name
297
+	 * @return boolean
298
+	 */
299
+	public function has($class_name = '')
300
+	{
301
+		// all legacy models have the same dependencies
302
+		if (strpos($class_name, 'EEM_') === 0) {
303
+			$class_name = 'LEGACY_MODELS';
304
+		}
305
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
306
+	}
307
+
308
+
309
+	/**
310
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
311
+	 *
312
+	 * @param string $class_name
313
+	 * @param string $dependency
314
+	 * @return bool
315
+	 */
316
+	public function has_dependency_for_class($class_name = '', $dependency = '')
317
+	{
318
+		// all legacy models have the same dependencies
319
+		if (strpos($class_name, 'EEM_') === 0) {
320
+			$class_name = 'LEGACY_MODELS';
321
+		}
322
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
323
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
324
+			? true
325
+			: false;
326
+	}
327
+
328
+
329
+	/**
330
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
331
+	 *
332
+	 * @param string $class_name
333
+	 * @param string $dependency
334
+	 * @return int
335
+	 */
336
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
337
+	{
338
+		// all legacy models have the same dependencies
339
+		if (strpos($class_name, 'EEM_') === 0) {
340
+			$class_name = 'LEGACY_MODELS';
341
+		}
342
+		$dependency = $this->getFqnForAlias($dependency);
343
+		return $this->has_dependency_for_class($class_name, $dependency)
344
+			? $this->_dependency_map[ $class_name ][ $dependency ]
345
+			: EE_Dependency_Map::not_registered;
346
+	}
347
+
348
+
349
+	/**
350
+	 * @param string $class_name
351
+	 * @return string | Closure
352
+	 */
353
+	public function class_loader($class_name)
354
+	{
355
+		// all legacy models use load_model()
356
+		if (strpos($class_name, 'EEM_') === 0) {
357
+			return 'load_model';
358
+		}
359
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
360
+		// perform strpos() first to avoid loading regex every time we load a class
361
+		if (strpos($class_name, 'EE_CPT_') === 0
362
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
363
+		) {
364
+			return 'load_core';
365
+		}
366
+		$class_name = $this->getFqnForAlias($class_name);
367
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
368
+	}
369
+
370
+
371
+	/**
372
+	 * @return array
373
+	 */
374
+	public function class_loaders()
375
+	{
376
+		return $this->_class_loaders;
377
+	}
378
+
379
+
380
+	/**
381
+	 * adds an alias for a classname
382
+	 *
383
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
384
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
385
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
386
+	 * @throws InvalidAliasException
387
+	 */
388
+	public function add_alias($fqcn, $alias, $for_class = '')
389
+	{
390
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
391
+	}
392
+
393
+
394
+	/**
395
+	 * Returns TRUE if the provided fully qualified name IS an alias
396
+	 * WHY?
397
+	 * Because if a class is type hinting for a concretion,
398
+	 * then why would we need to find another class to supply it?
399
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
400
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
401
+	 * Don't go looking for some substitute.
402
+	 * Whereas if a class is type hinting for an interface...
403
+	 * then we need to find an actual class to use.
404
+	 * So the interface IS the alias for some other FQN,
405
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
406
+	 * represents some other class.
407
+	 *
408
+	 * @param string $fqn
409
+	 * @param string $for_class
410
+	 * @return bool
411
+	 */
412
+	public function isAlias($fqn = '', $for_class = '')
413
+	{
414
+		return $this->class_cache->isAlias($fqn, $for_class);
415
+	}
416
+
417
+
418
+	/**
419
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
420
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
421
+	 *  for example:
422
+	 *      if the following two entries were added to the _aliases array:
423
+	 *          array(
424
+	 *              'interface_alias'           => 'some\namespace\interface'
425
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
426
+	 *          )
427
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
428
+	 *      to load an instance of 'some\namespace\classname'
429
+	 *
430
+	 * @param string $alias
431
+	 * @param string $for_class
432
+	 * @return string
433
+	 */
434
+	public function getFqnForAlias($alias = '', $for_class = '')
435
+	{
436
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
437
+	}
438
+
439
+
440
+	/**
441
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
442
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
443
+	 * This is done by using the following class constants:
444
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
445
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
446
+	 */
447
+	protected function _register_core_dependencies()
448
+	{
449
+		$this->_dependency_map = array(
450
+			'EE_Request_Handler'                                                                                          => array(
451
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
452
+			),
453
+			'EE_System'                                                                                                   => array(
454
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
455
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
456
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
457
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
458
+			),
459
+			'EE_Session'                                                                                                  => array(
460
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
461
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
462
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
463
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
464
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
465
+			),
466
+			'EE_Cart'                                                                                                     => array(
467
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
468
+			),
469
+			'EE_Front_Controller'                                                                                         => array(
470
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
471
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
472
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
473
+			),
474
+			'EE_Messenger_Collection_Loader'                                                                              => array(
475
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
476
+			),
477
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
478
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
479
+			),
480
+			'EE_Message_Resource_Manager'                                                                                 => array(
481
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
482
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
483
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
484
+			),
485
+			'EE_Message_Factory'                                                                                          => array(
486
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_messages'                                                                                                 => array(
489
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
490
+			),
491
+			'EE_Messages_Generator'                                                                                       => array(
492
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
493
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
494
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
495
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
496
+			),
497
+			'EE_Messages_Processor'                                                                                       => array(
498
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
499
+			),
500
+			'EE_Messages_Queue'                                                                                           => array(
501
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
502
+			),
503
+			'EE_Messages_Template_Defaults'                                                                               => array(
504
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
505
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
508
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
509
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
510
+			),
511
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
512
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
515
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
516
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
517
+			),
518
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
519
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
522
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
523
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
526
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
529
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
530
+			),
531
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
532
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
533
+			),
534
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
535
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
536
+			),
537
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
538
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
539
+			),
540
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
541
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
542
+			),
543
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
544
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
545
+			),
546
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
547
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
548
+			),
549
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
550
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
551
+			),
552
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
553
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
554
+			),
555
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
556
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
557
+			),
558
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
559
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
560
+			),
561
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
562
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
563
+			),
564
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
565
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_Data_Migration_Class_Base'                                                                                => 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_1_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_2_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_3_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_4_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_5_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_6_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_7_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_8_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_9_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
+			),
607
+			'EE_DMS_Core_4_10_0' => array(
608
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
609
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
610
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
613
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
614
+				array(),
615
+			),
616
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
617
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
618
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
619
+			),
620
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
621
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
+			),
623
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
624
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
+			),
626
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
627
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
630
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
+			),
632
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
633
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
634
+			),
635
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
636
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
637
+			),
638
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
639
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
640
+			),
641
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
642
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
643
+			),
644
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
645
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
646
+			),
647
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
648
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
649
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
652
+				null,
653
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
654
+			),
655
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
656
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'LEGACY_MODELS'                                                                                               => array(
659
+				null,
660
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
661
+			),
662
+			'EE_Module_Request_Router'                                                                                    => array(
663
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
664
+			),
665
+			'EE_Registration_Processor'                                                                                   => array(
666
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
667
+			),
668
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
669
+				null,
670
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
671
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
674
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
675
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
678
+				null,
679
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
680
+			),
681
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
682
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
683
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
684
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
685
+			),
686
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
687
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
688
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
689
+			),
690
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
691
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
692
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
693
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
694
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
695
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
696
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
697
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
698
+			),
699
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
700
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
701
+			),
702
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
703
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
704
+			),
705
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
706
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
708
+			),
709
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
710
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
711
+			),
712
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
713
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
714
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
715
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
716
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
717
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
718
+			),
719
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
720
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
723
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
724
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
725
+			),
726
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
727
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
728
+			),
729
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
730
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
+			),
732
+			'EE_CPT_Strategy'                                                                                             => array(
733
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
734
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
735
+			),
736
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
737
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
738
+			),
739
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
740
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
741
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
742
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
743
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
744
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
745
+			),
746
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
747
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
748
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
749
+			),
750
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
751
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
754
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
755
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
756
+			),
757
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
758
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
759
+			),
760
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
761
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
762
+			),
763
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
764
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
765
+			),
766
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
767
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
768
+			),
769
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
770
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
771
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
772
+			),
773
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
774
+				null,
775
+				null,
776
+				null,
777
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
778
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
779
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
780
+			),
781
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
782
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
783
+				'EE_Config' => EE_Dependency_Map::load_from_cache
784
+			),
785
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
786
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
787
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
788
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
789
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
790
+			),
791
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
792
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
793
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
794
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
795
+			),
796
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
797
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
798
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
799
+			),
800
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
801
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
802
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
804
+			),
805
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
806
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
807
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
808
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
809
+			),
810
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
811
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
813
+			),
814
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
815
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
816
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
817
+			),
818
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
819
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
820
+			),
821
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
822
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
823
+			),
824
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
825
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
826
+			),
827
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
828
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
829
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
+			),
831
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
832
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
833
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
834
+			),
835
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
836
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
837
+			),
838
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
839
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
840
+			),
841
+			'EE_URL_Validation_Strategy' => array(
842
+				null,
843
+				null,
844
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
845
+			),
846
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
847
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
848
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
849
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
850
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
852
+			),
853
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
854
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
856
+			),
857
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
858
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
859
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
860
+			),
861
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
862
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
863
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
864
+			),
865
+			'EventEspresso\core\services\request\files\FilesDataHandler' => array(
866
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
867
+			),
868
+			'EventEspressoBatchRequest\BatchRequestProcessor'                              => [
869
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
870
+			],
871
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
872
+				null,
873
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
+				'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
875
+			],
876
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
877
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
+				'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
879
+			],
880
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
881
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
+				'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
883
+			],
884
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
885
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
+				'EEM_Event'  => EE_Dependency_Map::load_from_cache,
887
+			],
888
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
889
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
890
+				'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
891
+			],
892
+			'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [
893
+				'WP_REST_Server' => EE_Dependency_Map::load_from_cache,
894
+				'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache,
895
+				'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
896
+				null
897
+			],
898
+			'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'  => [
899
+				'EE_Admin_Config' => EE_Dependency_Map::load_from_cache
900
+			],
901
+			'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorData'  => [
902
+				'EE_Event'        => EE_Dependency_Map::not_registered,
903
+				'EE_Admin_Config' => EE_Dependency_Map::load_from_cache,
904
+				'EEM_Datetime'    => EE_Dependency_Map::load_from_cache,
905
+				'EEM_Price'       => EE_Dependency_Map::load_from_cache,
906
+				'EEM_Ticket'      => EE_Dependency_Map::load_from_cache,
907
+			],
908
+			'EventEspresso\core\services\graphql\GraphQLManager' => [
909
+				'EventEspresso\core\services\graphql\TypesManager'  => EE_Dependency_Map::load_from_cache,
910
+				'EventEspresso\core\services\graphql\InputsManager'  => EE_Dependency_Map::load_from_cache,
911
+				'EventEspresso\core\services\graphql\EnumsManager'  => EE_Dependency_Map::load_from_cache,
912
+				'EventEspresso\core\services\graphql\ConnectionsManager'  => EE_Dependency_Map::load_from_cache,
913
+			],
914
+			'EventEspresso\core\services\graphql\TypesManager' => [
915
+				'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
916
+			],
917
+			'EventEspresso\core\services\graphql\InputsManager' => [
918
+				'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
919
+			],
920
+			'EventEspresso\core\services\graphql\EnumsManager' => [
921
+				'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
922
+			],
923
+			'EventEspresso\core\services\graphql\ConnectionsManager' => [
924
+				'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
925
+			],
926
+			'EventEspresso\core\domain\services\graphql\types\Datetime' => [
927
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
928
+			],
929
+			'EventEspresso\core\domain\services\graphql\types\Attendee' => [
930
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
931
+			],
932
+			'EventEspresso\core\domain\services\graphql\types\Event' => [
933
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
934
+			],
935
+			'EventEspresso\core\domain\services\graphql\types\Ticket' => [
936
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
937
+			],
938
+			'EventEspresso\core\domain\services\graphql\types\Price' => [
939
+				'EEM_Price' => EE_Dependency_Map::load_from_cache,
940
+			],
941
+			'EventEspresso\core\domain\services\graphql\types\PriceType' => [
942
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
943
+			],
944
+			'EventEspresso\core\domain\services\graphql\types\Venue' => [
945
+				'EEM_Venue' => EE_Dependency_Map::load_from_cache,
946
+			],
947
+			'EventEspresso\core\domain\services\graphql\types\State' => [
948
+				'EEM_State' => EE_Dependency_Map::load_from_cache,
949
+			],
950
+			'EventEspresso\core\domain\services\graphql\types\Country' => [
951
+				'EEM_Country' => EE_Dependency_Map::load_from_cache,
952
+			],
953
+			'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection' => [
954
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
955
+			],
956
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection' => [
957
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
958
+			],
959
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection' => [
960
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
961
+			],
962
+			'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection' => [
963
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
964
+			],
965
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection' => [
966
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
967
+			],
968
+			'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection' => [
969
+				'EEM_Price' => EE_Dependency_Map::load_from_cache,
970
+			],
971
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection' => [
972
+				'EEM_Price' => EE_Dependency_Map::load_from_cache,
973
+			],
974
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection' => [
975
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
976
+			],
977
+			'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection' => [
978
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
979
+			],
980
+			'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection' => [
981
+				'EEM_Venue' => EE_Dependency_Map::load_from_cache,
982
+			],
983
+		);
984
+	}
985
+
986
+
987
+	/**
988
+	 * Registers how core classes are loaded.
989
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
990
+	 *        'EE_Request_Handler' => 'load_core'
991
+	 *        'EE_Messages_Queue'  => 'load_lib'
992
+	 *        'EEH_Debug_Tools'    => 'load_helper'
993
+	 * or, if greater control is required, by providing a custom closure. For example:
994
+	 *        'Some_Class' => function () {
995
+	 *            return new Some_Class();
996
+	 *        },
997
+	 * This is required for instantiating dependencies
998
+	 * where an interface has been type hinted in a class constructor. For example:
999
+	 *        'Required_Interface' => function () {
1000
+	 *            return new A_Class_That_Implements_Required_Interface();
1001
+	 *        },
1002
+	 */
1003
+	protected function _register_core_class_loaders()
1004
+	{
1005
+		$this->_class_loaders = array(
1006
+			// load_core
1007
+			'EE_Dependency_Map'                            => function () {
1008
+				return $this;
1009
+			},
1010
+			'EE_Capabilities'                              => 'load_core',
1011
+			'EE_Encryption'                                => 'load_core',
1012
+			'EE_Front_Controller'                          => 'load_core',
1013
+			'EE_Module_Request_Router'                     => 'load_core',
1014
+			'EE_Registry'                                  => 'load_core',
1015
+			'EE_Request'                                   => function () {
1016
+				return $this->legacy_request;
1017
+			},
1018
+			'EventEspresso\core\services\request\Request'  => function () {
1019
+				return $this->request;
1020
+			},
1021
+			'EventEspresso\core\services\request\Response' => function () {
1022
+				return $this->response;
1023
+			},
1024
+			'EE_Base'                                      => 'load_core',
1025
+			'EE_Request_Handler'                           => 'load_core',
1026
+			'EE_Session'                                   => 'load_core',
1027
+			'EE_Cron_Tasks'                                => 'load_core',
1028
+			'EE_System'                                    => 'load_core',
1029
+			'EE_Maintenance_Mode'                          => 'load_core',
1030
+			'EE_Register_CPTs'                             => 'load_core',
1031
+			'EE_Admin'                                     => 'load_core',
1032
+			'EE_CPT_Strategy'                              => 'load_core',
1033
+			// load_class
1034
+			'EE_Registration_Processor'                    => 'load_class',
1035
+			// load_lib
1036
+			'EE_Message_Resource_Manager'                  => 'load_lib',
1037
+			'EE_Message_Type_Collection'                   => 'load_lib',
1038
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
1039
+			'EE_Messenger_Collection'                      => 'load_lib',
1040
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
1041
+			'EE_Messages_Processor'                        => 'load_lib',
1042
+			'EE_Message_Repository'                        => 'load_lib',
1043
+			'EE_Messages_Queue'                            => 'load_lib',
1044
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
1045
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
1046
+			'EE_Payment_Method_Manager'                    => 'load_lib',
1047
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
1048
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
1049
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
1050
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
1051
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
1052
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
1053
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
1054
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
1055
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
1056
+			'EE_Messages_Generator'                        => static function () {
1057
+				return EE_Registry::instance()->load_lib(
1058
+					'Messages_Generator',
1059
+					array(),
1060
+					false,
1061
+					false
1062
+				);
1063
+			},
1064
+			'EE_Messages_Template_Defaults'                => static function ($arguments = array()) {
1065
+				return EE_Registry::instance()->load_lib(
1066
+					'Messages_Template_Defaults',
1067
+					$arguments,
1068
+					false,
1069
+					false
1070
+				);
1071
+			},
1072
+			// load_helper
1073
+			'EEH_Parse_Shortcodes'                         => static function () {
1074
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1075
+					return new EEH_Parse_Shortcodes();
1076
+				}
1077
+				return null;
1078
+			},
1079
+			'EE_Template_Config'                           => static function () {
1080
+				return EE_Config::instance()->template_settings;
1081
+			},
1082
+			'EE_Currency_Config'                           => static function () {
1083
+				return EE_Config::instance()->currency;
1084
+			},
1085
+			'EE_Registration_Config'                       => static function () {
1086
+				return EE_Config::instance()->registration;
1087
+			},
1088
+			'EE_Core_Config'                               => static function () {
1089
+				return EE_Config::instance()->core;
1090
+			},
1091
+			'EventEspresso\core\services\loaders\Loader'   => static function () {
1092
+				return LoaderFactory::getLoader();
1093
+			},
1094
+			'EE_Network_Config'                            => static function () {
1095
+				return EE_Network_Config::instance();
1096
+			},
1097
+			'EE_Config'                                    => static function () {
1098
+				return EE_Config::instance();
1099
+			},
1100
+			'EventEspresso\core\domain\Domain'             => static function () {
1101
+				return DomainFactory::getEventEspressoCoreDomain();
1102
+			},
1103
+			'EE_Admin_Config'                              => static function () {
1104
+				return EE_Config::instance()->admin;
1105
+			},
1106
+			'EE_Organization_Config'                       => static function () {
1107
+				return EE_Config::instance()->organization;
1108
+			},
1109
+			'EE_Network_Core_Config'                       => static function () {
1110
+				return EE_Network_Config::instance()->core;
1111
+			},
1112
+			'EE_Environment_Config'                        => static function () {
1113
+				return EE_Config::instance()->environment;
1114
+			},
1115
+			'EED_Core_Rest_Api'                            => static function () {
1116
+				return EED_Core_Rest_Api::instance();
1117
+			},
1118
+			'WP_REST_Server'                            => static function () {
1119
+				return rest_get_server();
1120
+			},
1121
+		);
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 * can be used for supplying alternate names for classes,
1127
+	 * or for connecting interface names to instantiable classes
1128
+	 *
1129
+	 * @throws InvalidAliasException
1130
+	 */
1131
+	protected function _register_core_aliases()
1132
+	{
1133
+		$aliases = array(
1134
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1135
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1136
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1137
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1138
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1139
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1140
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1141
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1142
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1143
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1144
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1145
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1146
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1147
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1148
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1149
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1150
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1151
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1152
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1153
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1154
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1155
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1156
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1157
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1158
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1159
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1160
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1161
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1162
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1163
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1164
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1165
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1166
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1167
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1168
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1169
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1170
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1171
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1172
+		);
1173
+		foreach ($aliases as $alias => $fqn) {
1174
+			if (is_array($fqn)) {
1175
+				foreach ($fqn as $class => $for_class) {
1176
+					$this->class_cache->addAlias($class, $alias, $for_class);
1177
+				}
1178
+				continue;
1179
+			}
1180
+			$this->class_cache->addAlias($fqn, $alias);
1181
+		}
1182
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1183
+			$this->class_cache->addAlias(
1184
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1185
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1186
+			);
1187
+		}
1188
+	}
1189
+
1190
+
1191
+	/**
1192
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1193
+	 * request Primarily used by unit tests.
1194
+	 */
1195
+	public function reset()
1196
+	{
1197
+		$this->_register_core_class_loaders();
1198
+		$this->_register_core_dependencies();
1199
+	}
1200
+
1201
+
1202
+	/**
1203
+	 * PLZ NOTE: a better name for this method would be is_alias()
1204
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1205
+	 * WHY?
1206
+	 * Because if a class is type hinting for a concretion,
1207
+	 * then why would we need to find another class to supply it?
1208
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1209
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1210
+	 * Don't go looking for some substitute.
1211
+	 * Whereas if a class is type hinting for an interface...
1212
+	 * then we need to find an actual class to use.
1213
+	 * So the interface IS the alias for some other FQN,
1214
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1215
+	 * represents some other class.
1216
+	 *
1217
+	 * @deprecated 4.9.62.p
1218
+	 * @param string $fqn
1219
+	 * @param string $for_class
1220
+	 * @return bool
1221
+	 */
1222
+	public function has_alias($fqn = '', $for_class = '')
1223
+	{
1224
+		return $this->isAlias($fqn, $for_class);
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1230
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1231
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1232
+	 *  for example:
1233
+	 *      if the following two entries were added to the _aliases array:
1234
+	 *          array(
1235
+	 *              'interface_alias'           => 'some\namespace\interface'
1236
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1237
+	 *          )
1238
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1239
+	 *      to load an instance of 'some\namespace\classname'
1240
+	 *
1241
+	 * @deprecated 4.9.62.p
1242
+	 * @param string $alias
1243
+	 * @param string $for_class
1244
+	 * @return string
1245
+	 */
1246
+	public function get_alias($alias = '', $for_class = '')
1247
+	{
1248
+		return $this->getFqnForAlias($alias, $for_class);
1249
+	}
1250 1250
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 1 patch
Indentation   +768 added lines, -768 removed lines patch added patch discarded remove patch
@@ -25,772 +25,772 @@
 block discarded – undo
25 25
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
26 26
 {
27 27
 
28
-    /**
29
-     * Sets some dynamic defaults
30
-     *
31
-     * @param array  $fieldValues
32
-     * @param bool   $bydb
33
-     * @param string $timezone
34
-     * @param array  $date_formats
35
-     * @throws EE_Error
36
-     */
37
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
-    {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
-            $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
43
-        }
44
-        if (! isset($fieldValues['ATT_slug'])) {
45
-            // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
-        }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
-        }
51
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param array  $props_n_values          incoming values
57
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
-     *                                        used.)
59
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
-     *                                        date_format and the second value is the time format
61
-     * @return EE_Attendee
62
-     * @throws EE_Error
63
-     */
64
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
-    {
66
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
-    }
69
-
70
-
71
-    /**
72
-     * @param array  $props_n_values  incoming values from the database
73
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
-     *                                the website will be used.
75
-     * @return EE_Attendee
76
-     */
77
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
-    {
79
-        return new self($props_n_values, true, $timezone);
80
-    }
81
-
82
-
83
-    /**
84
-     *        Set Attendee First Name
85
-     *
86
-     * @access        public
87
-     * @param string $fname
88
-     * @throws EE_Error
89
-     */
90
-    public function set_fname($fname = '')
91
-    {
92
-        $this->set('ATT_fname', $fname);
93
-    }
94
-
95
-
96
-    /**
97
-     *        Set Attendee Last Name
98
-     *
99
-     * @access        public
100
-     * @param string $lname
101
-     * @throws EE_Error
102
-     */
103
-    public function set_lname($lname = '')
104
-    {
105
-        $this->set('ATT_lname', $lname);
106
-    }
107
-
108
-
109
-    /**
110
-     *        Set Attendee Address
111
-     *
112
-     * @access        public
113
-     * @param string $address
114
-     * @throws EE_Error
115
-     */
116
-    public function set_address($address = '')
117
-    {
118
-        $this->set('ATT_address', $address);
119
-    }
120
-
121
-
122
-    /**
123
-     *        Set Attendee Address2
124
-     *
125
-     * @access        public
126
-     * @param        string $address2
127
-     * @throws EE_Error
128
-     */
129
-    public function set_address2($address2 = '')
130
-    {
131
-        $this->set('ATT_address2', $address2);
132
-    }
133
-
134
-
135
-    /**
136
-     *        Set Attendee City
137
-     *
138
-     * @access        public
139
-     * @param        string $city
140
-     * @throws EE_Error
141
-     */
142
-    public function set_city($city = '')
143
-    {
144
-        $this->set('ATT_city', $city);
145
-    }
146
-
147
-
148
-    /**
149
-     *        Set Attendee State ID
150
-     *
151
-     * @access        public
152
-     * @param        int $STA_ID
153
-     * @throws EE_Error
154
-     */
155
-    public function set_state($STA_ID = 0)
156
-    {
157
-        $this->set('STA_ID', $STA_ID);
158
-    }
159
-
160
-
161
-    /**
162
-     *        Set Attendee Country ISO Code
163
-     *
164
-     * @access        public
165
-     * @param        string $CNT_ISO
166
-     * @throws EE_Error
167
-     */
168
-    public function set_country($CNT_ISO = '')
169
-    {
170
-        $this->set('CNT_ISO', $CNT_ISO);
171
-    }
172
-
173
-
174
-    /**
175
-     *        Set Attendee Zip/Postal Code
176
-     *
177
-     * @access        public
178
-     * @param        string $zip
179
-     * @throws EE_Error
180
-     */
181
-    public function set_zip($zip = '')
182
-    {
183
-        $this->set('ATT_zip', $zip);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Email Address
189
-     *
190
-     * @access        public
191
-     * @param        string $email
192
-     * @throws EE_Error
193
-     */
194
-    public function set_email($email = '')
195
-    {
196
-        $this->set('ATT_email', $email);
197
-    }
198
-
199
-
200
-    /**
201
-     *        Set Attendee Phone
202
-     *
203
-     * @access        public
204
-     * @param        string $phone
205
-     * @throws EE_Error
206
-     */
207
-    public function set_phone($phone = '')
208
-    {
209
-        $this->set('ATT_phone', $phone);
210
-    }
211
-
212
-
213
-    /**
214
-     *        set deleted
215
-     *
216
-     * @access        public
217
-     * @param        bool $ATT_deleted
218
-     * @throws EE_Error
219
-     */
220
-    public function set_deleted($ATT_deleted = false)
221
-    {
222
-        $this->set('ATT_deleted', $ATT_deleted);
223
-    }
224
-
225
-
226
-    /**
227
-     * Returns the value for the post_author id saved with the cpt
228
-     *
229
-     * @since 4.5.0
230
-     * @return int
231
-     * @throws EE_Error
232
-     */
233
-    public function wp_user()
234
-    {
235
-        return $this->get('ATT_author');
236
-    }
237
-
238
-
239
-    /**
240
-     *        get Attendee First Name
241
-     *
242
-     * @access        public
243
-     * @return string
244
-     * @throws EE_Error
245
-     */
246
-    public function fname()
247
-    {
248
-        return $this->get('ATT_fname');
249
-    }
250
-
251
-
252
-    /**
253
-     * echoes out the attendee's first name
254
-     *
255
-     * @return void
256
-     * @throws EE_Error
257
-     */
258
-    public function e_full_name()
259
-    {
260
-        echo $this->full_name();
261
-    }
262
-
263
-
264
-    /**
265
-     * Returns the first and last name concatenated together with a space.
266
-     *
267
-     * @param bool $apply_html_entities
268
-     * @return string
269
-     * @throws EE_Error
270
-     */
271
-    public function full_name($apply_html_entities = false)
272
-    {
273
-        $full_name = array(
274
-            $this->fname(),
275
-            $this->lname(),
276
-        );
277
-        $full_name = array_filter($full_name);
278
-        $full_name = implode(' ', $full_name);
279
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
-    }
281
-
282
-
283
-    /**
284
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
-     * attendee.
287
-     *
288
-     * @param bool $apply_html_entities
289
-     * @return string
290
-     * @throws EE_Error
291
-     */
292
-    public function ATT_full_name($apply_html_entities = false)
293
-    {
294
-        return $apply_html_entities
295
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
-            : $this->get('ATT_full_name');
297
-    }
298
-
299
-
300
-    /**
301
-     *        get Attendee Last Name
302
-     *
303
-     * @access        public
304
-     * @return string
305
-     * @throws EE_Error
306
-     */
307
-    public function lname()
308
-    {
309
-        return $this->get('ATT_lname');
310
-    }
311
-
312
-
313
-    /**
314
-     * get Attendee bio
315
-     *
316
-     * @access public
317
-     * @return string
318
-     * @throws EE_Error
319
-     */
320
-    public function bio()
321
-    {
322
-        return $this->get('ATT_bio');
323
-    }
324
-
325
-
326
-    /**
327
-     * get Attendee short bio
328
-     *
329
-     * @access public
330
-     * @return string
331
-     * @throws EE_Error
332
-     */
333
-    public function short_bio()
334
-    {
335
-        return $this->get('ATT_short_bio');
336
-    }
337
-
338
-
339
-    /**
340
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
341
-     *
342
-     * @return array numerically indexed, with each part of the address that is known.
343
-     * Eg, if the user only responded to state and country,
344
-     * it would be array(0=>'Alabama',1=>'USA')
345
-     * @return array
346
-     * @throws EE_Error
347
-     */
348
-    public function full_address_as_array()
349
-    {
350
-        $full_address_array = array();
351
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
352
-        foreach ($initial_address_fields as $address_field_name) {
353
-            $address_fields_value = $this->get($address_field_name);
354
-            if (! empty($address_fields_value)) {
355
-                $full_address_array[] = $address_fields_value;
356
-            }
357
-        }
358
-        // now handle state and country
359
-        $state_obj = $this->state_obj();
360
-        if ($state_obj instanceof EE_State) {
361
-            $full_address_array[] = $state_obj->name();
362
-        }
363
-        $country_obj = $this->country_obj();
364
-        if ($country_obj instanceof EE_Country) {
365
-            $full_address_array[] = $country_obj->name();
366
-        }
367
-        // lastly get the xip
368
-        $zip_value = $this->zip();
369
-        if (! empty($zip_value)) {
370
-            $full_address_array[] = $zip_value;
371
-        }
372
-        return $full_address_array;
373
-    }
374
-
375
-
376
-    /**
377
-     *        get Attendee Address
378
-     *
379
-     * @return string
380
-     * @throws EE_Error
381
-     */
382
-    public function address()
383
-    {
384
-        return $this->get('ATT_address');
385
-    }
386
-
387
-
388
-    /**
389
-     *        get Attendee Address2
390
-     *
391
-     * @return string
392
-     * @throws EE_Error
393
-     */
394
-    public function address2()
395
-    {
396
-        return $this->get('ATT_address2');
397
-    }
398
-
399
-
400
-    /**
401
-     *        get Attendee City
402
-     *
403
-     * @return string
404
-     * @throws EE_Error
405
-     */
406
-    public function city()
407
-    {
408
-        return $this->get('ATT_city');
409
-    }
410
-
411
-
412
-    /**
413
-     *        get Attendee State ID
414
-     *
415
-     * @return string
416
-     * @throws EE_Error
417
-     */
418
-    public function state_ID()
419
-    {
420
-        return $this->get('STA_ID');
421
-    }
422
-
423
-
424
-    /**
425
-     * @return string
426
-     * @throws EE_Error
427
-     */
428
-    public function state_abbrev()
429
-    {
430
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
431
-    }
432
-
433
-
434
-    /**
435
-     * Gets the state set to this attendee
436
-     *
437
-     * @return EE_State
438
-     * @throws EE_Error
439
-     */
440
-    public function state_obj()
441
-    {
442
-        return $this->get_first_related('State');
443
-    }
444
-
445
-
446
-    /**
447
-     * Returns the state's name, otherwise 'Unknown'
448
-     *
449
-     * @return string
450
-     * @throws EE_Error
451
-     */
452
-    public function state_name()
453
-    {
454
-        if ($this->state_obj()) {
455
-            return $this->state_obj()->name();
456
-        } else {
457
-            return '';
458
-        }
459
-    }
460
-
461
-
462
-    /**
463
-     * either displays the state abbreviation or the state name, as determined
464
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
465
-     * defaults to abbreviation
466
-     *
467
-     * @return string
468
-     * @throws EE_Error
469
-     */
470
-    public function state()
471
-    {
472
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
473
-            return $this->state_abbrev();
474
-        }
475
-        return $this->state_name();
476
-    }
477
-
478
-
479
-    /**
480
-     *    get Attendee Country ISO Code
481
-     *
482
-     * @return string
483
-     * @throws EE_Error
484
-     */
485
-    public function country_ID()
486
-    {
487
-        return $this->get('CNT_ISO');
488
-    }
489
-
490
-
491
-    /**
492
-     * Gets country set for this attendee
493
-     *
494
-     * @return EE_Country
495
-     * @throws EE_Error
496
-     */
497
-    public function country_obj()
498
-    {
499
-        return $this->get_first_related('Country');
500
-    }
501
-
502
-
503
-    /**
504
-     * Returns the country's name if known, otherwise 'Unknown'
505
-     *
506
-     * @return string
507
-     * @throws EE_Error
508
-     */
509
-    public function country_name()
510
-    {
511
-        if ($this->country_obj()) {
512
-            return $this->country_obj()->name();
513
-        }
514
-        return '';
515
-    }
516
-
517
-
518
-    /**
519
-     * either displays the country ISO2 code or the country name, as determined
520
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
521
-     * defaults to abbreviation
522
-     *
523
-     * @return string
524
-     * @throws EE_Error
525
-     */
526
-    public function country()
527
-    {
528
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
529
-            return $this->country_ID();
530
-        }
531
-        return $this->country_name();
532
-    }
533
-
534
-
535
-    /**
536
-     *        get Attendee Zip/Postal Code
537
-     *
538
-     * @return string
539
-     * @throws EE_Error
540
-     */
541
-    public function zip()
542
-    {
543
-        return $this->get('ATT_zip');
544
-    }
545
-
546
-
547
-    /**
548
-     *        get Attendee Email Address
549
-     *
550
-     * @return string
551
-     * @throws EE_Error
552
-     */
553
-    public function email()
554
-    {
555
-        return $this->get('ATT_email');
556
-    }
557
-
558
-
559
-    /**
560
-     *        get Attendee Phone #
561
-     *
562
-     * @return string
563
-     * @throws EE_Error
564
-     */
565
-    public function phone()
566
-    {
567
-        return $this->get('ATT_phone');
568
-    }
569
-
570
-
571
-    /**
572
-     *    get deleted
573
-     *
574
-     * @return        bool
575
-     * @throws EE_Error
576
-     */
577
-    public function deleted()
578
-    {
579
-        return $this->get('ATT_deleted');
580
-    }
581
-
582
-
583
-    /**
584
-     * Gets registrations of this attendee
585
-     *
586
-     * @param array $query_params
587
-     * @return EE_Registration[]
588
-     * @throws EE_Error
589
-     */
590
-    public function get_registrations($query_params = array())
591
-    {
592
-        return $this->get_many_related('Registration', $query_params);
593
-    }
594
-
595
-
596
-    /**
597
-     * Gets the most recent registration of this attendee
598
-     *
599
-     * @return EE_Registration
600
-     * @throws EE_Error
601
-     */
602
-    public function get_most_recent_registration()
603
-    {
604
-        return $this->get_first_related(
605
-            'Registration',
606
-            array('order_by' => array('REG_date' => 'DESC'))
607
-        ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
608
-    }
609
-
610
-
611
-    /**
612
-     * Gets the most recent registration for this attend at this event
613
-     *
614
-     * @param int $event_id
615
-     * @return EE_Registration
616
-     * @throws EE_Error
617
-     */
618
-    public function get_most_recent_registration_for_event($event_id)
619
-    {
620
-        return $this->get_first_related(
621
-            'Registration',
622
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
623
-        );
624
-    }
625
-
626
-
627
-    /**
628
-     * returns any events attached to this attendee ($_Event property);
629
-     *
630
-     * @return array
631
-     * @throws EE_Error
632
-     */
633
-    public function events()
634
-    {
635
-        return $this->get_many_related('Event');
636
-    }
637
-
638
-
639
-    /**
640
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
641
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
642
-     * used to save the billing info
643
-     *
644
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
645
-     * @return EE_Form_Section_Proper|null
646
-     * @throws EE_Error
647
-     */
648
-    public function billing_info_for_payment_method($payment_method)
649
-    {
650
-        $pm_type = $payment_method->type_obj();
651
-        if (! $pm_type instanceof EE_PMT_Base) {
652
-            return null;
653
-        }
654
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
655
-        if (! $billing_info) {
656
-            return null;
657
-        }
658
-        $billing_form = $pm_type->billing_form();
659
-        // double-check the form isn't totally hidden, in which case pretend there is no form
660
-        $form_totally_hidden = true;
661
-        foreach ($billing_form->inputs_in_subsections() as $input) {
662
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
663
-                $form_totally_hidden = false;
664
-                break;
665
-            }
666
-        }
667
-        if ($form_totally_hidden) {
668
-            return null;
669
-        }
670
-        if ($billing_form instanceof EE_Form_Section_Proper) {
671
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
672
-        }
673
-
674
-        return $billing_form;
675
-    }
676
-
677
-
678
-    /**
679
-     * Gets the postmeta key that holds this attendee's billing info for the
680
-     * specified payment method
681
-     *
682
-     * @param EE_Payment_Method $payment_method
683
-     * @return string
684
-     * @throws EE_Error
685
-     */
686
-    public function get_billing_info_postmeta_name($payment_method)
687
-    {
688
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
689
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
690
-        }
691
-        return null;
692
-    }
693
-
694
-
695
-    /**
696
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
697
-     * retrieve it
698
-     *
699
-     * @param EE_Billing_Attendee_Info_Form $billing_form
700
-     * @param EE_Payment_Method             $payment_method
701
-     * @return boolean
702
-     * @throws EE_Error
703
-     */
704
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
705
-    {
706
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
707
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
708
-            return false;
709
-        }
710
-        $billing_form->clean_sensitive_data();
711
-        return update_post_meta(
712
-            $this->ID(),
713
-            $this->get_billing_info_postmeta_name($payment_method),
714
-            $billing_form->input_values(true)
715
-        );
716
-    }
717
-
718
-
719
-    /**
720
-     * Return the link to the admin details for the object.
721
-     *
722
-     * @return string
723
-     * @throws EE_Error
724
-     * @throws InvalidArgumentException
725
-     * @throws InvalidDataTypeException
726
-     * @throws InvalidInterfaceException
727
-     * @throws ReflectionException
728
-     */
729
-    public function get_admin_details_link()
730
-    {
731
-        return $this->get_admin_edit_link();
732
-    }
733
-
734
-
735
-    /**
736
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
737
-     *
738
-     * @return string
739
-     * @throws EE_Error
740
-     * @throws InvalidArgumentException
741
-     * @throws ReflectionException
742
-     * @throws InvalidDataTypeException
743
-     * @throws InvalidInterfaceException
744
-     */
745
-    public function get_admin_edit_link()
746
-    {
747
-        EE_Registry::instance()->load_helper('URL');
748
-        return EEH_URL::add_query_args_and_nonce(
749
-            array(
750
-                'page'   => 'espresso_registrations',
751
-                'action' => 'edit_attendee',
752
-                'post'   => $this->ID(),
753
-            ),
754
-            admin_url('admin.php')
755
-        );
756
-    }
757
-
758
-
759
-    /**
760
-     * Returns the link to a settings page for the object.
761
-     *
762
-     * @return string
763
-     * @throws EE_Error
764
-     * @throws InvalidArgumentException
765
-     * @throws InvalidDataTypeException
766
-     * @throws InvalidInterfaceException
767
-     * @throws ReflectionException
768
-     */
769
-    public function get_admin_settings_link()
770
-    {
771
-        return $this->get_admin_edit_link();
772
-    }
773
-
774
-
775
-    /**
776
-     * Returns the link to the "overview" for the object (typically the "list table" view).
777
-     *
778
-     * @return string
779
-     * @throws EE_Error
780
-     * @throws InvalidArgumentException
781
-     * @throws ReflectionException
782
-     * @throws InvalidDataTypeException
783
-     * @throws InvalidInterfaceException
784
-     */
785
-    public function get_admin_overview_link()
786
-    {
787
-        EE_Registry::instance()->load_helper('URL');
788
-        return EEH_URL::add_query_args_and_nonce(
789
-            array(
790
-                'page'   => 'espresso_registrations',
791
-                'action' => 'contact_list',
792
-            ),
793
-            admin_url('admin.php')
794
-        );
795
-    }
28
+	/**
29
+	 * Sets some dynamic defaults
30
+	 *
31
+	 * @param array  $fieldValues
32
+	 * @param bool   $bydb
33
+	 * @param string $timezone
34
+	 * @param array  $date_formats
35
+	 * @throws EE_Error
36
+	 */
37
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
+	{
39
+		if (! isset($fieldValues['ATT_full_name'])) {
40
+			$fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
+			$lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
+			$fieldValues['ATT_full_name'] = $fname . $lname;
43
+		}
44
+		if (! isset($fieldValues['ATT_slug'])) {
45
+			// $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
+		}
48
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
+		}
51
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param array  $props_n_values          incoming values
57
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
+	 *                                        used.)
59
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
+	 *                                        date_format and the second value is the time format
61
+	 * @return EE_Attendee
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
+	{
66
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param array  $props_n_values  incoming values from the database
73
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
+	 *                                the website will be used.
75
+	 * @return EE_Attendee
76
+	 */
77
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
+	{
79
+		return new self($props_n_values, true, $timezone);
80
+	}
81
+
82
+
83
+	/**
84
+	 *        Set Attendee First Name
85
+	 *
86
+	 * @access        public
87
+	 * @param string $fname
88
+	 * @throws EE_Error
89
+	 */
90
+	public function set_fname($fname = '')
91
+	{
92
+		$this->set('ATT_fname', $fname);
93
+	}
94
+
95
+
96
+	/**
97
+	 *        Set Attendee Last Name
98
+	 *
99
+	 * @access        public
100
+	 * @param string $lname
101
+	 * @throws EE_Error
102
+	 */
103
+	public function set_lname($lname = '')
104
+	{
105
+		$this->set('ATT_lname', $lname);
106
+	}
107
+
108
+
109
+	/**
110
+	 *        Set Attendee Address
111
+	 *
112
+	 * @access        public
113
+	 * @param string $address
114
+	 * @throws EE_Error
115
+	 */
116
+	public function set_address($address = '')
117
+	{
118
+		$this->set('ATT_address', $address);
119
+	}
120
+
121
+
122
+	/**
123
+	 *        Set Attendee Address2
124
+	 *
125
+	 * @access        public
126
+	 * @param        string $address2
127
+	 * @throws EE_Error
128
+	 */
129
+	public function set_address2($address2 = '')
130
+	{
131
+		$this->set('ATT_address2', $address2);
132
+	}
133
+
134
+
135
+	/**
136
+	 *        Set Attendee City
137
+	 *
138
+	 * @access        public
139
+	 * @param        string $city
140
+	 * @throws EE_Error
141
+	 */
142
+	public function set_city($city = '')
143
+	{
144
+		$this->set('ATT_city', $city);
145
+	}
146
+
147
+
148
+	/**
149
+	 *        Set Attendee State ID
150
+	 *
151
+	 * @access        public
152
+	 * @param        int $STA_ID
153
+	 * @throws EE_Error
154
+	 */
155
+	public function set_state($STA_ID = 0)
156
+	{
157
+		$this->set('STA_ID', $STA_ID);
158
+	}
159
+
160
+
161
+	/**
162
+	 *        Set Attendee Country ISO Code
163
+	 *
164
+	 * @access        public
165
+	 * @param        string $CNT_ISO
166
+	 * @throws EE_Error
167
+	 */
168
+	public function set_country($CNT_ISO = '')
169
+	{
170
+		$this->set('CNT_ISO', $CNT_ISO);
171
+	}
172
+
173
+
174
+	/**
175
+	 *        Set Attendee Zip/Postal Code
176
+	 *
177
+	 * @access        public
178
+	 * @param        string $zip
179
+	 * @throws EE_Error
180
+	 */
181
+	public function set_zip($zip = '')
182
+	{
183
+		$this->set('ATT_zip', $zip);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Email Address
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $email
192
+	 * @throws EE_Error
193
+	 */
194
+	public function set_email($email = '')
195
+	{
196
+		$this->set('ATT_email', $email);
197
+	}
198
+
199
+
200
+	/**
201
+	 *        Set Attendee Phone
202
+	 *
203
+	 * @access        public
204
+	 * @param        string $phone
205
+	 * @throws EE_Error
206
+	 */
207
+	public function set_phone($phone = '')
208
+	{
209
+		$this->set('ATT_phone', $phone);
210
+	}
211
+
212
+
213
+	/**
214
+	 *        set deleted
215
+	 *
216
+	 * @access        public
217
+	 * @param        bool $ATT_deleted
218
+	 * @throws EE_Error
219
+	 */
220
+	public function set_deleted($ATT_deleted = false)
221
+	{
222
+		$this->set('ATT_deleted', $ATT_deleted);
223
+	}
224
+
225
+
226
+	/**
227
+	 * Returns the value for the post_author id saved with the cpt
228
+	 *
229
+	 * @since 4.5.0
230
+	 * @return int
231
+	 * @throws EE_Error
232
+	 */
233
+	public function wp_user()
234
+	{
235
+		return $this->get('ATT_author');
236
+	}
237
+
238
+
239
+	/**
240
+	 *        get Attendee First Name
241
+	 *
242
+	 * @access        public
243
+	 * @return string
244
+	 * @throws EE_Error
245
+	 */
246
+	public function fname()
247
+	{
248
+		return $this->get('ATT_fname');
249
+	}
250
+
251
+
252
+	/**
253
+	 * echoes out the attendee's first name
254
+	 *
255
+	 * @return void
256
+	 * @throws EE_Error
257
+	 */
258
+	public function e_full_name()
259
+	{
260
+		echo $this->full_name();
261
+	}
262
+
263
+
264
+	/**
265
+	 * Returns the first and last name concatenated together with a space.
266
+	 *
267
+	 * @param bool $apply_html_entities
268
+	 * @return string
269
+	 * @throws EE_Error
270
+	 */
271
+	public function full_name($apply_html_entities = false)
272
+	{
273
+		$full_name = array(
274
+			$this->fname(),
275
+			$this->lname(),
276
+		);
277
+		$full_name = array_filter($full_name);
278
+		$full_name = implode(' ', $full_name);
279
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
+	}
281
+
282
+
283
+	/**
284
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
+	 * attendee.
287
+	 *
288
+	 * @param bool $apply_html_entities
289
+	 * @return string
290
+	 * @throws EE_Error
291
+	 */
292
+	public function ATT_full_name($apply_html_entities = false)
293
+	{
294
+		return $apply_html_entities
295
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
+			: $this->get('ATT_full_name');
297
+	}
298
+
299
+
300
+	/**
301
+	 *        get Attendee Last Name
302
+	 *
303
+	 * @access        public
304
+	 * @return string
305
+	 * @throws EE_Error
306
+	 */
307
+	public function lname()
308
+	{
309
+		return $this->get('ATT_lname');
310
+	}
311
+
312
+
313
+	/**
314
+	 * get Attendee bio
315
+	 *
316
+	 * @access public
317
+	 * @return string
318
+	 * @throws EE_Error
319
+	 */
320
+	public function bio()
321
+	{
322
+		return $this->get('ATT_bio');
323
+	}
324
+
325
+
326
+	/**
327
+	 * get Attendee short bio
328
+	 *
329
+	 * @access public
330
+	 * @return string
331
+	 * @throws EE_Error
332
+	 */
333
+	public function short_bio()
334
+	{
335
+		return $this->get('ATT_short_bio');
336
+	}
337
+
338
+
339
+	/**
340
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
341
+	 *
342
+	 * @return array numerically indexed, with each part of the address that is known.
343
+	 * Eg, if the user only responded to state and country,
344
+	 * it would be array(0=>'Alabama',1=>'USA')
345
+	 * @return array
346
+	 * @throws EE_Error
347
+	 */
348
+	public function full_address_as_array()
349
+	{
350
+		$full_address_array = array();
351
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
352
+		foreach ($initial_address_fields as $address_field_name) {
353
+			$address_fields_value = $this->get($address_field_name);
354
+			if (! empty($address_fields_value)) {
355
+				$full_address_array[] = $address_fields_value;
356
+			}
357
+		}
358
+		// now handle state and country
359
+		$state_obj = $this->state_obj();
360
+		if ($state_obj instanceof EE_State) {
361
+			$full_address_array[] = $state_obj->name();
362
+		}
363
+		$country_obj = $this->country_obj();
364
+		if ($country_obj instanceof EE_Country) {
365
+			$full_address_array[] = $country_obj->name();
366
+		}
367
+		// lastly get the xip
368
+		$zip_value = $this->zip();
369
+		if (! empty($zip_value)) {
370
+			$full_address_array[] = $zip_value;
371
+		}
372
+		return $full_address_array;
373
+	}
374
+
375
+
376
+	/**
377
+	 *        get Attendee Address
378
+	 *
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 */
382
+	public function address()
383
+	{
384
+		return $this->get('ATT_address');
385
+	}
386
+
387
+
388
+	/**
389
+	 *        get Attendee Address2
390
+	 *
391
+	 * @return string
392
+	 * @throws EE_Error
393
+	 */
394
+	public function address2()
395
+	{
396
+		return $this->get('ATT_address2');
397
+	}
398
+
399
+
400
+	/**
401
+	 *        get Attendee City
402
+	 *
403
+	 * @return string
404
+	 * @throws EE_Error
405
+	 */
406
+	public function city()
407
+	{
408
+		return $this->get('ATT_city');
409
+	}
410
+
411
+
412
+	/**
413
+	 *        get Attendee State ID
414
+	 *
415
+	 * @return string
416
+	 * @throws EE_Error
417
+	 */
418
+	public function state_ID()
419
+	{
420
+		return $this->get('STA_ID');
421
+	}
422
+
423
+
424
+	/**
425
+	 * @return string
426
+	 * @throws EE_Error
427
+	 */
428
+	public function state_abbrev()
429
+	{
430
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
431
+	}
432
+
433
+
434
+	/**
435
+	 * Gets the state set to this attendee
436
+	 *
437
+	 * @return EE_State
438
+	 * @throws EE_Error
439
+	 */
440
+	public function state_obj()
441
+	{
442
+		return $this->get_first_related('State');
443
+	}
444
+
445
+
446
+	/**
447
+	 * Returns the state's name, otherwise 'Unknown'
448
+	 *
449
+	 * @return string
450
+	 * @throws EE_Error
451
+	 */
452
+	public function state_name()
453
+	{
454
+		if ($this->state_obj()) {
455
+			return $this->state_obj()->name();
456
+		} else {
457
+			return '';
458
+		}
459
+	}
460
+
461
+
462
+	/**
463
+	 * either displays the state abbreviation or the state name, as determined
464
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
465
+	 * defaults to abbreviation
466
+	 *
467
+	 * @return string
468
+	 * @throws EE_Error
469
+	 */
470
+	public function state()
471
+	{
472
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
473
+			return $this->state_abbrev();
474
+		}
475
+		return $this->state_name();
476
+	}
477
+
478
+
479
+	/**
480
+	 *    get Attendee Country ISO Code
481
+	 *
482
+	 * @return string
483
+	 * @throws EE_Error
484
+	 */
485
+	public function country_ID()
486
+	{
487
+		return $this->get('CNT_ISO');
488
+	}
489
+
490
+
491
+	/**
492
+	 * Gets country set for this attendee
493
+	 *
494
+	 * @return EE_Country
495
+	 * @throws EE_Error
496
+	 */
497
+	public function country_obj()
498
+	{
499
+		return $this->get_first_related('Country');
500
+	}
501
+
502
+
503
+	/**
504
+	 * Returns the country's name if known, otherwise 'Unknown'
505
+	 *
506
+	 * @return string
507
+	 * @throws EE_Error
508
+	 */
509
+	public function country_name()
510
+	{
511
+		if ($this->country_obj()) {
512
+			return $this->country_obj()->name();
513
+		}
514
+		return '';
515
+	}
516
+
517
+
518
+	/**
519
+	 * either displays the country ISO2 code or the country name, as determined
520
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
521
+	 * defaults to abbreviation
522
+	 *
523
+	 * @return string
524
+	 * @throws EE_Error
525
+	 */
526
+	public function country()
527
+	{
528
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
529
+			return $this->country_ID();
530
+		}
531
+		return $this->country_name();
532
+	}
533
+
534
+
535
+	/**
536
+	 *        get Attendee Zip/Postal Code
537
+	 *
538
+	 * @return string
539
+	 * @throws EE_Error
540
+	 */
541
+	public function zip()
542
+	{
543
+		return $this->get('ATT_zip');
544
+	}
545
+
546
+
547
+	/**
548
+	 *        get Attendee Email Address
549
+	 *
550
+	 * @return string
551
+	 * @throws EE_Error
552
+	 */
553
+	public function email()
554
+	{
555
+		return $this->get('ATT_email');
556
+	}
557
+
558
+
559
+	/**
560
+	 *        get Attendee Phone #
561
+	 *
562
+	 * @return string
563
+	 * @throws EE_Error
564
+	 */
565
+	public function phone()
566
+	{
567
+		return $this->get('ATT_phone');
568
+	}
569
+
570
+
571
+	/**
572
+	 *    get deleted
573
+	 *
574
+	 * @return        bool
575
+	 * @throws EE_Error
576
+	 */
577
+	public function deleted()
578
+	{
579
+		return $this->get('ATT_deleted');
580
+	}
581
+
582
+
583
+	/**
584
+	 * Gets registrations of this attendee
585
+	 *
586
+	 * @param array $query_params
587
+	 * @return EE_Registration[]
588
+	 * @throws EE_Error
589
+	 */
590
+	public function get_registrations($query_params = array())
591
+	{
592
+		return $this->get_many_related('Registration', $query_params);
593
+	}
594
+
595
+
596
+	/**
597
+	 * Gets the most recent registration of this attendee
598
+	 *
599
+	 * @return EE_Registration
600
+	 * @throws EE_Error
601
+	 */
602
+	public function get_most_recent_registration()
603
+	{
604
+		return $this->get_first_related(
605
+			'Registration',
606
+			array('order_by' => array('REG_date' => 'DESC'))
607
+		); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
608
+	}
609
+
610
+
611
+	/**
612
+	 * Gets the most recent registration for this attend at this event
613
+	 *
614
+	 * @param int $event_id
615
+	 * @return EE_Registration
616
+	 * @throws EE_Error
617
+	 */
618
+	public function get_most_recent_registration_for_event($event_id)
619
+	{
620
+		return $this->get_first_related(
621
+			'Registration',
622
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
623
+		);
624
+	}
625
+
626
+
627
+	/**
628
+	 * returns any events attached to this attendee ($_Event property);
629
+	 *
630
+	 * @return array
631
+	 * @throws EE_Error
632
+	 */
633
+	public function events()
634
+	{
635
+		return $this->get_many_related('Event');
636
+	}
637
+
638
+
639
+	/**
640
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
641
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
642
+	 * used to save the billing info
643
+	 *
644
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
645
+	 * @return EE_Form_Section_Proper|null
646
+	 * @throws EE_Error
647
+	 */
648
+	public function billing_info_for_payment_method($payment_method)
649
+	{
650
+		$pm_type = $payment_method->type_obj();
651
+		if (! $pm_type instanceof EE_PMT_Base) {
652
+			return null;
653
+		}
654
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
655
+		if (! $billing_info) {
656
+			return null;
657
+		}
658
+		$billing_form = $pm_type->billing_form();
659
+		// double-check the form isn't totally hidden, in which case pretend there is no form
660
+		$form_totally_hidden = true;
661
+		foreach ($billing_form->inputs_in_subsections() as $input) {
662
+			if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
663
+				$form_totally_hidden = false;
664
+				break;
665
+			}
666
+		}
667
+		if ($form_totally_hidden) {
668
+			return null;
669
+		}
670
+		if ($billing_form instanceof EE_Form_Section_Proper) {
671
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
672
+		}
673
+
674
+		return $billing_form;
675
+	}
676
+
677
+
678
+	/**
679
+	 * Gets the postmeta key that holds this attendee's billing info for the
680
+	 * specified payment method
681
+	 *
682
+	 * @param EE_Payment_Method $payment_method
683
+	 * @return string
684
+	 * @throws EE_Error
685
+	 */
686
+	public function get_billing_info_postmeta_name($payment_method)
687
+	{
688
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
689
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
690
+		}
691
+		return null;
692
+	}
693
+
694
+
695
+	/**
696
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
697
+	 * retrieve it
698
+	 *
699
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
700
+	 * @param EE_Payment_Method             $payment_method
701
+	 * @return boolean
702
+	 * @throws EE_Error
703
+	 */
704
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
705
+	{
706
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
707
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
708
+			return false;
709
+		}
710
+		$billing_form->clean_sensitive_data();
711
+		return update_post_meta(
712
+			$this->ID(),
713
+			$this->get_billing_info_postmeta_name($payment_method),
714
+			$billing_form->input_values(true)
715
+		);
716
+	}
717
+
718
+
719
+	/**
720
+	 * Return the link to the admin details for the object.
721
+	 *
722
+	 * @return string
723
+	 * @throws EE_Error
724
+	 * @throws InvalidArgumentException
725
+	 * @throws InvalidDataTypeException
726
+	 * @throws InvalidInterfaceException
727
+	 * @throws ReflectionException
728
+	 */
729
+	public function get_admin_details_link()
730
+	{
731
+		return $this->get_admin_edit_link();
732
+	}
733
+
734
+
735
+	/**
736
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
737
+	 *
738
+	 * @return string
739
+	 * @throws EE_Error
740
+	 * @throws InvalidArgumentException
741
+	 * @throws ReflectionException
742
+	 * @throws InvalidDataTypeException
743
+	 * @throws InvalidInterfaceException
744
+	 */
745
+	public function get_admin_edit_link()
746
+	{
747
+		EE_Registry::instance()->load_helper('URL');
748
+		return EEH_URL::add_query_args_and_nonce(
749
+			array(
750
+				'page'   => 'espresso_registrations',
751
+				'action' => 'edit_attendee',
752
+				'post'   => $this->ID(),
753
+			),
754
+			admin_url('admin.php')
755
+		);
756
+	}
757
+
758
+
759
+	/**
760
+	 * Returns the link to a settings page for the object.
761
+	 *
762
+	 * @return string
763
+	 * @throws EE_Error
764
+	 * @throws InvalidArgumentException
765
+	 * @throws InvalidDataTypeException
766
+	 * @throws InvalidInterfaceException
767
+	 * @throws ReflectionException
768
+	 */
769
+	public function get_admin_settings_link()
770
+	{
771
+		return $this->get_admin_edit_link();
772
+	}
773
+
774
+
775
+	/**
776
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
777
+	 *
778
+	 * @return string
779
+	 * @throws EE_Error
780
+	 * @throws InvalidArgumentException
781
+	 * @throws ReflectionException
782
+	 * @throws InvalidDataTypeException
783
+	 * @throws InvalidInterfaceException
784
+	 */
785
+	public function get_admin_overview_link()
786
+	{
787
+		EE_Registry::instance()->load_helper('URL');
788
+		return EEH_URL::add_query_args_and_nonce(
789
+			array(
790
+				'page'   => 'espresso_registrations',
791
+				'action' => 'contact_list',
792
+			),
793
+			admin_url('admin.php')
794
+		);
795
+	}
796 796
 }
Please login to merge, or discard this patch.
core/services/graphql/TypesManager.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -19,133 +19,133 @@
 block discarded – undo
19 19
 class TypesManager
20 20
 {
21 21
 
22
-    /**
23
-     * @var TypeCollection|TypeInterface[] $types
24
-     */
25
-    private $types;
26
-
27
-
28
-    /**
29
-     * TypesManager constructor.
30
-     *
31
-     * @param TypeCollection|TypeInterface[] $types
32
-     */
33
-    public function __construct(TypeCollection $types)
34
-    {
35
-        $this->types = $types;
36
-    }
37
-
38
-
39
-    /**
40
-     * @throws CollectionDetailsException
41
-     * @throws CollectionLoaderException
42
-     * @since $VID:$
43
-     */
44
-    public function init()
45
-    {
46
-        $this->types->loadTypes();
47
-        add_action('graphql_register_types', [$this, 'configureTypes'], 10);
48
-
49
-        add_filter('graphql_data_loaders', [$this, 'registerLoaders'], 10, 2);
50
-    }
51
-
52
-
53
-    /**
54
-     * @param array      $loaders The loaders accessible in the AppContext
55
-     * @param AppContext $context The AppContext
56
-     *
57
-     * @since $VID:$
58
-     */
59
-    public function registerLoaders($loaders, $context)
60
-    {
61
-        $newLoaders = [
62
-            'espresso_attendee'  => new Loaders\AttendeeLoader($context),
63
-            'espresso_datetime'  => new Loaders\DatetimeLoader($context),
64
-            'espresso_price'     => new Loaders\PriceLoader($context),
65
-            'espresso_priceType' => new Loaders\PriceTypeLoader($context),
66
-            'espresso_ticket'    => new Loaders\TicketLoader($context),
67
-            'espresso_venue'     => new Loaders\VenueLoader($context),
68
-        ];
69
-
70
-        return array_merge($loaders, $newLoaders);
71
-    }
72
-
73
-
74
-    /**
75
-     * @since $VID:$
76
-     */
77
-    public function configureTypes()
78
-    {
79
-        // loop through the collection of types and register their fields
80
-        foreach ($this->types as $type) {
81
-            if ($type->isCustomPostType()) {
82
-                $this->extendCustomPostType($type);
83
-            } else {
84
-                $this->registerType($type);
85
-            }
86
-        }
87
-    }
88
-
89
-
90
-    /**
91
-     * @param TypeInterface $type
92
-     * @since $VID:$
93
-     */
94
-    public function extendCustomPostType(TypeInterface $type)
95
-    {
96
-        $typeName = $type->name();
97
-        foreach ($type->fields() as $field) {
98
-            $fieldName = $field->name();
99
-            $config = $field->toArray();
100
-            if ($field->useForInput()) {
101
-                // Register input fields for existing mutations.
102
-                register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config);
103
-                register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config);
104
-            }
105
-            if ($field->useForOutput()) {
106
-                $config['resolve'] = [$type, 'resolveField'];
107
-                // Register fields for queries.
108
-                register_graphql_field($typeName, $fieldName, $config);
109
-            }
110
-        }
111
-        if (is_callable([$type, 'extendMutations'])) {
112
-            $type->extendMutations();
113
-        }
114
-    }
115
-
116
-
117
-    /**
118
-     * @param TypeInterface $type
119
-     * @since $VID:$
120
-     */
121
-    public function registerType(TypeInterface $type)
122
-    {
123
-        $outputFields = [];
124
-        $inputFields = [];
125
-        foreach ($type->fields() as $field) {
126
-            $fieldName = $field->name();
127
-            $config = $field->toArray();
128
-            if ($field->useForInput()) {
129
-                $inputFields[ $fieldName ] = $config;
130
-            }
131
-            if ($field->useForOutput()) {
132
-                $config['resolve'] = [$type, 'resolveField'];
133
-                $outputFields[ $fieldName ] = $config;
134
-            }
135
-        }
136
-        $typeName = $type->name();
137
-        if (! empty($outputFields)) {
138
-            // Register the object type.
139
-            register_graphql_object_type(
140
-                $typeName,
141
-                [
142
-                    'description' => $type->description(),
143
-                    'fields'      => $outputFields,
144
-                ]
145
-            );
146
-        }
147
-        if (is_callable([$type, 'registerMutations'])) {
148
-            $type->registerMutations($inputFields);
149
-        }
150
-    }
22
+	/**
23
+	 * @var TypeCollection|TypeInterface[] $types
24
+	 */
25
+	private $types;
26
+
27
+
28
+	/**
29
+	 * TypesManager constructor.
30
+	 *
31
+	 * @param TypeCollection|TypeInterface[] $types
32
+	 */
33
+	public function __construct(TypeCollection $types)
34
+	{
35
+		$this->types = $types;
36
+	}
37
+
38
+
39
+	/**
40
+	 * @throws CollectionDetailsException
41
+	 * @throws CollectionLoaderException
42
+	 * @since $VID:$
43
+	 */
44
+	public function init()
45
+	{
46
+		$this->types->loadTypes();
47
+		add_action('graphql_register_types', [$this, 'configureTypes'], 10);
48
+
49
+		add_filter('graphql_data_loaders', [$this, 'registerLoaders'], 10, 2);
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param array      $loaders The loaders accessible in the AppContext
55
+	 * @param AppContext $context The AppContext
56
+	 *
57
+	 * @since $VID:$
58
+	 */
59
+	public function registerLoaders($loaders, $context)
60
+	{
61
+		$newLoaders = [
62
+			'espresso_attendee'  => new Loaders\AttendeeLoader($context),
63
+			'espresso_datetime'  => new Loaders\DatetimeLoader($context),
64
+			'espresso_price'     => new Loaders\PriceLoader($context),
65
+			'espresso_priceType' => new Loaders\PriceTypeLoader($context),
66
+			'espresso_ticket'    => new Loaders\TicketLoader($context),
67
+			'espresso_venue'     => new Loaders\VenueLoader($context),
68
+		];
69
+
70
+		return array_merge($loaders, $newLoaders);
71
+	}
72
+
73
+
74
+	/**
75
+	 * @since $VID:$
76
+	 */
77
+	public function configureTypes()
78
+	{
79
+		// loop through the collection of types and register their fields
80
+		foreach ($this->types as $type) {
81
+			if ($type->isCustomPostType()) {
82
+				$this->extendCustomPostType($type);
83
+			} else {
84
+				$this->registerType($type);
85
+			}
86
+		}
87
+	}
88
+
89
+
90
+	/**
91
+	 * @param TypeInterface $type
92
+	 * @since $VID:$
93
+	 */
94
+	public function extendCustomPostType(TypeInterface $type)
95
+	{
96
+		$typeName = $type->name();
97
+		foreach ($type->fields() as $field) {
98
+			$fieldName = $field->name();
99
+			$config = $field->toArray();
100
+			if ($field->useForInput()) {
101
+				// Register input fields for existing mutations.
102
+				register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config);
103
+				register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config);
104
+			}
105
+			if ($field->useForOutput()) {
106
+				$config['resolve'] = [$type, 'resolveField'];
107
+				// Register fields for queries.
108
+				register_graphql_field($typeName, $fieldName, $config);
109
+			}
110
+		}
111
+		if (is_callable([$type, 'extendMutations'])) {
112
+			$type->extendMutations();
113
+		}
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param TypeInterface $type
119
+	 * @since $VID:$
120
+	 */
121
+	public function registerType(TypeInterface $type)
122
+	{
123
+		$outputFields = [];
124
+		$inputFields = [];
125
+		foreach ($type->fields() as $field) {
126
+			$fieldName = $field->name();
127
+			$config = $field->toArray();
128
+			if ($field->useForInput()) {
129
+				$inputFields[ $fieldName ] = $config;
130
+			}
131
+			if ($field->useForOutput()) {
132
+				$config['resolve'] = [$type, 'resolveField'];
133
+				$outputFields[ $fieldName ] = $config;
134
+			}
135
+		}
136
+		$typeName = $type->name();
137
+		if (! empty($outputFields)) {
138
+			// Register the object type.
139
+			register_graphql_object_type(
140
+				$typeName,
141
+				[
142
+					'description' => $type->description(),
143
+					'fields'      => $outputFields,
144
+				]
145
+			);
146
+		}
147
+		if (is_callable([$type, 'registerMutations'])) {
148
+			$type->registerMutations($inputFields);
149
+		}
150
+	}
151 151
 }
Please login to merge, or discard this patch.
core/services/assets/I18nRegistry.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -15,226 +15,226 @@
 block discarded – undo
15 15
  */
16 16
 class I18nRegistry
17 17
 {
18
-    /**
19
-     * @var DomainInterface
20
-     */
21
-    private $domain;
22
-
23
-    /**
24
-     * Will hold all registered i18n scripts.  Prevents script handles from being registered more than once.
25
-     *
26
-     * @var array
27
-     */
28
-    private $registered_i18n = array();
29
-
30
-    /**
31
-     * Used to hold queued translations for the chunks loading in a view.
32
-     *
33
-     * @var array
34
-     */
35
-    private $queued_handle_translations = array();
36
-
37
-    /**
38
-     * Used to track script handles queued for adding translation strings as inline data in the dom.
39
-     *
40
-     * @var array
41
-     */
42
-    private $queued_scripts = array();
43
-
44
-    /**
45
-     * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to
46
-     * translation strings.
47
-     *
48
-     * @var array
49
-     */
50
-    private $i18n_map;
51
-
52
-    /**
53
-     * I18nRegistry constructor.
54
-     *
55
-     * @param DomainInterface $domain
56
-     * @param array() $i18n_map  An array of script handle names and the strings translated for those handles.  If not
57
-     *                            provided, the class will look for map in root of plugin with filename of
58
-     *                            'translation-map.json'.
59
-     */
60
-    public function __construct(DomainInterface $domain, array $i18n_map = [])
61
-    {
62
-        $this->domain = $domain;
63
-        $this->setI18nMap($i18n_map);
64
-        add_filter('print_scripts_array', array($this, 'queueI18n'));
65
-    }
66
-
67
-    /**
68
-     * Used to register a script that has i18n strings for its $handle
69
-     *
70
-     * @param string $handle The script handle reference.
71
-     * @param string $domain The i18n domain for the strings.
72
-     */
73
-    public function registerScriptI18n($handle, $domain = 'event_espresso')
74
-    {
75
-        if (!isset($this->registered_i18n[$handle])) {
76
-            $this->registered_i18n[$handle] = 1;
77
-            $this->queued_scripts[$handle] = $domain;
78
-        }
79
-    }
80
-
81
-    /**
82
-     * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data.
83
-     *
84
-     * @param array $handles Array of registered script handles.
85
-     * @return array
86
-     */
87
-    public function queueI18n(array $handles)
88
-    {
89
-        if (empty($this->queued_scripts)) {
90
-            return $handles;
91
-        }
92
-        foreach ($handles as $handle) {
93
-            $this->queueI18nTranslationsForHandle($handle);
94
-        }
95
-        if ($this->queued_handle_translations) {
96
-            foreach ($this->queued_handle_translations as $handle => $translations_for_domain) {
97
-                $this->registerInlineScript(
98
-                    $handle,
99
-                    $translations_for_domain['translations'],
100
-                    $translations_for_domain['domain']
101
-                );
102
-                unset($this->queued_handle_translations[$handle]);
103
-            }
104
-        }
105
-        return $handles;
106
-    }
107
-
108
-    /**
109
-     * Registers inline script with translations for given handle and domain.
110
-     *
111
-     * @param string $handle       Handle used to register javascript file containing translations.
112
-     * @param array  $translations Array of string translations.
113
-     * @param string $domain       Domain for translations.  If left empty then strings are registered with the default
114
-     *                             domain for the javascript.
115
-     */
116
-    protected function registerInlineScript($handle, array $translations, $domain)
117
-    {
118
-        $script = $domain ?
119
-        'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' :
120
-        'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );';
121
-        wp_add_inline_script($handle, $script, 'before');
122
-    }
123
-
124
-    /**
125
-     * Queues up the translation strings for the given handle.
126
-     *
127
-     * @param string $handle The script handle being queued up.
128
-     */
129
-    private function queueI18nTranslationsForHandle($handle)
130
-    {
131
-        if (isset($this->queued_scripts[$handle])) {
132
-            $domain = $this->queued_scripts[$handle];
133
-            $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain);
134
-            if (count($translations) > 0) {
135
-                $this->queued_handle_translations[$handle] = array(
136
-                    'domain' => $domain,
137
-                    'translations' => $translations,
138
-                );
139
-            }
140
-            unset($this->queued_scripts[$handle]);
141
-        }
142
-    }
143
-
144
-    /**
145
-     * Sets the internal i18n_map property.
146
-     * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map.
147
-     *
148
-     * @param array $i18n_map  If provided, an array of translation strings indexed by script handle names they
149
-     *                         correspond to.
150
-     */
151
-    private function setI18nMap(array $i18n_map)
152
-    {
153
-        if (empty($i18n_map)) {
154
-            $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json')
155
-            ? json_decode(
156
-                file_get_contents($this->domain->pluginPath() . 'translation-map.json'),
157
-                true
158
-            )
159
-            : array();
160
-        }
161
-        $this->i18n_map = $i18n_map;
162
-    }
163
-
164
-    /**
165
-     * Get the jed locale data for a given $handle and domain
166
-     *
167
-     * @param string $handle The name for the script handle we want strings returned for.
168
-     * @param string $domain The i18n domain.
169
-     * @return array
170
-     */
171
-    protected function getJedLocaleDataForDomainAndChunk($handle, $domain)
172
-    {
173
-        $translations = $this->getJedLocaleData($domain);
174
-        // get index for adding back after extracting strings for this $chunk.
175
-        $index = $translations[''];
176
-        $translations = $this->getLocaleDataMatchingMap(
177
-            $this->getOriginalStringsForHandleFromMap($handle),
178
-            $translations
179
-        );
180
-        $translations[''] = $index;
181
-        return $translations;
182
-    }
183
-
184
-    /**
185
-     * Get locale data for given strings from given translations
186
-     *
187
-     * @param array $string_set   This is the subset of strings (msgIds) we want to extract from the translations array.
188
-     * @param array $translations Translation data to extra strings from.
189
-     * @return array
190
-     */
191
-    protected function getLocaleDataMatchingMap(array $string_set, array $translations)
192
-    {
193
-        if (empty($string_set)) {
194
-            return array();
195
-        }
196
-        // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are
197
-        // slashed also filter falsey values.
198
-        $string_set = array_unique(array_filter(wp_slash($string_set)));
199
-        return array_intersect_key($translations, array_flip($string_set));
200
-    }
201
-
202
-    /**
203
-     * Get original strings to translate for the given chunk from the map
204
-     *
205
-     * @param string $handle The script handle name to get strings from the map for.
206
-     * @return array
207
-     */
208
-    protected function getOriginalStringsForHandleFromMap($handle)
209
-    {
210
-        return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array();
211
-    }
212
-
213
-    /**
214
-     * Returns Jed-formatted localization data.
215
-     *
216
-     * @param  string $domain Translation domain.
217
-     * @return array
218
-     */
219
-    private function getJedLocaleData($domain)
220
-    {
221
-        $translations = get_translations_for_domain($domain);
222
-
223
-        $locale = array(
224
-            '' => array(
225
-                'domain' => $domain,
226
-                'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale(),
227
-            ),
228
-        );
229
-
230
-        if (!empty($translations->headers['Plural-Forms'])) {
231
-            $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
232
-        }
233
-
234
-        foreach ($translations->entries as $msgid => $entry) {
235
-            $locale[$msgid] = $entry->translations;
236
-        }
237
-
238
-        return $locale;
239
-    }
18
+	/**
19
+	 * @var DomainInterface
20
+	 */
21
+	private $domain;
22
+
23
+	/**
24
+	 * Will hold all registered i18n scripts.  Prevents script handles from being registered more than once.
25
+	 *
26
+	 * @var array
27
+	 */
28
+	private $registered_i18n = array();
29
+
30
+	/**
31
+	 * Used to hold queued translations for the chunks loading in a view.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	private $queued_handle_translations = array();
36
+
37
+	/**
38
+	 * Used to track script handles queued for adding translation strings as inline data in the dom.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	private $queued_scripts = array();
43
+
44
+	/**
45
+	 * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to
46
+	 * translation strings.
47
+	 *
48
+	 * @var array
49
+	 */
50
+	private $i18n_map;
51
+
52
+	/**
53
+	 * I18nRegistry constructor.
54
+	 *
55
+	 * @param DomainInterface $domain
56
+	 * @param array() $i18n_map  An array of script handle names and the strings translated for those handles.  If not
57
+	 *                            provided, the class will look for map in root of plugin with filename of
58
+	 *                            'translation-map.json'.
59
+	 */
60
+	public function __construct(DomainInterface $domain, array $i18n_map = [])
61
+	{
62
+		$this->domain = $domain;
63
+		$this->setI18nMap($i18n_map);
64
+		add_filter('print_scripts_array', array($this, 'queueI18n'));
65
+	}
66
+
67
+	/**
68
+	 * Used to register a script that has i18n strings for its $handle
69
+	 *
70
+	 * @param string $handle The script handle reference.
71
+	 * @param string $domain The i18n domain for the strings.
72
+	 */
73
+	public function registerScriptI18n($handle, $domain = 'event_espresso')
74
+	{
75
+		if (!isset($this->registered_i18n[$handle])) {
76
+			$this->registered_i18n[$handle] = 1;
77
+			$this->queued_scripts[$handle] = $domain;
78
+		}
79
+	}
80
+
81
+	/**
82
+	 * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data.
83
+	 *
84
+	 * @param array $handles Array of registered script handles.
85
+	 * @return array
86
+	 */
87
+	public function queueI18n(array $handles)
88
+	{
89
+		if (empty($this->queued_scripts)) {
90
+			return $handles;
91
+		}
92
+		foreach ($handles as $handle) {
93
+			$this->queueI18nTranslationsForHandle($handle);
94
+		}
95
+		if ($this->queued_handle_translations) {
96
+			foreach ($this->queued_handle_translations as $handle => $translations_for_domain) {
97
+				$this->registerInlineScript(
98
+					$handle,
99
+					$translations_for_domain['translations'],
100
+					$translations_for_domain['domain']
101
+				);
102
+				unset($this->queued_handle_translations[$handle]);
103
+			}
104
+		}
105
+		return $handles;
106
+	}
107
+
108
+	/**
109
+	 * Registers inline script with translations for given handle and domain.
110
+	 *
111
+	 * @param string $handle       Handle used to register javascript file containing translations.
112
+	 * @param array  $translations Array of string translations.
113
+	 * @param string $domain       Domain for translations.  If left empty then strings are registered with the default
114
+	 *                             domain for the javascript.
115
+	 */
116
+	protected function registerInlineScript($handle, array $translations, $domain)
117
+	{
118
+		$script = $domain ?
119
+		'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' :
120
+		'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );';
121
+		wp_add_inline_script($handle, $script, 'before');
122
+	}
123
+
124
+	/**
125
+	 * Queues up the translation strings for the given handle.
126
+	 *
127
+	 * @param string $handle The script handle being queued up.
128
+	 */
129
+	private function queueI18nTranslationsForHandle($handle)
130
+	{
131
+		if (isset($this->queued_scripts[$handle])) {
132
+			$domain = $this->queued_scripts[$handle];
133
+			$translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain);
134
+			if (count($translations) > 0) {
135
+				$this->queued_handle_translations[$handle] = array(
136
+					'domain' => $domain,
137
+					'translations' => $translations,
138
+				);
139
+			}
140
+			unset($this->queued_scripts[$handle]);
141
+		}
142
+	}
143
+
144
+	/**
145
+	 * Sets the internal i18n_map property.
146
+	 * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map.
147
+	 *
148
+	 * @param array $i18n_map  If provided, an array of translation strings indexed by script handle names they
149
+	 *                         correspond to.
150
+	 */
151
+	private function setI18nMap(array $i18n_map)
152
+	{
153
+		if (empty($i18n_map)) {
154
+			$i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json')
155
+			? json_decode(
156
+				file_get_contents($this->domain->pluginPath() . 'translation-map.json'),
157
+				true
158
+			)
159
+			: array();
160
+		}
161
+		$this->i18n_map = $i18n_map;
162
+	}
163
+
164
+	/**
165
+	 * Get the jed locale data for a given $handle and domain
166
+	 *
167
+	 * @param string $handle The name for the script handle we want strings returned for.
168
+	 * @param string $domain The i18n domain.
169
+	 * @return array
170
+	 */
171
+	protected function getJedLocaleDataForDomainAndChunk($handle, $domain)
172
+	{
173
+		$translations = $this->getJedLocaleData($domain);
174
+		// get index for adding back after extracting strings for this $chunk.
175
+		$index = $translations[''];
176
+		$translations = $this->getLocaleDataMatchingMap(
177
+			$this->getOriginalStringsForHandleFromMap($handle),
178
+			$translations
179
+		);
180
+		$translations[''] = $index;
181
+		return $translations;
182
+	}
183
+
184
+	/**
185
+	 * Get locale data for given strings from given translations
186
+	 *
187
+	 * @param array $string_set   This is the subset of strings (msgIds) we want to extract from the translations array.
188
+	 * @param array $translations Translation data to extra strings from.
189
+	 * @return array
190
+	 */
191
+	protected function getLocaleDataMatchingMap(array $string_set, array $translations)
192
+	{
193
+		if (empty($string_set)) {
194
+			return array();
195
+		}
196
+		// some strings with quotes in them will break on the array_flip, so making sure quotes in the string are
197
+		// slashed also filter falsey values.
198
+		$string_set = array_unique(array_filter(wp_slash($string_set)));
199
+		return array_intersect_key($translations, array_flip($string_set));
200
+	}
201
+
202
+	/**
203
+	 * Get original strings to translate for the given chunk from the map
204
+	 *
205
+	 * @param string $handle The script handle name to get strings from the map for.
206
+	 * @return array
207
+	 */
208
+	protected function getOriginalStringsForHandleFromMap($handle)
209
+	{
210
+		return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array();
211
+	}
212
+
213
+	/**
214
+	 * Returns Jed-formatted localization data.
215
+	 *
216
+	 * @param  string $domain Translation domain.
217
+	 * @return array
218
+	 */
219
+	private function getJedLocaleData($domain)
220
+	{
221
+		$translations = get_translations_for_domain($domain);
222
+
223
+		$locale = array(
224
+			'' => array(
225
+				'domain' => $domain,
226
+				'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale(),
227
+			),
228
+		);
229
+
230
+		if (!empty($translations->headers['Plural-Forms'])) {
231
+			$locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
232
+		}
233
+
234
+		foreach ($translations->entries as $msgid => $entry) {
235
+			$locale[$msgid] = $entry->translations;
236
+		}
237
+
238
+		return $locale;
239
+	}
240 240
 }
Please login to merge, or discard this patch.