Completed
Branch BUG/PHP8-getClass-deprecated (0f65d3)
by
unknown
18:28 queued 09:47
created
core/services/container/Mirror.php 2 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -21,234 +21,234 @@
 block discarded – undo
21 21
 class Mirror
22 22
 {
23 23
 
24
-    /**
25
-     * @var ReflectionClass[] $classes
26
-     */
27
-    private $classes = array();
28
-
29
-    /**
30
-     * @var ReflectionMethod[] $constructors
31
-     */
32
-    private $constructors = array();
33
-
34
-    /**
35
-     * @var ReflectionParameter[][] $parameters
36
-     */
37
-    private $parameters = array();
38
-
39
-    /**
40
-     * @var ReflectionParameter[][] $parameters
41
-     */
42
-    private $parameter_classes = array();
43
-
44
-    /**
45
-     * @var ReflectionProperty[][] $properties
46
-     */
47
-    private $properties = array();
48
-
49
-    /**
50
-     * @var ReflectionMethod[][] $methods
51
-     */
52
-    private $methods = array();
53
-
54
-
55
-    /**
56
-     * @param string $class_name
57
-     * @return ReflectionClass
58
-     * @throws ReflectionException
59
-     * @throws InvalidDataTypeException
60
-     */
61
-    public function getReflectionClass($class_name)
62
-    {
63
-        if (! is_string($class_name)) {
64
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65
-        }
66
-        if (! isset($this->classes[ $class_name ])) {
67
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
68
-        }
69
-        return $this->classes[ $class_name ];
70
-    }
71
-
72
-
73
-    /**
74
-     * @param string $class_name
75
-     * @return ReflectionMethod
76
-     * @throws InvalidDataTypeException
77
-     * @throws ReflectionException
78
-     */
79
-    public function getConstructor($class_name)
80
-    {
81
-        if (! is_string($class_name)) {
82
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83
-        }
84
-        if (! isset($this->constructors[ $class_name ])) {
85
-            $reflection_class                  = $this->getReflectionClass($class_name);
86
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
87
-        }
88
-        return $this->constructors[ $class_name ];
89
-    }
90
-
91
-
92
-    /**
93
-     * @param ReflectionClass $reflection_class
94
-     * @return ReflectionMethod
95
-     * @throws InvalidDataTypeException
96
-     * @throws ReflectionException
97
-     */
98
-    public function getConstructorFromReflection(ReflectionClass $reflection_class)
99
-    {
100
-        return $this->getConstructor($reflection_class->getName());
101
-    }
102
-
103
-
104
-    /**
105
-     * @param string $class_name
106
-     * @return ReflectionParameter[]
107
-     * @throws InvalidDataTypeException
108
-     * @throws ReflectionException
109
-     */
110
-    public function getParameters($class_name)
111
-    {
112
-        if (! isset($this->parameters[ $class_name ])) {
113
-            $constructor                     = $this->getConstructor($class_name);
114
-            $this->parameters[ $class_name ] = $constructor->getParameters();
115
-        }
116
-        return $this->parameters[ $class_name ];
117
-    }
118
-
119
-
120
-    /**
121
-     * @param ReflectionClass $reflection_class
122
-     * @return ReflectionParameter[]
123
-     * @throws InvalidDataTypeException
124
-     * @throws ReflectionException
125
-     */
126
-    public function getParametersFromReflection(ReflectionClass $reflection_class)
127
-    {
128
-        return $this->getParameters($reflection_class->getName());
129
-    }
130
-
131
-
132
-    /**
133
-     * @param ReflectionMethod $constructor
134
-     * @return ReflectionParameter[]
135
-     * @throws InvalidDataTypeException
136
-     * @throws ReflectionException
137
-     */
138
-    public function getParametersFromReflectionConstructor(ReflectionMethod $constructor)
139
-    {
140
-        return $this->getParameters($constructor->getDeclaringClass());
141
-    }
142
-
143
-
144
-    /**
145
-     * @param ReflectionParameter $param
146
-     * @param string              $class_name
147
-     * @param string              $index
148
-     * @return string|null
149
-     */
150
-    public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151
-    {
152
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
154
-        }
155
-        if (! isset($this->parameter_classes[ $class_name ])) {
156
-            $this->parameter_classes[ $class_name ] = array();
157
-        }
158
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
-            $this->parameter_classes[ $class_name ][ $index ] = array();
160
-        }
161
-        // ReflectionParameter::getClass() is deprecated in PHP 8+
162
-        if (PHP_VERSION_ID >= 80000) {
163
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
164
-                $param->getType() instanceof ReflectionNamedType
165
-                    ? $param->getType()->getName()
166
-                    : null;
167
-        } else {
168
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
169
-                    ? $param->getClass()->getName()
170
-                    : null;
171
-        }
172
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
173
-    }
174
-
175
-
176
-    /**
177
-     * @param ReflectionParameter $param
178
-     * @param string              $class_name
179
-     * @param string              $index
180
-     * @return string|null
181
-     */
182
-    public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
183
-    {
184
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
185
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
186
-        }
187
-        if (! isset($this->parameter_classes[ $class_name ])) {
188
-            $this->parameter_classes[ $class_name ] = array();
189
-        }
190
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
191
-            $this->parameter_classes[ $class_name ][ $index ] = array();
192
-        }
193
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
194
-            ? $param->getDefaultValue()
195
-            : null;
196
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
197
-    }
198
-
199
-
200
-    /**
201
-     * @param string $class_name
202
-     * @return ReflectionProperty[]
203
-     * @throws InvalidDataTypeException
204
-     * @throws ReflectionException
205
-     */
206
-    public function getProperties($class_name)
207
-    {
208
-        if (! isset($this->properties[ $class_name ])) {
209
-            $reflection_class                = $this->getReflectionClass($class_name);
210
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
211
-        }
212
-        return $this->properties[ $class_name ];
213
-    }
214
-
215
-
216
-    /**
217
-     * @param ReflectionClass $reflection_class
218
-     * @return ReflectionProperty[]
219
-     * @throws InvalidDataTypeException
220
-     * @throws ReflectionException
221
-     */
222
-    public function getPropertiesFromReflection(ReflectionClass $reflection_class)
223
-    {
224
-        return $this->getProperties($reflection_class->getName());
225
-    }
226
-
227
-
228
-    /**
229
-     * @param string $class_name
230
-     * @return ReflectionMethod[]
231
-     * @throws InvalidDataTypeException
232
-     * @throws ReflectionException
233
-     */
234
-    public function getMethods($class_name)
235
-    {
236
-        if (! isset($this->methods[ $class_name ])) {
237
-            $reflection_class             = $this->getReflectionClass($class_name);
238
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
239
-        }
240
-        return $this->methods[ $class_name ];
241
-    }
242
-
243
-
244
-    /**
245
-     * @param ReflectionClass $reflection_class )
246
-     * @return ReflectionMethod[]
247
-     * @throws InvalidDataTypeException
248
-     * @throws ReflectionException
249
-     */
250
-    public function getMethodsFromReflection(ReflectionClass $reflection_class)
251
-    {
252
-        return $this->getMethods($reflection_class->getName());
253
-    }
24
+	/**
25
+	 * @var ReflectionClass[] $classes
26
+	 */
27
+	private $classes = array();
28
+
29
+	/**
30
+	 * @var ReflectionMethod[] $constructors
31
+	 */
32
+	private $constructors = array();
33
+
34
+	/**
35
+	 * @var ReflectionParameter[][] $parameters
36
+	 */
37
+	private $parameters = array();
38
+
39
+	/**
40
+	 * @var ReflectionParameter[][] $parameters
41
+	 */
42
+	private $parameter_classes = array();
43
+
44
+	/**
45
+	 * @var ReflectionProperty[][] $properties
46
+	 */
47
+	private $properties = array();
48
+
49
+	/**
50
+	 * @var ReflectionMethod[][] $methods
51
+	 */
52
+	private $methods = array();
53
+
54
+
55
+	/**
56
+	 * @param string $class_name
57
+	 * @return ReflectionClass
58
+	 * @throws ReflectionException
59
+	 * @throws InvalidDataTypeException
60
+	 */
61
+	public function getReflectionClass($class_name)
62
+	{
63
+		if (! is_string($class_name)) {
64
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65
+		}
66
+		if (! isset($this->classes[ $class_name ])) {
67
+			$this->classes[ $class_name ] = new ReflectionClass($class_name);
68
+		}
69
+		return $this->classes[ $class_name ];
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param string $class_name
75
+	 * @return ReflectionMethod
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function getConstructor($class_name)
80
+	{
81
+		if (! is_string($class_name)) {
82
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83
+		}
84
+		if (! isset($this->constructors[ $class_name ])) {
85
+			$reflection_class                  = $this->getReflectionClass($class_name);
86
+			$this->constructors[ $class_name ] = $reflection_class->getConstructor();
87
+		}
88
+		return $this->constructors[ $class_name ];
89
+	}
90
+
91
+
92
+	/**
93
+	 * @param ReflectionClass $reflection_class
94
+	 * @return ReflectionMethod
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws ReflectionException
97
+	 */
98
+	public function getConstructorFromReflection(ReflectionClass $reflection_class)
99
+	{
100
+		return $this->getConstructor($reflection_class->getName());
101
+	}
102
+
103
+
104
+	/**
105
+	 * @param string $class_name
106
+	 * @return ReflectionParameter[]
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws ReflectionException
109
+	 */
110
+	public function getParameters($class_name)
111
+	{
112
+		if (! isset($this->parameters[ $class_name ])) {
113
+			$constructor                     = $this->getConstructor($class_name);
114
+			$this->parameters[ $class_name ] = $constructor->getParameters();
115
+		}
116
+		return $this->parameters[ $class_name ];
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param ReflectionClass $reflection_class
122
+	 * @return ReflectionParameter[]
123
+	 * @throws InvalidDataTypeException
124
+	 * @throws ReflectionException
125
+	 */
126
+	public function getParametersFromReflection(ReflectionClass $reflection_class)
127
+	{
128
+		return $this->getParameters($reflection_class->getName());
129
+	}
130
+
131
+
132
+	/**
133
+	 * @param ReflectionMethod $constructor
134
+	 * @return ReflectionParameter[]
135
+	 * @throws InvalidDataTypeException
136
+	 * @throws ReflectionException
137
+	 */
138
+	public function getParametersFromReflectionConstructor(ReflectionMethod $constructor)
139
+	{
140
+		return $this->getParameters($constructor->getDeclaringClass());
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param ReflectionParameter $param
146
+	 * @param string              $class_name
147
+	 * @param string              $index
148
+	 * @return string|null
149
+	 */
150
+	public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151
+	{
152
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
154
+		}
155
+		if (! isset($this->parameter_classes[ $class_name ])) {
156
+			$this->parameter_classes[ $class_name ] = array();
157
+		}
158
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
+			$this->parameter_classes[ $class_name ][ $index ] = array();
160
+		}
161
+		// ReflectionParameter::getClass() is deprecated in PHP 8+
162
+		if (PHP_VERSION_ID >= 80000) {
163
+			$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
164
+				$param->getType() instanceof ReflectionNamedType
165
+					? $param->getType()->getName()
166
+					: null;
167
+		} else {
168
+			$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
169
+					? $param->getClass()->getName()
170
+					: null;
171
+		}
172
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param ReflectionParameter $param
178
+	 * @param string              $class_name
179
+	 * @param string              $index
180
+	 * @return string|null
181
+	 */
182
+	public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
183
+	{
184
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
185
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
186
+		}
187
+		if (! isset($this->parameter_classes[ $class_name ])) {
188
+			$this->parameter_classes[ $class_name ] = array();
189
+		}
190
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
191
+			$this->parameter_classes[ $class_name ][ $index ] = array();
192
+		}
193
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
194
+			? $param->getDefaultValue()
195
+			: null;
196
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
197
+	}
198
+
199
+
200
+	/**
201
+	 * @param string $class_name
202
+	 * @return ReflectionProperty[]
203
+	 * @throws InvalidDataTypeException
204
+	 * @throws ReflectionException
205
+	 */
206
+	public function getProperties($class_name)
207
+	{
208
+		if (! isset($this->properties[ $class_name ])) {
209
+			$reflection_class                = $this->getReflectionClass($class_name);
210
+			$this->properties[ $class_name ] = $reflection_class->getProperties();
211
+		}
212
+		return $this->properties[ $class_name ];
213
+	}
214
+
215
+
216
+	/**
217
+	 * @param ReflectionClass $reflection_class
218
+	 * @return ReflectionProperty[]
219
+	 * @throws InvalidDataTypeException
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function getPropertiesFromReflection(ReflectionClass $reflection_class)
223
+	{
224
+		return $this->getProperties($reflection_class->getName());
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param string $class_name
230
+	 * @return ReflectionMethod[]
231
+	 * @throws InvalidDataTypeException
232
+	 * @throws ReflectionException
233
+	 */
234
+	public function getMethods($class_name)
235
+	{
236
+		if (! isset($this->methods[ $class_name ])) {
237
+			$reflection_class             = $this->getReflectionClass($class_name);
238
+			$this->methods[ $class_name ] = $reflection_class->getMethods();
239
+		}
240
+		return $this->methods[ $class_name ];
241
+	}
242
+
243
+
244
+	/**
245
+	 * @param ReflectionClass $reflection_class )
246
+	 * @return ReflectionMethod[]
247
+	 * @throws InvalidDataTypeException
248
+	 * @throws ReflectionException
249
+	 */
250
+	public function getMethodsFromReflection(ReflectionClass $reflection_class)
251
+	{
252
+		return $this->getMethods($reflection_class->getName());
253
+	}
254 254
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getReflectionClass($class_name)
62 62
     {
63
-        if (! is_string($class_name)) {
63
+        if ( ! is_string($class_name)) {
64 64
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65 65
         }
66
-        if (! isset($this->classes[ $class_name ])) {
67
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
66
+        if ( ! isset($this->classes[$class_name])) {
67
+            $this->classes[$class_name] = new ReflectionClass($class_name);
68 68
         }
69
-        return $this->classes[ $class_name ];
69
+        return $this->classes[$class_name];
70 70
     }
71 71
 
72 72
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function getConstructor($class_name)
80 80
     {
81
-        if (! is_string($class_name)) {
81
+        if ( ! is_string($class_name)) {
82 82
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83 83
         }
84
-        if (! isset($this->constructors[ $class_name ])) {
84
+        if ( ! isset($this->constructors[$class_name])) {
85 85
             $reflection_class                  = $this->getReflectionClass($class_name);
86
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
86
+            $this->constructors[$class_name] = $reflection_class->getConstructor();
87 87
         }
88
-        return $this->constructors[ $class_name ];
88
+        return $this->constructors[$class_name];
89 89
     }
90 90
 
91 91
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getParameters($class_name)
111 111
     {
112
-        if (! isset($this->parameters[ $class_name ])) {
112
+        if ( ! isset($this->parameters[$class_name])) {
113 113
             $constructor                     = $this->getConstructor($class_name);
114
-            $this->parameters[ $class_name ] = $constructor->getParameters();
114
+            $this->parameters[$class_name] = $constructor->getParameters();
115 115
         }
116
-        return $this->parameters[ $class_name ];
116
+        return $this->parameters[$class_name];
117 117
     }
118 118
 
119 119
 
@@ -149,27 +149,27 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151 151
     {
152
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
152
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) {
153
+            return $this->parameter_classes[$class_name][$index]['param_class_name'];
154 154
         }
155
-        if (! isset($this->parameter_classes[ $class_name ])) {
156
-            $this->parameter_classes[ $class_name ] = array();
155
+        if ( ! isset($this->parameter_classes[$class_name])) {
156
+            $this->parameter_classes[$class_name] = array();
157 157
         }
158
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
-            $this->parameter_classes[ $class_name ][ $index ] = array();
158
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
159
+            $this->parameter_classes[$class_name][$index] = array();
160 160
         }
161 161
         // ReflectionParameter::getClass() is deprecated in PHP 8+
162 162
         if (PHP_VERSION_ID >= 80000) {
163
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
163
+            $this->parameter_classes[$class_name][$index]['param_class_name'] =
164 164
                 $param->getType() instanceof ReflectionNamedType
165 165
                     ? $param->getType()->getName()
166 166
                     : null;
167 167
         } else {
168
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
168
+            $this->parameter_classes[$class_name][$index]['param_class_name'] = $param->getClass()
169 169
                     ? $param->getClass()->getName()
170 170
                     : null;
171 171
         }
172
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
172
+        return $this->parameter_classes[$class_name][$index]['param_class_name'];
173 173
     }
174 174
 
175 175
 
@@ -181,19 +181,19 @@  discard block
 block discarded – undo
181 181
      */
182 182
     public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
183 183
     {
184
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
185
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
184
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) {
185
+            return $this->parameter_classes[$class_name][$index]['param_class_default'];
186 186
         }
187
-        if (! isset($this->parameter_classes[ $class_name ])) {
188
-            $this->parameter_classes[ $class_name ] = array();
187
+        if ( ! isset($this->parameter_classes[$class_name])) {
188
+            $this->parameter_classes[$class_name] = array();
189 189
         }
190
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
191
-            $this->parameter_classes[ $class_name ][ $index ] = array();
190
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
191
+            $this->parameter_classes[$class_name][$index] = array();
192 192
         }
193
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
193
+        $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable()
194 194
             ? $param->getDefaultValue()
195 195
             : null;
196
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
196
+        return $this->parameter_classes[$class_name][$index]['param_class_default'];
197 197
     }
198 198
 
199 199
 
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function getProperties($class_name)
207 207
     {
208
-        if (! isset($this->properties[ $class_name ])) {
208
+        if ( ! isset($this->properties[$class_name])) {
209 209
             $reflection_class                = $this->getReflectionClass($class_name);
210
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
210
+            $this->properties[$class_name] = $reflection_class->getProperties();
211 211
         }
212
-        return $this->properties[ $class_name ];
212
+        return $this->properties[$class_name];
213 213
     }
214 214
 
215 215
 
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
      */
234 234
     public function getMethods($class_name)
235 235
     {
236
-        if (! isset($this->methods[ $class_name ])) {
236
+        if ( ! isset($this->methods[$class_name])) {
237 237
             $reflection_class             = $this->getReflectionClass($class_name);
238
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
238
+            $this->methods[$class_name] = $reflection_class->getMethods();
239 239
         }
240
-        return $this->methods[ $class_name ];
240
+        return $this->methods[$class_name];
241 241
     }
242 242
 
243 243
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4059 added lines, -4059 removed lines patch added patch discarded remove patch
@@ -17,4126 +17,4126 @@
 block discarded – undo
17 17
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    protected $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	protected $loader;
24 24
 
25
-    // set in _init_page_props()
26
-    public $page_slug;
25
+	// set in _init_page_props()
26
+	public $page_slug;
27 27
 
28
-    public $page_label;
28
+	public $page_label;
29 29
 
30
-    public $page_folder;
30
+	public $page_folder;
31 31
 
32
-    // set in define_page_props()
33
-    protected $_admin_base_url;
32
+	// set in define_page_props()
33
+	protected $_admin_base_url;
34 34
 
35
-    protected $_admin_base_path;
35
+	protected $_admin_base_path;
36 36
 
37
-    protected $_admin_page_title;
37
+	protected $_admin_page_title;
38 38
 
39
-    protected $_labels;
39
+	protected $_labels;
40 40
 
41 41
 
42
-    // set early within EE_Admin_Init
43
-    protected $_wp_page_slug;
42
+	// set early within EE_Admin_Init
43
+	protected $_wp_page_slug;
44 44
 
45
-    // navtabs
46
-    protected $_nav_tabs;
45
+	// navtabs
46
+	protected $_nav_tabs;
47 47
 
48
-    protected $_default_nav_tab_name;
48
+	protected $_default_nav_tab_name;
49 49
 
50
-    /**
51
-     * @var array $_help_tour
52
-     */
53
-    protected $_help_tour = array();
50
+	/**
51
+	 * @var array $_help_tour
52
+	 */
53
+	protected $_help_tour = array();
54 54
 
55 55
 
56
-    // template variables (used by templates)
57
-    protected $_template_path;
56
+	// template variables (used by templates)
57
+	protected $_template_path;
58 58
 
59
-    protected $_column_template_path;
59
+	protected $_column_template_path;
60 60
 
61
-    /**
62
-     * @var array $_template_args
63
-     */
64
-    protected $_template_args = array();
61
+	/**
62
+	 * @var array $_template_args
63
+	 */
64
+	protected $_template_args = array();
65 65
 
66
-    /**
67
-     * this will hold the list table object for a given view.
68
-     *
69
-     * @var EE_Admin_List_Table $_list_table_object
70
-     */
71
-    protected $_list_table_object;
66
+	/**
67
+	 * this will hold the list table object for a given view.
68
+	 *
69
+	 * @var EE_Admin_List_Table $_list_table_object
70
+	 */
71
+	protected $_list_table_object;
72 72
 
73
-    // bools
74
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
73
+	// bools
74
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
75 75
 
76
-    protected $_routing;
76
+	protected $_routing;
77 77
 
78
-    // list table args
79
-    protected $_view;
78
+	// list table args
79
+	protected $_view;
80 80
 
81
-    protected $_views;
81
+	protected $_views;
82 82
 
83 83
 
84
-    // action => method pairs used for routing incoming requests
85
-    protected $_page_routes;
84
+	// action => method pairs used for routing incoming requests
85
+	protected $_page_routes;
86 86
 
87
-    /**
88
-     * @var array $_page_config
89
-     */
90
-    protected $_page_config;
87
+	/**
88
+	 * @var array $_page_config
89
+	 */
90
+	protected $_page_config;
91 91
 
92
-    /**
93
-     * the current page route and route config
94
-     *
95
-     * @var string $_route
96
-     */
97
-    protected $_route;
92
+	/**
93
+	 * the current page route and route config
94
+	 *
95
+	 * @var string $_route
96
+	 */
97
+	protected $_route;
98 98
 
99
-    /**
100
-     * @var string $_cpt_route
101
-     */
102
-    protected $_cpt_route;
99
+	/**
100
+	 * @var string $_cpt_route
101
+	 */
102
+	protected $_cpt_route;
103 103
 
104
-    /**
105
-     * @var array $_route_config
106
-     */
107
-    protected $_route_config;
108
-
109
-    /**
110
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
-     * actions.
112
-     *
113
-     * @since 4.6.x
114
-     * @var array.
115
-     */
116
-    protected $_default_route_query_args;
117
-
118
-    // set via request page and action args.
119
-    protected $_current_page;
120
-
121
-    protected $_current_view;
122
-
123
-    protected $_current_page_view_url;
124
-
125
-    // sanitized request action (and nonce)
126
-
127
-    /**
128
-     * @var string $_req_action
129
-     */
130
-    protected $_req_action;
131
-
132
-    /**
133
-     * @var string $_req_nonce
134
-     */
135
-    protected $_req_nonce;
136
-
137
-    // search related
138
-    protected $_search_btn_label;
139
-
140
-    protected $_search_box_callback;
141
-
142
-    /**
143
-     * WP Current Screen object
144
-     *
145
-     * @var WP_Screen
146
-     */
147
-    protected $_current_screen;
148
-
149
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
-    protected $_hook_obj;
151
-
152
-    // for holding incoming request data
153
-    protected $_req_data = [];
154
-
155
-    // yes / no array for admin form fields
156
-    protected $_yes_no_values = array();
157
-
158
-    // some default things shared by all child classes
159
-    protected $_default_espresso_metaboxes;
160
-
161
-    /**
162
-     *    EE_Registry Object
163
-     *
164
-     * @var    EE_Registry
165
-     */
166
-    protected $EE = null;
167
-
168
-
169
-    /**
170
-     * This is just a property that flags whether the given route is a caffeinated route or not.
171
-     *
172
-     * @var boolean
173
-     */
174
-    protected $_is_caf = false;
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws ReflectionException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function __construct($routing = true)
187
-    {
188
-        $this->loader = LoaderFactory::getLoader();
189
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
-            $this->_is_caf = true;
191
-        }
192
-        $this->_yes_no_values = array(
193
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
-        );
196
-        // set the _req_data property.
197
-        $this->_req_data = array_merge($_GET, $_POST);
198
-        // routing enabled?
199
-        $this->_routing = $routing;
200
-        // set initial page props (child method)
201
-        $this->_init_page_props();
202
-        // set global defaults
203
-        $this->_set_defaults();
204
-        // set early because incoming requests could be ajax related and we need to register those hooks.
205
-        $this->_global_ajax_hooks();
206
-        $this->_ajax_hooks();
207
-        // other_page_hooks have to be early too.
208
-        $this->_do_other_page_hooks();
209
-        // This just allows us to have extending classes do something specific
210
-        // before the parent constructor runs _page_setup().
211
-        if (method_exists($this, '_before_page_setup')) {
212
-            $this->_before_page_setup();
213
-        }
214
-        // set up page dependencies
215
-        $this->_page_setup();
216
-    }
217
-
218
-
219
-    /**
220
-     * _init_page_props
221
-     * Child classes use to set at least the following properties:
222
-     * $page_slug.
223
-     * $page_label.
224
-     *
225
-     * @abstract
226
-     * @return void
227
-     */
228
-    abstract protected function _init_page_props();
229
-
230
-
231
-    /**
232
-     * _ajax_hooks
233
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
-     * Note: within the ajax callback methods.
235
-     *
236
-     * @abstract
237
-     * @return void
238
-     */
239
-    abstract protected function _ajax_hooks();
240
-
241
-
242
-    /**
243
-     * _define_page_props
244
-     * child classes define page properties in here.  Must include at least:
245
-     * $_admin_base_url = base_url for all admin pages
246
-     * $_admin_page_title = default admin_page_title for admin pages
247
-     * $_labels = array of default labels for various automatically generated elements:
248
-     *    array(
249
-     *        'buttons' => array(
250
-     *            'add' => esc_html__('label for add new button'),
251
-     *            'edit' => esc_html__('label for edit button'),
252
-     *            'delete' => esc_html__('label for delete button')
253
-     *            )
254
-     *        )
255
-     *
256
-     * @abstract
257
-     * @return void
258
-     */
259
-    abstract protected function _define_page_props();
260
-
261
-
262
-    /**
263
-     * _set_page_routes
264
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
-     * have a 'default' route. Here's the format
267
-     * $this->_page_routes = array(
268
-     *        'default' => array(
269
-     *            'func' => '_default_method_handling_route',
270
-     *            'args' => array('array','of','args'),
271
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
-     *            ajax request, backend processing)
273
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
-     *            headers route after.  The string you enter here should match the defined route reference for a
275
-     *            headers sent route.
276
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
-     *            this route.
278
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
-     *            checks).
280
-     *        ),
281
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
-     *        handling method.
283
-     *        )
284
-     * )
285
-     *
286
-     * @abstract
287
-     * @return void
288
-     */
289
-    abstract protected function _set_page_routes();
290
-
291
-
292
-    /**
293
-     * _set_page_config
294
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
-     * array corresponds to the page_route for the loaded page. Format:
296
-     * $this->_page_config = array(
297
-     *        'default' => array(
298
-     *            'labels' => array(
299
-     *                'buttons' => array(
300
-     *                    'add' => esc_html__('label for adding item'),
301
-     *                    'edit' => esc_html__('label for editing item'),
302
-     *                    'delete' => esc_html__('label for deleting item')
303
-     *                ),
304
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
-     *            _define_page_props() method
308
-     *            'nav' => array(
309
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
-     *                'order' => 10, //required to indicate tab position.
313
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
-     *                displayed then add this parameter.
315
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
-     *            metaboxes set for eventespresso admin pages.
318
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
-     *            want to display.
327
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
328
-     *                'tab_id' => array(
329
-     *                    'title' => 'tab_title',
330
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
-     *                    attempt to use the callback which should match the name of a method in the class
336
-     *                    ),
337
-     *                'tab2_id' => array(
338
-     *                    'title' => 'tab2 title',
339
-     *                    'filename' => 'file_name_2'
340
-     *                    'callback' => 'callback_method_for_content',
341
-     *                 ),
342
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
-     *            help tab area on an admin page. @link
344
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
-     *            'help_tour' => array(
346
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
-     *            ),
350
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
-     *            just set
353
-     *            'require_nonce' to FALSE
354
-     *            )
355
-     * )
356
-     *
357
-     * @abstract
358
-     * @return void
359
-     */
360
-    abstract protected function _set_page_config();
361
-
362
-
363
-
364
-
365
-
366
-    /** end sample help_tour methods **/
367
-    /**
368
-     * _add_screen_options
369
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
-     * to a particular view.
372
-     *
373
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
-     *         see also WP_Screen object documents...
375
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
-     * @abstract
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-    /**
383
-     * _add_feature_pointers
384
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
-     * extended) also see:
389
-     *
390
-     * @link   http://eamann.com/tech/wordpress-portland/
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _add_feature_pointers();
395
-
396
-
397
-    /**
398
-     * load_scripts_styles
399
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
-     * scripts/styles per view by putting them in a dynamic function in this format
402
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
-     *
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract public function load_scripts_styles();
408
-
409
-
410
-    /**
411
-     * admin_init
412
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
-     * all pages/views loaded by child class.
414
-     *
415
-     * @abstract
416
-     * @return void
417
-     */
418
-    abstract public function admin_init();
419
-
420
-
421
-    /**
422
-     * admin_notices
423
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
-     * all pages/views loaded by child class.
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function admin_notices();
430
-
431
-
432
-    /**
433
-     * admin_footer_scripts
434
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
-     * will apply to all pages/views loaded by child class.
436
-     *
437
-     * @return void
438
-     */
439
-    abstract public function admin_footer_scripts();
440
-
441
-
442
-    /**
443
-     * admin_footer
444
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
-     * apply to all pages/views loaded by child class.
446
-     *
447
-     * @return void
448
-     */
449
-    public function admin_footer()
450
-    {
451
-    }
452
-
453
-
454
-    /**
455
-     * _global_ajax_hooks
456
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
-     * Note: within the ajax callback methods.
458
-     *
459
-     * @abstract
460
-     * @return void
461
-     */
462
-    protected function _global_ajax_hooks()
463
-    {
464
-        // for lazy loading of metabox content
465
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
-    }
467
-
468
-
469
-    public function ajax_metabox_content()
470
-    {
471
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
-        self::cached_rss_display($contentid, $url);
474
-        wp_die();
475
-    }
476
-
477
-
478
-    /**
479
-     * _page_setup
480
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
-     * doesn't match the object.
482
-     *
483
-     * @final
484
-     * @return void
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws ReflectionException
488
-     * @throws InvalidDataTypeException
489
-     * @throws InvalidInterfaceException
490
-     */
491
-    final protected function _page_setup()
492
-    {
493
-        // requires?
494
-        // admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
496
-        // next verify if we need to load anything...
497
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
-        $this->page_folder = strtolower(
499
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
-        );
501
-        global $ee_menu_slugs;
502
-        $ee_menu_slugs = (array) $ee_menu_slugs;
503
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
-            return;
505
-        }
506
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
-                ? $this->_req_data['action2']
510
-                : $this->_req_data['action'];
511
-        }
512
-        // then set blank or -1 action values to 'default'
513
-        $this->_req_action = isset($this->_req_data['action'])
514
-                             && ! empty($this->_req_data['action'])
515
-                             && $this->_req_data['action'] !== '-1'
516
-            ? sanitize_key($this->_req_data['action'])
517
-            : 'default';
518
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
520
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
-            ? $this->_req_data['route'] : $this->_req_action;
522
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
-            ? $this->_req_data['route']
525
-            : $this->_req_action;
526
-        $this->_current_view = $this->_req_action;
527
-        $this->_req_nonce = $this->_req_action . '_nonce';
528
-        $this->_define_page_props();
529
-        $this->_current_page_view_url = add_query_arg(
530
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
531
-            $this->_admin_base_url
532
-        );
533
-        // default things
534
-        $this->_default_espresso_metaboxes = array(
535
-            '_espresso_news_post_box',
536
-            '_espresso_links_post_box',
537
-            '_espresso_ratings_request',
538
-            '_espresso_sponsors_post_box',
539
-        );
540
-        // set page configs
541
-        $this->_set_page_routes();
542
-        $this->_set_page_config();
543
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
544
-        if (isset($this->_req_data['wp_referer'])) {
545
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
-        }
547
-        // for caffeinated and other extended functionality.
548
-        //  If there is a _extend_page_config method
549
-        // then let's run that to modify the all the various page configuration arrays
550
-        if (method_exists($this, '_extend_page_config')) {
551
-            $this->_extend_page_config();
552
-        }
553
-        // for CPT and other extended functionality.
554
-        // If there is an _extend_page_config_for_cpt
555
-        // then let's run that to modify all the various page configuration arrays.
556
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
557
-            $this->_extend_page_config_for_cpt();
558
-        }
559
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
560
-        $this->_page_routes = apply_filters(
561
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
-            $this->_page_routes,
563
-            $this
564
-        );
565
-        $this->_page_config = apply_filters(
566
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
567
-            $this->_page_config,
568
-            $this
569
-        );
570
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
-            add_action(
574
-                'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
-                10,
577
-                2
578
-            );
579
-        }
580
-        // next route only if routing enabled
581
-        if ($this->_routing && ! defined('DOING_AJAX')) {
582
-            $this->_verify_routes();
583
-            // next let's just check user_access and kill if no access
584
-            $this->check_user_access();
585
-            if ($this->_is_UI_request) {
586
-                // admin_init stuff - global, all views for this page class, specific view
587
-                add_action('admin_init', array($this, 'admin_init'), 10);
588
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
-                }
591
-            } else {
592
-                // hijack regular WP loading and route admin request immediately
593
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
-                $this->route_admin_request();
595
-            }
596
-        }
597
-    }
598
-
599
-
600
-    /**
601
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
-     *
603
-     * @return void
604
-     * @throws ReflectionException
605
-     * @throws EE_Error
606
-     */
607
-    private function _do_other_page_hooks()
608
-    {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
-        foreach ($registered_pages as $page) {
611
-            // now let's setup the file name and class that should be present
612
-            $classname = str_replace('.class.php', '', $page);
613
-            // autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
615
-                $error_msg[] = sprintf(
616
-                    esc_html__(
617
-                        'Something went wrong with loading the %s admin hooks page.',
618
-                        'event_espresso'
619
-                    ),
620
-                    $page
621
-                );
622
-                $error_msg[] = $error_msg[0]
623
-                               . "\r\n"
624
-                               . sprintf(
625
-                                   esc_html__(
626
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
627
-                                       'event_espresso'
628
-                                   ),
629
-                                   $page,
630
-                                   '<br />',
631
-                                   '<strong>' . $classname . '</strong>'
632
-                               );
633
-                throw new EE_Error(implode('||', $error_msg));
634
-            }
635
-            $a = new ReflectionClass($classname);
636
-            // notice we are passing the instance of this class to the hook object.
637
-            $hookobj[] = $a->newInstance($this);
638
-        }
639
-    }
640
-
641
-
642
-    public function load_page_dependencies()
643
-    {
644
-        try {
645
-            $this->_load_page_dependencies();
646
-        } catch (EE_Error $e) {
647
-            $e->get_error();
648
-        }
649
-    }
650
-
651
-
652
-    /**
653
-     * load_page_dependencies
654
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
-     *
656
-     * @return void
657
-     * @throws DomainException
658
-     * @throws EE_Error
659
-     * @throws InvalidArgumentException
660
-     * @throws InvalidDataTypeException
661
-     * @throws InvalidInterfaceException
662
-     * @throws ReflectionException
663
-     */
664
-    protected function _load_page_dependencies()
665
-    {
666
-        // let's set the current_screen and screen options to override what WP set
667
-        $this->_current_screen = get_current_screen();
668
-        // load admin_notices - global, page class, and view specific
669
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
671
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
-        }
674
-        // load network admin_notices - global, page class, and view specific
675
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
-        }
679
-        // this will save any per_page screen options if they are present
680
-        $this->_set_per_page_screen_options();
681
-        // setup list table properties
682
-        $this->_set_list_table();
683
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
-        // However in some cases the metaboxes will need to be added within a route handling callback.
685
-        $this->_add_registered_meta_boxes();
686
-        $this->_add_screen_columns();
687
-        // add screen options - global, page child class, and view specific
688
-        $this->_add_global_screen_options();
689
-        $this->_add_screen_options();
690
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
691
-        if (method_exists($this, $add_screen_options)) {
692
-            $this->{$add_screen_options}();
693
-        }
694
-        // add help tab(s) and tours- set via page_config and qtips.
695
-        // $this->_add_help_tour();
696
-        $this->_add_help_tabs();
697
-        $this->_add_qtips();
698
-        // add feature_pointers - global, page child class, and view specific
699
-        $this->_add_feature_pointers();
700
-        $this->_add_global_feature_pointers();
701
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
-        if (method_exists($this, $add_feature_pointer)) {
703
-            $this->{$add_feature_pointer}();
704
-        }
705
-        // enqueue scripts/styles - global, page class, and view specific
706
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
-        }
711
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
-        // admin_print_footer_scripts - global, page child class, and view specific.
713
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
-        // is a good use case. Notice the late priority we're giving these
716
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
-        }
721
-        // admin footer scripts
722
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
724
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
-        }
727
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
-        // targeted hook
729
-        do_action(
730
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
-        );
732
-    }
733
-
734
-
735
-    /**
736
-     * _set_defaults
737
-     * This sets some global defaults for class properties.
738
-     */
739
-    private function _set_defaults()
740
-    {
741
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
743
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
-        $this->_page_config = $this->_default_route_query_args = array();
745
-        $this->_default_nav_tab_name = 'overview';
746
-        // init template args
747
-        $this->_template_args = array(
748
-            'admin_page_header'  => '',
749
-            'admin_page_content' => '',
750
-            'post_body_content'  => '',
751
-            'before_list_table'  => '',
752
-            'after_list_table'   => '',
753
-        );
754
-    }
755
-
756
-
757
-    /**
758
-     * route_admin_request
759
-     *
760
-     * @see    _route_admin_request()
761
-     * @return exception|void error
762
-     * @throws InvalidArgumentException
763
-     * @throws InvalidInterfaceException
764
-     * @throws InvalidDataTypeException
765
-     * @throws EE_Error
766
-     * @throws ReflectionException
767
-     */
768
-    public function route_admin_request()
769
-    {
770
-        try {
771
-            $this->_route_admin_request();
772
-        } catch (EE_Error $e) {
773
-            $e->get_error();
774
-        }
775
-    }
776
-
777
-
778
-    public function set_wp_page_slug($wp_page_slug)
779
-    {
780
-        $this->_wp_page_slug = $wp_page_slug;
781
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
-        if (is_network_admin()) {
783
-            $this->_wp_page_slug .= '-network';
784
-        }
785
-    }
786
-
787
-
788
-    /**
789
-     * _verify_routes
790
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
-     * we know if we need to drop out.
792
-     *
793
-     * @return bool
794
-     * @throws EE_Error
795
-     */
796
-    protected function _verify_routes()
797
-    {
798
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
-            return false;
801
-        }
802
-        $this->_route = false;
803
-        // check that the page_routes array is not empty
804
-        if (empty($this->_page_routes)) {
805
-            // user error msg
806
-            $error_msg = sprintf(
807
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
-                $this->_admin_page_title
809
-            );
810
-            // developer error msg
811
-            $error_msg .= '||' . $error_msg
812
-                          . esc_html__(
813
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
-                              'event_espresso'
815
-                          );
816
-            throw new EE_Error($error_msg);
817
-        }
818
-        // and that the requested page route exists
819
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
-            $this->_route = $this->_page_routes[ $this->_req_action ];
821
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
-                ? $this->_page_config[ $this->_req_action ] : array();
823
-        } else {
824
-            // user error msg
825
-            $error_msg = sprintf(
826
-                esc_html__(
827
-                    'The requested page route does not exist for the %s admin page.',
828
-                    'event_espresso'
829
-                ),
830
-                $this->_admin_page_title
831
-            );
832
-            // developer error msg
833
-            $error_msg .= '||' . $error_msg
834
-                          . sprintf(
835
-                              esc_html__(
836
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
-                                  'event_espresso'
838
-                              ),
839
-                              $this->_req_action
840
-                          );
841
-            throw new EE_Error($error_msg);
842
-        }
843
-        // and that a default route exists
844
-        if (! array_key_exists('default', $this->_page_routes)) {
845
-            // user error msg
846
-            $error_msg = sprintf(
847
-                esc_html__(
848
-                    'A default page route has not been set for the % admin page.',
849
-                    'event_espresso'
850
-                ),
851
-                $this->_admin_page_title
852
-            );
853
-            // developer error msg
854
-            $error_msg .= '||' . $error_msg
855
-                          . esc_html__(
856
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
-                              'event_espresso'
858
-                          );
859
-            throw new EE_Error($error_msg);
860
-        }
861
-        // first lets' catch if the UI request has EVER been set.
862
-        if ($this->_is_UI_request === null) {
863
-            // lets set if this is a UI request or not.
864
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
-            // wait a minute... we might have a noheader in the route array
866
-            $this->_is_UI_request = is_array($this->_route)
867
-                                    && isset($this->_route['noheader'])
868
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
869
-        }
870
-        $this->_set_current_labels();
871
-        return true;
872
-    }
873
-
874
-
875
-    /**
876
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
-     *
878
-     * @param  string $route the route name we're verifying
879
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
-     * @throws EE_Error
881
-     */
882
-    protected function _verify_route($route)
883
-    {
884
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
-            return true;
886
-        }
887
-        // user error msg
888
-        $error_msg = sprintf(
889
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
-            $this->_admin_page_title
891
-        );
892
-        // developer error msg
893
-        $error_msg .= '||' . $error_msg
894
-                      . sprintf(
895
-                          esc_html__(
896
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
-                              'event_espresso'
898
-                          ),
899
-                          $route
900
-                      );
901
-        throw new EE_Error($error_msg);
902
-    }
903
-
904
-
905
-    /**
906
-     * perform nonce verification
907
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
-     * using this method (and save retyping!)
909
-     *
910
-     * @param  string $nonce     The nonce sent
911
-     * @param  string $nonce_ref The nonce reference string (name0)
912
-     * @return void
913
-     * @throws EE_Error
914
-     */
915
-    protected function _verify_nonce($nonce, $nonce_ref)
916
-    {
917
-        // verify nonce against expected value
918
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
-            // these are not the droids you are looking for !!!
920
-            $msg = sprintf(
921
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
-                '</a>'
924
-            );
925
-            if (WP_DEBUG) {
926
-                $msg .= "\n  "
927
-                        . sprintf(
928
-                            esc_html__(
929
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
-                                'event_espresso'
931
-                            ),
932
-                            __CLASS__
933
-                        );
934
-            }
935
-            if (! defined('DOING_AJAX')) {
936
-                wp_die($msg);
937
-            } else {
938
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
-                $this->_return_json();
940
-            }
941
-        }
942
-    }
943
-
944
-
945
-    /**
946
-     * _route_admin_request()
947
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
-     * in the page routes and then will try to load the corresponding method.
950
-     *
951
-     * @return void
952
-     * @throws EE_Error
953
-     * @throws InvalidArgumentException
954
-     * @throws InvalidDataTypeException
955
-     * @throws InvalidInterfaceException
956
-     * @throws ReflectionException
957
-     */
958
-    protected function _route_admin_request()
959
-    {
960
-        if (! $this->_is_UI_request) {
961
-            $this->_verify_routes();
962
-        }
963
-        $nonce_check = isset($this->_route_config['require_nonce'])
964
-            ? $this->_route_config['require_nonce']
965
-            : true;
966
-        if ($this->_req_action !== 'default' && $nonce_check) {
967
-            // set nonce from post data
968
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
969
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
-                : '';
971
-            $this->_verify_nonce($nonce, $this->_req_nonce);
972
-        }
973
-        // set the nav_tabs array but ONLY if this is  UI_request
974
-        if ($this->_is_UI_request) {
975
-            $this->_set_nav_tabs();
976
-        }
977
-        // grab callback function
978
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
-        // check if callback has args
980
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
-        $error_msg = '';
982
-        // action right before calling route
983
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
-        }
987
-        // right before calling the route, let's remove _wp_http_referer from the
988
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
990
-            '_wp_http_referer',
991
-            wp_unslash($_SERVER['REQUEST_URI'])
992
-        );
993
-        if (! empty($func)) {
994
-            if (is_array($func)) {
995
-                list($class, $method) = $func;
996
-            } elseif (strpos($func, '::') !== false) {
997
-                list($class, $method) = explode('::', $func);
998
-            } else {
999
-                $class = $this;
1000
-                $method = $func;
1001
-            }
1002
-            if (! (is_object($class) && $class === $this)) {
1003
-                // send along this admin page object for access by addons.
1004
-                $args['admin_page_object'] = $this;
1005
-            }
1006
-            if (// is it a method on a class that doesn't work?
1007
-                (
1008
-                    (
1009
-                        method_exists($class, $method)
1010
-                        && call_user_func_array(array($class, $method), $args) === false
1011
-                    )
1012
-                    && (
1013
-                        // is it a standalone function that doesn't work?
1014
-                        function_exists($method)
1015
-                        && call_user_func_array(
1016
-                            $func,
1017
-                            array_merge(array('admin_page_object' => $this), $args)
1018
-                        ) === false
1019
-                    )
1020
-                )
1021
-                || (
1022
-                    // is it neither a class method NOR a standalone function?
1023
-                    ! method_exists($class, $method)
1024
-                    && ! function_exists($method)
1025
-                )
1026
-            ) {
1027
-                // user error msg
1028
-                $error_msg = esc_html__(
1029
-                    'An error occurred. The  requested page route could not be found.',
1030
-                    'event_espresso'
1031
-                );
1032
-                // developer error msg
1033
-                $error_msg .= '||';
1034
-                $error_msg .= sprintf(
1035
-                    esc_html__(
1036
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
-                        'event_espresso'
1038
-                    ),
1039
-                    $method
1040
-                );
1041
-            }
1042
-            if (! empty($error_msg)) {
1043
-                throw new EE_Error($error_msg);
1044
-            }
1045
-        }
1046
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1047
-        // then we need to reset the routing properties to the new route.
1048
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1049
-        if ($this->_is_UI_request === false
1050
-            && is_array($this->_route)
1051
-            && ! empty($this->_route['headers_sent_route'])
1052
-        ) {
1053
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
-        }
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * This method just allows the resetting of page properties in the case where a no headers
1060
-     * route redirects to a headers route in its route config.
1061
-     *
1062
-     * @since   4.3.0
1063
-     * @param  string $new_route New (non header) route to redirect to.
1064
-     * @return   void
1065
-     * @throws ReflectionException
1066
-     * @throws InvalidArgumentException
1067
-     * @throws InvalidInterfaceException
1068
-     * @throws InvalidDataTypeException
1069
-     * @throws EE_Error
1070
-     */
1071
-    protected function _reset_routing_properties($new_route)
1072
-    {
1073
-        $this->_is_UI_request = true;
1074
-        // now we set the current route to whatever the headers_sent_route is set at
1075
-        $this->_req_data['action'] = $new_route;
1076
-        // rerun page setup
1077
-        $this->_page_setup();
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * _add_query_arg
1083
-     * adds nonce to array of arguments then calls WP add_query_arg function
1084
-     *(internally just uses EEH_URL's function with the same name)
1085
-     *
1086
-     * @param array  $args
1087
-     * @param string $url
1088
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
-     *                                        Example usage: If the current page is:
1091
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
-     *                                        &action=default&event_id=20&month_range=March%202015
1093
-     *                                        &_wpnonce=5467821
1094
-     *                                        and you call:
1095
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
-     *                                        array(
1097
-     *                                        'action' => 'resend_something',
1098
-     *                                        'page=>espresso_registrations'
1099
-     *                                        ),
1100
-     *                                        $some_url,
1101
-     *                                        true
1102
-     *                                        );
1103
-     *                                        It will produce a url in this structure:
1104
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
-     *                                        month_range]=March%202015
1107
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
-     * @return string
1109
-     */
1110
-    public static function add_query_args_and_nonce(
1111
-        $args = array(),
1112
-        $url = false,
1113
-        $sticky = false,
1114
-        $exclude_nonce = false
1115
-    ) {
1116
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
-        if ($sticky) {
1118
-            $request = $_REQUEST;
1119
-            unset($request['_wp_http_referer']);
1120
-            unset($request['wp_referer']);
1121
-            foreach ($request as $key => $value) {
1122
-                // do not add nonces
1123
-                if (strpos($key, 'nonce') !== false) {
1124
-                    continue;
1125
-                }
1126
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1127
-            }
1128
-        }
1129
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * This returns a generated link that will load the related help tab.
1135
-     *
1136
-     * @param  string $help_tab_id the id for the connected help tab
1137
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
-     * @uses EEH_Template::get_help_tab_link()
1140
-     * @return string              generated link
1141
-     */
1142
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
-    {
1144
-        return EEH_Template::get_help_tab_link(
1145
-            $help_tab_id,
1146
-            $this->page_slug,
1147
-            $this->_req_action,
1148
-            $icon_style,
1149
-            $help_text
1150
-        );
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * _add_help_tabs
1156
-     * Note child classes define their help tabs within the page_config array.
1157
-     *
1158
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
-     * @return void
1160
-     * @throws DomainException
1161
-     * @throws EE_Error
1162
-     */
1163
-    protected function _add_help_tabs()
1164
-    {
1165
-        $tour_buttons = '';
1166
-        if (isset($this->_page_config[ $this->_req_action ])) {
1167
-            $config = $this->_page_config[ $this->_req_action ];
1168
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1169
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1170
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1171
-            //     $tb = array();
1172
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1173
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1174
-            //         // if this is the end tour then we don't need to setup a button
1175
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1176
-            //             continue;
1177
-            //         }
1178
-            //         $tb[] = '<button id="trigger-tour-'
1179
-            //                 . $tour->get_slug()
1180
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1181
-            //                 . $tour->get_label()
1182
-            //                 . '</button>';
1183
-            //     }
1184
-            //     $tour_buttons .= implode('<br />', $tb);
1185
-            //     $tour_buttons .= '</div></div>';
1186
-            // }
1187
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1188
-            if (is_array($config) && isset($config['help_sidebar'])) {
1189
-                // check that the callback given is valid
1190
-                if (! method_exists($this, $config['help_sidebar'])) {
1191
-                    throw new EE_Error(
1192
-                        sprintf(
1193
-                            esc_html__(
1194
-                                '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',
1195
-                                'event_espresso'
1196
-                            ),
1197
-                            $config['help_sidebar'],
1198
-                            get_class($this)
1199
-                        )
1200
-                    );
1201
-                }
1202
-                $content = apply_filters(
1203
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1204
-                    $this->{$config['help_sidebar']}()
1205
-                );
1206
-                $content .= $tour_buttons; // add help tour buttons.
1207
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1208
-                $this->_current_screen->set_help_sidebar($content);
1209
-            }
1210
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1211
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1212
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1213
-            }
1214
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1215
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1216
-                $_ht['id'] = $this->page_slug;
1217
-                $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1218
-                $_ht['content'] = '<p>'
1219
-                                  . esc_html__(
1220
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1221
-                                      'event_espresso'
1222
-                                  ) . '</p>';
1223
-                $this->_current_screen->add_help_tab($_ht);
1224
-            }
1225
-            if (! isset($config['help_tabs'])) {
1226
-                return;
1227
-            } //no help tabs for this route
1228
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1229
-                // we're here so there ARE help tabs!
1230
-                // make sure we've got what we need
1231
-                if (! isset($cfg['title'])) {
1232
-                    throw new EE_Error(
1233
-                        esc_html__(
1234
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1235
-                            'event_espresso'
1236
-                        )
1237
-                    );
1238
-                }
1239
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1240
-                    throw new EE_Error(
1241
-                        esc_html__(
1242
-                            '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',
1243
-                            'event_espresso'
1244
-                        )
1245
-                    );
1246
-                }
1247
-                // first priority goes to content.
1248
-                if (! empty($cfg['content'])) {
1249
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1250
-                    // second priority goes to filename
1251
-                } elseif (! empty($cfg['filename'])) {
1252
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1253
-                    // 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)
1254
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1255
-                                                             . basename($this->_get_dir())
1256
-                                                             . '/help_tabs/'
1257
-                                                             . $cfg['filename']
1258
-                                                             . '.help_tab.php' : $file_path;
1259
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1260
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1261
-                        EE_Error::add_error(
1262
-                            sprintf(
1263
-                                esc_html__(
1264
-                                    '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',
1265
-                                    'event_espresso'
1266
-                                ),
1267
-                                $tab_id,
1268
-                                key($config),
1269
-                                $file_path
1270
-                            ),
1271
-                            __FILE__,
1272
-                            __FUNCTION__,
1273
-                            __LINE__
1274
-                        );
1275
-                        return;
1276
-                    }
1277
-                    $template_args['admin_page_obj'] = $this;
1278
-                    $content = EEH_Template::display_template(
1279
-                        $file_path,
1280
-                        $template_args,
1281
-                        true
1282
-                    );
1283
-                } else {
1284
-                    $content = '';
1285
-                }
1286
-                // check if callback is valid
1287
-                if (empty($content) && (
1288
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1289
-                    )
1290
-                ) {
1291
-                    EE_Error::add_error(
1292
-                        sprintf(
1293
-                            esc_html__(
1294
-                                '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.',
1295
-                                'event_espresso'
1296
-                            ),
1297
-                            $cfg['title']
1298
-                        ),
1299
-                        __FILE__,
1300
-                        __FUNCTION__,
1301
-                        __LINE__
1302
-                    );
1303
-                    return;
1304
-                }
1305
-                // setup config array for help tab method
1306
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1307
-                $_ht = array(
1308
-                    'id'       => $id,
1309
-                    'title'    => $cfg['title'],
1310
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1311
-                    'content'  => $content,
1312
-                );
1313
-                $this->_current_screen->add_help_tab($_ht);
1314
-            }
1315
-        }
1316
-    }
1317
-
1318
-
1319
-    /**
1320
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1321
-     * an array with properties for setting up usage of the joyride plugin
1322
-     *
1323
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1324
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1325
-     *         _set_page_config() comments
1326
-     * @return void
1327
-     * @throws EE_Error
1328
-     * @throws InvalidArgumentException
1329
-     * @throws InvalidDataTypeException
1330
-     * @throws InvalidInterfaceException
1331
-     */
1332
-    protected function _add_help_tour()
1333
-    {
1334
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1335
-        // $tours = array();
1336
-        // $this->_help_tour = array();
1337
-        // // exit early if help tours are turned off globally
1338
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1339
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1340
-        // ) {
1341
-        //     return;
1342
-        // }
1343
-        // // loop through _page_config to find any help_tour defined
1344
-        // foreach ($this->_page_config as $route => $config) {
1345
-        //     // we're only going to set things up for this route
1346
-        //     if ($route !== $this->_req_action) {
1347
-        //         continue;
1348
-        //     }
1349
-        //     if (isset($config['help_tour'])) {
1350
-        //         foreach ($config['help_tour'] as $tour) {
1351
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1352
-        //             // let's see if we can get that file...
1353
-        //             // if not its possible this is a decaf route not set in caffeinated
1354
-        //             // so lets try and get the caffeinated equivalent
1355
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1356
-        //                                                      . basename($this->_get_dir())
1357
-        //                                                      . '/help_tours/'
1358
-        //                                                      . $tour
1359
-        //                                                      . '.class.php' : $file_path;
1360
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1361
-        //             if (! is_readable($file_path)) {
1362
-        //                 EE_Error::add_error(
1363
-        //                     sprintf(
1364
-        //                         esc_html__(
1365
-        //                             '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',
1366
-        //                             'event_espresso'
1367
-        //                         ),
1368
-        //                         $file_path,
1369
-        //                         $tour
1370
-        //                     ),
1371
-        //                     __FILE__,
1372
-        //                     __FUNCTION__,
1373
-        //                     __LINE__
1374
-        //                 );
1375
-        //                 return;
1376
-        //             }
1377
-        //             require_once $file_path;
1378
-        //             if (! class_exists($tour)) {
1379
-        //                 $error_msg[] = sprintf(
1380
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1381
-        //                     $tour
1382
-        //                 );
1383
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1384
-        //                                . sprintf(
1385
-        //                                    esc_html__(
1386
-        //                                        '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.',
1387
-        //                                        'event_espresso'
1388
-        //                                    ),
1389
-        //                                    $tour,
1390
-        //                                    '<br />',
1391
-        //                                    $tour,
1392
-        //                                    $this->_req_action,
1393
-        //                                    get_class($this)
1394
-        //                                );
1395
-        //                 throw new EE_Error(implode('||', $error_msg));
1396
-        //             }
1397
-        //             $tour_obj = new $tour($this->_is_caf);
1398
-        //             $tours[] = $tour_obj;
1399
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1400
-        //         }
1401
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1402
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1403
-        //         $tours[] = $end_stop_tour;
1404
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1405
-        //     }
1406
-        // }
1407
-        //
1408
-        // if (! empty($tours)) {
1409
-        //     $this->_help_tour['tours'] = $tours;
1410
-        // }
1411
-        // // that's it!  Now that the $_help_tours property is set (or not)
1412
-        // // the scripts and html should be taken care of automatically.
1413
-        //
1414
-        // /**
1415
-        //  * Allow extending the help tours variable.
1416
-        //  *
1417
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1418
-        //  */
1419
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1420
-    }
1421
-
1422
-
1423
-    /**
1424
-     * This simply sets up any qtips that have been defined in the page config
1425
-     *
1426
-     * @return void
1427
-     */
1428
-    protected function _add_qtips()
1429
-    {
1430
-        if (isset($this->_route_config['qtips'])) {
1431
-            $qtips = (array) $this->_route_config['qtips'];
1432
-            // load qtip loader
1433
-            $path = array(
1434
-                $this->_get_dir() . '/qtips/',
1435
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1436
-            );
1437
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1438
-        }
1439
-    }
1440
-
1441
-
1442
-    /**
1443
-     * _set_nav_tabs
1444
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1445
-     * wish to add additional tabs or modify accordingly.
1446
-     *
1447
-     * @return void
1448
-     * @throws InvalidArgumentException
1449
-     * @throws InvalidInterfaceException
1450
-     * @throws InvalidDataTypeException
1451
-     */
1452
-    protected function _set_nav_tabs()
1453
-    {
1454
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1455
-        $i = 0;
1456
-        foreach ($this->_page_config as $slug => $config) {
1457
-            if (! is_array($config)
1458
-                || (
1459
-                    is_array($config)
1460
-                    && (
1461
-                        (isset($config['nav']) && ! $config['nav'])
1462
-                        || ! isset($config['nav'])
1463
-                    )
1464
-                )
1465
-            ) {
1466
-                continue;
1467
-            }
1468
-            // no nav tab for this config
1469
-            // check for persistent flag
1470
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1471
-                // nav tab is only to appear when route requested.
1472
-                continue;
1473
-            }
1474
-            if (! $this->check_user_access($slug, true)) {
1475
-                // no nav tab because current user does not have access.
1476
-                continue;
1477
-            }
1478
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1479
-            $this->_nav_tabs[ $slug ] = array(
1480
-                'url'       => isset($config['nav']['url'])
1481
-                    ? $config['nav']['url']
1482
-                    : self::add_query_args_and_nonce(
1483
-                        array('action' => $slug),
1484
-                        $this->_admin_base_url
1485
-                    ),
1486
-                'link_text' => isset($config['nav']['label'])
1487
-                    ? $config['nav']['label']
1488
-                    : ucwords(
1489
-                        str_replace('_', ' ', $slug)
1490
-                    ),
1491
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1492
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1493
-            );
1494
-            $i++;
1495
-        }
1496
-        // if $this->_nav_tabs is empty then lets set the default
1497
-        if (empty($this->_nav_tabs)) {
1498
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1499
-                'url'       => $this->_admin_base_url,
1500
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1501
-                'css_class' => 'nav-tab-active',
1502
-                'order'     => 10,
1503
-            );
1504
-        }
1505
-        // now let's sort the tabs according to order
1506
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1507
-    }
1508
-
1509
-
1510
-    /**
1511
-     * _set_current_labels
1512
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1513
-     * property array
1514
-     *
1515
-     * @return void
1516
-     */
1517
-    private function _set_current_labels()
1518
-    {
1519
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1520
-            foreach ($this->_route_config['labels'] as $label => $text) {
1521
-                if (is_array($text)) {
1522
-                    foreach ($text as $sublabel => $subtext) {
1523
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1524
-                    }
1525
-                } else {
1526
-                    $this->_labels[ $label ] = $text;
1527
-                }
1528
-            }
1529
-        }
1530
-    }
1531
-
1532
-
1533
-    /**
1534
-     *        verifies user access for this admin page
1535
-     *
1536
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1537
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1538
-     *                               return false if verify fail.
1539
-     * @return bool
1540
-     * @throws InvalidArgumentException
1541
-     * @throws InvalidDataTypeException
1542
-     * @throws InvalidInterfaceException
1543
-     */
1544
-    public function check_user_access($route_to_check = '', $verify_only = false)
1545
-    {
1546
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1547
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1548
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1549
-                      && is_array(
1550
-                          $this->_page_routes[ $route_to_check ]
1551
-                      )
1552
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1553
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1554
-        if (empty($capability) && empty($route_to_check)) {
1555
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1556
-                : $this->_route['capability'];
1557
-        } else {
1558
-            $capability = empty($capability) ? 'manage_options' : $capability;
1559
-        }
1560
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1561
-        if (! defined('DOING_AJAX')
1562
-            && (
1563
-                ! function_exists('is_admin')
1564
-                || ! EE_Registry::instance()->CAP->current_user_can(
1565
-                    $capability,
1566
-                    $this->page_slug
1567
-                    . '_'
1568
-                    . $route_to_check,
1569
-                    $id
1570
-                )
1571
-            )
1572
-        ) {
1573
-            if ($verify_only) {
1574
-                return false;
1575
-            }
1576
-            if (is_user_logged_in()) {
1577
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1578
-            } else {
1579
-                return false;
1580
-            }
1581
-        }
1582
-        return true;
1583
-    }
1584
-
1585
-
1586
-    /**
1587
-     * admin_init_global
1588
-     * This runs all the code that we want executed within the WP admin_init hook.
1589
-     * This method executes for ALL EE Admin pages.
1590
-     *
1591
-     * @return void
1592
-     */
1593
-    public function admin_init_global()
1594
-    {
1595
-    }
1596
-
1597
-
1598
-    /**
1599
-     * wp_loaded_global
1600
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1601
-     * EE_Admin page and will execute on every EE Admin Page load
1602
-     *
1603
-     * @return void
1604
-     */
1605
-    public function wp_loaded()
1606
-    {
1607
-    }
1608
-
1609
-
1610
-    /**
1611
-     * admin_notices
1612
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1613
-     * ALL EE_Admin pages.
1614
-     *
1615
-     * @return void
1616
-     */
1617
-    public function admin_notices_global()
1618
-    {
1619
-        $this->_display_no_javascript_warning();
1620
-        $this->_display_espresso_notices();
1621
-    }
1622
-
1623
-
1624
-    public function network_admin_notices_global()
1625
-    {
1626
-        $this->_display_no_javascript_warning();
1627
-        $this->_display_espresso_notices();
1628
-    }
1629
-
1630
-
1631
-    /**
1632
-     * admin_footer_scripts_global
1633
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1634
-     * will apply on ALL EE_Admin pages.
1635
-     *
1636
-     * @return void
1637
-     */
1638
-    public function admin_footer_scripts_global()
1639
-    {
1640
-        $this->_add_admin_page_ajax_loading_img();
1641
-        $this->_add_admin_page_overlay();
1642
-        // if metaboxes are present we need to add the nonce field
1643
-        if (isset($this->_route_config['metaboxes'])
1644
-            || isset($this->_route_config['list_table'])
1645
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1646
-        ) {
1647
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1648
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1649
-        }
1650
-    }
1651
-
1652
-
1653
-    /**
1654
-     * admin_footer_global
1655
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1656
-     * ALL EE_Admin Pages.
1657
-     *
1658
-     * @return void
1659
-     * @throws EE_Error
1660
-     */
1661
-    public function admin_footer_global()
1662
-    {
1663
-        // dialog container for dialog helper
1664
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1665
-        $d_cont .= '<div class="ee-notices"></div>';
1666
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1667
-        $d_cont .= '</div>';
1668
-        echo $d_cont;
1669
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1670
-        // help tour stuff?
1671
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1672
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1673
-        // }
1674
-        // current set timezone for timezone js
1675
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1676
-    }
1677
-
1678
-
1679
-    /**
1680
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1681
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1682
-     * help popups then in your templates or your content you set "triggers" for the content using the
1683
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1684
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1685
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1686
-     * for the
1687
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1688
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1689
-     *    'help_trigger_id' => array(
1690
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1691
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1692
-     *    )
1693
-     * );
1694
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1695
-     *
1696
-     * @param array $help_array
1697
-     * @param bool  $display
1698
-     * @return string content
1699
-     * @throws DomainException
1700
-     * @throws EE_Error
1701
-     */
1702
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1703
-    {
1704
-        $content = '';
1705
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1706
-        // loop through the array and setup content
1707
-        foreach ($help_array as $trigger => $help) {
1708
-            // make sure the array is setup properly
1709
-            if (! isset($help['title']) || ! isset($help['content'])) {
1710
-                throw new EE_Error(
1711
-                    esc_html__(
1712
-                        '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',
1713
-                        'event_espresso'
1714
-                    )
1715
-                );
1716
-            }
1717
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1718
-            $template_args = array(
1719
-                'help_popup_id'      => $trigger,
1720
-                'help_popup_title'   => $help['title'],
1721
-                'help_popup_content' => $help['content'],
1722
-            );
1723
-            $content .= EEH_Template::display_template(
1724
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1725
-                $template_args,
1726
-                true
1727
-            );
1728
-        }
1729
-        if ($display) {
1730
-            echo $content;
1731
-            return '';
1732
-        }
1733
-        return $content;
1734
-    }
1735
-
1736
-
1737
-    /**
1738
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1739
-     *
1740
-     * @return array properly formatted array for help popup content
1741
-     * @throws EE_Error
1742
-     */
1743
-    private function _get_help_content()
1744
-    {
1745
-        // what is the method we're looking for?
1746
-        $method_name = '_help_popup_content_' . $this->_req_action;
1747
-        // if method doesn't exist let's get out.
1748
-        if (! method_exists($this, $method_name)) {
1749
-            return array();
1750
-        }
1751
-        // k we're good to go let's retrieve the help array
1752
-        $help_array = call_user_func(array($this, $method_name));
1753
-        // make sure we've got an array!
1754
-        if (! is_array($help_array)) {
1755
-            throw new EE_Error(
1756
-                esc_html__(
1757
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1758
-                    'event_espresso'
1759
-                )
1760
-            );
1761
-        }
1762
-        return $help_array;
1763
-    }
1764
-
1765
-
1766
-    /**
1767
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1768
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1769
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1770
-     *
1771
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1772
-     * @param boolean $display    if false then we return the trigger string
1773
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1774
-     * @return string
1775
-     * @throws DomainException
1776
-     * @throws EE_Error
1777
-     */
1778
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1779
-    {
1780
-        if (defined('DOING_AJAX')) {
1781
-            return '';
1782
-        }
1783
-        // 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
1784
-        $help_array = $this->_get_help_content();
1785
-        $help_content = '';
1786
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1787
-            $help_array[ $trigger_id ] = array(
1788
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1789
-                'content' => esc_html__(
1790
-                    '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.)',
1791
-                    'event_espresso'
1792
-                ),
1793
-            );
1794
-            $help_content = $this->_set_help_popup_content($help_array, false);
1795
-        }
1796
-        // let's setup the trigger
1797
-        $content = '<a class="ee-dialog" href="?height='
1798
-                   . $dimensions[0]
1799
-                   . '&width='
1800
-                   . $dimensions[1]
1801
-                   . '&inlineId='
1802
-                   . $trigger_id
1803
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1804
-        $content .= $help_content;
1805
-        if ($display) {
1806
-            echo $content;
1807
-            return '';
1808
-        }
1809
-        return $content;
1810
-    }
1811
-
1812
-
1813
-    /**
1814
-     * _add_global_screen_options
1815
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1816
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1817
-     *
1818
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1819
-     *         see also WP_Screen object documents...
1820
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1821
-     * @abstract
1822
-     * @return void
1823
-     */
1824
-    private function _add_global_screen_options()
1825
-    {
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * _add_global_feature_pointers
1831
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1832
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1833
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1834
-     *
1835
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1836
-     *         extended) also see:
1837
-     * @link   http://eamann.com/tech/wordpress-portland/
1838
-     * @abstract
1839
-     * @return void
1840
-     */
1841
-    private function _add_global_feature_pointers()
1842
-    {
1843
-    }
1844
-
1845
-
1846
-    /**
1847
-     * load_global_scripts_styles
1848
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1849
-     *
1850
-     * @return void
1851
-     * @throws EE_Error
1852
-     */
1853
-    public function load_global_scripts_styles()
1854
-    {
1855
-        /** STYLES **/
1856
-        // add debugging styles
1857
-        if (WP_DEBUG) {
1858
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1859
-        }
1860
-        // register all styles
1861
-        wp_register_style(
1862
-            'espresso-ui-theme',
1863
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1864
-            array(),
1865
-            EVENT_ESPRESSO_VERSION
1866
-        );
1867
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1868
-        // helpers styles
1869
-        wp_register_style(
1870
-            'ee-text-links',
1871
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1872
-            array(),
1873
-            EVENT_ESPRESSO_VERSION
1874
-        );
1875
-        /** SCRIPTS **/
1876
-        // register all scripts
1877
-        wp_register_script(
1878
-            'ee-dialog',
1879
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1880
-            array('jquery', 'jquery-ui-draggable'),
1881
-            EVENT_ESPRESSO_VERSION,
1882
-            true
1883
-        );
1884
-        wp_register_script(
1885
-            'ee_admin_js',
1886
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1887
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1888
-            EVENT_ESPRESSO_VERSION,
1889
-            true
1890
-        );
1891
-        wp_register_script(
1892
-            'jquery-ui-timepicker-addon',
1893
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1894
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1895
-            EVENT_ESPRESSO_VERSION,
1896
-            true
1897
-        );
1898
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1899
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1900
-        //     add_filter('FHEE_load_joyride', '__return_true');
1901
-        // }
1902
-        // script for sorting tables
1903
-        wp_register_script(
1904
-            'espresso_ajax_table_sorting',
1905
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1906
-            array('ee_admin_js', 'jquery-ui-sortable'),
1907
-            EVENT_ESPRESSO_VERSION,
1908
-            true
1909
-        );
1910
-        // script for parsing uri's
1911
-        wp_register_script(
1912
-            'ee-parse-uri',
1913
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1914
-            array(),
1915
-            EVENT_ESPRESSO_VERSION,
1916
-            true
1917
-        );
1918
-        // and parsing associative serialized form elements
1919
-        wp_register_script(
1920
-            'ee-serialize-full-array',
1921
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1922
-            array('jquery'),
1923
-            EVENT_ESPRESSO_VERSION,
1924
-            true
1925
-        );
1926
-        // helpers scripts
1927
-        wp_register_script(
1928
-            'ee-text-links',
1929
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1930
-            array('jquery'),
1931
-            EVENT_ESPRESSO_VERSION,
1932
-            true
1933
-        );
1934
-        wp_register_script(
1935
-            'ee-moment-core',
1936
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1937
-            array(),
1938
-            EVENT_ESPRESSO_VERSION,
1939
-            true
1940
-        );
1941
-        wp_register_script(
1942
-            'ee-moment',
1943
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1944
-            array('ee-moment-core'),
1945
-            EVENT_ESPRESSO_VERSION,
1946
-            true
1947
-        );
1948
-        wp_register_script(
1949
-            'ee-datepicker',
1950
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1951
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1952
-            EVENT_ESPRESSO_VERSION,
1953
-            true
1954
-        );
1955
-        // google charts
1956
-        wp_register_script(
1957
-            'google-charts',
1958
-            'https://www.gstatic.com/charts/loader.js',
1959
-            array(),
1960
-            EVENT_ESPRESSO_VERSION,
1961
-            false
1962
-        );
1963
-        // ENQUEUE ALL BASICS BY DEFAULT
1964
-        wp_enqueue_style('ee-admin-css');
1965
-        wp_enqueue_script('ee_admin_js');
1966
-        wp_enqueue_script('ee-accounting');
1967
-        wp_enqueue_script('jquery-validate');
1968
-        // taking care of metaboxes
1969
-        if (empty($this->_cpt_route)
1970
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1971
-        ) {
1972
-            wp_enqueue_script('dashboard');
1973
-        }
1974
-        // LOCALIZED DATA
1975
-        // localize script for ajax lazy loading
1976
-        $lazy_loader_container_ids = apply_filters(
1977
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1978
-            array('espresso_news_post_box_content')
1979
-        );
1980
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1981
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1982
-        // /**
1983
-        //  * help tour stuff
1984
-        //  */
1985
-        // if (! empty($this->_help_tour)) {
1986
-        //     // register the js for kicking things off
1987
-        //     wp_enqueue_script(
1988
-        //         'ee-help-tour',
1989
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
1990
-        //         array('jquery-joyride'),
1991
-        //         EVENT_ESPRESSO_VERSION,
1992
-        //         true
1993
-        //     );
1994
-        //     $tours = array();
1995
-        //     // setup tours for the js tour object
1996
-        //     foreach ($this->_help_tour['tours'] as $tour) {
1997
-        //         if ($tour instanceof EE_Help_Tour) {
1998
-        //             $tours[] = array(
1999
-        //                 'id'      => $tour->get_slug(),
2000
-        //                 'options' => $tour->get_options(),
2001
-        //             );
2002
-        //         }
2003
-        //     }
2004
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2005
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2006
-        // }
2007
-    }
2008
-
2009
-
2010
-    /**
2011
-     *        admin_footer_scripts_eei18n_js_strings
2012
-     *
2013
-     * @return        void
2014
-     */
2015
-    public function admin_footer_scripts_eei18n_js_strings()
2016
-    {
2017
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2018
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2019
-            '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!!!',
2020
-            'event_espresso'
2021
-        );
2022
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2023
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2024
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2025
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2026
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2027
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2028
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2029
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2030
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2031
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2032
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2033
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2034
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2035
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2036
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2037
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2038
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2039
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2040
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2041
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2042
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2043
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2044
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2045
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2046
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2047
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2048
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2049
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2050
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2051
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2052
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2053
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2054
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2055
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2056
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2057
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2058
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2059
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2060
-    }
2061
-
2062
-
2063
-    /**
2064
-     *        load enhanced xdebug styles for ppl with failing eyesight
2065
-     *
2066
-     * @return        void
2067
-     */
2068
-    public function add_xdebug_style()
2069
-    {
2070
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2071
-    }
2072
-
2073
-
2074
-    /************************/
2075
-    /** LIST TABLE METHODS **/
2076
-    /************************/
2077
-    /**
2078
-     * this sets up the list table if the current view requires it.
2079
-     *
2080
-     * @return void
2081
-     * @throws EE_Error
2082
-     */
2083
-    protected function _set_list_table()
2084
-    {
2085
-        // first is this a list_table view?
2086
-        if (! isset($this->_route_config['list_table'])) {
2087
-            return;
2088
-        } //not a list_table view so get out.
2089
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2090
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2091
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2092
-            // user error msg
2093
-            $error_msg = esc_html__(
2094
-                'An error occurred. The requested list table views could not be found.',
2095
-                'event_espresso'
2096
-            );
2097
-            // developer error msg
2098
-            $error_msg .= '||'
2099
-                          . sprintf(
2100
-                              esc_html__(
2101
-                                  '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.',
2102
-                                  'event_espresso'
2103
-                              ),
2104
-                              $this->_req_action,
2105
-                              $list_table_view
2106
-                          );
2107
-            throw new EE_Error($error_msg);
2108
-        }
2109
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2110
-        $this->_views = apply_filters(
2111
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2112
-            $this->_views
2113
-        );
2114
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2115
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2116
-        $this->_set_list_table_view();
2117
-        $this->_set_list_table_object();
2118
-    }
2119
-
2120
-
2121
-    /**
2122
-     * set current view for List Table
2123
-     *
2124
-     * @return void
2125
-     */
2126
-    protected function _set_list_table_view()
2127
-    {
2128
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2129
-        // looking at active items or dumpster diving ?
2130
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2131
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2132
-        } else {
2133
-            $this->_view = sanitize_key($this->_req_data['status']);
2134
-        }
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     * _set_list_table_object
2140
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2141
-     *
2142
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2143
-     * @throws \InvalidArgumentException
2144
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2145
-     * @throws EE_Error
2146
-     * @throws InvalidInterfaceException
2147
-     */
2148
-    protected function _set_list_table_object()
2149
-    {
2150
-        if (isset($this->_route_config['list_table'])) {
2151
-            if (! class_exists($this->_route_config['list_table'])) {
2152
-                throw new EE_Error(
2153
-                    sprintf(
2154
-                        esc_html__(
2155
-                            '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.',
2156
-                            'event_espresso'
2157
-                        ),
2158
-                        $this->_route_config['list_table'],
2159
-                        get_class($this)
2160
-                    )
2161
-                );
2162
-            }
2163
-            $this->_list_table_object = $this->loader->getShared(
2164
-                $this->_route_config['list_table'],
2165
-                array($this)
2166
-            );
2167
-        }
2168
-    }
2169
-
2170
-
2171
-    /**
2172
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2173
-     *
2174
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2175
-     *                                                    urls.  The array should be indexed by the view it is being
2176
-     *                                                    added to.
2177
-     * @return array
2178
-     */
2179
-    public function get_list_table_view_RLs($extra_query_args = array())
2180
-    {
2181
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2182
-        if (empty($this->_views)) {
2183
-            $this->_views = array();
2184
-        }
2185
-        // cycle thru views
2186
-        foreach ($this->_views as $key => $view) {
2187
-            $query_args = array();
2188
-            // check for current view
2189
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2190
-            $query_args['action'] = $this->_req_action;
2191
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2192
-            $query_args['status'] = $view['slug'];
2193
-            // merge any other arguments sent in.
2194
-            if (isset($extra_query_args[ $view['slug'] ])) {
2195
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2196
-            }
2197
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2198
-        }
2199
-        return $this->_views;
2200
-    }
2201
-
2202
-
2203
-    /**
2204
-     * _entries_per_page_dropdown
2205
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2206
-     *
2207
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2208
-     *         WP does it.
2209
-     * @param int $max_entries total number of rows in the table
2210
-     * @return string
2211
-     */
2212
-    protected function _entries_per_page_dropdown($max_entries = 0)
2213
-    {
2214
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2215
-        $values = array(10, 25, 50, 100);
2216
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2217
-        if ($max_entries) {
2218
-            $values[] = $max_entries;
2219
-            sort($values);
2220
-        }
2221
-        $entries_per_page_dropdown = '
104
+	/**
105
+	 * @var array $_route_config
106
+	 */
107
+	protected $_route_config;
108
+
109
+	/**
110
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
+	 * actions.
112
+	 *
113
+	 * @since 4.6.x
114
+	 * @var array.
115
+	 */
116
+	protected $_default_route_query_args;
117
+
118
+	// set via request page and action args.
119
+	protected $_current_page;
120
+
121
+	protected $_current_view;
122
+
123
+	protected $_current_page_view_url;
124
+
125
+	// sanitized request action (and nonce)
126
+
127
+	/**
128
+	 * @var string $_req_action
129
+	 */
130
+	protected $_req_action;
131
+
132
+	/**
133
+	 * @var string $_req_nonce
134
+	 */
135
+	protected $_req_nonce;
136
+
137
+	// search related
138
+	protected $_search_btn_label;
139
+
140
+	protected $_search_box_callback;
141
+
142
+	/**
143
+	 * WP Current Screen object
144
+	 *
145
+	 * @var WP_Screen
146
+	 */
147
+	protected $_current_screen;
148
+
149
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
+	protected $_hook_obj;
151
+
152
+	// for holding incoming request data
153
+	protected $_req_data = [];
154
+
155
+	// yes / no array for admin form fields
156
+	protected $_yes_no_values = array();
157
+
158
+	// some default things shared by all child classes
159
+	protected $_default_espresso_metaboxes;
160
+
161
+	/**
162
+	 *    EE_Registry Object
163
+	 *
164
+	 * @var    EE_Registry
165
+	 */
166
+	protected $EE = null;
167
+
168
+
169
+	/**
170
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
171
+	 *
172
+	 * @var boolean
173
+	 */
174
+	protected $_is_caf = false;
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws ReflectionException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function __construct($routing = true)
187
+	{
188
+		$this->loader = LoaderFactory::getLoader();
189
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
+			$this->_is_caf = true;
191
+		}
192
+		$this->_yes_no_values = array(
193
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
+		);
196
+		// set the _req_data property.
197
+		$this->_req_data = array_merge($_GET, $_POST);
198
+		// routing enabled?
199
+		$this->_routing = $routing;
200
+		// set initial page props (child method)
201
+		$this->_init_page_props();
202
+		// set global defaults
203
+		$this->_set_defaults();
204
+		// set early because incoming requests could be ajax related and we need to register those hooks.
205
+		$this->_global_ajax_hooks();
206
+		$this->_ajax_hooks();
207
+		// other_page_hooks have to be early too.
208
+		$this->_do_other_page_hooks();
209
+		// This just allows us to have extending classes do something specific
210
+		// before the parent constructor runs _page_setup().
211
+		if (method_exists($this, '_before_page_setup')) {
212
+			$this->_before_page_setup();
213
+		}
214
+		// set up page dependencies
215
+		$this->_page_setup();
216
+	}
217
+
218
+
219
+	/**
220
+	 * _init_page_props
221
+	 * Child classes use to set at least the following properties:
222
+	 * $page_slug.
223
+	 * $page_label.
224
+	 *
225
+	 * @abstract
226
+	 * @return void
227
+	 */
228
+	abstract protected function _init_page_props();
229
+
230
+
231
+	/**
232
+	 * _ajax_hooks
233
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
+	 * Note: within the ajax callback methods.
235
+	 *
236
+	 * @abstract
237
+	 * @return void
238
+	 */
239
+	abstract protected function _ajax_hooks();
240
+
241
+
242
+	/**
243
+	 * _define_page_props
244
+	 * child classes define page properties in here.  Must include at least:
245
+	 * $_admin_base_url = base_url for all admin pages
246
+	 * $_admin_page_title = default admin_page_title for admin pages
247
+	 * $_labels = array of default labels for various automatically generated elements:
248
+	 *    array(
249
+	 *        'buttons' => array(
250
+	 *            'add' => esc_html__('label for add new button'),
251
+	 *            'edit' => esc_html__('label for edit button'),
252
+	 *            'delete' => esc_html__('label for delete button')
253
+	 *            )
254
+	 *        )
255
+	 *
256
+	 * @abstract
257
+	 * @return void
258
+	 */
259
+	abstract protected function _define_page_props();
260
+
261
+
262
+	/**
263
+	 * _set_page_routes
264
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
+	 * have a 'default' route. Here's the format
267
+	 * $this->_page_routes = array(
268
+	 *        'default' => array(
269
+	 *            'func' => '_default_method_handling_route',
270
+	 *            'args' => array('array','of','args'),
271
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
+	 *            ajax request, backend processing)
273
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
+	 *            headers route after.  The string you enter here should match the defined route reference for a
275
+	 *            headers sent route.
276
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
+	 *            this route.
278
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
+	 *            checks).
280
+	 *        ),
281
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
+	 *        handling method.
283
+	 *        )
284
+	 * )
285
+	 *
286
+	 * @abstract
287
+	 * @return void
288
+	 */
289
+	abstract protected function _set_page_routes();
290
+
291
+
292
+	/**
293
+	 * _set_page_config
294
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
+	 * array corresponds to the page_route for the loaded page. Format:
296
+	 * $this->_page_config = array(
297
+	 *        'default' => array(
298
+	 *            'labels' => array(
299
+	 *                'buttons' => array(
300
+	 *                    'add' => esc_html__('label for adding item'),
301
+	 *                    'edit' => esc_html__('label for editing item'),
302
+	 *                    'delete' => esc_html__('label for deleting item')
303
+	 *                ),
304
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
+	 *            _define_page_props() method
308
+	 *            'nav' => array(
309
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
+	 *                'order' => 10, //required to indicate tab position.
313
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
+	 *                displayed then add this parameter.
315
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
+	 *            metaboxes set for eventespresso admin pages.
318
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
+	 *            want to display.
327
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
328
+	 *                'tab_id' => array(
329
+	 *                    'title' => 'tab_title',
330
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
+	 *                    attempt to use the callback which should match the name of a method in the class
336
+	 *                    ),
337
+	 *                'tab2_id' => array(
338
+	 *                    'title' => 'tab2 title',
339
+	 *                    'filename' => 'file_name_2'
340
+	 *                    'callback' => 'callback_method_for_content',
341
+	 *                 ),
342
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
+	 *            help tab area on an admin page. @link
344
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
+	 *            'help_tour' => array(
346
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
+	 *            ),
350
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
+	 *            just set
353
+	 *            'require_nonce' to FALSE
354
+	 *            )
355
+	 * )
356
+	 *
357
+	 * @abstract
358
+	 * @return void
359
+	 */
360
+	abstract protected function _set_page_config();
361
+
362
+
363
+
364
+
365
+
366
+	/** end sample help_tour methods **/
367
+	/**
368
+	 * _add_screen_options
369
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
+	 * to a particular view.
372
+	 *
373
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
+	 *         see also WP_Screen object documents...
375
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
+	 * @abstract
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+	/**
383
+	 * _add_feature_pointers
384
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
+	 * extended) also see:
389
+	 *
390
+	 * @link   http://eamann.com/tech/wordpress-portland/
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _add_feature_pointers();
395
+
396
+
397
+	/**
398
+	 * load_scripts_styles
399
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
+	 * scripts/styles per view by putting them in a dynamic function in this format
402
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
+	 *
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract public function load_scripts_styles();
408
+
409
+
410
+	/**
411
+	 * admin_init
412
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
+	 * all pages/views loaded by child class.
414
+	 *
415
+	 * @abstract
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_init();
419
+
420
+
421
+	/**
422
+	 * admin_notices
423
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
+	 * all pages/views loaded by child class.
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function admin_notices();
430
+
431
+
432
+	/**
433
+	 * admin_footer_scripts
434
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
+	 * will apply to all pages/views loaded by child class.
436
+	 *
437
+	 * @return void
438
+	 */
439
+	abstract public function admin_footer_scripts();
440
+
441
+
442
+	/**
443
+	 * admin_footer
444
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
+	 * apply to all pages/views loaded by child class.
446
+	 *
447
+	 * @return void
448
+	 */
449
+	public function admin_footer()
450
+	{
451
+	}
452
+
453
+
454
+	/**
455
+	 * _global_ajax_hooks
456
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
+	 * Note: within the ajax callback methods.
458
+	 *
459
+	 * @abstract
460
+	 * @return void
461
+	 */
462
+	protected function _global_ajax_hooks()
463
+	{
464
+		// for lazy loading of metabox content
465
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
+	}
467
+
468
+
469
+	public function ajax_metabox_content()
470
+	{
471
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
+		self::cached_rss_display($contentid, $url);
474
+		wp_die();
475
+	}
476
+
477
+
478
+	/**
479
+	 * _page_setup
480
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
+	 * doesn't match the object.
482
+	 *
483
+	 * @final
484
+	 * @return void
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws ReflectionException
488
+	 * @throws InvalidDataTypeException
489
+	 * @throws InvalidInterfaceException
490
+	 */
491
+	final protected function _page_setup()
492
+	{
493
+		// requires?
494
+		// admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
496
+		// next verify if we need to load anything...
497
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
+		$this->page_folder = strtolower(
499
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
+		);
501
+		global $ee_menu_slugs;
502
+		$ee_menu_slugs = (array) $ee_menu_slugs;
503
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
+			return;
505
+		}
506
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
+				? $this->_req_data['action2']
510
+				: $this->_req_data['action'];
511
+		}
512
+		// then set blank or -1 action values to 'default'
513
+		$this->_req_action = isset($this->_req_data['action'])
514
+							 && ! empty($this->_req_data['action'])
515
+							 && $this->_req_data['action'] !== '-1'
516
+			? sanitize_key($this->_req_data['action'])
517
+			: 'default';
518
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
520
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
+			? $this->_req_data['route'] : $this->_req_action;
522
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
+			? $this->_req_data['route']
525
+			: $this->_req_action;
526
+		$this->_current_view = $this->_req_action;
527
+		$this->_req_nonce = $this->_req_action . '_nonce';
528
+		$this->_define_page_props();
529
+		$this->_current_page_view_url = add_query_arg(
530
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
531
+			$this->_admin_base_url
532
+		);
533
+		// default things
534
+		$this->_default_espresso_metaboxes = array(
535
+			'_espresso_news_post_box',
536
+			'_espresso_links_post_box',
537
+			'_espresso_ratings_request',
538
+			'_espresso_sponsors_post_box',
539
+		);
540
+		// set page configs
541
+		$this->_set_page_routes();
542
+		$this->_set_page_config();
543
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
544
+		if (isset($this->_req_data['wp_referer'])) {
545
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
+		}
547
+		// for caffeinated and other extended functionality.
548
+		//  If there is a _extend_page_config method
549
+		// then let's run that to modify the all the various page configuration arrays
550
+		if (method_exists($this, '_extend_page_config')) {
551
+			$this->_extend_page_config();
552
+		}
553
+		// for CPT and other extended functionality.
554
+		// If there is an _extend_page_config_for_cpt
555
+		// then let's run that to modify all the various page configuration arrays.
556
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
557
+			$this->_extend_page_config_for_cpt();
558
+		}
559
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
560
+		$this->_page_routes = apply_filters(
561
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
+			$this->_page_routes,
563
+			$this
564
+		);
565
+		$this->_page_config = apply_filters(
566
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
567
+			$this->_page_config,
568
+			$this
569
+		);
570
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
+			add_action(
574
+				'AHEE__EE_Admin_Page__route_admin_request',
575
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
+				10,
577
+				2
578
+			);
579
+		}
580
+		// next route only if routing enabled
581
+		if ($this->_routing && ! defined('DOING_AJAX')) {
582
+			$this->_verify_routes();
583
+			// next let's just check user_access and kill if no access
584
+			$this->check_user_access();
585
+			if ($this->_is_UI_request) {
586
+				// admin_init stuff - global, all views for this page class, specific view
587
+				add_action('admin_init', array($this, 'admin_init'), 10);
588
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
+				}
591
+			} else {
592
+				// hijack regular WP loading and route admin request immediately
593
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
+				$this->route_admin_request();
595
+			}
596
+		}
597
+	}
598
+
599
+
600
+	/**
601
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
+	 *
603
+	 * @return void
604
+	 * @throws ReflectionException
605
+	 * @throws EE_Error
606
+	 */
607
+	private function _do_other_page_hooks()
608
+	{
609
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
+		foreach ($registered_pages as $page) {
611
+			// now let's setup the file name and class that should be present
612
+			$classname = str_replace('.class.php', '', $page);
613
+			// autoloaders should take care of loading file
614
+			if (! class_exists($classname)) {
615
+				$error_msg[] = sprintf(
616
+					esc_html__(
617
+						'Something went wrong with loading the %s admin hooks page.',
618
+						'event_espresso'
619
+					),
620
+					$page
621
+				);
622
+				$error_msg[] = $error_msg[0]
623
+							   . "\r\n"
624
+							   . sprintf(
625
+								   esc_html__(
626
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
627
+									   'event_espresso'
628
+								   ),
629
+								   $page,
630
+								   '<br />',
631
+								   '<strong>' . $classname . '</strong>'
632
+							   );
633
+				throw new EE_Error(implode('||', $error_msg));
634
+			}
635
+			$a = new ReflectionClass($classname);
636
+			// notice we are passing the instance of this class to the hook object.
637
+			$hookobj[] = $a->newInstance($this);
638
+		}
639
+	}
640
+
641
+
642
+	public function load_page_dependencies()
643
+	{
644
+		try {
645
+			$this->_load_page_dependencies();
646
+		} catch (EE_Error $e) {
647
+			$e->get_error();
648
+		}
649
+	}
650
+
651
+
652
+	/**
653
+	 * load_page_dependencies
654
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
+	 *
656
+	 * @return void
657
+	 * @throws DomainException
658
+	 * @throws EE_Error
659
+	 * @throws InvalidArgumentException
660
+	 * @throws InvalidDataTypeException
661
+	 * @throws InvalidInterfaceException
662
+	 * @throws ReflectionException
663
+	 */
664
+	protected function _load_page_dependencies()
665
+	{
666
+		// let's set the current_screen and screen options to override what WP set
667
+		$this->_current_screen = get_current_screen();
668
+		// load admin_notices - global, page class, and view specific
669
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
671
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
+		}
674
+		// load network admin_notices - global, page class, and view specific
675
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
+		}
679
+		// this will save any per_page screen options if they are present
680
+		$this->_set_per_page_screen_options();
681
+		// setup list table properties
682
+		$this->_set_list_table();
683
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
+		// However in some cases the metaboxes will need to be added within a route handling callback.
685
+		$this->_add_registered_meta_boxes();
686
+		$this->_add_screen_columns();
687
+		// add screen options - global, page child class, and view specific
688
+		$this->_add_global_screen_options();
689
+		$this->_add_screen_options();
690
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
691
+		if (method_exists($this, $add_screen_options)) {
692
+			$this->{$add_screen_options}();
693
+		}
694
+		// add help tab(s) and tours- set via page_config and qtips.
695
+		// $this->_add_help_tour();
696
+		$this->_add_help_tabs();
697
+		$this->_add_qtips();
698
+		// add feature_pointers - global, page child class, and view specific
699
+		$this->_add_feature_pointers();
700
+		$this->_add_global_feature_pointers();
701
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
+		if (method_exists($this, $add_feature_pointer)) {
703
+			$this->{$add_feature_pointer}();
704
+		}
705
+		// enqueue scripts/styles - global, page class, and view specific
706
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
+		}
711
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
+		// admin_print_footer_scripts - global, page child class, and view specific.
713
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
+		// is a good use case. Notice the late priority we're giving these
716
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
+		}
721
+		// admin footer scripts
722
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
724
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
+		}
727
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
+		// targeted hook
729
+		do_action(
730
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
+		);
732
+	}
733
+
734
+
735
+	/**
736
+	 * _set_defaults
737
+	 * This sets some global defaults for class properties.
738
+	 */
739
+	private function _set_defaults()
740
+	{
741
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
743
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
+		$this->_page_config = $this->_default_route_query_args = array();
745
+		$this->_default_nav_tab_name = 'overview';
746
+		// init template args
747
+		$this->_template_args = array(
748
+			'admin_page_header'  => '',
749
+			'admin_page_content' => '',
750
+			'post_body_content'  => '',
751
+			'before_list_table'  => '',
752
+			'after_list_table'   => '',
753
+		);
754
+	}
755
+
756
+
757
+	/**
758
+	 * route_admin_request
759
+	 *
760
+	 * @see    _route_admin_request()
761
+	 * @return exception|void error
762
+	 * @throws InvalidArgumentException
763
+	 * @throws InvalidInterfaceException
764
+	 * @throws InvalidDataTypeException
765
+	 * @throws EE_Error
766
+	 * @throws ReflectionException
767
+	 */
768
+	public function route_admin_request()
769
+	{
770
+		try {
771
+			$this->_route_admin_request();
772
+		} catch (EE_Error $e) {
773
+			$e->get_error();
774
+		}
775
+	}
776
+
777
+
778
+	public function set_wp_page_slug($wp_page_slug)
779
+	{
780
+		$this->_wp_page_slug = $wp_page_slug;
781
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
+		if (is_network_admin()) {
783
+			$this->_wp_page_slug .= '-network';
784
+		}
785
+	}
786
+
787
+
788
+	/**
789
+	 * _verify_routes
790
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
+	 * we know if we need to drop out.
792
+	 *
793
+	 * @return bool
794
+	 * @throws EE_Error
795
+	 */
796
+	protected function _verify_routes()
797
+	{
798
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
+			return false;
801
+		}
802
+		$this->_route = false;
803
+		// check that the page_routes array is not empty
804
+		if (empty($this->_page_routes)) {
805
+			// user error msg
806
+			$error_msg = sprintf(
807
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
+				$this->_admin_page_title
809
+			);
810
+			// developer error msg
811
+			$error_msg .= '||' . $error_msg
812
+						  . esc_html__(
813
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
+							  'event_espresso'
815
+						  );
816
+			throw new EE_Error($error_msg);
817
+		}
818
+		// and that the requested page route exists
819
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
+			$this->_route = $this->_page_routes[ $this->_req_action ];
821
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
+				? $this->_page_config[ $this->_req_action ] : array();
823
+		} else {
824
+			// user error msg
825
+			$error_msg = sprintf(
826
+				esc_html__(
827
+					'The requested page route does not exist for the %s admin page.',
828
+					'event_espresso'
829
+				),
830
+				$this->_admin_page_title
831
+			);
832
+			// developer error msg
833
+			$error_msg .= '||' . $error_msg
834
+						  . sprintf(
835
+							  esc_html__(
836
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
+								  'event_espresso'
838
+							  ),
839
+							  $this->_req_action
840
+						  );
841
+			throw new EE_Error($error_msg);
842
+		}
843
+		// and that a default route exists
844
+		if (! array_key_exists('default', $this->_page_routes)) {
845
+			// user error msg
846
+			$error_msg = sprintf(
847
+				esc_html__(
848
+					'A default page route has not been set for the % admin page.',
849
+					'event_espresso'
850
+				),
851
+				$this->_admin_page_title
852
+			);
853
+			// developer error msg
854
+			$error_msg .= '||' . $error_msg
855
+						  . esc_html__(
856
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
+							  'event_espresso'
858
+						  );
859
+			throw new EE_Error($error_msg);
860
+		}
861
+		// first lets' catch if the UI request has EVER been set.
862
+		if ($this->_is_UI_request === null) {
863
+			// lets set if this is a UI request or not.
864
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
+			// wait a minute... we might have a noheader in the route array
866
+			$this->_is_UI_request = is_array($this->_route)
867
+									&& isset($this->_route['noheader'])
868
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
869
+		}
870
+		$this->_set_current_labels();
871
+		return true;
872
+	}
873
+
874
+
875
+	/**
876
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
+	 *
878
+	 * @param  string $route the route name we're verifying
879
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
+	 * @throws EE_Error
881
+	 */
882
+	protected function _verify_route($route)
883
+	{
884
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
+			return true;
886
+		}
887
+		// user error msg
888
+		$error_msg = sprintf(
889
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
+			$this->_admin_page_title
891
+		);
892
+		// developer error msg
893
+		$error_msg .= '||' . $error_msg
894
+					  . sprintf(
895
+						  esc_html__(
896
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
+							  'event_espresso'
898
+						  ),
899
+						  $route
900
+					  );
901
+		throw new EE_Error($error_msg);
902
+	}
903
+
904
+
905
+	/**
906
+	 * perform nonce verification
907
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
+	 * using this method (and save retyping!)
909
+	 *
910
+	 * @param  string $nonce     The nonce sent
911
+	 * @param  string $nonce_ref The nonce reference string (name0)
912
+	 * @return void
913
+	 * @throws EE_Error
914
+	 */
915
+	protected function _verify_nonce($nonce, $nonce_ref)
916
+	{
917
+		// verify nonce against expected value
918
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
+			// these are not the droids you are looking for !!!
920
+			$msg = sprintf(
921
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
+				'</a>'
924
+			);
925
+			if (WP_DEBUG) {
926
+				$msg .= "\n  "
927
+						. sprintf(
928
+							esc_html__(
929
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
+								'event_espresso'
931
+							),
932
+							__CLASS__
933
+						);
934
+			}
935
+			if (! defined('DOING_AJAX')) {
936
+				wp_die($msg);
937
+			} else {
938
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
+				$this->_return_json();
940
+			}
941
+		}
942
+	}
943
+
944
+
945
+	/**
946
+	 * _route_admin_request()
947
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
+	 * in the page routes and then will try to load the corresponding method.
950
+	 *
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 * @throws InvalidArgumentException
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws InvalidInterfaceException
956
+	 * @throws ReflectionException
957
+	 */
958
+	protected function _route_admin_request()
959
+	{
960
+		if (! $this->_is_UI_request) {
961
+			$this->_verify_routes();
962
+		}
963
+		$nonce_check = isset($this->_route_config['require_nonce'])
964
+			? $this->_route_config['require_nonce']
965
+			: true;
966
+		if ($this->_req_action !== 'default' && $nonce_check) {
967
+			// set nonce from post data
968
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
969
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
+				: '';
971
+			$this->_verify_nonce($nonce, $this->_req_nonce);
972
+		}
973
+		// set the nav_tabs array but ONLY if this is  UI_request
974
+		if ($this->_is_UI_request) {
975
+			$this->_set_nav_tabs();
976
+		}
977
+		// grab callback function
978
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
+		// check if callback has args
980
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
+		$error_msg = '';
982
+		// action right before calling route
983
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
+		}
987
+		// right before calling the route, let's remove _wp_http_referer from the
988
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
990
+			'_wp_http_referer',
991
+			wp_unslash($_SERVER['REQUEST_URI'])
992
+		);
993
+		if (! empty($func)) {
994
+			if (is_array($func)) {
995
+				list($class, $method) = $func;
996
+			} elseif (strpos($func, '::') !== false) {
997
+				list($class, $method) = explode('::', $func);
998
+			} else {
999
+				$class = $this;
1000
+				$method = $func;
1001
+			}
1002
+			if (! (is_object($class) && $class === $this)) {
1003
+				// send along this admin page object for access by addons.
1004
+				$args['admin_page_object'] = $this;
1005
+			}
1006
+			if (// is it a method on a class that doesn't work?
1007
+				(
1008
+					(
1009
+						method_exists($class, $method)
1010
+						&& call_user_func_array(array($class, $method), $args) === false
1011
+					)
1012
+					&& (
1013
+						// is it a standalone function that doesn't work?
1014
+						function_exists($method)
1015
+						&& call_user_func_array(
1016
+							$func,
1017
+							array_merge(array('admin_page_object' => $this), $args)
1018
+						) === false
1019
+					)
1020
+				)
1021
+				|| (
1022
+					// is it neither a class method NOR a standalone function?
1023
+					! method_exists($class, $method)
1024
+					&& ! function_exists($method)
1025
+				)
1026
+			) {
1027
+				// user error msg
1028
+				$error_msg = esc_html__(
1029
+					'An error occurred. The  requested page route could not be found.',
1030
+					'event_espresso'
1031
+				);
1032
+				// developer error msg
1033
+				$error_msg .= '||';
1034
+				$error_msg .= sprintf(
1035
+					esc_html__(
1036
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
+						'event_espresso'
1038
+					),
1039
+					$method
1040
+				);
1041
+			}
1042
+			if (! empty($error_msg)) {
1043
+				throw new EE_Error($error_msg);
1044
+			}
1045
+		}
1046
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1047
+		// then we need to reset the routing properties to the new route.
1048
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1049
+		if ($this->_is_UI_request === false
1050
+			&& is_array($this->_route)
1051
+			&& ! empty($this->_route['headers_sent_route'])
1052
+		) {
1053
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
+		}
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * This method just allows the resetting of page properties in the case where a no headers
1060
+	 * route redirects to a headers route in its route config.
1061
+	 *
1062
+	 * @since   4.3.0
1063
+	 * @param  string $new_route New (non header) route to redirect to.
1064
+	 * @return   void
1065
+	 * @throws ReflectionException
1066
+	 * @throws InvalidArgumentException
1067
+	 * @throws InvalidInterfaceException
1068
+	 * @throws InvalidDataTypeException
1069
+	 * @throws EE_Error
1070
+	 */
1071
+	protected function _reset_routing_properties($new_route)
1072
+	{
1073
+		$this->_is_UI_request = true;
1074
+		// now we set the current route to whatever the headers_sent_route is set at
1075
+		$this->_req_data['action'] = $new_route;
1076
+		// rerun page setup
1077
+		$this->_page_setup();
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * _add_query_arg
1083
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1084
+	 *(internally just uses EEH_URL's function with the same name)
1085
+	 *
1086
+	 * @param array  $args
1087
+	 * @param string $url
1088
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
+	 *                                        Example usage: If the current page is:
1091
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
+	 *                                        &action=default&event_id=20&month_range=March%202015
1093
+	 *                                        &_wpnonce=5467821
1094
+	 *                                        and you call:
1095
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
+	 *                                        array(
1097
+	 *                                        'action' => 'resend_something',
1098
+	 *                                        'page=>espresso_registrations'
1099
+	 *                                        ),
1100
+	 *                                        $some_url,
1101
+	 *                                        true
1102
+	 *                                        );
1103
+	 *                                        It will produce a url in this structure:
1104
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
+	 *                                        month_range]=March%202015
1107
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
+	 * @return string
1109
+	 */
1110
+	public static function add_query_args_and_nonce(
1111
+		$args = array(),
1112
+		$url = false,
1113
+		$sticky = false,
1114
+		$exclude_nonce = false
1115
+	) {
1116
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
+		if ($sticky) {
1118
+			$request = $_REQUEST;
1119
+			unset($request['_wp_http_referer']);
1120
+			unset($request['wp_referer']);
1121
+			foreach ($request as $key => $value) {
1122
+				// do not add nonces
1123
+				if (strpos($key, 'nonce') !== false) {
1124
+					continue;
1125
+				}
1126
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1127
+			}
1128
+		}
1129
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * This returns a generated link that will load the related help tab.
1135
+	 *
1136
+	 * @param  string $help_tab_id the id for the connected help tab
1137
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
+	 * @uses EEH_Template::get_help_tab_link()
1140
+	 * @return string              generated link
1141
+	 */
1142
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
+	{
1144
+		return EEH_Template::get_help_tab_link(
1145
+			$help_tab_id,
1146
+			$this->page_slug,
1147
+			$this->_req_action,
1148
+			$icon_style,
1149
+			$help_text
1150
+		);
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * _add_help_tabs
1156
+	 * Note child classes define their help tabs within the page_config array.
1157
+	 *
1158
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
+	 * @return void
1160
+	 * @throws DomainException
1161
+	 * @throws EE_Error
1162
+	 */
1163
+	protected function _add_help_tabs()
1164
+	{
1165
+		$tour_buttons = '';
1166
+		if (isset($this->_page_config[ $this->_req_action ])) {
1167
+			$config = $this->_page_config[ $this->_req_action ];
1168
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1169
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1170
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1171
+			//     $tb = array();
1172
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1173
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1174
+			//         // if this is the end tour then we don't need to setup a button
1175
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1176
+			//             continue;
1177
+			//         }
1178
+			//         $tb[] = '<button id="trigger-tour-'
1179
+			//                 . $tour->get_slug()
1180
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1181
+			//                 . $tour->get_label()
1182
+			//                 . '</button>';
1183
+			//     }
1184
+			//     $tour_buttons .= implode('<br />', $tb);
1185
+			//     $tour_buttons .= '</div></div>';
1186
+			// }
1187
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1188
+			if (is_array($config) && isset($config['help_sidebar'])) {
1189
+				// check that the callback given is valid
1190
+				if (! method_exists($this, $config['help_sidebar'])) {
1191
+					throw new EE_Error(
1192
+						sprintf(
1193
+							esc_html__(
1194
+								'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',
1195
+								'event_espresso'
1196
+							),
1197
+							$config['help_sidebar'],
1198
+							get_class($this)
1199
+						)
1200
+					);
1201
+				}
1202
+				$content = apply_filters(
1203
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1204
+					$this->{$config['help_sidebar']}()
1205
+				);
1206
+				$content .= $tour_buttons; // add help tour buttons.
1207
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1208
+				$this->_current_screen->set_help_sidebar($content);
1209
+			}
1210
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1211
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1212
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1213
+			}
1214
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1215
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1216
+				$_ht['id'] = $this->page_slug;
1217
+				$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1218
+				$_ht['content'] = '<p>'
1219
+								  . esc_html__(
1220
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1221
+									  'event_espresso'
1222
+								  ) . '</p>';
1223
+				$this->_current_screen->add_help_tab($_ht);
1224
+			}
1225
+			if (! isset($config['help_tabs'])) {
1226
+				return;
1227
+			} //no help tabs for this route
1228
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1229
+				// we're here so there ARE help tabs!
1230
+				// make sure we've got what we need
1231
+				if (! isset($cfg['title'])) {
1232
+					throw new EE_Error(
1233
+						esc_html__(
1234
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1235
+							'event_espresso'
1236
+						)
1237
+					);
1238
+				}
1239
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1240
+					throw new EE_Error(
1241
+						esc_html__(
1242
+							'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',
1243
+							'event_espresso'
1244
+						)
1245
+					);
1246
+				}
1247
+				// first priority goes to content.
1248
+				if (! empty($cfg['content'])) {
1249
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1250
+					// second priority goes to filename
1251
+				} elseif (! empty($cfg['filename'])) {
1252
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1253
+					// 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)
1254
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1255
+															 . basename($this->_get_dir())
1256
+															 . '/help_tabs/'
1257
+															 . $cfg['filename']
1258
+															 . '.help_tab.php' : $file_path;
1259
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1260
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1261
+						EE_Error::add_error(
1262
+							sprintf(
1263
+								esc_html__(
1264
+									'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',
1265
+									'event_espresso'
1266
+								),
1267
+								$tab_id,
1268
+								key($config),
1269
+								$file_path
1270
+							),
1271
+							__FILE__,
1272
+							__FUNCTION__,
1273
+							__LINE__
1274
+						);
1275
+						return;
1276
+					}
1277
+					$template_args['admin_page_obj'] = $this;
1278
+					$content = EEH_Template::display_template(
1279
+						$file_path,
1280
+						$template_args,
1281
+						true
1282
+					);
1283
+				} else {
1284
+					$content = '';
1285
+				}
1286
+				// check if callback is valid
1287
+				if (empty($content) && (
1288
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1289
+					)
1290
+				) {
1291
+					EE_Error::add_error(
1292
+						sprintf(
1293
+							esc_html__(
1294
+								'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.',
1295
+								'event_espresso'
1296
+							),
1297
+							$cfg['title']
1298
+						),
1299
+						__FILE__,
1300
+						__FUNCTION__,
1301
+						__LINE__
1302
+					);
1303
+					return;
1304
+				}
1305
+				// setup config array for help tab method
1306
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1307
+				$_ht = array(
1308
+					'id'       => $id,
1309
+					'title'    => $cfg['title'],
1310
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1311
+					'content'  => $content,
1312
+				);
1313
+				$this->_current_screen->add_help_tab($_ht);
1314
+			}
1315
+		}
1316
+	}
1317
+
1318
+
1319
+	/**
1320
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1321
+	 * an array with properties for setting up usage of the joyride plugin
1322
+	 *
1323
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1324
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1325
+	 *         _set_page_config() comments
1326
+	 * @return void
1327
+	 * @throws EE_Error
1328
+	 * @throws InvalidArgumentException
1329
+	 * @throws InvalidDataTypeException
1330
+	 * @throws InvalidInterfaceException
1331
+	 */
1332
+	protected function _add_help_tour()
1333
+	{
1334
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1335
+		// $tours = array();
1336
+		// $this->_help_tour = array();
1337
+		// // exit early if help tours are turned off globally
1338
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1339
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1340
+		// ) {
1341
+		//     return;
1342
+		// }
1343
+		// // loop through _page_config to find any help_tour defined
1344
+		// foreach ($this->_page_config as $route => $config) {
1345
+		//     // we're only going to set things up for this route
1346
+		//     if ($route !== $this->_req_action) {
1347
+		//         continue;
1348
+		//     }
1349
+		//     if (isset($config['help_tour'])) {
1350
+		//         foreach ($config['help_tour'] as $tour) {
1351
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1352
+		//             // let's see if we can get that file...
1353
+		//             // if not its possible this is a decaf route not set in caffeinated
1354
+		//             // so lets try and get the caffeinated equivalent
1355
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1356
+		//                                                      . basename($this->_get_dir())
1357
+		//                                                      . '/help_tours/'
1358
+		//                                                      . $tour
1359
+		//                                                      . '.class.php' : $file_path;
1360
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1361
+		//             if (! is_readable($file_path)) {
1362
+		//                 EE_Error::add_error(
1363
+		//                     sprintf(
1364
+		//                         esc_html__(
1365
+		//                             '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',
1366
+		//                             'event_espresso'
1367
+		//                         ),
1368
+		//                         $file_path,
1369
+		//                         $tour
1370
+		//                     ),
1371
+		//                     __FILE__,
1372
+		//                     __FUNCTION__,
1373
+		//                     __LINE__
1374
+		//                 );
1375
+		//                 return;
1376
+		//             }
1377
+		//             require_once $file_path;
1378
+		//             if (! class_exists($tour)) {
1379
+		//                 $error_msg[] = sprintf(
1380
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1381
+		//                     $tour
1382
+		//                 );
1383
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1384
+		//                                . sprintf(
1385
+		//                                    esc_html__(
1386
+		//                                        '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.',
1387
+		//                                        'event_espresso'
1388
+		//                                    ),
1389
+		//                                    $tour,
1390
+		//                                    '<br />',
1391
+		//                                    $tour,
1392
+		//                                    $this->_req_action,
1393
+		//                                    get_class($this)
1394
+		//                                );
1395
+		//                 throw new EE_Error(implode('||', $error_msg));
1396
+		//             }
1397
+		//             $tour_obj = new $tour($this->_is_caf);
1398
+		//             $tours[] = $tour_obj;
1399
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1400
+		//         }
1401
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1402
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1403
+		//         $tours[] = $end_stop_tour;
1404
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1405
+		//     }
1406
+		// }
1407
+		//
1408
+		// if (! empty($tours)) {
1409
+		//     $this->_help_tour['tours'] = $tours;
1410
+		// }
1411
+		// // that's it!  Now that the $_help_tours property is set (or not)
1412
+		// // the scripts and html should be taken care of automatically.
1413
+		//
1414
+		// /**
1415
+		//  * Allow extending the help tours variable.
1416
+		//  *
1417
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1418
+		//  */
1419
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1420
+	}
1421
+
1422
+
1423
+	/**
1424
+	 * This simply sets up any qtips that have been defined in the page config
1425
+	 *
1426
+	 * @return void
1427
+	 */
1428
+	protected function _add_qtips()
1429
+	{
1430
+		if (isset($this->_route_config['qtips'])) {
1431
+			$qtips = (array) $this->_route_config['qtips'];
1432
+			// load qtip loader
1433
+			$path = array(
1434
+				$this->_get_dir() . '/qtips/',
1435
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1436
+			);
1437
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1438
+		}
1439
+	}
1440
+
1441
+
1442
+	/**
1443
+	 * _set_nav_tabs
1444
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1445
+	 * wish to add additional tabs or modify accordingly.
1446
+	 *
1447
+	 * @return void
1448
+	 * @throws InvalidArgumentException
1449
+	 * @throws InvalidInterfaceException
1450
+	 * @throws InvalidDataTypeException
1451
+	 */
1452
+	protected function _set_nav_tabs()
1453
+	{
1454
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1455
+		$i = 0;
1456
+		foreach ($this->_page_config as $slug => $config) {
1457
+			if (! is_array($config)
1458
+				|| (
1459
+					is_array($config)
1460
+					&& (
1461
+						(isset($config['nav']) && ! $config['nav'])
1462
+						|| ! isset($config['nav'])
1463
+					)
1464
+				)
1465
+			) {
1466
+				continue;
1467
+			}
1468
+			// no nav tab for this config
1469
+			// check for persistent flag
1470
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1471
+				// nav tab is only to appear when route requested.
1472
+				continue;
1473
+			}
1474
+			if (! $this->check_user_access($slug, true)) {
1475
+				// no nav tab because current user does not have access.
1476
+				continue;
1477
+			}
1478
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1479
+			$this->_nav_tabs[ $slug ] = array(
1480
+				'url'       => isset($config['nav']['url'])
1481
+					? $config['nav']['url']
1482
+					: self::add_query_args_and_nonce(
1483
+						array('action' => $slug),
1484
+						$this->_admin_base_url
1485
+					),
1486
+				'link_text' => isset($config['nav']['label'])
1487
+					? $config['nav']['label']
1488
+					: ucwords(
1489
+						str_replace('_', ' ', $slug)
1490
+					),
1491
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1492
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1493
+			);
1494
+			$i++;
1495
+		}
1496
+		// if $this->_nav_tabs is empty then lets set the default
1497
+		if (empty($this->_nav_tabs)) {
1498
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1499
+				'url'       => $this->_admin_base_url,
1500
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1501
+				'css_class' => 'nav-tab-active',
1502
+				'order'     => 10,
1503
+			);
1504
+		}
1505
+		// now let's sort the tabs according to order
1506
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1507
+	}
1508
+
1509
+
1510
+	/**
1511
+	 * _set_current_labels
1512
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1513
+	 * property array
1514
+	 *
1515
+	 * @return void
1516
+	 */
1517
+	private function _set_current_labels()
1518
+	{
1519
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1520
+			foreach ($this->_route_config['labels'] as $label => $text) {
1521
+				if (is_array($text)) {
1522
+					foreach ($text as $sublabel => $subtext) {
1523
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1524
+					}
1525
+				} else {
1526
+					$this->_labels[ $label ] = $text;
1527
+				}
1528
+			}
1529
+		}
1530
+	}
1531
+
1532
+
1533
+	/**
1534
+	 *        verifies user access for this admin page
1535
+	 *
1536
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1537
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1538
+	 *                               return false if verify fail.
1539
+	 * @return bool
1540
+	 * @throws InvalidArgumentException
1541
+	 * @throws InvalidDataTypeException
1542
+	 * @throws InvalidInterfaceException
1543
+	 */
1544
+	public function check_user_access($route_to_check = '', $verify_only = false)
1545
+	{
1546
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1547
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1548
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1549
+					  && is_array(
1550
+						  $this->_page_routes[ $route_to_check ]
1551
+					  )
1552
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1553
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1554
+		if (empty($capability) && empty($route_to_check)) {
1555
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1556
+				: $this->_route['capability'];
1557
+		} else {
1558
+			$capability = empty($capability) ? 'manage_options' : $capability;
1559
+		}
1560
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1561
+		if (! defined('DOING_AJAX')
1562
+			&& (
1563
+				! function_exists('is_admin')
1564
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1565
+					$capability,
1566
+					$this->page_slug
1567
+					. '_'
1568
+					. $route_to_check,
1569
+					$id
1570
+				)
1571
+			)
1572
+		) {
1573
+			if ($verify_only) {
1574
+				return false;
1575
+			}
1576
+			if (is_user_logged_in()) {
1577
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1578
+			} else {
1579
+				return false;
1580
+			}
1581
+		}
1582
+		return true;
1583
+	}
1584
+
1585
+
1586
+	/**
1587
+	 * admin_init_global
1588
+	 * This runs all the code that we want executed within the WP admin_init hook.
1589
+	 * This method executes for ALL EE Admin pages.
1590
+	 *
1591
+	 * @return void
1592
+	 */
1593
+	public function admin_init_global()
1594
+	{
1595
+	}
1596
+
1597
+
1598
+	/**
1599
+	 * wp_loaded_global
1600
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1601
+	 * EE_Admin page and will execute on every EE Admin Page load
1602
+	 *
1603
+	 * @return void
1604
+	 */
1605
+	public function wp_loaded()
1606
+	{
1607
+	}
1608
+
1609
+
1610
+	/**
1611
+	 * admin_notices
1612
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1613
+	 * ALL EE_Admin pages.
1614
+	 *
1615
+	 * @return void
1616
+	 */
1617
+	public function admin_notices_global()
1618
+	{
1619
+		$this->_display_no_javascript_warning();
1620
+		$this->_display_espresso_notices();
1621
+	}
1622
+
1623
+
1624
+	public function network_admin_notices_global()
1625
+	{
1626
+		$this->_display_no_javascript_warning();
1627
+		$this->_display_espresso_notices();
1628
+	}
1629
+
1630
+
1631
+	/**
1632
+	 * admin_footer_scripts_global
1633
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1634
+	 * will apply on ALL EE_Admin pages.
1635
+	 *
1636
+	 * @return void
1637
+	 */
1638
+	public function admin_footer_scripts_global()
1639
+	{
1640
+		$this->_add_admin_page_ajax_loading_img();
1641
+		$this->_add_admin_page_overlay();
1642
+		// if metaboxes are present we need to add the nonce field
1643
+		if (isset($this->_route_config['metaboxes'])
1644
+			|| isset($this->_route_config['list_table'])
1645
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1646
+		) {
1647
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1648
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1649
+		}
1650
+	}
1651
+
1652
+
1653
+	/**
1654
+	 * admin_footer_global
1655
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1656
+	 * ALL EE_Admin Pages.
1657
+	 *
1658
+	 * @return void
1659
+	 * @throws EE_Error
1660
+	 */
1661
+	public function admin_footer_global()
1662
+	{
1663
+		// dialog container for dialog helper
1664
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1665
+		$d_cont .= '<div class="ee-notices"></div>';
1666
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1667
+		$d_cont .= '</div>';
1668
+		echo $d_cont;
1669
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1670
+		// help tour stuff?
1671
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1672
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1673
+		// }
1674
+		// current set timezone for timezone js
1675
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1676
+	}
1677
+
1678
+
1679
+	/**
1680
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1681
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1682
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1683
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1684
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1685
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1686
+	 * for the
1687
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1688
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1689
+	 *    'help_trigger_id' => array(
1690
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1691
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1692
+	 *    )
1693
+	 * );
1694
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1695
+	 *
1696
+	 * @param array $help_array
1697
+	 * @param bool  $display
1698
+	 * @return string content
1699
+	 * @throws DomainException
1700
+	 * @throws EE_Error
1701
+	 */
1702
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1703
+	{
1704
+		$content = '';
1705
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1706
+		// loop through the array and setup content
1707
+		foreach ($help_array as $trigger => $help) {
1708
+			// make sure the array is setup properly
1709
+			if (! isset($help['title']) || ! isset($help['content'])) {
1710
+				throw new EE_Error(
1711
+					esc_html__(
1712
+						'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',
1713
+						'event_espresso'
1714
+					)
1715
+				);
1716
+			}
1717
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1718
+			$template_args = array(
1719
+				'help_popup_id'      => $trigger,
1720
+				'help_popup_title'   => $help['title'],
1721
+				'help_popup_content' => $help['content'],
1722
+			);
1723
+			$content .= EEH_Template::display_template(
1724
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1725
+				$template_args,
1726
+				true
1727
+			);
1728
+		}
1729
+		if ($display) {
1730
+			echo $content;
1731
+			return '';
1732
+		}
1733
+		return $content;
1734
+	}
1735
+
1736
+
1737
+	/**
1738
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1739
+	 *
1740
+	 * @return array properly formatted array for help popup content
1741
+	 * @throws EE_Error
1742
+	 */
1743
+	private function _get_help_content()
1744
+	{
1745
+		// what is the method we're looking for?
1746
+		$method_name = '_help_popup_content_' . $this->_req_action;
1747
+		// if method doesn't exist let's get out.
1748
+		if (! method_exists($this, $method_name)) {
1749
+			return array();
1750
+		}
1751
+		// k we're good to go let's retrieve the help array
1752
+		$help_array = call_user_func(array($this, $method_name));
1753
+		// make sure we've got an array!
1754
+		if (! is_array($help_array)) {
1755
+			throw new EE_Error(
1756
+				esc_html__(
1757
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1758
+					'event_espresso'
1759
+				)
1760
+			);
1761
+		}
1762
+		return $help_array;
1763
+	}
1764
+
1765
+
1766
+	/**
1767
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1768
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1769
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1770
+	 *
1771
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1772
+	 * @param boolean $display    if false then we return the trigger string
1773
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1774
+	 * @return string
1775
+	 * @throws DomainException
1776
+	 * @throws EE_Error
1777
+	 */
1778
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1779
+	{
1780
+		if (defined('DOING_AJAX')) {
1781
+			return '';
1782
+		}
1783
+		// 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
1784
+		$help_array = $this->_get_help_content();
1785
+		$help_content = '';
1786
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1787
+			$help_array[ $trigger_id ] = array(
1788
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1789
+				'content' => esc_html__(
1790
+					'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.)',
1791
+					'event_espresso'
1792
+				),
1793
+			);
1794
+			$help_content = $this->_set_help_popup_content($help_array, false);
1795
+		}
1796
+		// let's setup the trigger
1797
+		$content = '<a class="ee-dialog" href="?height='
1798
+				   . $dimensions[0]
1799
+				   . '&width='
1800
+				   . $dimensions[1]
1801
+				   . '&inlineId='
1802
+				   . $trigger_id
1803
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1804
+		$content .= $help_content;
1805
+		if ($display) {
1806
+			echo $content;
1807
+			return '';
1808
+		}
1809
+		return $content;
1810
+	}
1811
+
1812
+
1813
+	/**
1814
+	 * _add_global_screen_options
1815
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1816
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1817
+	 *
1818
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1819
+	 *         see also WP_Screen object documents...
1820
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1821
+	 * @abstract
1822
+	 * @return void
1823
+	 */
1824
+	private function _add_global_screen_options()
1825
+	{
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * _add_global_feature_pointers
1831
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1832
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1833
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1834
+	 *
1835
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1836
+	 *         extended) also see:
1837
+	 * @link   http://eamann.com/tech/wordpress-portland/
1838
+	 * @abstract
1839
+	 * @return void
1840
+	 */
1841
+	private function _add_global_feature_pointers()
1842
+	{
1843
+	}
1844
+
1845
+
1846
+	/**
1847
+	 * load_global_scripts_styles
1848
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1849
+	 *
1850
+	 * @return void
1851
+	 * @throws EE_Error
1852
+	 */
1853
+	public function load_global_scripts_styles()
1854
+	{
1855
+		/** STYLES **/
1856
+		// add debugging styles
1857
+		if (WP_DEBUG) {
1858
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1859
+		}
1860
+		// register all styles
1861
+		wp_register_style(
1862
+			'espresso-ui-theme',
1863
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1864
+			array(),
1865
+			EVENT_ESPRESSO_VERSION
1866
+		);
1867
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1868
+		// helpers styles
1869
+		wp_register_style(
1870
+			'ee-text-links',
1871
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1872
+			array(),
1873
+			EVENT_ESPRESSO_VERSION
1874
+		);
1875
+		/** SCRIPTS **/
1876
+		// register all scripts
1877
+		wp_register_script(
1878
+			'ee-dialog',
1879
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1880
+			array('jquery', 'jquery-ui-draggable'),
1881
+			EVENT_ESPRESSO_VERSION,
1882
+			true
1883
+		);
1884
+		wp_register_script(
1885
+			'ee_admin_js',
1886
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1887
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1888
+			EVENT_ESPRESSO_VERSION,
1889
+			true
1890
+		);
1891
+		wp_register_script(
1892
+			'jquery-ui-timepicker-addon',
1893
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1894
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1895
+			EVENT_ESPRESSO_VERSION,
1896
+			true
1897
+		);
1898
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1899
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1900
+		//     add_filter('FHEE_load_joyride', '__return_true');
1901
+		// }
1902
+		// script for sorting tables
1903
+		wp_register_script(
1904
+			'espresso_ajax_table_sorting',
1905
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1906
+			array('ee_admin_js', 'jquery-ui-sortable'),
1907
+			EVENT_ESPRESSO_VERSION,
1908
+			true
1909
+		);
1910
+		// script for parsing uri's
1911
+		wp_register_script(
1912
+			'ee-parse-uri',
1913
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1914
+			array(),
1915
+			EVENT_ESPRESSO_VERSION,
1916
+			true
1917
+		);
1918
+		// and parsing associative serialized form elements
1919
+		wp_register_script(
1920
+			'ee-serialize-full-array',
1921
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1922
+			array('jquery'),
1923
+			EVENT_ESPRESSO_VERSION,
1924
+			true
1925
+		);
1926
+		// helpers scripts
1927
+		wp_register_script(
1928
+			'ee-text-links',
1929
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1930
+			array('jquery'),
1931
+			EVENT_ESPRESSO_VERSION,
1932
+			true
1933
+		);
1934
+		wp_register_script(
1935
+			'ee-moment-core',
1936
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1937
+			array(),
1938
+			EVENT_ESPRESSO_VERSION,
1939
+			true
1940
+		);
1941
+		wp_register_script(
1942
+			'ee-moment',
1943
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1944
+			array('ee-moment-core'),
1945
+			EVENT_ESPRESSO_VERSION,
1946
+			true
1947
+		);
1948
+		wp_register_script(
1949
+			'ee-datepicker',
1950
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1951
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1952
+			EVENT_ESPRESSO_VERSION,
1953
+			true
1954
+		);
1955
+		// google charts
1956
+		wp_register_script(
1957
+			'google-charts',
1958
+			'https://www.gstatic.com/charts/loader.js',
1959
+			array(),
1960
+			EVENT_ESPRESSO_VERSION,
1961
+			false
1962
+		);
1963
+		// ENQUEUE ALL BASICS BY DEFAULT
1964
+		wp_enqueue_style('ee-admin-css');
1965
+		wp_enqueue_script('ee_admin_js');
1966
+		wp_enqueue_script('ee-accounting');
1967
+		wp_enqueue_script('jquery-validate');
1968
+		// taking care of metaboxes
1969
+		if (empty($this->_cpt_route)
1970
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1971
+		) {
1972
+			wp_enqueue_script('dashboard');
1973
+		}
1974
+		// LOCALIZED DATA
1975
+		// localize script for ajax lazy loading
1976
+		$lazy_loader_container_ids = apply_filters(
1977
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1978
+			array('espresso_news_post_box_content')
1979
+		);
1980
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1981
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1982
+		// /**
1983
+		//  * help tour stuff
1984
+		//  */
1985
+		// if (! empty($this->_help_tour)) {
1986
+		//     // register the js for kicking things off
1987
+		//     wp_enqueue_script(
1988
+		//         'ee-help-tour',
1989
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
1990
+		//         array('jquery-joyride'),
1991
+		//         EVENT_ESPRESSO_VERSION,
1992
+		//         true
1993
+		//     );
1994
+		//     $tours = array();
1995
+		//     // setup tours for the js tour object
1996
+		//     foreach ($this->_help_tour['tours'] as $tour) {
1997
+		//         if ($tour instanceof EE_Help_Tour) {
1998
+		//             $tours[] = array(
1999
+		//                 'id'      => $tour->get_slug(),
2000
+		//                 'options' => $tour->get_options(),
2001
+		//             );
2002
+		//         }
2003
+		//     }
2004
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2005
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2006
+		// }
2007
+	}
2008
+
2009
+
2010
+	/**
2011
+	 *        admin_footer_scripts_eei18n_js_strings
2012
+	 *
2013
+	 * @return        void
2014
+	 */
2015
+	public function admin_footer_scripts_eei18n_js_strings()
2016
+	{
2017
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2018
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2019
+			'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!!!',
2020
+			'event_espresso'
2021
+		);
2022
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2023
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2024
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2025
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2026
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2027
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2028
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2029
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2030
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2031
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2032
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2033
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2034
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2035
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2036
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2037
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2038
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2039
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2040
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2041
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2042
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2043
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2044
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2045
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2046
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2047
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2048
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2049
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2050
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2051
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2052
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2053
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2054
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2055
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2056
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2057
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2058
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2059
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2060
+	}
2061
+
2062
+
2063
+	/**
2064
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2065
+	 *
2066
+	 * @return        void
2067
+	 */
2068
+	public function add_xdebug_style()
2069
+	{
2070
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2071
+	}
2072
+
2073
+
2074
+	/************************/
2075
+	/** LIST TABLE METHODS **/
2076
+	/************************/
2077
+	/**
2078
+	 * this sets up the list table if the current view requires it.
2079
+	 *
2080
+	 * @return void
2081
+	 * @throws EE_Error
2082
+	 */
2083
+	protected function _set_list_table()
2084
+	{
2085
+		// first is this a list_table view?
2086
+		if (! isset($this->_route_config['list_table'])) {
2087
+			return;
2088
+		} //not a list_table view so get out.
2089
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2090
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2091
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2092
+			// user error msg
2093
+			$error_msg = esc_html__(
2094
+				'An error occurred. The requested list table views could not be found.',
2095
+				'event_espresso'
2096
+			);
2097
+			// developer error msg
2098
+			$error_msg .= '||'
2099
+						  . sprintf(
2100
+							  esc_html__(
2101
+								  '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.',
2102
+								  'event_espresso'
2103
+							  ),
2104
+							  $this->_req_action,
2105
+							  $list_table_view
2106
+						  );
2107
+			throw new EE_Error($error_msg);
2108
+		}
2109
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2110
+		$this->_views = apply_filters(
2111
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2112
+			$this->_views
2113
+		);
2114
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2115
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2116
+		$this->_set_list_table_view();
2117
+		$this->_set_list_table_object();
2118
+	}
2119
+
2120
+
2121
+	/**
2122
+	 * set current view for List Table
2123
+	 *
2124
+	 * @return void
2125
+	 */
2126
+	protected function _set_list_table_view()
2127
+	{
2128
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2129
+		// looking at active items or dumpster diving ?
2130
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2131
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2132
+		} else {
2133
+			$this->_view = sanitize_key($this->_req_data['status']);
2134
+		}
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 * _set_list_table_object
2140
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2141
+	 *
2142
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2143
+	 * @throws \InvalidArgumentException
2144
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2145
+	 * @throws EE_Error
2146
+	 * @throws InvalidInterfaceException
2147
+	 */
2148
+	protected function _set_list_table_object()
2149
+	{
2150
+		if (isset($this->_route_config['list_table'])) {
2151
+			if (! class_exists($this->_route_config['list_table'])) {
2152
+				throw new EE_Error(
2153
+					sprintf(
2154
+						esc_html__(
2155
+							'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.',
2156
+							'event_espresso'
2157
+						),
2158
+						$this->_route_config['list_table'],
2159
+						get_class($this)
2160
+					)
2161
+				);
2162
+			}
2163
+			$this->_list_table_object = $this->loader->getShared(
2164
+				$this->_route_config['list_table'],
2165
+				array($this)
2166
+			);
2167
+		}
2168
+	}
2169
+
2170
+
2171
+	/**
2172
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2173
+	 *
2174
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2175
+	 *                                                    urls.  The array should be indexed by the view it is being
2176
+	 *                                                    added to.
2177
+	 * @return array
2178
+	 */
2179
+	public function get_list_table_view_RLs($extra_query_args = array())
2180
+	{
2181
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2182
+		if (empty($this->_views)) {
2183
+			$this->_views = array();
2184
+		}
2185
+		// cycle thru views
2186
+		foreach ($this->_views as $key => $view) {
2187
+			$query_args = array();
2188
+			// check for current view
2189
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2190
+			$query_args['action'] = $this->_req_action;
2191
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2192
+			$query_args['status'] = $view['slug'];
2193
+			// merge any other arguments sent in.
2194
+			if (isset($extra_query_args[ $view['slug'] ])) {
2195
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2196
+			}
2197
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2198
+		}
2199
+		return $this->_views;
2200
+	}
2201
+
2202
+
2203
+	/**
2204
+	 * _entries_per_page_dropdown
2205
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2206
+	 *
2207
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2208
+	 *         WP does it.
2209
+	 * @param int $max_entries total number of rows in the table
2210
+	 * @return string
2211
+	 */
2212
+	protected function _entries_per_page_dropdown($max_entries = 0)
2213
+	{
2214
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2215
+		$values = array(10, 25, 50, 100);
2216
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2217
+		if ($max_entries) {
2218
+			$values[] = $max_entries;
2219
+			sort($values);
2220
+		}
2221
+		$entries_per_page_dropdown = '
2222 2222
 			<div id="entries-per-page-dv" class="alignleft actions">
2223 2223
 				<label class="hide-if-no-js">
2224 2224
 					Show
2225 2225
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2226
-        foreach ($values as $value) {
2227
-            if ($value < $max_entries) {
2228
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2229
-                $entries_per_page_dropdown .= '
2226
+		foreach ($values as $value) {
2227
+			if ($value < $max_entries) {
2228
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2229
+				$entries_per_page_dropdown .= '
2230 2230
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2231
-            }
2232
-        }
2233
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2234
-        $entries_per_page_dropdown .= '
2231
+			}
2232
+		}
2233
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2234
+		$entries_per_page_dropdown .= '
2235 2235
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2236
-        $entries_per_page_dropdown .= '
2236
+		$entries_per_page_dropdown .= '
2237 2237
 					</select>
2238 2238
 					entries
2239 2239
 				</label>
2240 2240
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2241 2241
 			</div>
2242 2242
 		';
2243
-        return $entries_per_page_dropdown;
2244
-    }
2245
-
2246
-
2247
-    /**
2248
-     *        _set_search_attributes
2249
-     *
2250
-     * @return        void
2251
-     */
2252
-    public function _set_search_attributes()
2253
-    {
2254
-        $this->_template_args['search']['btn_label'] = sprintf(
2255
-            esc_html__('Search %s', 'event_espresso'),
2256
-            empty($this->_search_btn_label) ? $this->page_label
2257
-                : $this->_search_btn_label
2258
-        );
2259
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2260
-    }
2261
-
2262
-
2263
-
2264
-    /*** END LIST TABLE METHODS **/
2265
-
2266
-
2267
-    /**
2268
-     * _add_registered_metaboxes
2269
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2270
-     *
2271
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2272
-     * @return void
2273
-     * @throws EE_Error
2274
-     */
2275
-    private function _add_registered_meta_boxes()
2276
-    {
2277
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2278
-        // we only add meta boxes if the page_route calls for it
2279
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2280
-            && is_array(
2281
-                $this->_route_config['metaboxes']
2282
-            )
2283
-        ) {
2284
-            // this simply loops through the callbacks provided
2285
-            // and checks if there is a corresponding callback registered by the child
2286
-            // if there is then we go ahead and process the metabox loader.
2287
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2288
-                // first check for Closures
2289
-                if ($metabox_callback instanceof Closure) {
2290
-                    $result = $metabox_callback();
2291
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2292
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2293
-                } else {
2294
-                    $result = call_user_func(array($this, &$metabox_callback));
2295
-                }
2296
-                if ($result === false) {
2297
-                    // user error msg
2298
-                    $error_msg = esc_html__(
2299
-                        'An error occurred. The  requested metabox could not be found.',
2300
-                        'event_espresso'
2301
-                    );
2302
-                    // developer error msg
2303
-                    $error_msg .= '||'
2304
-                                  . sprintf(
2305
-                                      esc_html__(
2306
-                                          '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.',
2307
-                                          'event_espresso'
2308
-                                      ),
2309
-                                      $metabox_callback
2310
-                                  );
2311
-                    throw new EE_Error($error_msg);
2312
-                }
2313
-            }
2314
-        }
2315
-    }
2316
-
2317
-
2318
-    /**
2319
-     * _add_screen_columns
2320
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2321
-     * the dynamic column template and we'll setup the column options for the page.
2322
-     *
2323
-     * @return void
2324
-     */
2325
-    private function _add_screen_columns()
2326
-    {
2327
-        if (is_array($this->_route_config)
2328
-            && isset($this->_route_config['columns'])
2329
-            && is_array($this->_route_config['columns'])
2330
-            && count($this->_route_config['columns']) === 2
2331
-        ) {
2332
-            add_screen_option(
2333
-                'layout_columns',
2334
-                array(
2335
-                    'max'     => (int) $this->_route_config['columns'][0],
2336
-                    'default' => (int) $this->_route_config['columns'][1],
2337
-                )
2338
-            );
2339
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2340
-            $screen_id = $this->_current_screen->id;
2341
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2342
-            $total_columns = ! empty($screen_columns)
2343
-                ? $screen_columns
2344
-                : $this->_route_config['columns'][1];
2345
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2346
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2347
-            $this->_template_args['screen'] = $this->_current_screen;
2348
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2349
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2350
-            // finally if we don't have has_metaboxes set in the route config
2351
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2352
-            $this->_route_config['has_metaboxes'] = true;
2353
-        }
2354
-    }
2355
-
2356
-
2357
-
2358
-    /** GLOBALLY AVAILABLE METABOXES **/
2359
-
2360
-
2361
-    /**
2362
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2363
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2364
-     * these get loaded on.
2365
-     */
2366
-    private function _espresso_news_post_box()
2367
-    {
2368
-        $news_box_title = apply_filters(
2369
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2370
-            esc_html__('New @ Event Espresso', 'event_espresso')
2371
-        );
2372
-        add_meta_box(
2373
-            'espresso_news_post_box',
2374
-            $news_box_title,
2375
-            array(
2376
-                $this,
2377
-                'espresso_news_post_box',
2378
-            ),
2379
-            $this->_wp_page_slug,
2380
-            'side'
2381
-        );
2382
-    }
2383
-
2384
-
2385
-    /**
2386
-     * Code for setting up espresso ratings request metabox.
2387
-     */
2388
-    protected function _espresso_ratings_request()
2389
-    {
2390
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2391
-            return;
2392
-        }
2393
-        $ratings_box_title = apply_filters(
2394
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2395
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2396
-        );
2397
-        add_meta_box(
2398
-            'espresso_ratings_request',
2399
-            $ratings_box_title,
2400
-            array(
2401
-                $this,
2402
-                'espresso_ratings_request',
2403
-            ),
2404
-            $this->_wp_page_slug,
2405
-            'side'
2406
-        );
2407
-    }
2408
-
2409
-
2410
-    /**
2411
-     * Code for setting up espresso ratings request metabox content.
2412
-     *
2413
-     * @throws DomainException
2414
-     */
2415
-    public function espresso_ratings_request()
2416
-    {
2417
-        EEH_Template::display_template(
2418
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2419
-            array()
2420
-        );
2421
-    }
2422
-
2423
-
2424
-    public static function cached_rss_display($rss_id, $url)
2425
-    {
2426
-        $loading = '<p class="widget-loading hide-if-no-js">'
2427
-                   . __('Loading&#8230;', 'event_espresso')
2428
-                   . '</p><p class="hide-if-js">'
2429
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2430
-                   . '</p>';
2431
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2432
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2433
-        $post = '</div>' . "\n";
2434
-        $cache_key = 'ee_rss_' . md5($rss_id);
2435
-        $output = get_transient($cache_key);
2436
-        if ($output !== false) {
2437
-            echo $pre . $output . $post;
2438
-            return true;
2439
-        }
2440
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2441
-            echo $pre . $loading . $post;
2442
-            return false;
2443
-        }
2444
-        ob_start();
2445
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2446
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2447
-        return true;
2448
-    }
2449
-
2450
-
2451
-    public function espresso_news_post_box()
2452
-    {
2453
-        ?>
2243
+		return $entries_per_page_dropdown;
2244
+	}
2245
+
2246
+
2247
+	/**
2248
+	 *        _set_search_attributes
2249
+	 *
2250
+	 * @return        void
2251
+	 */
2252
+	public function _set_search_attributes()
2253
+	{
2254
+		$this->_template_args['search']['btn_label'] = sprintf(
2255
+			esc_html__('Search %s', 'event_espresso'),
2256
+			empty($this->_search_btn_label) ? $this->page_label
2257
+				: $this->_search_btn_label
2258
+		);
2259
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2260
+	}
2261
+
2262
+
2263
+
2264
+	/*** END LIST TABLE METHODS **/
2265
+
2266
+
2267
+	/**
2268
+	 * _add_registered_metaboxes
2269
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2270
+	 *
2271
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2272
+	 * @return void
2273
+	 * @throws EE_Error
2274
+	 */
2275
+	private function _add_registered_meta_boxes()
2276
+	{
2277
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2278
+		// we only add meta boxes if the page_route calls for it
2279
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2280
+			&& is_array(
2281
+				$this->_route_config['metaboxes']
2282
+			)
2283
+		) {
2284
+			// this simply loops through the callbacks provided
2285
+			// and checks if there is a corresponding callback registered by the child
2286
+			// if there is then we go ahead and process the metabox loader.
2287
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2288
+				// first check for Closures
2289
+				if ($metabox_callback instanceof Closure) {
2290
+					$result = $metabox_callback();
2291
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2292
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2293
+				} else {
2294
+					$result = call_user_func(array($this, &$metabox_callback));
2295
+				}
2296
+				if ($result === false) {
2297
+					// user error msg
2298
+					$error_msg = esc_html__(
2299
+						'An error occurred. The  requested metabox could not be found.',
2300
+						'event_espresso'
2301
+					);
2302
+					// developer error msg
2303
+					$error_msg .= '||'
2304
+								  . sprintf(
2305
+									  esc_html__(
2306
+										  '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.',
2307
+										  'event_espresso'
2308
+									  ),
2309
+									  $metabox_callback
2310
+								  );
2311
+					throw new EE_Error($error_msg);
2312
+				}
2313
+			}
2314
+		}
2315
+	}
2316
+
2317
+
2318
+	/**
2319
+	 * _add_screen_columns
2320
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2321
+	 * the dynamic column template and we'll setup the column options for the page.
2322
+	 *
2323
+	 * @return void
2324
+	 */
2325
+	private function _add_screen_columns()
2326
+	{
2327
+		if (is_array($this->_route_config)
2328
+			&& isset($this->_route_config['columns'])
2329
+			&& is_array($this->_route_config['columns'])
2330
+			&& count($this->_route_config['columns']) === 2
2331
+		) {
2332
+			add_screen_option(
2333
+				'layout_columns',
2334
+				array(
2335
+					'max'     => (int) $this->_route_config['columns'][0],
2336
+					'default' => (int) $this->_route_config['columns'][1],
2337
+				)
2338
+			);
2339
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2340
+			$screen_id = $this->_current_screen->id;
2341
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2342
+			$total_columns = ! empty($screen_columns)
2343
+				? $screen_columns
2344
+				: $this->_route_config['columns'][1];
2345
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2346
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2347
+			$this->_template_args['screen'] = $this->_current_screen;
2348
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2349
+										   . 'admin_details_metabox_column_wrapper.template.php';
2350
+			// finally if we don't have has_metaboxes set in the route config
2351
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2352
+			$this->_route_config['has_metaboxes'] = true;
2353
+		}
2354
+	}
2355
+
2356
+
2357
+
2358
+	/** GLOBALLY AVAILABLE METABOXES **/
2359
+
2360
+
2361
+	/**
2362
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2363
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2364
+	 * these get loaded on.
2365
+	 */
2366
+	private function _espresso_news_post_box()
2367
+	{
2368
+		$news_box_title = apply_filters(
2369
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2370
+			esc_html__('New @ Event Espresso', 'event_espresso')
2371
+		);
2372
+		add_meta_box(
2373
+			'espresso_news_post_box',
2374
+			$news_box_title,
2375
+			array(
2376
+				$this,
2377
+				'espresso_news_post_box',
2378
+			),
2379
+			$this->_wp_page_slug,
2380
+			'side'
2381
+		);
2382
+	}
2383
+
2384
+
2385
+	/**
2386
+	 * Code for setting up espresso ratings request metabox.
2387
+	 */
2388
+	protected function _espresso_ratings_request()
2389
+	{
2390
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2391
+			return;
2392
+		}
2393
+		$ratings_box_title = apply_filters(
2394
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2395
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2396
+		);
2397
+		add_meta_box(
2398
+			'espresso_ratings_request',
2399
+			$ratings_box_title,
2400
+			array(
2401
+				$this,
2402
+				'espresso_ratings_request',
2403
+			),
2404
+			$this->_wp_page_slug,
2405
+			'side'
2406
+		);
2407
+	}
2408
+
2409
+
2410
+	/**
2411
+	 * Code for setting up espresso ratings request metabox content.
2412
+	 *
2413
+	 * @throws DomainException
2414
+	 */
2415
+	public function espresso_ratings_request()
2416
+	{
2417
+		EEH_Template::display_template(
2418
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2419
+			array()
2420
+		);
2421
+	}
2422
+
2423
+
2424
+	public static function cached_rss_display($rss_id, $url)
2425
+	{
2426
+		$loading = '<p class="widget-loading hide-if-no-js">'
2427
+				   . __('Loading&#8230;', 'event_espresso')
2428
+				   . '</p><p class="hide-if-js">'
2429
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2430
+				   . '</p>';
2431
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2432
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2433
+		$post = '</div>' . "\n";
2434
+		$cache_key = 'ee_rss_' . md5($rss_id);
2435
+		$output = get_transient($cache_key);
2436
+		if ($output !== false) {
2437
+			echo $pre . $output . $post;
2438
+			return true;
2439
+		}
2440
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2441
+			echo $pre . $loading . $post;
2442
+			return false;
2443
+		}
2444
+		ob_start();
2445
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2446
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2447
+		return true;
2448
+	}
2449
+
2450
+
2451
+	public function espresso_news_post_box()
2452
+	{
2453
+		?>
2454 2454
         <div class="padding">
2455 2455
             <div id="espresso_news_post_box_content" class="infolinks">
2456 2456
                 <?php
2457
-                // Get RSS Feed(s)
2458
-                self::cached_rss_display(
2459
-                    'espresso_news_post_box_content',
2460
-                    urlencode(
2461
-                        apply_filters(
2462
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2463
-                            'http://eventespresso.com/feed/'
2464
-                        )
2465
-                    )
2466
-                );
2467
-                ?>
2457
+				// Get RSS Feed(s)
2458
+				self::cached_rss_display(
2459
+					'espresso_news_post_box_content',
2460
+					urlencode(
2461
+						apply_filters(
2462
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2463
+							'http://eventespresso.com/feed/'
2464
+						)
2465
+					)
2466
+				);
2467
+				?>
2468 2468
             </div>
2469 2469
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2470 2470
         </div>
2471 2471
         <?php
2472
-    }
2473
-
2474
-
2475
-    private function _espresso_links_post_box()
2476
-    {
2477
-        // Hiding until we actually have content to put in here...
2478
-        // 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');
2479
-    }
2480
-
2481
-
2482
-    public function espresso_links_post_box()
2483
-    {
2484
-        // Hiding until we actually have content to put in here...
2485
-        // EEH_Template::display_template(
2486
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2487
-        // );
2488
-    }
2489
-
2490
-
2491
-    protected function _espresso_sponsors_post_box()
2492
-    {
2493
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2494
-            add_meta_box(
2495
-                'espresso_sponsors_post_box',
2496
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2497
-                array($this, 'espresso_sponsors_post_box'),
2498
-                $this->_wp_page_slug,
2499
-                'side'
2500
-            );
2501
-        }
2502
-    }
2503
-
2504
-
2505
-    public function espresso_sponsors_post_box()
2506
-    {
2507
-        EEH_Template::display_template(
2508
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2509
-        );
2510
-    }
2511
-
2512
-
2513
-    private function _publish_post_box()
2514
-    {
2515
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2516
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2517
-        // then we'll use that for the metabox label.
2518
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2519
-        if (! empty($this->_labels['publishbox'])) {
2520
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2521
-                : $this->_labels['publishbox'];
2522
-        } else {
2523
-            $box_label = esc_html__('Publish', 'event_espresso');
2524
-        }
2525
-        $box_label = apply_filters(
2526
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2527
-            $box_label,
2528
-            $this->_req_action,
2529
-            $this
2530
-        );
2531
-        add_meta_box(
2532
-            $meta_box_ref,
2533
-            $box_label,
2534
-            array($this, 'editor_overview'),
2535
-            $this->_current_screen->id,
2536
-            'side',
2537
-            'high'
2538
-        );
2539
-    }
2540
-
2541
-
2542
-    public function editor_overview()
2543
-    {
2544
-        // if we have extra content set let's add it in if not make sure its empty
2545
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2546
-            ? $this->_template_args['publish_box_extra_content']
2547
-            : '';
2548
-        echo EEH_Template::display_template(
2549
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2550
-            $this->_template_args,
2551
-            true
2552
-        );
2553
-    }
2554
-
2555
-
2556
-    /** end of globally available metaboxes section **/
2557
-
2558
-
2559
-    /**
2560
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2561
-     * protected method.
2562
-     *
2563
-     * @see   $this->_set_publish_post_box_vars for param details
2564
-     * @since 4.6.0
2565
-     * @param string $name
2566
-     * @param int    $id
2567
-     * @param bool   $delete
2568
-     * @param string $save_close_redirect_URL
2569
-     * @param bool   $both_btns
2570
-     * @throws EE_Error
2571
-     * @throws InvalidArgumentException
2572
-     * @throws InvalidDataTypeException
2573
-     * @throws InvalidInterfaceException
2574
-     */
2575
-    public function set_publish_post_box_vars(
2576
-        $name = '',
2577
-        $id = 0,
2578
-        $delete = false,
2579
-        $save_close_redirect_URL = '',
2580
-        $both_btns = true
2581
-    ) {
2582
-        $this->_set_publish_post_box_vars(
2583
-            $name,
2584
-            $id,
2585
-            $delete,
2586
-            $save_close_redirect_URL,
2587
-            $both_btns
2588
-        );
2589
-    }
2590
-
2591
-
2592
-    /**
2593
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2594
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2595
-     * save, and save and close buttons to work properly, then you will want to include a
2596
-     * values for the name and id arguments.
2597
-     *
2598
-     * @todo  Add in validation for name/id arguments.
2599
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2600
-     * @param    int     $id                      id attached to the item published
2601
-     * @param    string  $delete                  page route callback for the delete action
2602
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2603
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2604
-     *                                            the Save button
2605
-     * @throws EE_Error
2606
-     * @throws InvalidArgumentException
2607
-     * @throws InvalidDataTypeException
2608
-     * @throws InvalidInterfaceException
2609
-     */
2610
-    protected function _set_publish_post_box_vars(
2611
-        $name = '',
2612
-        $id = 0,
2613
-        $delete = '',
2614
-        $save_close_redirect_URL = '',
2615
-        $both_btns = true
2616
-    ) {
2617
-        // if Save & Close, use a custom redirect URL or default to the main page?
2618
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2619
-            ? $save_close_redirect_URL
2620
-            : $this->_admin_base_url;
2621
-        // create the Save & Close and Save buttons
2622
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2623
-        // if we have extra content set let's add it in if not make sure its empty
2624
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2625
-            ? $this->_template_args['publish_box_extra_content']
2626
-            : '';
2627
-        if ($delete && ! empty($id)) {
2628
-            // make sure we have a default if just true is sent.
2629
-            $delete = ! empty($delete) ? $delete : 'delete';
2630
-            $delete_link_args = array($name => $id);
2631
-            $delete = $this->get_action_link_or_button(
2632
-                $delete,
2633
-                $delete,
2634
-                $delete_link_args,
2635
-                'submitdelete deletion',
2636
-                '',
2637
-                false
2638
-            );
2639
-        }
2640
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2641
-        if (! empty($name) && ! empty($id)) {
2642
-            $hidden_field_arr[ $name ] = array(
2643
-                'type'  => 'hidden',
2644
-                'value' => $id,
2645
-            );
2646
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2647
-        } else {
2648
-            $hf = '';
2649
-        }
2650
-        // add hidden field
2651
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2652
-            ? $hf[ $name ]['field']
2653
-            : $hf;
2654
-    }
2655
-
2656
-
2657
-    /**
2658
-     * displays an error message to ppl who have javascript disabled
2659
-     *
2660
-     * @return void
2661
-     */
2662
-    private function _display_no_javascript_warning()
2663
-    {
2664
-        ?>
2472
+	}
2473
+
2474
+
2475
+	private function _espresso_links_post_box()
2476
+	{
2477
+		// Hiding until we actually have content to put in here...
2478
+		// 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');
2479
+	}
2480
+
2481
+
2482
+	public function espresso_links_post_box()
2483
+	{
2484
+		// Hiding until we actually have content to put in here...
2485
+		// EEH_Template::display_template(
2486
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2487
+		// );
2488
+	}
2489
+
2490
+
2491
+	protected function _espresso_sponsors_post_box()
2492
+	{
2493
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2494
+			add_meta_box(
2495
+				'espresso_sponsors_post_box',
2496
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2497
+				array($this, 'espresso_sponsors_post_box'),
2498
+				$this->_wp_page_slug,
2499
+				'side'
2500
+			);
2501
+		}
2502
+	}
2503
+
2504
+
2505
+	public function espresso_sponsors_post_box()
2506
+	{
2507
+		EEH_Template::display_template(
2508
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2509
+		);
2510
+	}
2511
+
2512
+
2513
+	private function _publish_post_box()
2514
+	{
2515
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2516
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2517
+		// then we'll use that for the metabox label.
2518
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2519
+		if (! empty($this->_labels['publishbox'])) {
2520
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2521
+				: $this->_labels['publishbox'];
2522
+		} else {
2523
+			$box_label = esc_html__('Publish', 'event_espresso');
2524
+		}
2525
+		$box_label = apply_filters(
2526
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2527
+			$box_label,
2528
+			$this->_req_action,
2529
+			$this
2530
+		);
2531
+		add_meta_box(
2532
+			$meta_box_ref,
2533
+			$box_label,
2534
+			array($this, 'editor_overview'),
2535
+			$this->_current_screen->id,
2536
+			'side',
2537
+			'high'
2538
+		);
2539
+	}
2540
+
2541
+
2542
+	public function editor_overview()
2543
+	{
2544
+		// if we have extra content set let's add it in if not make sure its empty
2545
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2546
+			? $this->_template_args['publish_box_extra_content']
2547
+			: '';
2548
+		echo EEH_Template::display_template(
2549
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2550
+			$this->_template_args,
2551
+			true
2552
+		);
2553
+	}
2554
+
2555
+
2556
+	/** end of globally available metaboxes section **/
2557
+
2558
+
2559
+	/**
2560
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2561
+	 * protected method.
2562
+	 *
2563
+	 * @see   $this->_set_publish_post_box_vars for param details
2564
+	 * @since 4.6.0
2565
+	 * @param string $name
2566
+	 * @param int    $id
2567
+	 * @param bool   $delete
2568
+	 * @param string $save_close_redirect_URL
2569
+	 * @param bool   $both_btns
2570
+	 * @throws EE_Error
2571
+	 * @throws InvalidArgumentException
2572
+	 * @throws InvalidDataTypeException
2573
+	 * @throws InvalidInterfaceException
2574
+	 */
2575
+	public function set_publish_post_box_vars(
2576
+		$name = '',
2577
+		$id = 0,
2578
+		$delete = false,
2579
+		$save_close_redirect_URL = '',
2580
+		$both_btns = true
2581
+	) {
2582
+		$this->_set_publish_post_box_vars(
2583
+			$name,
2584
+			$id,
2585
+			$delete,
2586
+			$save_close_redirect_URL,
2587
+			$both_btns
2588
+		);
2589
+	}
2590
+
2591
+
2592
+	/**
2593
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2594
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2595
+	 * save, and save and close buttons to work properly, then you will want to include a
2596
+	 * values for the name and id arguments.
2597
+	 *
2598
+	 * @todo  Add in validation for name/id arguments.
2599
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2600
+	 * @param    int     $id                      id attached to the item published
2601
+	 * @param    string  $delete                  page route callback for the delete action
2602
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2603
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2604
+	 *                                            the Save button
2605
+	 * @throws EE_Error
2606
+	 * @throws InvalidArgumentException
2607
+	 * @throws InvalidDataTypeException
2608
+	 * @throws InvalidInterfaceException
2609
+	 */
2610
+	protected function _set_publish_post_box_vars(
2611
+		$name = '',
2612
+		$id = 0,
2613
+		$delete = '',
2614
+		$save_close_redirect_URL = '',
2615
+		$both_btns = true
2616
+	) {
2617
+		// if Save & Close, use a custom redirect URL or default to the main page?
2618
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2619
+			? $save_close_redirect_URL
2620
+			: $this->_admin_base_url;
2621
+		// create the Save & Close and Save buttons
2622
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2623
+		// if we have extra content set let's add it in if not make sure its empty
2624
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2625
+			? $this->_template_args['publish_box_extra_content']
2626
+			: '';
2627
+		if ($delete && ! empty($id)) {
2628
+			// make sure we have a default if just true is sent.
2629
+			$delete = ! empty($delete) ? $delete : 'delete';
2630
+			$delete_link_args = array($name => $id);
2631
+			$delete = $this->get_action_link_or_button(
2632
+				$delete,
2633
+				$delete,
2634
+				$delete_link_args,
2635
+				'submitdelete deletion',
2636
+				'',
2637
+				false
2638
+			);
2639
+		}
2640
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2641
+		if (! empty($name) && ! empty($id)) {
2642
+			$hidden_field_arr[ $name ] = array(
2643
+				'type'  => 'hidden',
2644
+				'value' => $id,
2645
+			);
2646
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2647
+		} else {
2648
+			$hf = '';
2649
+		}
2650
+		// add hidden field
2651
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2652
+			? $hf[ $name ]['field']
2653
+			: $hf;
2654
+	}
2655
+
2656
+
2657
+	/**
2658
+	 * displays an error message to ppl who have javascript disabled
2659
+	 *
2660
+	 * @return void
2661
+	 */
2662
+	private function _display_no_javascript_warning()
2663
+	{
2664
+		?>
2665 2665
         <noscript>
2666 2666
             <div id="no-js-message" class="error">
2667 2667
                 <p style="font-size:1.3em;">
2668 2668
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2669 2669
                     <?php esc_html_e(
2670
-                        '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.',
2671
-                        'event_espresso'
2672
-                    ); ?>
2670
+						'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.',
2671
+						'event_espresso'
2672
+					); ?>
2673 2673
                 </p>
