Completed
Branch BUG-10202-persistent-admin-not... (41a214)
by
unknown
42:16 queued 30:56
created
core/services/cache/PostRelatedCacheManager.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -17,126 +17,126 @@
 block discarded – undo
17 17
 class PostRelatedCacheManager extends BasicCacheManager
18 18
 {
19 19
 
20
-    /**
21
-     * @type string
22
-     */
23
-    const POST_CACHE_PREFIX = 'ee_cache_post_';
24
-
25
-    /**
26
-     * wp-option option_name for tracking post related cache
27
-     *
28
-     * @type string
29
-     */
30
-    const POST_CACHE_OPTIONS_KEY = 'ee_post_cache';
31
-
32
-
33
-
34
-    /**
35
-     * PostRelatedCacheManager constructor.
36
-     *
37
-     * @param CacheStorageInterface      $cache_storage
38
-     */
39
-    public function __construct(CacheStorageInterface $cache_storage)
40
-    {
41
-        parent::__construct($cache_storage);
42
-        add_action('save_post', array($this, 'clearPostRelatedCache'));
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * returns a string that will be prepended to all cache identifiers
49
-     *
50
-     * @return string
51
-     */
52
-    public function cachePrefix()
53
-    {
54
-        return PostRelatedCacheManager::POST_CACHE_PREFIX;
55
-    }
56
-
57
-
58
-    /**
59
-     * @return array
60
-     */
61
-    protected function getPostRelatedCache()
62
-    {
63
-        $post_related_cache = get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
64
-        // verify that cached data was not truncated or corrupted and no longer an array
65
-        if (! is_array($post_related_cache))  {
66
-            // uh-oh... let's get rid of any transients using our cache prefix
67
-            $this->clear(PostRelatedCacheManager::CACHE_PREFIX);
68
-            // then update the post related cache tracking option
69
-            $post_related_cache = array();
70
-            $this->updatePostRelatedCache($post_related_cache);
71
-        }
72
-        return $post_related_cache;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param array $post_related_cache
78
-     */
79
-    protected function updatePostRelatedCache(array $post_related_cache = array())
80
-    {
81
-        update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
82
-    }
83
-
84
-
85
-    /**
86
-     * If you are caching content that pertains to a Post of any type,
87
-     * then it is recommended to pass the post id and cache id prefix to this method
88
-     * so that it can be added to the post related cache tracking.
89
-     * Then, whenever that post is updated, the cache will automatically be deleted,
90
-     * which helps to ensure that outdated cache content will not be served
91
-     *
92
-     * @param int    $post_ID    [required]
93
-     * @param string $id_prefix  [required] Appended to all cache IDs. Can be helpful in finding specific cache types.
94
-     *                           May also be helpful to include an additional specific identifier,
95
-     *                           such as a post ID as part of the $id_prefix so that individual caches
96
-     *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
97
-     *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
98
-     */
99
-    public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix)
100
-    {
101
-        $post_related_cache = $this->getPostRelatedCache();
102
-        // if post is not already being tracked
103
-        if ( ! isset($post_related_cache[$post_ID])) {
104
-            // add array to add cache ids to
105
-            $post_related_cache[$post_ID] = array();
106
-        }
107
-        if( ! in_array($id_prefix, $post_related_cache[$post_ID], true)) {
108
-            // add cache id to be tracked
109
-            $post_related_cache[$post_ID][] = $id_prefix;
110
-            $this->updatePostRelatedCache($post_related_cache);
111
-        }
112
-    }
113
-
114
-
115
-
116
-    /**
117
-     * callback hooked into the WordPress "save_post" action
118
-     * deletes any cache content associated with the post
119
-     *
120
-     * @param int $post_ID [required]
121
-     */
122
-    public function clearPostRelatedCache($post_ID)
123
-    {
124
-        $post_related_cache = $this->getPostRelatedCache();
125
-        // if post is not being tracked
126
-        if ( ! isset($post_related_cache[$post_ID])) {
127
-            // let's clean up some of the duplicate IDs that were getting added
128
-            foreach ($post_related_cache as $other_post_ID => $cache_IDs) {
129
-                //remove duplicates
130
-                $post_related_cache[$other_post_ID] = array_unique($post_related_cache[$other_post_ID]);
131
-            }
132
-            $this->updatePostRelatedCache($post_related_cache);
133
-            return;
134
-        }
135
-        // get cache id prefixes for post, and delete their corresponding transients
136
-        $this->clear($post_related_cache[$post_ID]);
137
-        unset($post_related_cache[$post_ID]);
138
-        $this->updatePostRelatedCache($post_related_cache);
139
-    }
20
+	/**
21
+	 * @type string
22
+	 */
23
+	const POST_CACHE_PREFIX = 'ee_cache_post_';
24
+
25
+	/**
26
+	 * wp-option option_name for tracking post related cache
27
+	 *
28
+	 * @type string
29
+	 */
30
+	const POST_CACHE_OPTIONS_KEY = 'ee_post_cache';
31
+
32
+
33
+
34
+	/**
35
+	 * PostRelatedCacheManager constructor.
36
+	 *
37
+	 * @param CacheStorageInterface      $cache_storage
38
+	 */
39
+	public function __construct(CacheStorageInterface $cache_storage)
40
+	{
41
+		parent::__construct($cache_storage);
42
+		add_action('save_post', array($this, 'clearPostRelatedCache'));
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * returns a string that will be prepended to all cache identifiers
49
+	 *
50
+	 * @return string
51
+	 */
52
+	public function cachePrefix()
53
+	{
54
+		return PostRelatedCacheManager::POST_CACHE_PREFIX;
55
+	}
56
+
57
+
58
+	/**
59
+	 * @return array
60
+	 */
61
+	protected function getPostRelatedCache()
62
+	{
63
+		$post_related_cache = get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
64
+		// verify that cached data was not truncated or corrupted and no longer an array
65
+		if (! is_array($post_related_cache))  {
66
+			// uh-oh... let's get rid of any transients using our cache prefix
67
+			$this->clear(PostRelatedCacheManager::CACHE_PREFIX);
68
+			// then update the post related cache tracking option
69
+			$post_related_cache = array();
70
+			$this->updatePostRelatedCache($post_related_cache);
71
+		}
72
+		return $post_related_cache;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param array $post_related_cache
78
+	 */
79
+	protected function updatePostRelatedCache(array $post_related_cache = array())
80
+	{
81
+		update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
82
+	}
83
+
84
+
85
+	/**
86
+	 * If you are caching content that pertains to a Post of any type,
87
+	 * then it is recommended to pass the post id and cache id prefix to this method
88
+	 * so that it can be added to the post related cache tracking.
89
+	 * Then, whenever that post is updated, the cache will automatically be deleted,
90
+	 * which helps to ensure that outdated cache content will not be served
91
+	 *
92
+	 * @param int    $post_ID    [required]
93
+	 * @param string $id_prefix  [required] Appended to all cache IDs. Can be helpful in finding specific cache types.
94
+	 *                           May also be helpful to include an additional specific identifier,
95
+	 *                           such as a post ID as part of the $id_prefix so that individual caches
96
+	 *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
97
+	 *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
98
+	 */
99
+	public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix)
100
+	{
101
+		$post_related_cache = $this->getPostRelatedCache();
102
+		// if post is not already being tracked
103
+		if ( ! isset($post_related_cache[$post_ID])) {
104
+			// add array to add cache ids to
105
+			$post_related_cache[$post_ID] = array();
106
+		}
107
+		if( ! in_array($id_prefix, $post_related_cache[$post_ID], true)) {
108
+			// add cache id to be tracked
109
+			$post_related_cache[$post_ID][] = $id_prefix;
110
+			$this->updatePostRelatedCache($post_related_cache);
111
+		}
112
+	}
113
+
114
+
115
+
116
+	/**
117
+	 * callback hooked into the WordPress "save_post" action
118
+	 * deletes any cache content associated with the post
119
+	 *
120
+	 * @param int $post_ID [required]
121
+	 */
122
+	public function clearPostRelatedCache($post_ID)
123
+	{
124
+		$post_related_cache = $this->getPostRelatedCache();
125
+		// if post is not being tracked
126
+		if ( ! isset($post_related_cache[$post_ID])) {
127
+			// let's clean up some of the duplicate IDs that were getting added
128
+			foreach ($post_related_cache as $other_post_ID => $cache_IDs) {
129
+				//remove duplicates
130
+				$post_related_cache[$other_post_ID] = array_unique($post_related_cache[$other_post_ID]);
131
+			}
132
+			$this->updatePostRelatedCache($post_related_cache);
133
+			return;
134
+		}
135
+		// get cache id prefixes for post, and delete their corresponding transients
136
+		$this->clear($post_related_cache[$post_ID]);
137
+		unset($post_related_cache[$post_ID]);
138
+		$this->updatePostRelatedCache($post_related_cache);
139
+	}
140 140
 
141 141
 
142 142
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $post_related_cache = get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
64 64
         // verify that cached data was not truncated or corrupted and no longer an array
65
-        if (! is_array($post_related_cache))  {
65
+        if ( ! is_array($post_related_cache)) {
66 66
             // uh-oh... let's get rid of any transients using our cache prefix
67 67
             $this->clear(PostRelatedCacheManager::CACHE_PREFIX);
68 68
             // then update the post related cache tracking option
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             // add array to add cache ids to
105 105
             $post_related_cache[$post_ID] = array();
106 106
         }
107
-        if( ! in_array($id_prefix, $post_related_cache[$post_ID], true)) {
107
+        if ( ! in_array($id_prefix, $post_related_cache[$post_ID], true)) {
108 108
             // add cache id to be tracked
109 109
             $post_related_cache[$post_ID][] = $id_prefix;
110 110
             $this->updatePostRelatedCache($post_related_cache);
Please login to merge, or discard this patch.
core/services/cache/TransientCacheStorage.php 1 patch
Indentation   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -19,361 +19,361 @@
 block discarded – undo
19 19
 class TransientCacheStorage implements CacheStorageInterface
20 20
 {
21 21
 
22
-    /**
23
-     * wp-option option_name for tracking transients
24
-     *
25
-     * @type string
26
-     */
27
-    const TRANSIENT_SCHEDULE_OPTIONS_KEY = 'ee_transient_schedule';
28
-
29
-    /**
30
-     * @var int $current_time
31
-     */
32
-    private $current_time;
33
-
34
-    /**
35
-     * how often to perform transient cleanup
36
-     *
37
-     * @var string $transient_cleanup_frequency
38
-     */
39
-    private $transient_cleanup_frequency;
40
-
41
-    /**
42
-     * options for how often to perform transient cleanup
43
-     *
44
-     * @var array $transient_cleanup_frequency_options
45
-     */
46
-    private $transient_cleanup_frequency_options = array();
47
-
48
-    /**
49
-     * @var array $transients
50
-     */
51
-    private $transients;
52
-
53
-
54
-
55
-    /**
56
-     * TransientCacheStorage constructor.
57
-     */
58
-    public function __construct()
59
-    {
60
-        $this->transient_cleanup_frequency = $this->setTransientCleanupFrequency();
61
-        // round current time down to closest 5 minutes to simplify scheduling
62
-        $this->current_time = $this->roundTimestamp(time(), '5-minutes', false);
63
-        $this->transients = (array)get_option(TransientCacheStorage::TRANSIENT_SCHEDULE_OPTIONS_KEY, array());
64
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && $this->transient_cleanup_frequency !== 'off') {
65
-            add_action('shutdown', array($this, 'checkTransientCleanupSchedule'), 999);
66
-        }
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     * Sets how often transient cleanup occurs
73
-     *
74
-     * @return string
75
-     */
76
-    private function setTransientCleanupFrequency()
77
-    {
78
-        // sets how often transients are cleaned up
79
-        $this->transient_cleanup_frequency_options = apply_filters(
80
-            'FHEE__TransientCacheStorage__transient_cleanup_schedule_options',
81
-            array(
82
-                'off',
83
-                '15-minutes',
84
-                'hour',
85
-                '12-hours',
86
-                'day',
87
-            )
88
-        );
89
-        $transient_cleanup_frequency = apply_filters(
90
-            'FHEE__TransientCacheStorage__transient_cleanup_schedule',
91
-            'hour'
92
-        );
93
-        return in_array(
94
-            $transient_cleanup_frequency,
95
-            $this->transient_cleanup_frequency_options,
96
-            true
97
-        )
98
-            ? $transient_cleanup_frequency
99
-            : 'hour';
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     * we need to be able to round timestamps off to match the set transient cleanup frequency
106
-     * so if a transient is set to expire at 1:17 pm for example, and our cleanup schedule is every hour,
107
-     * then that timestamp needs to be rounded up to 2:00 pm so that it is removed
108
-     * during the next scheduled cleanup after its expiration.
109
-     * We also round off the current time timestamp to the closest 5 minutes
110
-     * just to make the timestamps a little easier to round which helps with debugging.
111
-     *
112
-     * @param int    $timestamp [required]
113
-     * @param string $cleanup_frequency
114
-     * @param bool   $round_up
115
-     * @return int
116
-     */
117
-    private function roundTimestamp($timestamp, $cleanup_frequency = 'hour', $round_up = true)
118
-    {
119
-        $cleanup_frequency = $cleanup_frequency ? $cleanup_frequency : $this->transient_cleanup_frequency;
120
-        // in order to round the time to the closest xx minutes (or hours),
121
-        // we take the minutes (or hours) portion of the timestamp and divide it by xx,
122
-        // round down to a whole number, then multiply by xx to bring us almost back up to where we were
123
-        // why round down ? so the minutes (or hours) don't go over 60 (or 24)
124
-        // and bump the hour, which could bump the day, which could bump the month, etc,
125
-        // which would be bad because we don't always want to round up,
126
-        // but when we do we can easily achieve that by simply adding the desired offset,
127
-        $minutes = '00';
128
-        $hours = 'H';
129
-        switch ($cleanup_frequency) {
130
-            case '5-minutes' :
131
-                $minutes = floor((int)date('i', $timestamp) / 5) * 5;
132
-                $minutes = str_pad($minutes, 2, '0', STR_PAD_LEFT);
133
-                $offset = MINUTE_IN_SECONDS * 5;
134
-                break;
135
-            case '15-minutes' :
136
-                $minutes = floor((int)date('i', $timestamp) / 15) * 15;
137
-                $minutes = str_pad($minutes, 2, '0', STR_PAD_LEFT);
138
-                $offset = MINUTE_IN_SECONDS * 15;
139
-                break;
140
-            case '12-hours' :
141
-                $hours = floor((int)date('H', $timestamp) / 12) * 12;
142
-                $hours = str_pad($hours, 2, '0', STR_PAD_LEFT);
143
-                $offset = HOUR_IN_SECONDS * 12;
144
-                break;
145
-            case 'day' :
146
-                $hours = '03'; // run cleanup at 3:00 am (or first site hit after that)
147
-                $offset = DAY_IN_SECONDS;
148
-                break;
149
-            case 'hour' :
150
-            default :
151
-                $offset = HOUR_IN_SECONDS;
152
-                break;
153
-        }
154
-        $rounded_timestamp = (int) strtotime(date("Y-m-d {$hours}:{$minutes}:00", $timestamp));
155
-        $rounded_timestamp += $round_up ? $offset : 0;
156
-        return apply_filters(
157
-            'FHEE__TransientCacheStorage__roundTimestamp__timestamp',
158
-            $rounded_timestamp,
159
-            $timestamp,
160
-            $cleanup_frequency,
161
-            $round_up
162
-        );
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Saves supplied data to a transient
169
-     * if an expiration is set, then it automatically schedules the transient for cleanup
170
-     *
171
-     * @param string $transient_key [required]
172
-     * @param string $data          [required]
173
-     * @param int    $expiration    number of seconds until the cache expires
174
-     * @return bool
175
-     */
176
-    public function add($transient_key, $data, $expiration = 0)
177
-    {
178
-        $expiration = (int)abs($expiration);
179
-        $saved = set_transient($transient_key, $data, $expiration);
180
-        if ($saved && $expiration) {
181
-            $this->scheduleTransientCleanup($transient_key, $expiration);
182
-        }
183
-        return $saved;
184
-    }
185
-
186
-
187
-
188
-    /**
189
-     * retrieves transient data
190
-     * automatically triggers early cache refresh for standard cache items
191
-     * in order to avoid cache stampedes on busy sites.
192
-     * For non-standard cache items like PHP Session data where early refreshing is not wanted,
193
-     * the $standard_cache parameter should be set to false when retrieving data
194
-     *
195
-     * @param string $transient_key [required]
196
-     * @param bool   $standard_cache
197
-     * @return mixed|null
198
-     */
199
-    public function get($transient_key, $standard_cache = true)
200
-    {
201
-        // to avoid cache stampedes (AKA:dogpiles) for standard cache items,
202
-        // check if known cache expires within the next minute,
203
-        // and if so, remove it from our tracking and and return nothing.
204
-        // this should trigger the cache content to be regenerated during this request,
205
-        // while allowing any following requests to still access the existing cache
206
-        // until it gets replaced with the refreshed content
207
-        if (
208
-            $standard_cache
209
-            && isset($this->transients[$transient_key])
210
-            && $this->transients[$transient_key] - time() <= MINUTE_IN_SECONDS
211
-        ) {
212
-            unset($this->transients[$transient_key]);
213
-            $this->updateTransients();
214
-            return null;
215
-        }
216
-        $content = get_transient($transient_key);
217
-        return $content !== false ? $content : null;
218
-    }
219
-
220
-
221
-
222
-    /**
223
-     * delete a single transient and remove tracking
224
-     *
225
-     * @param string $transient_key [required] full or partial transient key to be deleted
226
-     */
227
-    public function delete($transient_key)
228
-    {
229
-        $this->deleteMany(array($transient_key));
230
-    }
231
-
232
-
233
-
234
-    /**
235
-     * delete multiple transients and remove tracking
236
-     *
237
-     * @param array $transient_keys [required] array of full or partial transient keys to be deleted
238
-     */
239
-    public function deleteMany(array $transient_keys)
240
-    {
241
-        $full_transient_keys = array();
242
-        foreach ($this->transients as $transient_key => $expiration) {
243
-            foreach ($transient_keys as $transient_key_to_delete) {
244
-                if (strpos($transient_key, $transient_key_to_delete) !== false) {
245
-                    $full_transient_keys[] = $transient_key;
246
-                }
247
-            }
248
-        }
249
-        if ($this->deleteTransientKeys($full_transient_keys)) {
250
-            $this->updateTransients();
251
-        }
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     * sorts transients numerically by timestamp
258
-     * then saves the transient schedule to a WP option
259
-     */
260
-    private function updateTransients()
261
-    {
262
-        asort($this->transients, SORT_NUMERIC);
263
-        update_option(
264
-            TransientCacheStorage::TRANSIENT_SCHEDULE_OPTIONS_KEY,
265
-            $this->transients
266
-        );
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * schedules a transient for cleanup by adding it to the transient tracking
273
-     *
274
-     * @param string $transient_key [required]
275
-     * @param int    $expiration    [required]
276
-     */
277
-    private function scheduleTransientCleanup($transient_key, $expiration)
278
-    {
279
-        // make sure a valid future timestamp is set
280
-        $expiration += $expiration < time() ? time() : 0;
281
-        // and round to the closest 15 minutes
282
-        $expiration = $this->roundTimestamp($expiration);
283
-        // save transients to clear using their ID as the key to avoid duplicates
284
-        $this->transients[$transient_key] = $expiration;
285
-        $this->updateTransients();
286
-    }
287
-
288
-
289
-
290
-    /**
291
-     * Since our tracked transients are sorted by their timestamps
292
-     * we can grab the first transient and see when it is scheduled for cleanup.
293
-     * If that timestamp is less than or equal to the current time,
294
-     * then cleanup is triggered
295
-     */
296
-    public function checkTransientCleanupSchedule()
297
-    {
298
-        if (empty($this->transients)) {
299
-            return;
300
-        }
301
-        // when do we run the next cleanup job?
302
-        reset($this->transients);
303
-        $next_scheduled_cleanup = current($this->transients);
304
-        // if the next cleanup job is scheduled for the current hour
305
-        if ($next_scheduled_cleanup <= $this->current_time) {
306
-            if ($this->cleanupExpiredTransients()) {
307
-                $this->updateTransients();
308
-            }
309
-        }
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * loops through the array of tracked transients,
316
-     * compiles a list of those that have expired, and sends that list off for deletion.
317
-     * Also removes any bad records from the transients array
318
-     *
319
-     * @return bool
320
-     */
321
-    private function cleanupExpiredTransients()
322
-    {
323
-        $update = false;
324
-        // filter the query limit. Set to 0 to turn off garbage collection
325
-        $limit = (int)abs(
326
-            apply_filters(
327
-                'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
328
-                50
329
-            )
330
-        );
331
-        // non-zero LIMIT means take out the trash
332
-        if ($limit) {
333
-            $transient_keys = array();
334
-            foreach ($this->transients as $transient_key => $expiration) {
335
-                if ($expiration > $this->current_time) {
336
-                    continue;
337
-                }
338
-                if ( ! $expiration || ! $transient_key) {
339
-                    unset($this->transients[$transient_key]);
340
-                    $update = true;
341
-                    continue;
342
-                }
343
-                $transient_keys[] = $transient_key;
344
-            }
345
-            // delete expired keys, but maintain value of $update if nothing is deleted
346
-            $update = $this->deleteTransientKeys($transient_keys, $limit) ? true : $update;
347
-            do_action( 'FHEE__TransientCacheStorage__clearExpiredTransients__end', $this);
348
-        }
349
-        return $update;
350
-    }
351
-
352
-
353
-
354
-    /**
355
-     * calls delete_transient() on each transient key provided, up to the specified limit
356
-     *
357
-     * @param array $transient_keys [required]
358
-     * @param int   $limit
359
-     * @return bool
360
-     */
361
-    private function deleteTransientKeys(array $transient_keys, $limit = 50)
362
-    {
363
-        if (empty($transient_keys)) {
364
-            return false;
365
-        }
366
-        $counter = 0;
367
-        foreach ($transient_keys as $transient_key) {
368
-            if($counter === $limit){
369
-                break;
370
-            }
371
-            delete_transient($transient_key);
372
-            unset($this->transients[$transient_key]);
373
-            $counter++;
374
-        }
375
-        return $counter > 0;
376
-    }
22
+	/**
23
+	 * wp-option option_name for tracking transients
24
+	 *
25
+	 * @type string
26
+	 */
27
+	const TRANSIENT_SCHEDULE_OPTIONS_KEY = 'ee_transient_schedule';
28
+
29
+	/**
30
+	 * @var int $current_time
31
+	 */
32
+	private $current_time;
33
+
34
+	/**
35
+	 * how often to perform transient cleanup
36
+	 *
37
+	 * @var string $transient_cleanup_frequency
38
+	 */
39
+	private $transient_cleanup_frequency;
40
+
41
+	/**
42
+	 * options for how often to perform transient cleanup
43
+	 *
44
+	 * @var array $transient_cleanup_frequency_options
45
+	 */
46
+	private $transient_cleanup_frequency_options = array();
47
+
48
+	/**
49
+	 * @var array $transients
50
+	 */
51
+	private $transients;
52
+
53
+
54
+
55
+	/**
56
+	 * TransientCacheStorage constructor.
57
+	 */
58
+	public function __construct()
59
+	{
60
+		$this->transient_cleanup_frequency = $this->setTransientCleanupFrequency();
61
+		// round current time down to closest 5 minutes to simplify scheduling
62
+		$this->current_time = $this->roundTimestamp(time(), '5-minutes', false);
63
+		$this->transients = (array)get_option(TransientCacheStorage::TRANSIENT_SCHEDULE_OPTIONS_KEY, array());
64
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX) && $this->transient_cleanup_frequency !== 'off') {
65
+			add_action('shutdown', array($this, 'checkTransientCleanupSchedule'), 999);
66
+		}
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 * Sets how often transient cleanup occurs
73
+	 *
74
+	 * @return string
75
+	 */
76
+	private function setTransientCleanupFrequency()
77
+	{
78
+		// sets how often transients are cleaned up
79
+		$this->transient_cleanup_frequency_options = apply_filters(
80
+			'FHEE__TransientCacheStorage__transient_cleanup_schedule_options',
81
+			array(
82
+				'off',
83
+				'15-minutes',
84
+				'hour',
85
+				'12-hours',
86
+				'day',
87
+			)
88
+		);
89
+		$transient_cleanup_frequency = apply_filters(
90
+			'FHEE__TransientCacheStorage__transient_cleanup_schedule',
91
+			'hour'
92
+		);
93
+		return in_array(
94
+			$transient_cleanup_frequency,
95
+			$this->transient_cleanup_frequency_options,
96
+			true
97
+		)
98
+			? $transient_cleanup_frequency
99
+			: 'hour';
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 * we need to be able to round timestamps off to match the set transient cleanup frequency
106
+	 * so if a transient is set to expire at 1:17 pm for example, and our cleanup schedule is every hour,
107
+	 * then that timestamp needs to be rounded up to 2:00 pm so that it is removed
108
+	 * during the next scheduled cleanup after its expiration.
109
+	 * We also round off the current time timestamp to the closest 5 minutes
110
+	 * just to make the timestamps a little easier to round which helps with debugging.
111
+	 *
112
+	 * @param int    $timestamp [required]
113
+	 * @param string $cleanup_frequency
114
+	 * @param bool   $round_up
115
+	 * @return int
116
+	 */
117
+	private function roundTimestamp($timestamp, $cleanup_frequency = 'hour', $round_up = true)
118
+	{
119
+		$cleanup_frequency = $cleanup_frequency ? $cleanup_frequency : $this->transient_cleanup_frequency;
120
+		// in order to round the time to the closest xx minutes (or hours),
121
+		// we take the minutes (or hours) portion of the timestamp and divide it by xx,
122
+		// round down to a whole number, then multiply by xx to bring us almost back up to where we were
123
+		// why round down ? so the minutes (or hours) don't go over 60 (or 24)
124
+		// and bump the hour, which could bump the day, which could bump the month, etc,
125
+		// which would be bad because we don't always want to round up,
126
+		// but when we do we can easily achieve that by simply adding the desired offset,
127
+		$minutes = '00';
128
+		$hours = 'H';
129
+		switch ($cleanup_frequency) {
130
+			case '5-minutes' :
131
+				$minutes = floor((int)date('i', $timestamp) / 5) * 5;
132
+				$minutes = str_pad($minutes, 2, '0', STR_PAD_LEFT);
133
+				$offset = MINUTE_IN_SECONDS * 5;
134
+				break;
135
+			case '15-minutes' :
136
+				$minutes = floor((int)date('i', $timestamp) / 15) * 15;
137
+				$minutes = str_pad($minutes, 2, '0', STR_PAD_LEFT);
138
+				$offset = MINUTE_IN_SECONDS * 15;
139
+				break;
140
+			case '12-hours' :
141
+				$hours = floor((int)date('H', $timestamp) / 12) * 12;
142
+				$hours = str_pad($hours, 2, '0', STR_PAD_LEFT);
143
+				$offset = HOUR_IN_SECONDS * 12;
144
+				break;
145
+			case 'day' :
146
+				$hours = '03'; // run cleanup at 3:00 am (or first site hit after that)
147
+				$offset = DAY_IN_SECONDS;
148
+				break;
149
+			case 'hour' :
150
+			default :
151
+				$offset = HOUR_IN_SECONDS;
152
+				break;
153
+		}
154
+		$rounded_timestamp = (int) strtotime(date("Y-m-d {$hours}:{$minutes}:00", $timestamp));
155
+		$rounded_timestamp += $round_up ? $offset : 0;
156
+		return apply_filters(
157
+			'FHEE__TransientCacheStorage__roundTimestamp__timestamp',
158
+			$rounded_timestamp,
159
+			$timestamp,
160
+			$cleanup_frequency,
161
+			$round_up
162
+		);
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Saves supplied data to a transient
169
+	 * if an expiration is set, then it automatically schedules the transient for cleanup
170
+	 *
171
+	 * @param string $transient_key [required]
172
+	 * @param string $data          [required]
173
+	 * @param int    $expiration    number of seconds until the cache expires
174
+	 * @return bool
175
+	 */
176
+	public function add($transient_key, $data, $expiration = 0)
177
+	{
178
+		$expiration = (int)abs($expiration);
179
+		$saved = set_transient($transient_key, $data, $expiration);
180
+		if ($saved && $expiration) {
181
+			$this->scheduleTransientCleanup($transient_key, $expiration);
182
+		}
183
+		return $saved;
184
+	}
185
+
186
+
187
+
188
+	/**
189
+	 * retrieves transient data
190
+	 * automatically triggers early cache refresh for standard cache items
191
+	 * in order to avoid cache stampedes on busy sites.
192
+	 * For non-standard cache items like PHP Session data where early refreshing is not wanted,
193
+	 * the $standard_cache parameter should be set to false when retrieving data
194
+	 *
195
+	 * @param string $transient_key [required]
196
+	 * @param bool   $standard_cache
197
+	 * @return mixed|null
198
+	 */
199
+	public function get($transient_key, $standard_cache = true)
200
+	{
201
+		// to avoid cache stampedes (AKA:dogpiles) for standard cache items,
202
+		// check if known cache expires within the next minute,
203
+		// and if so, remove it from our tracking and and return nothing.
204
+		// this should trigger the cache content to be regenerated during this request,
205
+		// while allowing any following requests to still access the existing cache
206
+		// until it gets replaced with the refreshed content
207
+		if (
208
+			$standard_cache
209
+			&& isset($this->transients[$transient_key])
210
+			&& $this->transients[$transient_key] - time() <= MINUTE_IN_SECONDS
211
+		) {
212
+			unset($this->transients[$transient_key]);
213
+			$this->updateTransients();
214
+			return null;
215
+		}
216
+		$content = get_transient($transient_key);
217
+		return $content !== false ? $content : null;
218
+	}
219
+
220
+
221
+
222
+	/**
223
+	 * delete a single transient and remove tracking
224
+	 *
225
+	 * @param string $transient_key [required] full or partial transient key to be deleted
226
+	 */
227
+	public function delete($transient_key)
228
+	{
229
+		$this->deleteMany(array($transient_key));
230
+	}
231
+
232
+
233
+
234
+	/**
235
+	 * delete multiple transients and remove tracking
236
+	 *
237
+	 * @param array $transient_keys [required] array of full or partial transient keys to be deleted
238
+	 */
239
+	public function deleteMany(array $transient_keys)
240
+	{
241
+		$full_transient_keys = array();
242
+		foreach ($this->transients as $transient_key => $expiration) {
243
+			foreach ($transient_keys as $transient_key_to_delete) {
244
+				if (strpos($transient_key, $transient_key_to_delete) !== false) {
245
+					$full_transient_keys[] = $transient_key;
246
+				}
247
+			}
248
+		}
249
+		if ($this->deleteTransientKeys($full_transient_keys)) {
250
+			$this->updateTransients();
251
+		}
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 * sorts transients numerically by timestamp
258
+	 * then saves the transient schedule to a WP option
259
+	 */
260
+	private function updateTransients()
261
+	{
262
+		asort($this->transients, SORT_NUMERIC);
263
+		update_option(
264
+			TransientCacheStorage::TRANSIENT_SCHEDULE_OPTIONS_KEY,
265
+			$this->transients
266
+		);
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * schedules a transient for cleanup by adding it to the transient tracking
273
+	 *
274
+	 * @param string $transient_key [required]
275
+	 * @param int    $expiration    [required]
276
+	 */
277
+	private function scheduleTransientCleanup($transient_key, $expiration)
278
+	{
279
+		// make sure a valid future timestamp is set
280
+		$expiration += $expiration < time() ? time() : 0;
281
+		// and round to the closest 15 minutes
282
+		$expiration = $this->roundTimestamp($expiration);
283
+		// save transients to clear using their ID as the key to avoid duplicates
284
+		$this->transients[$transient_key] = $expiration;
285
+		$this->updateTransients();
286
+	}
287
+
288
+
289
+
290
+	/**
291
+	 * Since our tracked transients are sorted by their timestamps
292
+	 * we can grab the first transient and see when it is scheduled for cleanup.
293
+	 * If that timestamp is less than or equal to the current time,
294
+	 * then cleanup is triggered
295
+	 */
296
+	public function checkTransientCleanupSchedule()
297
+	{
298
+		if (empty($this->transients)) {
299
+			return;
300
+		}
301
+		// when do we run the next cleanup job?
302
+		reset($this->transients);
303
+		$next_scheduled_cleanup = current($this->transients);
304
+		// if the next cleanup job is scheduled for the current hour
305
+		if ($next_scheduled_cleanup <= $this->current_time) {
306
+			if ($this->cleanupExpiredTransients()) {
307
+				$this->updateTransients();
308
+			}
309
+		}
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * loops through the array of tracked transients,
316
+	 * compiles a list of those that have expired, and sends that list off for deletion.
317
+	 * Also removes any bad records from the transients array
318
+	 *
319
+	 * @return bool
320
+	 */
321
+	private function cleanupExpiredTransients()
322
+	{
323
+		$update = false;
324
+		// filter the query limit. Set to 0 to turn off garbage collection
325
+		$limit = (int)abs(
326
+			apply_filters(
327
+				'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
328
+				50
329
+			)
330
+		);
331
+		// non-zero LIMIT means take out the trash
332
+		if ($limit) {
333
+			$transient_keys = array();
334
+			foreach ($this->transients as $transient_key => $expiration) {
335
+				if ($expiration > $this->current_time) {
336
+					continue;
337
+				}
338
+				if ( ! $expiration || ! $transient_key) {
339
+					unset($this->transients[$transient_key]);
340
+					$update = true;
341
+					continue;
342
+				}
343
+				$transient_keys[] = $transient_key;
344
+			}
345
+			// delete expired keys, but maintain value of $update if nothing is deleted
346
+			$update = $this->deleteTransientKeys($transient_keys, $limit) ? true : $update;
347
+			do_action( 'FHEE__TransientCacheStorage__clearExpiredTransients__end', $this);
348
+		}
349
+		return $update;
350
+	}
351
+
352
+
353
+
354
+	/**
355
+	 * calls delete_transient() on each transient key provided, up to the specified limit
356
+	 *
357
+	 * @param array $transient_keys [required]
358
+	 * @param int   $limit
359
+	 * @return bool
360
+	 */
361
+	private function deleteTransientKeys(array $transient_keys, $limit = 50)
362
+	{
363
+		if (empty($transient_keys)) {
364
+			return false;
365
+		}
366
+		$counter = 0;
367
+		foreach ($transient_keys as $transient_key) {
368
+			if($counter === $limit){
369
+				break;
370
+			}
371
+			delete_transient($transient_key);
372
+			unset($this->transients[$transient_key]);
373
+			$counter++;
374
+		}
375
+		return $counter > 0;
376
+	}
377 377
 
378 378
 
379 379
 }
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EEG_Paypal_Express.gateway.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@
 block discarded – undo
20 20
      * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
21 21
      * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
22 22
      * @param $string
23
-     * @param $start
24
-     * @param $length
23
+     * @param integer $start
24
+     * @param integer $length
25 25
      * @return bool|string
26 26
      */
27 27
     function mb_strcut($string, $start, $length = null)
Please login to merge, or discard this patch.
Indentation   +599 added lines, -599 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('NO direct script access allowed');
2
+	exit('NO direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -16,608 +16,608 @@  discard block
 block discarded – undo
16 16
  */
17 17
 //Quickfix to address https://events.codebasehq.com/projects/event-espresso/tickets/11089 ASAP
18 18
 if (! function_exists('mb_strcut')) {
19
-    /**
20
-     * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
21
-     * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
22
-     * @param $string
23
-     * @param $start
24
-     * @param $length
25
-     * @return bool|string
26
-     */
27
-    function mb_strcut($string, $start, $length = null)
28
-    {
29
-        return mb_substr($string, $start, $length);
30
-    }
19
+	/**
20
+	 * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
21
+	 * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
22
+	 * @param $string
23
+	 * @param $start
24
+	 * @param $length
25
+	 * @return bool|string
26
+	 */
27
+	function mb_strcut($string, $start, $length = null)
28
+	{
29
+		return mb_substr($string, $start, $length);
30
+	}
31 31
 }
32 32
 class EEG_Paypal_Express extends EE_Offsite_Gateway
33 33
 {
34 34
 
35
-    /**
36
-     * Merchant API Username.
37
-     *
38
-     * @var string
39
-     */
40
-    protected $_api_username;
41
-
42
-    /**
43
-     * Merchant API Password.
44
-     *
45
-     * @var string
46
-     */
47
-    protected $_api_password;
48
-
49
-    /**
50
-     * API Signature.
51
-     *
52
-     * @var string
53
-     */
54
-    protected $_api_signature;
55
-
56
-    /**
57
-     * Request Shipping address on PP checkout page.
58
-     *
59
-     * @var string
60
-     */
61
-    protected $_request_shipping_addr;
62
-
63
-    /**
64
-     * Business/personal logo.
65
-     *
66
-     * @var string
67
-     */
68
-    protected $_image_url;
69
-
70
-    /**
71
-     * gateway URL variable
72
-     *
73
-     * @var string
74
-     */
75
-    protected $_base_gateway_url = '';
76
-
77
-
78
-
79
-    /**
80
-     * EEG_Paypal_Express constructor.
81
-     */
82
-    public function __construct()
83
-    {
84
-        $this->_currencies_supported = array(
85
-            'USD',
86
-            'AUD',
87
-            'BRL',
88
-            'CAD',
89
-            'CZK',
90
-            'DKK',
91
-            'EUR',
92
-            'HKD',
93
-            'HUF',
94
-            'ILS',
95
-            'JPY',
96
-            'MYR',
97
-            'MXN',
98
-            'NOK',
99
-            'NZD',
100
-            'PHP',
101
-            'PLN',
102
-            'GBP',
103
-            'RUB',
104
-            'SGD',
105
-            'SEK',
106
-            'CHF',
107
-            'TWD',
108
-            'THB',
109
-            'TRY',
110
-        );
111
-        parent::__construct();
112
-    }
113
-
114
-
115
-
116
-    /**
117
-     * Sets the gateway URL variable based on whether debug mode is enabled or not.
118
-     *
119
-     * @param array $settings_array
120
-     */
121
-    public function set_settings($settings_array)
122
-    {
123
-        parent::set_settings($settings_array);
124
-        // Redirect URL.
125
-        $this->_base_gateway_url = $this->_debug_mode
126
-            ? 'https://api-3t.sandbox.paypal.com/nvp'
127
-            : 'https://api-3t.paypal.com/nvp';
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @param EEI_Payment $payment
134
-     * @param array       $billing_info
135
-     * @param string      $return_url
136
-     * @param string      $notify_url
137
-     * @param string      $cancel_url
138
-     * @return \EE_Payment|\EEI_Payment
139
-     * @throws \EE_Error
140
-     */
141
-    public function set_redirection_info(
142
-        $payment,
143
-        $billing_info = array(),
144
-        $return_url = null,
145
-        $notify_url = null,
146
-        $cancel_url = null
147
-    ) {
148
-        if (! $payment instanceof EEI_Payment) {
149
-            $payment->set_gateway_response(
150
-                esc_html__(
151
-                    'Error. No associated payment was found.',
152
-                    'event_espresso'
153
-                )
154
-            );
155
-            $payment->set_status($this->_pay_model->failed_status());
156
-            return $payment;
157
-        }
158
-        $transaction = $payment->transaction();
159
-        if (! $transaction instanceof EEI_Transaction) {
160
-            $payment->set_gateway_response(
161
-                esc_html__(
162
-                    'Could not process this payment because it has no associated transaction.',
163
-                    'event_espresso'
164
-                )
165
-            );
166
-            $payment->set_status($this->_pay_model->failed_status());
167
-            return $payment;
168
-        }
169
-        $order_description = mb_strcut($this->_format_order_description($payment), 0, 127);
170
-        $primary_registration = $transaction->primary_registration();
171
-        $primary_attendee = $primary_registration instanceof EE_Registration
172
-            ? $primary_registration->attendee()
173
-            : false;
174
-        $locale = explode('-', get_bloginfo('language'));
175
-        // Gather request parameters.
176
-        $token_request_dtls = array(
177
-            'METHOD'                         => 'SetExpressCheckout',
178
-            'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
179
-            'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
180
-            'PAYMENTREQUEST_0_DESC'          => $order_description,
181
-            'RETURNURL'                      => $return_url,
182
-            'CANCELURL'                      => $cancel_url,
183
-            'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
184
-            // Buyer does not need to create a PayPal account to check out.
185
-            // This is referred to as PayPal Account Optional.
186
-            'SOLUTIONTYPE'                   => 'Sole',
187
-            //EE will blow up if you change this
188
-            'BUTTONSOURCE'                   => 'EventEspresso_SP',
189
-            // Locale of the pages displayed by PayPal during Express Checkout.
190
-            'LOCALECODE'                     => $locale[1]
191
-        );
192
-        // Show itemized list.
193
-        if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
194
-            $item_num = 0;
195
-            $itemized_sum = 0;
196
-            $total_line_items = $transaction->total_line_item();
197
-            // Go through each item in the list.
198
-            foreach ($total_line_items->get_items() as $line_item) {
199
-                if ($line_item instanceof EE_Line_Item) {
200
-                    // PayPal doesn't like line items with 0.00 amount, so we may skip those.
201
-                    if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) {
202
-                        continue;
203
-                    }
204
-                    $unit_price = $line_item->unit_price();
205
-                    $line_item_quantity = $line_item->quantity();
206
-                    // This is a discount.
207
-                    if ($line_item->is_percent()) {
208
-                        $unit_price = $line_item->total();
209
-                        $line_item_quantity = 1;
210
-                    }
211
-                    // Item Name.
212
-                    $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut(
213
-                        $this->_format_line_item_name($line_item, $payment),
214
-                        0,
215
-                        127
216
-                    );
217
-                    // Item description.
218
-                    $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = mb_strcut(
219
-                        $this->_format_line_item_desc($line_item, $payment),
220
-                        0,
221
-                        127
222
-                    );
223
-                    // Cost of individual item.
224
-                    $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency($unit_price);
225
-                    // Item Number.
226
-                    $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1;
227
-                    // Item quantity.
228
-                    $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity;
229
-                    // Digital item is sold.
230
-                    $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical';
231
-                    $itemized_sum += $line_item->total();
232
-                    ++$item_num;
233
-                }
234
-            }
235
-            // Item's sales S/H and tax amount.
236
-            $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total();
237
-            $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax();
238
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
239
-            $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
240
-            $itemized_sum_diff_from_txn_total = round(
241
-                $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(),
242
-                2
243
-            );
244
-            // If we were not able to recognize some item like promotion, surcharge or cancellation,
245
-            // add the difference as an extra line item.
246
-            if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
247
-                // Item Name.
248
-                $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut(
249
-                    esc_html__(
250
-                        'Other (promotion/surcharge/cancellation)',
251
-                        'event_espresso'
252
-                    ),
253
-                    0,
254
-                    127
255
-                );
256
-                // Item description.
257
-                $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = '';
258
-                // Cost of individual item.
259
-                $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency(
260
-                    $itemized_sum_diff_from_txn_total
261
-                );
262
-                // Item Number.
263
-                $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1;
264
-                // Item quantity.
265
-                $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1;
266
-                // Digital item is sold.
267
-                $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical';
268
-                $item_num++;
269
-            }
270
-        } else {
271
-            // Just one Item.
272
-            // Item Name.
273
-            $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = mb_strcut(
274
-                $this->_format_partial_payment_line_item_name($payment),
275
-                0,
276
-                127
277
-            );
278
-            // Item description.
279
-            $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = mb_strcut(
280
-                $this->_format_partial_payment_line_item_desc($payment),
281
-                0,
282
-                127
283
-            );
284
-            // Cost of individual item.
285
-            $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount());
286
-            // Item Number.
287
-            $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
288
-            // Item quantity.
289
-            $token_request_dtls['L_PAYMENTREQUEST_0_QTY0'] = 1;
290
-            // Digital item is sold.
291
-            $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical';
292
-            // Item's sales S/H and tax amount.
293
-            $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount());
294
-            $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0';
295
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
296
-            $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
297
-        }
298
-        // Automatically filling out shipping and contact information.
299
-        if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) {
300
-            //  If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
301
-            $token_request_dtls['NOSHIPPING'] = '2';
302
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address();
303
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2();
304
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city();
305
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev();
306
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID();
307
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
308
-            $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
309
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
310
-        } elseif (! $this->_request_shipping_addr) {
311
-            // Do not request shipping details on the PP Checkout page.
312
-            $token_request_dtls['NOSHIPPING'] = '1';
313
-            $token_request_dtls['REQCONFIRMSHIPPING'] = '0';
314
-        }
315
-        // Used a business/personal logo on the PayPal page.
316
-        if (! empty($this->_image_url)) {
317
-            $token_request_dtls['LOGOIMG'] = $this->_image_url;
318
-        }
319
-        $token_request_dtls = apply_filters(
320
-            'FHEE__EEG_Paypal_Express__set_redirection_info__arguments',
321
-            $token_request_dtls,
322
-            $this
323
-        );
324
-        // Request PayPal token.
325
-        $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment);
326
-        $token_rstatus = $this->_ppExpress_check_response($token_request_response);
327
-        $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args']))
328
-            ? $token_rstatus['args']
329
-            : array();
330
-        if ($token_rstatus['status']) {
331
-            // We got the Token so we may continue with the payment and redirect the client.
332
-            $payment->set_details($response_args);
333
-            $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
334
-            $payment->set_redirect_url(
335
-                $gateway_url
336
-                . '/checkoutnow?useraction=commit&cmd=_express-checkout&token='
337
-                . $response_args['TOKEN']
338
-            );
339
-        } else {
340
-            if (isset($response_args['L_ERRORCODE'])) {
341
-                $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']);
342
-            } else {
343
-                $payment->set_gateway_response(
344
-                    esc_html__(
345
-                        'Error occurred while trying to setup the Express Checkout.',
346
-                        'event_espresso'
347
-                    )
348
-                );
349
-            }
350
-            $payment->set_details($response_args);
351
-            $payment->set_status($this->_pay_model->failed_status());
352
-        }
353
-        return $payment;
354
-    }
355
-
356
-
357
-
358
-    /**
359
-     * @param array           $update_info {
360
-     * @type string           $gateway_txn_id
361
-     * @type string status an EEMI_Payment status
362
-     *                                     }
363
-     * @param EEI_Transaction $transaction
364
-     * @return EEI_Payment
365
-     */
366
-    public function handle_payment_update($update_info, $transaction)
367
-    {
368
-        $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null;
369
-        if ($payment instanceof EEI_Payment) {
370
-            $this->log(array('Return from Authorization' => $update_info), $payment);
371
-            $transaction = $payment->transaction();
372
-            if (! $transaction instanceof EEI_Transaction) {
373
-                $payment->set_gateway_response(
374
-                    esc_html__(
375
-                        'Could not process this payment because it has no associated transaction.',
376
-                        'event_espresso'
377
-                    )
378
-                );
379
-                $payment->set_status($this->_pay_model->failed_status());
380
-                return $payment;
381
-            }
382
-            $primary_registrant = $transaction->primary_registration();
383
-            $payment_details = $payment->details();
384
-            // Check if we still have the token.
385
-            if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
386
-                $payment->set_status($this->_pay_model->failed_status());
387
-                return $payment;
388
-            }
389
-            $cdetails_request_dtls = array(
390
-                'METHOD' => 'GetExpressCheckoutDetails',
391
-                'TOKEN'  => $payment_details['TOKEN'],
392
-            );
393
-            // Request Customer Details.
394
-            $cdetails_request_response = $this->_ppExpress_request(
395
-                $cdetails_request_dtls,
396
-                'Customer Details',
397
-                $payment
398
-            );
399
-            $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response);
400
-            $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']))
401
-                ? $cdetails_rstatus['args']
402
-                : array();
403
-            if ($cdetails_rstatus['status']) {
404
-                // We got the PayerID so now we can Complete the transaction.
405
-                $docheckout_request_dtls = array(
406
-                    'METHOD'                         => 'DoExpressCheckoutPayment',
407
-                    'PAYERID'                        => $cdata_response_args['PAYERID'],
408
-                    'TOKEN'                          => $payment_details['TOKEN'],
409
-                    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
410
-                    'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
411
-                    'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
412
-                    //EE will blow up if you change this
413
-                    'BUTTONSOURCE'                   => 'EventEspresso_SP',
414
-                );
415
-                // Payment Checkout/Capture.
416
-                $docheckout_request_response = $this->_ppExpress_request(
417
-                    $docheckout_request_dtls,
418
-                    'Do Payment',
419
-                    $payment
420
-                );
421
-                $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response);
422
-                $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']))
423
-                    ? $docheckout_rstatus['args']
424
-                    : array();
425
-                if ($docheckout_rstatus['status']) {
426
-                    // All is well, payment approved.
427
-                    $primary_registration_code = $primary_registrant instanceof EE_Registration ?
428
-                        $primary_registrant->reg_code()
429
-                        : '';
430
-                    $payment->set_extra_accntng($primary_registration_code);
431
-                    $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT'])
432
-                        ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT']
433
-                        : 0);
434
-                    $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'])
435
-                        ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']
436
-                        : null);
437
-                    $payment->set_details($cdata_response_args);
438
-                    $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK'])
439
-                        ? $docheckout_response_args['PAYMENTINFO_0_ACK']
440
-                        : '');
441
-                    $payment->set_status($this->_pay_model->approved_status());
442
-                } else {
443
-                    if (isset($docheckout_response_args['L_ERRORCODE'])) {
444
-                        $payment->set_gateway_response(
445
-                            $docheckout_response_args['L_ERRORCODE']
446
-                            . '; '
447
-                            . $docheckout_response_args['L_SHORTMESSAGE']
448
-                        );
449
-                    } else {
450
-                        $payment->set_gateway_response(
451
-                            esc_html__(
452
-                                'Error occurred while trying to Capture the funds.',
453
-                                'event_espresso'
454
-                            )
455
-                        );
456
-                    }
457
-                    $payment->set_details($docheckout_response_args);
458
-                    $payment->set_status($this->_pay_model->declined_status());
459
-                }
460
-            } else {
461
-                if (isset($cdata_response_args['L_ERRORCODE'])) {
462
-                    $payment->set_gateway_response(
463
-                        $cdata_response_args['L_ERRORCODE']
464
-                        . '; '
465
-                        . $cdata_response_args['L_SHORTMESSAGE']
466
-                    );
467
-                } else {
468
-                    $payment->set_gateway_response(
469
-                        esc_html__(
470
-                            'Error occurred while trying to get payment Details from PayPal.',
471
-                            'event_espresso'
472
-                        )
473
-                    );
474
-                }
475
-                $payment->set_details($cdata_response_args);
476
-                $payment->set_status($this->_pay_model->failed_status());
477
-            }
478
-        } else {
479
-            $payment->set_gateway_response(
480
-                esc_html__(
481
-                    'Error occurred while trying to process the payment.',
482
-                    'event_espresso'
483
-                )
484
-            );
485
-            $payment->set_status($this->_pay_model->failed_status());
486
-        }
487
-        return $payment;
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     *  Make the Express checkout request.
494
-     *
495
-     * @param array       $request_params
496
-     * @param string      $request_text
497
-     * @param EEI_Payment $payment
498
-     * @return mixed
499
-     */
500
-    public function _ppExpress_request($request_params, $request_text, $payment)
501
-    {
502
-        $request_dtls = array(
503
-            'VERSION'   => '204.0',
504
-            'USER'      => urlencode($this->_api_username),
505
-            'PWD'       => urlencode($this->_api_password),
506
-            'SIGNATURE' => urlencode($this->_api_signature),
507
-        );
508
-        $dtls = array_merge($request_dtls, $request_params);
509
-        $this->_log_clean_request($dtls, $payment, $request_text . ' Request');
510
-        // Request Customer Details.
511
-        $request_response = wp_remote_post(
512
-            $this->_base_gateway_url,
513
-            array(
514
-                'method'      => 'POST',
515
-                'timeout'     => 45,
516
-                'httpversion' => '1.1',
517
-                'cookies'     => array(),
518
-                'headers'     => array(),
519
-                'body'        => http_build_query($dtls),
520
-            )
521
-        );
522
-        // Log the response.
523
-        $this->log(array($request_text . ' Response' => $request_response), $payment);
524
-        return $request_response;
525
-    }
526
-
527
-
528
-
529
-    /**
530
-     *  Check the response status.
531
-     *
532
-     * @param mixed $request_response
533
-     * @return array
534
-     */
535
-    public function _ppExpress_check_response($request_response)
536
-    {
537
-        if (is_wp_error($request_response) || empty($request_response['body'])) {
538
-            // If we got here then there was an error in this request.
539
-            return array('status' => false, 'args' => $request_response);
540
-        }
541
-        $response_args = array();
542
-        parse_str(urldecode($request_response['body']), $response_args);
543
-        if (! isset($response_args['ACK'])) {
544
-            return array('status' => false, 'args' => $request_response);
545
-        }
546
-        if (
547
-            (
548
-                isset($response_args['PAYERID'])
549
-                || isset($response_args['TOKEN'])
550
-                || isset($response_args['PAYMENTINFO_0_TRANSACTIONID'])
551
-                || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed')
552
-            )
553
-            && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true)
554
-        ) {
555
-            // Response status OK, return response parameters for further processing.
556
-            return array('status' => true, 'args' => $response_args);
557
-        }
558
-        $errors = $this->_get_errors($response_args);
559
-        return array('status' => false, 'args' => $errors);
560
-    }
561
-
562
-
563
-
564
-    /**
565
-     *  Log a "Cleared" request.
566
-     *
567
-     * @param array       $request
568
-     * @param EEI_Payment $payment
569
-     * @param string      $info
570
-     * @return void
571
-     */
572
-    private function _log_clean_request($request, $payment, $info)
573
-    {
574
-        $cleaned_request_data = $request;
575
-        unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']);
576
-        $this->log(array($info => $cleaned_request_data), $payment);
577
-    }
578
-
579
-
580
-
581
-    /**
582
-     *  Get error from the response data.
583
-     *
584
-     * @param array $data_array
585
-     * @return array
586
-     */
587
-    private function _get_errors($data_array)
588
-    {
589
-        $errors = array();
590
-        $n = 0;
591
-        while (isset($data_array["L_ERRORCODE{$n}"])) {
592
-            $l_error_code = isset($data_array["L_ERRORCODE{$n}"])
593
-                ? $data_array["L_ERRORCODE{$n}"]
594
-                : '';
595
-            $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"])
596
-                ? $data_array["L_SEVERITYCODE{$n}"]
597
-                : '';
598
-            $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"])
599
-                ? $data_array["L_SHORTMESSAGE{$n}"]
600
-                : '';
601
-            $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"])
602
-                ? $data_array["L_LONGMESSAGE{$n}"]
603
-                : '';
604
-            if ($n === 0) {
605
-                $errors = array(
606
-                    'L_ERRORCODE'    => $l_error_code,
607
-                    'L_SHORTMESSAGE' => $l_short_message,
608
-                    'L_LONGMESSAGE'  => $l_long_message,
609
-                    'L_SEVERITYCODE' => $l_severity_code,
610
-                );
611
-            } else {
612
-                $errors['L_ERRORCODE'] .= ', ' . $l_error_code;
613
-                $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
614
-                $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
615
-                $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
616
-            }
617
-            $n++;
618
-        }
619
-        return $errors;
620
-    }
35
+	/**
36
+	 * Merchant API Username.
37
+	 *
38
+	 * @var string
39
+	 */
40
+	protected $_api_username;
41
+
42
+	/**
43
+	 * Merchant API Password.
44
+	 *
45
+	 * @var string
46
+	 */
47
+	protected $_api_password;
48
+
49
+	/**
50
+	 * API Signature.
51
+	 *
52
+	 * @var string
53
+	 */
54
+	protected $_api_signature;
55
+
56
+	/**
57
+	 * Request Shipping address on PP checkout page.
58
+	 *
59
+	 * @var string
60
+	 */
61
+	protected $_request_shipping_addr;
62
+
63
+	/**
64
+	 * Business/personal logo.
65
+	 *
66
+	 * @var string
67
+	 */
68
+	protected $_image_url;
69
+
70
+	/**
71
+	 * gateway URL variable
72
+	 *
73
+	 * @var string
74
+	 */
75
+	protected $_base_gateway_url = '';
76
+
77
+
78
+
79
+	/**
80
+	 * EEG_Paypal_Express constructor.
81
+	 */
82
+	public function __construct()
83
+	{
84
+		$this->_currencies_supported = array(
85
+			'USD',
86
+			'AUD',
87
+			'BRL',
88
+			'CAD',
89
+			'CZK',
90
+			'DKK',
91
+			'EUR',
92
+			'HKD',
93
+			'HUF',
94
+			'ILS',
95
+			'JPY',
96
+			'MYR',
97
+			'MXN',
98
+			'NOK',
99
+			'NZD',
100
+			'PHP',
101
+			'PLN',
102
+			'GBP',
103
+			'RUB',
104
+			'SGD',
105
+			'SEK',
106
+			'CHF',
107
+			'TWD',
108
+			'THB',
109
+			'TRY',
110
+		);
111
+		parent::__construct();
112
+	}
113
+
114
+
115
+
116
+	/**
117
+	 * Sets the gateway URL variable based on whether debug mode is enabled or not.
118
+	 *
119
+	 * @param array $settings_array
120
+	 */
121
+	public function set_settings($settings_array)
122
+	{
123
+		parent::set_settings($settings_array);
124
+		// Redirect URL.
125
+		$this->_base_gateway_url = $this->_debug_mode
126
+			? 'https://api-3t.sandbox.paypal.com/nvp'
127
+			: 'https://api-3t.paypal.com/nvp';
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @param EEI_Payment $payment
134
+	 * @param array       $billing_info
135
+	 * @param string      $return_url
136
+	 * @param string      $notify_url
137
+	 * @param string      $cancel_url
138
+	 * @return \EE_Payment|\EEI_Payment
139
+	 * @throws \EE_Error
140
+	 */
141
+	public function set_redirection_info(
142
+		$payment,
143
+		$billing_info = array(),
144
+		$return_url = null,
145
+		$notify_url = null,
146
+		$cancel_url = null
147
+	) {
148
+		if (! $payment instanceof EEI_Payment) {
149
+			$payment->set_gateway_response(
150
+				esc_html__(
151
+					'Error. No associated payment was found.',
152
+					'event_espresso'
153
+				)
154
+			);
155
+			$payment->set_status($this->_pay_model->failed_status());
156
+			return $payment;
157
+		}
158
+		$transaction = $payment->transaction();
159
+		if (! $transaction instanceof EEI_Transaction) {
160
+			$payment->set_gateway_response(
161
+				esc_html__(
162
+					'Could not process this payment because it has no associated transaction.',
163
+					'event_espresso'
164
+				)
165
+			);
166
+			$payment->set_status($this->_pay_model->failed_status());
167
+			return $payment;
168
+		}
169
+		$order_description = mb_strcut($this->_format_order_description($payment), 0, 127);
170
+		$primary_registration = $transaction->primary_registration();
171
+		$primary_attendee = $primary_registration instanceof EE_Registration
172
+			? $primary_registration->attendee()
173
+			: false;
174
+		$locale = explode('-', get_bloginfo('language'));
175
+		// Gather request parameters.
176
+		$token_request_dtls = array(
177
+			'METHOD'                         => 'SetExpressCheckout',
178
+			'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
179
+			'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
180
+			'PAYMENTREQUEST_0_DESC'          => $order_description,
181
+			'RETURNURL'                      => $return_url,
182
+			'CANCELURL'                      => $cancel_url,
183
+			'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
184
+			// Buyer does not need to create a PayPal account to check out.
185
+			// This is referred to as PayPal Account Optional.
186
+			'SOLUTIONTYPE'                   => 'Sole',
187
+			//EE will blow up if you change this
188
+			'BUTTONSOURCE'                   => 'EventEspresso_SP',
189
+			// Locale of the pages displayed by PayPal during Express Checkout.
190
+			'LOCALECODE'                     => $locale[1]
191
+		);
192
+		// Show itemized list.
193
+		if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
194
+			$item_num = 0;
195
+			$itemized_sum = 0;
196
+			$total_line_items = $transaction->total_line_item();
197
+			// Go through each item in the list.
198
+			foreach ($total_line_items->get_items() as $line_item) {
199
+				if ($line_item instanceof EE_Line_Item) {
200
+					// PayPal doesn't like line items with 0.00 amount, so we may skip those.
201
+					if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) {
202
+						continue;
203
+					}
204
+					$unit_price = $line_item->unit_price();
205
+					$line_item_quantity = $line_item->quantity();
206
+					// This is a discount.
207
+					if ($line_item->is_percent()) {
208
+						$unit_price = $line_item->total();
209
+						$line_item_quantity = 1;
210
+					}
211
+					// Item Name.
212
+					$token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut(
213
+						$this->_format_line_item_name($line_item, $payment),
214
+						0,
215
+						127
216
+					);
217
+					// Item description.
218
+					$token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = mb_strcut(
219
+						$this->_format_line_item_desc($line_item, $payment),
220
+						0,
221
+						127
222
+					);
223
+					// Cost of individual item.
224
+					$token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency($unit_price);
225
+					// Item Number.
226
+					$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1;
227
+					// Item quantity.
228
+					$token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity;
229
+					// Digital item is sold.
230
+					$token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical';
231
+					$itemized_sum += $line_item->total();
232
+					++$item_num;
233
+				}
234
+			}
235
+			// Item's sales S/H and tax amount.
236
+			$token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total();
237
+			$token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax();
238
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
239
+			$token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
240
+			$itemized_sum_diff_from_txn_total = round(
241
+				$transaction->total() - $itemized_sum - $total_line_items->get_total_tax(),
242
+				2
243
+			);
244
+			// If we were not able to recognize some item like promotion, surcharge or cancellation,
245
+			// add the difference as an extra line item.
246
+			if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
247
+				// Item Name.
248
+				$token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut(
249
+					esc_html__(
250
+						'Other (promotion/surcharge/cancellation)',
251
+						'event_espresso'
252
+					),
253
+					0,
254
+					127
255
+				);
256
+				// Item description.
257
+				$token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = '';
258
+				// Cost of individual item.
259
+				$token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency(
260
+					$itemized_sum_diff_from_txn_total
261
+				);
262
+				// Item Number.
263
+				$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1;
264
+				// Item quantity.
265
+				$token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1;
266
+				// Digital item is sold.
267
+				$token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical';
268
+				$item_num++;
269
+			}
270
+		} else {
271
+			// Just one Item.
272
+			// Item Name.
273
+			$token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = mb_strcut(
274
+				$this->_format_partial_payment_line_item_name($payment),
275
+				0,
276
+				127
277
+			);
278
+			// Item description.
279
+			$token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = mb_strcut(
280
+				$this->_format_partial_payment_line_item_desc($payment),
281
+				0,
282
+				127
283
+			);
284
+			// Cost of individual item.
285
+			$token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount());
286
+			// Item Number.
287
+			$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
288
+			// Item quantity.
289
+			$token_request_dtls['L_PAYMENTREQUEST_0_QTY0'] = 1;
290
+			// Digital item is sold.
291
+			$token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical';
292
+			// Item's sales S/H and tax amount.
293
+			$token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount());
294
+			$token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0';
295
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
296
+			$token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
297
+		}
298
+		// Automatically filling out shipping and contact information.
299
+		if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) {
300
+			//  If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
301
+			$token_request_dtls['NOSHIPPING'] = '2';
302
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address();
303
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2();
304
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city();
305
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev();
306
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID();
307
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
308
+			$token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
309
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
310
+		} elseif (! $this->_request_shipping_addr) {
311
+			// Do not request shipping details on the PP Checkout page.
312
+			$token_request_dtls['NOSHIPPING'] = '1';
313
+			$token_request_dtls['REQCONFIRMSHIPPING'] = '0';
314
+		}
315
+		// Used a business/personal logo on the PayPal page.
316
+		if (! empty($this->_image_url)) {
317
+			$token_request_dtls['LOGOIMG'] = $this->_image_url;
318
+		}
319
+		$token_request_dtls = apply_filters(
320
+			'FHEE__EEG_Paypal_Express__set_redirection_info__arguments',
321
+			$token_request_dtls,
322
+			$this
323
+		);
324
+		// Request PayPal token.
325
+		$token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment);
326
+		$token_rstatus = $this->_ppExpress_check_response($token_request_response);
327
+		$response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args']))
328
+			? $token_rstatus['args']
329
+			: array();
330
+		if ($token_rstatus['status']) {
331
+			// We got the Token so we may continue with the payment and redirect the client.
332
+			$payment->set_details($response_args);
333
+			$gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
334
+			$payment->set_redirect_url(
335
+				$gateway_url
336
+				. '/checkoutnow?useraction=commit&cmd=_express-checkout&token='
337
+				. $response_args['TOKEN']
338
+			);
339
+		} else {
340
+			if (isset($response_args['L_ERRORCODE'])) {
341
+				$payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']);
342
+			} else {
343
+				$payment->set_gateway_response(
344
+					esc_html__(
345
+						'Error occurred while trying to setup the Express Checkout.',
346
+						'event_espresso'
347
+					)
348
+				);
349
+			}
350
+			$payment->set_details($response_args);
351
+			$payment->set_status($this->_pay_model->failed_status());
352
+		}
353
+		return $payment;
354
+	}
355
+
356
+
357
+
358
+	/**
359
+	 * @param array           $update_info {
360
+	 * @type string           $gateway_txn_id
361
+	 * @type string status an EEMI_Payment status
362
+	 *                                     }
363
+	 * @param EEI_Transaction $transaction
364
+	 * @return EEI_Payment
365
+	 */
366
+	public function handle_payment_update($update_info, $transaction)
367
+	{
368
+		$payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null;
369
+		if ($payment instanceof EEI_Payment) {
370
+			$this->log(array('Return from Authorization' => $update_info), $payment);
371
+			$transaction = $payment->transaction();
372
+			if (! $transaction instanceof EEI_Transaction) {
373
+				$payment->set_gateway_response(
374
+					esc_html__(
375
+						'Could not process this payment because it has no associated transaction.',
376
+						'event_espresso'
377
+					)
378
+				);
379
+				$payment->set_status($this->_pay_model->failed_status());
380
+				return $payment;
381
+			}
382
+			$primary_registrant = $transaction->primary_registration();
383
+			$payment_details = $payment->details();
384
+			// Check if we still have the token.
385
+			if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
386
+				$payment->set_status($this->_pay_model->failed_status());
387
+				return $payment;
388
+			}
389
+			$cdetails_request_dtls = array(
390
+				'METHOD' => 'GetExpressCheckoutDetails',
391
+				'TOKEN'  => $payment_details['TOKEN'],
392
+			);
393
+			// Request Customer Details.
394
+			$cdetails_request_response = $this->_ppExpress_request(
395
+				$cdetails_request_dtls,
396
+				'Customer Details',
397
+				$payment
398
+			);
399
+			$cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response);
400
+			$cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']))
401
+				? $cdetails_rstatus['args']
402
+				: array();
403
+			if ($cdetails_rstatus['status']) {
404
+				// We got the PayerID so now we can Complete the transaction.
405
+				$docheckout_request_dtls = array(
406
+					'METHOD'                         => 'DoExpressCheckoutPayment',
407
+					'PAYERID'                        => $cdata_response_args['PAYERID'],
408
+					'TOKEN'                          => $payment_details['TOKEN'],
409
+					'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
410
+					'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
411
+					'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
412
+					//EE will blow up if you change this
413
+					'BUTTONSOURCE'                   => 'EventEspresso_SP',
414
+				);
415
+				// Payment Checkout/Capture.
416
+				$docheckout_request_response = $this->_ppExpress_request(
417
+					$docheckout_request_dtls,
418
+					'Do Payment',
419
+					$payment
420
+				);
421
+				$docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response);
422
+				$docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']))
423
+					? $docheckout_rstatus['args']
424
+					: array();
425
+				if ($docheckout_rstatus['status']) {
426
+					// All is well, payment approved.
427
+					$primary_registration_code = $primary_registrant instanceof EE_Registration ?
428
+						$primary_registrant->reg_code()
429
+						: '';
430
+					$payment->set_extra_accntng($primary_registration_code);
431
+					$payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT'])
432
+						? (float)$docheckout_response_args['PAYMENTINFO_0_AMT']
433
+						: 0);
434
+					$payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'])
435
+						? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']
436
+						: null);
437
+					$payment->set_details($cdata_response_args);
438
+					$payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK'])
439
+						? $docheckout_response_args['PAYMENTINFO_0_ACK']
440
+						: '');
441
+					$payment->set_status($this->_pay_model->approved_status());
442
+				} else {
443
+					if (isset($docheckout_response_args['L_ERRORCODE'])) {
444
+						$payment->set_gateway_response(
445
+							$docheckout_response_args['L_ERRORCODE']
446
+							. '; '
447
+							. $docheckout_response_args['L_SHORTMESSAGE']
448
+						);
449
+					} else {
450
+						$payment->set_gateway_response(
451
+							esc_html__(
452
+								'Error occurred while trying to Capture the funds.',
453
+								'event_espresso'
454
+							)
455
+						);
456
+					}
457
+					$payment->set_details($docheckout_response_args);
458
+					$payment->set_status($this->_pay_model->declined_status());
459
+				}
460
+			} else {
461
+				if (isset($cdata_response_args['L_ERRORCODE'])) {
462
+					$payment->set_gateway_response(
463
+						$cdata_response_args['L_ERRORCODE']
464
+						. '; '
465
+						. $cdata_response_args['L_SHORTMESSAGE']
466
+					);
467
+				} else {
468
+					$payment->set_gateway_response(
469
+						esc_html__(
470
+							'Error occurred while trying to get payment Details from PayPal.',
471
+							'event_espresso'
472
+						)
473
+					);
474
+				}
475
+				$payment->set_details($cdata_response_args);
476
+				$payment->set_status($this->_pay_model->failed_status());
477
+			}
478
+		} else {
479
+			$payment->set_gateway_response(
480
+				esc_html__(
481
+					'Error occurred while trying to process the payment.',
482
+					'event_espresso'
483
+				)
484
+			);
485
+			$payment->set_status($this->_pay_model->failed_status());
486
+		}
487
+		return $payment;
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 *  Make the Express checkout request.
494
+	 *
495
+	 * @param array       $request_params
496
+	 * @param string      $request_text
497
+	 * @param EEI_Payment $payment
498
+	 * @return mixed
499
+	 */
500
+	public function _ppExpress_request($request_params, $request_text, $payment)
501
+	{
502
+		$request_dtls = array(
503
+			'VERSION'   => '204.0',
504
+			'USER'      => urlencode($this->_api_username),
505
+			'PWD'       => urlencode($this->_api_password),
506
+			'SIGNATURE' => urlencode($this->_api_signature),
507
+		);
508
+		$dtls = array_merge($request_dtls, $request_params);
509
+		$this->_log_clean_request($dtls, $payment, $request_text . ' Request');
510
+		// Request Customer Details.
511
+		$request_response = wp_remote_post(
512
+			$this->_base_gateway_url,
513
+			array(
514
+				'method'      => 'POST',
515
+				'timeout'     => 45,
516
+				'httpversion' => '1.1',
517
+				'cookies'     => array(),
518
+				'headers'     => array(),
519
+				'body'        => http_build_query($dtls),
520
+			)
521
+		);
522
+		// Log the response.
523
+		$this->log(array($request_text . ' Response' => $request_response), $payment);
524
+		return $request_response;
525
+	}
526
+
527
+
528
+
529
+	/**
530
+	 *  Check the response status.
531
+	 *
532
+	 * @param mixed $request_response
533
+	 * @return array
534
+	 */
535
+	public function _ppExpress_check_response($request_response)
536
+	{
537
+		if (is_wp_error($request_response) || empty($request_response['body'])) {
538
+			// If we got here then there was an error in this request.
539
+			return array('status' => false, 'args' => $request_response);
540
+		}
541
+		$response_args = array();
542
+		parse_str(urldecode($request_response['body']), $response_args);
543
+		if (! isset($response_args['ACK'])) {
544
+			return array('status' => false, 'args' => $request_response);
545
+		}
546
+		if (
547
+			(
548
+				isset($response_args['PAYERID'])
549
+				|| isset($response_args['TOKEN'])
550
+				|| isset($response_args['PAYMENTINFO_0_TRANSACTIONID'])
551
+				|| (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed')
552
+			)
553
+			&& in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true)
554
+		) {
555
+			// Response status OK, return response parameters for further processing.
556
+			return array('status' => true, 'args' => $response_args);
557
+		}
558
+		$errors = $this->_get_errors($response_args);
559
+		return array('status' => false, 'args' => $errors);
560
+	}
561
+
562
+
563
+
564
+	/**
565
+	 *  Log a "Cleared" request.
566
+	 *
567
+	 * @param array       $request
568
+	 * @param EEI_Payment $payment
569
+	 * @param string      $info
570
+	 * @return void
571
+	 */
572
+	private function _log_clean_request($request, $payment, $info)
573
+	{
574
+		$cleaned_request_data = $request;
575
+		unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']);
576
+		$this->log(array($info => $cleaned_request_data), $payment);
577
+	}
578
+
579
+
580
+
581
+	/**
582
+	 *  Get error from the response data.
583
+	 *
584
+	 * @param array $data_array
585
+	 * @return array
586
+	 */
587
+	private function _get_errors($data_array)
588
+	{
589
+		$errors = array();
590
+		$n = 0;
591
+		while (isset($data_array["L_ERRORCODE{$n}"])) {
592
+			$l_error_code = isset($data_array["L_ERRORCODE{$n}"])
593
+				? $data_array["L_ERRORCODE{$n}"]
594
+				: '';
595
+			$l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"])
596
+				? $data_array["L_SEVERITYCODE{$n}"]
597
+				: '';
598
+			$l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"])
599
+				? $data_array["L_SHORTMESSAGE{$n}"]
600
+				: '';
601
+			$l_long_message = isset($data_array["L_LONGMESSAGE{$n}"])
602
+				? $data_array["L_LONGMESSAGE{$n}"]
603
+				: '';
604
+			if ($n === 0) {
605
+				$errors = array(
606
+					'L_ERRORCODE'    => $l_error_code,
607
+					'L_SHORTMESSAGE' => $l_short_message,
608
+					'L_LONGMESSAGE'  => $l_long_message,
609
+					'L_SEVERITYCODE' => $l_severity_code,
610
+				);
611
+			} else {
612
+				$errors['L_ERRORCODE'] .= ', ' . $l_error_code;
613
+				$errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
614
+				$errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
615
+				$errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
616
+			}
617
+			$n++;
618
+		}
619
+		return $errors;
620
+	}
621 621
 
622 622
 }
623 623
 // End of file EEG_Paypal_Express.gateway.php
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('NO direct script access allowed');
3 3
 }
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * ----------------------------------------------
16 16
  */
17 17
 //Quickfix to address https://events.codebasehq.com/projects/event-espresso/tickets/11089 ASAP
18
-if (! function_exists('mb_strcut')) {
18
+if ( ! function_exists('mb_strcut')) {
19 19
     /**
20 20
      * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
21 21
      * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $notify_url = null,
146 146
         $cancel_url = null
147 147
     ) {
148
-        if (! $payment instanceof EEI_Payment) {
148
+        if ( ! $payment instanceof EEI_Payment) {
149 149
             $payment->set_gateway_response(
150 150
                 esc_html__(
151 151
                     'Error. No associated payment was found.',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             return $payment;
157 157
         }
158 158
         $transaction = $payment->transaction();
159
-        if (! $transaction instanceof EEI_Transaction) {
159
+        if ( ! $transaction instanceof EEI_Transaction) {
160 160
             $payment->set_gateway_response(
161 161
                 esc_html__(
162 162
                     'Could not process this payment because it has no associated transaction.',
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
                         $line_item_quantity = 1;
210 210
                     }
211 211
                     // Item Name.
212
-                    $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut(
212
+                    $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = mb_strcut(
213 213
                         $this->_format_line_item_name($line_item, $payment),
214 214
                         0,
215 215
                         127
216 216
                     );
217 217
                     // Item description.
218
-                    $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = mb_strcut(
218
+                    $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = mb_strcut(
219 219
                         $this->_format_line_item_desc($line_item, $payment),
220 220
                         0,
221 221
                         127
222 222
                     );
223 223
                     // Cost of individual item.
224
-                    $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency($unit_price);
224
+                    $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price);
225 225
                     // Item Number.
226
-                    $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1;
226
+                    $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
227 227
                     // Item quantity.
228
-                    $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity;
228
+                    $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = $line_item_quantity;
229 229
                     // Digital item is sold.
230
-                    $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical';
230
+                    $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical';
231 231
                     $itemized_sum += $line_item->total();
232 232
                     ++$item_num;
233 233
                 }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             // add the difference as an extra line item.
246 246
             if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
247 247
                 // Item Name.
248
-                $token_request_dtls['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut(
248
+                $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = mb_strcut(
249 249
                     esc_html__(
250 250
                         'Other (promotion/surcharge/cancellation)',
251 251
                         'event_espresso'
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
                     127
255 255
                 );
256 256
                 // Item description.
257
-                $token_request_dtls['L_PAYMENTREQUEST_0_DESC' . $item_num] = '';
257
+                $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = '';
258 258
                 // Cost of individual item.
259
-                $token_request_dtls['L_PAYMENTREQUEST_0_AMT' . $item_num] = $this->format_currency(
259
+                $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency(
260 260
                     $itemized_sum_diff_from_txn_total
261 261
                 );
262 262
                 // Item Number.
263
-                $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1;
263
+                $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
264 264
                 // Item quantity.
265
-                $token_request_dtls['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1;
265
+                $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1;
266 266
                 // Digital item is sold.
267
-                $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical';
267
+                $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical';
268 268
                 $item_num++;
269 269
             }
270 270
         } else {
@@ -307,13 +307,13 @@  discard block
 block discarded – undo
307 307
             $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
308 308
             $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
309 309
             $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
310
-        } elseif (! $this->_request_shipping_addr) {
310
+        } elseif ( ! $this->_request_shipping_addr) {
311 311
             // Do not request shipping details on the PP Checkout page.
312 312
             $token_request_dtls['NOSHIPPING'] = '1';
313 313
             $token_request_dtls['REQCONFIRMSHIPPING'] = '0';
314 314
         }
315 315
         // Used a business/personal logo on the PayPal page.
316
-        if (! empty($this->_image_url)) {
316
+        if ( ! empty($this->_image_url)) {
317 317
             $token_request_dtls['LOGOIMG'] = $this->_image_url;
318 318
         }
319 319
         $token_request_dtls = apply_filters(
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
             );
339 339
         } else {
340 340
             if (isset($response_args['L_ERRORCODE'])) {
341
-                $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']);
341
+                $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']);
342 342
             } else {
343 343
                 $payment->set_gateway_response(
344 344
                     esc_html__(
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         if ($payment instanceof EEI_Payment) {
370 370
             $this->log(array('Return from Authorization' => $update_info), $payment);
371 371
             $transaction = $payment->transaction();
372
-            if (! $transaction instanceof EEI_Transaction) {
372
+            if ( ! $transaction instanceof EEI_Transaction) {
373 373
                 $payment->set_gateway_response(
374 374
                     esc_html__(
375 375
                         'Could not process this payment because it has no associated transaction.',
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             $primary_registrant = $transaction->primary_registration();
383 383
             $payment_details = $payment->details();
384 384
             // Check if we still have the token.
385
-            if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
385
+            if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
386 386
                 $payment->set_status($this->_pay_model->failed_status());
387 387
                 return $payment;
388 388
             }
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
                         : '';
430 430
                     $payment->set_extra_accntng($primary_registration_code);
431 431
                     $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT'])
432
-                        ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT']
432
+                        ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT']
433 433
                         : 0);
434 434
                     $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'])
435 435
                         ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
             'SIGNATURE' => urlencode($this->_api_signature),
507 507
         );
508 508
         $dtls = array_merge($request_dtls, $request_params);
509
-        $this->_log_clean_request($dtls, $payment, $request_text . ' Request');
509
+        $this->_log_clean_request($dtls, $payment, $request_text.' Request');
510 510
         // Request Customer Details.
511 511
         $request_response = wp_remote_post(
512 512
             $this->_base_gateway_url,
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
             )
521 521
         );
522 522
         // Log the response.
523
-        $this->log(array($request_text . ' Response' => $request_response), $payment);
523
+        $this->log(array($request_text.' Response' => $request_response), $payment);
524 524
         return $request_response;
525 525
     }
526 526
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
         }
541 541
         $response_args = array();
542 542
         parse_str(urldecode($request_response['body']), $response_args);
543
-        if (! isset($response_args['ACK'])) {
543
+        if ( ! isset($response_args['ACK'])) {
544 544
             return array('status' => false, 'args' => $request_response);
545 545
         }
546 546
         if (
@@ -609,10 +609,10 @@  discard block
 block discarded – undo
609 609
                     'L_SEVERITYCODE' => $l_severity_code,
610 610
                 );
611 611
             } else {
612
-                $errors['L_ERRORCODE'] .= ', ' . $l_error_code;
613
-                $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
614
-                $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
615
-                $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
612
+                $errors['L_ERRORCODE'] .= ', '.$l_error_code;
613
+                $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message;
614
+                $errors['L_LONGMESSAGE'] .= ', '.$l_long_message;
615
+                $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code;
616 616
             }
617 617
             $n++;
618 618
         }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -14,128 +14,128 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
24
-
25
-
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
-    }
33
-
34
-
35
-    /**
36
-     * Triggers saving the Event.
37
-     */
38
-    public function saveEvent()
39
-    {
40
-        $this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
41
-    }
42
-
43
-
44
-    /**
45
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
46
-     * First this will search using the given title and then attempt to edit from the results of the search.
47
-     *
48
-     * Assumes actor is already logged in.
49
-     * @param $event_title
50
-     */
51
-    public function amEditingTheEventWithTitle($event_title)
52
-    {
53
-        $this->amOnDefaultEventsListTablePage();
54
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
55
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
56
-        $this->actor()->waitForText($event_title, 15);
57
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
58
-    }
59
-
60
-
61
-    /**
62
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
63
-     * link for the event in the event list table.
64
-     * Assumes the actor is already logged in and on the Event list table page.
65
-     *
66
-     * @param string $event_title
67
-     */
68
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
69
-    {
70
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
71
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
72
-    }
73
-
74
-
75
-    /**
76
-     * Used to retrieve the event id for the event via the list table and for the given event.
77
-     * @param string $event_title
78
-     */
79
-    public function observeEventIdInListTableForEvent($event_title)
80
-    {
81
-        return $this->actor()->observeValueFromInputAt(EventsPage::eventListTableEventIdSelectorForTitle($event_title));
82
-    }
83
-
84
-
85
-    /**
86
-     * This performs the click action on the gear icon that triggers the advanced settings view state.
87
-     * Assumes the actor is already logged in and editing an event.
88
-     *
89
-     * @param int $row_number  What ticket row to toggle open/close.
90
-     */
91
-    public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
92
-    {
93
-        $this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
94
-    }
95
-
96
-
97
-    /**
98
-     * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
99
-     * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
100
-     * ticket is "open".
101
-     *
102
-     * @param int $row_number  What ticket row to toggle the checkbox for.
103
-     */
104
-    public function toggleTicketIsTaxableForTicketRow($row_number = 1)
105
-    {
106
-        $this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
107
-    }
108
-
109
-
110
-    /**
111
-     * Use to change the default registration status for the event.
112
-     * Assumes the view is already on the event editor.
113
-     * @param $registration_status
114
-     */
115
-    public function changeDefaultRegistrationStatusTo($registration_status)
116
-    {
117
-        $this->actor()->selectOption(
118
-            EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
119
-            $registration_status
120
-        );
121
-    }
122
-
123
-
124
-    /**
125
-     * Use this from the context of the event editor to select the given custom template for a given message type and
126
-     * messenger.
127
-     *
128
-     * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
129
-     * @param string $messenger_slug      The slug for the messenger (eg 'email')
130
-     * @param string $custom_template_label The visible label in the select input for the custom template you want
131
-     *                                      selected.
132
-     */
133
-    public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
134
-    {
135
-        $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
136
-        $this->actor()->selectOption(
137
-            EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
138
-            $custom_template_label
139
-        );
140
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24
+
25
+
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
+	}
33
+
34
+
35
+	/**
36
+	 * Triggers saving the Event.
37
+	 */
38
+	public function saveEvent()
39
+	{
40
+		$this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
46
+	 * First this will search using the given title and then attempt to edit from the results of the search.
47
+	 *
48
+	 * Assumes actor is already logged in.
49
+	 * @param $event_title
50
+	 */
51
+	public function amEditingTheEventWithTitle($event_title)
52
+	{
53
+		$this->amOnDefaultEventsListTablePage();
54
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
55
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
56
+		$this->actor()->waitForText($event_title, 15);
57
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
58
+	}
59
+
60
+
61
+	/**
62
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
63
+	 * link for the event in the event list table.
64
+	 * Assumes the actor is already logged in and on the Event list table page.
65
+	 *
66
+	 * @param string $event_title
67
+	 */
68
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
69
+	{
70
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
71
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
72
+	}
73
+
74
+
75
+	/**
76
+	 * Used to retrieve the event id for the event via the list table and for the given event.
77
+	 * @param string $event_title
78
+	 */
79
+	public function observeEventIdInListTableForEvent($event_title)
80
+	{
81
+		return $this->actor()->observeValueFromInputAt(EventsPage::eventListTableEventIdSelectorForTitle($event_title));
82
+	}
83
+
84
+
85
+	/**
86
+	 * This performs the click action on the gear icon that triggers the advanced settings view state.
87
+	 * Assumes the actor is already logged in and editing an event.
88
+	 *
89
+	 * @param int $row_number  What ticket row to toggle open/close.
90
+	 */
91
+	public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
92
+	{
93
+		$this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
94
+	}
95
+
96
+
97
+	/**
98
+	 * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
99
+	 * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
100
+	 * ticket is "open".
101
+	 *
102
+	 * @param int $row_number  What ticket row to toggle the checkbox for.
103
+	 */
104
+	public function toggleTicketIsTaxableForTicketRow($row_number = 1)
105
+	{
106
+		$this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
107
+	}
108
+
109
+
110
+	/**
111
+	 * Use to change the default registration status for the event.
112
+	 * Assumes the view is already on the event editor.
113
+	 * @param $registration_status
114
+	 */
115
+	public function changeDefaultRegistrationStatusTo($registration_status)
116
+	{
117
+		$this->actor()->selectOption(
118
+			EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
119
+			$registration_status
120
+		);
121
+	}
122
+
123
+
124
+	/**
125
+	 * Use this from the context of the event editor to select the given custom template for a given message type and
126
+	 * messenger.
127
+	 *
128
+	 * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
129
+	 * @param string $messenger_slug      The slug for the messenger (eg 'email')
130
+	 * @param string $custom_template_label The visible label in the select input for the custom template you want
131
+	 *                                      selected.
132
+	 */
133
+	public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
134
+	{
135
+		$this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
136
+		$this->actor()->selectOption(
137
+			EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
138
+			$custom_template_label
139
+		);
140
+	}
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/MessagesAdmin.php 1 patch
Indentation   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -10,290 +10,290 @@
 block discarded – undo
10 10
  */
11 11
 trait MessagesAdmin
12 12
 {
13
-    /**
14
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
15
-     *                                  a string.
16
-     */
17
-    public function amOnMessagesActivityListTablePage($additional_params = '')
18
-    {
19
-        $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
-    }
21
-
22
-    /**
23
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
24
-     *                                  a string.
25
-     */
26
-    public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
-    {
28
-        $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
-    }
30
-
31
-
32
-    /**
33
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
34
-     *                                  a string.
35
-     */
36
-    public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
-    {
38
-        $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
-    }
40
-
41
-
42
-    /**
43
-     * Directs to message settings page
44
-     */
45
-    public function amOnMessageSettingsPage()
46
-    {
47
-        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
-    }
49
-
50
-
51
-    public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
-    {
53
-        $this->actor()->dragAndDrop(
54
-            MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
-            MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     * Assumes you are already on the list table page that has the ui for editing the template.
62
-     * @param string $message_type_slug
63
-     * @param string $context [optional] if you want to click directly to the given context in the editor
64
-     */
65
-    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
-    {
67
-        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
-    }
69
-
70
-
71
-    /**
72
-     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
-     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
-     *
75
-     * @param int    $expected_occurence_count
76
-     * @param string $text_to_check_for
77
-     * @param string $field
78
-     * @param string $message_type_label
79
-     * @param string $message_status
80
-     * @param string $messenger
81
-     * @param string $context
82
-     */
83
-    public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
-        $expected_occurence_count,
85
-        $text_to_check_for,
86
-        $field,
87
-        $message_type_label,
88
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
-        $messenger = 'Email',
90
-        $context = 'Event Admin'
91
-    ) {
92
-        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
-            $field,
94
-            $message_type_label,
95
-            $message_status,
96
-            $messenger,
97
-            $context,
98
-            $text_to_check_for,
99
-            0
100
-        ));
101
-        $actual_count = count($elements);
102
-        $this->actor()->assertEquals(
103
-            $expected_occurence_count,
104
-            $actual_count,
105
-            sprintf(
106
-                'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
-                $expected_occurence_count,
108
-                $text_to_check_for,
109
-                $field,
110
-                $actual_count
111
-            )
112
-        );
113
-    }
114
-
115
-
116
-    /**
117
-     * This will create a custom message template for the given messenger and message type from the context of the
118
-     * default (global) message template list table.
119
-     * Also takes care of verifying the template was created.
120
-     * @param string $message_type_label
121
-     * @param string $messenger_label
122
-     */
123
-    public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
-    {
125
-        $this->amOnDefaultMessageTemplateListTablePage();
126
-        $this->actor()->click(
127
-            MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
-                $message_type_label,
129
-                $messenger_label
130
-            )
131
-        );
132
-        $this->actor()->seeInField('#title', 'New Custom Template');
133
-    }
134
-
135
-
136
-    /**
137
-     * This switches the context of the current messages template to the given reference.
138
-     * @param string $context_reference  This should be the visible label for the option.
139
-     */
140
-    public function switchContextTo($context_reference)
141
-    {
142
-        $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
-        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
-        $this->actor()->waitForText($context_reference, 10, 'h1');
145
-    }
146
-
147
-
148
-    /**
149
-     * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after
150
-     * toggling.
151
-     *
152
-     * @param string $context_string           What context is being switched (used for the expected state text)
153
-     * @param bool   $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive
154
-     *                                         (false)
155
-     */
156
-    public function toggleContextState($context_string, $expected_state_is_active = true)
157
-    {
158
-        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE);
159
-        if ($expected_state_is_active) {
160
-            $this->actor()->waitForText("The template for $context_string is currently active.");
161
-        } else {
162
-            $this->actor()->waitForText("The template for $context_string is currently inactive");
163
-        }
164
-    }
165
-
166
-
167
-    /**
168
-     * Triggers saving the message template.
169
-     * @param bool $and_close   Use to indicate to click the Save and Close button.
170
-     */
171
-    public function saveMessageTemplate($and_close = false)
172
-    {
173
-        if ($and_close) {
174
-            $this->actor()->click('Save and Close');
175
-        } else {
176
-            $this->actor()->click('Save');
177
-        }
178
-        $this->actor()->waitForText('successfully updated');
179
-    }
180
-
181
-
182
-    /**
183
-     * This takes care of clicking the View Message icon for the given parameters.
184
-     * Assumes you are already viewing the messages activity list table.
185
-     * @param        $message_type_label
186
-     * @param        $message_status
187
-     * @param string $messenger
188
-     * @param string $context
189
-     * @param int    $number_in_set
190
-     */
191
-    public function viewMessageInMessagesListTableFor(
192
-        $message_type_label,
193
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
194
-        $messenger = 'Email',
195
-        $context = 'Event Admin',
196
-        $number_in_set = 1
197
-    ) {
198
-        $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
199
-            $message_type_label,
200
-            $message_status,
201
-            $messenger,
202
-            $context,
203
-            $number_in_set
204
-        ));
205
-    }
206
-
207
-
208
-    /**
209
-     * Takes care of deleting a message matching the given parameters via the message activity list table.
210
-     * Assumes you are already viewing the messages activity list table.
211
-     * @param        $message_type_label
212
-     * @param        $message_status
213
-     * @param string $messenger
214
-     * @param string $context
215
-     * @param int    $number_in_set
216
-     */
217
-    public function deleteMessageInMessagesListTableFor(
218
-        $message_type_label,
219
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
220
-        $messenger = 'Email',
221
-        $context = 'Event Admin',
222
-        $number_in_set = 1
223
-    ) {
224
-        $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
225
-            $message_type_label,
226
-            $message_status,
227
-            $messenger,
228
-            $context,
229
-            $number_in_set
230
-        );
231
-        $this->actor()->moveMouseOver(
232
-            MessagesPage::messagesActivityListTableCellSelectorFor(
233
-                'to',
234
-                $message_type_label,
235
-                $message_status,
236
-                $messenger,
237
-                $context,
238
-                '',
239
-                $number_in_set
240
-            ),
241
-            5,
242
-            5
243
-        );
244
-        $this->actor()->waitForElementVisible(
245
-            $delete_action_selector
246
-        );
247
-        $this->actor()->click(
248
-            $delete_action_selector
249
-        );
250
-        $this->actor()->waitForText('successfully deleted');
251
-    }
252
-
253
-
254
-    /**
255
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
256
-     * list table, this will take care of validating the given text is in that window.
257
-     * @param string $text_to_view
258
-     */
259
-    public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
260
-    {
261
-        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
262
-        $this->actor()->switchToIframe('message-view-window');
263
-        $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
264
-        $this->actor()->switchToIframe();
265
-    }
266
-
267
-
268
-    /**
269
-     * This returns the value for the link at the given selector in the message modal.
270
-     * @param string $selector (any selector string accepted by WebDriver)
271
-     */
272
-    public function observeLinkAtSelectorInMessageModal($selector)
273
-    {
274
-        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
275
-        $this->actor()->switchToIframe('message-view-window');
276
-        $link = $this->actor()->observeLinkUrlAt($selector);
277
-        $this->actor()->switchToIframe();
278
-        return $link;
279
-    }
280
-
281
-
282
-    /**
283
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
284
-     * list table, this will take care of validating the given text is NOT that window.
285
-     * @param string $text_to_view
286
-     */
287
-    public function dontSeeTextInViewMessageModal($text_to_view)
288
-    {
289
-        $this->seeTextInViewMessageModal($text_to_view, true);
290
-    }
291
-
292
-
293
-    public function dismissMessageModal()
294
-    {
295
-        $this->actor()->click('#espresso-admin-page-overlay-dv');
296
-        //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail.
297
-        $this->actor()->click('form#EE_Message_List_Table-table-frm');
298
-    }
13
+	/**
14
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
15
+	 *                                  a string.
16
+	 */
17
+	public function amOnMessagesActivityListTablePage($additional_params = '')
18
+	{
19
+		$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
+	}
21
+
22
+	/**
23
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
24
+	 *                                  a string.
25
+	 */
26
+	public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
+	{
28
+		$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
34
+	 *                                  a string.
35
+	 */
36
+	public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
+	{
38
+		$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
+	}
40
+
41
+
42
+	/**
43
+	 * Directs to message settings page
44
+	 */
45
+	public function amOnMessageSettingsPage()
46
+	{
47
+		$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
+	}
49
+
50
+
51
+	public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
+	{
53
+		$this->actor()->dragAndDrop(
54
+			MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
+			MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 * Assumes you are already on the list table page that has the ui for editing the template.
62
+	 * @param string $message_type_slug
63
+	 * @param string $context [optional] if you want to click directly to the given context in the editor
64
+	 */
65
+	public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
+	{
67
+		$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
+	}
69
+
70
+
71
+	/**
72
+	 * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
+	 * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
+	 *
75
+	 * @param int    $expected_occurence_count
76
+	 * @param string $text_to_check_for
77
+	 * @param string $field
78
+	 * @param string $message_type_label
79
+	 * @param string $message_status
80
+	 * @param string $messenger
81
+	 * @param string $context
82
+	 */
83
+	public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
+		$expected_occurence_count,
85
+		$text_to_check_for,
86
+		$field,
87
+		$message_type_label,
88
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
+		$messenger = 'Email',
90
+		$context = 'Event Admin'
91
+	) {
92
+		$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
+			$field,
94
+			$message_type_label,
95
+			$message_status,
96
+			$messenger,
97
+			$context,
98
+			$text_to_check_for,
99
+			0
100
+		));
101
+		$actual_count = count($elements);
102
+		$this->actor()->assertEquals(
103
+			$expected_occurence_count,
104
+			$actual_count,
105
+			sprintf(
106
+				'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
+				$expected_occurence_count,
108
+				$text_to_check_for,
109
+				$field,
110
+				$actual_count
111
+			)
112
+		);
113
+	}
114
+
115
+
116
+	/**
117
+	 * This will create a custom message template for the given messenger and message type from the context of the
118
+	 * default (global) message template list table.
119
+	 * Also takes care of verifying the template was created.
120
+	 * @param string $message_type_label
121
+	 * @param string $messenger_label
122
+	 */
123
+	public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
+	{
125
+		$this->amOnDefaultMessageTemplateListTablePage();
126
+		$this->actor()->click(
127
+			MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
+				$message_type_label,
129
+				$messenger_label
130
+			)
131
+		);
132
+		$this->actor()->seeInField('#title', 'New Custom Template');
133
+	}
134
+
135
+
136
+	/**
137
+	 * This switches the context of the current messages template to the given reference.
138
+	 * @param string $context_reference  This should be the visible label for the option.
139
+	 */
140
+	public function switchContextTo($context_reference)
141
+	{
142
+		$this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
+		$this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
+		$this->actor()->waitForText($context_reference, 10, 'h1');
145
+	}
146
+
147
+
148
+	/**
149
+	 * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after
150
+	 * toggling.
151
+	 *
152
+	 * @param string $context_string           What context is being switched (used for the expected state text)
153
+	 * @param bool   $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive
154
+	 *                                         (false)
155
+	 */
156
+	public function toggleContextState($context_string, $expected_state_is_active = true)
157
+	{
158
+		$this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE);
159
+		if ($expected_state_is_active) {
160
+			$this->actor()->waitForText("The template for $context_string is currently active.");
161
+		} else {
162
+			$this->actor()->waitForText("The template for $context_string is currently inactive");
163
+		}
164
+	}
165
+
166
+
167
+	/**
168
+	 * Triggers saving the message template.
169
+	 * @param bool $and_close   Use to indicate to click the Save and Close button.
170
+	 */
171
+	public function saveMessageTemplate($and_close = false)
172
+	{
173
+		if ($and_close) {
174
+			$this->actor()->click('Save and Close');
175
+		} else {
176
+			$this->actor()->click('Save');
177
+		}
178
+		$this->actor()->waitForText('successfully updated');
179
+	}
180
+
181
+
182
+	/**
183
+	 * This takes care of clicking the View Message icon for the given parameters.
184
+	 * Assumes you are already viewing the messages activity list table.
185
+	 * @param        $message_type_label
186
+	 * @param        $message_status
187
+	 * @param string $messenger
188
+	 * @param string $context
189
+	 * @param int    $number_in_set
190
+	 */
191
+	public function viewMessageInMessagesListTableFor(
192
+		$message_type_label,
193
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
194
+		$messenger = 'Email',
195
+		$context = 'Event Admin',
196
+		$number_in_set = 1
197
+	) {
198
+		$this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
199
+			$message_type_label,
200
+			$message_status,
201
+			$messenger,
202
+			$context,
203
+			$number_in_set
204
+		));
205
+	}
206
+
207
+
208
+	/**
209
+	 * Takes care of deleting a message matching the given parameters via the message activity list table.
210
+	 * Assumes you are already viewing the messages activity list table.
211
+	 * @param        $message_type_label
212
+	 * @param        $message_status
213
+	 * @param string $messenger
214
+	 * @param string $context
215
+	 * @param int    $number_in_set
216
+	 */
217
+	public function deleteMessageInMessagesListTableFor(
218
+		$message_type_label,
219
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
220
+		$messenger = 'Email',
221
+		$context = 'Event Admin',
222
+		$number_in_set = 1
223
+	) {
224
+		$delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
225
+			$message_type_label,
226
+			$message_status,
227
+			$messenger,
228
+			$context,
229
+			$number_in_set
230
+		);
231
+		$this->actor()->moveMouseOver(
232
+			MessagesPage::messagesActivityListTableCellSelectorFor(
233
+				'to',
234
+				$message_type_label,
235
+				$message_status,
236
+				$messenger,
237
+				$context,
238
+				'',
239
+				$number_in_set
240
+			),
241
+			5,
242
+			5
243
+		);
244
+		$this->actor()->waitForElementVisible(
245
+			$delete_action_selector
246
+		);
247
+		$this->actor()->click(
248
+			$delete_action_selector
249
+		);
250
+		$this->actor()->waitForText('successfully deleted');
251
+	}
252
+
253
+
254
+	/**
255
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
256
+	 * list table, this will take care of validating the given text is in that window.
257
+	 * @param string $text_to_view
258
+	 */
259
+	public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
260
+	{
261
+		$this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
262
+		$this->actor()->switchToIframe('message-view-window');
263
+		$should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
264
+		$this->actor()->switchToIframe();
265
+	}
266
+
267
+
268
+	/**
269
+	 * This returns the value for the link at the given selector in the message modal.
270
+	 * @param string $selector (any selector string accepted by WebDriver)
271
+	 */
272
+	public function observeLinkAtSelectorInMessageModal($selector)
273
+	{
274
+		$this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
275
+		$this->actor()->switchToIframe('message-view-window');
276
+		$link = $this->actor()->observeLinkUrlAt($selector);
277
+		$this->actor()->switchToIframe();
278
+		return $link;
279
+	}
280
+
281
+
282
+	/**
283
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
284
+	 * list table, this will take care of validating the given text is NOT that window.
285
+	 * @param string $text_to_view
286
+	 */
287
+	public function dontSeeTextInViewMessageModal($text_to_view)
288
+	{
289
+		$this->seeTextInViewMessageModal($text_to_view, true);
290
+	}
291
+
292
+
293
+	public function dismissMessageModal()
294
+	{
295
+		$this->actor()->click('#espresso-admin-page-overlay-dv');
296
+		//this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail.
297
+		$this->actor()->click('form#EE_Message_List_Table-table-frm');
298
+	}
299 299
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/MessagesAdmin.php 1 patch
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -14,292 +14,292 @@
 block discarded – undo
14 14
 class MessagesAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Context slug for the admin messages context.
19
-     */
20
-    const ADMIN_CONTEXT_SLUG = 'admin';
17
+	/**
18
+	 * Context slug for the admin messages context.
19
+	 */
20
+	const ADMIN_CONTEXT_SLUG = 'admin';
21 21
 
22
-    /**
23
-     * Context slug for the primary attendee messages context
24
-     */
25
-    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
22
+	/**
23
+	 * Context slug for the primary attendee messages context
24
+	 */
25
+	const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26 26
 
27 27
 
28
-    /**
29
-     * Context slug for the attendee messages context
30
-     */
31
-    const ATTENDEE_CONTEXT_SLUG = 'attendee';
28
+	/**
29
+	 * Context slug for the attendee messages context
30
+	 */
31
+	const ATTENDEE_CONTEXT_SLUG = 'attendee';
32 32
 
33 33
 
34
-    /**
35
-     * Status reference for the EEM_Message::status_sent status.
36
-     */
37
-    const MESSAGE_STATUS_SENT = 'MSN';
34
+	/**
35
+	 * Status reference for the EEM_Message::status_sent status.
36
+	 */
37
+	const MESSAGE_STATUS_SENT = 'MSN';
38 38
 
39 39
 
40
-    /**
41
-     * Message type slug for the Payment Failed message type
42
-     */
43
-    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
40
+	/**
41
+	 * Message type slug for the Payment Failed message type
42
+	 */
43
+	const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
44 44
 
45 45
 
46
-    /**
47
-     * Message type slug for the Registration Pending Payment message type
48
-     */
49
-    const MESSAGE_TYPE_PENDING_PAYMENT = 'pending_approval';
46
+	/**
47
+	 * Message type slug for the Registration Pending Payment message type
48
+	 */
49
+	const MESSAGE_TYPE_PENDING_PAYMENT = 'pending_approval';
50 50
 
51 51
 
52
-    /**
53
-     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
54
-     */
55
-    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
56
-        '#global_messages_settings-do-messages-on-same-request';
52
+	/**
53
+	 * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
54
+	 */
55
+	const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
56
+		'#global_messages_settings-do-messages-on-same-request';
57 57
 
58 58
 
59
-    /**
60
-     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
61
-     */
62
-    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
59
+	/**
60
+	 * Selector for the Global Messages Settings submit button in the Messages Settings tab.
61
+	 */
62
+	const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
63 63
 
64 64
 
65
-    /**
66
-     * This is the container where active message types for a messenger are found/dragged to.
67
-     */
68
-    const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
65
+	/**
66
+	 * This is the container where active message types for a messenger are found/dragged to.
67
+	 */
68
+	const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
69 69
 
70 70
 
71
-    /**
72
-     * Locator for the context switcher selector on the Message Template Editor page.
73
-     */
74
-    const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
71
+	/**
72
+	 * Locator for the context switcher selector on the Message Template Editor page.
73
+	 */
74
+	const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
75 75
 
76 76
 
77
-    /**
78
-     * Locator for the context switcher submit button in the Message Template Editor page.
79
-     */
80
-    const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
77
+	/**
78
+	 * Locator for the context switcher submit button in the Message Template Editor page.
79
+	 */
80
+	const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
81 81
 
82 82
 
83
-    /**
84
-     * Locator for the dialog container used for housing viewed messages in the message activity list table.
85
-     */
86
-    const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
87
-
88
-
89
-    /**
90
-     * Returns the selector for the on/off toggle for context on the message template editor.
91
-     */
92
-    const MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE =
93
-        "//div[@class='activate_context_on_off_toggle_container']/div[@class='switch']/label";
94
-
95
-
96
-    const SELECTOR_LINK_FINALIZE_PAYMENT_PENDING_PAYMENT_MESSAGE = "//td/p[@class='callout']/a";
97
-
98
-
99
-
100
-    /**
101
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
102
-     *                                  a string.
103
-     * @return string
104
-     */
105
-    public static function messageActivityListTableUrl($additional_params = '')
106
-    {
107
-        return self::adminUrl('espresso_messages', 'default', $additional_params);
108
-    }
109
-
110
-
111
-    /**
112
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
113
-     *                                  a string.
114
-     * @return string
115
-     */
116
-    public static function defaultMessageTemplateListTableUrl($additional_params = '')
117
-    {
118
-        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
119
-    }
120
-
121
-
122
-    /**
123
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
124
-     *                                  a string.
125
-     * @return string
126
-     */
127
-    public static function customMessageTemplateListTableUrl($additional_params = '')
128
-    {
129
-        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
130
-    }
131
-
132
-
133
-    /**
134
-     * @return string
135
-     */
136
-    public static function messageSettingsUrl()
137
-    {
138
-        return self::adminUrl('espresso_messages', 'settings');
139
-    }
140
-
141
-
142
-
143
-    public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
144
-        $message_type_slug,
145
-        $messenger_slug = 'email'
146
-    ) {
147
-        return "#$message_type_slug-messagetype-$messenger_slug";
148
-    }
149
-
150
-
151
-    /**
152
-     * @param string $message_type_slug
153
-     * @param string $context
154
-     * @return string
155
-     */
156
-    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
157
-    {
158
-        return $context
159
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
160
-            : '.' . $message_type_slug . '-edit-link';
161
-    }
162
-
163
-
164
-    /**
165
-     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
166
-     *
167
-     * @param        $field
168
-     * @param        $message_type_label
169
-     * @param string $message_status
170
-     * @param string $messenger
171
-     * @param string $context
172
-     * @param string $table_cell_content_for_field
173
-     * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
174
-     *                                This allows you to indicate which item from the set to match.  If this is set to 0
175
-     *                                then all matches for the locator will be returned.
176
-     * @return string
177
-     * @throws \InvalidArgumentException
178
-     */
179
-    public static function messagesActivityListTableCellSelectorFor(
180
-        $field,
181
-        $message_type_label,
182
-        $message_status = self::MESSAGE_STATUS_SENT,
183
-        $messenger = 'Email',
184
-        $context = 'Event Admin',
185
-        $table_cell_content_for_field = '',
186
-        $number_in_set = 1
187
-    ) {
188
-        $selector = "//tbody[@id='the-list']";
189
-        $selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
190
-                     . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
191
-        if ($messenger) {
192
-            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
193
-        }
194
-        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
195
-        $selector .= $table_cell_content_for_field
196
-            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
197
-            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
198
-        return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector;
199
-    }
200
-
201
-
202
-    /**
203
-     * Selector for the Create Custom button found in the message template list table.
204
-     * @param string $message_type_label
205
-     * @param string $messenger_label
206
-     * @return string
207
-     */
208
-    public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
209
-    {
210
-        $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
211
-                    . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
212
-                    . "//ancestor::tr/td/a[@class='button button-small']";
213
-        return $selector;
214
-    }
215
-
216
-
217
-    /**
218
-     * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
219
-     * the FIRST match (which will be the latest message sent if the table is default sorted).
220
-     *
221
-     * @param string $message_type_label    The visible message type label for the row you want to match
222
-     * @param string $message_status        The status of the message for the row you want to match.
223
-     * @param string $messenger             The visible messenger label for the row you want to match.
224
-     * @param string $context               The visible context label for the row you want to match.
225
-     * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
226
-     *                                      view. This allows you to indicate which item from the set to match.
227
-     * @return string
228
-     * @throws \InvalidArgumentException
229
-     */
230
-    public static function messagesActivityListTableViewButtonSelectorFor(
231
-        $message_type_label,
232
-        $message_status = self::MESSAGE_STATUS_SENT,
233
-        $messenger = 'Email',
234
-        $context = 'Event Admin',
235
-        $number_in_set = 1
236
-    ) {
237
-        $selector = self::messagesActivityListTableCellSelectorFor(
238
-            'action',
239
-            $message_type_label,
240
-            $message_status,
241
-            $messenger,
242
-            $context,
243
-            '',
244
-            $number_in_set
245
-        );
246
-        $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
247
-                     . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
248
-        return $selector;
249
-    }
250
-
251
-
252
-    /**
253
-     * Locator for the delete action link for a message item in the message activity list table.
254
-     * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
255
-     *
256
-     * @param        $message_type_label
257
-     * @param string $message_status
258
-     * @param string $messenger
259
-     * @param string $context
260
-     * @param int    $number_in_set
261
-     * @return string
262
-     * @throws \InvalidArgumentException
263
-     */
264
-    public static function messagesActivityListTableDeleteActionSelectorFor(
265
-        $message_type_label,
266
-        $message_status = self::MESSAGE_STATUS_SENT,
267
-        $messenger = 'Email',
268
-        $context = 'Event Admin',
269
-        $number_in_set = 1
270
-    ) {
271
-        $selector = self::messagesActivityListTableCellSelectorFor(
272
-            'to',
273
-            $message_type_label,
274
-            $message_status,
275
-            $messenger,
276
-            $context,
277
-            '',
278
-            $number_in_set
279
-        );
280
-        $selector .= "/div/span[@class='delete']/a";
281
-        return $selector;
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * Returns the input selector for a given field in the message template editor.
288
-     * Assumes one is already viewing the Message Template Editor.
289
-     * @param string     $field
290
-     * @return string
291
-     */
292
-    public static function messageInputFieldSelectorFor($field)
293
-    {
294
-        return "//div[@id='post-body']//input[@id='$field-content']";
295
-    }
296
-
297
-
298
-    /**
299
-     * Wrapper for self::messageInputFieldSelectorFor('to') that takes care of getting the input for the To field.
300
-     */
301
-    public static function messageTemplateToFieldSelector()
302
-    {
303
-        return self::messageInputFieldSelectorFor('to');
304
-    }
83
+	/**
84
+	 * Locator for the dialog container used for housing viewed messages in the message activity list table.
85
+	 */
86
+	const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
87
+
88
+
89
+	/**
90
+	 * Returns the selector for the on/off toggle for context on the message template editor.
91
+	 */
92
+	const MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE =
93
+		"//div[@class='activate_context_on_off_toggle_container']/div[@class='switch']/label";
94
+
95
+
96
+	const SELECTOR_LINK_FINALIZE_PAYMENT_PENDING_PAYMENT_MESSAGE = "//td/p[@class='callout']/a";
97
+
98
+
99
+
100
+	/**
101
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
102
+	 *                                  a string.
103
+	 * @return string
104
+	 */
105
+	public static function messageActivityListTableUrl($additional_params = '')
106
+	{
107
+		return self::adminUrl('espresso_messages', 'default', $additional_params);
108
+	}
109
+
110
+
111
+	/**
112
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
113
+	 *                                  a string.
114
+	 * @return string
115
+	 */
116
+	public static function defaultMessageTemplateListTableUrl($additional_params = '')
117
+	{
118
+		return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
124
+	 *                                  a string.
125
+	 * @return string
126
+	 */
127
+	public static function customMessageTemplateListTableUrl($additional_params = '')
128
+	{
129
+		return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
130
+	}
131
+
132
+
133
+	/**
134
+	 * @return string
135
+	 */
136
+	public static function messageSettingsUrl()
137
+	{
138
+		return self::adminUrl('espresso_messages', 'settings');
139
+	}
140
+
141
+
142
+
143
+	public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
144
+		$message_type_slug,
145
+		$messenger_slug = 'email'
146
+	) {
147
+		return "#$message_type_slug-messagetype-$messenger_slug";
148
+	}
149
+
150
+
151
+	/**
152
+	 * @param string $message_type_slug
153
+	 * @param string $context
154
+	 * @return string
155
+	 */
156
+	public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
157
+	{
158
+		return $context
159
+			? '.' . $message_type_slug . '-' . $context . '-edit-link'
160
+			: '.' . $message_type_slug . '-edit-link';
161
+	}
162
+
163
+
164
+	/**
165
+	 * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
166
+	 *
167
+	 * @param        $field
168
+	 * @param        $message_type_label
169
+	 * @param string $message_status
170
+	 * @param string $messenger
171
+	 * @param string $context
172
+	 * @param string $table_cell_content_for_field
173
+	 * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
174
+	 *                                This allows you to indicate which item from the set to match.  If this is set to 0
175
+	 *                                then all matches for the locator will be returned.
176
+	 * @return string
177
+	 * @throws \InvalidArgumentException
178
+	 */
179
+	public static function messagesActivityListTableCellSelectorFor(
180
+		$field,
181
+		$message_type_label,
182
+		$message_status = self::MESSAGE_STATUS_SENT,
183
+		$messenger = 'Email',
184
+		$context = 'Event Admin',
185
+		$table_cell_content_for_field = '',
186
+		$number_in_set = 1
187
+	) {
188
+		$selector = "//tbody[@id='the-list']";
189
+		$selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
190
+					 . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
191
+		if ($messenger) {
192
+			$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
193
+		}
194
+		$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
195
+		$selector .= $table_cell_content_for_field
196
+			? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
197
+			: "/ancestor::tr/td[contains(@class, 'column-$field')]";
198
+		return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector;
199
+	}
200
+
201
+
202
+	/**
203
+	 * Selector for the Create Custom button found in the message template list table.
204
+	 * @param string $message_type_label
205
+	 * @param string $messenger_label
206
+	 * @return string
207
+	 */
208
+	public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
209
+	{
210
+		$selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
211
+					. "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
212
+					. "//ancestor::tr/td/a[@class='button button-small']";
213
+		return $selector;
214
+	}
215
+
216
+
217
+	/**
218
+	 * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
219
+	 * the FIRST match (which will be the latest message sent if the table is default sorted).
220
+	 *
221
+	 * @param string $message_type_label    The visible message type label for the row you want to match
222
+	 * @param string $message_status        The status of the message for the row you want to match.
223
+	 * @param string $messenger             The visible messenger label for the row you want to match.
224
+	 * @param string $context               The visible context label for the row you want to match.
225
+	 * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
226
+	 *                                      view. This allows you to indicate which item from the set to match.
227
+	 * @return string
228
+	 * @throws \InvalidArgumentException
229
+	 */
230
+	public static function messagesActivityListTableViewButtonSelectorFor(
231
+		$message_type_label,
232
+		$message_status = self::MESSAGE_STATUS_SENT,
233
+		$messenger = 'Email',
234
+		$context = 'Event Admin',
235
+		$number_in_set = 1
236
+	) {
237
+		$selector = self::messagesActivityListTableCellSelectorFor(
238
+			'action',
239
+			$message_type_label,
240
+			$message_status,
241
+			$messenger,
242
+			$context,
243
+			'',
244
+			$number_in_set
245
+		);
246
+		$selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
247
+					 . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
248
+		return $selector;
249
+	}
250
+
251
+
252
+	/**
253
+	 * Locator for the delete action link for a message item in the message activity list table.
254
+	 * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
255
+	 *
256
+	 * @param        $message_type_label
257
+	 * @param string $message_status
258
+	 * @param string $messenger
259
+	 * @param string $context
260
+	 * @param int    $number_in_set
261
+	 * @return string
262
+	 * @throws \InvalidArgumentException
263
+	 */
264
+	public static function messagesActivityListTableDeleteActionSelectorFor(
265
+		$message_type_label,
266
+		$message_status = self::MESSAGE_STATUS_SENT,
267
+		$messenger = 'Email',
268
+		$context = 'Event Admin',
269
+		$number_in_set = 1
270
+	) {
271
+		$selector = self::messagesActivityListTableCellSelectorFor(
272
+			'to',
273
+			$message_type_label,
274
+			$message_status,
275
+			$messenger,
276
+			$context,
277
+			'',
278
+			$number_in_set
279
+		);
280
+		$selector .= "/div/span[@class='delete']/a";
281
+		return $selector;
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * Returns the input selector for a given field in the message template editor.
288
+	 * Assumes one is already viewing the Message Template Editor.
289
+	 * @param string     $field
290
+	 * @return string
291
+	 */
292
+	public static function messageInputFieldSelectorFor($field)
293
+	{
294
+		return "//div[@id='post-body']//input[@id='$field-content']";
295
+	}
296
+
297
+
298
+	/**
299
+	 * Wrapper for self::messageInputFieldSelectorFor('to') that takes care of getting the input for the To field.
300
+	 */
301
+	public static function messageTemplateToFieldSelector()
302
+	{
303
+		return self::messageInputFieldSelectorFor('to');
304
+	}
305 305
 }
306 306
\ No newline at end of file
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
      * we know if we need to drop out.
778 778
      *
779 779
      * @access protected
780
-     * @return void
780
+     * @return false|null
781 781
      */
782 782
     protected function _verify_routes()
783 783
     {
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
      * this method simply verifies a given route and makes sure its an actual route available for the loaded page
857 857
      *
858 858
      * @param  string $route the route name we're verifying
859
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
859
+     * @return boolean  (bool|Exception)      we'll throw an exception if this isn't a valid route.
860 860
      */
861 861
     protected function _verify_route($route)
862 862
     {
@@ -3843,7 +3843,7 @@  discard block
 block discarded – undo
3843 3843
 
3844 3844
 
3845 3845
     /**
3846
-     * @return mixed
3846
+     * @return string[]
3847 3847
      */
3848 3848
     public function default_espresso_metaboxes()
3849 3849
     {
@@ -3863,7 +3863,7 @@  discard block
 block discarded – undo
3863 3863
 
3864 3864
 
3865 3865
     /**
3866
-     * @return mixed
3866
+     * @return string
3867 3867
      */
3868 3868
     public function wp_page_slug()
3869 3869
     {
Please login to merge, or discard this patch.
Indentation   +3886 added lines, -3886 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\InterminableInterface;
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * Event Espresso
@@ -30,3975 +30,3975 @@  discard block
 block discarded – undo
30 30
 {
31 31
 
32 32
 
33
-    //set in _init_page_props()
34
-    public $page_slug;
33
+	//set in _init_page_props()
34
+	public $page_slug;
35 35
 
36
-    public $page_label;
36
+	public $page_label;
37 37
 
38
-    public $page_folder;
38
+	public $page_folder;
39 39
 
40
-    //set in define_page_props()
41
-    protected $_admin_base_url;
40
+	//set in define_page_props()
41
+	protected $_admin_base_url;
42 42
 
43
-    protected $_admin_base_path;
43
+	protected $_admin_base_path;
44 44
 
45
-    protected $_admin_page_title;
45
+	protected $_admin_page_title;
46 46
 
47
-    protected $_labels;
47
+	protected $_labels;
48 48
 
49 49
 
50
-    //set early within EE_Admin_Init
51
-    protected $_wp_page_slug;
50
+	//set early within EE_Admin_Init
51
+	protected $_wp_page_slug;
52 52
 
53
-    //navtabs
54
-    protected $_nav_tabs;
53
+	//navtabs
54
+	protected $_nav_tabs;
55 55
 
56
-    protected $_default_nav_tab_name;
56
+	protected $_default_nav_tab_name;
57 57
 
58
-    //helptourstops
59
-    protected $_help_tour = array();
58
+	//helptourstops
59
+	protected $_help_tour = array();
60 60
 
61 61
 
62
-    //template variables (used by templates)
63
-    protected $_template_path;
62
+	//template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = array();
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = array();
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    //bools
80
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79
+	//bools
80
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    //list table args
85
-    protected $_view;
84
+	//list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    //action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	//action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    protected $_page_config;
93
+	protected $_page_config;
94 94
 
95
-    //the current page route and route config
96
-    protected $_route;
95
+	//the current page route and route config
96
+	protected $_route;
97 97
 
98
-    protected $_route_config;
98
+	protected $_route_config;
99 99
 
100
-    /**
101
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
102
-     * actions.
103
-     *
104
-     * @since 4.6.x
105
-     * @var array.
106
-     */
107
-    protected $_default_route_query_args;
100
+	/**
101
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
102
+	 * actions.
103
+	 *
104
+	 * @since 4.6.x
105
+	 * @var array.
106
+	 */
107
+	protected $_default_route_query_args;
108 108
 
109
-    //set via request page and action args.
110
-    protected $_current_page;
109
+	//set via request page and action args.
110
+	protected $_current_page;
111 111
 
112
-    protected $_current_view;
112
+	protected $_current_view;
113 113
 
114
-    protected $_current_page_view_url;
114
+	protected $_current_page_view_url;
115 115
 
116
-    //sanitized request action (and nonce)
116
+	//sanitized request action (and nonce)
117 117
 
118
-    /**
119
-     * @var string $_req_action
120
-     */
121
-    protected $_req_action;
118
+	/**
119
+	 * @var string $_req_action
120
+	 */
121
+	protected $_req_action;
122 122
 
123
-    /**
124
-     * @var string $_req_nonce
125
-     */
126
-    protected $_req_nonce;
123
+	/**
124
+	 * @var string $_req_nonce
125
+	 */
126
+	protected $_req_nonce;
127 127
 
128
-    //search related
129
-    protected $_search_btn_label;
128
+	//search related
129
+	protected $_search_btn_label;
130 130
 
131
-    protected $_search_box_callback;
131
+	protected $_search_box_callback;
132 132
 
133
-    /**
134
-     * WP Current Screen object
135
-     *
136
-     * @var WP_Screen
137
-     */
138
-    protected $_current_screen;
133
+	/**
134
+	 * WP Current Screen object
135
+	 *
136
+	 * @var WP_Screen
137
+	 */
138
+	protected $_current_screen;
139 139
 
140
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
141
-    protected $_hook_obj;
140
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
141
+	protected $_hook_obj;
142 142
 
143
-    //for holding incoming request data
144
-    protected $_req_data;
143
+	//for holding incoming request data
144
+	protected $_req_data;
145 145
 
146
-    // yes / no array for admin form fields
147
-    protected $_yes_no_values = array();
148
-
149
-    //some default things shared by all child classes
150
-    protected $_default_espresso_metaboxes;
151
-
152
-    /**
153
-     *    EE_Registry Object
154
-     *
155
-     * @var    EE_Registry
156
-     * @access    protected
157
-     */
158
-    protected $EE = null;
159
-
160
-
161
-
162
-    /**
163
-     * This is just a property that flags whether the given route is a caffeinated route or not.
164
-     *
165
-     * @var boolean
166
-     */
167
-    protected $_is_caf = false;
168
-
169
-
170
-
171
-    /**
172
-     * @Constructor
173
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
174
-     * @access public
175
-     */
176
-    public function __construct($routing = true)
177
-    {
178
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
179
-            $this->_is_caf = true;
180
-        }
181
-        $this->_yes_no_values = array(
182
-            array('id' => true, 'text' => __('Yes', 'event_espresso')),
183
-            array('id' => false, 'text' => __('No', 'event_espresso')),
184
-        );
185
-        //set the _req_data property.
186
-        $this->_req_data = array_merge($_GET, $_POST);
187
-        //routing enabled?
188
-        $this->_routing = $routing;
189
-        //set initial page props (child method)
190
-        $this->_init_page_props();
191
-        //set global defaults
192
-        $this->_set_defaults();
193
-        //set early because incoming requests could be ajax related and we need to register those hooks.
194
-        $this->_global_ajax_hooks();
195
-        $this->_ajax_hooks();
196
-        //other_page_hooks have to be early too.
197
-        $this->_do_other_page_hooks();
198
-        //This just allows us to have extending classes do something specific
199
-        // before the parent constructor runs _page_setup().
200
-        if (method_exists($this, '_before_page_setup')) {
201
-            $this->_before_page_setup();
202
-        }
203
-        //set up page dependencies
204
-        $this->_page_setup();
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * _init_page_props
211
-     * Child classes use to set at least the following properties:
212
-     * $page_slug.
213
-     * $page_label.
214
-     *
215
-     * @abstract
216
-     * @access protected
217
-     * @return void
218
-     */
219
-    abstract protected function _init_page_props();
220
-
221
-
222
-
223
-    /**
224
-     * _ajax_hooks
225
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
226
-     * Note: within the ajax callback methods.
227
-     *
228
-     * @abstract
229
-     * @access protected
230
-     * @return void
231
-     */
232
-    abstract protected function _ajax_hooks();
233
-
234
-
235
-
236
-    /**
237
-     * _define_page_props
238
-     * child classes define page properties in here.  Must include at least:
239
-     * $_admin_base_url = base_url for all admin pages
240
-     * $_admin_page_title = default admin_page_title for admin pages
241
-     * $_labels = array of default labels for various automatically generated elements:
242
-     *    array(
243
-     *        'buttons' => array(
244
-     *            'add' => __('label for add new button'),
245
-     *            'edit' => __('label for edit button'),
246
-     *            'delete' => __('label for delete button')
247
-     *            )
248
-     *        )
249
-     *
250
-     * @abstract
251
-     * @access protected
252
-     * @return void
253
-     */
254
-    abstract protected function _define_page_props();
255
-
256
-
257
-
258
-    /**
259
-     * _set_page_routes
260
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
261
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
262
-     * have a 'default' route. Here's the format
263
-     * $this->_page_routes = array(
264
-     *        'default' => array(
265
-     *            'func' => '_default_method_handling_route',
266
-     *            'args' => array('array','of','args'),
267
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
268
-     *            ajax request, backend processing)
269
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
270
-     *            headers route after.  The string you enter here should match the defined route reference for a
271
-     *            headers sent route.
272
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
273
-     *            this route.
274
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
275
-     *            checks).
276
-     *        ),
277
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
278
-     *        handling method.
279
-     *        )
280
-     * )
281
-     *
282
-     * @abstract
283
-     * @access protected
284
-     * @return void
285
-     */
286
-    abstract protected function _set_page_routes();
287
-
288
-
289
-
290
-    /**
291
-     * _set_page_config
292
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
293
-     * array corresponds to the page_route for the loaded page. Format:
294
-     * $this->_page_config = array(
295
-     *        'default' => array(
296
-     *            'labels' => array(
297
-     *                'buttons' => array(
298
-     *                    'add' => __('label for adding item'),
299
-     *                    'edit' => __('label for editing item'),
300
-     *                    'delete' => __('label for deleting item')
301
-     *                ),
302
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
303
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
304
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
305
-     *            _define_page_props() method
306
-     *            'nav' => array(
307
-     *                'label' => __('Label for Tab', 'event_espresso').
308
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
309
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
310
-     *                'order' => 10, //required to indicate tab position.
311
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
312
-     *                displayed then add this parameter.
313
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
314
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
315
-     *            metaboxes set for eventespresso admin pages.
316
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
317
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
318
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
319
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
320
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
321
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
322
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
323
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
324
-     *            want to display.
325
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
326
-     *                'tab_id' => array(
327
-     *                    'title' => 'tab_title',
328
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
329
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
330
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
331
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
332
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
333
-     *                    attempt to use the callback which should match the name of a method in the class
334
-     *                    ),
335
-     *                'tab2_id' => array(
336
-     *                    'title' => 'tab2 title',
337
-     *                    'filename' => 'file_name_2'
338
-     *                    'callback' => 'callback_method_for_content',
339
-     *                 ),
340
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
341
-     *            help tab area on an admin page. @link
342
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
343
-     *            'help_tour' => array(
344
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
345
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
346
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
347
-     *            ),
348
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
349
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
350
-     *            just set
351
-     *            'require_nonce' to FALSE
352
-     *            )
353
-     * )
354
-     *
355
-     * @abstract
356
-     * @access protected
357
-     * @return void
358
-     */
359
-    abstract protected function _set_page_config();
360
-
361
-
362
-
363
-
364
-
365
-    /** end sample help_tour methods **/
366
-    /**
367
-     * _add_screen_options
368
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
-     * to a particular view.
371
-     *
372
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
-     *         see also WP_Screen object documents...
374
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
-     * @abstract
376
-     * @access protected
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-
383
-    /**
384
-     * _add_feature_pointers
385
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
386
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
387
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
388
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
389
-     * extended) also see:
390
-     *
391
-     * @link   http://eamann.com/tech/wordpress-portland/
392
-     * @abstract
393
-     * @access protected
394
-     * @return void
395
-     */
396
-    abstract protected function _add_feature_pointers();
397
-
398
-
399
-
400
-    /**
401
-     * load_scripts_styles
402
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
403
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
404
-     * scripts/styles per view by putting them in a dynamic function in this format
405
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
406
-     *
407
-     * @abstract
408
-     * @access public
409
-     * @return void
410
-     */
411
-    abstract public function load_scripts_styles();
412
-
413
-
414
-
415
-    /**
416
-     * admin_init
417
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
418
-     * all pages/views loaded by child class.
419
-     *
420
-     * @abstract
421
-     * @access public
422
-     * @return void
423
-     */
424
-    abstract public function admin_init();
425
-
426
-
427
-
428
-    /**
429
-     * admin_notices
430
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
431
-     * all pages/views loaded by child class.
432
-     *
433
-     * @abstract
434
-     * @access public
435
-     * @return void
436
-     */
437
-    abstract public function admin_notices();
438
-
439
-
440
-
441
-    /**
442
-     * admin_footer_scripts
443
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
-     * will apply to all pages/views loaded by child class.
445
-     *
446
-     * @access public
447
-     * @return void
448
-     */
449
-    abstract public function admin_footer_scripts();
450
-
451
-
452
-
453
-    /**
454
-     * admin_footer
455
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
456
-     * apply to all pages/views loaded by child class.
457
-     *
458
-     * @access  public
459
-     * @return void
460
-     */
461
-    public function admin_footer()
462
-    {
463
-    }
464
-
465
-
466
-
467
-    /**
468
-     * _global_ajax_hooks
469
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
470
-     * Note: within the ajax callback methods.
471
-     *
472
-     * @abstract
473
-     * @access protected
474
-     * @return void
475
-     */
476
-    protected function _global_ajax_hooks()
477
-    {
478
-        //for lazy loading of metabox content
479
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
480
-    }
481
-
482
-
483
-
484
-    public function ajax_metabox_content()
485
-    {
486
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
487
-        $url       = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
488
-        self::cached_rss_display($contentid, $url);
489
-        wp_die();
490
-    }
491
-
492
-
493
-
494
-    /**
495
-     * _page_setup
496
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
497
-     * doesn't match the object.
498
-     *
499
-     * @final
500
-     * @access protected
501
-     * @return void
502
-     */
503
-    final protected function _page_setup()
504
-    {
505
-        //requires?
506
-        //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.
507
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
508
-        //next verify if we need to load anything...
509
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
510
-        $this->page_folder   = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
511
-        global $ee_menu_slugs;
512
-        $ee_menu_slugs = (array)$ee_menu_slugs;
513
-        if ((! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
514
-            return;
515
-        }
516
-        // 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
517
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
518
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1
519
-                ? $this->_req_data['action2'] : $this->_req_data['action'];
520
-        }
521
-        // then set blank or -1 action values to 'default'
522
-        $this->_req_action = isset($this->_req_data['action'])
523
-                             && ! empty($this->_req_data['action'])
524
-                             && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
525
-        //if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
526
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
527
-            ? $this->_req_data['route'] : $this->_req_action;
528
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
529
-        $this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route']
530
-            : $this->_req_action;
531
-        $this->_current_view = $this->_req_action;
532
-        $this->_req_nonce    = $this->_req_action . '_nonce';
533
-        $this->_define_page_props();
534
-        $this->_current_page_view_url = add_query_arg(
535
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
536
-            $this->_admin_base_url
537
-        );
538
-        //default things
539
-        $this->_default_espresso_metaboxes = array(
540
-            '_espresso_news_post_box',
541
-            '_espresso_links_post_box',
542
-            '_espresso_ratings_request',
543
-            '_espresso_sponsors_post_box',
544
-        );
545
-        //set page configs
546
-        $this->_set_page_routes();
547
-        $this->_set_page_config();
548
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
549
-        if (isset($this->_req_data['wp_referer'])) {
550
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
551
-        }
552
-        //for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
553
-        if (method_exists($this, '_extend_page_config')) {
554
-            $this->_extend_page_config();
555
-        }
556
-        //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
557
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
558
-            $this->_extend_page_config_for_cpt();
559
-        }
560
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
561
-        $this->_page_routes = apply_filters(
562
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
563
-            $this->_page_routes,
564
-            $this
565
-        );
566
-        $this->_page_config = apply_filters(
567
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
568
-            $this->_page_config,
569
-            $this
570
-        );
571
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present 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
-    /**
602
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
603
-     *
604
-     * @access private
605
-     * @return void
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__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'),
617
-                    $page
618
-                );
619
-                $error_msg[] = $error_msg[0]
620
-                               . "\r\n"
621
-                               . sprintf(
622
-                                   esc_html__(
623
-                                       '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',
624
-                                       'event_espresso'
625
-                                   ),
626
-                                   $page,
627
-                                   '<br />',
628
-                                   '<strong>' . $classname . '</strong>'
629
-                               );
630
-                throw new EE_Error(implode('||', $error_msg));
631
-            }
632
-            $a = new ReflectionClass($classname);
633
-            //notice we are passing the instance of this class to the hook object.
634
-            $hookobj[] = $a->newInstance($this);
635
-        }
636
-    }
637
-
638
-
639
-
640
-    public function load_page_dependencies()
641
-    {
642
-        try {
643
-            $this->_load_page_dependencies();
644
-        } catch (EE_Error $e) {
645
-            $e->get_error();
646
-        }
647
-    }
648
-
649
-
650
-
651
-    /**
652
-     * load_page_dependencies
653
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
654
-     *
655
-     * @access public
656
-     * @return void
657
-     */
658
-    protected function _load_page_dependencies()
659
-    {
660
-        //let's set the current_screen and screen options to override what WP set
661
-        $this->_current_screen = get_current_screen();
662
-        //load admin_notices - global, page class, and view specific
663
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
664
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
665
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
666
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
667
-        }
668
-        //load network admin_notices - global, page class, and view specific
669
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
670
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
671
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
672
-        }
673
-        //this will save any per_page screen options if they are present
674
-        $this->_set_per_page_screen_options();
675
-        //setup list table properties
676
-        $this->_set_list_table();
677
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
678
-        $this->_add_registered_meta_boxes();
679
-        $this->_add_screen_columns();
680
-        //add screen options - global, page child class, and view specific
681
-        $this->_add_global_screen_options();
682
-        $this->_add_screen_options();
683
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
684
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
685
-        }
686
-        //add help tab(s) and tours- set via page_config and qtips.
687
-        $this->_add_help_tour();
688
-        $this->_add_help_tabs();
689
-        $this->_add_qtips();
690
-        //add feature_pointers - global, page child class, and view specific
691
-        $this->_add_feature_pointers();
692
-        $this->_add_global_feature_pointers();
693
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
694
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
695
-        }
696
-        //enqueue scripts/styles - global, page class, and view specific
697
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
698
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
699
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
700
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
701
-        }
702
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
703
-        //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
704
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
705
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
706
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
707
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
708
-        }
709
-        //admin footer scripts
710
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
711
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
712
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
713
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
714
-        }
715
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
716
-        //targeted hook
717
-        do_action(
718
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action
719
-        );
720
-    }
721
-
722
-
723
-
724
-    /**
725
-     * _set_defaults
726
-     * This sets some global defaults for class properties.
727
-     */
728
-    private function _set_defaults()
729
-    {
730
-        $this->_current_screen      = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
731
-        $this->_nav_tabs            = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
732
-        $this->default_nav_tab_name = 'overview';
733
-        //init template args
734
-        $this->_template_args = array(
735
-            'admin_page_header'  => '',
736
-            'admin_page_content' => '',
737
-            'post_body_content'  => '',
738
-            'before_list_table'  => '',
739
-            'after_list_table'   => '',
740
-        );
741
-    }
742
-
743
-
744
-
745
-    /**
746
-     * route_admin_request
747
-     *
748
-     * @see    _route_admin_request()
749
-     * @access public
750
-     * @return void|exception error
751
-     */
752
-    public function route_admin_request()
753
-    {
754
-        try {
755
-            $this->_route_admin_request();
756
-        } catch (EE_Error $e) {
757
-            $e->get_error();
758
-        }
759
-    }
760
-
761
-
762
-
763
-    public function set_wp_page_slug($wp_page_slug)
764
-    {
765
-        $this->_wp_page_slug = $wp_page_slug;
766
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
767
-        if (is_network_admin()) {
768
-            $this->_wp_page_slug .= '-network';
769
-        }
770
-    }
771
-
772
-
773
-
774
-    /**
775
-     * _verify_routes
776
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
777
-     * we know if we need to drop out.
778
-     *
779
-     * @access protected
780
-     * @return void
781
-     */
782
-    protected function _verify_routes()
783
-    {
784
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
785
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
786
-            return false;
787
-        }
788
-        $this->_route = false;
789
-        $func         = false;
790
-        $args         = array();
791
-        // check that the page_routes array is not empty
792
-        if (empty($this->_page_routes)) {
793
-            // user error msg
794
-            $error_msg = sprintf(
795
-                __('No page routes have been set for the %s admin page.', 'event_espresso'),
796
-                $this->_admin_page_title
797
-            );
798
-            // developer error msg
799
-            $error_msg .= '||' . $error_msg . __(
800
-                    ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
801
-                    'event_espresso'
802
-                );
803
-            throw new EE_Error($error_msg);
804
-        }
805
-        // and that the requested page route exists
806
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
807
-            $this->_route        = $this->_page_routes[$this->_req_action];
808
-            $this->_route_config = isset($this->_page_config[$this->_req_action])
809
-                ? $this->_page_config[$this->_req_action] : array();
810
-        } else {
811
-            // user error msg
812
-            $error_msg = sprintf(
813
-                __('The requested page route does not exist for the %s admin page.', 'event_espresso'),
814
-                $this->_admin_page_title
815
-            );
816
-            // developer error msg
817
-            $error_msg .= '||' . $error_msg . sprintf(
818
-                    __(
819
-                        ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
820
-                        'event_espresso'
821
-                    ),
822
-                    $this->_req_action
823
-                );
824
-            throw new EE_Error($error_msg);
825
-        }
826
-        // and that a default route exists
827
-        if (! array_key_exists('default', $this->_page_routes)) {
828
-            // user error msg
829
-            $error_msg = sprintf(
830
-                __('A default page route has not been set for the % admin page.', 'event_espresso'),
831
-                $this->_admin_page_title
832
-            );
833
-            // developer error msg
834
-            $error_msg .= '||' . $error_msg . __(
835
-                    ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
836
-                    'event_espresso'
837
-                );
838
-            throw new EE_Error($error_msg);
839
-        }
840
-        //first lets' catch if the UI request has EVER been set.
841
-        if ($this->_is_UI_request === null) {
842
-            //lets set if this is a UI request or not.
843
-            $this->_is_UI_request = (! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
844
-                ? true : false;
845
-            //wait a minute... we might have a noheader in the route array
846
-            $this->_is_UI_request = is_array($this->_route)
847
-                                    && isset($this->_route['noheader'])
848
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
849
-        }
850
-        $this->_set_current_labels();
851
-    }
852
-
853
-
854
-
855
-    /**
856
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
857
-     *
858
-     * @param  string $route the route name we're verifying
859
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
860
-     */
861
-    protected function _verify_route($route)
862
-    {
863
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
864
-            return true;
865
-        } else {
866
-            // user error msg
867
-            $error_msg = sprintf(
868
-                __('The given page route does not exist for the %s admin page.', 'event_espresso'),
869
-                $this->_admin_page_title
870
-            );
871
-            // developer error msg
872
-            $error_msg .= '||' . $error_msg . sprintf(
873
-                    __(
874
-                        ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
875
-                        'event_espresso'
876
-                    ),
877
-                    $route
878
-                );
879
-            throw new EE_Error($error_msg);
880
-        }
881
-    }
882
-
883
-
884
-
885
-    /**
886
-     * perform nonce verification
887
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
888
-     * using this method (and save retyping!)
889
-     *
890
-     * @param  string $nonce     The nonce sent
891
-     * @param  string $nonce_ref The nonce reference string (name0)
892
-     * @return mixed (bool|die)
893
-     */
894
-    protected function _verify_nonce($nonce, $nonce_ref)
895
-    {
896
-        // verify nonce against expected value
897
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
898
-            // these are not the droids you are looking for !!!
899
-            $msg = sprintf(
900
-                __('%sNonce Fail.%s', 'event_espresso'),
901
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
902
-                '</a>'
903
-            );
904
-            if (WP_DEBUG) {
905
-                $msg .= "\n  " . sprintf(
906
-                        __(
907
-                            'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
908
-                            'event_espresso'
909
-                        ),
910
-                        __CLASS__
911
-                    );
912
-            }
913
-            if (! defined('DOING_AJAX')) {
914
-                wp_die($msg);
915
-            } else {
916
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
917
-                $this->_return_json();
918
-            }
919
-        }
920
-    }
921
-
922
-
923
-
924
-    /**
925
-     * _route_admin_request()
926
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
927
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
928
-     * in the page routes and then will try to load the corresponding method.
929
-     *
930
-     * @access protected
931
-     * @return void
932
-     * @throws \EE_Error
933
-     */
934
-    protected function _route_admin_request()
935
-    {
936
-        if (! $this->_is_UI_request) {
937
-            $this->_verify_routes();
938
-        }
939
-        $nonce_check = isset($this->_route_config['require_nonce'])
940
-            ? $this->_route_config['require_nonce']
941
-            : true;
942
-        if ($this->_req_action !== 'default' && $nonce_check) {
943
-            // set nonce from post data
944
-            $nonce = isset($this->_req_data[$this->_req_nonce])
945
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
946
-                : '';
947
-            $this->_verify_nonce($nonce, $this->_req_nonce);
948
-        }
949
-        //set the nav_tabs array but ONLY if this is  UI_request
950
-        if ($this->_is_UI_request) {
951
-            $this->_set_nav_tabs();
952
-        }
953
-        // grab callback function
954
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
955
-        // check if callback has args
956
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
957
-        $error_msg = '';
958
-        // action right before calling route
959
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
960
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
961
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
962
-        }
963
-        // right before calling the route, let's remove _wp_http_referer from the
964
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
965
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
966
-        if (! empty($func)) {
967
-            if (is_array($func)) {
968
-                list($class, $method) = $func;
969
-            } elseif (strpos($func, '::') !== false) {
970
-                list($class, $method) = explode('::', $func);
971
-            } else {
972
-                $class  = $this;
973
-                $method = $func;
974
-            }
975
-            if (! (is_object($class) && $class === $this)) {
976
-                // send along this admin page object for access by addons.
977
-                $args['admin_page_object'] = $this;
978
-            }
979
-            if (
980
-                //is it a method on a class that doesn't work?
981
-                (
982
-                    (
983
-                        method_exists($class, $method)
984
-                        && call_user_func_array(array($class, $method), $args) === false
985
-                    )
986
-                    && (
987
-                        //is it a standalone function that doesn't work?
988
-                        function_exists($method)
989
-                        && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args))
990
-                           === false
991
-                    )
992
-                )
993
-                || (
994
-                    //is it neither a class method NOR a standalone function?
995
-                    ! method_exists($class, $method)
996
-                    && ! function_exists($method)
997
-                )
998
-            ) {
999
-                // user error msg
1000
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
1001
-                // developer error msg
1002
-                $error_msg .= '||';
1003
-                $error_msg .= sprintf(
1004
-                    __(
1005
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1006
-                        'event_espresso'
1007
-                    ),
1008
-                    $method
1009
-                );
1010
-            }
1011
-            if (! empty($error_msg)) {
1012
-                throw new EE_Error($error_msg);
1013
-            }
1014
-        }
1015
-        //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
1016
-        //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.
1017
-        if ($this->_is_UI_request === false
1018
-            && is_array($this->_route)
1019
-            && ! empty($this->_route['headers_sent_route'])
1020
-        ) {
1021
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1022
-        }
1023
-    }
1024
-
1025
-
1026
-
1027
-    /**
1028
-     * This method just allows the resetting of page properties in the case where a no headers
1029
-     * route redirects to a headers route in its route config.
1030
-     *
1031
-     * @since   4.3.0
1032
-     * @param  string $new_route New (non header) route to redirect to.
1033
-     * @return   void
1034
-     */
1035
-    protected function _reset_routing_properties($new_route)
1036
-    {
1037
-        $this->_is_UI_request = true;
1038
-        //now we set the current route to whatever the headers_sent_route is set at
1039
-        $this->_req_data['action'] = $new_route;
1040
-        //rerun page setup
1041
-        $this->_page_setup();
1042
-    }
1043
-
1044
-
1045
-
1046
-    /**
1047
-     * _add_query_arg
1048
-     * adds nonce to array of arguments then calls WP add_query_arg function
1049
-     *(internally just uses EEH_URL's function with the same name)
1050
-     *
1051
-     * @access public
1052
-     * @param array  $args
1053
-     * @param string $url
1054
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1055
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1056
-     *                                        Example usage: If the current page is:
1057
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1058
-     *                                        &action=default&event_id=20&month_range=March%202015
1059
-     *                                        &_wpnonce=5467821
1060
-     *                                        and you call:
1061
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1062
-     *                                        array(
1063
-     *                                        'action' => 'resend_something',
1064
-     *                                        'page=>espresso_registrations'
1065
-     *                                        ),
1066
-     *                                        $some_url,
1067
-     *                                        true
1068
-     *                                        );
1069
-     *                                        It will produce a url in this structure:
1070
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1071
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1072
-     *                                        month_range]=March%202015
1073
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1074
-     * @return string
1075
-     */
1076
-    public static function add_query_args_and_nonce(
1077
-        $args = array(),
1078
-        $url = false,
1079
-        $sticky = false,
1080
-        $exclude_nonce = false
1081
-    ) {
1082
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
1083
-        if ($sticky) {
1084
-            $request = $_REQUEST;
1085
-            unset($request['_wp_http_referer']);
1086
-            unset($request['wp_referer']);
1087
-            foreach ($request as $key => $value) {
1088
-                //do not add nonces
1089
-                if (strpos($key, 'nonce') !== false) {
1090
-                    continue;
1091
-                }
1092
-                $args['wp_referer[' . $key . ']'] = $value;
1093
-            }
1094
-        }
1095
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1096
-    }
1097
-
1098
-
1099
-
1100
-    /**
1101
-     * This returns a generated link that will load the related help tab.
1102
-     *
1103
-     * @param  string $help_tab_id the id for the connected help tab
1104
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1105
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1106
-     * @uses EEH_Template::get_help_tab_link()
1107
-     * @return string              generated link
1108
-     */
1109
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
1110
-    {
1111
-        return EEH_Template::get_help_tab_link(
1112
-            $help_tab_id,
1113
-            $this->page_slug,
1114
-            $this->_req_action,
1115
-            $icon_style,
1116
-            $help_text
1117
-        );
1118
-    }
1119
-
1120
-
1121
-
1122
-    /**
1123
-     * _add_help_tabs
1124
-     * Note child classes define their help tabs within the page_config array.
1125
-     *
1126
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1127
-     * @access protected
1128
-     * @return void
1129
-     */
1130
-    protected function _add_help_tabs()
1131
-    {
1132
-        $tour_buttons = '';
1133
-        if (isset($this->_page_config[$this->_req_action])) {
1134
-            $config = $this->_page_config[$this->_req_action];
1135
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1136
-            if (isset($this->_help_tour[$this->_req_action])) {
1137
-                $tb           = array();
1138
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1139
-                foreach ($this->_help_tour['tours'] as $tour) {
1140
-                    //if this is the end tour then we don't need to setup a button
1141
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1142
-                        continue;
1143
-                    }
1144
-                    $tb[] = '<button id="trigger-tour-'
1145
-                            . $tour->get_slug()
1146
-                            . '" class="button-primary trigger-ee-help-tour">'
1147
-                            . $tour->get_label()
1148
-                            . '</button>';
1149
-                }
1150
-                $tour_buttons .= implode('<br />', $tb);
1151
-                $tour_buttons .= '</div></div>';
1152
-            }
1153
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1154
-            if (is_array($config) && isset($config['help_sidebar'])) {
1155
-                //check that the callback given is valid
1156
-                if (! method_exists($this, $config['help_sidebar'])) {
1157
-                    throw new EE_Error(
1158
-                        sprintf(
1159
-                            __(
1160
-                                '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',
1161
-                                'event_espresso'
1162
-                            ),
1163
-                            $config['help_sidebar'],
1164
-                            get_class($this)
1165
-                        )
1166
-                    );
1167
-                }
1168
-                $content = apply_filters(
1169
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1170
-                    call_user_func(array($this, $config['help_sidebar']))
1171
-                );
1172
-                $content .= $tour_buttons; //add help tour buttons.
1173
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1174
-                $this->_current_screen->set_help_sidebar($content);
1175
-            }
1176
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1177
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1178
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1179
-            }
1180
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1181
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1182
-                $_ht['id']      = $this->page_slug;
1183
-                $_ht['title']   = __('Help Tours', 'event_espresso');
1184
-                $_ht['content'] = '<p>' . __(
1185
-                        'The buttons to the right allow you to start/restart any help tours available for this page',
1186
-                        'event_espresso'
1187
-                    ) . '</p>';
1188
-                $this->_current_screen->add_help_tab($_ht);
1189
-            }/**/
1190
-            if (! isset($config['help_tabs'])) {
1191
-                return;
1192
-            } //no help tabs for this route
1193
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1194
-                //we're here so there ARE help tabs!
1195
-                //make sure we've got what we need
1196
-                if (! isset($cfg['title'])) {
1197
-                    throw new EE_Error(
1198
-                        __(
1199
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1200
-                            'event_espresso'
1201
-                        )
1202
-                    );
1203
-                }
1204
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1205
-                    throw new EE_Error(
1206
-                        __(
1207
-                            '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',
1208
-                            'event_espresso'
1209
-                        )
1210
-                    );
1211
-                }
1212
-                //first priority goes to content.
1213
-                if (! empty($cfg['content'])) {
1214
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1215
-                    //second priority goes to filename
1216
-                } elseif (! empty($cfg['filename'])) {
1217
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1218
-                    //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)
1219
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1220
-                                                             . basename($this->_get_dir())
1221
-                                                             . '/help_tabs/'
1222
-                                                             . $cfg['filename']
1223
-                                                             . '.help_tab.php' : $file_path;
1224
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1225
-                    if (! is_readable($file_path) && ! isset($cfg['callback'])) {
1226
-                        EE_Error::add_error(
1227
-                            sprintf(
1228
-                                __(
1229
-                                    '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',
1230
-                                    'event_espresso'
1231
-                                ),
1232
-                                $tab_id,
1233
-                                key($config),
1234
-                                $file_path
1235
-                            ),
1236
-                            __FILE__,
1237
-                            __FUNCTION__,
1238
-                            __LINE__
1239
-                        );
1240
-                        return;
1241
-                    }
1242
-                    $template_args['admin_page_obj'] = $this;
1243
-                    $content                         = EEH_Template::display_template($file_path, $template_args, true);
1244
-                } else {
1245
-                    $content = '';
1246
-                }
1247
-                //check if callback is valid
1248
-                if (empty($content) && (! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1249
-                    EE_Error::add_error(
1250
-                        sprintf(
1251
-                            __(
1252
-                                '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.',
1253
-                                'event_espresso'
1254
-                            ),
1255
-                            $cfg['title']
1256
-                        ),
1257
-                        __FILE__,
1258
-                        __FUNCTION__,
1259
-                        __LINE__
1260
-                    );
1261
-                    return;
1262
-                }
1263
-                //setup config array for help tab method
1264
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1265
-                $_ht = array(
1266
-                    'id'       => $id,
1267
-                    'title'    => $cfg['title'],
1268
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1269
-                    'content'  => $content,
1270
-                );
1271
-                $this->_current_screen->add_help_tab($_ht);
1272
-            }
1273
-        }
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1280
-     * an array with properties for setting up usage of the joyride plugin
1281
-     *
1282
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1283
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1284
-     *         _set_page_config() comments
1285
-     * @access protected
1286
-     * @return void
1287
-     */
1288
-    protected function _add_help_tour()
1289
-    {
1290
-        $tours            = array();
1291
-        $this->_help_tour = array();
1292
-        //exit early if help tours are turned off globally
1293
-        if (! EE_Registry::instance()->CFG->admin->help_tour_activation
1294
-            || (defined('EE_DISABLE_HELP_TOURS')
1295
-                && EE_DISABLE_HELP_TOURS)) {
1296
-            return;
1297
-        }
1298
-        //loop through _page_config to find any help_tour defined
1299
-        foreach ($this->_page_config as $route => $config) {
1300
-            //we're only going to set things up for this route
1301
-            if ($route !== $this->_req_action) {
1302
-                continue;
1303
-            }
1304
-            if (isset($config['help_tour'])) {
1305
-                foreach ($config['help_tour'] as $tour) {
1306
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1307
-                    //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1308
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1309
-                                                             . basename($this->_get_dir())
1310
-                                                             . '/help_tours/'
1311
-                                                             . $tour
1312
-                                                             . '.class.php' : $file_path;
1313
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1314
-                    if (! is_readable($file_path)) {
1315
-                        EE_Error::add_error(
1316
-                            sprintf(
1317
-                                __(
1318
-                                    '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',
1319
-                                    'event_espresso'
1320
-                                ),
1321
-                                $file_path,
1322
-                                $tour
1323
-                            ),
1324
-                            __FILE__,
1325
-                            __FUNCTION__,
1326
-                            __LINE__
1327
-                        );
1328
-                        return;
1329
-                    }
1330
-                    require_once $file_path;
1331
-                    if (! class_exists($tour)) {
1332
-                        $error_msg[] = sprintf(
1333
-                            __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1334
-                            $tour
1335
-                        );
1336
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1337
-                                __(
1338
-                                    '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.',
1339
-                                    'event_espresso'
1340
-                                ),
1341
-                                $tour,
1342
-                                '<br />',
1343
-                                $tour,
1344
-                                $this->_req_action,
1345
-                                get_class($this)
1346
-                            );
1347
-                        throw new EE_Error(implode('||', $error_msg));
1348
-                    }
1349
-                    $a                          = new ReflectionClass($tour);
1350
-                    $tour_obj                   = $a->newInstance($this->_is_caf);
1351
-                    $tours[]                    = $tour_obj;
1352
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1353
-                }
1354
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1355
-                $end_stop_tour              = new EE_Help_Tour_final_stop($this->_is_caf);
1356
-                $tours[]                    = $end_stop_tour;
1357
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1358
-            }
1359
-        }
1360
-        if (! empty($tours)) {
1361
-            $this->_help_tour['tours'] = $tours;
1362
-        }
1363
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1364
-    }
1365
-
1366
-
1367
-
1368
-    /**
1369
-     * This simply sets up any qtips that have been defined in the page config
1370
-     *
1371
-     * @access protected
1372
-     * @return void
1373
-     */
1374
-    protected function _add_qtips()
1375
-    {
1376
-        if (isset($this->_route_config['qtips'])) {
1377
-            $qtips = (array)$this->_route_config['qtips'];
1378
-            //load qtip loader
1379
-            $path = array(
1380
-                $this->_get_dir() . '/qtips/',
1381
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1382
-            );
1383
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1384
-        }
1385
-    }
1386
-
1387
-
1388
-
1389
-    /**
1390
-     * _set_nav_tabs
1391
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1392
-     * wish to add additional tabs or modify accordingly.
1393
-     *
1394
-     * @access protected
1395
-     * @return void
1396
-     */
1397
-    protected function _set_nav_tabs()
1398
-    {
1399
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1400
-        $i = 0;
1401
-        foreach ($this->_page_config as $slug => $config) {
1402
-            if (! is_array($config)
1403
-                || (is_array($config)
1404
-                    && (isset($config['nav']) && ! $config['nav'])
1405
-                    || ! isset($config['nav']))) {
1406
-                continue;
1407
-            } //no nav tab for this config
1408
-            //check for persistent flag
1409
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1410
-                continue;
1411
-            } //nav tab is only to appear when route requested.
1412
-            if (! $this->check_user_access($slug, true)) {
1413
-                continue;
1414
-            } //no nav tab becasue current user does not have access.
1415
-            $css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1416
-            $this->_nav_tabs[$slug] = array(
1417
-                'url'       => isset($config['nav']['url'])
1418
-                    ? $config['nav']['url']
1419
-                    : self::add_query_args_and_nonce(
1420
-                        array('action' => $slug),
1421
-                        $this->_admin_base_url
1422
-                    ),
1423
-                'link_text' => isset($config['nav']['label'])
1424
-                    ? $config['nav']['label']
1425
-                    : ucwords(
1426
-                        str_replace('_', ' ', $slug)
1427
-                    ),
1428
-                'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1429
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1430
-            );
1431
-            $i++;
1432
-        }
1433
-        //if $this->_nav_tabs is empty then lets set the default
1434
-        if (empty($this->_nav_tabs)) {
1435
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1436
-                'url'       => $this->admin_base_url,
1437
-                'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1438
-                'css_class' => 'nav-tab-active',
1439
-                'order'     => 10,
1440
-            );
1441
-        }
1442
-        //now let's sort the tabs according to order
1443
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1444
-    }
1445
-
1446
-
1447
-
1448
-    /**
1449
-     * _set_current_labels
1450
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1451
-     * property array
1452
-     *
1453
-     * @access private
1454
-     * @return void
1455
-     */
1456
-    private function _set_current_labels()
1457
-    {
1458
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1459
-            foreach ($this->_route_config['labels'] as $label => $text) {
1460
-                if (is_array($text)) {
1461
-                    foreach ($text as $sublabel => $subtext) {
1462
-                        $this->_labels[$label][$sublabel] = $subtext;
1463
-                    }
1464
-                } else {
1465
-                    $this->_labels[$label] = $text;
1466
-                }
1467
-            }
1468
-        }
1469
-    }
1470
-
1471
-
1472
-
1473
-    /**
1474
-     *        verifies user access for this admin page
1475
-     *
1476
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1477
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1478
-     *                               return false if verify fail.
1479
-     * @return        BOOL|wp_die()
1480
-     */
1481
-    public function check_user_access($route_to_check = '', $verify_only = false)
1482
-    {
1483
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1484
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1485
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1486
-                          && is_array(
1487
-                              $this->_page_routes[$route_to_check]
1488
-                          )
1489
-                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1490
-            ? $this->_page_routes[$route_to_check]['capability'] : null;
1491
-        if (empty($capability) && empty($route_to_check)) {
1492
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1493
-                : $this->_route['capability'];
1494
-        } else {
1495
-            $capability = empty($capability) ? 'manage_options' : $capability;
1496
-        }
1497
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1498
-        if ((! function_exists('is_admin')
1499
-             || ! EE_Registry::instance()->CAP->current_user_can(
1500
-                    $capability,
1501
-                    $this->page_slug
1502
-                    . '_'
1503
-                    . $route_to_check,
1504
-                    $id
1505
-                ))
1506
-            && ! defined('DOING_AJAX')) {
1507
-            if ($verify_only) {
1508
-                return false;
1509
-            } else {
1510
-                if (is_user_logged_in()) {
1511
-                    wp_die(__('You do not have access to this route.', 'event_espresso'));
1512
-                } else {
1513
-                    return false;
1514
-                }
1515
-            }
1516
-        }
1517
-        return true;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * admin_init_global
1524
-     * This runs all the code that we want executed within the WP admin_init hook.
1525
-     * This method executes for ALL EE Admin pages.
1526
-     *
1527
-     * @access public
1528
-     * @return void
1529
-     */
1530
-    public function admin_init_global()
1531
-    {
1532
-    }
1533
-
1534
-
1535
-
1536
-    /**
1537
-     * wp_loaded_global
1538
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1539
-     * EE_Admin page and will execute on every EE Admin Page load
1540
-     *
1541
-     * @access public
1542
-     * @return void
1543
-     */
1544
-    public function wp_loaded()
1545
-    {
1546
-    }
1547
-
1548
-
1549
-
1550
-    /**
1551
-     * admin_notices
1552
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1553
-     * ALL EE_Admin pages.
1554
-     *
1555
-     * @access public
1556
-     * @return void
1557
-     */
1558
-    public function admin_notices_global()
1559
-    {
1560
-        $this->_display_no_javascript_warning();
1561
-        $this->_display_espresso_notices();
1562
-    }
1563
-
1564
-
1565
-
1566
-    public function network_admin_notices_global()
1567
-    {
1568
-        $this->_display_no_javascript_warning();
1569
-        $this->_display_espresso_notices();
1570
-    }
1571
-
1572
-
1573
-
1574
-    /**
1575
-     * admin_footer_scripts_global
1576
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1577
-     * will apply on ALL EE_Admin pages.
1578
-     *
1579
-     * @access public
1580
-     * @return void
1581
-     */
1582
-    public function admin_footer_scripts_global()
1583
-    {
1584
-        $this->_add_admin_page_ajax_loading_img();
1585
-        $this->_add_admin_page_overlay();
1586
-        //if metaboxes are present we need to add the nonce field
1587
-        if ((isset($this->_route_config['metaboxes'])
1588
-             || (isset($this->_route_config['has_metaboxes'])
1589
-                 && $this->_route_config['has_metaboxes'])
1590
-             || isset($this->_route_config['list_table']))) {
1591
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1592
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1593
-        }
1594
-    }
1595
-
1596
-
1597
-
1598
-    /**
1599
-     * admin_footer_global
1600
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on
1601
-     * ALL EE_Admin Pages.
1602
-     *
1603
-     * @access  public
1604
-     * @return  void
1605
-     */
1606
-    public function admin_footer_global()
1607
-    {
1608
-        //dialog container for dialog helper
1609
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1610
-        $d_cont .= '<div class="ee-notices"></div>';
1611
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1612
-        $d_cont .= '</div>';
1613
-        echo $d_cont;
1614
-        //help tour stuff?
1615
-        if (isset($this->_help_tour[$this->_req_action])) {
1616
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1617
-        }
1618
-        //current set timezone for timezone js
1619
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1620
-    }
1621
-
1622
-
1623
-
1624
-    /**
1625
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1626
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1627
-     * help popups then in your templates or your content you set "triggers" for the content using the
1628
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1629
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1630
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1631
-     * for the
1632
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1633
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1634
-     *    'help_trigger_id' => array(
1635
-     *        'title' => __('localized title for popup', 'event_espresso'),
1636
-     *        'content' => __('localized content for popup', 'event_espresso')
1637
-     *    )
1638
-     * );
1639
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1640
-     *
1641
-     * @access protected
1642
-     * @return string content
1643
-     */
1644
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1645
-    {
1646
-        $content       = '';
1647
-        $help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1648
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1649
-        //loop through the array and setup content
1650
-        foreach ($help_array as $trigger => $help) {
1651
-            //make sure the array is setup properly
1652
-            if (! isset($help['title']) || ! isset($help['content'])) {
1653
-                throw new EE_Error(
1654
-                    __(
1655
-                        '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',
1656
-                        'event_espresso'
1657
-                    )
1658
-                );
1659
-            }
1660
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1661
-            $template_args = array(
1662
-                'help_popup_id'      => $trigger,
1663
-                'help_popup_title'   => $help['title'],
1664
-                'help_popup_content' => $help['content'],
1665
-            );
1666
-            $content       .= EEH_Template::display_template($template_path, $template_args, true);
1667
-        }
1668
-        if ($display) {
1669
-            echo $content;
1670
-        } else {
1671
-            return $content;
1672
-        }
1673
-    }
1674
-
1675
-
1676
-
1677
-    /**
1678
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1679
-     *
1680
-     * @access private
1681
-     * @return array properly formatted array for help popup content
1682
-     */
1683
-    private function _get_help_content()
1684
-    {
1685
-        //what is the method we're looking for?
1686
-        $method_name = '_help_popup_content_' . $this->_req_action;
1687
-        //if method doesn't exist let's get out.
1688
-        if (! method_exists($this, $method_name)) {
1689
-            return array();
1690
-        }
1691
-        //k we're good to go let's retrieve the help array
1692
-        $help_array = call_user_func(array($this, $method_name));
1693
-        //make sure we've got an array!
1694
-        if (! is_array($help_array)) {
1695
-            throw new EE_Error(
1696
-                __(
1697
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1698
-                    'event_espresso'
1699
-                )
1700
-            );
1701
-        }
1702
-        return $help_array;
1703
-    }
1704
-
1705
-
1706
-
1707
-    /**
1708
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1709
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1710
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1711
-     *
1712
-     * @access protected
1713
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1714
-     * @param boolean $display    if false then we return the trigger string
1715
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1716
-     * @return string
1717
-     */
1718
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1719
-    {
1720
-        if (defined('DOING_AJAX')) {
1721
-            return;
1722
-        }
1723
-        //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
1724
-        $help_array   = $this->_get_help_content();
1725
-        $help_content = '';
1726
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1727
-            $help_array[$trigger_id] = array(
1728
-                'title'   => __('Missing Content', 'event_espresso'),
1729
-                'content' => __(
1730
-                    '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.)',
1731
-                    'event_espresso'
1732
-                ),
1733
-            );
1734
-            $help_content            = $this->_set_help_popup_content($help_array, false);
1735
-        }
1736
-        //let's setup the trigger
1737
-        $content = '<a class="ee-dialog" href="?height='
1738
-                   . $dimensions[0]
1739
-                   . '&width='
1740
-                   . $dimensions[1]
1741
-                   . '&inlineId='
1742
-                   . $trigger_id
1743
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1744
-        $content = $content . $help_content;
1745
-        if ($display) {
1746
-            echo $content;
1747
-        } else {
1748
-            return $content;
1749
-        }
1750
-    }
1751
-
1752
-
1753
-
1754
-    /**
1755
-     * _add_global_screen_options
1756
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1757
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1758
-     *
1759
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1760
-     *         see also WP_Screen object documents...
1761
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1762
-     * @abstract
1763
-     * @access private
1764
-     * @return void
1765
-     */
1766
-    private function _add_global_screen_options()
1767
-    {
1768
-    }
1769
-
1770
-
1771
-
1772
-    /**
1773
-     * _add_global_feature_pointers
1774
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1775
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1776
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1777
-     *
1778
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1779
-     *         extended) also see:
1780
-     * @link   http://eamann.com/tech/wordpress-portland/
1781
-     * @abstract
1782
-     * @access protected
1783
-     * @return void
1784
-     */
1785
-    private function _add_global_feature_pointers()
1786
-    {
1787
-    }
1788
-
1789
-
1790
-
1791
-    /**
1792
-     * load_global_scripts_styles
1793
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1794
-     *
1795
-     * @return void
1796
-     */
1797
-    public function load_global_scripts_styles()
1798
-    {
1799
-        /** STYLES **/
1800
-        // add debugging styles
1801
-        if (WP_DEBUG) {
1802
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1803
-        }
1804
-        // register all styles
1805
-        wp_register_style(
1806
-            'espresso-ui-theme',
1807
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1808
-            array(),
1809
-            EVENT_ESPRESSO_VERSION
1810
-        );
1811
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1812
-        //helpers styles
1813
-        wp_register_style(
1814
-            'ee-text-links',
1815
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1816
-            array(),
1817
-            EVENT_ESPRESSO_VERSION
1818
-        );
1819
-        /** SCRIPTS **/
1820
-        //register all scripts
1821
-        wp_register_script(
1822
-            'ee-dialog',
1823
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1824
-            array('jquery', 'jquery-ui-draggable'),
1825
-            EVENT_ESPRESSO_VERSION,
1826
-            true
1827
-        );
1828
-        wp_register_script(
1829
-            'ee_admin_js',
1830
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1831
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1832
-            EVENT_ESPRESSO_VERSION,
1833
-            true
1834
-        );
1835
-        wp_register_script(
1836
-            'jquery-ui-timepicker-addon',
1837
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1838
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1839
-            EVENT_ESPRESSO_VERSION,
1840
-            true
1841
-        );
1842
-        add_filter('FHEE_load_joyride', '__return_true');
1843
-        //script for sorting tables
1844
-        wp_register_script(
1845
-            'espresso_ajax_table_sorting',
1846
-            EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js",
1847
-            array('ee_admin_js', 'jquery-ui-sortable'),
1848
-            EVENT_ESPRESSO_VERSION,
1849
-            true
1850
-        );
1851
-        //script for parsing uri's
1852
-        wp_register_script(
1853
-            'ee-parse-uri',
1854
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1855
-            array(),
1856
-            EVENT_ESPRESSO_VERSION,
1857
-            true
1858
-        );
1859
-        //and parsing associative serialized form elements
1860
-        wp_register_script(
1861
-            'ee-serialize-full-array',
1862
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1863
-            array('jquery'),
1864
-            EVENT_ESPRESSO_VERSION,
1865
-            true
1866
-        );
1867
-        //helpers scripts
1868
-        wp_register_script(
1869
-            'ee-text-links',
1870
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1871
-            array('jquery'),
1872
-            EVENT_ESPRESSO_VERSION,
1873
-            true
1874
-        );
1875
-        wp_register_script(
1876
-            'ee-moment-core',
1877
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1878
-            array(),
1879
-            EVENT_ESPRESSO_VERSION,
1880
-            true
1881
-        );
1882
-        wp_register_script(
1883
-            'ee-moment',
1884
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1885
-            array('ee-moment-core'),
1886
-            EVENT_ESPRESSO_VERSION,
1887
-            true
1888
-        );
1889
-        wp_register_script(
1890
-            'ee-datepicker',
1891
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1892
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1893
-            EVENT_ESPRESSO_VERSION,
1894
-            true
1895
-        );
1896
-        //google charts
1897
-        wp_register_script(
1898
-            'google-charts',
1899
-            'https://www.gstatic.com/charts/loader.js',
1900
-            array(),
1901
-            EVENT_ESPRESSO_VERSION,
1902
-            false
1903
-        );
1904
-        // ENQUEUE ALL BASICS BY DEFAULT
1905
-        wp_enqueue_style('ee-admin-css');
1906
-        wp_enqueue_script('ee_admin_js');
1907
-        wp_enqueue_script('ee-accounting');
1908
-        wp_enqueue_script('jquery-validate');
1909
-        //taking care of metaboxes
1910
-        if (
1911
-            empty($this->_cpt_route)
1912
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1913
-        ) {
1914
-            wp_enqueue_script('dashboard');
1915
-        }
1916
-        // LOCALIZED DATA
1917
-        //localize script for ajax lazy loading
1918
-        $lazy_loader_container_ids = apply_filters(
1919
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1920
-            array('espresso_news_post_box_content')
1921
-        );
1922
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1923
-        /**
1924
-         * help tour stuff
1925
-         */
1926
-        if (! empty($this->_help_tour)) {
1927
-            //register the js for kicking things off
1928
-            wp_enqueue_script(
1929
-                'ee-help-tour',
1930
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1931
-                array('jquery-joyride'),
1932
-                EVENT_ESPRESSO_VERSION,
1933
-                true
1934
-            );
1935
-            //setup tours for the js tour object
1936
-            foreach ($this->_help_tour['tours'] as $tour) {
1937
-                $tours[] = array(
1938
-                    'id'      => $tour->get_slug(),
1939
-                    'options' => $tour->get_options(),
1940
-                );
1941
-            }
1942
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1943
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1944
-        }
1945
-    }
1946
-
1947
-
1948
-
1949
-    /**
1950
-     *        admin_footer_scripts_eei18n_js_strings
1951
-     *
1952
-     * @access        public
1953
-     * @return        void
1954
-     */
1955
-    public function admin_footer_scripts_eei18n_js_strings()
1956
-    {
1957
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1958
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __(
1959
-            '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!!!',
1960
-            'event_espresso'
1961
-        );
1962
-        EE_Registry::$i18n_js_strings['January']        = __('January', 'event_espresso');
1963
-        EE_Registry::$i18n_js_strings['February']       = __('February', 'event_espresso');
1964
-        EE_Registry::$i18n_js_strings['March']          = __('March', 'event_espresso');
1965
-        EE_Registry::$i18n_js_strings['April']          = __('April', 'event_espresso');
1966
-        EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1967
-        EE_Registry::$i18n_js_strings['June']           = __('June', 'event_espresso');
1968
-        EE_Registry::$i18n_js_strings['July']           = __('July', 'event_espresso');
1969
-        EE_Registry::$i18n_js_strings['August']         = __('August', 'event_espresso');
1970
-        EE_Registry::$i18n_js_strings['September']      = __('September', 'event_espresso');
1971
-        EE_Registry::$i18n_js_strings['October']        = __('October', 'event_espresso');
1972
-        EE_Registry::$i18n_js_strings['November']       = __('November', 'event_espresso');
1973
-        EE_Registry::$i18n_js_strings['December']       = __('December', 'event_espresso');
1974
-        EE_Registry::$i18n_js_strings['Jan']            = __('Jan', 'event_espresso');
1975
-        EE_Registry::$i18n_js_strings['Feb']            = __('Feb', 'event_espresso');
1976
-        EE_Registry::$i18n_js_strings['Mar']            = __('Mar', 'event_espresso');
1977
-        EE_Registry::$i18n_js_strings['Apr']            = __('Apr', 'event_espresso');
1978
-        EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1979
-        EE_Registry::$i18n_js_strings['Jun']            = __('Jun', 'event_espresso');
1980
-        EE_Registry::$i18n_js_strings['Jul']            = __('Jul', 'event_espresso');
1981
-        EE_Registry::$i18n_js_strings['Aug']            = __('Aug', 'event_espresso');
1982
-        EE_Registry::$i18n_js_strings['Sep']            = __('Sep', 'event_espresso');
1983
-        EE_Registry::$i18n_js_strings['Oct']            = __('Oct', 'event_espresso');
1984
-        EE_Registry::$i18n_js_strings['Nov']            = __('Nov', 'event_espresso');
1985
-        EE_Registry::$i18n_js_strings['Dec']            = __('Dec', 'event_espresso');
1986
-        EE_Registry::$i18n_js_strings['Sunday']         = __('Sunday', 'event_espresso');
1987
-        EE_Registry::$i18n_js_strings['Monday']         = __('Monday', 'event_espresso');
1988
-        EE_Registry::$i18n_js_strings['Tuesday']        = __('Tuesday', 'event_espresso');
1989
-        EE_Registry::$i18n_js_strings['Wednesday']      = __('Wednesday', 'event_espresso');
1990
-        EE_Registry::$i18n_js_strings['Thursday']       = __('Thursday', 'event_espresso');
1991
-        EE_Registry::$i18n_js_strings['Friday']         = __('Friday', 'event_espresso');
1992
-        EE_Registry::$i18n_js_strings['Saturday']       = __('Saturday', 'event_espresso');
1993
-        EE_Registry::$i18n_js_strings['Sun']            = __('Sun', 'event_espresso');
1994
-        EE_Registry::$i18n_js_strings['Mon']            = __('Mon', 'event_espresso');
1995
-        EE_Registry::$i18n_js_strings['Tue']            = __('Tue', 'event_espresso');
1996
-        EE_Registry::$i18n_js_strings['Wed']            = __('Wed', 'event_espresso');
1997
-        EE_Registry::$i18n_js_strings['Thu']            = __('Thu', 'event_espresso');
1998
-        EE_Registry::$i18n_js_strings['Fri']            = __('Fri', 'event_espresso');
1999
-        EE_Registry::$i18n_js_strings['Sat']            = __('Sat', 'event_espresso');
2000
-    }
2001
-
2002
-
2003
-
2004
-    /**
2005
-     *        load enhanced xdebug styles for ppl with failing eyesight
2006
-     *
2007
-     * @access        public
2008
-     * @return        void
2009
-     */
2010
-    public function add_xdebug_style()
2011
-    {
2012
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2013
-    }
2014
-
2015
-
2016
-    /************************/
2017
-    /** LIST TABLE METHODS **/
2018
-    /************************/
2019
-    /**
2020
-     * this sets up the list table if the current view requires it.
2021
-     *
2022
-     * @access protected
2023
-     * @return void
2024
-     */
2025
-    protected function _set_list_table()
2026
-    {
2027
-        //first is this a list_table view?
2028
-        if (! isset($this->_route_config['list_table'])) {
2029
-            return;
2030
-        } //not a list_table view so get out.
2031
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
2032
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
2033
-            //user error msg
2034
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
2035
-            //developer error msg
2036
-            $error_msg .= '||' . sprintf(
2037
-                    __(
2038
-                        '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.',
2039
-                        'event_espresso'
2040
-                    ),
2041
-                    $this->_req_action,
2042
-                    '_set_list_table_views_' . $this->_req_action
2043
-                );
2044
-            throw new EE_Error($error_msg);
2045
-        }
2046
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2047
-        $this->_views = apply_filters(
2048
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2049
-            $this->_views
2050
-        );
2051
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2052
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2053
-        $this->_set_list_table_view();
2054
-        $this->_set_list_table_object();
2055
-    }
2056
-
2057
-
2058
-
2059
-    /**
2060
-     *        set current view for List Table
2061
-     *
2062
-     * @access public
2063
-     * @return array
2064
-     */
2065
-    protected function _set_list_table_view()
2066
-    {
2067
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2068
-        // looking at active items or dumpster diving ?
2069
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2070
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2071
-        } else {
2072
-            $this->_view = sanitize_key($this->_req_data['status']);
2073
-        }
2074
-    }
2075
-
2076
-
2077
-
2078
-    /**
2079
-     * _set_list_table_object
2080
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2081
-     *
2082
-     * @throws \EE_Error
2083
-     */
2084
-    protected function _set_list_table_object()
2085
-    {
2086
-        if (isset($this->_route_config['list_table'])) {
2087
-            if (! class_exists($this->_route_config['list_table'])) {
2088
-                throw new EE_Error(
2089
-                    sprintf(
2090
-                        __(
2091
-                            '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.',
2092
-                            'event_espresso'
2093
-                        ),
2094
-                        $this->_route_config['list_table'],
2095
-                        get_class($this)
2096
-                    )
2097
-                );
2098
-            }
2099
-            $list_table               = $this->_route_config['list_table'];
2100
-            $this->_list_table_object = new $list_table($this);
2101
-        }
2102
-    }
2103
-
2104
-
2105
-
2106
-    /**
2107
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2108
-     *
2109
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2110
-     *                                                    urls.  The array should be indexed by the view it is being
2111
-     *                                                    added to.
2112
-     * @return array
2113
-     */
2114
-    public function get_list_table_view_RLs($extra_query_args = array())
2115
-    {
2116
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2117
-        if (empty($this->_views)) {
2118
-            $this->_views = array();
2119
-        }
2120
-        // cycle thru views
2121
-        foreach ($this->_views as $key => $view) {
2122
-            $query_args = array();
2123
-            // check for current view
2124
-            $this->_views[$key]['class']               = $this->_view == $view['slug'] ? 'current' : '';
2125
-            $query_args['action']                      = $this->_req_action;
2126
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2127
-            $query_args['status']                      = $view['slug'];
2128
-            //merge any other arguments sent in.
2129
-            if (isset($extra_query_args[$view['slug']])) {
2130
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2131
-            }
2132
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2133
-        }
2134
-        return $this->_views;
2135
-    }
2136
-
2137
-
2138
-
2139
-    /**
2140
-     * _entries_per_page_dropdown
2141
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
2142
-     *
2143
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2144
-     *         WP does it.
2145
-     * @access protected
2146
-     * @param int $max_entries total number of rows in the table
2147
-     * @return string
2148
-     */
2149
-    protected function _entries_per_page_dropdown($max_entries = false)
2150
-    {
2151
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2152
-        $values   = array(10, 25, 50, 100);
2153
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2154
-        if ($max_entries) {
2155
-            $values[] = $max_entries;
2156
-            sort($values);
2157
-        }
2158
-        $entries_per_page_dropdown = '
146
+	// yes / no array for admin form fields
147
+	protected $_yes_no_values = array();
148
+
149
+	//some default things shared by all child classes
150
+	protected $_default_espresso_metaboxes;
151
+
152
+	/**
153
+	 *    EE_Registry Object
154
+	 *
155
+	 * @var    EE_Registry
156
+	 * @access    protected
157
+	 */
158
+	protected $EE = null;
159
+
160
+
161
+
162
+	/**
163
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
164
+	 *
165
+	 * @var boolean
166
+	 */
167
+	protected $_is_caf = false;
168
+
169
+
170
+
171
+	/**
172
+	 * @Constructor
173
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
174
+	 * @access public
175
+	 */
176
+	public function __construct($routing = true)
177
+	{
178
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
179
+			$this->_is_caf = true;
180
+		}
181
+		$this->_yes_no_values = array(
182
+			array('id' => true, 'text' => __('Yes', 'event_espresso')),
183
+			array('id' => false, 'text' => __('No', 'event_espresso')),
184
+		);
185
+		//set the _req_data property.
186
+		$this->_req_data = array_merge($_GET, $_POST);
187
+		//routing enabled?
188
+		$this->_routing = $routing;
189
+		//set initial page props (child method)
190
+		$this->_init_page_props();
191
+		//set global defaults
192
+		$this->_set_defaults();
193
+		//set early because incoming requests could be ajax related and we need to register those hooks.
194
+		$this->_global_ajax_hooks();
195
+		$this->_ajax_hooks();
196
+		//other_page_hooks have to be early too.
197
+		$this->_do_other_page_hooks();
198
+		//This just allows us to have extending classes do something specific
199
+		// before the parent constructor runs _page_setup().
200
+		if (method_exists($this, '_before_page_setup')) {
201
+			$this->_before_page_setup();
202
+		}
203
+		//set up page dependencies
204
+		$this->_page_setup();
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * _init_page_props
211
+	 * Child classes use to set at least the following properties:
212
+	 * $page_slug.
213
+	 * $page_label.
214
+	 *
215
+	 * @abstract
216
+	 * @access protected
217
+	 * @return void
218
+	 */
219
+	abstract protected function _init_page_props();
220
+
221
+
222
+
223
+	/**
224
+	 * _ajax_hooks
225
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
226
+	 * Note: within the ajax callback methods.
227
+	 *
228
+	 * @abstract
229
+	 * @access protected
230
+	 * @return void
231
+	 */
232
+	abstract protected function _ajax_hooks();
233
+
234
+
235
+
236
+	/**
237
+	 * _define_page_props
238
+	 * child classes define page properties in here.  Must include at least:
239
+	 * $_admin_base_url = base_url for all admin pages
240
+	 * $_admin_page_title = default admin_page_title for admin pages
241
+	 * $_labels = array of default labels for various automatically generated elements:
242
+	 *    array(
243
+	 *        'buttons' => array(
244
+	 *            'add' => __('label for add new button'),
245
+	 *            'edit' => __('label for edit button'),
246
+	 *            'delete' => __('label for delete button')
247
+	 *            )
248
+	 *        )
249
+	 *
250
+	 * @abstract
251
+	 * @access protected
252
+	 * @return void
253
+	 */
254
+	abstract protected function _define_page_props();
255
+
256
+
257
+
258
+	/**
259
+	 * _set_page_routes
260
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
261
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
262
+	 * have a 'default' route. Here's the format
263
+	 * $this->_page_routes = array(
264
+	 *        'default' => array(
265
+	 *            'func' => '_default_method_handling_route',
266
+	 *            'args' => array('array','of','args'),
267
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
268
+	 *            ajax request, backend processing)
269
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
270
+	 *            headers route after.  The string you enter here should match the defined route reference for a
271
+	 *            headers sent route.
272
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
273
+	 *            this route.
274
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
275
+	 *            checks).
276
+	 *        ),
277
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
278
+	 *        handling method.
279
+	 *        )
280
+	 * )
281
+	 *
282
+	 * @abstract
283
+	 * @access protected
284
+	 * @return void
285
+	 */
286
+	abstract protected function _set_page_routes();
287
+
288
+
289
+
290
+	/**
291
+	 * _set_page_config
292
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
293
+	 * array corresponds to the page_route for the loaded page. Format:
294
+	 * $this->_page_config = array(
295
+	 *        'default' => array(
296
+	 *            'labels' => array(
297
+	 *                'buttons' => array(
298
+	 *                    'add' => __('label for adding item'),
299
+	 *                    'edit' => __('label for editing item'),
300
+	 *                    'delete' => __('label for deleting item')
301
+	 *                ),
302
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
303
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
304
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
305
+	 *            _define_page_props() method
306
+	 *            'nav' => array(
307
+	 *                'label' => __('Label for Tab', 'event_espresso').
308
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
309
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
310
+	 *                'order' => 10, //required to indicate tab position.
311
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
312
+	 *                displayed then add this parameter.
313
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
314
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
315
+	 *            metaboxes set for eventespresso admin pages.
316
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
317
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
318
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
319
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
320
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
321
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
322
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
323
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
324
+	 *            want to display.
325
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
326
+	 *                'tab_id' => array(
327
+	 *                    'title' => 'tab_title',
328
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
329
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
330
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
331
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
332
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
333
+	 *                    attempt to use the callback which should match the name of a method in the class
334
+	 *                    ),
335
+	 *                'tab2_id' => array(
336
+	 *                    'title' => 'tab2 title',
337
+	 *                    'filename' => 'file_name_2'
338
+	 *                    'callback' => 'callback_method_for_content',
339
+	 *                 ),
340
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
341
+	 *            help tab area on an admin page. @link
342
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
343
+	 *            'help_tour' => array(
344
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
345
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
346
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
347
+	 *            ),
348
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
349
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
350
+	 *            just set
351
+	 *            'require_nonce' to FALSE
352
+	 *            )
353
+	 * )
354
+	 *
355
+	 * @abstract
356
+	 * @access protected
357
+	 * @return void
358
+	 */
359
+	abstract protected function _set_page_config();
360
+
361
+
362
+
363
+
364
+
365
+	/** end sample help_tour methods **/
366
+	/**
367
+	 * _add_screen_options
368
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
+	 * to a particular view.
371
+	 *
372
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
+	 *         see also WP_Screen object documents...
374
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
+	 * @abstract
376
+	 * @access protected
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+
383
+	/**
384
+	 * _add_feature_pointers
385
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
386
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
387
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
388
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
389
+	 * extended) also see:
390
+	 *
391
+	 * @link   http://eamann.com/tech/wordpress-portland/
392
+	 * @abstract
393
+	 * @access protected
394
+	 * @return void
395
+	 */
396
+	abstract protected function _add_feature_pointers();
397
+
398
+
399
+
400
+	/**
401
+	 * load_scripts_styles
402
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
403
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
404
+	 * scripts/styles per view by putting them in a dynamic function in this format
405
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
406
+	 *
407
+	 * @abstract
408
+	 * @access public
409
+	 * @return void
410
+	 */
411
+	abstract public function load_scripts_styles();
412
+
413
+
414
+
415
+	/**
416
+	 * admin_init
417
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
418
+	 * all pages/views loaded by child class.
419
+	 *
420
+	 * @abstract
421
+	 * @access public
422
+	 * @return void
423
+	 */
424
+	abstract public function admin_init();
425
+
426
+
427
+
428
+	/**
429
+	 * admin_notices
430
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
431
+	 * all pages/views loaded by child class.
432
+	 *
433
+	 * @abstract
434
+	 * @access public
435
+	 * @return void
436
+	 */
437
+	abstract public function admin_notices();
438
+
439
+
440
+
441
+	/**
442
+	 * admin_footer_scripts
443
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
+	 * will apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @access public
447
+	 * @return void
448
+	 */
449
+	abstract public function admin_footer_scripts();
450
+
451
+
452
+
453
+	/**
454
+	 * admin_footer
455
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
456
+	 * apply to all pages/views loaded by child class.
457
+	 *
458
+	 * @access  public
459
+	 * @return void
460
+	 */
461
+	public function admin_footer()
462
+	{
463
+	}
464
+
465
+
466
+
467
+	/**
468
+	 * _global_ajax_hooks
469
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
470
+	 * Note: within the ajax callback methods.
471
+	 *
472
+	 * @abstract
473
+	 * @access protected
474
+	 * @return void
475
+	 */
476
+	protected function _global_ajax_hooks()
477
+	{
478
+		//for lazy loading of metabox content
479
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
480
+	}
481
+
482
+
483
+
484
+	public function ajax_metabox_content()
485
+	{
486
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
487
+		$url       = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
488
+		self::cached_rss_display($contentid, $url);
489
+		wp_die();
490
+	}
491
+
492
+
493
+
494
+	/**
495
+	 * _page_setup
496
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
497
+	 * doesn't match the object.
498
+	 *
499
+	 * @final
500
+	 * @access protected
501
+	 * @return void
502
+	 */
503
+	final protected function _page_setup()
504
+	{
505
+		//requires?
506
+		//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.
507
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
508
+		//next verify if we need to load anything...
509
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
510
+		$this->page_folder   = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
511
+		global $ee_menu_slugs;
512
+		$ee_menu_slugs = (array)$ee_menu_slugs;
513
+		if ((! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
514
+			return;
515
+		}
516
+		// 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
517
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
518
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1
519
+				? $this->_req_data['action2'] : $this->_req_data['action'];
520
+		}
521
+		// then set blank or -1 action values to 'default'
522
+		$this->_req_action = isset($this->_req_data['action'])
523
+							 && ! empty($this->_req_data['action'])
524
+							 && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
525
+		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
526
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
527
+			? $this->_req_data['route'] : $this->_req_action;
528
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
529
+		$this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route']
530
+			: $this->_req_action;
531
+		$this->_current_view = $this->_req_action;
532
+		$this->_req_nonce    = $this->_req_action . '_nonce';
533
+		$this->_define_page_props();
534
+		$this->_current_page_view_url = add_query_arg(
535
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
536
+			$this->_admin_base_url
537
+		);
538
+		//default things
539
+		$this->_default_espresso_metaboxes = array(
540
+			'_espresso_news_post_box',
541
+			'_espresso_links_post_box',
542
+			'_espresso_ratings_request',
543
+			'_espresso_sponsors_post_box',
544
+		);
545
+		//set page configs
546
+		$this->_set_page_routes();
547
+		$this->_set_page_config();
548
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
549
+		if (isset($this->_req_data['wp_referer'])) {
550
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
551
+		}
552
+		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
553
+		if (method_exists($this, '_extend_page_config')) {
554
+			$this->_extend_page_config();
555
+		}
556
+		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
557
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
558
+			$this->_extend_page_config_for_cpt();
559
+		}
560
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
561
+		$this->_page_routes = apply_filters(
562
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
563
+			$this->_page_routes,
564
+			$this
565
+		);
566
+		$this->_page_config = apply_filters(
567
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
568
+			$this->_page_config,
569
+			$this
570
+		);
571
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present 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
+	/**
602
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
603
+	 *
604
+	 * @access private
605
+	 * @return void
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__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'),
617
+					$page
618
+				);
619
+				$error_msg[] = $error_msg[0]
620
+							   . "\r\n"
621
+							   . sprintf(
622
+								   esc_html__(
623
+									   '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',
624
+									   'event_espresso'
625
+								   ),
626
+								   $page,
627
+								   '<br />',
628
+								   '<strong>' . $classname . '</strong>'
629
+							   );
630
+				throw new EE_Error(implode('||', $error_msg));
631
+			}
632
+			$a = new ReflectionClass($classname);
633
+			//notice we are passing the instance of this class to the hook object.
634
+			$hookobj[] = $a->newInstance($this);
635
+		}
636
+	}
637
+
638
+
639
+
640
+	public function load_page_dependencies()
641
+	{
642
+		try {
643
+			$this->_load_page_dependencies();
644
+		} catch (EE_Error $e) {
645
+			$e->get_error();
646
+		}
647
+	}
648
+
649
+
650
+
651
+	/**
652
+	 * load_page_dependencies
653
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
654
+	 *
655
+	 * @access public
656
+	 * @return void
657
+	 */
658
+	protected function _load_page_dependencies()
659
+	{
660
+		//let's set the current_screen and screen options to override what WP set
661
+		$this->_current_screen = get_current_screen();
662
+		//load admin_notices - global, page class, and view specific
663
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
664
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
665
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
666
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
667
+		}
668
+		//load network admin_notices - global, page class, and view specific
669
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
670
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
671
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
672
+		}
673
+		//this will save any per_page screen options if they are present
674
+		$this->_set_per_page_screen_options();
675
+		//setup list table properties
676
+		$this->_set_list_table();
677
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
678
+		$this->_add_registered_meta_boxes();
679
+		$this->_add_screen_columns();
680
+		//add screen options - global, page child class, and view specific
681
+		$this->_add_global_screen_options();
682
+		$this->_add_screen_options();
683
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
684
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
685
+		}
686
+		//add help tab(s) and tours- set via page_config and qtips.
687
+		$this->_add_help_tour();
688
+		$this->_add_help_tabs();
689
+		$this->_add_qtips();
690
+		//add feature_pointers - global, page child class, and view specific
691
+		$this->_add_feature_pointers();
692
+		$this->_add_global_feature_pointers();
693
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
694
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
695
+		}
696
+		//enqueue scripts/styles - global, page class, and view specific
697
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
698
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
699
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
700
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
701
+		}
702
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
703
+		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
704
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
705
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
706
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
707
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
708
+		}
709
+		//admin footer scripts
710
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
711
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
712
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
713
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
714
+		}
715
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
716
+		//targeted hook
717
+		do_action(
718
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action
719
+		);
720
+	}
721
+
722
+
723
+
724
+	/**
725
+	 * _set_defaults
726
+	 * This sets some global defaults for class properties.
727
+	 */
728
+	private function _set_defaults()
729
+	{
730
+		$this->_current_screen      = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
731
+		$this->_nav_tabs            = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
732
+		$this->default_nav_tab_name = 'overview';
733
+		//init template args
734
+		$this->_template_args = array(
735
+			'admin_page_header'  => '',
736
+			'admin_page_content' => '',
737
+			'post_body_content'  => '',
738
+			'before_list_table'  => '',
739
+			'after_list_table'   => '',
740
+		);
741
+	}
742
+
743
+
744
+
745
+	/**
746
+	 * route_admin_request
747
+	 *
748
+	 * @see    _route_admin_request()
749
+	 * @access public
750
+	 * @return void|exception error
751
+	 */
752
+	public function route_admin_request()
753
+	{
754
+		try {
755
+			$this->_route_admin_request();
756
+		} catch (EE_Error $e) {
757
+			$e->get_error();
758
+		}
759
+	}
760
+
761
+
762
+
763
+	public function set_wp_page_slug($wp_page_slug)
764
+	{
765
+		$this->_wp_page_slug = $wp_page_slug;
766
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
767
+		if (is_network_admin()) {
768
+			$this->_wp_page_slug .= '-network';
769
+		}
770
+	}
771
+
772
+
773
+
774
+	/**
775
+	 * _verify_routes
776
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
777
+	 * we know if we need to drop out.
778
+	 *
779
+	 * @access protected
780
+	 * @return void
781
+	 */
782
+	protected function _verify_routes()
783
+	{
784
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
785
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
786
+			return false;
787
+		}
788
+		$this->_route = false;
789
+		$func         = false;
790
+		$args         = array();
791
+		// check that the page_routes array is not empty
792
+		if (empty($this->_page_routes)) {
793
+			// user error msg
794
+			$error_msg = sprintf(
795
+				__('No page routes have been set for the %s admin page.', 'event_espresso'),
796
+				$this->_admin_page_title
797
+			);
798
+			// developer error msg
799
+			$error_msg .= '||' . $error_msg . __(
800
+					' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
801
+					'event_espresso'
802
+				);
803
+			throw new EE_Error($error_msg);
804
+		}
805
+		// and that the requested page route exists
806
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
807
+			$this->_route        = $this->_page_routes[$this->_req_action];
808
+			$this->_route_config = isset($this->_page_config[$this->_req_action])
809
+				? $this->_page_config[$this->_req_action] : array();
810
+		} else {
811
+			// user error msg
812
+			$error_msg = sprintf(
813
+				__('The requested page route does not exist for the %s admin page.', 'event_espresso'),
814
+				$this->_admin_page_title
815
+			);
816
+			// developer error msg
817
+			$error_msg .= '||' . $error_msg . sprintf(
818
+					__(
819
+						' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
820
+						'event_espresso'
821
+					),
822
+					$this->_req_action
823
+				);
824
+			throw new EE_Error($error_msg);
825
+		}
826
+		// and that a default route exists
827
+		if (! array_key_exists('default', $this->_page_routes)) {
828
+			// user error msg
829
+			$error_msg = sprintf(
830
+				__('A default page route has not been set for the % admin page.', 'event_espresso'),
831
+				$this->_admin_page_title
832
+			);
833
+			// developer error msg
834
+			$error_msg .= '||' . $error_msg . __(
835
+					' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
836
+					'event_espresso'
837
+				);
838
+			throw new EE_Error($error_msg);
839
+		}
840
+		//first lets' catch if the UI request has EVER been set.
841
+		if ($this->_is_UI_request === null) {
842
+			//lets set if this is a UI request or not.
843
+			$this->_is_UI_request = (! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
844
+				? true : false;
845
+			//wait a minute... we might have a noheader in the route array
846
+			$this->_is_UI_request = is_array($this->_route)
847
+									&& isset($this->_route['noheader'])
848
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
849
+		}
850
+		$this->_set_current_labels();
851
+	}
852
+
853
+
854
+
855
+	/**
856
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
857
+	 *
858
+	 * @param  string $route the route name we're verifying
859
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
860
+	 */
861
+	protected function _verify_route($route)
862
+	{
863
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
864
+			return true;
865
+		} else {
866
+			// user error msg
867
+			$error_msg = sprintf(
868
+				__('The given page route does not exist for the %s admin page.', 'event_espresso'),
869
+				$this->_admin_page_title
870
+			);
871
+			// developer error msg
872
+			$error_msg .= '||' . $error_msg . sprintf(
873
+					__(
874
+						' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
875
+						'event_espresso'
876
+					),
877
+					$route
878
+				);
879
+			throw new EE_Error($error_msg);
880
+		}
881
+	}
882
+
883
+
884
+
885
+	/**
886
+	 * perform nonce verification
887
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
888
+	 * using this method (and save retyping!)
889
+	 *
890
+	 * @param  string $nonce     The nonce sent
891
+	 * @param  string $nonce_ref The nonce reference string (name0)
892
+	 * @return mixed (bool|die)
893
+	 */
894
+	protected function _verify_nonce($nonce, $nonce_ref)
895
+	{
896
+		// verify nonce against expected value
897
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
898
+			// these are not the droids you are looking for !!!
899
+			$msg = sprintf(
900
+				__('%sNonce Fail.%s', 'event_espresso'),
901
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
902
+				'</a>'
903
+			);
904
+			if (WP_DEBUG) {
905
+				$msg .= "\n  " . sprintf(
906
+						__(
907
+							'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
908
+							'event_espresso'
909
+						),
910
+						__CLASS__
911
+					);
912
+			}
913
+			if (! defined('DOING_AJAX')) {
914
+				wp_die($msg);
915
+			} else {
916
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
917
+				$this->_return_json();
918
+			}
919
+		}
920
+	}
921
+
922
+
923
+
924
+	/**
925
+	 * _route_admin_request()
926
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
927
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
928
+	 * in the page routes and then will try to load the corresponding method.
929
+	 *
930
+	 * @access protected
931
+	 * @return void
932
+	 * @throws \EE_Error
933
+	 */
934
+	protected function _route_admin_request()
935
+	{
936
+		if (! $this->_is_UI_request) {
937
+			$this->_verify_routes();
938
+		}
939
+		$nonce_check = isset($this->_route_config['require_nonce'])
940
+			? $this->_route_config['require_nonce']
941
+			: true;
942
+		if ($this->_req_action !== 'default' && $nonce_check) {
943
+			// set nonce from post data
944
+			$nonce = isset($this->_req_data[$this->_req_nonce])
945
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
946
+				: '';
947
+			$this->_verify_nonce($nonce, $this->_req_nonce);
948
+		}
949
+		//set the nav_tabs array but ONLY if this is  UI_request
950
+		if ($this->_is_UI_request) {
951
+			$this->_set_nav_tabs();
952
+		}
953
+		// grab callback function
954
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
955
+		// check if callback has args
956
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
957
+		$error_msg = '';
958
+		// action right before calling route
959
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
960
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
961
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
962
+		}
963
+		// right before calling the route, let's remove _wp_http_referer from the
964
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
965
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
966
+		if (! empty($func)) {
967
+			if (is_array($func)) {
968
+				list($class, $method) = $func;
969
+			} elseif (strpos($func, '::') !== false) {
970
+				list($class, $method) = explode('::', $func);
971
+			} else {
972
+				$class  = $this;
973
+				$method = $func;
974
+			}
975
+			if (! (is_object($class) && $class === $this)) {
976
+				// send along this admin page object for access by addons.
977
+				$args['admin_page_object'] = $this;
978
+			}
979
+			if (
980
+				//is it a method on a class that doesn't work?
981
+				(
982
+					(
983
+						method_exists($class, $method)
984
+						&& call_user_func_array(array($class, $method), $args) === false
985
+					)
986
+					&& (
987
+						//is it a standalone function that doesn't work?
988
+						function_exists($method)
989
+						&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args))
990
+						   === false
991
+					)
992
+				)
993
+				|| (
994
+					//is it neither a class method NOR a standalone function?
995
+					! method_exists($class, $method)
996
+					&& ! function_exists($method)
997
+				)
998
+			) {
999
+				// user error msg
1000
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
1001
+				// developer error msg
1002
+				$error_msg .= '||';
1003
+				$error_msg .= sprintf(
1004
+					__(
1005
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1006
+						'event_espresso'
1007
+					),
1008
+					$method
1009
+				);
1010
+			}
1011
+			if (! empty($error_msg)) {
1012
+				throw new EE_Error($error_msg);
1013
+			}
1014
+		}
1015
+		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
1016
+		//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.
1017
+		if ($this->_is_UI_request === false
1018
+			&& is_array($this->_route)
1019
+			&& ! empty($this->_route['headers_sent_route'])
1020
+		) {
1021
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1022
+		}
1023
+	}
1024
+
1025
+
1026
+
1027
+	/**
1028
+	 * This method just allows the resetting of page properties in the case where a no headers
1029
+	 * route redirects to a headers route in its route config.
1030
+	 *
1031
+	 * @since   4.3.0
1032
+	 * @param  string $new_route New (non header) route to redirect to.
1033
+	 * @return   void
1034
+	 */
1035
+	protected function _reset_routing_properties($new_route)
1036
+	{
1037
+		$this->_is_UI_request = true;
1038
+		//now we set the current route to whatever the headers_sent_route is set at
1039
+		$this->_req_data['action'] = $new_route;
1040
+		//rerun page setup
1041
+		$this->_page_setup();
1042
+	}
1043
+
1044
+
1045
+
1046
+	/**
1047
+	 * _add_query_arg
1048
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1049
+	 *(internally just uses EEH_URL's function with the same name)
1050
+	 *
1051
+	 * @access public
1052
+	 * @param array  $args
1053
+	 * @param string $url
1054
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1055
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1056
+	 *                                        Example usage: If the current page is:
1057
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1058
+	 *                                        &action=default&event_id=20&month_range=March%202015
1059
+	 *                                        &_wpnonce=5467821
1060
+	 *                                        and you call:
1061
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1062
+	 *                                        array(
1063
+	 *                                        'action' => 'resend_something',
1064
+	 *                                        'page=>espresso_registrations'
1065
+	 *                                        ),
1066
+	 *                                        $some_url,
1067
+	 *                                        true
1068
+	 *                                        );
1069
+	 *                                        It will produce a url in this structure:
1070
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1071
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1072
+	 *                                        month_range]=March%202015
1073
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1074
+	 * @return string
1075
+	 */
1076
+	public static function add_query_args_and_nonce(
1077
+		$args = array(),
1078
+		$url = false,
1079
+		$sticky = false,
1080
+		$exclude_nonce = false
1081
+	) {
1082
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
1083
+		if ($sticky) {
1084
+			$request = $_REQUEST;
1085
+			unset($request['_wp_http_referer']);
1086
+			unset($request['wp_referer']);
1087
+			foreach ($request as $key => $value) {
1088
+				//do not add nonces
1089
+				if (strpos($key, 'nonce') !== false) {
1090
+					continue;
1091
+				}
1092
+				$args['wp_referer[' . $key . ']'] = $value;
1093
+			}
1094
+		}
1095
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1096
+	}
1097
+
1098
+
1099
+
1100
+	/**
1101
+	 * This returns a generated link that will load the related help tab.
1102
+	 *
1103
+	 * @param  string $help_tab_id the id for the connected help tab
1104
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1105
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1106
+	 * @uses EEH_Template::get_help_tab_link()
1107
+	 * @return string              generated link
1108
+	 */
1109
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
1110
+	{
1111
+		return EEH_Template::get_help_tab_link(
1112
+			$help_tab_id,
1113
+			$this->page_slug,
1114
+			$this->_req_action,
1115
+			$icon_style,
1116
+			$help_text
1117
+		);
1118
+	}
1119
+
1120
+
1121
+
1122
+	/**
1123
+	 * _add_help_tabs
1124
+	 * Note child classes define their help tabs within the page_config array.
1125
+	 *
1126
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1127
+	 * @access protected
1128
+	 * @return void
1129
+	 */
1130
+	protected function _add_help_tabs()
1131
+	{
1132
+		$tour_buttons = '';
1133
+		if (isset($this->_page_config[$this->_req_action])) {
1134
+			$config = $this->_page_config[$this->_req_action];
1135
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1136
+			if (isset($this->_help_tour[$this->_req_action])) {
1137
+				$tb           = array();
1138
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1139
+				foreach ($this->_help_tour['tours'] as $tour) {
1140
+					//if this is the end tour then we don't need to setup a button
1141
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1142
+						continue;
1143
+					}
1144
+					$tb[] = '<button id="trigger-tour-'
1145
+							. $tour->get_slug()
1146
+							. '" class="button-primary trigger-ee-help-tour">'
1147
+							. $tour->get_label()
1148
+							. '</button>';
1149
+				}
1150
+				$tour_buttons .= implode('<br />', $tb);
1151
+				$tour_buttons .= '</div></div>';
1152
+			}
1153
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1154
+			if (is_array($config) && isset($config['help_sidebar'])) {
1155
+				//check that the callback given is valid
1156
+				if (! method_exists($this, $config['help_sidebar'])) {
1157
+					throw new EE_Error(
1158
+						sprintf(
1159
+							__(
1160
+								'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',
1161
+								'event_espresso'
1162
+							),
1163
+							$config['help_sidebar'],
1164
+							get_class($this)
1165
+						)
1166
+					);
1167
+				}
1168
+				$content = apply_filters(
1169
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1170
+					call_user_func(array($this, $config['help_sidebar']))
1171
+				);
1172
+				$content .= $tour_buttons; //add help tour buttons.
1173
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1174
+				$this->_current_screen->set_help_sidebar($content);
1175
+			}
1176
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1177
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1178
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1179
+			}
1180
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1181
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1182
+				$_ht['id']      = $this->page_slug;
1183
+				$_ht['title']   = __('Help Tours', 'event_espresso');
1184
+				$_ht['content'] = '<p>' . __(
1185
+						'The buttons to the right allow you to start/restart any help tours available for this page',
1186
+						'event_espresso'
1187
+					) . '</p>';
1188
+				$this->_current_screen->add_help_tab($_ht);
1189
+			}/**/
1190
+			if (! isset($config['help_tabs'])) {
1191
+				return;
1192
+			} //no help tabs for this route
1193
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1194
+				//we're here so there ARE help tabs!
1195
+				//make sure we've got what we need
1196
+				if (! isset($cfg['title'])) {
1197
+					throw new EE_Error(
1198
+						__(
1199
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1200
+							'event_espresso'
1201
+						)
1202
+					);
1203
+				}
1204
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1205
+					throw new EE_Error(
1206
+						__(
1207
+							'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',
1208
+							'event_espresso'
1209
+						)
1210
+					);
1211
+				}
1212
+				//first priority goes to content.
1213
+				if (! empty($cfg['content'])) {
1214
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1215
+					//second priority goes to filename
1216
+				} elseif (! empty($cfg['filename'])) {
1217
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1218
+					//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)
1219
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1220
+															 . basename($this->_get_dir())
1221
+															 . '/help_tabs/'
1222
+															 . $cfg['filename']
1223
+															 . '.help_tab.php' : $file_path;
1224
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1225
+					if (! is_readable($file_path) && ! isset($cfg['callback'])) {
1226
+						EE_Error::add_error(
1227
+							sprintf(
1228
+								__(
1229
+									'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',
1230
+									'event_espresso'
1231
+								),
1232
+								$tab_id,
1233
+								key($config),
1234
+								$file_path
1235
+							),
1236
+							__FILE__,
1237
+							__FUNCTION__,
1238
+							__LINE__
1239
+						);
1240
+						return;
1241
+					}
1242
+					$template_args['admin_page_obj'] = $this;
1243
+					$content                         = EEH_Template::display_template($file_path, $template_args, true);
1244
+				} else {
1245
+					$content = '';
1246
+				}
1247
+				//check if callback is valid
1248
+				if (empty($content) && (! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1249
+					EE_Error::add_error(
1250
+						sprintf(
1251
+							__(
1252
+								'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.',
1253
+								'event_espresso'
1254
+							),
1255
+							$cfg['title']
1256
+						),
1257
+						__FILE__,
1258
+						__FUNCTION__,
1259
+						__LINE__
1260
+					);
1261
+					return;
1262
+				}
1263
+				//setup config array for help tab method
1264
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1265
+				$_ht = array(
1266
+					'id'       => $id,
1267
+					'title'    => $cfg['title'],
1268
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1269
+					'content'  => $content,
1270
+				);
1271
+				$this->_current_screen->add_help_tab($_ht);
1272
+			}
1273
+		}
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1280
+	 * an array with properties for setting up usage of the joyride plugin
1281
+	 *
1282
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1283
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1284
+	 *         _set_page_config() comments
1285
+	 * @access protected
1286
+	 * @return void
1287
+	 */
1288
+	protected function _add_help_tour()
1289
+	{
1290
+		$tours            = array();
1291
+		$this->_help_tour = array();
1292
+		//exit early if help tours are turned off globally
1293
+		if (! EE_Registry::instance()->CFG->admin->help_tour_activation
1294
+			|| (defined('EE_DISABLE_HELP_TOURS')
1295
+				&& EE_DISABLE_HELP_TOURS)) {
1296
+			return;
1297
+		}
1298
+		//loop through _page_config to find any help_tour defined
1299
+		foreach ($this->_page_config as $route => $config) {
1300
+			//we're only going to set things up for this route
1301
+			if ($route !== $this->_req_action) {
1302
+				continue;
1303
+			}
1304
+			if (isset($config['help_tour'])) {
1305
+				foreach ($config['help_tour'] as $tour) {
1306
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1307
+					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1308
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1309
+															 . basename($this->_get_dir())
1310
+															 . '/help_tours/'
1311
+															 . $tour
1312
+															 . '.class.php' : $file_path;
1313
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1314
+					if (! is_readable($file_path)) {
1315
+						EE_Error::add_error(
1316
+							sprintf(
1317
+								__(
1318
+									'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',
1319
+									'event_espresso'
1320
+								),
1321
+								$file_path,
1322
+								$tour
1323
+							),
1324
+							__FILE__,
1325
+							__FUNCTION__,
1326
+							__LINE__
1327
+						);
1328
+						return;
1329
+					}
1330
+					require_once $file_path;
1331
+					if (! class_exists($tour)) {
1332
+						$error_msg[] = sprintf(
1333
+							__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1334
+							$tour
1335
+						);
1336
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1337
+								__(
1338
+									'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.',
1339
+									'event_espresso'
1340
+								),
1341
+								$tour,
1342
+								'<br />',
1343
+								$tour,
1344
+								$this->_req_action,
1345
+								get_class($this)
1346
+							);
1347
+						throw new EE_Error(implode('||', $error_msg));
1348
+					}
1349
+					$a                          = new ReflectionClass($tour);
1350
+					$tour_obj                   = $a->newInstance($this->_is_caf);
1351
+					$tours[]                    = $tour_obj;
1352
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1353
+				}
1354
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1355
+				$end_stop_tour              = new EE_Help_Tour_final_stop($this->_is_caf);
1356
+				$tours[]                    = $end_stop_tour;
1357
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1358
+			}
1359
+		}
1360
+		if (! empty($tours)) {
1361
+			$this->_help_tour['tours'] = $tours;
1362
+		}
1363
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1364
+	}
1365
+
1366
+
1367
+
1368
+	/**
1369
+	 * This simply sets up any qtips that have been defined in the page config
1370
+	 *
1371
+	 * @access protected
1372
+	 * @return void
1373
+	 */
1374
+	protected function _add_qtips()
1375
+	{
1376
+		if (isset($this->_route_config['qtips'])) {
1377
+			$qtips = (array)$this->_route_config['qtips'];
1378
+			//load qtip loader
1379
+			$path = array(
1380
+				$this->_get_dir() . '/qtips/',
1381
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1382
+			);
1383
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1384
+		}
1385
+	}
1386
+
1387
+
1388
+
1389
+	/**
1390
+	 * _set_nav_tabs
1391
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1392
+	 * wish to add additional tabs or modify accordingly.
1393
+	 *
1394
+	 * @access protected
1395
+	 * @return void
1396
+	 */
1397
+	protected function _set_nav_tabs()
1398
+	{
1399
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1400
+		$i = 0;
1401
+		foreach ($this->_page_config as $slug => $config) {
1402
+			if (! is_array($config)
1403
+				|| (is_array($config)
1404
+					&& (isset($config['nav']) && ! $config['nav'])
1405
+					|| ! isset($config['nav']))) {
1406
+				continue;
1407
+			} //no nav tab for this config
1408
+			//check for persistent flag
1409
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1410
+				continue;
1411
+			} //nav tab is only to appear when route requested.
1412
+			if (! $this->check_user_access($slug, true)) {
1413
+				continue;
1414
+			} //no nav tab becasue current user does not have access.
1415
+			$css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1416
+			$this->_nav_tabs[$slug] = array(
1417
+				'url'       => isset($config['nav']['url'])
1418
+					? $config['nav']['url']
1419
+					: self::add_query_args_and_nonce(
1420
+						array('action' => $slug),
1421
+						$this->_admin_base_url
1422
+					),
1423
+				'link_text' => isset($config['nav']['label'])
1424
+					? $config['nav']['label']
1425
+					: ucwords(
1426
+						str_replace('_', ' ', $slug)
1427
+					),
1428
+				'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1429
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1430
+			);
1431
+			$i++;
1432
+		}
1433
+		//if $this->_nav_tabs is empty then lets set the default
1434
+		if (empty($this->_nav_tabs)) {
1435
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1436
+				'url'       => $this->admin_base_url,
1437
+				'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1438
+				'css_class' => 'nav-tab-active',
1439
+				'order'     => 10,
1440
+			);
1441
+		}
1442
+		//now let's sort the tabs according to order
1443
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1444
+	}
1445
+
1446
+
1447
+
1448
+	/**
1449
+	 * _set_current_labels
1450
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1451
+	 * property array
1452
+	 *
1453
+	 * @access private
1454
+	 * @return void
1455
+	 */
1456
+	private function _set_current_labels()
1457
+	{
1458
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1459
+			foreach ($this->_route_config['labels'] as $label => $text) {
1460
+				if (is_array($text)) {
1461
+					foreach ($text as $sublabel => $subtext) {
1462
+						$this->_labels[$label][$sublabel] = $subtext;
1463
+					}
1464
+				} else {
1465
+					$this->_labels[$label] = $text;
1466
+				}
1467
+			}
1468
+		}
1469
+	}
1470
+
1471
+
1472
+
1473
+	/**
1474
+	 *        verifies user access for this admin page
1475
+	 *
1476
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1477
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1478
+	 *                               return false if verify fail.
1479
+	 * @return        BOOL|wp_die()
1480
+	 */
1481
+	public function check_user_access($route_to_check = '', $verify_only = false)
1482
+	{
1483
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1484
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1485
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1486
+						  && is_array(
1487
+							  $this->_page_routes[$route_to_check]
1488
+						  )
1489
+						  && ! empty($this->_page_routes[$route_to_check]['capability'])
1490
+			? $this->_page_routes[$route_to_check]['capability'] : null;
1491
+		if (empty($capability) && empty($route_to_check)) {
1492
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1493
+				: $this->_route['capability'];
1494
+		} else {
1495
+			$capability = empty($capability) ? 'manage_options' : $capability;
1496
+		}
1497
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1498
+		if ((! function_exists('is_admin')
1499
+			 || ! EE_Registry::instance()->CAP->current_user_can(
1500
+					$capability,
1501
+					$this->page_slug
1502
+					. '_'
1503
+					. $route_to_check,
1504
+					$id
1505
+				))
1506
+			&& ! defined('DOING_AJAX')) {
1507
+			if ($verify_only) {
1508
+				return false;
1509
+			} else {
1510
+				if (is_user_logged_in()) {
1511
+					wp_die(__('You do not have access to this route.', 'event_espresso'));
1512
+				} else {
1513
+					return false;
1514
+				}
1515
+			}
1516
+		}
1517
+		return true;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * admin_init_global
1524
+	 * This runs all the code that we want executed within the WP admin_init hook.
1525
+	 * This method executes for ALL EE Admin pages.
1526
+	 *
1527
+	 * @access public
1528
+	 * @return void
1529
+	 */
1530
+	public function admin_init_global()
1531
+	{
1532
+	}
1533
+
1534
+
1535
+
1536
+	/**
1537
+	 * wp_loaded_global
1538
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1539
+	 * EE_Admin page and will execute on every EE Admin Page load
1540
+	 *
1541
+	 * @access public
1542
+	 * @return void
1543
+	 */
1544
+	public function wp_loaded()
1545
+	{
1546
+	}
1547
+
1548
+
1549
+
1550
+	/**
1551
+	 * admin_notices
1552
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1553
+	 * ALL EE_Admin pages.
1554
+	 *
1555
+	 * @access public
1556
+	 * @return void
1557
+	 */
1558
+	public function admin_notices_global()
1559
+	{
1560
+		$this->_display_no_javascript_warning();
1561
+		$this->_display_espresso_notices();
1562
+	}
1563
+
1564
+
1565
+
1566
+	public function network_admin_notices_global()
1567
+	{
1568
+		$this->_display_no_javascript_warning();
1569
+		$this->_display_espresso_notices();
1570
+	}
1571
+
1572
+
1573
+
1574
+	/**
1575
+	 * admin_footer_scripts_global
1576
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1577
+	 * will apply on ALL EE_Admin pages.
1578
+	 *
1579
+	 * @access public
1580
+	 * @return void
1581
+	 */
1582
+	public function admin_footer_scripts_global()
1583
+	{
1584
+		$this->_add_admin_page_ajax_loading_img();
1585
+		$this->_add_admin_page_overlay();
1586
+		//if metaboxes are present we need to add the nonce field
1587
+		if ((isset($this->_route_config['metaboxes'])
1588
+			 || (isset($this->_route_config['has_metaboxes'])
1589
+				 && $this->_route_config['has_metaboxes'])
1590
+			 || isset($this->_route_config['list_table']))) {
1591
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1592
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1593
+		}
1594
+	}
1595
+
1596
+
1597
+
1598
+	/**
1599
+	 * admin_footer_global
1600
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on
1601
+	 * ALL EE_Admin Pages.
1602
+	 *
1603
+	 * @access  public
1604
+	 * @return  void
1605
+	 */
1606
+	public function admin_footer_global()
1607
+	{
1608
+		//dialog container for dialog helper
1609
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1610
+		$d_cont .= '<div class="ee-notices"></div>';
1611
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1612
+		$d_cont .= '</div>';
1613
+		echo $d_cont;
1614
+		//help tour stuff?
1615
+		if (isset($this->_help_tour[$this->_req_action])) {
1616
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1617
+		}
1618
+		//current set timezone for timezone js
1619
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1620
+	}
1621
+
1622
+
1623
+
1624
+	/**
1625
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1626
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1627
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1628
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1629
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1630
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1631
+	 * for the
1632
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1633
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1634
+	 *    'help_trigger_id' => array(
1635
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1636
+	 *        'content' => __('localized content for popup', 'event_espresso')
1637
+	 *    )
1638
+	 * );
1639
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1640
+	 *
1641
+	 * @access protected
1642
+	 * @return string content
1643
+	 */
1644
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1645
+	{
1646
+		$content       = '';
1647
+		$help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1648
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1649
+		//loop through the array and setup content
1650
+		foreach ($help_array as $trigger => $help) {
1651
+			//make sure the array is setup properly
1652
+			if (! isset($help['title']) || ! isset($help['content'])) {
1653
+				throw new EE_Error(
1654
+					__(
1655
+						'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',
1656
+						'event_espresso'
1657
+					)
1658
+				);
1659
+			}
1660
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1661
+			$template_args = array(
1662
+				'help_popup_id'      => $trigger,
1663
+				'help_popup_title'   => $help['title'],
1664
+				'help_popup_content' => $help['content'],
1665
+			);
1666
+			$content       .= EEH_Template::display_template($template_path, $template_args, true);
1667
+		}
1668
+		if ($display) {
1669
+			echo $content;
1670
+		} else {
1671
+			return $content;
1672
+		}
1673
+	}
1674
+
1675
+
1676
+
1677
+	/**
1678
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1679
+	 *
1680
+	 * @access private
1681
+	 * @return array properly formatted array for help popup content
1682
+	 */
1683
+	private function _get_help_content()
1684
+	{
1685
+		//what is the method we're looking for?
1686
+		$method_name = '_help_popup_content_' . $this->_req_action;
1687
+		//if method doesn't exist let's get out.
1688
+		if (! method_exists($this, $method_name)) {
1689
+			return array();
1690
+		}
1691
+		//k we're good to go let's retrieve the help array
1692
+		$help_array = call_user_func(array($this, $method_name));
1693
+		//make sure we've got an array!
1694
+		if (! is_array($help_array)) {
1695
+			throw new EE_Error(
1696
+				__(
1697
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1698
+					'event_espresso'
1699
+				)
1700
+			);
1701
+		}
1702
+		return $help_array;
1703
+	}
1704
+
1705
+
1706
+
1707
+	/**
1708
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1709
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1710
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1711
+	 *
1712
+	 * @access protected
1713
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1714
+	 * @param boolean $display    if false then we return the trigger string
1715
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1716
+	 * @return string
1717
+	 */
1718
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1719
+	{
1720
+		if (defined('DOING_AJAX')) {
1721
+			return;
1722
+		}
1723
+		//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
1724
+		$help_array   = $this->_get_help_content();
1725
+		$help_content = '';
1726
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1727
+			$help_array[$trigger_id] = array(
1728
+				'title'   => __('Missing Content', 'event_espresso'),
1729
+				'content' => __(
1730
+					'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.)',
1731
+					'event_espresso'
1732
+				),
1733
+			);
1734
+			$help_content            = $this->_set_help_popup_content($help_array, false);
1735
+		}
1736
+		//let's setup the trigger
1737
+		$content = '<a class="ee-dialog" href="?height='
1738
+				   . $dimensions[0]
1739
+				   . '&width='
1740
+				   . $dimensions[1]
1741
+				   . '&inlineId='
1742
+				   . $trigger_id
1743
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1744
+		$content = $content . $help_content;
1745
+		if ($display) {
1746
+			echo $content;
1747
+		} else {
1748
+			return $content;
1749
+		}
1750
+	}
1751
+
1752
+
1753
+
1754
+	/**
1755
+	 * _add_global_screen_options
1756
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1757
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1758
+	 *
1759
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1760
+	 *         see also WP_Screen object documents...
1761
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1762
+	 * @abstract
1763
+	 * @access private
1764
+	 * @return void
1765
+	 */
1766
+	private function _add_global_screen_options()
1767
+	{
1768
+	}
1769
+
1770
+
1771
+
1772
+	/**
1773
+	 * _add_global_feature_pointers
1774
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1775
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1776
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1777
+	 *
1778
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1779
+	 *         extended) also see:
1780
+	 * @link   http://eamann.com/tech/wordpress-portland/
1781
+	 * @abstract
1782
+	 * @access protected
1783
+	 * @return void
1784
+	 */
1785
+	private function _add_global_feature_pointers()
1786
+	{
1787
+	}
1788
+
1789
+
1790
+
1791
+	/**
1792
+	 * load_global_scripts_styles
1793
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1794
+	 *
1795
+	 * @return void
1796
+	 */
1797
+	public function load_global_scripts_styles()
1798
+	{
1799
+		/** STYLES **/
1800
+		// add debugging styles
1801
+		if (WP_DEBUG) {
1802
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1803
+		}
1804
+		// register all styles
1805
+		wp_register_style(
1806
+			'espresso-ui-theme',
1807
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1808
+			array(),
1809
+			EVENT_ESPRESSO_VERSION
1810
+		);
1811
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1812
+		//helpers styles
1813
+		wp_register_style(
1814
+			'ee-text-links',
1815
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1816
+			array(),
1817
+			EVENT_ESPRESSO_VERSION
1818
+		);
1819
+		/** SCRIPTS **/
1820
+		//register all scripts
1821
+		wp_register_script(
1822
+			'ee-dialog',
1823
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1824
+			array('jquery', 'jquery-ui-draggable'),
1825
+			EVENT_ESPRESSO_VERSION,
1826
+			true
1827
+		);
1828
+		wp_register_script(
1829
+			'ee_admin_js',
1830
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1831
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1832
+			EVENT_ESPRESSO_VERSION,
1833
+			true
1834
+		);
1835
+		wp_register_script(
1836
+			'jquery-ui-timepicker-addon',
1837
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1838
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1839
+			EVENT_ESPRESSO_VERSION,
1840
+			true
1841
+		);
1842
+		add_filter('FHEE_load_joyride', '__return_true');
1843
+		//script for sorting tables
1844
+		wp_register_script(
1845
+			'espresso_ajax_table_sorting',
1846
+			EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js",
1847
+			array('ee_admin_js', 'jquery-ui-sortable'),
1848
+			EVENT_ESPRESSO_VERSION,
1849
+			true
1850
+		);
1851
+		//script for parsing uri's
1852
+		wp_register_script(
1853
+			'ee-parse-uri',
1854
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1855
+			array(),
1856
+			EVENT_ESPRESSO_VERSION,
1857
+			true
1858
+		);
1859
+		//and parsing associative serialized form elements
1860
+		wp_register_script(
1861
+			'ee-serialize-full-array',
1862
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1863
+			array('jquery'),
1864
+			EVENT_ESPRESSO_VERSION,
1865
+			true
1866
+		);
1867
+		//helpers scripts
1868
+		wp_register_script(
1869
+			'ee-text-links',
1870
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1871
+			array('jquery'),
1872
+			EVENT_ESPRESSO_VERSION,
1873
+			true
1874
+		);
1875
+		wp_register_script(
1876
+			'ee-moment-core',
1877
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1878
+			array(),
1879
+			EVENT_ESPRESSO_VERSION,
1880
+			true
1881
+		);
1882
+		wp_register_script(
1883
+			'ee-moment',
1884
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1885
+			array('ee-moment-core'),
1886
+			EVENT_ESPRESSO_VERSION,
1887
+			true
1888
+		);
1889
+		wp_register_script(
1890
+			'ee-datepicker',
1891
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1892
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1893
+			EVENT_ESPRESSO_VERSION,
1894
+			true
1895
+		);
1896
+		//google charts
1897
+		wp_register_script(
1898
+			'google-charts',
1899
+			'https://www.gstatic.com/charts/loader.js',
1900
+			array(),
1901
+			EVENT_ESPRESSO_VERSION,
1902
+			false
1903
+		);
1904
+		// ENQUEUE ALL BASICS BY DEFAULT
1905
+		wp_enqueue_style('ee-admin-css');
1906
+		wp_enqueue_script('ee_admin_js');
1907
+		wp_enqueue_script('ee-accounting');
1908
+		wp_enqueue_script('jquery-validate');
1909
+		//taking care of metaboxes
1910
+		if (
1911
+			empty($this->_cpt_route)
1912
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1913
+		) {
1914
+			wp_enqueue_script('dashboard');
1915
+		}
1916
+		// LOCALIZED DATA
1917
+		//localize script for ajax lazy loading
1918
+		$lazy_loader_container_ids = apply_filters(
1919
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1920
+			array('espresso_news_post_box_content')
1921
+		);
1922
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1923
+		/**
1924
+		 * help tour stuff
1925
+		 */
1926
+		if (! empty($this->_help_tour)) {
1927
+			//register the js for kicking things off
1928
+			wp_enqueue_script(
1929
+				'ee-help-tour',
1930
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
1931
+				array('jquery-joyride'),
1932
+				EVENT_ESPRESSO_VERSION,
1933
+				true
1934
+			);
1935
+			//setup tours for the js tour object
1936
+			foreach ($this->_help_tour['tours'] as $tour) {
1937
+				$tours[] = array(
1938
+					'id'      => $tour->get_slug(),
1939
+					'options' => $tour->get_options(),
1940
+				);
1941
+			}
1942
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1943
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1944
+		}
1945
+	}
1946
+
1947
+
1948
+
1949
+	/**
1950
+	 *        admin_footer_scripts_eei18n_js_strings
1951
+	 *
1952
+	 * @access        public
1953
+	 * @return        void
1954
+	 */
1955
+	public function admin_footer_scripts_eei18n_js_strings()
1956
+	{
1957
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1958
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __(
1959
+			'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!!!',
1960
+			'event_espresso'
1961
+		);
1962
+		EE_Registry::$i18n_js_strings['January']        = __('January', 'event_espresso');
1963
+		EE_Registry::$i18n_js_strings['February']       = __('February', 'event_espresso');
1964
+		EE_Registry::$i18n_js_strings['March']          = __('March', 'event_espresso');
1965
+		EE_Registry::$i18n_js_strings['April']          = __('April', 'event_espresso');
1966
+		EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1967
+		EE_Registry::$i18n_js_strings['June']           = __('June', 'event_espresso');
1968
+		EE_Registry::$i18n_js_strings['July']           = __('July', 'event_espresso');
1969
+		EE_Registry::$i18n_js_strings['August']         = __('August', 'event_espresso');
1970
+		EE_Registry::$i18n_js_strings['September']      = __('September', 'event_espresso');
1971
+		EE_Registry::$i18n_js_strings['October']        = __('October', 'event_espresso');
1972
+		EE_Registry::$i18n_js_strings['November']       = __('November', 'event_espresso');
1973
+		EE_Registry::$i18n_js_strings['December']       = __('December', 'event_espresso');
1974
+		EE_Registry::$i18n_js_strings['Jan']            = __('Jan', 'event_espresso');
1975
+		EE_Registry::$i18n_js_strings['Feb']            = __('Feb', 'event_espresso');
1976
+		EE_Registry::$i18n_js_strings['Mar']            = __('Mar', 'event_espresso');
1977
+		EE_Registry::$i18n_js_strings['Apr']            = __('Apr', 'event_espresso');
1978
+		EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1979
+		EE_Registry::$i18n_js_strings['Jun']            = __('Jun', 'event_espresso');
1980
+		EE_Registry::$i18n_js_strings['Jul']            = __('Jul', 'event_espresso');
1981
+		EE_Registry::$i18n_js_strings['Aug']            = __('Aug', 'event_espresso');
1982
+		EE_Registry::$i18n_js_strings['Sep']            = __('Sep', 'event_espresso');
1983
+		EE_Registry::$i18n_js_strings['Oct']            = __('Oct', 'event_espresso');
1984
+		EE_Registry::$i18n_js_strings['Nov']            = __('Nov', 'event_espresso');
1985
+		EE_Registry::$i18n_js_strings['Dec']            = __('Dec', 'event_espresso');
1986
+		EE_Registry::$i18n_js_strings['Sunday']         = __('Sunday', 'event_espresso');
1987
+		EE_Registry::$i18n_js_strings['Monday']         = __('Monday', 'event_espresso');
1988
+		EE_Registry::$i18n_js_strings['Tuesday']        = __('Tuesday', 'event_espresso');
1989
+		EE_Registry::$i18n_js_strings['Wednesday']      = __('Wednesday', 'event_espresso');
1990
+		EE_Registry::$i18n_js_strings['Thursday']       = __('Thursday', 'event_espresso');
1991
+		EE_Registry::$i18n_js_strings['Friday']         = __('Friday', 'event_espresso');
1992
+		EE_Registry::$i18n_js_strings['Saturday']       = __('Saturday', 'event_espresso');
1993
+		EE_Registry::$i18n_js_strings['Sun']            = __('Sun', 'event_espresso');
1994
+		EE_Registry::$i18n_js_strings['Mon']            = __('Mon', 'event_espresso');
1995
+		EE_Registry::$i18n_js_strings['Tue']            = __('Tue', 'event_espresso');
1996
+		EE_Registry::$i18n_js_strings['Wed']            = __('Wed', 'event_espresso');
1997
+		EE_Registry::$i18n_js_strings['Thu']            = __('Thu', 'event_espresso');
1998
+		EE_Registry::$i18n_js_strings['Fri']            = __('Fri', 'event_espresso');
1999
+		EE_Registry::$i18n_js_strings['Sat']            = __('Sat', 'event_espresso');
2000
+	}
2001
+
2002
+
2003
+
2004
+	/**
2005
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2006
+	 *
2007
+	 * @access        public
2008
+	 * @return        void
2009
+	 */
2010
+	public function add_xdebug_style()
2011
+	{
2012
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2013
+	}
2014
+
2015
+
2016
+	/************************/
2017
+	/** LIST TABLE METHODS **/
2018
+	/************************/
2019
+	/**
2020
+	 * this sets up the list table if the current view requires it.
2021
+	 *
2022
+	 * @access protected
2023
+	 * @return void
2024
+	 */
2025
+	protected function _set_list_table()
2026
+	{
2027
+		//first is this a list_table view?
2028
+		if (! isset($this->_route_config['list_table'])) {
2029
+			return;
2030
+		} //not a list_table view so get out.
2031
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
2032
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
2033
+			//user error msg
2034
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
2035
+			//developer error msg
2036
+			$error_msg .= '||' . sprintf(
2037
+					__(
2038
+						'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.',
2039
+						'event_espresso'
2040
+					),
2041
+					$this->_req_action,
2042
+					'_set_list_table_views_' . $this->_req_action
2043
+				);
2044
+			throw new EE_Error($error_msg);
2045
+		}
2046
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2047
+		$this->_views = apply_filters(
2048
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2049
+			$this->_views
2050
+		);
2051
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2052
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2053
+		$this->_set_list_table_view();
2054
+		$this->_set_list_table_object();
2055
+	}
2056
+
2057
+
2058
+
2059
+	/**
2060
+	 *        set current view for List Table
2061
+	 *
2062
+	 * @access public
2063
+	 * @return array
2064
+	 */
2065
+	protected function _set_list_table_view()
2066
+	{
2067
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2068
+		// looking at active items or dumpster diving ?
2069
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2070
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2071
+		} else {
2072
+			$this->_view = sanitize_key($this->_req_data['status']);
2073
+		}
2074
+	}
2075
+
2076
+
2077
+
2078
+	/**
2079
+	 * _set_list_table_object
2080
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2081
+	 *
2082
+	 * @throws \EE_Error
2083
+	 */
2084
+	protected function _set_list_table_object()
2085
+	{
2086
+		if (isset($this->_route_config['list_table'])) {
2087
+			if (! class_exists($this->_route_config['list_table'])) {
2088
+				throw new EE_Error(
2089
+					sprintf(
2090
+						__(
2091
+							'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.',
2092
+							'event_espresso'
2093
+						),
2094
+						$this->_route_config['list_table'],
2095
+						get_class($this)
2096
+					)
2097
+				);
2098
+			}
2099
+			$list_table               = $this->_route_config['list_table'];
2100
+			$this->_list_table_object = new $list_table($this);
2101
+		}
2102
+	}
2103
+
2104
+
2105
+
2106
+	/**
2107
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2108
+	 *
2109
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2110
+	 *                                                    urls.  The array should be indexed by the view it is being
2111
+	 *                                                    added to.
2112
+	 * @return array
2113
+	 */
2114
+	public function get_list_table_view_RLs($extra_query_args = array())
2115
+	{
2116
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2117
+		if (empty($this->_views)) {
2118
+			$this->_views = array();
2119
+		}
2120
+		// cycle thru views
2121
+		foreach ($this->_views as $key => $view) {
2122
+			$query_args = array();
2123
+			// check for current view
2124
+			$this->_views[$key]['class']               = $this->_view == $view['slug'] ? 'current' : '';
2125
+			$query_args['action']                      = $this->_req_action;
2126
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2127
+			$query_args['status']                      = $view['slug'];
2128
+			//merge any other arguments sent in.
2129
+			if (isset($extra_query_args[$view['slug']])) {
2130
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2131
+			}
2132
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2133
+		}
2134
+		return $this->_views;
2135
+	}
2136
+
2137
+
2138
+
2139
+	/**
2140
+	 * _entries_per_page_dropdown
2141
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
2142
+	 *
2143
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2144
+	 *         WP does it.
2145
+	 * @access protected
2146
+	 * @param int $max_entries total number of rows in the table
2147
+	 * @return string
2148
+	 */
2149
+	protected function _entries_per_page_dropdown($max_entries = false)
2150
+	{
2151
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2152
+		$values   = array(10, 25, 50, 100);
2153
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2154
+		if ($max_entries) {
2155
+			$values[] = $max_entries;
2156
+			sort($values);
2157
+		}
2158
+		$entries_per_page_dropdown = '
2159 2159
 			<div id="entries-per-page-dv" class="alignleft actions">
2160 2160
 				<label class="hide-if-no-js">
2161 2161
 					Show
2162 2162
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2163
-        foreach ($values as $value) {
2164
-            if ($value < $max_entries) {
2165
-                $selected                  = $value == $per_page ? ' selected="' . $per_page . '"' : '';
2166
-                $entries_per_page_dropdown .= '
2163
+		foreach ($values as $value) {
2164
+			if ($value < $max_entries) {
2165
+				$selected                  = $value == $per_page ? ' selected="' . $per_page . '"' : '';
2166
+				$entries_per_page_dropdown .= '
2167 2167
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2168
-            }
2169
-        }
2170
-        $selected                  = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
2171
-        $entries_per_page_dropdown .= '
2168
+			}
2169
+		}
2170
+		$selected                  = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
2171
+		$entries_per_page_dropdown .= '
2172 2172
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2173
-        $entries_per_page_dropdown .= '
2173
+		$entries_per_page_dropdown .= '
2174 2174
 					</select>
2175 2175
 					entries
2176 2176
 				</label>
2177 2177
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2178 2178
 			</div>
2179 2179
 		';
2180
-        return $entries_per_page_dropdown;
2181
-    }
2182
-
2183
-
2184
-
2185
-    /**
2186
-     *        _set_search_attributes
2187
-     *
2188
-     * @access        protected
2189
-     * @return        void
2190
-     */
2191
-    public function _set_search_attributes()
2192
-    {
2193
-        $this->_template_args['search']['btn_label'] = sprintf(
2194
-            __('Search %s', 'event_espresso'),
2195
-            empty($this->_search_btn_label) ? $this->page_label
2196
-                : $this->_search_btn_label
2197
-        );
2198
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2199
-    }
2200
-
2201
-    /*** END LIST TABLE METHODS **/
2202
-    /*****************************/
2203
-    /**
2204
-     *        _add_registered_metaboxes
2205
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2206
-     *
2207
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2208
-     * @access private
2209
-     * @return void
2210
-     */
2211
-    private function _add_registered_meta_boxes()
2212
-    {
2213
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2214
-        //we only add meta boxes if the page_route calls for it
2215
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2216
-            && is_array(
2217
-                $this->_route_config['metaboxes']
2218
-            )
2219
-        ) {
2220
-            // this simply loops through the callbacks provided
2221
-            // and checks if there is a corresponding callback registered by the child
2222
-            // if there is then we go ahead and process the metabox loader.
2223
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2224
-                // first check for Closures
2225
-                if ($metabox_callback instanceof Closure) {
2226
-                    $result = $metabox_callback();
2227
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2228
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2229
-                } else {
2230
-                    $result = call_user_func(array($this, &$metabox_callback));
2231
-                }
2232
-                if ($result === false) {
2233
-                    // user error msg
2234
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
2235
-                    // developer error msg
2236
-                    $error_msg .= '||' . sprintf(
2237
-                            __(
2238
-                                '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.',
2239
-                                'event_espresso'
2240
-                            ),
2241
-                            $metabox_callback
2242
-                        );
2243
-                    throw new EE_Error($error_msg);
2244
-                }
2245
-            }
2246
-        }
2247
-    }
2248
-
2249
-
2250
-
2251
-    /**
2252
-     * _add_screen_columns
2253
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2254
-     * the dynamic column template and we'll setup the column options for the page.
2255
-     *
2256
-     * @access private
2257
-     * @return void
2258
-     */
2259
-    private function _add_screen_columns()
2260
-    {
2261
-        if (
2262
-            is_array($this->_route_config)
2263
-            && isset($this->_route_config['columns'])
2264
-            && is_array($this->_route_config['columns'])
2265
-            && count($this->_route_config['columns']) === 2
2266
-        ) {
2267
-            add_screen_option(
2268
-                'layout_columns',
2269
-                array(
2270
-                    'max'     => (int)$this->_route_config['columns'][0],
2271
-                    'default' => (int)$this->_route_config['columns'][1],
2272
-                )
2273
-            );
2274
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2275
-            $screen_id                                           = $this->_current_screen->id;
2276
-            $screen_columns                                      = (int)get_user_option("screen_layout_$screen_id");
2277
-            $total_columns                                       = ! empty($screen_columns) ? $screen_columns
2278
-                : $this->_route_config['columns'][1];
2279
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2280
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2281
-            $this->_template_args['screen']                      = $this->_current_screen;
2282
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2283
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2284
-            //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2285
-            $this->_route_config['has_metaboxes'] = true;
2286
-        }
2287
-    }
2288
-
2289
-
2290
-
2291
-    /**********************************/
2292
-    /** GLOBALLY AVAILABLE METABOXES **/
2293
-    /**
2294
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2295
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2296
-     * these get loaded on.
2297
-     */
2298
-    private function _espresso_news_post_box()
2299
-    {
2300
-        $news_box_title = apply_filters(
2301
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2302
-            __('New @ Event Espresso', 'event_espresso')
2303
-        );
2304
-        add_meta_box(
2305
-            'espresso_news_post_box',
2306
-            $news_box_title,
2307
-            array(
2308
-                $this,
2309
-                'espresso_news_post_box',
2310
-            ),
2311
-            $this->_wp_page_slug,
2312
-            'side'
2313
-        );
2314
-    }
2315
-
2316
-
2317
-
2318
-    /**
2319
-     * Code for setting up espresso ratings request metabox.
2320
-     */
2321
-    protected function _espresso_ratings_request()
2322
-    {
2323
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2324
-            return '';
2325
-        }
2326
-        $ratings_box_title = apply_filters(
2327
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2328
-            __('Keep Event Espresso Decaf Free', 'event_espresso')
2329
-        );
2330
-        add_meta_box(
2331
-            'espresso_ratings_request',
2332
-            $ratings_box_title,
2333
-            array(
2334
-                $this,
2335
-                'espresso_ratings_request',
2336
-            ),
2337
-            $this->_wp_page_slug,
2338
-            'side'
2339
-        );
2340
-    }
2341
-
2342
-
2343
-
2344
-    /**
2345
-     * Code for setting up espresso ratings request metabox content.
2346
-     */
2347
-    public function espresso_ratings_request()
2348
-    {
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2350
-        EEH_Template::display_template($template_path, array());
2351
-    }
2352
-
2353
-
2354
-
2355
-    public static function cached_rss_display($rss_id, $url)
2356
-    {
2357
-        $loading    = '<p class="widget-loading hide-if-no-js">'
2358
-                      . __('Loading&#8230;')
2359
-                      . '</p><p class="hide-if-js">'
2360
-                      . __('This widget requires JavaScript.')
2361
-                      . '</p>';
2362
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2363
-        $pre        = '<div class="espresso-rss-display">' . "\n\t";
2364
-        $pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2365
-        $post       = '</div>' . "\n";
2366
-        $cache_key  = 'ee_rss_' . md5($rss_id);
2367
-        if (false != ($output = get_transient($cache_key))) {
2368
-            echo $pre . $output . $post;
2369
-            return true;
2370
-        }
2371
-        if (! $doing_ajax) {
2372
-            echo $pre . $loading . $post;
2373
-            return false;
2374
-        }
2375
-        ob_start();
2376
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2377
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2378
-        return true;
2379
-    }
2380
-
2381
-
2382
-
2383
-    public function espresso_news_post_box()
2384
-    {
2385
-        ?>
2180
+		return $entries_per_page_dropdown;
2181
+	}
2182
+
2183
+
2184
+
2185
+	/**
2186
+	 *        _set_search_attributes
2187
+	 *
2188
+	 * @access        protected
2189
+	 * @return        void
2190
+	 */
2191
+	public function _set_search_attributes()
2192
+	{
2193
+		$this->_template_args['search']['btn_label'] = sprintf(
2194
+			__('Search %s', 'event_espresso'),
2195
+			empty($this->_search_btn_label) ? $this->page_label
2196
+				: $this->_search_btn_label
2197
+		);
2198
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2199
+	}
2200
+
2201
+	/*** END LIST TABLE METHODS **/
2202
+	/*****************************/
2203
+	/**
2204
+	 *        _add_registered_metaboxes
2205
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2206
+	 *
2207
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2208
+	 * @access private
2209
+	 * @return void
2210
+	 */
2211
+	private function _add_registered_meta_boxes()
2212
+	{
2213
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2214
+		//we only add meta boxes if the page_route calls for it
2215
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2216
+			&& is_array(
2217
+				$this->_route_config['metaboxes']
2218
+			)
2219
+		) {
2220
+			// this simply loops through the callbacks provided
2221
+			// and checks if there is a corresponding callback registered by the child
2222
+			// if there is then we go ahead and process the metabox loader.
2223
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2224
+				// first check for Closures
2225
+				if ($metabox_callback instanceof Closure) {
2226
+					$result = $metabox_callback();
2227
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2228
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2229
+				} else {
2230
+					$result = call_user_func(array($this, &$metabox_callback));
2231
+				}
2232
+				if ($result === false) {
2233
+					// user error msg
2234
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
2235
+					// developer error msg
2236
+					$error_msg .= '||' . sprintf(
2237
+							__(
2238
+								'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.',
2239
+								'event_espresso'
2240
+							),
2241
+							$metabox_callback
2242
+						);
2243
+					throw new EE_Error($error_msg);
2244
+				}
2245
+			}
2246
+		}
2247
+	}
2248
+
2249
+
2250
+
2251
+	/**
2252
+	 * _add_screen_columns
2253
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2254
+	 * the dynamic column template and we'll setup the column options for the page.
2255
+	 *
2256
+	 * @access private
2257
+	 * @return void
2258
+	 */
2259
+	private function _add_screen_columns()
2260
+	{
2261
+		if (
2262
+			is_array($this->_route_config)
2263
+			&& isset($this->_route_config['columns'])
2264
+			&& is_array($this->_route_config['columns'])
2265
+			&& count($this->_route_config['columns']) === 2
2266
+		) {
2267
+			add_screen_option(
2268
+				'layout_columns',
2269
+				array(
2270
+					'max'     => (int)$this->_route_config['columns'][0],
2271
+					'default' => (int)$this->_route_config['columns'][1],
2272
+				)
2273
+			);
2274
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2275
+			$screen_id                                           = $this->_current_screen->id;
2276
+			$screen_columns                                      = (int)get_user_option("screen_layout_$screen_id");
2277
+			$total_columns                                       = ! empty($screen_columns) ? $screen_columns
2278
+				: $this->_route_config['columns'][1];
2279
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2280
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2281
+			$this->_template_args['screen']                      = $this->_current_screen;
2282
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2283
+																   . 'admin_details_metabox_column_wrapper.template.php';
2284
+			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2285
+			$this->_route_config['has_metaboxes'] = true;
2286
+		}
2287
+	}
2288
+
2289
+
2290
+
2291
+	/**********************************/
2292
+	/** GLOBALLY AVAILABLE METABOXES **/
2293
+	/**
2294
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2295
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2296
+	 * these get loaded on.
2297
+	 */
2298
+	private function _espresso_news_post_box()
2299
+	{
2300
+		$news_box_title = apply_filters(
2301
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2302
+			__('New @ Event Espresso', 'event_espresso')
2303
+		);
2304
+		add_meta_box(
2305
+			'espresso_news_post_box',
2306
+			$news_box_title,
2307
+			array(
2308
+				$this,
2309
+				'espresso_news_post_box',
2310
+			),
2311
+			$this->_wp_page_slug,
2312
+			'side'
2313
+		);
2314
+	}
2315
+
2316
+
2317
+
2318
+	/**
2319
+	 * Code for setting up espresso ratings request metabox.
2320
+	 */
2321
+	protected function _espresso_ratings_request()
2322
+	{
2323
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2324
+			return '';
2325
+		}
2326
+		$ratings_box_title = apply_filters(
2327
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2328
+			__('Keep Event Espresso Decaf Free', 'event_espresso')
2329
+		);
2330
+		add_meta_box(
2331
+			'espresso_ratings_request',
2332
+			$ratings_box_title,
2333
+			array(
2334
+				$this,
2335
+				'espresso_ratings_request',
2336
+			),
2337
+			$this->_wp_page_slug,
2338
+			'side'
2339
+		);
2340
+	}
2341
+
2342
+
2343
+
2344
+	/**
2345
+	 * Code for setting up espresso ratings request metabox content.
2346
+	 */
2347
+	public function espresso_ratings_request()
2348
+	{
2349
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2350
+		EEH_Template::display_template($template_path, array());
2351
+	}
2352
+
2353
+
2354
+
2355
+	public static function cached_rss_display($rss_id, $url)
2356
+	{
2357
+		$loading    = '<p class="widget-loading hide-if-no-js">'
2358
+					  . __('Loading&#8230;')
2359
+					  . '</p><p class="hide-if-js">'
2360
+					  . __('This widget requires JavaScript.')
2361
+					  . '</p>';
2362
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2363
+		$pre        = '<div class="espresso-rss-display">' . "\n\t";
2364
+		$pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2365
+		$post       = '</div>' . "\n";
2366
+		$cache_key  = 'ee_rss_' . md5($rss_id);
2367
+		if (false != ($output = get_transient($cache_key))) {
2368
+			echo $pre . $output . $post;
2369
+			return true;
2370
+		}
2371
+		if (! $doing_ajax) {
2372
+			echo $pre . $loading . $post;
2373
+			return false;
2374
+		}
2375
+		ob_start();
2376
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2377
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2378
+		return true;
2379
+	}
2380
+
2381
+
2382
+
2383
+	public function espresso_news_post_box()
2384
+	{
2385
+		?>
2386 2386
         <div class="padding">
2387 2387
             <div id="espresso_news_post_box_content" class="infolinks">
2388 2388
                 <?php
2389
-                // Get RSS Feed(s)
2390
-                $feed_url = apply_filters(
2391
-                    'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2392
-                    'http://eventespresso.com/feed/'
2393
-                );
2394
-                $url      = urlencode($feed_url);
2395
-                self::cached_rss_display('espresso_news_post_box_content', $url);
2396
-                ?>
2389
+				// Get RSS Feed(s)
2390
+				$feed_url = apply_filters(
2391
+					'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2392
+					'http://eventespresso.com/feed/'
2393
+				);
2394
+				$url      = urlencode($feed_url);
2395
+				self::cached_rss_display('espresso_news_post_box_content', $url);
2396
+				?>
2397 2397
             </div>
2398 2398
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2399 2399
         </div>
2400 2400
         <?php
2401
-    }
2402
-
2403
-
2404
-
2405
-    private function _espresso_links_post_box()
2406
-    {
2407
-        //Hiding until we actually have content to put in here...
2408
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2409
-    }
2410
-
2411
-
2412
-
2413
-    public function espresso_links_post_box()
2414
-    {
2415
-        //Hiding until we actually have content to put in here...
2416
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2417
-        //EEH_Template::display_template( $templatepath );
2418
-    }
2419
-
2420
-
2421
-
2422
-    protected function _espresso_sponsors_post_box()
2423
-    {
2424
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2425
-        if ($show_sponsors) {
2426
-            add_meta_box(
2427
-                'espresso_sponsors_post_box',
2428
-                __('Event Espresso Highlights', 'event_espresso'),
2429
-                array($this, 'espresso_sponsors_post_box'),
2430
-                $this->_wp_page_slug,
2431
-                'side'
2432
-            );
2433
-        }
2434
-    }
2435
-
2436
-
2437
-
2438
-    public function espresso_sponsors_post_box()
2439
-    {
2440
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2441
-        EEH_Template::display_template($templatepath);
2442
-    }
2443
-
2444
-
2445
-
2446
-    private function _publish_post_box()
2447
-    {
2448
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2449
-        //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2450
-        if (! empty($this->_labels['publishbox'])) {
2451
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2452
-                : $this->_labels['publishbox'];
2453
-        } else {
2454
-            $box_label = __('Publish', 'event_espresso');
2455
-        }
2456
-        $box_label = apply_filters(
2457
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2458
-            $box_label,
2459
-            $this->_req_action,
2460
-            $this
2461
-        );
2462
-        add_meta_box(
2463
-            $meta_box_ref,
2464
-            $box_label,
2465
-            array($this, 'editor_overview'),
2466
-            $this->_current_screen->id,
2467
-            'side',
2468
-            'high'
2469
-        );
2470
-    }
2471
-
2472
-
2473
-
2474
-    public function editor_overview()
2475
-    {
2476
-        //if we have extra content set let's add it in if not make sure its empty
2477
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2478
-            ? $this->_template_args['publish_box_extra_content'] : '';
2479
-        $template_path                                     = EE_ADMIN_TEMPLATE
2480
-                                                             . 'admin_details_publish_metabox.template.php';
2481
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2482
-    }
2483
-
2484
-
2485
-    /** end of globally available metaboxes section **/
2486
-    /*************************************************/
2487
-    /**
2488
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2489
-     * protected method.
2490
-     *
2491
-     * @see   $this->_set_publish_post_box_vars for param details
2492
-     * @since 4.6.0
2493
-     */
2494
-    public function set_publish_post_box_vars(
2495
-        $name = null,
2496
-        $id = false,
2497
-        $delete = false,
2498
-        $save_close_redirect_URL = null,
2499
-        $both_btns = true
2500
-    ) {
2501
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2502
-    }
2503
-
2504
-
2505
-
2506
-    /**
2507
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2508
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2509
-     * save, and save and close buttons to work properly, then you will want to include a
2510
-     * values for the name and id arguments.
2511
-     *
2512
-     * @todo  Add in validation for name/id arguments.
2513
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2514
-     * @param    int     $id                      id attached to the item published
2515
-     * @param    string  $delete                  page route callback for the delete action
2516
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2517
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2518
-     *                                            the Save button
2519
-     * @throws \EE_Error
2520
-     */
2521
-    protected function _set_publish_post_box_vars(
2522
-        $name = '',
2523
-        $id = 0,
2524
-        $delete = '',
2525
-        $save_close_redirect_URL = '',
2526
-        $both_btns = true
2527
-    ) {
2528
-        // if Save & Close, use a custom redirect URL or default to the main page?
2529
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL
2530
-            : $this->_admin_base_url;
2531
-        // create the Save & Close and Save buttons
2532
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2533
-        //if we have extra content set let's add it in if not make sure its empty
2534
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2535
-            ? $this->_template_args['publish_box_extra_content'] : '';
2536
-        if ($delete && ! empty($id)) {
2537
-            //make sure we have a default if just true is sent.
2538
-            $delete           = ! empty($delete) ? $delete : 'delete';
2539
-            $delete_link_args = array($name => $id);
2540
-            $delete           = $this->get_action_link_or_button(
2541
-                $delete,
2542
-                $delete,
2543
-                $delete_link_args,
2544
-                'submitdelete deletion',
2545
-                '',
2546
-                false
2547
-            );
2548
-        }
2549
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2550
-        if (! empty($name) && ! empty($id)) {
2551
-            $hidden_field_arr[$name] = array(
2552
-                'type'  => 'hidden',
2553
-                'value' => $id,
2554
-            );
2555
-            $hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2556
-        } else {
2557
-            $hf = '';
2558
-        }
2559
-        // add hidden field
2560
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2561
-    }
2562
-
2563
-
2564
-
2565
-    /**
2566
-     *        displays an error message to ppl who have javascript disabled
2567
-     *
2568
-     * @access        private
2569
-     * @return        string
2570
-     */
2571
-    private function _display_no_javascript_warning()
2572
-    {
2573
-        ?>
2401
+	}
2402
+
2403
+
2404
+
2405
+	private function _espresso_links_post_box()
2406
+	{
2407
+		//Hiding until we actually have content to put in here...
2408
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2409
+	}
2410
+
2411
+
2412
+
2413
+	public function espresso_links_post_box()
2414
+	{
2415
+		//Hiding until we actually have content to put in here...
2416
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2417
+		//EEH_Template::display_template( $templatepath );
2418
+	}
2419
+
2420
+
2421
+
2422
+	protected function _espresso_sponsors_post_box()
2423
+	{
2424
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2425
+		if ($show_sponsors) {
2426
+			add_meta_box(
2427
+				'espresso_sponsors_post_box',
2428
+				__('Event Espresso Highlights', 'event_espresso'),
2429
+				array($this, 'espresso_sponsors_post_box'),
2430
+				$this->_wp_page_slug,
2431
+				'side'
2432
+			);
2433
+		}
2434
+	}
2435
+
2436
+
2437
+
2438
+	public function espresso_sponsors_post_box()
2439
+	{
2440
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2441
+		EEH_Template::display_template($templatepath);
2442
+	}
2443
+
2444
+
2445
+
2446
+	private function _publish_post_box()
2447
+	{
2448
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2449
+		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2450
+		if (! empty($this->_labels['publishbox'])) {
2451
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2452
+				: $this->_labels['publishbox'];
2453
+		} else {
2454
+			$box_label = __('Publish', 'event_espresso');
2455
+		}
2456
+		$box_label = apply_filters(
2457
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2458
+			$box_label,
2459
+			$this->_req_action,
2460
+			$this
2461
+		);
2462
+		add_meta_box(
2463
+			$meta_box_ref,
2464
+			$box_label,
2465
+			array($this, 'editor_overview'),
2466
+			$this->_current_screen->id,
2467
+			'side',
2468
+			'high'
2469
+		);
2470
+	}
2471
+
2472
+
2473
+
2474
+	public function editor_overview()
2475
+	{
2476
+		//if we have extra content set let's add it in if not make sure its empty
2477
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2478
+			? $this->_template_args['publish_box_extra_content'] : '';
2479
+		$template_path                                     = EE_ADMIN_TEMPLATE
2480
+															 . 'admin_details_publish_metabox.template.php';
2481
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2482
+	}
2483
+
2484
+
2485
+	/** end of globally available metaboxes section **/
2486
+	/*************************************************/
2487
+	/**
2488
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2489
+	 * protected method.
2490
+	 *
2491
+	 * @see   $this->_set_publish_post_box_vars for param details
2492
+	 * @since 4.6.0
2493
+	 */
2494
+	public function set_publish_post_box_vars(
2495
+		$name = null,
2496
+		$id = false,
2497
+		$delete = false,
2498
+		$save_close_redirect_URL = null,
2499
+		$both_btns = true
2500
+	) {
2501
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2502
+	}
2503
+
2504
+
2505
+
2506
+	/**
2507
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2508
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2509
+	 * save, and save and close buttons to work properly, then you will want to include a
2510
+	 * values for the name and id arguments.
2511
+	 *
2512
+	 * @todo  Add in validation for name/id arguments.
2513
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2514
+	 * @param    int     $id                      id attached to the item published
2515
+	 * @param    string  $delete                  page route callback for the delete action
2516
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2517
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2518
+	 *                                            the Save button
2519
+	 * @throws \EE_Error
2520
+	 */
2521
+	protected function _set_publish_post_box_vars(
2522
+		$name = '',
2523
+		$id = 0,
2524
+		$delete = '',
2525
+		$save_close_redirect_URL = '',
2526
+		$both_btns = true
2527
+	) {
2528
+		// if Save & Close, use a custom redirect URL or default to the main page?
2529
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL
2530
+			: $this->_admin_base_url;
2531
+		// create the Save & Close and Save buttons
2532
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2533
+		//if we have extra content set let's add it in if not make sure its empty
2534
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2535
+			? $this->_template_args['publish_box_extra_content'] : '';
2536
+		if ($delete && ! empty($id)) {
2537
+			//make sure we have a default if just true is sent.
2538
+			$delete           = ! empty($delete) ? $delete : 'delete';
2539
+			$delete_link_args = array($name => $id);
2540
+			$delete           = $this->get_action_link_or_button(
2541
+				$delete,
2542
+				$delete,
2543
+				$delete_link_args,
2544
+				'submitdelete deletion',
2545
+				'',
2546
+				false
2547
+			);
2548
+		}
2549
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2550
+		if (! empty($name) && ! empty($id)) {
2551
+			$hidden_field_arr[$name] = array(
2552
+				'type'  => 'hidden',
2553
+				'value' => $id,
2554
+			);
2555
+			$hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2556
+		} else {
2557
+			$hf = '';
2558
+		}
2559
+		// add hidden field
2560
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2561
+	}
2562
+
2563
+
2564
+
2565
+	/**
2566
+	 *        displays an error message to ppl who have javascript disabled
2567
+	 *
2568
+	 * @access        private
2569
+	 * @return        string
2570
+	 */
2571
+	private function _display_no_javascript_warning()
2572
+	{
2573
+		?>
2574 2574
         <noscript>
2575 2575
             <div id="no-js-message" class="error">
2576 2576
                 <p style="font-size:1.3em;">
2577 2577
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2578 2578
                     <?php esc_html_e(
2579
-                        '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.',
2580
-                        'event_espresso'
2581
-                    ); ?>
2579
+						'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.',
2580
+						'event_espresso'
2581
+					); ?>
2582 2582
                 </p>
2583 2583
             </div>
2584 2584
         </noscript>
2585 2585
         <?php
2586
-    }
2586
+	}
2587 2587
 
2588 2588
 
2589 2589
 
2590
-    /**
2591
-     *        displays espresso success and/or error notices
2592
-     *
2593
-     * @access        private
2594
-     * @return        string
2595
-     */
2596
-    private function _display_espresso_notices()
2597
-    {
2598
-        $notices = $this->_get_transient(true);
2599
-        echo stripslashes($notices);
2600
-    }
2590
+	/**
2591
+	 *        displays espresso success and/or error notices
2592
+	 *
2593
+	 * @access        private
2594
+	 * @return        string
2595
+	 */
2596
+	private function _display_espresso_notices()
2597
+	{
2598
+		$notices = $this->_get_transient(true);
2599
+		echo stripslashes($notices);
2600
+	}
2601 2601
 
2602 2602
 
2603 2603
 
2604
-    /**
2605
-     *        spinny things pacify the masses
2606
-     *
2607
-     * @access private
2608
-     * @return string
2609
-     */
2610
-    protected function _add_admin_page_ajax_loading_img()
2611
-    {
2612
-        ?>
2604
+	/**
2605
+	 *        spinny things pacify the masses
2606
+	 *
2607
+	 * @access private
2608
+	 * @return string
2609
+	 */
2610
+	protected function _add_admin_page_ajax_loading_img()
2611
+	{
2612
+		?>
2613 2613
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2614 2614
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e(
2615
-                    'loading...',
2616
-                    'event_espresso'
2617
-                ); ?></span>
2615
+					'loading...',
2616
+					'event_espresso'
2617
+				); ?></span>
2618 2618
         </div>
2619 2619
         <?php
2620
-    }
2620
+	}
2621 2621
 
2622 2622
 
2623 2623
 
2624
-    /**
2625
-     *        add admin page overlay for modal boxes
2626
-     *
2627
-     * @access private
2628
-     * @return string
2629
-     */
2630
-    protected function _add_admin_page_overlay()
2631
-    {
2632
-        ?>
2624
+	/**
2625
+	 *        add admin page overlay for modal boxes
2626
+	 *
2627
+	 * @access private
2628
+	 * @return string
2629
+	 */
2630
+	protected function _add_admin_page_overlay()
2631
+	{
2632
+		?>
2633 2633
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2634 2634
         <?php
2635
-    }
2636
-
2637
-
2638
-
2639
-    /**
2640
-     * facade for add_meta_box
2641
-     *
2642
-     * @param string  $action        where the metabox get's displayed
2643
-     * @param string  $title         Title of Metabox (output in metabox header)
2644
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2645
-     *                               instead of the one created in here.
2646
-     * @param array   $callback_args an array of args supplied for the metabox
2647
-     * @param string  $column        what metabox column
2648
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2649
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2650
-     *                               created but just set our own callback for wp's add_meta_box.
2651
-     */
2652
-    public function _add_admin_page_meta_box(
2653
-        $action,
2654
-        $title,
2655
-        $callback,
2656
-        $callback_args,
2657
-        $column = 'normal',
2658
-        $priority = 'high',
2659
-        $create_func = true
2660
-    ) {
2661
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2662
-        //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.
2663
-        if (empty($callback_args) && $create_func) {
2664
-            $callback_args = array(
2665
-                'template_path' => $this->_template_path,
2666
-                'template_args' => $this->_template_args,
2667
-            );
2668
-        }
2669
-        //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)
2670
-        $call_back_func = $create_func ? create_function(
2671
-            '$post, $metabox',
2672
-            'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'
2673
-        ) : $callback;
2674
-        add_meta_box(
2675
-            str_replace('_', '-', $action) . '-mbox',
2676
-            $title,
2677
-            $call_back_func,
2678
-            $this->_wp_page_slug,
2679
-            $column,
2680
-            $priority,
2681
-            $callback_args
2682
-        );
2683
-    }
2684
-
2685
-
2686
-
2687
-    /**
2688
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2689
-     *
2690
-     * @return [type] [description]
2691
-     */
2692
-    public function display_admin_page_with_metabox_columns()
2693
-    {
2694
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2695
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2696
-            $this->_column_template_path,
2697
-            $this->_template_args,
2698
-            true
2699
-        );
2700
-        //the final wrapper
2701
-        $this->admin_page_wrapper();
2702
-    }
2703
-
2704
-
2705
-
2706
-    /**
2707
-     *        generates  HTML wrapper for an admin details page
2708
-     *
2709
-     * @access public
2710
-     * @return void
2711
-     */
2712
-    public function display_admin_page_with_sidebar()
2713
-    {
2714
-        $this->_display_admin_page(true);
2715
-    }
2716
-
2717
-
2718
-
2719
-    /**
2720
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2721
-     *
2722
-     * @access public
2723
-     * @return void
2724
-     */
2725
-    public function display_admin_page_with_no_sidebar()
2726
-    {
2727
-        $this->_display_admin_page();
2728
-    }
2729
-
2730
-
2731
-
2732
-    /**
2733
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2734
-     *
2735
-     * @access public
2736
-     * @return void
2737
-     */
2738
-    public function display_about_admin_page()
2739
-    {
2740
-        $this->_display_admin_page(false, true);
2741
-    }
2742
-
2743
-
2744
-
2745
-    /**
2746
-     * display_admin_page
2747
-     * contains the code for actually displaying an admin page
2748
-     *
2749
-     * @access private
2750
-     * @param  boolean $sidebar true with sidebar, false without
2751
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2752
-     * @return void
2753
-     */
2754
-    private function _display_admin_page($sidebar = false, $about = false)
2755
-    {
2756
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2757
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2758
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2759
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2760
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2761
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2762
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2763
-            ? 'poststuff'
2764
-            : 'espresso-default-admin';
2765
-        $template_path                                     = $sidebar
2766
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2767
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2768
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2769
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2770
-        }
2771
-        $template_path                                     = ! empty($this->_column_template_path)
2772
-            ? $this->_column_template_path : $template_path;
2773
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2774
-            ? $this->_template_args['admin_page_content'] : '';
2775
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2776
-            ? $this->_template_args['before_admin_page_content'] : '';
2777
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2778
-            ? $this->_template_args['after_admin_page_content'] : '';
2779
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2780
-            $template_path,
2781
-            $this->_template_args,
2782
-            true
2783
-        );
2784
-        // the final template wrapper
2785
-        $this->admin_page_wrapper($about);
2786
-    }
2787
-
2788
-
2789
-
2790
-    /**
2791
-     * This is used to display caf preview pages.
2792
-     *
2793
-     * @since 4.3.2
2794
-     * @param string $utm_campaign_source what is the key used for google analytics link
2795
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2796
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2797
-     * @return void
2798
-     * @throws \EE_Error
2799
-     */
2800
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2801
-    {
2802
-        //let's generate a default preview action button if there isn't one already present.
2803
-        $this->_labels['buttons']['buy_now']           = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2804
-        $buy_now_url                                   = add_query_arg(
2805
-            array(
2806
-                'ee_ver'       => 'ee4',
2807
-                'utm_source'   => 'ee4_plugin_admin',
2808
-                'utm_medium'   => 'link',
2809
-                'utm_campaign' => $utm_campaign_source,
2810
-                'utm_content'  => 'buy_now_button',
2811
-            ),
2812
-            'http://eventespresso.com/pricing/'
2813
-        );
2814
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2815
-            ? $this->get_action_link_or_button(
2816
-                '',
2817
-                'buy_now',
2818
-                array(),
2819
-                'button-primary button-large',
2820
-                $buy_now_url,
2821
-                true
2822
-            )
2823
-            : $this->_template_args['preview_action_button'];
2824
-        $template_path                                 = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2825
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2826
-            $template_path,
2827
-            $this->_template_args,
2828
-            true
2829
-        );
2830
-        $this->_display_admin_page($display_sidebar);
2831
-    }
2832
-
2833
-
2834
-
2835
-    /**
2836
-     * display_admin_list_table_page_with_sidebar
2837
-     * generates HTML wrapper for an admin_page with list_table
2838
-     *
2839
-     * @access public
2840
-     * @return void
2841
-     */
2842
-    public function display_admin_list_table_page_with_sidebar()
2843
-    {
2844
-        $this->_display_admin_list_table_page(true);
2845
-    }
2846
-
2847
-
2848
-
2849
-    /**
2850
-     * display_admin_list_table_page_with_no_sidebar
2851
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2852
-     *
2853
-     * @access public
2854
-     * @return void
2855
-     */
2856
-    public function display_admin_list_table_page_with_no_sidebar()
2857
-    {
2858
-        $this->_display_admin_list_table_page();
2859
-    }
2860
-
2861
-
2862
-
2863
-    /**
2864
-     * generates html wrapper for an admin_list_table page
2865
-     *
2866
-     * @access private
2867
-     * @param boolean $sidebar whether to display with sidebar or not.
2868
-     * @return void
2869
-     */
2870
-    private function _display_admin_list_table_page($sidebar = false)
2871
-    {
2872
-        //setup search attributes
2873
-        $this->_set_search_attributes();
2874
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2875
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2876
-        $this->_template_args['table_url']        = defined('DOING_AJAX')
2877
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2878
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2879
-        $this->_template_args['list_table']       = $this->_list_table_object;
2880
-        $this->_template_args['current_route']    = $this->_req_action;
2881
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2882
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2883
-        if (! empty($ajax_sorting_callback)) {
2884
-            $sortable_list_table_form_fields = wp_nonce_field(
2885
-                $ajax_sorting_callback . '_nonce',
2886
-                $ajax_sorting_callback . '_nonce',
2887
-                false,
2888
-                false
2889
-            );
2890
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2891
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2892
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2893
-                                                . $this->page_slug
2894
-                                                . '" />';
2895
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2896
-                                                . $ajax_sorting_callback
2897
-                                                . '" />';
2898
-        } else {
2899
-            $sortable_list_table_form_fields = '';
2900
-        }
2901
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2902
-        $hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
2903
-            ? $this->_template_args['list_table_hidden_fields'] : '';
2904
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2905
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2906
-                                                                    . $nonce_ref
2907
-                                                                    . '" value="'
2908
-                                                                    . wp_create_nonce($nonce_ref)
2909
-                                                                    . '">';
2910
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2911
-        //display message about search results?
2912
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2913
-            ? '<p class="ee-search-results">' . sprintf(
2914
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2915
-                trim($this->_req_data['s'], '%')
2916
-            ) . '</p>'
2917
-            : '';
2918
-        // filter before_list_table template arg
2919
-        $this->_template_args['before_list_table'] = apply_filters(
2920
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2921
-            $this->_template_args['before_list_table'],
2922
-            $this->page_slug,
2923
-            $this->_req_data,
2924
-            $this->_req_action
2925
-        );
2926
-        // convert to array and filter again
2927
-        // arrays are easier to inject new items in a specific location,
2928
-        // but would not be backwards compatible, so we have to add a new filter
2929
-        $this->_template_args['before_list_table'] = implode(
2930
-            " \n",
2931
-            (array)apply_filters(
2932
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2933
-                (array)$this->_template_args['before_list_table'],
2934
-                $this->page_slug,
2935
-                $this->_req_data,
2936
-                $this->_req_action
2937
-            )
2938
-        );
2939
-        // filter after_list_table template arg
2940
-        $this->_template_args['after_list_table'] = apply_filters(
2941
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2942
-            $this->_template_args['after_list_table'],
2943
-            $this->page_slug,
2944
-            $this->_req_data,
2945
-            $this->_req_action
2946
-        );
2947
-        // convert to array and filter again
2948
-        // arrays are easier to inject new items in a specific location,
2949
-        // but would not be backwards compatible, so we have to add a new filter
2950
-        $this->_template_args['after_list_table']   = implode(
2951
-            " \n",
2952
-            (array)apply_filters(
2953
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2954
-                (array)$this->_template_args['after_list_table'],
2955
-                $this->page_slug,
2956
-                $this->_req_data,
2957
-                $this->_req_action
2958
-            )
2959
-        );
2960
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2961
-            $template_path,
2962
-            $this->_template_args,
2963
-            true
2964
-        );
2965
-        // the final template wrapper
2966
-        if ($sidebar) {
2967
-            $this->display_admin_page_with_sidebar();
2968
-        } else {
2969
-            $this->display_admin_page_with_no_sidebar();
2970
-        }
2971
-    }
2972
-
2973
-
2974
-
2975
-    /**
2976
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2977
-     * html string for the legend.
2978
-     * $items are expected in an array in the following format:
2979
-     * $legend_items = array(
2980
-     *        'item_id' => array(
2981
-     *            'icon' => 'http://url_to_icon_being_described.png',
2982
-     *            'desc' => __('localized description of item');
2983
-     *        )
2984
-     * );
2985
-     *
2986
-     * @param  array $items see above for format of array
2987
-     * @return string        html string of legend
2988
-     */
2989
-    protected function _display_legend($items)
2990
-    {
2991
-        $this->_template_args['items'] = apply_filters(
2992
-            'FHEE__EE_Admin_Page___display_legend__items',
2993
-            (array)$items,
2994
-            $this
2995
-        );
2996
-        $legend_template               = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2997
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2998
-    }
2999
-
3000
-
3001
-    /**
3002
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3003
-     * The returned json object is created from an array in the following format:
3004
-     * array(
3005
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3006
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3007
-     *  'notices' => '', // - contains any EE_Error formatted notices
3008
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3009
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3010
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3011
-     *  that might be included in here)
3012
-     * )
3013
-     * The json object is populated by whatever is set in the $_template_args property.
3014
-     *
3015
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3016
-     *                                 instead of displayed.
3017
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3018
-     * @return void
3019
-     */
3020
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3021
-    {
3022
-        //make sure any EE_Error notices have been handled.
3023
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3024
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3025
-        unset($this->_template_args['data']);
3026
-        $json = array(
3027
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3028
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3029
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3030
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3031
-            'notices'   => EE_Error::get_notices(),
3032
-            'content'   => isset($this->_template_args['admin_page_content'])
3033
-                ? $this->_template_args['admin_page_content'] : '',
3034
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3035
-            'isEEajax'  => true
3036
-            //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3037
-        );
3038
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3039
-        if (null === error_get_last() || ! headers_sent()) {
3040
-            header('Content-Type: application/json; charset=UTF-8');
3041
-        }
3042
-        echo wp_json_encode($json);
3043
-        exit();
3044
-    }
3045
-
3046
-
3047
-
3048
-    /**
3049
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3050
-     *
3051
-     * @return void
3052
-     * @throws EE_Error
3053
-     */
3054
-    public function return_json()
3055
-    {
3056
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3057
-            $this->_return_json();
3058
-        } else {
3059
-            throw new EE_Error(
3060
-                sprintf(
3061
-                    __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3062
-                    __FUNCTION__
3063
-                )
3064
-            );
3065
-        }
3066
-    }
3067
-
3068
-
3069
-
3070
-    /**
3071
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3072
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3073
-     *
3074
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3075
-     * @access   public
3076
-     */
3077
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3078
-    {
3079
-        $this->_hook_obj = $hook_obj;
3080
-    }
3081
-
3082
-
3083
-
3084
-    /**
3085
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3086
-     *
3087
-     * @access public
3088
-     * @param  boolean $about whether to use the special about page wrapper or default.
3089
-     * @return void
3090
-     */
3091
-    public function admin_page_wrapper($about = false)
3092
-    {
3093
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3094
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3095
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3096
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3097
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3098
-            'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
3099
-            isset($this->_template_args['before_admin_page_content'])
3100
-                ? $this->_template_args['before_admin_page_content'] : ''
3101
-        );
3102
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3103
-            'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
3104
-            isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content']
3105
-                : ''
3106
-        );
3107
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3108
-        // load settings page wrapper template
3109
-        $template_path = ! defined('DOING_AJAX')
3110
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3111
-            : EE_ADMIN_TEMPLATE
3112
-              . 'admin_wrapper_ajax.template.php';
3113
-        //about page?
3114
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
3115
-        if (defined('DOING_AJAX')) {
3116
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3117
-                $template_path,
3118
-                $this->_template_args,
3119
-                true
3120
-            );
3121
-            $this->_return_json();
3122
-        } else {
3123
-            EEH_Template::display_template($template_path, $this->_template_args);
3124
-        }
3125
-    }
3126
-
3127
-
3128
-
3129
-    /**
3130
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3131
-     *
3132
-     * @return string html
3133
-     */
3134
-    protected function _get_main_nav_tabs()
3135
-    {
3136
-        //let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
3137
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3138
-    }
3139
-
3140
-
3141
-
3142
-    /**
3143
-     *        sort nav tabs
3144
-     *
3145
-     * @access public
3146
-     * @param $a
3147
-     * @param $b
3148
-     * @return int
3149
-     */
3150
-    private function _sort_nav_tabs($a, $b)
3151
-    {
3152
-        if ($a['order'] == $b['order']) {
3153
-            return 0;
3154
-        }
3155
-        return ($a['order'] < $b['order']) ? -1 : 1;
3156
-    }
3157
-
3158
-
3159
-
3160
-    /**
3161
-     *    generates HTML for the forms used on admin pages
3162
-     *
3163
-     * @access protected
3164
-     * @param    array $input_vars - array of input field details
3165
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3166
-     *                             use)
3167
-     * @return string
3168
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3169
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3170
-     */
3171
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3172
-    {
3173
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3174
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3175
-        return $content;
3176
-    }
3177
-
3178
-
3179
-
3180
-    /**
3181
-     * generates the "Save" and "Save & Close" buttons for edit forms
3182
-     *
3183
-     * @access protected
3184
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3185
-     *                                   Close" button.
3186
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3187
-     *                                   'Save', [1] => 'save & close')
3188
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3189
-     *                                   via the "name" value in the button).  We can also use this to just dump
3190
-     *                                   default actions by submitting some other value.
3191
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3192
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3193
-     *                                   close (normal form handling).
3194
-     */
3195
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3196
-    {
3197
-        //make sure $text and $actions are in an array
3198
-        $text          = (array)$text;
3199
-        $actions       = (array)$actions;
3200
-        $referrer_url  = empty($referrer) ? '' : $referrer;
3201
-        $referrer_url  = ! $referrer
3202
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3203
-              . $_SERVER['REQUEST_URI']
3204
-              . '" />'
3205
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3206
-              . $referrer
3207
-              . '" />';
3208
-        $button_text   = ! empty($text)
3209
-            ? $text
3210
-            : array(
3211
-                __('Save', 'event_espresso'),
3212
-                __('Save and Close', 'event_espresso'),
3213
-            );
3214
-        $default_names = array('save', 'save_and_close');
3215
-        //add in a hidden index for the current page (so save and close redirects properly)
3216
-        $this->_template_args['save_buttons'] = $referrer_url;
3217
-        foreach ($button_text as $key => $button) {
3218
-            $ref                                  = $default_names[$key];
3219
-            $id                                   = $this->_current_view . '_' . $ref;
3220
-            $name                                 = ! empty($actions) ? $actions[$key] : $ref;
3221
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3222
-                                                     . $ref
3223
-                                                     . '" value="'
3224
-                                                     . $button
3225
-                                                     . '" name="'
3226
-                                                     . $name
3227
-                                                     . '" id="'
3228
-                                                     . $id
3229
-                                                     . '" />';
3230
-            if (! $both) {
3231
-                break;
3232
-            }
3233
-        }
3234
-    }
3235
-
3236
-
3237
-
3238
-    /**
3239
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3240
-     *
3241
-     * @see   $this->_set_add_edit_form_tags() for details on params
3242
-     * @since 4.6.0
3243
-     * @param string $route
3244
-     * @param array  $additional_hidden_fields
3245
-     */
3246
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3247
-    {
3248
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3249
-    }
3250
-
3251
-
3252
-
3253
-    /**
3254
-     * set form open and close tags on add/edit pages.
3255
-     *
3256
-     * @access protected
3257
-     * @param string $route                    the route you want the form to direct to
3258
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3259
-     * @return void
3260
-     */
3261
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3262
-    {
3263
-        if (empty($route)) {
3264
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
3265
-            $dev_msg  = $user_msg . "\n" . sprintf(
3266
-                    __('The $route argument is required for the %s->%s method.', 'event_espresso'),
3267
-                    __FUNCTION__,
3268
-                    __CLASS__
3269
-                );
3270
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3271
-        }
3272
-        // open form
3273
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3274
-                                                             . $this->_admin_base_url
3275
-                                                             . '" id="'
3276
-                                                             . $route
3277
-                                                             . '_event_form" >';
3278
-        // add nonce
3279
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3280
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3281
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3282
-        // add REQUIRED form action
3283
-        $hidden_fields = array(
3284
-            'action' => array('type' => 'hidden', 'value' => $route),
3285
-        );
3286
-        // merge arrays
3287
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields)
3288
-            : $hidden_fields;
3289
-        // generate form fields
3290
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3291
-        // add fields to form
3292
-        foreach ((array)$form_fields as $field_name => $form_field) {
3293
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3294
-        }
3295
-        // close form
3296
-        $this->_template_args['after_admin_page_content'] = '</form>';
3297
-    }
3298
-
3299
-
3300
-
3301
-    /**
3302
-     * Public Wrapper for _redirect_after_action() method since its
3303
-     * discovered it would be useful for external code to have access.
3304
-     *
3305
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3306
-     * @since 4.5.0
3307
-     */
3308
-    public function redirect_after_action(
3309
-        $success = false,
3310
-        $what = 'item',
3311
-        $action_desc = 'processed',
3312
-        $query_args = array(),
3313
-        $override_overwrite = false
3314
-    ) {
3315
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
3316
-    }
3317
-
3318
-
3319
-
3320
-    /**
3321
-     *    _redirect_after_action
3322
-     *
3323
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3324
-     * @param string $what               - what the action was performed on
3325
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3326
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3327
-     *                                   action is completed
3328
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3329
-     *                                   override this so that they show.
3330
-     * @access protected
3331
-     * @return void
3332
-     */
3333
-    protected function _redirect_after_action(
3334
-        $success = 0,
3335
-        $what = 'item',
3336
-        $action_desc = 'processed',
3337
-        $query_args = array(),
3338
-        $override_overwrite = false
3339
-    ) {
3340
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3341
-        //class name for actions/filters.
3342
-        $classname = get_class($this);
3343
-        //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
3344
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3345
-        $notices      = EE_Error::get_notices(false);
3346
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3347
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3348
-            EE_Error::overwrite_success();
3349
-        }
3350
-        if (! empty($what) && ! empty($action_desc)) {
3351
-            // how many records affected ? more than one record ? or just one ?
3352
-            if ($success > 1 && empty($notices['errors'])) {
3353
-                // set plural msg
3354
-                EE_Error::add_success(
3355
-                    sprintf(
3356
-                        __('The "%s" have been successfully %s.', 'event_espresso'),
3357
-                        $what,
3358
-                        $action_desc
3359
-                    ),
3360
-                    __FILE__,
3361
-                    __FUNCTION__,
3362
-                    __LINE__
3363
-                );
3364
-            } elseif ($success == 1 && empty($notices['errors'])) {
3365
-                // set singular msg
3366
-                EE_Error::add_success(
3367
-                    sprintf(
3368
-                        __('The "%s" has been successfully %s.', 'event_espresso'),
3369
-                        $what,
3370
-                        $action_desc
3371
-                    ),
3372
-                    __FILE__,
3373
-                    __FUNCTION__,
3374
-                    __LINE__
3375
-                );
3376
-            }
3377
-        }
3378
-        // check that $query_args isn't something crazy
3379
-        if (! is_array($query_args)) {
3380
-            $query_args = array();
3381
-        }
3382
-        /**
3383
-         * Allow injecting actions before the query_args are modified for possible different
3384
-         * redirections on save and close actions
3385
-         *
3386
-         * @since 4.2.0
3387
-         * @param array $query_args       The original query_args array coming into the
3388
-         *                                method.
3389
-         */
3390
-        do_action(
3391
-            'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action,
3392
-            $query_args
3393
-        );
3394
-        //calculate where we're going (if we have a "save and close" button pushed)
3395
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
3396
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3397
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3398
-            // regenerate query args array from referrer URL
3399
-            parse_str($parsed_url['query'], $query_args);
3400
-            // correct page and action will be in the query args now
3401
-            $redirect_url = admin_url('admin.php');
3402
-        }
3403
-        //merge any default query_args set in _default_route_query_args property
3404
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3405
-            $args_to_merge = array();
3406
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3407
-                //is there a wp_referer array in our _default_route_query_args property?
3408
-                if ($query_param == 'wp_referer') {
3409
-                    $query_value = (array)$query_value;
3410
-                    foreach ($query_value as $reference => $value) {
3411
-                        if (strpos($reference, 'nonce') !== false) {
3412
-                            continue;
3413
-                        }
3414
-                        //finally we will override any arguments in the referer with
3415
-                        //what might be set on the _default_route_query_args array.
3416
-                        if (isset($this->_default_route_query_args[$reference])) {
3417
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3418
-                        } else {
3419
-                            $args_to_merge[$reference] = urlencode($value);
3420
-                        }
3421
-                    }
3422
-                    continue;
3423
-                }
3424
-                $args_to_merge[$query_param] = $query_value;
3425
-            }
3426
-            //now let's merge these arguments but override with what was specifically sent in to the
3427
-            //redirect.
3428
-            $query_args = array_merge($args_to_merge, $query_args);
3429
-        }
3430
-        $this->_process_notices($query_args);
3431
-        // generate redirect url
3432
-        // if redirecting to anything other than the main page, add a nonce
3433
-        if (isset($query_args['action'])) {
3434
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
3435
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3436
-        }
3437
-        //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
3438
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3439
-        $redirect_url = apply_filters(
3440
-            'FHEE_redirect_' . $classname . $this->_req_action,
3441
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3442
-            $query_args
3443
-        );
3444
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3445
-        if (defined('DOING_AJAX')) {
3446
-            $default_data                    = array(
3447
-                'close'        => true,
3448
-                'redirect_url' => $redirect_url,
3449
-                'where'        => 'main',
3450
-                'what'         => 'append',
3451
-            );
3452
-            $this->_template_args['success'] = $success;
3453
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3454
-                $default_data,
3455
-                $this->_template_args['data']
3456
-            ) : $default_data;
3457
-            $this->_return_json();
3458
-        }
3459
-        wp_safe_redirect($redirect_url);
3460
-        exit();
3461
-    }
3462
-
3463
-
3464
-
3465
-    /**
3466
-     * process any notices before redirecting (or returning ajax request)
3467
-     * This method sets the $this->_template_args['notices'] attribute;
3468
-     *
3469
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3470
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3471
-     *                                  page_routes haven't been defined yet.
3472
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3473
-     *                                  still save a transient for the notice.
3474
-     * @return void
3475
-     */
3476
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3477
-    {
3478
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
3479
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3480
-            $notices = EE_Error::get_notices(false);
3481
-            if (empty($this->_template_args['success'])) {
3482
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3483
-            }
3484
-            if (empty($this->_template_args['errors'])) {
3485
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3486
-            }
3487
-            if (empty($this->_template_args['attention'])) {
3488
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3489
-            }
3490
-        }
3491
-        $this->_template_args['notices'] = EE_Error::get_notices();
3492
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3493
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3494
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3495
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
3496
-        }
3497
-    }
3498
-
3499
-
3500
-
3501
-    /**
3502
-     * get_action_link_or_button
3503
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3504
-     *
3505
-     * @param string $action        use this to indicate which action the url is generated with.
3506
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3507
-     *                              property.
3508
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3509
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3510
-     * @param string $base_url      If this is not provided
3511
-     *                              the _admin_base_url will be used as the default for the button base_url.
3512
-     *                              Otherwise this value will be used.
3513
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3514
-     * @return string
3515
-     * @throws \EE_Error
3516
-     */
3517
-    public function get_action_link_or_button(
3518
-        $action,
3519
-        $type = 'add',
3520
-        $extra_request = array(),
3521
-        $class = 'button-primary',
3522
-        $base_url = '',
3523
-        $exclude_nonce = false
3524
-    ) {
3525
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3526
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3527
-            throw new EE_Error(
3528
-                sprintf(
3529
-                    __(
3530
-                        'There is no page route for given action for the button.  This action was given: %s',
3531
-                        'event_espresso'
3532
-                    ),
3533
-                    $action
3534
-                )
3535
-            );
3536
-        }
3537
-        if (! isset($this->_labels['buttons'][$type])) {
3538
-            throw new EE_Error(
3539
-                sprintf(
3540
-                    __(
3541
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3542
-                        'event_espresso'
3543
-                    ),
3544
-                    $type
3545
-                )
3546
-            );
3547
-        }
3548
-        //finally check user access for this button.
3549
-        $has_access = $this->check_user_access($action, true);
3550
-        if (! $has_access) {
3551
-            return '';
3552
-        }
3553
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3554
-        $query_args = array(
3555
-            'action' => $action,
3556
-        );
3557
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3558
-        if (! empty($extra_request)) {
3559
-            $query_args = array_merge($extra_request, $query_args);
3560
-        }
3561
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3562
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3563
-    }
3564
-
3565
-
3566
-
3567
-    /**
3568
-     * _per_page_screen_option
3569
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3570
-     *
3571
-     * @return void
3572
-     */
3573
-    protected function _per_page_screen_option()
3574
-    {
3575
-        $option = 'per_page';
3576
-        $args   = array(
3577
-            'label'   => $this->_admin_page_title,
3578
-            'default' => 10,
3579
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3580
-        );
3581
-        //ONLY add the screen option if the user has access to it.
3582
-        if ($this->check_user_access($this->_current_view, true)) {
3583
-            add_screen_option($option, $args);
3584
-        }
3585
-    }
3586
-
3587
-
3588
-
3589
-    /**
3590
-     * set_per_page_screen_option
3591
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3592
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3593
-     * admin_menu.
3594
-     *
3595
-     * @access private
3596
-     * @return void
3597
-     */
3598
-    private function _set_per_page_screen_options()
3599
-    {
3600
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3601
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3602
-            if (! $user = wp_get_current_user()) {
3603
-                return;
3604
-            }
3605
-            $option = $_POST['wp_screen_options']['option'];
3606
-            $value  = $_POST['wp_screen_options']['value'];
3607
-            if ($option != sanitize_key($option)) {
3608
-                return;
3609
-            }
3610
-            $map_option = $option;
3611
-            $option     = str_replace('-', '_', $option);
3612
-            switch ($map_option) {
3613
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3614
-                    $value = (int)$value;
3615
-                    if ($value < 1 || $value > 999) {
3616
-                        return;
3617
-                    }
3618
-                    break;
3619
-                default:
3620
-                    $value = apply_filters(
3621
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
-                        false,
3623
-                        $option,
3624
-                        $value
3625
-                    );
3626
-                    if (false === $value) {
3627
-                        return;
3628
-                    }
3629
-                    break;
3630
-            }
3631
-            update_user_meta($user->ID, $option, $value);
3632
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3633
-            exit;
3634
-        }
3635
-    }
3636
-
3637
-
3638
-
3639
-    /**
3640
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
-     *
3642
-     * @param array $data array that will be assigned to template args.
3643
-     */
3644
-    public function set_template_args($data)
3645
-    {
3646
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3647
-    }
3648
-
3649
-
3650
-
3651
-    /**
3652
-     * This makes available the WP transient system for temporarily moving data between routes
3653
-     *
3654
-     * @access protected
3655
-     * @param string $route             the route that should receive the transient
3656
-     * @param array  $data              the data that gets sent
3657
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3658
-     *                                  normal route transient.
3659
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3660
-     *                                  when we are adding a transient before page_routes have been defined.
3661
-     * @return void
3662
-     */
3663
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3664
-    {
3665
-        $user_id = get_current_user_id();
3666
-        if (! $skip_route_verify) {
3667
-            $this->_verify_route($route);
3668
-        }
3669
-        //now let's set the string for what kind of transient we're setting
3670
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3671
-        $data      = $notices ? array('notices' => $data) : $data;
3672
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3673
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3674
-        if ($existing) {
3675
-            $data = array_merge((array)$data, (array)$existing);
3676
-        }
3677
-        if (is_multisite() && is_network_admin()) {
3678
-            set_site_transient($transient, $data, 8);
3679
-        } else {
3680
-            set_transient($transient, $data, 8);
3681
-        }
3682
-    }
3683
-
3684
-
3685
-
3686
-    /**
3687
-     * this retrieves the temporary transient that has been set for moving data between routes.
3688
-     *
3689
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3690
-     * @return mixed data
3691
-     */
3692
-    protected function _get_transient($notices = false, $route = false)
3693
-    {
3694
-        $user_id   = get_current_user_id();
3695
-        $route     = ! $route ? $this->_req_action : $route;
3696
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3697
-        $data      = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3698
-        //delete transient after retrieval (just in case it hasn't expired);
3699
-        if (is_multisite() && is_network_admin()) {
3700
-            delete_site_transient($transient);
3701
-        } else {
3702
-            delete_transient($transient);
3703
-        }
3704
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3705
-    }
3706
-
3707
-
3708
-
3709
-    /**
3710
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3711
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3712
-     * default route callback on the EE_Admin page you want it run.)
3713
-     *
3714
-     * @return void
3715
-     */
3716
-    protected function _transient_garbage_collection()
3717
-    {
3718
-        global $wpdb;
3719
-        //retrieve all existing transients
3720
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3721
-        if ($results = $wpdb->get_results($query)) {
3722
-            foreach ($results as $result) {
3723
-                $transient = str_replace('_transient_', '', $result->option_name);
3724
-                get_transient($transient);
3725
-                if (is_multisite() && is_network_admin()) {
3726
-                    get_site_transient($transient);
3727
-                }
3728
-            }
3729
-        }
3730
-    }
3731
-
3732
-
3733
-
3734
-    /**
3735
-     * get_view
3736
-     *
3737
-     * @access public
3738
-     * @return string content of _view property
3739
-     */
3740
-    public function get_view()
3741
-    {
3742
-        return $this->_view;
3743
-    }
3744
-
3745
-
3746
-
3747
-    /**
3748
-     * getter for the protected $_views property
3749
-     *
3750
-     * @return array
3751
-     */
3752
-    public function get_views()
3753
-    {
3754
-        return $this->_views;
3755
-    }
3756
-
3757
-
3758
-
3759
-    /**
3760
-     * get_current_page
3761
-     *
3762
-     * @access public
3763
-     * @return string _current_page property value
3764
-     */
3765
-    public function get_current_page()
3766
-    {
3767
-        return $this->_current_page;
3768
-    }
3769
-
3770
-
3771
-
3772
-    /**
3773
-     * get_current_view
3774
-     *
3775
-     * @access public
3776
-     * @return string _current_view property value
3777
-     */
3778
-    public function get_current_view()
3779
-    {
3780
-        return $this->_current_view;
3781
-    }
3782
-
3783
-
3784
-
3785
-    /**
3786
-     * get_current_screen
3787
-     *
3788
-     * @access public
3789
-     * @return object The current WP_Screen object
3790
-     */
3791
-    public function get_current_screen()
3792
-    {
3793
-        return $this->_current_screen;
3794
-    }
3795
-
3796
-
3797
-
3798
-    /**
3799
-     * get_current_page_view_url
3800
-     *
3801
-     * @access public
3802
-     * @return string This returns the url for the current_page_view.
3803
-     */
3804
-    public function get_current_page_view_url()
3805
-    {
3806
-        return $this->_current_page_view_url;
3807
-    }
3808
-
3809
-
3810
-
3811
-    /**
3812
-     * just returns the _req_data property
3813
-     *
3814
-     * @return array
3815
-     */
3816
-    public function get_request_data()
3817
-    {
3818
-        return $this->_req_data;
3819
-    }
3820
-
3821
-
3822
-
3823
-    /**
3824
-     * returns the _req_data protected property
3825
-     *
3826
-     * @return string
3827
-     */
3828
-    public function get_req_action()
3829
-    {
3830
-        return $this->_req_action;
3831
-    }
3832
-
3833
-
3834
-
3835
-    /**
3836
-     * @return bool  value of $_is_caf property
3837
-     */
3838
-    public function is_caf()
3839
-    {
3840
-        return $this->_is_caf;
3841
-    }
3842
-
3843
-
3844
-
3845
-    /**
3846
-     * @return mixed
3847
-     */
3848
-    public function default_espresso_metaboxes()
3849
-    {
3850
-        return $this->_default_espresso_metaboxes;
3851
-    }
3852
-
3853
-
3854
-
3855
-    /**
3856
-     * @return mixed
3857
-     */
3858
-    public function admin_base_url()
3859
-    {
3860
-        return $this->_admin_base_url;
3861
-    }
2635
+	}
2636
+
2637
+
2638
+
2639
+	/**
2640
+	 * facade for add_meta_box
2641
+	 *
2642
+	 * @param string  $action        where the metabox get's displayed
2643
+	 * @param string  $title         Title of Metabox (output in metabox header)
2644
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2645
+	 *                               instead of the one created in here.
2646
+	 * @param array   $callback_args an array of args supplied for the metabox
2647
+	 * @param string  $column        what metabox column
2648
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2649
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2650
+	 *                               created but just set our own callback for wp's add_meta_box.
2651
+	 */
2652
+	public function _add_admin_page_meta_box(
2653
+		$action,
2654
+		$title,
2655
+		$callback,
2656
+		$callback_args,
2657
+		$column = 'normal',
2658
+		$priority = 'high',
2659
+		$create_func = true
2660
+	) {
2661
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2662
+		//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.
2663
+		if (empty($callback_args) && $create_func) {
2664
+			$callback_args = array(
2665
+				'template_path' => $this->_template_path,
2666
+				'template_args' => $this->_template_args,
2667
+			);
2668
+		}
2669
+		//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)
2670
+		$call_back_func = $create_func ? create_function(
2671
+			'$post, $metabox',
2672
+			'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'
2673
+		) : $callback;
2674
+		add_meta_box(
2675
+			str_replace('_', '-', $action) . '-mbox',
2676
+			$title,
2677
+			$call_back_func,
2678
+			$this->_wp_page_slug,
2679
+			$column,
2680
+			$priority,
2681
+			$callback_args
2682
+		);
2683
+	}
2684
+
2685
+
2686
+
2687
+	/**
2688
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2689
+	 *
2690
+	 * @return [type] [description]
2691
+	 */
2692
+	public function display_admin_page_with_metabox_columns()
2693
+	{
2694
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2695
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2696
+			$this->_column_template_path,
2697
+			$this->_template_args,
2698
+			true
2699
+		);
2700
+		//the final wrapper
2701
+		$this->admin_page_wrapper();
2702
+	}
2703
+
2704
+
2705
+
2706
+	/**
2707
+	 *        generates  HTML wrapper for an admin details page
2708
+	 *
2709
+	 * @access public
2710
+	 * @return void
2711
+	 */
2712
+	public function display_admin_page_with_sidebar()
2713
+	{
2714
+		$this->_display_admin_page(true);
2715
+	}
2716
+
2717
+
2718
+
2719
+	/**
2720
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2721
+	 *
2722
+	 * @access public
2723
+	 * @return void
2724
+	 */
2725
+	public function display_admin_page_with_no_sidebar()
2726
+	{
2727
+		$this->_display_admin_page();
2728
+	}
2729
+
2730
+
2731
+
2732
+	/**
2733
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2734
+	 *
2735
+	 * @access public
2736
+	 * @return void
2737
+	 */
2738
+	public function display_about_admin_page()
2739
+	{
2740
+		$this->_display_admin_page(false, true);
2741
+	}
2742
+
2743
+
2744
+
2745
+	/**
2746
+	 * display_admin_page
2747
+	 * contains the code for actually displaying an admin page
2748
+	 *
2749
+	 * @access private
2750
+	 * @param  boolean $sidebar true with sidebar, false without
2751
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2752
+	 * @return void
2753
+	 */
2754
+	private function _display_admin_page($sidebar = false, $about = false)
2755
+	{
2756
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2757
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2758
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2759
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2760
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2761
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2762
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2763
+			? 'poststuff'
2764
+			: 'espresso-default-admin';
2765
+		$template_path                                     = $sidebar
2766
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2767
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2768
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2769
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2770
+		}
2771
+		$template_path                                     = ! empty($this->_column_template_path)
2772
+			? $this->_column_template_path : $template_path;
2773
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2774
+			? $this->_template_args['admin_page_content'] : '';
2775
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2776
+			? $this->_template_args['before_admin_page_content'] : '';
2777
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2778
+			? $this->_template_args['after_admin_page_content'] : '';
2779
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2780
+			$template_path,
2781
+			$this->_template_args,
2782
+			true
2783
+		);
2784
+		// the final template wrapper
2785
+		$this->admin_page_wrapper($about);
2786
+	}
2787
+
2788
+
2789
+
2790
+	/**
2791
+	 * This is used to display caf preview pages.
2792
+	 *
2793
+	 * @since 4.3.2
2794
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2795
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2796
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2797
+	 * @return void
2798
+	 * @throws \EE_Error
2799
+	 */
2800
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2801
+	{
2802
+		//let's generate a default preview action button if there isn't one already present.
2803
+		$this->_labels['buttons']['buy_now']           = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2804
+		$buy_now_url                                   = add_query_arg(
2805
+			array(
2806
+				'ee_ver'       => 'ee4',
2807
+				'utm_source'   => 'ee4_plugin_admin',
2808
+				'utm_medium'   => 'link',
2809
+				'utm_campaign' => $utm_campaign_source,
2810
+				'utm_content'  => 'buy_now_button',
2811
+			),
2812
+			'http://eventespresso.com/pricing/'
2813
+		);
2814
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2815
+			? $this->get_action_link_or_button(
2816
+				'',
2817
+				'buy_now',
2818
+				array(),
2819
+				'button-primary button-large',
2820
+				$buy_now_url,
2821
+				true
2822
+			)
2823
+			: $this->_template_args['preview_action_button'];
2824
+		$template_path                                 = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2825
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2826
+			$template_path,
2827
+			$this->_template_args,
2828
+			true
2829
+		);
2830
+		$this->_display_admin_page($display_sidebar);
2831
+	}
2832
+
2833
+
2834
+
2835
+	/**
2836
+	 * display_admin_list_table_page_with_sidebar
2837
+	 * generates HTML wrapper for an admin_page with list_table
2838
+	 *
2839
+	 * @access public
2840
+	 * @return void
2841
+	 */
2842
+	public function display_admin_list_table_page_with_sidebar()
2843
+	{
2844
+		$this->_display_admin_list_table_page(true);
2845
+	}
2846
+
2847
+
2848
+
2849
+	/**
2850
+	 * display_admin_list_table_page_with_no_sidebar
2851
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2852
+	 *
2853
+	 * @access public
2854
+	 * @return void
2855
+	 */
2856
+	public function display_admin_list_table_page_with_no_sidebar()
2857
+	{
2858
+		$this->_display_admin_list_table_page();
2859
+	}
2860
+
2861
+
2862
+
2863
+	/**
2864
+	 * generates html wrapper for an admin_list_table page
2865
+	 *
2866
+	 * @access private
2867
+	 * @param boolean $sidebar whether to display with sidebar or not.
2868
+	 * @return void
2869
+	 */
2870
+	private function _display_admin_list_table_page($sidebar = false)
2871
+	{
2872
+		//setup search attributes
2873
+		$this->_set_search_attributes();
2874
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2875
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2876
+		$this->_template_args['table_url']        = defined('DOING_AJAX')
2877
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2878
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2879
+		$this->_template_args['list_table']       = $this->_list_table_object;
2880
+		$this->_template_args['current_route']    = $this->_req_action;
2881
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2882
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2883
+		if (! empty($ajax_sorting_callback)) {
2884
+			$sortable_list_table_form_fields = wp_nonce_field(
2885
+				$ajax_sorting_callback . '_nonce',
2886
+				$ajax_sorting_callback . '_nonce',
2887
+				false,
2888
+				false
2889
+			);
2890
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2891
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2892
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2893
+												. $this->page_slug
2894
+												. '" />';
2895
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2896
+												. $ajax_sorting_callback
2897
+												. '" />';
2898
+		} else {
2899
+			$sortable_list_table_form_fields = '';
2900
+		}
2901
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2902
+		$hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
2903
+			? $this->_template_args['list_table_hidden_fields'] : '';
2904
+		$nonce_ref                                               = $this->_req_action . '_nonce';
2905
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
2906
+																	. $nonce_ref
2907
+																	. '" value="'
2908
+																	. wp_create_nonce($nonce_ref)
2909
+																	. '">';
2910
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2911
+		//display message about search results?
2912
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2913
+			? '<p class="ee-search-results">' . sprintf(
2914
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2915
+				trim($this->_req_data['s'], '%')
2916
+			) . '</p>'
2917
+			: '';
2918
+		// filter before_list_table template arg
2919
+		$this->_template_args['before_list_table'] = apply_filters(
2920
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2921
+			$this->_template_args['before_list_table'],
2922
+			$this->page_slug,
2923
+			$this->_req_data,
2924
+			$this->_req_action
2925
+		);
2926
+		// convert to array and filter again
2927
+		// arrays are easier to inject new items in a specific location,
2928
+		// but would not be backwards compatible, so we have to add a new filter
2929
+		$this->_template_args['before_list_table'] = implode(
2930
+			" \n",
2931
+			(array)apply_filters(
2932
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2933
+				(array)$this->_template_args['before_list_table'],
2934
+				$this->page_slug,
2935
+				$this->_req_data,
2936
+				$this->_req_action
2937
+			)
2938
+		);
2939
+		// filter after_list_table template arg
2940
+		$this->_template_args['after_list_table'] = apply_filters(
2941
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2942
+			$this->_template_args['after_list_table'],
2943
+			$this->page_slug,
2944
+			$this->_req_data,
2945
+			$this->_req_action
2946
+		);
2947
+		// convert to array and filter again
2948
+		// arrays are easier to inject new items in a specific location,
2949
+		// but would not be backwards compatible, so we have to add a new filter
2950
+		$this->_template_args['after_list_table']   = implode(
2951
+			" \n",
2952
+			(array)apply_filters(
2953
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2954
+				(array)$this->_template_args['after_list_table'],
2955
+				$this->page_slug,
2956
+				$this->_req_data,
2957
+				$this->_req_action
2958
+			)
2959
+		);
2960
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2961
+			$template_path,
2962
+			$this->_template_args,
2963
+			true
2964
+		);
2965
+		// the final template wrapper
2966
+		if ($sidebar) {
2967
+			$this->display_admin_page_with_sidebar();
2968
+		} else {
2969
+			$this->display_admin_page_with_no_sidebar();
2970
+		}
2971
+	}
2972
+
2973
+
2974
+
2975
+	/**
2976
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2977
+	 * html string for the legend.
2978
+	 * $items are expected in an array in the following format:
2979
+	 * $legend_items = array(
2980
+	 *        'item_id' => array(
2981
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2982
+	 *            'desc' => __('localized description of item');
2983
+	 *        )
2984
+	 * );
2985
+	 *
2986
+	 * @param  array $items see above for format of array
2987
+	 * @return string        html string of legend
2988
+	 */
2989
+	protected function _display_legend($items)
2990
+	{
2991
+		$this->_template_args['items'] = apply_filters(
2992
+			'FHEE__EE_Admin_Page___display_legend__items',
2993
+			(array)$items,
2994
+			$this
2995
+		);
2996
+		$legend_template               = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2997
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2998
+	}
2999
+
3000
+
3001
+	/**
3002
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3003
+	 * The returned json object is created from an array in the following format:
3004
+	 * array(
3005
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3006
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3007
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3008
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3009
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3010
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3011
+	 *  that might be included in here)
3012
+	 * )
3013
+	 * The json object is populated by whatever is set in the $_template_args property.
3014
+	 *
3015
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3016
+	 *                                 instead of displayed.
3017
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3018
+	 * @return void
3019
+	 */
3020
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3021
+	{
3022
+		//make sure any EE_Error notices have been handled.
3023
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3024
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3025
+		unset($this->_template_args['data']);
3026
+		$json = array(
3027
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3028
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3029
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3030
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3031
+			'notices'   => EE_Error::get_notices(),
3032
+			'content'   => isset($this->_template_args['admin_page_content'])
3033
+				? $this->_template_args['admin_page_content'] : '',
3034
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3035
+			'isEEajax'  => true
3036
+			//special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3037
+		);
3038
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3039
+		if (null === error_get_last() || ! headers_sent()) {
3040
+			header('Content-Type: application/json; charset=UTF-8');
3041
+		}
3042
+		echo wp_json_encode($json);
3043
+		exit();
3044
+	}
3045
+
3046
+
3047
+
3048
+	/**
3049
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3050
+	 *
3051
+	 * @return void
3052
+	 * @throws EE_Error
3053
+	 */
3054
+	public function return_json()
3055
+	{
3056
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3057
+			$this->_return_json();
3058
+		} else {
3059
+			throw new EE_Error(
3060
+				sprintf(
3061
+					__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3062
+					__FUNCTION__
3063
+				)
3064
+			);
3065
+		}
3066
+	}
3067
+
3068
+
3069
+
3070
+	/**
3071
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3072
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3073
+	 *
3074
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3075
+	 * @access   public
3076
+	 */
3077
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3078
+	{
3079
+		$this->_hook_obj = $hook_obj;
3080
+	}
3081
+
3082
+
3083
+
3084
+	/**
3085
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3086
+	 *
3087
+	 * @access public
3088
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3089
+	 * @return void
3090
+	 */
3091
+	public function admin_page_wrapper($about = false)
3092
+	{
3093
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3094
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3095
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3096
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3097
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3098
+			'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
3099
+			isset($this->_template_args['before_admin_page_content'])
3100
+				? $this->_template_args['before_admin_page_content'] : ''
3101
+		);
3102
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3103
+			'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
3104
+			isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content']
3105
+				: ''
3106
+		);
3107
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3108
+		// load settings page wrapper template
3109
+		$template_path = ! defined('DOING_AJAX')
3110
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3111
+			: EE_ADMIN_TEMPLATE
3112
+			  . 'admin_wrapper_ajax.template.php';
3113
+		//about page?
3114
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
3115
+		if (defined('DOING_AJAX')) {
3116
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3117
+				$template_path,
3118
+				$this->_template_args,
3119
+				true
3120
+			);
3121
+			$this->_return_json();
3122
+		} else {
3123
+			EEH_Template::display_template($template_path, $this->_template_args);
3124
+		}
3125
+	}
3126
+
3127
+
3128
+
3129
+	/**
3130
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3131
+	 *
3132
+	 * @return string html
3133
+	 */
3134
+	protected function _get_main_nav_tabs()
3135
+	{
3136
+		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
3137
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3138
+	}
3139
+
3140
+
3141
+
3142
+	/**
3143
+	 *        sort nav tabs
3144
+	 *
3145
+	 * @access public
3146
+	 * @param $a
3147
+	 * @param $b
3148
+	 * @return int
3149
+	 */
3150
+	private function _sort_nav_tabs($a, $b)
3151
+	{
3152
+		if ($a['order'] == $b['order']) {
3153
+			return 0;
3154
+		}
3155
+		return ($a['order'] < $b['order']) ? -1 : 1;
3156
+	}
3157
+
3158
+
3159
+
3160
+	/**
3161
+	 *    generates HTML for the forms used on admin pages
3162
+	 *
3163
+	 * @access protected
3164
+	 * @param    array $input_vars - array of input field details
3165
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3166
+	 *                             use)
3167
+	 * @return string
3168
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3169
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3170
+	 */
3171
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3172
+	{
3173
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3174
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3175
+		return $content;
3176
+	}
3177
+
3178
+
3179
+
3180
+	/**
3181
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3182
+	 *
3183
+	 * @access protected
3184
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3185
+	 *                                   Close" button.
3186
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3187
+	 *                                   'Save', [1] => 'save & close')
3188
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3189
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3190
+	 *                                   default actions by submitting some other value.
3191
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3192
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3193
+	 *                                   close (normal form handling).
3194
+	 */
3195
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3196
+	{
3197
+		//make sure $text and $actions are in an array
3198
+		$text          = (array)$text;
3199
+		$actions       = (array)$actions;
3200
+		$referrer_url  = empty($referrer) ? '' : $referrer;
3201
+		$referrer_url  = ! $referrer
3202
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3203
+			  . $_SERVER['REQUEST_URI']
3204
+			  . '" />'
3205
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3206
+			  . $referrer
3207
+			  . '" />';
3208
+		$button_text   = ! empty($text)
3209
+			? $text
3210
+			: array(
3211
+				__('Save', 'event_espresso'),
3212
+				__('Save and Close', 'event_espresso'),
3213
+			);
3214
+		$default_names = array('save', 'save_and_close');
3215
+		//add in a hidden index for the current page (so save and close redirects properly)
3216
+		$this->_template_args['save_buttons'] = $referrer_url;
3217
+		foreach ($button_text as $key => $button) {
3218
+			$ref                                  = $default_names[$key];
3219
+			$id                                   = $this->_current_view . '_' . $ref;
3220
+			$name                                 = ! empty($actions) ? $actions[$key] : $ref;
3221
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3222
+													 . $ref
3223
+													 . '" value="'
3224
+													 . $button
3225
+													 . '" name="'
3226
+													 . $name
3227
+													 . '" id="'
3228
+													 . $id
3229
+													 . '" />';
3230
+			if (! $both) {
3231
+				break;
3232
+			}
3233
+		}
3234
+	}
3235
+
3236
+
3237
+
3238
+	/**
3239
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3240
+	 *
3241
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3242
+	 * @since 4.6.0
3243
+	 * @param string $route
3244
+	 * @param array  $additional_hidden_fields
3245
+	 */
3246
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3247
+	{
3248
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3249
+	}
3250
+
3251
+
3252
+
3253
+	/**
3254
+	 * set form open and close tags on add/edit pages.
3255
+	 *
3256
+	 * @access protected
3257
+	 * @param string $route                    the route you want the form to direct to
3258
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3259
+	 * @return void
3260
+	 */
3261
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3262
+	{
3263
+		if (empty($route)) {
3264
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
3265
+			$dev_msg  = $user_msg . "\n" . sprintf(
3266
+					__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3267
+					__FUNCTION__,
3268
+					__CLASS__
3269
+				);
3270
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3271
+		}
3272
+		// open form
3273
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3274
+															 . $this->_admin_base_url
3275
+															 . '" id="'
3276
+															 . $route
3277
+															 . '_event_form" >';
3278
+		// add nonce
3279
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3280
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3281
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3282
+		// add REQUIRED form action
3283
+		$hidden_fields = array(
3284
+			'action' => array('type' => 'hidden', 'value' => $route),
3285
+		);
3286
+		// merge arrays
3287
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields)
3288
+			: $hidden_fields;
3289
+		// generate form fields
3290
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3291
+		// add fields to form
3292
+		foreach ((array)$form_fields as $field_name => $form_field) {
3293
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3294
+		}
3295
+		// close form
3296
+		$this->_template_args['after_admin_page_content'] = '</form>';
3297
+	}
3298
+
3299
+
3300
+
3301
+	/**
3302
+	 * Public Wrapper for _redirect_after_action() method since its
3303
+	 * discovered it would be useful for external code to have access.
3304
+	 *
3305
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3306
+	 * @since 4.5.0
3307
+	 */
3308
+	public function redirect_after_action(
3309
+		$success = false,
3310
+		$what = 'item',
3311
+		$action_desc = 'processed',
3312
+		$query_args = array(),
3313
+		$override_overwrite = false
3314
+	) {
3315
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
3316
+	}
3317
+
3318
+
3319
+
3320
+	/**
3321
+	 *    _redirect_after_action
3322
+	 *
3323
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3324
+	 * @param string $what               - what the action was performed on
3325
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3326
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3327
+	 *                                   action is completed
3328
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3329
+	 *                                   override this so that they show.
3330
+	 * @access protected
3331
+	 * @return void
3332
+	 */
3333
+	protected function _redirect_after_action(
3334
+		$success = 0,
3335
+		$what = 'item',
3336
+		$action_desc = 'processed',
3337
+		$query_args = array(),
3338
+		$override_overwrite = false
3339
+	) {
3340
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3341
+		//class name for actions/filters.
3342
+		$classname = get_class($this);
3343
+		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
3344
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3345
+		$notices      = EE_Error::get_notices(false);
3346
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3347
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3348
+			EE_Error::overwrite_success();
3349
+		}
3350
+		if (! empty($what) && ! empty($action_desc)) {
3351
+			// how many records affected ? more than one record ? or just one ?
3352
+			if ($success > 1 && empty($notices['errors'])) {
3353
+				// set plural msg
3354
+				EE_Error::add_success(
3355
+					sprintf(
3356
+						__('The "%s" have been successfully %s.', 'event_espresso'),
3357
+						$what,
3358
+						$action_desc
3359
+					),
3360
+					__FILE__,
3361
+					__FUNCTION__,
3362
+					__LINE__
3363
+				);
3364
+			} elseif ($success == 1 && empty($notices['errors'])) {
3365
+				// set singular msg
3366
+				EE_Error::add_success(
3367
+					sprintf(
3368
+						__('The "%s" has been successfully %s.', 'event_espresso'),
3369
+						$what,
3370
+						$action_desc
3371
+					),
3372
+					__FILE__,
3373
+					__FUNCTION__,
3374
+					__LINE__
3375
+				);
3376
+			}
3377
+		}
3378
+		// check that $query_args isn't something crazy
3379
+		if (! is_array($query_args)) {
3380
+			$query_args = array();
3381
+		}
3382
+		/**
3383
+		 * Allow injecting actions before the query_args are modified for possible different
3384
+		 * redirections on save and close actions
3385
+		 *
3386
+		 * @since 4.2.0
3387
+		 * @param array $query_args       The original query_args array coming into the
3388
+		 *                                method.
3389
+		 */
3390
+		do_action(
3391
+			'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action,
3392
+			$query_args
3393
+		);
3394
+		//calculate where we're going (if we have a "save and close" button pushed)
3395
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
3396
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3397
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3398
+			// regenerate query args array from referrer URL
3399
+			parse_str($parsed_url['query'], $query_args);
3400
+			// correct page and action will be in the query args now
3401
+			$redirect_url = admin_url('admin.php');
3402
+		}
3403
+		//merge any default query_args set in _default_route_query_args property
3404
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3405
+			$args_to_merge = array();
3406
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3407
+				//is there a wp_referer array in our _default_route_query_args property?
3408
+				if ($query_param == 'wp_referer') {
3409
+					$query_value = (array)$query_value;
3410
+					foreach ($query_value as $reference => $value) {
3411
+						if (strpos($reference, 'nonce') !== false) {
3412
+							continue;
3413
+						}
3414
+						//finally we will override any arguments in the referer with
3415
+						//what might be set on the _default_route_query_args array.
3416
+						if (isset($this->_default_route_query_args[$reference])) {
3417
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3418
+						} else {
3419
+							$args_to_merge[$reference] = urlencode($value);
3420
+						}
3421
+					}
3422
+					continue;
3423
+				}
3424
+				$args_to_merge[$query_param] = $query_value;
3425
+			}
3426
+			//now let's merge these arguments but override with what was specifically sent in to the
3427
+			//redirect.
3428
+			$query_args = array_merge($args_to_merge, $query_args);
3429
+		}
3430
+		$this->_process_notices($query_args);
3431
+		// generate redirect url
3432
+		// if redirecting to anything other than the main page, add a nonce
3433
+		if (isset($query_args['action'])) {
3434
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
3435
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3436
+		}
3437
+		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
3438
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3439
+		$redirect_url = apply_filters(
3440
+			'FHEE_redirect_' . $classname . $this->_req_action,
3441
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3442
+			$query_args
3443
+		);
3444
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3445
+		if (defined('DOING_AJAX')) {
3446
+			$default_data                    = array(
3447
+				'close'        => true,
3448
+				'redirect_url' => $redirect_url,
3449
+				'where'        => 'main',
3450
+				'what'         => 'append',
3451
+			);
3452
+			$this->_template_args['success'] = $success;
3453
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3454
+				$default_data,
3455
+				$this->_template_args['data']
3456
+			) : $default_data;
3457
+			$this->_return_json();
3458
+		}
3459
+		wp_safe_redirect($redirect_url);
3460
+		exit();
3461
+	}
3462
+
3463
+
3464
+
3465
+	/**
3466
+	 * process any notices before redirecting (or returning ajax request)
3467
+	 * This method sets the $this->_template_args['notices'] attribute;
3468
+	 *
3469
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3470
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3471
+	 *                                  page_routes haven't been defined yet.
3472
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3473
+	 *                                  still save a transient for the notice.
3474
+	 * @return void
3475
+	 */
3476
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3477
+	{
3478
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
3479
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3480
+			$notices = EE_Error::get_notices(false);
3481
+			if (empty($this->_template_args['success'])) {
3482
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3483
+			}
3484
+			if (empty($this->_template_args['errors'])) {
3485
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3486
+			}
3487
+			if (empty($this->_template_args['attention'])) {
3488
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3489
+			}
3490
+		}
3491
+		$this->_template_args['notices'] = EE_Error::get_notices();
3492
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3493
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3494
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3495
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
3496
+		}
3497
+	}
3498
+
3499
+
3500
+
3501
+	/**
3502
+	 * get_action_link_or_button
3503
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3504
+	 *
3505
+	 * @param string $action        use this to indicate which action the url is generated with.
3506
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3507
+	 *                              property.
3508
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3509
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3510
+	 * @param string $base_url      If this is not provided
3511
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3512
+	 *                              Otherwise this value will be used.
3513
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3514
+	 * @return string
3515
+	 * @throws \EE_Error
3516
+	 */
3517
+	public function get_action_link_or_button(
3518
+		$action,
3519
+		$type = 'add',
3520
+		$extra_request = array(),
3521
+		$class = 'button-primary',
3522
+		$base_url = '',
3523
+		$exclude_nonce = false
3524
+	) {
3525
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3526
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3527
+			throw new EE_Error(
3528
+				sprintf(
3529
+					__(
3530
+						'There is no page route for given action for the button.  This action was given: %s',
3531
+						'event_espresso'
3532
+					),
3533
+					$action
3534
+				)
3535
+			);
3536
+		}
3537
+		if (! isset($this->_labels['buttons'][$type])) {
3538
+			throw new EE_Error(
3539
+				sprintf(
3540
+					__(
3541
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3542
+						'event_espresso'
3543
+					),
3544
+					$type
3545
+				)
3546
+			);
3547
+		}
3548
+		//finally check user access for this button.
3549
+		$has_access = $this->check_user_access($action, true);
3550
+		if (! $has_access) {
3551
+			return '';
3552
+		}
3553
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3554
+		$query_args = array(
3555
+			'action' => $action,
3556
+		);
3557
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3558
+		if (! empty($extra_request)) {
3559
+			$query_args = array_merge($extra_request, $query_args);
3560
+		}
3561
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3562
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3563
+	}
3564
+
3565
+
3566
+
3567
+	/**
3568
+	 * _per_page_screen_option
3569
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3570
+	 *
3571
+	 * @return void
3572
+	 */
3573
+	protected function _per_page_screen_option()
3574
+	{
3575
+		$option = 'per_page';
3576
+		$args   = array(
3577
+			'label'   => $this->_admin_page_title,
3578
+			'default' => 10,
3579
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3580
+		);
3581
+		//ONLY add the screen option if the user has access to it.
3582
+		if ($this->check_user_access($this->_current_view, true)) {
3583
+			add_screen_option($option, $args);
3584
+		}
3585
+	}
3586
+
3587
+
3588
+
3589
+	/**
3590
+	 * set_per_page_screen_option
3591
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3592
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3593
+	 * admin_menu.
3594
+	 *
3595
+	 * @access private
3596
+	 * @return void
3597
+	 */
3598
+	private function _set_per_page_screen_options()
3599
+	{
3600
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3601
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3602
+			if (! $user = wp_get_current_user()) {
3603
+				return;
3604
+			}
3605
+			$option = $_POST['wp_screen_options']['option'];
3606
+			$value  = $_POST['wp_screen_options']['value'];
3607
+			if ($option != sanitize_key($option)) {
3608
+				return;
3609
+			}
3610
+			$map_option = $option;
3611
+			$option     = str_replace('-', '_', $option);
3612
+			switch ($map_option) {
3613
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3614
+					$value = (int)$value;
3615
+					if ($value < 1 || $value > 999) {
3616
+						return;
3617
+					}
3618
+					break;
3619
+				default:
3620
+					$value = apply_filters(
3621
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
+						false,
3623
+						$option,
3624
+						$value
3625
+					);
3626
+					if (false === $value) {
3627
+						return;
3628
+					}
3629
+					break;
3630
+			}
3631
+			update_user_meta($user->ID, $option, $value);
3632
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3633
+			exit;
3634
+		}
3635
+	}
3636
+
3637
+
3638
+
3639
+	/**
3640
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
+	 *
3642
+	 * @param array $data array that will be assigned to template args.
3643
+	 */
3644
+	public function set_template_args($data)
3645
+	{
3646
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3647
+	}
3648
+
3649
+
3650
+
3651
+	/**
3652
+	 * This makes available the WP transient system for temporarily moving data between routes
3653
+	 *
3654
+	 * @access protected
3655
+	 * @param string $route             the route that should receive the transient
3656
+	 * @param array  $data              the data that gets sent
3657
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3658
+	 *                                  normal route transient.
3659
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3660
+	 *                                  when we are adding a transient before page_routes have been defined.
3661
+	 * @return void
3662
+	 */
3663
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3664
+	{
3665
+		$user_id = get_current_user_id();
3666
+		if (! $skip_route_verify) {
3667
+			$this->_verify_route($route);
3668
+		}
3669
+		//now let's set the string for what kind of transient we're setting
3670
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3671
+		$data      = $notices ? array('notices' => $data) : $data;
3672
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3673
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3674
+		if ($existing) {
3675
+			$data = array_merge((array)$data, (array)$existing);
3676
+		}
3677
+		if (is_multisite() && is_network_admin()) {
3678
+			set_site_transient($transient, $data, 8);
3679
+		} else {
3680
+			set_transient($transient, $data, 8);
3681
+		}
3682
+	}
3683
+
3684
+
3685
+
3686
+	/**
3687
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3688
+	 *
3689
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3690
+	 * @return mixed data
3691
+	 */
3692
+	protected function _get_transient($notices = false, $route = false)
3693
+	{
3694
+		$user_id   = get_current_user_id();
3695
+		$route     = ! $route ? $this->_req_action : $route;
3696
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3697
+		$data      = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3698
+		//delete transient after retrieval (just in case it hasn't expired);
3699
+		if (is_multisite() && is_network_admin()) {
3700
+			delete_site_transient($transient);
3701
+		} else {
3702
+			delete_transient($transient);
3703
+		}
3704
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3705
+	}
3706
+
3707
+
3708
+
3709
+	/**
3710
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3711
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3712
+	 * default route callback on the EE_Admin page you want it run.)
3713
+	 *
3714
+	 * @return void
3715
+	 */
3716
+	protected function _transient_garbage_collection()
3717
+	{
3718
+		global $wpdb;
3719
+		//retrieve all existing transients
3720
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3721
+		if ($results = $wpdb->get_results($query)) {
3722
+			foreach ($results as $result) {
3723
+				$transient = str_replace('_transient_', '', $result->option_name);
3724
+				get_transient($transient);
3725
+				if (is_multisite() && is_network_admin()) {
3726
+					get_site_transient($transient);
3727
+				}
3728
+			}
3729
+		}
3730
+	}
3731
+
3732
+
3733
+
3734
+	/**
3735
+	 * get_view
3736
+	 *
3737
+	 * @access public
3738
+	 * @return string content of _view property
3739
+	 */
3740
+	public function get_view()
3741
+	{
3742
+		return $this->_view;
3743
+	}
3744
+
3745
+
3746
+
3747
+	/**
3748
+	 * getter for the protected $_views property
3749
+	 *
3750
+	 * @return array
3751
+	 */
3752
+	public function get_views()
3753
+	{
3754
+		return $this->_views;
3755
+	}
3756
+
3757
+
3758
+
3759
+	/**
3760
+	 * get_current_page
3761
+	 *
3762
+	 * @access public
3763
+	 * @return string _current_page property value
3764
+	 */
3765
+	public function get_current_page()
3766
+	{
3767
+		return $this->_current_page;
3768
+	}
3769
+
3770
+
3771
+
3772
+	/**
3773
+	 * get_current_view
3774
+	 *
3775
+	 * @access public
3776
+	 * @return string _current_view property value
3777
+	 */
3778
+	public function get_current_view()
3779
+	{
3780
+		return $this->_current_view;
3781
+	}
3782
+
3783
+
3784
+
3785
+	/**
3786
+	 * get_current_screen
3787
+	 *
3788
+	 * @access public
3789
+	 * @return object The current WP_Screen object
3790
+	 */
3791
+	public function get_current_screen()
3792
+	{
3793
+		return $this->_current_screen;
3794
+	}
3795
+
3796
+
3797
+
3798
+	/**
3799
+	 * get_current_page_view_url
3800
+	 *
3801
+	 * @access public
3802
+	 * @return string This returns the url for the current_page_view.
3803
+	 */
3804
+	public function get_current_page_view_url()
3805
+	{
3806
+		return $this->_current_page_view_url;
3807
+	}
3808
+
3809
+
3810
+
3811
+	/**
3812
+	 * just returns the _req_data property
3813
+	 *
3814
+	 * @return array
3815
+	 */
3816
+	public function get_request_data()
3817
+	{
3818
+		return $this->_req_data;
3819
+	}
3820
+
3821
+
3822
+
3823
+	/**
3824
+	 * returns the _req_data protected property
3825
+	 *
3826
+	 * @return string
3827
+	 */
3828
+	public function get_req_action()
3829
+	{
3830
+		return $this->_req_action;
3831
+	}
3832
+
3833
+
3834
+
3835
+	/**
3836
+	 * @return bool  value of $_is_caf property
3837
+	 */
3838
+	public function is_caf()
3839
+	{
3840
+		return $this->_is_caf;
3841
+	}
3842
+
3843
+
3844
+
3845
+	/**
3846
+	 * @return mixed
3847
+	 */
3848
+	public function default_espresso_metaboxes()
3849
+	{
3850
+		return $this->_default_espresso_metaboxes;
3851
+	}
3852
+
3853
+
3854
+
3855
+	/**
3856
+	 * @return mixed
3857
+	 */
3858
+	public function admin_base_url()
3859
+	{
3860
+		return $this->_admin_base_url;
3861
+	}
3862 3862
 
3863 3863
 
3864 3864
 
3865
-    /**
3866
-     * @return mixed
3867
-     */
3868
-    public function wp_page_slug()
3869
-    {
3870
-        return $this->_wp_page_slug;
3871
-    }
3872
-
3873
-
3874
-
3875
-    /**
3876
-     * updates  espresso configuration settings
3877
-     *
3878
-     * @access    protected
3879
-     * @param string                   $tab
3880
-     * @param EE_Config_Base|EE_Config $config
3881
-     * @param string                   $file file where error occurred
3882
-     * @param string                   $func function  where error occurred
3883
-     * @param string                   $line line no where error occurred
3884
-     * @return boolean
3885
-     */
3886
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3887
-    {
3888
-        //remove any options that are NOT going to be saved with the config settings.
3889
-        if (isset($config->core->ee_ueip_optin)) {
3890
-            $config->core->ee_ueip_has_notified = true;
3891
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3892
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3893
-            update_option('ee_ueip_has_notified', true);
3894
-        }
3895
-        // and save it (note we're also doing the network save here)
3896
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3897
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3898
-        if ($config_saved && $net_saved) {
3899
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3900
-            return true;
3901
-        } else {
3902
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3903
-            return false;
3904
-        }
3905
-    }
3906
-
3907
-
3908
-
3909
-    /**
3910
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3911
-     *
3912
-     * @return array
3913
-     */
3914
-    public function get_yes_no_values()
3915
-    {
3916
-        return $this->_yes_no_values;
3917
-    }
3918
-
3919
-
3920
-
3921
-    protected function _get_dir()
3922
-    {
3923
-        $reflector = new ReflectionClass(get_class($this));
3924
-        return dirname($reflector->getFileName());
3925
-    }
3926
-
3927
-
3928
-
3929
-    /**
3930
-     * A helper for getting a "next link".
3931
-     *
3932
-     * @param string $url   The url to link to
3933
-     * @param string $class The class to use.
3934
-     * @return string
3935
-     */
3936
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3937
-    {
3938
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3939
-    }
3940
-
3941
-
3942
-
3943
-    /**
3944
-     * A helper for getting a "previous link".
3945
-     *
3946
-     * @param string $url   The url to link to
3947
-     * @param string $class The class to use.
3948
-     * @return string
3949
-     */
3950
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3951
-    {
3952
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3953
-    }
3954
-
3955
-
3956
-
3957
-
3958
-
3959
-
3960
-
3961
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3962
-
3963
-
3964
-    /**
3965
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3966
-     * 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
3967
-     * _req_data array.
3968
-     *
3969
-     * @return bool success/fail
3970
-     */
3971
-    protected function _process_resend_registration()
3972
-    {
3973
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3974
-        do_action(
3975
-            'AHEE__EE_Admin_Page___process_resend_registration',
3976
-            $this->_template_args['success'],
3977
-            $this->_req_data
3978
-        );
3979
-        return $this->_template_args['success'];
3980
-    }
3981
-
3982
-
3983
-
3984
-    /**
3985
-     * This automatically processes any payment message notifications when manual payment has been applied.
3986
-     *
3987
-     * @access protected
3988
-     * @param \EE_Payment $payment
3989
-     * @return bool success/fail
3990
-     */
3991
-    protected function _process_payment_notification(EE_Payment $payment)
3992
-    {
3993
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3994
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3995
-        $this->_template_args['success'] = apply_filters(
3996
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3997
-            false,
3998
-            $payment
3999
-        );
4000
-        return $this->_template_args['success'];
4001
-    }
3865
+	/**
3866
+	 * @return mixed
3867
+	 */
3868
+	public function wp_page_slug()
3869
+	{
3870
+		return $this->_wp_page_slug;
3871
+	}
3872
+
3873
+
3874
+
3875
+	/**
3876
+	 * updates  espresso configuration settings
3877
+	 *
3878
+	 * @access    protected
3879
+	 * @param string                   $tab
3880
+	 * @param EE_Config_Base|EE_Config $config
3881
+	 * @param string                   $file file where error occurred
3882
+	 * @param string                   $func function  where error occurred
3883
+	 * @param string                   $line line no where error occurred
3884
+	 * @return boolean
3885
+	 */
3886
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3887
+	{
3888
+		//remove any options that are NOT going to be saved with the config settings.
3889
+		if (isset($config->core->ee_ueip_optin)) {
3890
+			$config->core->ee_ueip_has_notified = true;
3891
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3892
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3893
+			update_option('ee_ueip_has_notified', true);
3894
+		}
3895
+		// and save it (note we're also doing the network save here)
3896
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3897
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3898
+		if ($config_saved && $net_saved) {
3899
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3900
+			return true;
3901
+		} else {
3902
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3903
+			return false;
3904
+		}
3905
+	}
3906
+
3907
+
3908
+
3909
+	/**
3910
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3911
+	 *
3912
+	 * @return array
3913
+	 */
3914
+	public function get_yes_no_values()
3915
+	{
3916
+		return $this->_yes_no_values;
3917
+	}
3918
+
3919
+
3920
+
3921
+	protected function _get_dir()
3922
+	{
3923
+		$reflector = new ReflectionClass(get_class($this));
3924
+		return dirname($reflector->getFileName());
3925
+	}
3926
+
3927
+
3928
+
3929
+	/**
3930
+	 * A helper for getting a "next link".
3931
+	 *
3932
+	 * @param string $url   The url to link to
3933
+	 * @param string $class The class to use.
3934
+	 * @return string
3935
+	 */
3936
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3937
+	{
3938
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3939
+	}
3940
+
3941
+
3942
+
3943
+	/**
3944
+	 * A helper for getting a "previous link".
3945
+	 *
3946
+	 * @param string $url   The url to link to
3947
+	 * @param string $class The class to use.
3948
+	 * @return string
3949
+	 */
3950
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3951
+	{
3952
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3953
+	}
3954
+
3955
+
3956
+
3957
+
3958
+
3959
+
3960
+
3961
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3962
+
3963
+
3964
+	/**
3965
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3966
+	 * 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
3967
+	 * _req_data array.
3968
+	 *
3969
+	 * @return bool success/fail
3970
+	 */
3971
+	protected function _process_resend_registration()
3972
+	{
3973
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3974
+		do_action(
3975
+			'AHEE__EE_Admin_Page___process_resend_registration',
3976
+			$this->_template_args['success'],
3977
+			$this->_req_data
3978
+		);
3979
+		return $this->_template_args['success'];
3980
+	}
3981
+
3982
+
3983
+
3984
+	/**
3985
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3986
+	 *
3987
+	 * @access protected
3988
+	 * @param \EE_Payment $payment
3989
+	 * @return bool success/fail
3990
+	 */
3991
+	protected function _process_payment_notification(EE_Payment $payment)
3992
+	{
3993
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3994
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3995
+		$this->_template_args['success'] = apply_filters(
3996
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3997
+			false,
3998
+			$payment
3999
+		);
4000
+		return $this->_template_args['success'];
4001
+	}
4002 4002
 
4003 4003
 
4004 4004
 }
Please login to merge, or discard this patch.
Spacing   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\InterminableInterface;
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 /**
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
510 510
         $this->page_folder   = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
511 511
         global $ee_menu_slugs;
512
-        $ee_menu_slugs = (array)$ee_menu_slugs;
513
-        if ((! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
512
+        $ee_menu_slugs = (array) $ee_menu_slugs;
513
+        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
514 514
             return;
515 515
         }
516 516
         // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         $this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route']
530 530
             : $this->_req_action;
531 531
         $this->_current_view = $this->_req_action;
532
-        $this->_req_nonce    = $this->_req_action . '_nonce';
532
+        $this->_req_nonce    = $this->_req_action.'_nonce';
533 533
         $this->_define_page_props();
534 534
         $this->_current_page_view_url = add_query_arg(
535 535
             array('page' => $this->_current_page, 'action' => $this->_current_view),
@@ -559,20 +559,20 @@  discard block
 block discarded – undo
559 559
         }
560 560
         //filter routes and page_config so addons can add their stuff. Filtering done per class
561 561
         $this->_page_routes = apply_filters(
562
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
563 563
             $this->_page_routes,
564 564
             $this
565 565
         );
566 566
         $this->_page_config = apply_filters(
567
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
567
+            'FHEE__'.get_class($this).'__page_setup__page_config',
568 568
             $this->_page_config,
569 569
             $this
570 570
         );
571 571
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present 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)) {
572
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
573 573
             add_action(
574 574
                 'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
575
+                array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view),
576 576
                 10,
577 577
                 2
578 578
             );
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
             if ($this->_is_UI_request) {
586 586
                 //admin_init stuff - global, all views for this page class, specific view
587 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);
588
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
589
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
590 590
                 }
591 591
             } else {
592 592
                 //hijack regular WP loading and route admin request immediately
@@ -606,12 +606,12 @@  discard block
 block discarded – undo
606 606
      */
607 607
     private function _do_other_page_hooks()
608 608
     {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
609
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
610 610
         foreach ($registered_pages as $page) {
611 611
             //now let's setup the file name and class that should be present
612 612
             $classname = str_replace('.class.php', '', $page);
613 613
             //autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
614
+            if ( ! class_exists($classname)) {
615 615
                 $error_msg[] = sprintf(
616 616
                     esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'),
617 617
                     $page
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
                                    ),
626 626
                                    $page,
627 627
                                    '<br />',
628
-                                   '<strong>' . $classname . '</strong>'
628
+                                   '<strong>'.$classname.'</strong>'
629 629
                                );
630 630
                 throw new EE_Error(implode('||', $error_msg));
631 631
             }
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
         //load admin_notices - global, page class, and view specific
663 663
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
664 664
         add_action('admin_notices', array($this, 'admin_notices'), 10);
665
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
666
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
665
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
666
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
667 667
         }
668 668
         //load network admin_notices - global, page class, and view specific
669 669
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
670
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
671
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
670
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
671
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
672 672
         }
673 673
         //this will save any per_page screen options if they are present
674 674
         $this->_set_per_page_screen_options();
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
         //add screen options - global, page child class, and view specific
681 681
         $this->_add_global_screen_options();
682 682
         $this->_add_screen_options();
683
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
684
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
683
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
684
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
685 685
         }
686 686
         //add help tab(s) and tours- set via page_config and qtips.
687 687
         $this->_add_help_tour();
@@ -690,32 +690,32 @@  discard block
 block discarded – undo
690 690
         //add feature_pointers - global, page child class, and view specific
691 691
         $this->_add_feature_pointers();
692 692
         $this->_add_global_feature_pointers();
693
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
694
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
693
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
694
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
695 695
         }
696 696
         //enqueue scripts/styles - global, page class, and view specific
697 697
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
698 698
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
699
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
700
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
699
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
700
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
701 701
         }
702 702
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
703 703
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
704 704
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
705 705
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
706
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
707
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
706
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
707
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
708 708
         }
709 709
         //admin footer scripts
710 710
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
711 711
         add_action('admin_footer', array($this, 'admin_footer'), 100);
712
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
713
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
712
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
713
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
714 714
         }
715 715
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
716 716
         //targeted hook
717 717
         do_action(
718
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action
718
+            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action
719 719
         );
720 720
     }
721 721
 
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
     protected function _verify_routes()
783 783
     {
784 784
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
785
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
785
+        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
786 786
             return false;
787 787
         }
788 788
         $this->_route = false;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
                 $this->_admin_page_title
797 797
             );
798 798
             // developer error msg
799
-            $error_msg .= '||' . $error_msg . __(
799
+            $error_msg .= '||'.$error_msg.__(
800 800
                     ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
801 801
                     'event_espresso'
802 802
                 );
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
                 $this->_admin_page_title
815 815
             );
816 816
             // developer error msg
817
-            $error_msg .= '||' . $error_msg . sprintf(
817
+            $error_msg .= '||'.$error_msg.sprintf(
818 818
                     __(
819 819
                         ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
820 820
                         'event_espresso'
@@ -824,14 +824,14 @@  discard block
 block discarded – undo
824 824
             throw new EE_Error($error_msg);
825 825
         }
826 826
         // and that a default route exists
827
-        if (! array_key_exists('default', $this->_page_routes)) {
827
+        if ( ! array_key_exists('default', $this->_page_routes)) {
828 828
             // user error msg
829 829
             $error_msg = sprintf(
830 830
                 __('A default page route has not been set for the % admin page.', 'event_espresso'),
831 831
                 $this->_admin_page_title
832 832
             );
833 833
             // developer error msg
834
-            $error_msg .= '||' . $error_msg . __(
834
+            $error_msg .= '||'.$error_msg.__(
835 835
                     ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
836 836
                     'event_espresso'
837 837
                 );
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
         //first lets' catch if the UI request has EVER been set.
841 841
         if ($this->_is_UI_request === null) {
842 842
             //lets set if this is a UI request or not.
843
-            $this->_is_UI_request = (! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
843
+            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
844 844
                 ? true : false;
845 845
             //wait a minute... we might have a noheader in the route array
846 846
             $this->_is_UI_request = is_array($this->_route)
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
                 $this->_admin_page_title
870 870
             );
871 871
             // developer error msg
872
-            $error_msg .= '||' . $error_msg . sprintf(
872
+            $error_msg .= '||'.$error_msg.sprintf(
873 873
                     __(
874 874
                         ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
875 875
                         'event_espresso'
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
     protected function _verify_nonce($nonce, $nonce_ref)
895 895
     {
896 896
         // verify nonce against expected value
897
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
897
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
898 898
             // these are not the droids you are looking for !!!
899 899
             $msg = sprintf(
900 900
                 __('%sNonce Fail.%s', 'event_espresso'),
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
                 '</a>'
903 903
             );
904 904
             if (WP_DEBUG) {
905
-                $msg .= "\n  " . sprintf(
905
+                $msg .= "\n  ".sprintf(
906 906
                         __(
907 907
                             'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
908 908
                             'event_espresso'
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                         __CLASS__
911 911
                     );
912 912
             }
913
-            if (! defined('DOING_AJAX')) {
913
+            if ( ! defined('DOING_AJAX')) {
914 914
                 wp_die($msg);
915 915
             } else {
916 916
                 EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
      */
934 934
     protected function _route_admin_request()
935 935
     {
936
-        if (! $this->_is_UI_request) {
936
+        if ( ! $this->_is_UI_request) {
937 937
             $this->_verify_routes();
938 938
         }
939 939
         $nonce_check = isset($this->_route_config['require_nonce'])
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
         $error_msg = '';
958 958
         // action right before calling route
959 959
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
960
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
960
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
961 961
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
962 962
         }
963 963
         // right before calling the route, let's remove _wp_http_referer from the
964 964
         // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
965 965
         $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
966
-        if (! empty($func)) {
966
+        if ( ! empty($func)) {
967 967
             if (is_array($func)) {
968 968
                 list($class, $method) = $func;
969 969
             } elseif (strpos($func, '::') !== false) {
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
                 $class  = $this;
973 973
                 $method = $func;
974 974
             }
975
-            if (! (is_object($class) && $class === $this)) {
975
+            if ( ! (is_object($class) && $class === $this)) {
976 976
                 // send along this admin page object for access by addons.
977 977
                 $args['admin_page_object'] = $this;
978 978
             }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
                     $method
1009 1009
                 );
1010 1010
             }
1011
-            if (! empty($error_msg)) {
1011
+            if ( ! empty($error_msg)) {
1012 1012
                 throw new EE_Error($error_msg);
1013 1013
             }
1014 1014
         }
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
                 if (strpos($key, 'nonce') !== false) {
1090 1090
                     continue;
1091 1091
                 }
1092
-                $args['wp_referer[' . $key . ']'] = $value;
1092
+                $args['wp_referer['.$key.']'] = $value;
1093 1093
             }
1094 1094
         }
1095 1095
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1154 1154
             if (is_array($config) && isset($config['help_sidebar'])) {
1155 1155
                 //check that the callback given is valid
1156
-                if (! method_exists($this, $config['help_sidebar'])) {
1156
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1157 1157
                     throw new EE_Error(
1158 1158
                         sprintf(
1159 1159
                             __(
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
                     );
1167 1167
                 }
1168 1168
                 $content = apply_filters(
1169
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1169
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1170 1170
                     call_user_func(array($this, $config['help_sidebar']))
1171 1171
                 );
1172 1172
                 $content .= $tour_buttons; //add help tour buttons.
@@ -1174,26 +1174,26 @@  discard block
 block discarded – undo
1174 1174
                 $this->_current_screen->set_help_sidebar($content);
1175 1175
             }
1176 1176
             //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1177
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1177
+            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1178 1178
                 $this->_current_screen->set_help_sidebar($tour_buttons);
1179 1179
             }
1180 1180
             //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1181
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1181
+            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1182 1182
                 $_ht['id']      = $this->page_slug;
1183 1183
                 $_ht['title']   = __('Help Tours', 'event_espresso');
1184
-                $_ht['content'] = '<p>' . __(
1184
+                $_ht['content'] = '<p>'.__(
1185 1185
                         'The buttons to the right allow you to start/restart any help tours available for this page',
1186 1186
                         'event_espresso'
1187
-                    ) . '</p>';
1187
+                    ).'</p>';
1188 1188
                 $this->_current_screen->add_help_tab($_ht);
1189 1189
             }/**/
1190
-            if (! isset($config['help_tabs'])) {
1190
+            if ( ! isset($config['help_tabs'])) {
1191 1191
                 return;
1192 1192
             } //no help tabs for this route
1193
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1193
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1194 1194
                 //we're here so there ARE help tabs!
1195 1195
                 //make sure we've got what we need
1196
-                if (! isset($cfg['title'])) {
1196
+                if ( ! isset($cfg['title'])) {
1197 1197
                     throw new EE_Error(
1198 1198
                         __(
1199 1199
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
                         )
1202 1202
                     );
1203 1203
                 }
1204
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1204
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1205 1205
                     throw new EE_Error(
1206 1206
                         __(
1207 1207
                             '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',
@@ -1210,11 +1210,11 @@  discard block
 block discarded – undo
1210 1210
                     );
1211 1211
                 }
1212 1212
                 //first priority goes to content.
1213
-                if (! empty($cfg['content'])) {
1213
+                if ( ! empty($cfg['content'])) {
1214 1214
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1215 1215
                     //second priority goes to filename
1216
-                } elseif (! empty($cfg['filename'])) {
1217
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1216
+                } elseif ( ! empty($cfg['filename'])) {
1217
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1218 1218
                     //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)
1219 1219
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1220 1220
                                                              . basename($this->_get_dir())
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
                                                              . $cfg['filename']
1223 1223
                                                              . '.help_tab.php' : $file_path;
1224 1224
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1225
-                    if (! is_readable($file_path) && ! isset($cfg['callback'])) {
1225
+                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1226 1226
                         EE_Error::add_error(
1227 1227
                             sprintf(
1228 1228
                                 __(
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
                     $content = '';
1246 1246
                 }
1247 1247
                 //check if callback is valid
1248
-                if (empty($content) && (! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1248
+                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1249 1249
                     EE_Error::add_error(
1250 1250
                         sprintf(
1251 1251
                             __(
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
                     return;
1262 1262
                 }
1263 1263
                 //setup config array for help tab method
1264
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1264
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1265 1265
                 $_ht = array(
1266 1266
                     'id'       => $id,
1267 1267
                     'title'    => $cfg['title'],
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
         $tours            = array();
1291 1291
         $this->_help_tour = array();
1292 1292
         //exit early if help tours are turned off globally
1293
-        if (! EE_Registry::instance()->CFG->admin->help_tour_activation
1293
+        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation
1294 1294
             || (defined('EE_DISABLE_HELP_TOURS')
1295 1295
                 && EE_DISABLE_HELP_TOURS)) {
1296 1296
             return;
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
             }
1304 1304
             if (isset($config['help_tour'])) {
1305 1305
                 foreach ($config['help_tour'] as $tour) {
1306
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1306
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1307 1307
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1308 1308
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1309 1309
                                                              . basename($this->_get_dir())
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
                                                              . $tour
1312 1312
                                                              . '.class.php' : $file_path;
1313 1313
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1314
-                    if (! is_readable($file_path)) {
1314
+                    if ( ! is_readable($file_path)) {
1315 1315
                         EE_Error::add_error(
1316 1316
                             sprintf(
1317 1317
                                 __(
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
                         return;
1329 1329
                     }
1330 1330
                     require_once $file_path;
1331
-                    if (! class_exists($tour)) {
1331
+                    if ( ! class_exists($tour)) {
1332 1332
                         $error_msg[] = sprintf(
1333 1333
                             __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1334 1334
                             $tour
1335 1335
                         );
1336
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1336
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(
1337 1337
                                 __(
1338 1338
                                     '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.',
1339 1339
                                     'event_espresso'
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
                 $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1358 1358
             }
1359 1359
         }
1360
-        if (! empty($tours)) {
1360
+        if ( ! empty($tours)) {
1361 1361
             $this->_help_tour['tours'] = $tours;
1362 1362
         }
1363 1363
         //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
@@ -1374,11 +1374,11 @@  discard block
 block discarded – undo
1374 1374
     protected function _add_qtips()
1375 1375
     {
1376 1376
         if (isset($this->_route_config['qtips'])) {
1377
-            $qtips = (array)$this->_route_config['qtips'];
1377
+            $qtips = (array) $this->_route_config['qtips'];
1378 1378
             //load qtip loader
1379 1379
             $path = array(
1380
-                $this->_get_dir() . '/qtips/',
1381
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1380
+                $this->_get_dir().'/qtips/',
1381
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1382 1382
             );
1383 1383
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1384 1384
         }
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1400 1400
         $i = 0;
1401 1401
         foreach ($this->_page_config as $slug => $config) {
1402
-            if (! is_array($config)
1402
+            if ( ! is_array($config)
1403 1403
                 || (is_array($config)
1404 1404
                     && (isset($config['nav']) && ! $config['nav'])
1405 1405
                     || ! isset($config['nav']))) {
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
             if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1410 1410
                 continue;
1411 1411
             } //nav tab is only to appear when route requested.
1412
-            if (! $this->check_user_access($slug, true)) {
1412
+            if ( ! $this->check_user_access($slug, true)) {
1413 1413
                 continue;
1414 1414
             } //no nav tab becasue current user does not have access.
1415
-            $css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1415
+            $css_class              = isset($config['css_class']) ? $config['css_class'].' ' : '';
1416 1416
             $this->_nav_tabs[$slug] = array(
1417 1417
                 'url'       => isset($config['nav']['url'])
1418 1418
                     ? $config['nav']['url']
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
                     : ucwords(
1426 1426
                         str_replace('_', ' ', $slug)
1427 1427
                     ),
1428
-                'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1428
+                'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1429 1429
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1430 1430
             );
1431 1431
             $i++;
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
             $capability = empty($capability) ? 'manage_options' : $capability;
1496 1496
         }
1497 1497
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1498
-        if ((! function_exists('is_admin')
1498
+        if (( ! function_exists('is_admin')
1499 1499
              || ! EE_Registry::instance()->CAP->current_user_can(
1500 1500
                     $capability,
1501 1501
                     $this->page_slug
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
     public function admin_footer_global()
1607 1607
     {
1608 1608
         //dialog container for dialog helper
1609
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1609
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1610 1610
         $d_cont .= '<div class="ee-notices"></div>';
1611 1611
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1612 1612
         $d_cont .= '</div>';
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1617 1617
         }
1618 1618
         //current set timezone for timezone js
1619
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1619
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1620 1620
     }
1621 1621
 
1622 1622
 
@@ -1645,11 +1645,11 @@  discard block
 block discarded – undo
1645 1645
     {
1646 1646
         $content       = '';
1647 1647
         $help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1648
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1648
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1649 1649
         //loop through the array and setup content
1650 1650
         foreach ($help_array as $trigger => $help) {
1651 1651
             //make sure the array is setup properly
1652
-            if (! isset($help['title']) || ! isset($help['content'])) {
1652
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1653 1653
                 throw new EE_Error(
1654 1654
                     __(
1655 1655
                         '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',
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
                 'help_popup_title'   => $help['title'],
1664 1664
                 'help_popup_content' => $help['content'],
1665 1665
             );
1666
-            $content       .= EEH_Template::display_template($template_path, $template_args, true);
1666
+            $content .= EEH_Template::display_template($template_path, $template_args, true);
1667 1667
         }
1668 1668
         if ($display) {
1669 1669
             echo $content;
@@ -1683,15 +1683,15 @@  discard block
 block discarded – undo
1683 1683
     private function _get_help_content()
1684 1684
     {
1685 1685
         //what is the method we're looking for?
1686
-        $method_name = '_help_popup_content_' . $this->_req_action;
1686
+        $method_name = '_help_popup_content_'.$this->_req_action;
1687 1687
         //if method doesn't exist let's get out.
1688
-        if (! method_exists($this, $method_name)) {
1688
+        if ( ! method_exists($this, $method_name)) {
1689 1689
             return array();
1690 1690
         }
1691 1691
         //k we're good to go let's retrieve the help array
1692 1692
         $help_array = call_user_func(array($this, $method_name));
1693 1693
         //make sure we've got an array!
1694
-        if (! is_array($help_array)) {
1694
+        if ( ! is_array($help_array)) {
1695 1695
             throw new EE_Error(
1696 1696
                 __(
1697 1697
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
                     'event_espresso'
1732 1732
                 ),
1733 1733
             );
1734
-            $help_content            = $this->_set_help_popup_content($help_array, false);
1734
+            $help_content = $this->_set_help_popup_content($help_array, false);
1735 1735
         }
1736 1736
         //let's setup the trigger
1737 1737
         $content = '<a class="ee-dialog" href="?height='
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
                    . '&inlineId='
1742 1742
                    . $trigger_id
1743 1743
                    . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1744
-        $content = $content . $help_content;
1744
+        $content = $content.$help_content;
1745 1745
         if ($display) {
1746 1746
             echo $content;
1747 1747
         } else {
@@ -1804,15 +1804,15 @@  discard block
 block discarded – undo
1804 1804
         // register all styles
1805 1805
         wp_register_style(
1806 1806
             'espresso-ui-theme',
1807
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1807
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1808 1808
             array(),
1809 1809
             EVENT_ESPRESSO_VERSION
1810 1810
         );
1811
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1811
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1812 1812
         //helpers styles
1813 1813
         wp_register_style(
1814 1814
             'ee-text-links',
1815
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1815
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1816 1816
             array(),
1817 1817
             EVENT_ESPRESSO_VERSION
1818 1818
         );
@@ -1820,21 +1820,21 @@  discard block
 block discarded – undo
1820 1820
         //register all scripts
1821 1821
         wp_register_script(
1822 1822
             'ee-dialog',
1823
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1823
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1824 1824
             array('jquery', 'jquery-ui-draggable'),
1825 1825
             EVENT_ESPRESSO_VERSION,
1826 1826
             true
1827 1827
         );
1828 1828
         wp_register_script(
1829 1829
             'ee_admin_js',
1830
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1830
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1831 1831
             array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1832 1832
             EVENT_ESPRESSO_VERSION,
1833 1833
             true
1834 1834
         );
1835 1835
         wp_register_script(
1836 1836
             'jquery-ui-timepicker-addon',
1837
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1837
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1838 1838
             array('jquery-ui-datepicker', 'jquery-ui-slider'),
1839 1839
             EVENT_ESPRESSO_VERSION,
1840 1840
             true
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
         //script for sorting tables
1844 1844
         wp_register_script(
1845 1845
             'espresso_ajax_table_sorting',
1846
-            EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js",
1846
+            EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js",
1847 1847
             array('ee_admin_js', 'jquery-ui-sortable'),
1848 1848
             EVENT_ESPRESSO_VERSION,
1849 1849
             true
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
         //script for parsing uri's
1852 1852
         wp_register_script(
1853 1853
             'ee-parse-uri',
1854
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1854
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1855 1855
             array(),
1856 1856
             EVENT_ESPRESSO_VERSION,
1857 1857
             true
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
         //and parsing associative serialized form elements
1860 1860
         wp_register_script(
1861 1861
             'ee-serialize-full-array',
1862
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1862
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1863 1863
             array('jquery'),
1864 1864
             EVENT_ESPRESSO_VERSION,
1865 1865
             true
@@ -1867,28 +1867,28 @@  discard block
 block discarded – undo
1867 1867
         //helpers scripts
1868 1868
         wp_register_script(
1869 1869
             'ee-text-links',
1870
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1870
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1871 1871
             array('jquery'),
1872 1872
             EVENT_ESPRESSO_VERSION,
1873 1873
             true
1874 1874
         );
1875 1875
         wp_register_script(
1876 1876
             'ee-moment-core',
1877
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1877
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1878 1878
             array(),
1879 1879
             EVENT_ESPRESSO_VERSION,
1880 1880
             true
1881 1881
         );
1882 1882
         wp_register_script(
1883 1883
             'ee-moment',
1884
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1884
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1885 1885
             array('ee-moment-core'),
1886 1886
             EVENT_ESPRESSO_VERSION,
1887 1887
             true
1888 1888
         );
1889 1889
         wp_register_script(
1890 1890
             'ee-datepicker',
1891
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1891
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1892 1892
             array('jquery-ui-timepicker-addon', 'ee-moment'),
1893 1893
             EVENT_ESPRESSO_VERSION,
1894 1894
             true
@@ -1923,11 +1923,11 @@  discard block
 block discarded – undo
1923 1923
         /**
1924 1924
          * help tour stuff
1925 1925
          */
1926
-        if (! empty($this->_help_tour)) {
1926
+        if ( ! empty($this->_help_tour)) {
1927 1927
             //register the js for kicking things off
1928 1928
             wp_enqueue_script(
1929 1929
                 'ee-help-tour',
1930
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1930
+                EE_ADMIN_URL.'assets/ee-help-tour.js',
1931 1931
                 array('jquery-joyride'),
1932 1932
                 EVENT_ESPRESSO_VERSION,
1933 1933
                 true
@@ -2025,30 +2025,30 @@  discard block
 block discarded – undo
2025 2025
     protected function _set_list_table()
2026 2026
     {
2027 2027
         //first is this a list_table view?
2028
-        if (! isset($this->_route_config['list_table'])) {
2028
+        if ( ! isset($this->_route_config['list_table'])) {
2029 2029
             return;
2030 2030
         } //not a list_table view so get out.
2031 2031
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
2032
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
2032
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
2033 2033
             //user error msg
2034 2034
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
2035 2035
             //developer error msg
2036
-            $error_msg .= '||' . sprintf(
2036
+            $error_msg .= '||'.sprintf(
2037 2037
                     __(
2038 2038
                         '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.',
2039 2039
                         'event_espresso'
2040 2040
                     ),
2041 2041
                     $this->_req_action,
2042
-                    '_set_list_table_views_' . $this->_req_action
2042
+                    '_set_list_table_views_'.$this->_req_action
2043 2043
                 );
2044 2044
             throw new EE_Error($error_msg);
2045 2045
         }
2046 2046
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2047 2047
         $this->_views = apply_filters(
2048
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2048
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2049 2049
             $this->_views
2050 2050
         );
2051
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2051
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2052 2052
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2053 2053
         $this->_set_list_table_view();
2054 2054
         $this->_set_list_table_object();
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
     {
2067 2067
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2068 2068
         // looking at active items or dumpster diving ?
2069
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2069
+        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2070 2070
             $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2071 2071
         } else {
2072 2072
             $this->_view = sanitize_key($this->_req_data['status']);
@@ -2084,7 +2084,7 @@  discard block
 block discarded – undo
2084 2084
     protected function _set_list_table_object()
2085 2085
     {
2086 2086
         if (isset($this->_route_config['list_table'])) {
2087
-            if (! class_exists($this->_route_config['list_table'])) {
2087
+            if ( ! class_exists($this->_route_config['list_table'])) {
2088 2088
                 throw new EE_Error(
2089 2089
                     sprintf(
2090 2090
                         __(
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
             // check for current view
2124 2124
             $this->_views[$key]['class']               = $this->_view == $view['slug'] ? 'current' : '';
2125 2125
             $query_args['action']                      = $this->_req_action;
2126
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2126
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2127 2127
             $query_args['status']                      = $view['slug'];
2128 2128
             //merge any other arguments sent in.
2129 2129
             if (isset($extra_query_args[$view['slug']])) {
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
     {
2151 2151
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2152 2152
         $values   = array(10, 25, 50, 100);
2153
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2153
+        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2154 2154
         if ($max_entries) {
2155 2155
             $values[] = $max_entries;
2156 2156
             sort($values);
@@ -2162,14 +2162,14 @@  discard block
 block discarded – undo
2162 2162
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2163 2163
         foreach ($values as $value) {
2164 2164
             if ($value < $max_entries) {
2165
-                $selected                  = $value == $per_page ? ' selected="' . $per_page . '"' : '';
2165
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
2166 2166
                 $entries_per_page_dropdown .= '
2167
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2167
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2168 2168
             }
2169 2169
         }
2170
-        $selected                  = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
2170
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
2171 2171
         $entries_per_page_dropdown .= '
2172
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2172
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2173 2173
         $entries_per_page_dropdown .= '
2174 2174
 					</select>
2175 2175
 					entries
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
             empty($this->_search_btn_label) ? $this->page_label
2196 2196
                 : $this->_search_btn_label
2197 2197
         );
2198
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2198
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2199 2199
     }
2200 2200
 
2201 2201
     /*** END LIST TABLE METHODS **/
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
                     // user error msg
2234 2234
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
2235 2235
                     // developer error msg
2236
-                    $error_msg .= '||' . sprintf(
2236
+                    $error_msg .= '||'.sprintf(
2237 2237
                             __(
2238 2238
                                 '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.',
2239 2239
                                 'event_espresso'
@@ -2267,16 +2267,16 @@  discard block
 block discarded – undo
2267 2267
             add_screen_option(
2268 2268
                 'layout_columns',
2269 2269
                 array(
2270
-                    'max'     => (int)$this->_route_config['columns'][0],
2271
-                    'default' => (int)$this->_route_config['columns'][1],
2270
+                    'max'     => (int) $this->_route_config['columns'][0],
2271
+                    'default' => (int) $this->_route_config['columns'][1],
2272 2272
                 )
2273 2273
             );
2274 2274
             $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2275 2275
             $screen_id                                           = $this->_current_screen->id;
2276
-            $screen_columns                                      = (int)get_user_option("screen_layout_$screen_id");
2276
+            $screen_columns                                      = (int) get_user_option("screen_layout_$screen_id");
2277 2277
             $total_columns                                       = ! empty($screen_columns) ? $screen_columns
2278 2278
                 : $this->_route_config['columns'][1];
2279
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2279
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2280 2280
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2281 2281
             $this->_template_args['screen']                      = $this->_current_screen;
2282 2282
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2320,7 +2320,7 @@  discard block
 block discarded – undo
2320 2320
      */
2321 2321
     protected function _espresso_ratings_request()
2322 2322
     {
2323
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2323
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2324 2324
             return '';
2325 2325
         }
2326 2326
         $ratings_box_title = apply_filters(
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
      */
2347 2347
     public function espresso_ratings_request()
2348 2348
     {
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2349
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
2350 2350
         EEH_Template::display_template($template_path, array());
2351 2351
     }
2352 2352
 
@@ -2354,22 +2354,22 @@  discard block
 block discarded – undo
2354 2354
 
2355 2355
     public static function cached_rss_display($rss_id, $url)
2356 2356
     {
2357
-        $loading    = '<p class="widget-loading hide-if-no-js">'
2357
+        $loading = '<p class="widget-loading hide-if-no-js">'
2358 2358
                       . __('Loading&#8230;')
2359 2359
                       . '</p><p class="hide-if-js">'
2360 2360
                       . __('This widget requires JavaScript.')
2361 2361
                       . '</p>';
2362 2362
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2363
-        $pre        = '<div class="espresso-rss-display">' . "\n\t";
2364
-        $pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2365
-        $post       = '</div>' . "\n";
2366
-        $cache_key  = 'ee_rss_' . md5($rss_id);
2363
+        $pre        = '<div class="espresso-rss-display">'."\n\t";
2364
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
2365
+        $post       = '</div>'."\n";
2366
+        $cache_key  = 'ee_rss_'.md5($rss_id);
2367 2367
         if (false != ($output = get_transient($cache_key))) {
2368
-            echo $pre . $output . $post;
2368
+            echo $pre.$output.$post;
2369 2369
             return true;
2370 2370
         }
2371
-        if (! $doing_ajax) {
2372
-            echo $pre . $loading . $post;
2371
+        if ( ! $doing_ajax) {
2372
+            echo $pre.$loading.$post;
2373 2373
             return false;
2374 2374
         }
2375 2375
         ob_start();
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
                     'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2392 2392
                     'http://eventespresso.com/feed/'
2393 2393
                 );
2394
-                $url      = urlencode($feed_url);
2394
+                $url = urlencode($feed_url);
2395 2395
                 self::cached_rss_display('espresso_news_post_box_content', $url);
2396 2396
                 ?>
2397 2397
             </div>
@@ -2437,7 +2437,7 @@  discard block
 block discarded – undo
2437 2437
 
2438 2438
     public function espresso_sponsors_post_box()
2439 2439
     {
2440
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2440
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2441 2441
         EEH_Template::display_template($templatepath);
2442 2442
     }
2443 2443
 
@@ -2445,9 +2445,9 @@  discard block
 block discarded – undo
2445 2445
 
2446 2446
     private function _publish_post_box()
2447 2447
     {
2448
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2448
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2449 2449
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2450
-        if (! empty($this->_labels['publishbox'])) {
2450
+        if ( ! empty($this->_labels['publishbox'])) {
2451 2451
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2452 2452
                 : $this->_labels['publishbox'];
2453 2453
         } else {
@@ -2547,12 +2547,12 @@  discard block
 block discarded – undo
2547 2547
             );
2548 2548
         }
2549 2549
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2550
-        if (! empty($name) && ! empty($id)) {
2550
+        if ( ! empty($name) && ! empty($id)) {
2551 2551
             $hidden_field_arr[$name] = array(
2552 2552
                 'type'  => 'hidden',
2553 2553
                 'value' => $id,
2554 2554
             );
2555
-            $hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2555
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2556 2556
         } else {
2557 2557
             $hf = '';
2558 2558
         }
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
             'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'
2673 2673
         ) : $callback;
2674 2674
         add_meta_box(
2675
-            str_replace('_', '-', $action) . '-mbox',
2675
+            str_replace('_', '-', $action).'-mbox',
2676 2676
             $title,
2677 2677
             $call_back_func,
2678 2678
             $this->_wp_page_slug,
@@ -2764,9 +2764,9 @@  discard block
 block discarded – undo
2764 2764
             : 'espresso-default-admin';
2765 2765
         $template_path                                     = $sidebar
2766 2766
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2767
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2767
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2768 2768
         if (defined('DOING_AJAX') && DOING_AJAX) {
2769
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2769
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2770 2770
         }
2771 2771
         $template_path                                     = ! empty($this->_column_template_path)
2772 2772
             ? $this->_column_template_path : $template_path;
@@ -2821,7 +2821,7 @@  discard block
 block discarded – undo
2821 2821
                 true
2822 2822
             )
2823 2823
             : $this->_template_args['preview_action_button'];
2824
-        $template_path                                 = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2824
+        $template_path                                 = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2825 2825
         $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2826 2826
             $template_path,
2827 2827
             $this->_template_args,
@@ -2872,7 +2872,7 @@  discard block
 block discarded – undo
2872 2872
         //setup search attributes
2873 2873
         $this->_set_search_attributes();
2874 2874
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2875
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2875
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2876 2876
         $this->_template_args['table_url']        = defined('DOING_AJAX')
2877 2877
             ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2878 2878
             : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2880,10 +2880,10 @@  discard block
 block discarded – undo
2880 2880
         $this->_template_args['current_route']    = $this->_req_action;
2881 2881
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2882 2882
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2883
-        if (! empty($ajax_sorting_callback)) {
2883
+        if ( ! empty($ajax_sorting_callback)) {
2884 2884
             $sortable_list_table_form_fields = wp_nonce_field(
2885
-                $ajax_sorting_callback . '_nonce',
2886
-                $ajax_sorting_callback . '_nonce',
2885
+                $ajax_sorting_callback.'_nonce',
2886
+                $ajax_sorting_callback.'_nonce',
2887 2887
                 false,
2888 2888
                 false
2889 2889
             );
@@ -2901,19 +2901,19 @@  discard block
 block discarded – undo
2901 2901
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2902 2902
         $hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
2903 2903
             ? $this->_template_args['list_table_hidden_fields'] : '';
2904
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2905
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2904
+        $nonce_ref                                               = $this->_req_action.'_nonce';
2905
+        $hidden_form_fields .= '<input type="hidden" name="'
2906 2906
                                                                     . $nonce_ref
2907 2907
                                                                     . '" value="'
2908 2908
                                                                     . wp_create_nonce($nonce_ref)
2909 2909
                                                                     . '">';
2910
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2910
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2911 2911
         //display message about search results?
2912 2912
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2913
-            ? '<p class="ee-search-results">' . sprintf(
2913
+            ? '<p class="ee-search-results">'.sprintf(
2914 2914
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2915 2915
                 trim($this->_req_data['s'], '%')
2916
-            ) . '</p>'
2916
+            ).'</p>'
2917 2917
             : '';
2918 2918
         // filter before_list_table template arg
2919 2919
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2928,9 +2928,9 @@  discard block
 block discarded – undo
2928 2928
         // but would not be backwards compatible, so we have to add a new filter
2929 2929
         $this->_template_args['before_list_table'] = implode(
2930 2930
             " \n",
2931
-            (array)apply_filters(
2931
+            (array) apply_filters(
2932 2932
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2933
-                (array)$this->_template_args['before_list_table'],
2933
+                (array) $this->_template_args['before_list_table'],
2934 2934
                 $this->page_slug,
2935 2935
                 $this->_req_data,
2936 2936
                 $this->_req_action
@@ -2947,11 +2947,11 @@  discard block
 block discarded – undo
2947 2947
         // convert to array and filter again
2948 2948
         // arrays are easier to inject new items in a specific location,
2949 2949
         // but would not be backwards compatible, so we have to add a new filter
2950
-        $this->_template_args['after_list_table']   = implode(
2950
+        $this->_template_args['after_list_table'] = implode(
2951 2951
             " \n",
2952
-            (array)apply_filters(
2952
+            (array) apply_filters(
2953 2953
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2954
-                (array)$this->_template_args['after_list_table'],
2954
+                (array) $this->_template_args['after_list_table'],
2955 2955
                 $this->page_slug,
2956 2956
                 $this->_req_data,
2957 2957
                 $this->_req_action
@@ -2990,10 +2990,10 @@  discard block
 block discarded – undo
2990 2990
     {
2991 2991
         $this->_template_args['items'] = apply_filters(
2992 2992
             'FHEE__EE_Admin_Page___display_legend__items',
2993
-            (array)$items,
2993
+            (array) $items,
2994 2994
             $this
2995 2995
         );
2996
-        $legend_template               = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2996
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2997 2997
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2998 2998
     }
2999 2999
 
@@ -3095,16 +3095,16 @@  discard block
 block discarded – undo
3095 3095
         $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3096 3096
         $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3097 3097
         $this->_template_args['before_admin_page_content'] = apply_filters(
3098
-            'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
3098
+            'FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
3099 3099
             isset($this->_template_args['before_admin_page_content'])
3100 3100
                 ? $this->_template_args['before_admin_page_content'] : ''
3101 3101
         );
3102
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3103
-            'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
3102
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3103
+            'FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
3104 3104
             isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content']
3105 3105
                 : ''
3106 3106
         );
3107
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3107
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3108 3108
         // load settings page wrapper template
3109 3109
         $template_path = ! defined('DOING_AJAX')
3110 3110
             ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
@@ -3195,8 +3195,8 @@  discard block
 block discarded – undo
3195 3195
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3196 3196
     {
3197 3197
         //make sure $text and $actions are in an array
3198
-        $text          = (array)$text;
3199
-        $actions       = (array)$actions;
3198
+        $text          = (array) $text;
3199
+        $actions       = (array) $actions;
3200 3200
         $referrer_url  = empty($referrer) ? '' : $referrer;
3201 3201
         $referrer_url  = ! $referrer
3202 3202
             ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
             : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3206 3206
               . $referrer
3207 3207
               . '" />';
3208
-        $button_text   = ! empty($text)
3208
+        $button_text = ! empty($text)
3209 3209
             ? $text
3210 3210
             : array(
3211 3211
                 __('Save', 'event_espresso'),
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
         $this->_template_args['save_buttons'] = $referrer_url;
3217 3217
         foreach ($button_text as $key => $button) {
3218 3218
             $ref                                  = $default_names[$key];
3219
-            $id                                   = $this->_current_view . '_' . $ref;
3219
+            $id                                   = $this->_current_view.'_'.$ref;
3220 3220
             $name                                 = ! empty($actions) ? $actions[$key] : $ref;
3221 3221
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3222 3222
                                                      . $ref
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
                                                      . '" id="'
3228 3228
                                                      . $id
3229 3229
                                                      . '" />';
3230
-            if (! $both) {
3230
+            if ( ! $both) {
3231 3231
                 break;
3232 3232
             }
3233 3233
         }
@@ -3262,12 +3262,12 @@  discard block
 block discarded – undo
3262 3262
     {
3263 3263
         if (empty($route)) {
3264 3264
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
3265
-            $dev_msg  = $user_msg . "\n" . sprintf(
3265
+            $dev_msg  = $user_msg."\n".sprintf(
3266 3266
                     __('The $route argument is required for the %s->%s method.', 'event_espresso'),
3267 3267
                     __FUNCTION__,
3268 3268
                     __CLASS__
3269 3269
                 );
3270
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3270
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3271 3271
         }
3272 3272
         // open form
3273 3273
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3276,9 +3276,9 @@  discard block
 block discarded – undo
3276 3276
                                                              . $route
3277 3277
                                                              . '_event_form" >';
3278 3278
         // add nonce
3279
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3279
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3280 3280
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3281
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3281
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3282 3282
         // add REQUIRED form action
3283 3283
         $hidden_fields = array(
3284 3284
             'action' => array('type' => 'hidden', 'value' => $route),
@@ -3289,8 +3289,8 @@  discard block
 block discarded – undo
3289 3289
         // generate form fields
3290 3290
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3291 3291
         // add fields to form
3292
-        foreach ((array)$form_fields as $field_name => $form_field) {
3293
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3292
+        foreach ((array) $form_fields as $field_name => $form_field) {
3293
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3294 3294
         }
3295 3295
         // close form
3296 3296
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3344,10 +3344,10 @@  discard block
 block discarded – undo
3344 3344
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3345 3345
         $notices      = EE_Error::get_notices(false);
3346 3346
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3347
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3347
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3348 3348
             EE_Error::overwrite_success();
3349 3349
         }
3350
-        if (! empty($what) && ! empty($action_desc)) {
3350
+        if ( ! empty($what) && ! empty($action_desc)) {
3351 3351
             // how many records affected ? more than one record ? or just one ?
3352 3352
             if ($success > 1 && empty($notices['errors'])) {
3353 3353
                 // set plural msg
@@ -3376,7 +3376,7 @@  discard block
 block discarded – undo
3376 3376
             }
3377 3377
         }
3378 3378
         // check that $query_args isn't something crazy
3379
-        if (! is_array($query_args)) {
3379
+        if ( ! is_array($query_args)) {
3380 3380
             $query_args = array();
3381 3381
         }
3382 3382
         /**
@@ -3388,7 +3388,7 @@  discard block
 block discarded – undo
3388 3388
          *                                method.
3389 3389
          */
3390 3390
         do_action(
3391
-            'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action,
3391
+            'AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action,
3392 3392
             $query_args
3393 3393
         );
3394 3394
         //calculate where we're going (if we have a "save and close" button pushed)
@@ -3401,12 +3401,12 @@  discard block
 block discarded – undo
3401 3401
             $redirect_url = admin_url('admin.php');
3402 3402
         }
3403 3403
         //merge any default query_args set in _default_route_query_args property
3404
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3404
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3405 3405
             $args_to_merge = array();
3406 3406
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3407 3407
                 //is there a wp_referer array in our _default_route_query_args property?
3408 3408
                 if ($query_param == 'wp_referer') {
3409
-                    $query_value = (array)$query_value;
3409
+                    $query_value = (array) $query_value;
3410 3410
                     foreach ($query_value as $reference => $value) {
3411 3411
                         if (strpos($reference, 'nonce') !== false) {
3412 3412
                             continue;
@@ -3432,18 +3432,18 @@  discard block
 block discarded – undo
3432 3432
         // if redirecting to anything other than the main page, add a nonce
3433 3433
         if (isset($query_args['action'])) {
3434 3434
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
3435
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3435
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3436 3436
         }
3437 3437
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
3438
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3438
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3439 3439
         $redirect_url = apply_filters(
3440
-            'FHEE_redirect_' . $classname . $this->_req_action,
3440
+            'FHEE_redirect_'.$classname.$this->_req_action,
3441 3441
             self::add_query_args_and_nonce($query_args, $redirect_url),
3442 3442
             $query_args
3443 3443
         );
3444 3444
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3445 3445
         if (defined('DOING_AJAX')) {
3446
-            $default_data                    = array(
3446
+            $default_data = array(
3447 3447
                 'close'        => true,
3448 3448
                 'redirect_url' => $redirect_url,
3449 3449
                 'where'        => 'main',
@@ -3490,7 +3490,7 @@  discard block
 block discarded – undo
3490 3490
         }
3491 3491
         $this->_template_args['notices'] = EE_Error::get_notices();
3492 3492
         //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3493
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3493
+        if ( ! defined('DOING_AJAX') || $sticky_notices) {
3494 3494
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3495 3495
             $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
3496 3496
         }
@@ -3534,7 +3534,7 @@  discard block
 block discarded – undo
3534 3534
                 )
3535 3535
             );
3536 3536
         }
3537
-        if (! isset($this->_labels['buttons'][$type])) {
3537
+        if ( ! isset($this->_labels['buttons'][$type])) {
3538 3538
             throw new EE_Error(
3539 3539
                 sprintf(
3540 3540
                     __(
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
         }
3548 3548
         //finally check user access for this button.
3549 3549
         $has_access = $this->check_user_access($action, true);
3550
-        if (! $has_access) {
3550
+        if ( ! $has_access) {
3551 3551
             return '';
3552 3552
         }
3553 3553
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3555,7 +3555,7 @@  discard block
 block discarded – undo
3555 3555
             'action' => $action,
3556 3556
         );
3557 3557
         //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3558
-        if (! empty($extra_request)) {
3558
+        if ( ! empty($extra_request)) {
3559 3559
             $query_args = array_merge($extra_request, $query_args);
3560 3560
         }
3561 3561
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
@@ -3576,7 +3576,7 @@  discard block
 block discarded – undo
3576 3576
         $args   = array(
3577 3577
             'label'   => $this->_admin_page_title,
3578 3578
             'default' => 10,
3579
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3579
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3580 3580
         );
3581 3581
         //ONLY add the screen option if the user has access to it.
3582 3582
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3599,7 +3599,7 @@  discard block
 block discarded – undo
3599 3599
     {
3600 3600
         if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3601 3601
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3602
-            if (! $user = wp_get_current_user()) {
3602
+            if ( ! $user = wp_get_current_user()) {
3603 3603
                 return;
3604 3604
             }
3605 3605
             $option = $_POST['wp_screen_options']['option'];
@@ -3610,8 +3610,8 @@  discard block
 block discarded – undo
3610 3610
             $map_option = $option;
3611 3611
             $option     = str_replace('-', '_', $option);
3612 3612
             switch ($map_option) {
3613
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3614
-                    $value = (int)$value;
3613
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3614
+                    $value = (int) $value;
3615 3615
                     if ($value < 1 || $value > 999) {
3616 3616
                         return;
3617 3617
                     }
@@ -3643,7 +3643,7 @@  discard block
 block discarded – undo
3643 3643
      */
3644 3644
     public function set_template_args($data)
3645 3645
     {
3646
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3646
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3647 3647
     }
3648 3648
 
3649 3649
 
@@ -3663,16 +3663,16 @@  discard block
 block discarded – undo
3663 3663
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3664 3664
     {
3665 3665
         $user_id = get_current_user_id();
3666
-        if (! $skip_route_verify) {
3666
+        if ( ! $skip_route_verify) {
3667 3667
             $this->_verify_route($route);
3668 3668
         }
3669 3669
         //now let's set the string for what kind of transient we're setting
3670
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3670
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3671 3671
         $data      = $notices ? array('notices' => $data) : $data;
3672 3672
         //is there already a transient for this route?  If there is then let's ADD to that transient
3673 3673
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3674 3674
         if ($existing) {
3675
-            $data = array_merge((array)$data, (array)$existing);
3675
+            $data = array_merge((array) $data, (array) $existing);
3676 3676
         }
3677 3677
         if (is_multisite() && is_network_admin()) {
3678 3678
             set_site_transient($transient, $data, 8);
@@ -3693,7 +3693,7 @@  discard block
 block discarded – undo
3693 3693
     {
3694 3694
         $user_id   = get_current_user_id();
3695 3695
         $route     = ! $route ? $this->_req_action : $route;
3696
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3696
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3697 3697
         $data      = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3698 3698
         //delete transient after retrieval (just in case it hasn't expired);
3699 3699
         if (is_multisite() && is_network_admin()) {
@@ -3935,7 +3935,7 @@  discard block
 block discarded – undo
3935 3935
      */
3936 3936
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3937 3937
     {
3938
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3938
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3939 3939
     }
3940 3940
 
3941 3941
 
@@ -3949,7 +3949,7 @@  discard block
 block discarded – undo
3949 3949
      */
3950 3950
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3951 3951
     {
3952
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3952
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3953 3953
     }
3954 3954
 
3955 3955
 
Please login to merge, or discard this patch.
caffeinated/admin/extend/support/Extend_Support_Admin_Page.core.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -27,70 +27,70 @@  discard block
 block discarded – undo
27 27
 class Extend_Support_Admin_Page extends Support_Admin_Page
28 28
 {
29 29
 
30
-    public function __construct($routing = true)
31
-    {
32
-        parent::__construct($routing);
33
-        define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/');
34
-    }
35
-
36
-
37
-
38
-    protected function _extend_page_config()
39
-    {
40
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
41
-        //new routes and new configs (or overrides )
42
-        $new_page_routes    = array(
43
-            'faq' => array(
44
-                'func'       => '_faq',
45
-                'capability' => 'ee_read_ee',
46
-            ),
47
-        );
48
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
49
-        $new_page_config    = array(
50
-            'faq' => array(
51
-                'nav'           => array(
52
-                    'label' => __('FAQ', 'event_espresso'),
53
-                    'order' => 40,
54
-                ),
55
-                'metaboxes'     => array('_espresso_news_post_box', '_espresso_links_post_box'),
56
-                'require_nonce' => false,
57
-            ),
58
-        );
59
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
60
-        $this->_page_config['default']['metaboxes'][] = '_installation_boxes';
61
-    }
62
-
63
-
64
-
65
-    protected function _faq()
66
-    {
67
-        $template_path                              = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
68
-                                                      . 'support_admin_details_faq.template.php';
69
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', true);
70
-        $this->display_admin_page_with_sidebar();
71
-    }
72
-
73
-
74
-
75
-    protected function _installation_boxes()
76
-    {
77
-        $callback_args = array(
78
-            'template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
79
-                               . 'support_admin_details_additional_information.template.php',
80
-        );
81
-        add_meta_box(
82
-            'espresso_additional_information_support',
83
-            __('Additional Information', 'event_espresso'),
84
-            create_function(
85
-                '$post, $metabox',
86
-                'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);'
87
-            ),
88
-            $this->_current_screen->id,
89
-            'normal',
90
-            'high',
91
-            $callback_args
92
-        );
93
-    }
30
+	public function __construct($routing = true)
31
+	{
32
+		parent::__construct($routing);
33
+		define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/');
34
+	}
35
+
36
+
37
+
38
+	protected function _extend_page_config()
39
+	{
40
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
41
+		//new routes and new configs (or overrides )
42
+		$new_page_routes    = array(
43
+			'faq' => array(
44
+				'func'       => '_faq',
45
+				'capability' => 'ee_read_ee',
46
+			),
47
+		);
48
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
49
+		$new_page_config    = array(
50
+			'faq' => array(
51
+				'nav'           => array(
52
+					'label' => __('FAQ', 'event_espresso'),
53
+					'order' => 40,
54
+				),
55
+				'metaboxes'     => array('_espresso_news_post_box', '_espresso_links_post_box'),
56
+				'require_nonce' => false,
57
+			),
58
+		);
59
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
60
+		$this->_page_config['default']['metaboxes'][] = '_installation_boxes';
61
+	}
62
+
63
+
64
+
65
+	protected function _faq()
66
+	{
67
+		$template_path                              = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
68
+													  . 'support_admin_details_faq.template.php';
69
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', true);
70
+		$this->display_admin_page_with_sidebar();
71
+	}
72
+
73
+
74
+
75
+	protected function _installation_boxes()
76
+	{
77
+		$callback_args = array(
78
+			'template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
79
+							   . 'support_admin_details_additional_information.template.php',
80
+		);
81
+		add_meta_box(
82
+			'espresso_additional_information_support',
83
+			__('Additional Information', 'event_espresso'),
84
+			create_function(
85
+				'$post, $metabox',
86
+				'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);'
87
+			),
88
+			$this->_current_screen->id,
89
+			'normal',
90
+			'high',
91
+			$callback_args
92
+		);
93
+	}
94 94
 
95 95
 
96 96
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
     public function __construct($routing = true)
31 31
     {
32 32
         parent::__construct($routing);
33
-        define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/');
33
+        define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'support/templates/');
34 34
     }
35 35
 
36 36
 
37 37
 
38 38
     protected function _extend_page_config()
39 39
     {
40
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
40
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'support';
41 41
         //new routes and new configs (or overrides )
42
-        $new_page_routes    = array(
42
+        $new_page_routes = array(
43 43
             'faq' => array(
44 44
                 'func'       => '_faq',
45 45
                 'capability' => 'ee_read_ee',
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -38,217 +38,217 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         *
70
-         * @return void
71
-         */
72
-        function espresso_minimum_php_version_error()
73
-        {
74
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 *
70
+		 * @return void
71
+		 */
72
+		function espresso_minimum_php_version_error()
73
+		{
74
+			?>
75 75
             <div class="error">
76 76
                 <p>
77 77
                     <?php
78
-                    printf(
79
-                        esc_html__(
80
-                            '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.',
81
-                            'event_espresso'
82
-                        ),
83
-                        EE_MIN_PHP_VER_REQUIRED,
84
-                        PHP_VERSION,
85
-                        '<br/>',
86
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
-                    );
88
-                    ?>
78
+					printf(
79
+						esc_html__(
80
+							'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.',
81
+							'event_espresso'
82
+						),
83
+						EE_MIN_PHP_VER_REQUIRED,
84
+						PHP_VERSION,
85
+						'<br/>',
86
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
+					);
88
+					?>
89 89
                 </p>
90 90
             </div>
91 91
             <?php
92
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
93
-        }
92
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
93
+		}
94 94
 
95
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
-    } else {
97
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
-        /**
99
-         * espresso_version
100
-         * Returns the plugin version
101
-         *
102
-         * @return string
103
-         */
104
-        function espresso_version()
105
-        {
106
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.002');
107
-        }
95
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
+	} else {
97
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
+		/**
99
+		 * espresso_version
100
+		 * Returns the plugin version
101
+		 *
102
+		 * @return string
103
+		 */
104
+		function espresso_version()
105
+		{
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.002');
107
+		}
108 108
 
109
-        /**
110
-         * espresso_plugin_activation
111
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
-         */
113
-        function espresso_plugin_activation()
114
-        {
115
-            update_option('ee_espresso_activation', true);
116
-        }
109
+		/**
110
+		 * espresso_plugin_activation
111
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
+		 */
113
+		function espresso_plugin_activation()
114
+		{
115
+			update_option('ee_espresso_activation', true);
116
+		}
117 117
 
118
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
-        /**
120
-         *    espresso_load_error_handling
121
-         *    this function loads EE's class for handling exceptions and errors
122
-         */
123
-        function espresso_load_error_handling()
124
-        {
125
-            static $error_handling_loaded = false;
126
-            if ($error_handling_loaded) {
127
-                return;
128
-            }
129
-            // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
132
-                \EEH_Debug_Tools::instance();
133
-            }
134
-            // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once EE_CORE . 'EE_Error.core.php';
137
-            } else {
138
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
-            }
140
-            $error_handling_loaded = true;
141
-        }
118
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
+		/**
120
+		 *    espresso_load_error_handling
121
+		 *    this function loads EE's class for handling exceptions and errors
122
+		 */
123
+		function espresso_load_error_handling()
124
+		{
125
+			static $error_handling_loaded = false;
126
+			if ($error_handling_loaded) {
127
+				return;
128
+			}
129
+			// load debugging tools
130
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
+				require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
132
+				\EEH_Debug_Tools::instance();
133
+			}
134
+			// load error handling
135
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
+				require_once EE_CORE . 'EE_Error.core.php';
137
+			} else {
138
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
+			}
140
+			$error_handling_loaded = true;
141
+		}
142 142
 
143
-        /**
144
-         *    espresso_load_required
145
-         *    given a class name and path, this function will load that file or throw an exception
146
-         *
147
-         * @param    string $classname
148
-         * @param    string $full_path_to_file
149
-         * @throws    EE_Error
150
-         */
151
-        function espresso_load_required($classname, $full_path_to_file)
152
-        {
153
-            if (is_readable($full_path_to_file)) {
154
-                require_once $full_path_to_file;
155
-            } else {
156
-                throw new \EE_Error (
157
-                    sprintf(
158
-                        esc_html__(
159
-                            'The %s class file could not be located or is not readable due to file permissions.',
160
-                            'event_espresso'
161
-                        ),
162
-                        $classname
163
-                    )
164
-                );
165
-            }
166
-        }
143
+		/**
144
+		 *    espresso_load_required
145
+		 *    given a class name and path, this function will load that file or throw an exception
146
+		 *
147
+		 * @param    string $classname
148
+		 * @param    string $full_path_to_file
149
+		 * @throws    EE_Error
150
+		 */
151
+		function espresso_load_required($classname, $full_path_to_file)
152
+		{
153
+			if (is_readable($full_path_to_file)) {
154
+				require_once $full_path_to_file;
155
+			} else {
156
+				throw new \EE_Error (
157
+					sprintf(
158
+						esc_html__(
159
+							'The %s class file could not be located or is not readable due to file permissions.',
160
+							'event_espresso'
161
+						),
162
+						$classname
163
+					)
164
+				);
165
+			}
166
+		}
167 167
 
168
-        /**
169
-         * @since 4.9.27
170
-         * @throws \EE_Error
171
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
-         * @throws \OutOfBoundsException
179
-         */
180
-        function bootstrap_espresso()
181
-        {
182
-            require_once __DIR__ . '/core/espresso_definitions.php';
183
-            try {
184
-                espresso_load_error_handling();
185
-                espresso_load_required(
186
-                    'EEH_Base',
187
-                    EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
-                );
189
-                espresso_load_required(
190
-                    'EEH_File',
191
-                    EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
-                );
193
-                espresso_load_required(
194
-                    'EEH_File',
195
-                    EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
-                );
197
-                espresso_load_required(
198
-                    'EEH_Array',
199
-                    EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
-                );
201
-                // instantiate and configure PSR4 autoloader
202
-                espresso_load_required(
203
-                    'Psr4Autoloader',
204
-                    EE_CORE . 'Psr4Autoloader.php'
205
-                );
206
-                espresso_load_required(
207
-                    'EE_Psr4AutoloaderInit',
208
-                    EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
-                );
210
-                $AutoloaderInit = new EE_Psr4AutoloaderInit();
211
-                $AutoloaderInit->initializeAutoloader();
212
-                espresso_load_required(
213
-                    'EE_Request',
214
-                    EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
-                );
216
-                espresso_load_required(
217
-                    'EE_Response',
218
-                    EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
-                );
220
-                espresso_load_required(
221
-                    'EE_Bootstrap',
222
-                    EE_CORE . 'EE_Bootstrap.core.php'
223
-                );
224
-                // bootstrap EE and the request stack
225
-                new EE_Bootstrap(
226
-                    new EE_Request($_GET, $_POST, $_COOKIE),
227
-                    new EE_Response()
228
-                );
229
-            } catch (Exception $e) {
230
-                require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
231
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
-            }
233
-        }
234
-        bootstrap_espresso();
235
-    }
168
+		/**
169
+		 * @since 4.9.27
170
+		 * @throws \EE_Error
171
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
175
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
+		 * @throws \OutOfBoundsException
179
+		 */
180
+		function bootstrap_espresso()
181
+		{
182
+			require_once __DIR__ . '/core/espresso_definitions.php';
183
+			try {
184
+				espresso_load_error_handling();
185
+				espresso_load_required(
186
+					'EEH_Base',
187
+					EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
+				);
189
+				espresso_load_required(
190
+					'EEH_File',
191
+					EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
+				);
193
+				espresso_load_required(
194
+					'EEH_File',
195
+					EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
+				);
197
+				espresso_load_required(
198
+					'EEH_Array',
199
+					EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
+				);
201
+				// instantiate and configure PSR4 autoloader
202
+				espresso_load_required(
203
+					'Psr4Autoloader',
204
+					EE_CORE . 'Psr4Autoloader.php'
205
+				);
206
+				espresso_load_required(
207
+					'EE_Psr4AutoloaderInit',
208
+					EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
+				);
210
+				$AutoloaderInit = new EE_Psr4AutoloaderInit();
211
+				$AutoloaderInit->initializeAutoloader();
212
+				espresso_load_required(
213
+					'EE_Request',
214
+					EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
+				);
216
+				espresso_load_required(
217
+					'EE_Response',
218
+					EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
+				);
220
+				espresso_load_required(
221
+					'EE_Bootstrap',
222
+					EE_CORE . 'EE_Bootstrap.core.php'
223
+				);
224
+				// bootstrap EE and the request stack
225
+				new EE_Bootstrap(
226
+					new EE_Request($_GET, $_POST, $_COOKIE),
227
+					new EE_Response()
228
+				);
229
+			} catch (Exception $e) {
230
+				require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
231
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
+			}
233
+		}
234
+		bootstrap_espresso();
235
+	}
236 236
 }
237 237
 if (! function_exists('espresso_deactivate_plugin')) {
238
-    /**
239
-     *    deactivate_plugin
240
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
-     *
242
-     * @access public
243
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
-     * @return    void
245
-     */
246
-    function espresso_deactivate_plugin($plugin_basename = '')
247
-    {
248
-        if (! function_exists('deactivate_plugins')) {
249
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
250
-        }
251
-        unset($_GET['activate'], $_REQUEST['activate']);
252
-        deactivate_plugins($plugin_basename);
253
-    }
238
+	/**
239
+	 *    deactivate_plugin
240
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
+	 *
242
+	 * @access public
243
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
+	 * @return    void
245
+	 */
246
+	function espresso_deactivate_plugin($plugin_basename = '')
247
+	{
248
+		if (! function_exists('deactivate_plugins')) {
249
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
250
+		}
251
+		unset($_GET['activate'], $_REQUEST['activate']);
252
+		deactivate_plugins($plugin_basename);
253
+	}
254 254
 }
Please login to merge, or discard this patch.