2674 2674
             </div>
2675 2675
         </noscript>
2676 2676
         <?php
2677
-    }
2678
-
2679
-
2680
-    /**
2681
-     * displays espresso success and/or error notices
2682
-     *
2683
-     * @return void
2684
-     */
2685
-    private function _display_espresso_notices()
2686
-    {
2687
-        $notices = $this->_get_transient(true);
2688
-        echo stripslashes($notices);
2689
-    }
2690
-
2691
-
2692
-    /**
2693
-     * spinny things pacify the masses
2694
-     *
2695
-     * @return void
2696
-     */
2697
-    protected function _add_admin_page_ajax_loading_img()
2698
-    {
2699
-        ?>
2677
+	}
2678
+
2679
+
2680
+	/**
2681
+	 * displays espresso success and/or error notices
2682
+	 *
2683
+	 * @return void
2684
+	 */
2685
+	private function _display_espresso_notices()
2686
+	{
2687
+		$notices = $this->_get_transient(true);
2688
+		echo stripslashes($notices);
2689
+	}
2690
+
2691
+
2692
+	/**
2693
+	 * spinny things pacify the masses
2694
+	 *
2695
+	 * @return void
2696
+	 */
2697
+	protected function _add_admin_page_ajax_loading_img()
2698
+	{
2699
+		?>
2700 2700
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2701 2701
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2702
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2702
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2703 2703
         </div>
2704 2704
         <?php
2705
-    }
2705
+	}
2706 2706
 
2707 2707
 
2708
-    /**
2709
-     * add admin page overlay for modal boxes
2710
-     *
2711
-     * @return void
2712
-     */
2713
-    protected function _add_admin_page_overlay()
2714
-    {
2715
-        ?>
2708
+	/**
2709
+	 * add admin page overlay for modal boxes
2710
+	 *
2711
+	 * @return void
2712
+	 */
2713
+	protected function _add_admin_page_overlay()
2714
+	{
2715
+		?>
2716 2716
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2717 2717
         <?php
2718
-    }
2719
-
2720
-
2721
-    /**
2722
-     * facade for add_meta_box
2723
-     *
2724
-     * @param string  $action        where the metabox get's displayed
2725
-     * @param string  $title         Title of Metabox (output in metabox header)
2726
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2727
-     *                               instead of the one created in here.
2728
-     * @param array   $callback_args an array of args supplied for the metabox
2729
-     * @param string  $column        what metabox column
2730
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2731
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2732
-     *                               created but just set our own callback for wp's add_meta_box.
2733
-     * @throws \DomainException
2734
-     */
2735
-    public function _add_admin_page_meta_box(
2736
-        $action,
2737
-        $title,
2738
-        $callback,
2739
-        $callback_args,
2740
-        $column = 'normal',
2741
-        $priority = 'high',
2742
-        $create_func = true
2743
-    ) {
2744
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2745
-        // 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.
2746
-        if (empty($callback_args) && $create_func) {
2747
-            $callback_args = array(
2748
-                'template_path' => $this->_template_path,
2749
-                'template_args' => $this->_template_args,
2750
-            );
2751
-        }
2752
-        // 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)
2753
-        $call_back_func = $create_func
2754
-            ? function ($post, $metabox) {
2755
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2756
-                echo EEH_Template::display_template(
2757
-                    $metabox['args']['template_path'],
2758
-                    $metabox['args']['template_args'],
2759
-                    true
2760
-                );
2761
-            }
2762
-            : $callback;
2763
-        add_meta_box(
2764
-            str_replace('_', '-', $action) . '-mbox',
2765
-            $title,
2766
-            $call_back_func,
2767
-            $this->_wp_page_slug,
2768
-            $column,
2769
-            $priority,
2770
-            $callback_args
2771
-        );
2772
-    }
2773
-
2774
-
2775
-    /**
2776
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2777
-     *
2778
-     * @throws DomainException
2779
-     * @throws EE_Error
2780
-     */
2781
-    public function display_admin_page_with_metabox_columns()
2782
-    {
2783
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2784
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2785
-            $this->_column_template_path,
2786
-            $this->_template_args,
2787
-            true
2788
-        );
2789
-        // the final wrapper
2790
-        $this->admin_page_wrapper();
2791
-    }
2792
-
2793
-
2794
-    /**
2795
-     * generates  HTML wrapper for an admin details page
2796
-     *
2797
-     * @return void
2798
-     * @throws EE_Error
2799
-     * @throws DomainException
2800
-     */
2801
-    public function display_admin_page_with_sidebar()
2802
-    {
2803
-        $this->_display_admin_page(true);
2804
-    }
2805
-
2806
-
2807
-    /**
2808
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2809
-     *
2810
-     * @return void
2811
-     * @throws EE_Error
2812
-     * @throws DomainException
2813
-     */
2814
-    public function display_admin_page_with_no_sidebar()
2815
-    {
2816
-        $this->_display_admin_page();
2817
-    }
2818
-
2819
-
2820
-    /**
2821
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2822
-     *
2823
-     * @return void
2824
-     * @throws EE_Error
2825
-     * @throws DomainException
2826
-     */
2827
-    public function display_about_admin_page()
2828
-    {
2829
-        $this->_display_admin_page(false, true);
2830
-    }
2831
-
2832
-
2833
-    /**
2834
-     * display_admin_page
2835
-     * contains the code for actually displaying an admin page
2836
-     *
2837
-     * @param  boolean $sidebar true with sidebar, false without
2838
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2839
-     * @return void
2840
-     * @throws DomainException
2841
-     * @throws EE_Error
2842
-     */
2843
-    private function _display_admin_page($sidebar = false, $about = false)
2844
-    {
2845
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2846
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2847
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2848
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2849
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2850
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2851
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2852
-            ? 'poststuff'
2853
-            : 'espresso-default-admin';
2854
-        $template_path = $sidebar
2855
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2856
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2857
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2858
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2859
-        }
2860
-        $template_path = ! empty($this->_column_template_path)
2861
-            ? $this->_column_template_path : $template_path;
2862
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2863
-            ? $this->_template_args['admin_page_content']
2864
-            : '';
2865
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2866
-            ? $this->_template_args['before_admin_page_content']
2867
-            : '';
2868
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2869
-            ? $this->_template_args['after_admin_page_content']
2870
-            : '';
2871
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2872
-            $template_path,
2873
-            $this->_template_args,
2874
-            true
2875
-        );
2876
-        // the final template wrapper
2877
-        $this->admin_page_wrapper($about);
2878
-    }
2879
-
2880
-
2881
-    /**
2882
-     * This is used to display caf preview pages.
2883
-     *
2884
-     * @since 4.3.2
2885
-     * @param string $utm_campaign_source what is the key used for google analytics link
2886
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2887
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2888
-     * @return void
2889
-     * @throws DomainException
2890
-     * @throws EE_Error
2891
-     * @throws InvalidArgumentException
2892
-     * @throws InvalidDataTypeException
2893
-     * @throws InvalidInterfaceException
2894
-     */
2895
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2896
-    {
2897
-        // let's generate a default preview action button if there isn't one already present.
2898
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2899
-            'Upgrade to Event Espresso 4 Right Now',
2900
-            'event_espresso'
2901
-        );
2902
-        $buy_now_url = add_query_arg(
2903
-            array(
2904
-                'ee_ver'       => 'ee4',
2905
-                'utm_source'   => 'ee4_plugin_admin',
2906
-                'utm_medium'   => 'link',
2907
-                'utm_campaign' => $utm_campaign_source,
2908
-                'utm_content'  => 'buy_now_button',
2909
-            ),
2910
-            'http://eventespresso.com/pricing/'
2911
-        );
2912
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2913
-            ? $this->get_action_link_or_button(
2914
-                '',
2915
-                'buy_now',
2916
-                array(),
2917
-                'button-primary button-large',
2918
-                $buy_now_url,
2919
-                true
2920
-            )
2921
-            : $this->_template_args['preview_action_button'];
2922
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2923
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2924
-            $this->_template_args,
2925
-            true
2926
-        );
2927
-        $this->_display_admin_page($display_sidebar);
2928
-    }
2929
-
2930
-
2931
-    /**
2932
-     * display_admin_list_table_page_with_sidebar
2933
-     * generates HTML wrapper for an admin_page with list_table
2934
-     *
2935
-     * @return void
2936
-     * @throws EE_Error
2937
-     * @throws DomainException
2938
-     */
2939
-    public function display_admin_list_table_page_with_sidebar()
2940
-    {
2941
-        $this->_display_admin_list_table_page(true);
2942
-    }
2943
-
2944
-
2945
-    /**
2946
-     * display_admin_list_table_page_with_no_sidebar
2947
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2948
-     *
2949
-     * @return void
2950
-     * @throws EE_Error
2951
-     * @throws DomainException
2952
-     */
2953
-    public function display_admin_list_table_page_with_no_sidebar()
2954
-    {
2955
-        $this->_display_admin_list_table_page();
2956
-    }
2957
-
2958
-
2959
-    /**
2960
-     * generates html wrapper for an admin_list_table page
2961
-     *
2962
-     * @param boolean $sidebar whether to display with sidebar or not.
2963
-     * @return void
2964
-     * @throws DomainException
2965
-     * @throws EE_Error
2966
-     */
2967
-    private function _display_admin_list_table_page($sidebar = false)
2968
-    {
2969
-        // setup search attributes
2970
-        $this->_set_search_attributes();
2971
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2972
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2973
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2974
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2975
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2976
-        $this->_template_args['list_table'] = $this->_list_table_object;
2977
-        $this->_template_args['current_route'] = $this->_req_action;
2978
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2979
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2980
-        if (! empty($ajax_sorting_callback)) {
2981
-            $sortable_list_table_form_fields = wp_nonce_field(
2982
-                $ajax_sorting_callback . '_nonce',
2983
-                $ajax_sorting_callback . '_nonce',
2984
-                false,
2985
-                false
2986
-            );
2987
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2988
-                                                . $this->page_slug
2989
-                                                . '" />';
2990
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2991
-                                                . $ajax_sorting_callback
2992
-                                                . '" />';
2993
-        } else {
2994
-            $sortable_list_table_form_fields = '';
2995
-        }
2996
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2997
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2998
-            ? $this->_template_args['list_table_hidden_fields']
2999
-            : '';
3000
-        $nonce_ref = $this->_req_action . '_nonce';
3001
-        $hidden_form_fields .= '<input type="hidden" name="'
3002
-                               . $nonce_ref
3003
-                               . '" value="'
3004
-                               . wp_create_nonce($nonce_ref)
3005
-                               . '">';
3006
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3007
-        // display message about search results?
3008
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3009
-            ? '<p class="ee-search-results">' . sprintf(
3010
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3011
-                trim($this->_req_data['s'], '%')
3012
-            ) . '</p>'
3013
-            : '';
3014
-        // filter before_list_table template arg
3015
-        $this->_template_args['before_list_table'] = apply_filters(
3016
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3017
-            $this->_template_args['before_list_table'],
3018
-            $this->page_slug,
3019
-            $this->_req_data,
3020
-            $this->_req_action
3021
-        );
3022
-        // convert to array and filter again
3023
-        // arrays are easier to inject new items in a specific location,
3024
-        // but would not be backwards compatible, so we have to add a new filter
3025
-        $this->_template_args['before_list_table'] = implode(
3026
-            " \n",
3027
-            (array) apply_filters(
3028
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3029
-                (array) $this->_template_args['before_list_table'],
3030
-                $this->page_slug,
3031
-                $this->_req_data,
3032
-                $this->_req_action
3033
-            )
3034
-        );
3035
-        // filter after_list_table template arg
3036
-        $this->_template_args['after_list_table'] = apply_filters(
3037
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3038
-            $this->_template_args['after_list_table'],
3039
-            $this->page_slug,
3040
-            $this->_req_data,
3041
-            $this->_req_action
3042
-        );
3043
-        // convert to array and filter again
3044
-        // arrays are easier to inject new items in a specific location,
3045
-        // but would not be backwards compatible, so we have to add a new filter
3046
-        $this->_template_args['after_list_table'] = implode(
3047
-            " \n",
3048
-            (array) apply_filters(
3049
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3050
-                (array) $this->_template_args['after_list_table'],
3051
-                $this->page_slug,
3052
-                $this->_req_data,
3053
-                $this->_req_action
3054
-            )
3055
-        );
3056
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3057
-            $template_path,
3058
-            $this->_template_args,
3059
-            true
3060
-        );
3061
-        // the final template wrapper
3062
-        if ($sidebar) {
3063
-            $this->display_admin_page_with_sidebar();
3064
-        } else {
3065
-            $this->display_admin_page_with_no_sidebar();
3066
-        }
3067
-    }
3068
-
3069
-
3070
-    /**
3071
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3072
-     * html string for the legend.
3073
-     * $items are expected in an array in the following format:
3074
-     * $legend_items = array(
3075
-     *        'item_id' => array(
3076
-     *            'icon' => 'http://url_to_icon_being_described.png',
3077
-     *            'desc' => esc_html__('localized description of item');
3078
-     *        )
3079
-     * );
3080
-     *
3081
-     * @param  array $items see above for format of array
3082
-     * @return string html string of legend
3083
-     * @throws DomainException
3084
-     */
3085
-    protected function _display_legend($items)
3086
-    {
3087
-        $this->_template_args['items'] = apply_filters(
3088
-            'FHEE__EE_Admin_Page___display_legend__items',
3089
-            (array) $items,
3090
-            $this
3091
-        );
3092
-        return EEH_Template::display_template(
3093
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3094
-            $this->_template_args,
3095
-            true
3096
-        );
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3102
-     * The returned json object is created from an array in the following format:
3103
-     * array(
3104
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3105
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3106
-     *  'notices' => '', // - contains any EE_Error formatted notices
3107
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3108
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3109
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3110
-     *  that might be included in here)
3111
-     * )
3112
-     * The json object is populated by whatever is set in the $_template_args property.
3113
-     *
3114
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3115
-     *                                 instead of displayed.
3116
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3117
-     * @return void
3118
-     * @throws EE_Error
3119
-     */
3120
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3121
-    {
3122
-        // make sure any EE_Error notices have been handled.
3123
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3124
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3125
-        unset($this->_template_args['data']);
3126
-        $json = array(
3127
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3128
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3129
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3130
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3131
-            'notices'   => EE_Error::get_notices(),
3132
-            'content'   => isset($this->_template_args['admin_page_content'])
3133
-                ? $this->_template_args['admin_page_content'] : '',
3134
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3135
-            'isEEajax'  => true
3136
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3137
-        );
3138
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3139
-        if (null === error_get_last() || ! headers_sent()) {
3140
-            header('Content-Type: application/json; charset=UTF-8');
3141
-        }
3142
-        echo wp_json_encode($json);
3143
-        exit();
3144
-    }
3145
-
3146
-
3147
-    /**
3148
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3149
-     *
3150
-     * @return void
3151
-     * @throws EE_Error
3152
-     */
3153
-    public function return_json()
3154
-    {
3155
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3156
-            $this->_return_json();
3157
-        } else {
3158
-            throw new EE_Error(
3159
-                sprintf(
3160
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3161
-                    __FUNCTION__
3162
-                )
3163
-            );
3164
-        }
3165
-    }
3166
-
3167
-
3168
-    /**
3169
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3170
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3171
-     *
3172
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3173
-     */
3174
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3175
-    {
3176
-        $this->_hook_obj = $hook_obj;
3177
-    }
3178
-
3179
-
3180
-    /**
3181
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3182
-     *
3183
-     * @param  boolean $about whether to use the special about page wrapper or default.
3184
-     * @return void
3185
-     * @throws DomainException
3186
-     * @throws EE_Error
3187
-     */
3188
-    public function admin_page_wrapper($about = false)
3189
-    {
3190
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3191
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3192
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3193
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3194
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3195
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3196
-            isset($this->_template_args['before_admin_page_content'])
3197
-                ? $this->_template_args['before_admin_page_content']
3198
-                : ''
3199
-        );
3200
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3201
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3202
-            isset($this->_template_args['after_admin_page_content'])
3203
-                ? $this->_template_args['after_admin_page_content']
3204
-                : ''
3205
-        );
3206
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3207
-        // load settings page wrapper template
3208
-        $template_path = ! defined('DOING_AJAX')
3209
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3210
-            : EE_ADMIN_TEMPLATE
3211
-              . 'admin_wrapper_ajax.template.php';
3212
-        // about page?
3213
-        $template_path = $about
3214
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3215
-            : $template_path;
3216
-        if (defined('DOING_AJAX')) {
3217
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3218
-                $template_path,
3219
-                $this->_template_args,
3220
-                true
3221
-            );
3222
-            $this->_return_json();
3223
-        } else {
3224
-            EEH_Template::display_template($template_path, $this->_template_args);
3225
-        }
3226
-    }
3227
-
3228
-
3229
-    /**
3230
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3231
-     *
3232
-     * @return string html
3233
-     * @throws EE_Error
3234
-     */
3235
-    protected function _get_main_nav_tabs()
3236
-    {
3237
-        // let's generate the html using the EEH_Tabbed_Content helper.
3238
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3239
-        // (rather than setting in the page_routes array)
3240
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3241
-    }
3242
-
3243
-
3244
-    /**
3245
-     *        sort nav tabs
3246
-     *
3247
-     * @param $a
3248
-     * @param $b
3249
-     * @return int
3250
-     */
3251
-    private function _sort_nav_tabs($a, $b)
3252
-    {
3253
-        if ($a['order'] === $b['order']) {
3254
-            return 0;
3255
-        }
3256
-        return ($a['order'] < $b['order']) ? -1 : 1;
3257
-    }
3258
-
3259
-
3260
-    /**
3261
-     *    generates HTML for the forms used on admin pages
3262
-     *
3263
-     * @param    array $input_vars - array of input field details
3264
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3265
-     *                             use)
3266
-     * @param bool     $id
3267
-     * @return string
3268
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3269
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3270
-     */
3271
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3272
-    {
3273
-        $content = $generator === 'string'
3274
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3275
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3276
-        return $content;
3277
-    }
3278
-
3279
-
3280
-    /**
3281
-     * generates the "Save" and "Save & Close" buttons for edit forms
3282
-     *
3283
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3284
-     *                                   Close" button.
3285
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3286
-     *                                   'Save', [1] => 'save & close')
3287
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3288
-     *                                   via the "name" value in the button).  We can also use this to just dump
3289
-     *                                   default actions by submitting some other value.
3290
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3291
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3292
-     *                                   close (normal form handling).
3293
-     */
3294
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3295
-    {
3296
-        // make sure $text and $actions are in an array
3297
-        $text = (array) $text;
3298
-        $actions = (array) $actions;
3299
-        $referrer_url = empty($referrer)
3300
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3301
-              . $_SERVER['REQUEST_URI']
3302
-              . '" />'
3303
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3304
-              . $referrer
3305
-              . '" />';
3306
-        $button_text = ! empty($text)
3307
-            ? $text
3308
-            : array(
3309
-                esc_html__('Save', 'event_espresso'),
3310
-                esc_html__('Save and Close', 'event_espresso'),
3311
-            );
3312
-        $default_names = array('save', 'save_and_close');
3313
-        // add in a hidden index for the current page (so save and close redirects properly)
3314
-        $this->_template_args['save_buttons'] = $referrer_url;
3315
-        foreach ($button_text as $key => $button) {
3316
-            $ref = $default_names[ $key ];
3317
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3318
-                                                     . $ref
3319
-                                                     . '" value="'
3320
-                                                     . $button
3321
-                                                     . '" name="'
3322
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3323
-                                                     . '" id="'
3324
-                                                     . $this->_current_view . '_' . $ref
3325
-                                                     . '" />';
3326
-            if (! $both) {
3327
-                break;
3328
-            }
3329
-        }
3330
-    }
3331
-
3332
-
3333
-    /**
3334
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3335
-     *
3336
-     * @see   $this->_set_add_edit_form_tags() for details on params
3337
-     * @since 4.6.0
3338
-     * @param string $route
3339
-     * @param array  $additional_hidden_fields
3340
-     */
3341
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3342
-    {
3343
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3344
-    }
3345
-
3346
-
3347
-    /**
3348
-     * set form open and close tags on add/edit pages.
3349
-     *
3350
-     * @param string $route                    the route you want the form to direct to
3351
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3352
-     * @return void
3353
-     */
3354
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3355
-    {
3356
-        if (empty($route)) {
3357
-            $user_msg = esc_html__(
3358
-                'An error occurred. No action was set for this page\'s form.',
3359
-                'event_espresso'
3360
-            );
3361
-            $dev_msg = $user_msg . "\n"
3362
-                       . sprintf(
3363
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3364
-                           __FUNCTION__,
3365
-                           __CLASS__
3366
-                       );
3367
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3368
-        }
3369
-        // open form
3370
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3371
-                                                             . $this->_admin_base_url
3372
-                                                             . '" id="'
3373
-                                                             . $route
3374
-                                                             . '_event_form" >';
3375
-        // add nonce
3376
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3377
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3378
-        // add REQUIRED form action
3379
-        $hidden_fields = array(
3380
-            'action' => array('type' => 'hidden', 'value' => $route),
3381
-        );
3382
-        // merge arrays
3383
-        $hidden_fields = is_array($additional_hidden_fields)
3384
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3385
-            : $hidden_fields;
3386
-        // generate form fields
3387
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3388
-        // add fields to form
3389
-        foreach ((array) $form_fields as $field_name => $form_field) {
3390
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3391
-        }
3392
-        // close form
3393
-        $this->_template_args['after_admin_page_content'] = '</form>';
3394
-    }
3395
-
3396
-
3397
-    /**
3398
-     * Public Wrapper for _redirect_after_action() method since its
3399
-     * discovered it would be useful for external code to have access.
3400
-     *
3401
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3402
-     * @since 4.5.0
3403
-     * @param bool   $success
3404
-     * @param string $what
3405
-     * @param string $action_desc
3406
-     * @param array  $query_args
3407
-     * @param bool   $override_overwrite
3408
-     * @throws EE_Error
3409
-     */
3410
-    public function redirect_after_action(
3411
-        $success = false,
3412
-        $what = 'item',
3413
-        $action_desc = 'processed',
3414
-        $query_args = array(),
3415
-        $override_overwrite = false
3416
-    ) {
3417
-        $this->_redirect_after_action(
3418
-            $success,
3419
-            $what,
3420
-            $action_desc,
3421
-            $query_args,
3422
-            $override_overwrite
3423
-        );
3424
-    }
3425
-
3426
-
3427
-    /**
3428
-     * Helper method for merging existing request data with the returned redirect url.
3429
-     *
3430
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3431
-     * filters are still applied.
3432
-     *
3433
-     * @param array $new_route_data
3434
-     * @return array
3435
-     */
3436
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3437
-    {
3438
-        foreach ($this->_req_data as $ref => $value) {
3439
-            // unset nonces
3440
-            if (strpos($ref, 'nonce') !== false) {
3441
-                unset($this->_req_data[ $ref ]);
3442
-                continue;
3443
-            }
3444
-            // urlencode values.
3445
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3446
-            $this->_req_data[ $ref ] = $value;
3447
-        }
3448
-        return array_merge($this->_req_data, $new_route_data);
3449
-    }
3450
-
3451
-
3452
-    /**
3453
-     *    _redirect_after_action
3454
-     *
3455
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3456
-     * @param string $what               - what the action was performed on
3457
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3458
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3459
-     *                                   action is completed
3460
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3461
-     *                                   override this so that they show.
3462
-     * @return void
3463
-     * @throws EE_Error
3464
-     */
3465
-    protected function _redirect_after_action(
3466
-        $success = 0,
3467
-        $what = 'item',
3468
-        $action_desc = 'processed',
3469
-        $query_args = array(),
3470
-        $override_overwrite = false
3471
-    ) {
3472
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3473
-        // class name for actions/filters.
3474
-        $classname = get_class($this);
3475
-        // set redirect url.
3476
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3477
-        // otherwise we go with whatever is set as the _admin_base_url
3478
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3479
-        $notices = EE_Error::get_notices(false);
3480
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3481
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3482
-            EE_Error::overwrite_success();
3483
-        }
3484
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3485
-            // how many records affected ? more than one record ? or just one ?
3486
-            if ($success > 1) {
3487
-                // set plural msg
3488
-                EE_Error::add_success(
3489
-                    sprintf(
3490
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3491
-                        $what,
3492
-                        $action_desc
3493
-                    ),
3494
-                    __FILE__,
3495
-                    __FUNCTION__,
3496
-                    __LINE__
3497
-                );
3498
-            } elseif ($success === 1) {
3499
-                // set singular msg
3500
-                EE_Error::add_success(
3501
-                    sprintf(
3502
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3503
-                        $what,
3504
-                        $action_desc
3505
-                    ),
3506
-                    __FILE__,
3507
-                    __FUNCTION__,
3508
-                    __LINE__
3509
-                );
3510
-            }
3511
-        }
3512
-        // check that $query_args isn't something crazy
3513
-        if (! is_array($query_args)) {
3514
-            $query_args = array();
3515
-        }
3516
-        /**
3517
-         * Allow injecting actions before the query_args are modified for possible different
3518
-         * redirections on save and close actions
3519
-         *
3520
-         * @since 4.2.0
3521
-         * @param array $query_args       The original query_args array coming into the
3522
-         *                                method.
3523
-         */
3524
-        do_action(
3525
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3526
-            $query_args
3527
-        );
3528
-        // calculate where we're going (if we have a "save and close" button pushed)
3529
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3530
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3531
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3532
-            // regenerate query args array from referrer URL
3533
-            parse_str($parsed_url['query'], $query_args);
3534
-            // correct page and action will be in the query args now
3535
-            $redirect_url = admin_url('admin.php');
3536
-        }
3537
-        // merge any default query_args set in _default_route_query_args property
3538
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3539
-            $args_to_merge = array();
3540
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3541
-                // is there a wp_referer array in our _default_route_query_args property?
3542
-                if ($query_param === 'wp_referer') {
3543
-                    $query_value = (array) $query_value;
3544
-                    foreach ($query_value as $reference => $value) {
3545
-                        if (strpos($reference, 'nonce') !== false) {
3546
-                            continue;
3547
-                        }
3548
-                        // finally we will override any arguments in the referer with
3549
-                        // what might be set on the _default_route_query_args array.
3550
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3551
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3552
-                        } else {
3553
-                            $args_to_merge[ $reference ] = urlencode($value);
3554
-                        }
3555
-                    }
3556
-                    continue;
3557
-                }
3558
-                $args_to_merge[ $query_param ] = $query_value;
3559
-            }
3560
-            // now let's merge these arguments but override with what was specifically sent in to the
3561
-            // redirect.
3562
-            $query_args = array_merge($args_to_merge, $query_args);
3563
-        }
3564
-        $this->_process_notices($query_args);
3565
-        // generate redirect url
3566
-        // if redirecting to anything other than the main page, add a nonce
3567
-        if (isset($query_args['action'])) {
3568
-            // manually generate wp_nonce and merge that with the query vars
3569
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3570
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3571
-        }
3572
-        // we're adding some hooks and filters in here for processing any things just before redirects
3573
-        // (example: an admin page has done an insert or update and we want to run something after that).
3574
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3575
-        $redirect_url = apply_filters(
3576
-            'FHEE_redirect_' . $classname . $this->_req_action,
3577
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3578
-            $query_args
3579
-        );
3580
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3581
-        if (defined('DOING_AJAX')) {
3582
-            $default_data = array(
3583
-                'close'        => true,
3584
-                'redirect_url' => $redirect_url,
3585
-                'where'        => 'main',
3586
-                'what'         => 'append',
3587
-            );
3588
-            $this->_template_args['success'] = $success;
3589
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3590
-                $default_data,
3591
-                $this->_template_args['data']
3592
-            ) : $default_data;
3593
-            $this->_return_json();
3594
-        }
3595
-        wp_safe_redirect($redirect_url);
3596
-        exit();
3597
-    }
3598
-
3599
-
3600
-    /**
3601
-     * process any notices before redirecting (or returning ajax request)
3602
-     * This method sets the $this->_template_args['notices'] attribute;
3603
-     *
3604
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3605
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3606
-     *                                  page_routes haven't been defined yet.
3607
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3608
-     *                                  still save a transient for the notice.
3609
-     * @return void
3610
-     * @throws EE_Error
3611
-     */
3612
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3613
-    {
3614
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3615
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3616
-            $notices = EE_Error::get_notices(false);
3617
-            if (empty($this->_template_args['success'])) {
3618
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3619
-            }
3620
-            if (empty($this->_template_args['errors'])) {
3621
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3622
-            }
3623
-            if (empty($this->_template_args['attention'])) {
3624
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3625
-            }
3626
-        }
3627
-        $this->_template_args['notices'] = EE_Error::get_notices();
3628
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3629
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3630
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3631
-            $this->_add_transient(
3632
-                $route,
3633
-                $this->_template_args['notices'],
3634
-                true,
3635
-                $skip_route_verify
3636
-            );
3637
-        }
3638
-    }
3639
-
3640
-
3641
-    /**
3642
-     * get_action_link_or_button
3643
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3644
-     *
3645
-     * @param string $action        use this to indicate which action the url is generated with.
3646
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3647
-     *                              property.
3648
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3649
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3650
-     * @param string $base_url      If this is not provided
3651
-     *                              the _admin_base_url will be used as the default for the button base_url.
3652
-     *                              Otherwise this value will be used.
3653
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3654
-     * @return string
3655
-     * @throws InvalidArgumentException
3656
-     * @throws InvalidInterfaceException
3657
-     * @throws InvalidDataTypeException
3658
-     * @throws EE_Error
3659
-     */
3660
-    public function get_action_link_or_button(
3661
-        $action,
3662
-        $type = 'add',
3663
-        $extra_request = array(),
3664
-        $class = 'button-primary',
3665
-        $base_url = '',
3666
-        $exclude_nonce = false
3667
-    ) {
3668
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3669
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3670
-            throw new EE_Error(
3671
-                sprintf(
3672
-                    esc_html__(
3673
-                        'There is no page route for given action for the button.  This action was given: %s',
3674
-                        'event_espresso'
3675
-                    ),
3676
-                    $action
3677
-                )
3678
-            );
3679
-        }
3680
-        if (! isset($this->_labels['buttons'][ $type ])) {
3681
-            throw new EE_Error(
3682
-                sprintf(
3683
-                    __(
3684
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3685
-                        'event_espresso'
3686
-                    ),
3687
-                    $type
3688
-                )
3689
-            );
3690
-        }
3691
-        // finally check user access for this button.
3692
-        $has_access = $this->check_user_access($action, true);
3693
-        if (! $has_access) {
3694
-            return '';
3695
-        }
3696
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3697
-        $query_args = array(
3698
-            'action' => $action,
3699
-        );
3700
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3701
-        if (! empty($extra_request)) {
3702
-            $query_args = array_merge($extra_request, $query_args);
3703
-        }
3704
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3705
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3706
-    }
3707
-
3708
-
3709
-    /**
3710
-     * _per_page_screen_option
3711
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3712
-     *
3713
-     * @return void
3714
-     * @throws InvalidArgumentException
3715
-     * @throws InvalidInterfaceException
3716
-     * @throws InvalidDataTypeException
3717
-     */
3718
-    protected function _per_page_screen_option()
3719
-    {
3720
-        $option = 'per_page';
3721
-        $args = array(
3722
-            'label'   => apply_filters(
3723
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3724
-                $this->_admin_page_title,
3725
-                $this
3726
-            ),
3727
-            'default' => (int) apply_filters(
3728
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3729
-                20
3730
-            ),
3731
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3732
-        );
3733
-        // ONLY add the screen option if the user has access to it.
3734
-        if ($this->check_user_access($this->_current_view, true)) {
3735
-            add_screen_option($option, $args);
3736
-        }
3737
-    }
3738
-
3739
-
3740
-    /**
3741
-     * set_per_page_screen_option
3742
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3743
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3744
-     * admin_menu.
3745
-     *
3746
-     * @return void
3747
-     */
3748
-    private function _set_per_page_screen_options()
3749
-    {
3750
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3751
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3752
-            if (! $user = wp_get_current_user()) {
3753
-                return;
3754
-            }
3755
-            $option = $_POST['wp_screen_options']['option'];
3756
-            $value = $_POST['wp_screen_options']['value'];
3757
-            if ($option != sanitize_key($option)) {
3758
-                return;
3759
-            }
3760
-            $map_option = $option;
3761
-            $option = str_replace('-', '_', $option);
3762
-            switch ($map_option) {
3763
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3764
-                    $value = (int) $value;
3765
-                    $max_value = apply_filters(
3766
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3767
-                        999,
3768
-                        $this->_current_page,
3769
-                        $this->_current_view
3770
-                    );
3771
-                    if ($value < 1) {
3772
-                        return;
3773
-                    }
3774
-                    $value = min($value, $max_value);
3775
-                    break;
3776
-                default:
3777
-                    $value = apply_filters(
3778
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3779
-                        false,
3780
-                        $option,
3781
-                        $value
3782
-                    );
3783
-                    if (false === $value) {
3784
-                        return;
3785
-                    }
3786
-                    break;
3787
-            }
3788
-            update_user_meta($user->ID, $option, $value);
3789
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3790
-            exit;
3791
-        }
3792
-    }
3793
-
3794
-
3795
-    /**
3796
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3797
-     *
3798
-     * @param array $data array that will be assigned to template args.
3799
-     */
3800
-    public function set_template_args($data)
3801
-    {
3802
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3803
-    }
3804
-
3805
-
3806
-    /**
3807
-     * This makes available the WP transient system for temporarily moving data between routes
3808
-     *
3809
-     * @param string $route             the route that should receive the transient
3810
-     * @param array  $data              the data that gets sent
3811
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3812
-     *                                  normal route transient.
3813
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3814
-     *                                  when we are adding a transient before page_routes have been defined.
3815
-     * @return void
3816
-     * @throws EE_Error
3817
-     */
3818
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3819
-    {
3820
-        $user_id = get_current_user_id();
3821
-        if (! $skip_route_verify) {
3822
-            $this->_verify_route($route);
3823
-        }
3824
-        // now let's set the string for what kind of transient we're setting
3825
-        $transient = $notices
3826
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3827
-            : 'rte_tx_' . $route . '_' . $user_id;
3828
-        $data = $notices ? array('notices' => $data) : $data;
3829
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3830
-        $existing = is_multisite() && is_network_admin()
3831
-            ? get_site_transient($transient)
3832
-            : get_transient($transient);
3833
-        if ($existing) {
3834
-            $data = array_merge((array) $data, (array) $existing);
3835
-        }
3836
-        if (is_multisite() && is_network_admin()) {
3837
-            set_site_transient($transient, $data, 8);
3838
-        } else {
3839
-            set_transient($transient, $data, 8);
3840
-        }
3841
-    }
3842
-
3843
-
3844
-    /**
3845
-     * this retrieves the temporary transient that has been set for moving data between routes.
3846
-     *
3847
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3848
-     * @param string $route
3849
-     * @return mixed data
3850
-     */
3851
-    protected function _get_transient($notices = false, $route = '')
3852
-    {
3853
-        $user_id = get_current_user_id();
3854
-        $route = ! $route ? $this->_req_action : $route;
3855
-        $transient = $notices
3856
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3857
-            : 'rte_tx_' . $route . '_' . $user_id;
3858
-        $data = is_multisite() && is_network_admin()
3859
-            ? get_site_transient($transient)
3860
-            : get_transient($transient);
3861
-        // delete transient after retrieval (just in case it hasn't expired);
3862
-        if (is_multisite() && is_network_admin()) {
3863
-            delete_site_transient($transient);
3864
-        } else {
3865
-            delete_transient($transient);
3866
-        }
3867
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3868
-    }
3869
-
3870
-
3871
-    /**
3872
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3873
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3874
-     * default route callback on the EE_Admin page you want it run.)
3875
-     *
3876
-     * @return void
3877
-     */
3878
-    protected function _transient_garbage_collection()
3879
-    {
3880
-        global $wpdb;
3881
-        // retrieve all existing transients
3882
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3883
-        if ($results = $wpdb->get_results($query)) {
3884
-            foreach ($results as $result) {
3885
-                $transient = str_replace('_transient_', '', $result->option_name);
3886
-                get_transient($transient);
3887
-                if (is_multisite() && is_network_admin()) {
3888
-                    get_site_transient($transient);
3889
-                }
3890
-            }
3891
-        }
3892
-    }
3893
-
3894
-
3895
-    /**
3896
-     * get_view
3897
-     *
3898
-     * @return string content of _view property
3899
-     */
3900
-    public function get_view()
3901
-    {
3902
-        return $this->_view;
3903
-    }
3904
-
3905
-
3906
-    /**
3907
-     * getter for the protected $_views property
3908
-     *
3909
-     * @return array
3910
-     */
3911
-    public function get_views()
3912
-    {
3913
-        return $this->_views;
3914
-    }
3915
-
3916
-
3917
-    /**
3918
-     * get_current_page
3919
-     *
3920
-     * @return string _current_page property value
3921
-     */
3922
-    public function get_current_page()
3923
-    {
3924
-        return $this->_current_page;
3925
-    }
3926
-
3927
-
3928
-    /**
3929
-     * get_current_view
3930
-     *
3931
-     * @return string _current_view property value
3932
-     */
3933
-    public function get_current_view()
3934
-    {
3935
-        return $this->_current_view;
3936
-    }
3937
-
3938
-
3939
-    /**
3940
-     * get_current_screen
3941
-     *
3942
-     * @return object The current WP_Screen object
3943
-     */
3944
-    public function get_current_screen()
3945
-    {
3946
-        return $this->_current_screen;
3947
-    }
3948
-
3949
-
3950
-    /**
3951
-     * get_current_page_view_url
3952
-     *
3953
-     * @return string This returns the url for the current_page_view.
3954
-     */
3955
-    public function get_current_page_view_url()
3956
-    {
3957
-        return $this->_current_page_view_url;
3958
-    }
3959
-
3960
-
3961
-    /**
3962
-     * just returns the _req_data property
3963
-     *
3964
-     * @return array
3965
-     */
3966
-    public function get_request_data()
3967
-    {
3968
-        return $this->_req_data;
3969
-    }
3970
-
3971
-
3972
-    /**
3973
-     * returns the _req_data protected property
3974
-     *
3975
-     * @return string
3976
-     */
3977
-    public function get_req_action()
3978
-    {
3979
-        return $this->_req_action;
3980
-    }
3981
-
3982
-
3983
-    /**
3984
-     * @return bool  value of $_is_caf property
3985
-     */
3986
-    public function is_caf()
3987
-    {
3988
-        return $this->_is_caf;
3989
-    }
3990
-
3991
-
3992
-    /**
3993
-     * @return mixed
3994
-     */
3995
-    public function default_espresso_metaboxes()
3996
-    {
3997
-        return $this->_default_espresso_metaboxes;
3998
-    }
3999
-
4000
-
4001
-    /**
4002
-     * @return mixed
4003
-     */
4004
-    public function admin_base_url()
4005
-    {
4006
-        return $this->_admin_base_url;
4007
-    }
4008
-
4009
-
4010
-    /**
4011
-     * @return mixed
4012
-     */
4013
-    public function wp_page_slug()
4014
-    {
4015
-        return $this->_wp_page_slug;
4016
-    }
4017
-
4018
-
4019
-    /**
4020
-     * updates  espresso configuration settings
4021
-     *
4022
-     * @param string                   $tab
4023
-     * @param EE_Config_Base|EE_Config $config
4024
-     * @param string                   $file file where error occurred
4025
-     * @param string                   $func function  where error occurred
4026
-     * @param string                   $line line no where error occurred
4027
-     * @return boolean
4028
-     */
4029
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4030
-    {
4031
-        // remove any options that are NOT going to be saved with the config settings.
4032
-        if (isset($config->core->ee_ueip_optin)) {
4033
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4034
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4035
-            update_option('ee_ueip_has_notified', true);
4036
-        }
4037
-        // and save it (note we're also doing the network save here)
4038
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4039
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4040
-        if ($config_saved && $net_saved) {
4041
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4042
-            return true;
4043
-        }
4044
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4045
-        return false;
4046
-    }
4047
-
4048
-
4049
-    /**
4050
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4051
-     *
4052
-     * @return array
4053
-     */
4054
-    public function get_yes_no_values()
4055
-    {
4056
-        return $this->_yes_no_values;
4057
-    }
4058
-
4059
-
4060
-    protected function _get_dir()
4061
-    {
4062
-        $reflector = new ReflectionClass(get_class($this));
4063
-        return dirname($reflector->getFileName());
4064
-    }
4065
-
4066
-
4067
-    /**
4068
-     * A helper for getting a "next link".
4069
-     *
4070
-     * @param string $url   The url to link to
4071
-     * @param string $class The class to use.
4072
-     * @return string
4073
-     */
4074
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4075
-    {
4076
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4077
-    }
4078
-
4079
-
4080
-    /**
4081
-     * A helper for getting a "previous link".
4082
-     *
4083
-     * @param string $url   The url to link to
4084
-     * @param string $class The class to use.
4085
-     * @return string
4086
-     */
4087
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4088
-    {
4089
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4090
-    }
4091
-
4092
-
4093
-
4094
-
4095
-
4096
-
4097
-
4098
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4099
-
4100
-
4101
-    /**
4102
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4103
-     * 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
4104
-     * _req_data array.
4105
-     *
4106
-     * @return bool success/fail
4107
-     * @throws EE_Error
4108
-     * @throws InvalidArgumentException
4109
-     * @throws ReflectionException
4110
-     * @throws InvalidDataTypeException
4111
-     * @throws InvalidInterfaceException
4112
-     */
4113
-    protected function _process_resend_registration()
4114
-    {
4115
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4116
-        do_action(
4117
-            'AHEE__EE_Admin_Page___process_resend_registration',
4118
-            $this->_template_args['success'],
4119
-            $this->_req_data
4120
-        );
4121
-        return $this->_template_args['success'];
4122
-    }
4123
-
4124
-
4125
-    /**
4126
-     * This automatically processes any payment message notifications when manual payment has been applied.
4127
-     *
4128
-     * @param \EE_Payment $payment
4129
-     * @return bool success/fail
4130
-     */
4131
-    protected function _process_payment_notification(EE_Payment $payment)
4132
-    {
4133
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4134
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4135
-        $this->_template_args['success'] = apply_filters(
4136
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4137
-            false,
4138
-            $payment
4139
-        );
4140
-        return $this->_template_args['success'];
4141
-    }
2718
+	}
2719
+
2720
+
2721
+	/**
2722
+	 * facade for add_meta_box
2723
+	 *
2724
+	 * @param string  $action        where the metabox get's displayed
2725
+	 * @param string  $title         Title of Metabox (output in metabox header)
2726
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2727
+	 *                               instead of the one created in here.
2728
+	 * @param array   $callback_args an array of args supplied for the metabox
2729
+	 * @param string  $column        what metabox column
2730
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2731
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2732
+	 *                               created but just set our own callback for wp's add_meta_box.
2733
+	 * @throws \DomainException
2734
+	 */
2735
+	public function _add_admin_page_meta_box(
2736
+		$action,
2737
+		$title,
2738
+		$callback,
2739
+		$callback_args,
2740
+		$column = 'normal',
2741
+		$priority = 'high',
2742
+		$create_func = true
2743
+	) {
2744
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2745
+		// 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.
2746
+		if (empty($callback_args) && $create_func) {
2747
+			$callback_args = array(
2748
+				'template_path' => $this->_template_path,
2749
+				'template_args' => $this->_template_args,
2750
+			);
2751
+		}
2752
+		// 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)
2753
+		$call_back_func = $create_func
2754
+			? function ($post, $metabox) {
2755
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2756
+				echo EEH_Template::display_template(
2757
+					$metabox['args']['template_path'],
2758
+					$metabox['args']['template_args'],
2759
+					true
2760
+				);
2761
+			}
2762
+			: $callback;
2763
+		add_meta_box(
2764
+			str_replace('_', '-', $action) . '-mbox',
2765
+			$title,
2766
+			$call_back_func,
2767
+			$this->_wp_page_slug,
2768
+			$column,
2769
+			$priority,
2770
+			$callback_args
2771
+		);
2772
+	}
2773
+
2774
+
2775
+	/**
2776
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2777
+	 *
2778
+	 * @throws DomainException
2779
+	 * @throws EE_Error
2780
+	 */
2781
+	public function display_admin_page_with_metabox_columns()
2782
+	{
2783
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2784
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2785
+			$this->_column_template_path,
2786
+			$this->_template_args,
2787
+			true
2788
+		);
2789
+		// the final wrapper
2790
+		$this->admin_page_wrapper();
2791
+	}
2792
+
2793
+
2794
+	/**
2795
+	 * generates  HTML wrapper for an admin details page
2796
+	 *
2797
+	 * @return void
2798
+	 * @throws EE_Error
2799
+	 * @throws DomainException
2800
+	 */
2801
+	public function display_admin_page_with_sidebar()
2802
+	{
2803
+		$this->_display_admin_page(true);
2804
+	}
2805
+
2806
+
2807
+	/**
2808
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2809
+	 *
2810
+	 * @return void
2811
+	 * @throws EE_Error
2812
+	 * @throws DomainException
2813
+	 */
2814
+	public function display_admin_page_with_no_sidebar()
2815
+	{
2816
+		$this->_display_admin_page();
2817
+	}
2818
+
2819
+
2820
+	/**
2821
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2822
+	 *
2823
+	 * @return void
2824
+	 * @throws EE_Error
2825
+	 * @throws DomainException
2826
+	 */
2827
+	public function display_about_admin_page()
2828
+	{
2829
+		$this->_display_admin_page(false, true);
2830
+	}
2831
+
2832
+
2833
+	/**
2834
+	 * display_admin_page
2835
+	 * contains the code for actually displaying an admin page
2836
+	 *
2837
+	 * @param  boolean $sidebar true with sidebar, false without
2838
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2839
+	 * @return void
2840
+	 * @throws DomainException
2841
+	 * @throws EE_Error
2842
+	 */
2843
+	private function _display_admin_page($sidebar = false, $about = false)
2844
+	{
2845
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2846
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2847
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2848
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2849
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2850
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2851
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2852
+			? 'poststuff'
2853
+			: 'espresso-default-admin';
2854
+		$template_path = $sidebar
2855
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2856
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2857
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2858
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2859
+		}
2860
+		$template_path = ! empty($this->_column_template_path)
2861
+			? $this->_column_template_path : $template_path;
2862
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2863
+			? $this->_template_args['admin_page_content']
2864
+			: '';
2865
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2866
+			? $this->_template_args['before_admin_page_content']
2867
+			: '';
2868
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2869
+			? $this->_template_args['after_admin_page_content']
2870
+			: '';
2871
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2872
+			$template_path,
2873
+			$this->_template_args,
2874
+			true
2875
+		);
2876
+		// the final template wrapper
2877
+		$this->admin_page_wrapper($about);
2878
+	}
2879
+
2880
+
2881
+	/**
2882
+	 * This is used to display caf preview pages.
2883
+	 *
2884
+	 * @since 4.3.2
2885
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2886
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2887
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2888
+	 * @return void
2889
+	 * @throws DomainException
2890
+	 * @throws EE_Error
2891
+	 * @throws InvalidArgumentException
2892
+	 * @throws InvalidDataTypeException
2893
+	 * @throws InvalidInterfaceException
2894
+	 */
2895
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2896
+	{
2897
+		// let's generate a default preview action button if there isn't one already present.
2898
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2899
+			'Upgrade to Event Espresso 4 Right Now',
2900
+			'event_espresso'
2901
+		);
2902
+		$buy_now_url = add_query_arg(
2903
+			array(
2904
+				'ee_ver'       => 'ee4',
2905
+				'utm_source'   => 'ee4_plugin_admin',
2906
+				'utm_medium'   => 'link',
2907
+				'utm_campaign' => $utm_campaign_source,
2908
+				'utm_content'  => 'buy_now_button',
2909
+			),
2910
+			'http://eventespresso.com/pricing/'
2911
+		);
2912
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2913
+			? $this->get_action_link_or_button(
2914
+				'',
2915
+				'buy_now',
2916
+				array(),
2917
+				'button-primary button-large',
2918
+				$buy_now_url,
2919
+				true
2920
+			)
2921
+			: $this->_template_args['preview_action_button'];
2922
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2923
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2924
+			$this->_template_args,
2925
+			true
2926
+		);
2927
+		$this->_display_admin_page($display_sidebar);
2928
+	}
2929
+
2930
+
2931
+	/**
2932
+	 * display_admin_list_table_page_with_sidebar
2933
+	 * generates HTML wrapper for an admin_page with list_table
2934
+	 *
2935
+	 * @return void
2936
+	 * @throws EE_Error
2937
+	 * @throws DomainException
2938
+	 */
2939
+	public function display_admin_list_table_page_with_sidebar()
2940
+	{
2941
+		$this->_display_admin_list_table_page(true);
2942
+	}
2943
+
2944
+
2945
+	/**
2946
+	 * display_admin_list_table_page_with_no_sidebar
2947
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2948
+	 *
2949
+	 * @return void
2950
+	 * @throws EE_Error
2951
+	 * @throws DomainException
2952
+	 */
2953
+	public function display_admin_list_table_page_with_no_sidebar()
2954
+	{
2955
+		$this->_display_admin_list_table_page();
2956
+	}
2957
+
2958
+
2959
+	/**
2960
+	 * generates html wrapper for an admin_list_table page
2961
+	 *
2962
+	 * @param boolean $sidebar whether to display with sidebar or not.
2963
+	 * @return void
2964
+	 * @throws DomainException
2965
+	 * @throws EE_Error
2966
+	 */
2967
+	private function _display_admin_list_table_page($sidebar = false)
2968
+	{
2969
+		// setup search attributes
2970
+		$this->_set_search_attributes();
2971
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2972
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2973
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2974
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2975
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2976
+		$this->_template_args['list_table'] = $this->_list_table_object;
2977
+		$this->_template_args['current_route'] = $this->_req_action;
2978
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2979
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2980
+		if (! empty($ajax_sorting_callback)) {
2981
+			$sortable_list_table_form_fields = wp_nonce_field(
2982
+				$ajax_sorting_callback . '_nonce',
2983
+				$ajax_sorting_callback . '_nonce',
2984
+				false,
2985
+				false
2986
+			);
2987
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2988
+												. $this->page_slug
2989
+												. '" />';
2990
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2991
+												. $ajax_sorting_callback
2992
+												. '" />';
2993
+		} else {
2994
+			$sortable_list_table_form_fields = '';
2995
+		}
2996
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2997
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2998
+			? $this->_template_args['list_table_hidden_fields']
2999
+			: '';
3000
+		$nonce_ref = $this->_req_action . '_nonce';
3001
+		$hidden_form_fields .= '<input type="hidden" name="'
3002
+							   . $nonce_ref
3003
+							   . '" value="'
3004
+							   . wp_create_nonce($nonce_ref)
3005
+							   . '">';
3006
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3007
+		// display message about search results?
3008
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3009
+			? '<p class="ee-search-results">' . sprintf(
3010
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3011
+				trim($this->_req_data['s'], '%')
3012
+			) . '</p>'
3013
+			: '';
3014
+		// filter before_list_table template arg
3015
+		$this->_template_args['before_list_table'] = apply_filters(
3016
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3017
+			$this->_template_args['before_list_table'],
3018
+			$this->page_slug,
3019
+			$this->_req_data,
3020
+			$this->_req_action
3021
+		);
3022
+		// convert to array and filter again
3023
+		// arrays are easier to inject new items in a specific location,
3024
+		// but would not be backwards compatible, so we have to add a new filter
3025
+		$this->_template_args['before_list_table'] = implode(
3026
+			" \n",
3027
+			(array) apply_filters(
3028
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3029
+				(array) $this->_template_args['before_list_table'],
3030
+				$this->page_slug,
3031
+				$this->_req_data,
3032
+				$this->_req_action
3033
+			)
3034
+		);
3035
+		// filter after_list_table template arg
3036
+		$this->_template_args['after_list_table'] = apply_filters(
3037
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3038
+			$this->_template_args['after_list_table'],
3039
+			$this->page_slug,
3040
+			$this->_req_data,
3041
+			$this->_req_action
3042
+		);
3043
+		// convert to array and filter again
3044
+		// arrays are easier to inject new items in a specific location,
3045
+		// but would not be backwards compatible, so we have to add a new filter
3046
+		$this->_template_args['after_list_table'] = implode(
3047
+			" \n",
3048
+			(array) apply_filters(
3049
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3050
+				(array) $this->_template_args['after_list_table'],
3051
+				$this->page_slug,
3052
+				$this->_req_data,
3053
+				$this->_req_action
3054
+			)
3055
+		);
3056
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3057
+			$template_path,
3058
+			$this->_template_args,
3059
+			true
3060
+		);
3061
+		// the final template wrapper
3062
+		if ($sidebar) {
3063
+			$this->display_admin_page_with_sidebar();
3064
+		} else {
3065
+			$this->display_admin_page_with_no_sidebar();
3066
+		}
3067
+	}
3068
+
3069
+
3070
+	/**
3071
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3072
+	 * html string for the legend.
3073
+	 * $items are expected in an array in the following format:
3074
+	 * $legend_items = array(
3075
+	 *        'item_id' => array(
3076
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3077
+	 *            'desc' => esc_html__('localized description of item');
3078
+	 *        )
3079
+	 * );
3080
+	 *
3081
+	 * @param  array $items see above for format of array
3082
+	 * @return string html string of legend
3083
+	 * @throws DomainException
3084
+	 */
3085
+	protected function _display_legend($items)
3086
+	{
3087
+		$this->_template_args['items'] = apply_filters(
3088
+			'FHEE__EE_Admin_Page___display_legend__items',
3089
+			(array) $items,
3090
+			$this
3091
+		);
3092
+		return EEH_Template::display_template(
3093
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3094
+			$this->_template_args,
3095
+			true
3096
+		);
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3102
+	 * The returned json object is created from an array in the following format:
3103
+	 * array(
3104
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3105
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3106
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3107
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3108
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3109
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3110
+	 *  that might be included in here)
3111
+	 * )
3112
+	 * The json object is populated by whatever is set in the $_template_args property.
3113
+	 *
3114
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3115
+	 *                                 instead of displayed.
3116
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3117
+	 * @return void
3118
+	 * @throws EE_Error
3119
+	 */
3120
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3121
+	{
3122
+		// make sure any EE_Error notices have been handled.
3123
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3124
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3125
+		unset($this->_template_args['data']);
3126
+		$json = array(
3127
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3128
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3129
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3130
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3131
+			'notices'   => EE_Error::get_notices(),
3132
+			'content'   => isset($this->_template_args['admin_page_content'])
3133
+				? $this->_template_args['admin_page_content'] : '',
3134
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3135
+			'isEEajax'  => true
3136
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3137
+		);
3138
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3139
+		if (null === error_get_last() || ! headers_sent()) {
3140
+			header('Content-Type: application/json; charset=UTF-8');
3141
+		}
3142
+		echo wp_json_encode($json);
3143
+		exit();
3144
+	}
3145
+
3146
+
3147
+	/**
3148
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3149
+	 *
3150
+	 * @return void
3151
+	 * @throws EE_Error
3152
+	 */
3153
+	public function return_json()
3154
+	{
3155
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3156
+			$this->_return_json();
3157
+		} else {
3158
+			throw new EE_Error(
3159
+				sprintf(
3160
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3161
+					__FUNCTION__
3162
+				)
3163
+			);
3164
+		}
3165
+	}
3166
+
3167
+
3168
+	/**
3169
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3170
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3171
+	 *
3172
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3173
+	 */
3174
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3175
+	{
3176
+		$this->_hook_obj = $hook_obj;
3177
+	}
3178
+
3179
+
3180
+	/**
3181
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3182
+	 *
3183
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3184
+	 * @return void
3185
+	 * @throws DomainException
3186
+	 * @throws EE_Error
3187
+	 */
3188
+	public function admin_page_wrapper($about = false)
3189
+	{
3190
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3191
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3192
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3193
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3194
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3195
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3196
+			isset($this->_template_args['before_admin_page_content'])
3197
+				? $this->_template_args['before_admin_page_content']
3198
+				: ''
3199
+		);
3200
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3201
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3202
+			isset($this->_template_args['after_admin_page_content'])
3203
+				? $this->_template_args['after_admin_page_content']
3204
+				: ''
3205
+		);
3206
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3207
+		// load settings page wrapper template
3208
+		$template_path = ! defined('DOING_AJAX')
3209
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3210
+			: EE_ADMIN_TEMPLATE
3211
+			  . 'admin_wrapper_ajax.template.php';
3212
+		// about page?
3213
+		$template_path = $about
3214
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3215
+			: $template_path;
3216
+		if (defined('DOING_AJAX')) {
3217
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3218
+				$template_path,
3219
+				$this->_template_args,
3220
+				true
3221
+			);
3222
+			$this->_return_json();
3223
+		} else {
3224
+			EEH_Template::display_template($template_path, $this->_template_args);
3225
+		}
3226
+	}
3227
+
3228
+
3229
+	/**
3230
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3231
+	 *
3232
+	 * @return string html
3233
+	 * @throws EE_Error
3234
+	 */
3235
+	protected function _get_main_nav_tabs()
3236
+	{
3237
+		// let's generate the html using the EEH_Tabbed_Content helper.
3238
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3239
+		// (rather than setting in the page_routes array)
3240
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3241
+	}
3242
+
3243
+
3244
+	/**
3245
+	 *        sort nav tabs
3246
+	 *
3247
+	 * @param $a
3248
+	 * @param $b
3249
+	 * @return int
3250
+	 */
3251
+	private function _sort_nav_tabs($a, $b)
3252
+	{
3253
+		if ($a['order'] === $b['order']) {
3254
+			return 0;
3255
+		}
3256
+		return ($a['order'] < $b['order']) ? -1 : 1;
3257
+	}
3258
+
3259
+
3260
+	/**
3261
+	 *    generates HTML for the forms used on admin pages
3262
+	 *
3263
+	 * @param    array $input_vars - array of input field details
3264
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3265
+	 *                             use)
3266
+	 * @param bool     $id
3267
+	 * @return string
3268
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3269
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3270
+	 */
3271
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3272
+	{
3273
+		$content = $generator === 'string'
3274
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3275
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3276
+		return $content;
3277
+	}
3278
+
3279
+
3280
+	/**
3281
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3282
+	 *
3283
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3284
+	 *                                   Close" button.
3285
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3286
+	 *                                   'Save', [1] => 'save & close')
3287
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3288
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3289
+	 *                                   default actions by submitting some other value.
3290
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3291
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3292
+	 *                                   close (normal form handling).
3293
+	 */
3294
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3295
+	{
3296
+		// make sure $text and $actions are in an array
3297
+		$text = (array) $text;
3298
+		$actions = (array) $actions;
3299
+		$referrer_url = empty($referrer)
3300
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3301
+			  . $_SERVER['REQUEST_URI']
3302
+			  . '" />'
3303
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3304
+			  . $referrer
3305
+			  . '" />';
3306
+		$button_text = ! empty($text)
3307
+			? $text
3308
+			: array(
3309
+				esc_html__('Save', 'event_espresso'),
3310
+				esc_html__('Save and Close', 'event_espresso'),
3311
+			);
3312
+		$default_names = array('save', 'save_and_close');
3313
+		// add in a hidden index for the current page (so save and close redirects properly)
3314
+		$this->_template_args['save_buttons'] = $referrer_url;
3315
+		foreach ($button_text as $key => $button) {
3316
+			$ref = $default_names[ $key ];
3317
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3318
+													 . $ref
3319
+													 . '" value="'
3320
+													 . $button
3321
+													 . '" name="'
3322
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3323
+													 . '" id="'
3324
+													 . $this->_current_view . '_' . $ref
3325
+													 . '" />';
3326
+			if (! $both) {
3327
+				break;
3328
+			}
3329
+		}
3330
+	}
3331
+
3332
+
3333
+	/**
3334
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3335
+	 *
3336
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3337
+	 * @since 4.6.0
3338
+	 * @param string $route
3339
+	 * @param array  $additional_hidden_fields
3340
+	 */
3341
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3342
+	{
3343
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3344
+	}
3345
+
3346
+
3347
+	/**
3348
+	 * set form open and close tags on add/edit pages.
3349
+	 *
3350
+	 * @param string $route                    the route you want the form to direct to
3351
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3352
+	 * @return void
3353
+	 */
3354
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3355
+	{
3356
+		if (empty($route)) {
3357
+			$user_msg = esc_html__(
3358
+				'An error occurred. No action was set for this page\'s form.',
3359
+				'event_espresso'
3360
+			);
3361
+			$dev_msg = $user_msg . "\n"
3362
+					   . sprintf(
3363
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3364
+						   __FUNCTION__,
3365
+						   __CLASS__
3366
+					   );
3367
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3368
+		}
3369
+		// open form
3370
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3371
+															 . $this->_admin_base_url
3372
+															 . '" id="'
3373
+															 . $route
3374
+															 . '_event_form" >';
3375
+		// add nonce
3376
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3377
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3378
+		// add REQUIRED form action
3379
+		$hidden_fields = array(
3380
+			'action' => array('type' => 'hidden', 'value' => $route),
3381
+		);
3382
+		// merge arrays
3383
+		$hidden_fields = is_array($additional_hidden_fields)
3384
+			? array_merge($hidden_fields, $additional_hidden_fields)
3385
+			: $hidden_fields;
3386
+		// generate form fields
3387
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3388
+		// add fields to form
3389
+		foreach ((array) $form_fields as $field_name => $form_field) {
3390
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3391
+		}
3392
+		// close form
3393
+		$this->_template_args['after_admin_page_content'] = '</form>';
3394
+	}
3395
+
3396
+
3397
+	/**
3398
+	 * Public Wrapper for _redirect_after_action() method since its
3399
+	 * discovered it would be useful for external code to have access.
3400
+	 *
3401
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3402
+	 * @since 4.5.0
3403
+	 * @param bool   $success
3404
+	 * @param string $what
3405
+	 * @param string $action_desc
3406
+	 * @param array  $query_args
3407
+	 * @param bool   $override_overwrite
3408
+	 * @throws EE_Error
3409
+	 */
3410
+	public function redirect_after_action(
3411
+		$success = false,
3412
+		$what = 'item',
3413
+		$action_desc = 'processed',
3414
+		$query_args = array(),
3415
+		$override_overwrite = false
3416
+	) {
3417
+		$this->_redirect_after_action(
3418
+			$success,
3419
+			$what,
3420
+			$action_desc,
3421
+			$query_args,
3422
+			$override_overwrite
3423
+		);
3424
+	}
3425
+
3426
+
3427
+	/**
3428
+	 * Helper method for merging existing request data with the returned redirect url.
3429
+	 *
3430
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3431
+	 * filters are still applied.
3432
+	 *
3433
+	 * @param array $new_route_data
3434
+	 * @return array
3435
+	 */
3436
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3437
+	{
3438
+		foreach ($this->_req_data as $ref => $value) {
3439
+			// unset nonces
3440
+			if (strpos($ref, 'nonce') !== false) {
3441
+				unset($this->_req_data[ $ref ]);
3442
+				continue;
3443
+			}
3444
+			// urlencode values.
3445
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3446
+			$this->_req_data[ $ref ] = $value;
3447
+		}
3448
+		return array_merge($this->_req_data, $new_route_data);
3449
+	}
3450
+
3451
+
3452
+	/**
3453
+	 *    _redirect_after_action
3454
+	 *
3455
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3456
+	 * @param string $what               - what the action was performed on
3457
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3458
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3459
+	 *                                   action is completed
3460
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3461
+	 *                                   override this so that they show.
3462
+	 * @return void
3463
+	 * @throws EE_Error
3464
+	 */
3465
+	protected function _redirect_after_action(
3466
+		$success = 0,
3467
+		$what = 'item',
3468
+		$action_desc = 'processed',
3469
+		$query_args = array(),
3470
+		$override_overwrite = false
3471
+	) {
3472
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3473
+		// class name for actions/filters.
3474
+		$classname = get_class($this);
3475
+		// set redirect url.
3476
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3477
+		// otherwise we go with whatever is set as the _admin_base_url
3478
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3479
+		$notices = EE_Error::get_notices(false);
3480
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3481
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3482
+			EE_Error::overwrite_success();
3483
+		}
3484
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3485
+			// how many records affected ? more than one record ? or just one ?
3486
+			if ($success > 1) {
3487
+				// set plural msg
3488
+				EE_Error::add_success(
3489
+					sprintf(
3490
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3491
+						$what,
3492
+						$action_desc
3493
+					),
3494
+					__FILE__,
3495
+					__FUNCTION__,
3496
+					__LINE__
3497
+				);
3498
+			} elseif ($success === 1) {
3499
+				// set singular msg
3500
+				EE_Error::add_success(
3501
+					sprintf(
3502
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3503
+						$what,
3504
+						$action_desc
3505
+					),
3506
+					__FILE__,
3507
+					__FUNCTION__,
3508
+					__LINE__
3509
+				);
3510
+			}
3511
+		}
3512
+		// check that $query_args isn't something crazy
3513
+		if (! is_array($query_args)) {
3514
+			$query_args = array();
3515
+		}
3516
+		/**
3517
+		 * Allow injecting actions before the query_args are modified for possible different
3518
+		 * redirections on save and close actions
3519
+		 *
3520
+		 * @since 4.2.0
3521
+		 * @param array $query_args       The original query_args array coming into the
3522
+		 *                                method.
3523
+		 */
3524
+		do_action(
3525
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3526
+			$query_args
3527
+		);
3528
+		// calculate where we're going (if we have a "save and close" button pushed)
3529
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3530
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3531
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3532
+			// regenerate query args array from referrer URL
3533
+			parse_str($parsed_url['query'], $query_args);
3534
+			// correct page and action will be in the query args now
3535
+			$redirect_url = admin_url('admin.php');
3536
+		}
3537
+		// merge any default query_args set in _default_route_query_args property
3538
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3539
+			$args_to_merge = array();
3540
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3541
+				// is there a wp_referer array in our _default_route_query_args property?
3542
+				if ($query_param === 'wp_referer') {
3543
+					$query_value = (array) $query_value;
3544
+					foreach ($query_value as $reference => $value) {
3545
+						if (strpos($reference, 'nonce') !== false) {
3546
+							continue;
3547
+						}
3548
+						// finally we will override any arguments in the referer with
3549
+						// what might be set on the _default_route_query_args array.
3550
+						if (isset($this->_default_route_query_args[ $reference ])) {
3551
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3552
+						} else {
3553
+							$args_to_merge[ $reference ] = urlencode($value);
3554
+						}
3555
+					}
3556
+					continue;
3557
+				}
3558
+				$args_to_merge[ $query_param ] = $query_value;
3559
+			}
3560
+			// now let's merge these arguments but override with what was specifically sent in to the
3561
+			// redirect.
3562
+			$query_args = array_merge($args_to_merge, $query_args);
3563
+		}
3564
+		$this->_process_notices($query_args);
3565
+		// generate redirect url
3566
+		// if redirecting to anything other than the main page, add a nonce
3567
+		if (isset($query_args['action'])) {
3568
+			// manually generate wp_nonce and merge that with the query vars
3569
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3570
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3571
+		}
3572
+		// we're adding some hooks and filters in here for processing any things just before redirects
3573
+		// (example: an admin page has done an insert or update and we want to run something after that).
3574
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3575
+		$redirect_url = apply_filters(
3576
+			'FHEE_redirect_' . $classname . $this->_req_action,
3577
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3578
+			$query_args
3579
+		);
3580
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3581
+		if (defined('DOING_AJAX')) {
3582
+			$default_data = array(
3583
+				'close'        => true,
3584
+				'redirect_url' => $redirect_url,
3585
+				'where'        => 'main',
3586
+				'what'         => 'append',
3587
+			);
3588
+			$this->_template_args['success'] = $success;
3589
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3590
+				$default_data,
3591
+				$this->_template_args['data']
3592
+			) : $default_data;
3593
+			$this->_return_json();
3594
+		}
3595
+		wp_safe_redirect($redirect_url);
3596
+		exit();
3597
+	}
3598
+
3599
+
3600
+	/**
3601
+	 * process any notices before redirecting (or returning ajax request)
3602
+	 * This method sets the $this->_template_args['notices'] attribute;
3603
+	 *
3604
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3605
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3606
+	 *                                  page_routes haven't been defined yet.
3607
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3608
+	 *                                  still save a transient for the notice.
3609
+	 * @return void
3610
+	 * @throws EE_Error
3611
+	 */
3612
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3613
+	{
3614
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3615
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3616
+			$notices = EE_Error::get_notices(false);
3617
+			if (empty($this->_template_args['success'])) {
3618
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3619
+			}
3620
+			if (empty($this->_template_args['errors'])) {
3621
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3622
+			}
3623
+			if (empty($this->_template_args['attention'])) {
3624
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3625
+			}
3626
+		}
3627
+		$this->_template_args['notices'] = EE_Error::get_notices();
3628
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3629
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3630
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3631
+			$this->_add_transient(
3632
+				$route,
3633
+				$this->_template_args['notices'],
3634
+				true,
3635
+				$skip_route_verify
3636
+			);
3637
+		}
3638
+	}
3639
+
3640
+
3641
+	/**
3642
+	 * get_action_link_or_button
3643
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3644
+	 *
3645
+	 * @param string $action        use this to indicate which action the url is generated with.
3646
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3647
+	 *                              property.
3648
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3649
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3650
+	 * @param string $base_url      If this is not provided
3651
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3652
+	 *                              Otherwise this value will be used.
3653
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3654
+	 * @return string
3655
+	 * @throws InvalidArgumentException
3656
+	 * @throws InvalidInterfaceException
3657
+	 * @throws InvalidDataTypeException
3658
+	 * @throws EE_Error
3659
+	 */
3660
+	public function get_action_link_or_button(
3661
+		$action,
3662
+		$type = 'add',
3663
+		$extra_request = array(),
3664
+		$class = 'button-primary',
3665
+		$base_url = '',
3666
+		$exclude_nonce = false
3667
+	) {
3668
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3669
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3670
+			throw new EE_Error(
3671
+				sprintf(
3672
+					esc_html__(
3673
+						'There is no page route for given action for the button.  This action was given: %s',
3674
+						'event_espresso'
3675
+					),
3676
+					$action
3677
+				)
3678
+			);
3679
+		}
3680
+		if (! isset($this->_labels['buttons'][ $type ])) {
3681
+			throw new EE_Error(
3682
+				sprintf(
3683
+					__(
3684
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3685
+						'event_espresso'
3686
+					),
3687
+					$type
3688
+				)
3689
+			);
3690
+		}
3691
+		// finally check user access for this button.
3692
+		$has_access = $this->check_user_access($action, true);
3693
+		if (! $has_access) {
3694
+			return '';
3695
+		}
3696
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3697
+		$query_args = array(
3698
+			'action' => $action,
3699
+		);
3700
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3701
+		if (! empty($extra_request)) {
3702
+			$query_args = array_merge($extra_request, $query_args);
3703
+		}
3704
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3705
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3706
+	}
3707
+
3708
+
3709
+	/**
3710
+	 * _per_page_screen_option
3711
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3712
+	 *
3713
+	 * @return void
3714
+	 * @throws InvalidArgumentException
3715
+	 * @throws InvalidInterfaceException
3716
+	 * @throws InvalidDataTypeException
3717
+	 */
3718
+	protected function _per_page_screen_option()
3719
+	{
3720
+		$option = 'per_page';
3721
+		$args = array(
3722
+			'label'   => apply_filters(
3723
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3724
+				$this->_admin_page_title,
3725
+				$this
3726
+			),
3727
+			'default' => (int) apply_filters(
3728
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3729
+				20
3730
+			),
3731
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3732
+		);
3733
+		// ONLY add the screen option if the user has access to it.
3734
+		if ($this->check_user_access($this->_current_view, true)) {
3735
+			add_screen_option($option, $args);
3736
+		}
3737
+	}
3738
+
3739
+
3740
+	/**
3741
+	 * set_per_page_screen_option
3742
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3743
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3744
+	 * admin_menu.
3745
+	 *
3746
+	 * @return void
3747
+	 */
3748
+	private function _set_per_page_screen_options()
3749
+	{
3750
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3751
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3752
+			if (! $user = wp_get_current_user()) {
3753
+				return;
3754
+			}
3755
+			$option = $_POST['wp_screen_options']['option'];
3756
+			$value = $_POST['wp_screen_options']['value'];
3757
+			if ($option != sanitize_key($option)) {
3758
+				return;
3759
+			}
3760
+			$map_option = $option;
3761
+			$option = str_replace('-', '_', $option);
3762
+			switch ($map_option) {
3763
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3764
+					$value = (int) $value;
3765
+					$max_value = apply_filters(
3766
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3767
+						999,
3768
+						$this->_current_page,
3769
+						$this->_current_view
3770
+					);
3771
+					if ($value < 1) {
3772
+						return;
3773
+					}
3774
+					$value = min($value, $max_value);
3775
+					break;
3776
+				default:
3777
+					$value = apply_filters(
3778
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3779
+						false,
3780
+						$option,
3781
+						$value
3782
+					);
3783
+					if (false === $value) {
3784
+						return;
3785
+					}
3786
+					break;
3787
+			}
3788
+			update_user_meta($user->ID, $option, $value);
3789
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3790
+			exit;
3791
+		}
3792
+	}
3793
+
3794
+
3795
+	/**
3796
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3797
+	 *
3798
+	 * @param array $data array that will be assigned to template args.
3799
+	 */
3800
+	public function set_template_args($data)
3801
+	{
3802
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3803
+	}
3804
+
3805
+
3806
+	/**
3807
+	 * This makes available the WP transient system for temporarily moving data between routes
3808
+	 *
3809
+	 * @param string $route             the route that should receive the transient
3810
+	 * @param array  $data              the data that gets sent
3811
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3812
+	 *                                  normal route transient.
3813
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3814
+	 *                                  when we are adding a transient before page_routes have been defined.
3815
+	 * @return void
3816
+	 * @throws EE_Error
3817
+	 */
3818
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3819
+	{
3820
+		$user_id = get_current_user_id();
3821
+		if (! $skip_route_verify) {
3822
+			$this->_verify_route($route);
3823
+		}
3824
+		// now let's set the string for what kind of transient we're setting
3825
+		$transient = $notices
3826
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3827
+			: 'rte_tx_' . $route . '_' . $user_id;
3828
+		$data = $notices ? array('notices' => $data) : $data;
3829
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3830
+		$existing = is_multisite() && is_network_admin()
3831
+			? get_site_transient($transient)
3832
+			: get_transient($transient);
3833
+		if ($existing) {
3834
+			$data = array_merge((array) $data, (array) $existing);
3835
+		}
3836
+		if (is_multisite() && is_network_admin()) {
3837
+			set_site_transient($transient, $data, 8);
3838
+		} else {
3839
+			set_transient($transient, $data, 8);
3840
+		}
3841
+	}
3842
+
3843
+
3844
+	/**
3845
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3846
+	 *
3847
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3848
+	 * @param string $route
3849
+	 * @return mixed data
3850
+	 */
3851
+	protected function _get_transient($notices = false, $route = '')
3852
+	{
3853
+		$user_id = get_current_user_id();
3854
+		$route = ! $route ? $this->_req_action : $route;
3855
+		$transient = $notices
3856
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3857
+			: 'rte_tx_' . $route . '_' . $user_id;
3858
+		$data = is_multisite() && is_network_admin()
3859
+			? get_site_transient($transient)
3860
+			: get_transient($transient);
3861
+		// delete transient after retrieval (just in case it hasn't expired);
3862
+		if (is_multisite() && is_network_admin()) {
3863
+			delete_site_transient($transient);
3864
+		} else {
3865
+			delete_transient($transient);
3866
+		}
3867
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3868
+	}
3869
+
3870
+
3871
+	/**
3872
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3873
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3874
+	 * default route callback on the EE_Admin page you want it run.)
3875
+	 *
3876
+	 * @return void
3877
+	 */
3878
+	protected function _transient_garbage_collection()
3879
+	{
3880
+		global $wpdb;
3881
+		// retrieve all existing transients
3882
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3883
+		if ($results = $wpdb->get_results($query)) {
3884
+			foreach ($results as $result) {
3885
+				$transient = str_replace('_transient_', '', $result->option_name);
3886
+				get_transient($transient);
3887
+				if (is_multisite() && is_network_admin()) {
3888
+					get_site_transient($transient);
3889
+				}
3890
+			}
3891
+		}
3892
+	}
3893
+
3894
+
3895
+	/**
3896
+	 * get_view
3897
+	 *
3898
+	 * @return string content of _view property
3899
+	 */
3900
+	public function get_view()
3901
+	{
3902
+		return $this->_view;
3903
+	}
3904
+
3905
+
3906
+	/**
3907
+	 * getter for the protected $_views property
3908
+	 *
3909
+	 * @return array
3910
+	 */
3911
+	public function get_views()
3912
+	{
3913
+		return $this->_views;
3914
+	}
3915
+
3916
+
3917
+	/**
3918
+	 * get_current_page
3919
+	 *
3920
+	 * @return string _current_page property value
3921
+	 */
3922
+	public function get_current_page()
3923
+	{
3924
+		return $this->_current_page;
3925
+	}
3926
+
3927
+
3928
+	/**
3929
+	 * get_current_view
3930
+	 *
3931
+	 * @return string _current_view property value
3932
+	 */
3933
+	public function get_current_view()
3934
+	{
3935
+		return $this->_current_view;
3936
+	}
3937
+
3938
+
3939
+	/**
3940
+	 * get_current_screen
3941
+	 *
3942
+	 * @return object The current WP_Screen object
3943
+	 */
3944
+	public function get_current_screen()
3945
+	{
3946
+		return $this->_current_screen;
3947
+	}
3948
+
3949
+
3950
+	/**
3951
+	 * get_current_page_view_url
3952
+	 *
3953
+	 * @return string This returns the url for the current_page_view.
3954
+	 */
3955
+	public function get_current_page_view_url()
3956
+	{
3957
+		return $this->_current_page_view_url;
3958
+	}
3959
+
3960
+
3961
+	/**
3962
+	 * just returns the _req_data property
3963
+	 *
3964
+	 * @return array
3965
+	 */
3966
+	public function get_request_data()
3967
+	{
3968
+		return $this->_req_data;
3969
+	}
3970
+
3971
+
3972
+	/**
3973
+	 * returns the _req_data protected property
3974
+	 *
3975
+	 * @return string
3976
+	 */
3977
+	public function get_req_action()
3978
+	{
3979
+		return $this->_req_action;
3980
+	}
3981
+
3982
+
3983
+	/**
3984
+	 * @return bool  value of $_is_caf property
3985
+	 */
3986
+	public function is_caf()
3987
+	{
3988
+		return $this->_is_caf;
3989
+	}
3990
+
3991
+
3992
+	/**
3993
+	 * @return mixed
3994
+	 */
3995
+	public function default_espresso_metaboxes()
3996
+	{
3997
+		return $this->_default_espresso_metaboxes;
3998
+	}
3999
+
4000
+
4001
+	/**
4002
+	 * @return mixed
4003
+	 */
4004
+	public function admin_base_url()
4005
+	{
4006
+		return $this->_admin_base_url;
4007
+	}
4008
+
4009
+
4010
+	/**
4011
+	 * @return mixed
4012
+	 */
4013
+	public function wp_page_slug()
4014
+	{
4015
+		return $this->_wp_page_slug;
4016
+	}
4017
+
4018
+
4019
+	/**
4020
+	 * updates  espresso configuration settings
4021
+	 *
4022
+	 * @param string                   $tab
4023
+	 * @param EE_Config_Base|EE_Config $config
4024
+	 * @param string                   $file file where error occurred
4025
+	 * @param string                   $func function  where error occurred
4026
+	 * @param string                   $line line no where error occurred
4027
+	 * @return boolean
4028
+	 */
4029
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4030
+	{
4031
+		// remove any options that are NOT going to be saved with the config settings.
4032
+		if (isset($config->core->ee_ueip_optin)) {
4033
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4034
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4035
+			update_option('ee_ueip_has_notified', true);
4036
+		}
4037
+		// and save it (note we're also doing the network save here)
4038
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4039
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4040
+		if ($config_saved && $net_saved) {
4041
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4042
+			return true;
4043
+		}
4044
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4045
+		return false;
4046
+	}
4047
+
4048
+
4049
+	/**
4050
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4051
+	 *
4052
+	 * @return array
4053
+	 */
4054
+	public function get_yes_no_values()
4055
+	{
4056
+		return $this->_yes_no_values;
4057
+	}
4058
+
4059
+
4060
+	protected function _get_dir()
4061
+	{
4062
+		$reflector = new ReflectionClass(get_class($this));
4063
+		return dirname($reflector->getFileName());
4064
+	}
4065
+
4066
+
4067
+	/**
4068
+	 * A helper for getting a "next link".
4069
+	 *
4070
+	 * @param string $url   The url to link to
4071
+	 * @param string $class The class to use.
4072
+	 * @return string
4073
+	 */
4074
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4075
+	{
4076
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4077
+	}
4078
+
4079
+
4080
+	/**
4081
+	 * A helper for getting a "previous link".
4082
+	 *
4083
+	 * @param string $url   The url to link to
4084
+	 * @param string $class The class to use.
4085
+	 * @return string
4086
+	 */
4087
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4088
+	{
4089
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4090
+	}
4091
+
4092
+
4093
+
4094
+
4095
+
4096
+
4097
+
4098
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4099
+
4100
+
4101
+	/**
4102
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4103
+	 * 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
4104
+	 * _req_data array.
4105
+	 *
4106
+	 * @return bool success/fail
4107
+	 * @throws EE_Error
4108
+	 * @throws InvalidArgumentException
4109
+	 * @throws ReflectionException
4110
+	 * @throws InvalidDataTypeException
4111
+	 * @throws InvalidInterfaceException
4112
+	 */
4113
+	protected function _process_resend_registration()
4114
+	{
4115
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4116
+		do_action(
4117
+			'AHEE__EE_Admin_Page___process_resend_registration',
4118
+			$this->_template_args['success'],
4119
+			$this->_req_data
4120
+		);
4121
+		return $this->_template_args['success'];
4122
+	}
4123
+
4124
+
4125
+	/**
4126
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4127
+	 *
4128
+	 * @param \EE_Payment $payment
4129
+	 * @return bool success/fail
4130
+	 */
4131
+	protected function _process_payment_notification(EE_Payment $payment)
4132
+	{
4133
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4134
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4135
+		$this->_template_args['success'] = apply_filters(
4136
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4137
+			false,
4138
+			$payment
4139
+		);
4140
+		return $this->_template_args['success'];
4141
+	}
4142 4142
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.12.rc.008');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.12.rc.008');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.