Completed
Branch BUG/fqcn-locator-only-load-php (d1f132)
by
unknown
09:46 queued 25s
created
core/admin/EE_Admin.core.php 1 patch
Indentation   +1025 added lines, -1025 removed lines patch added patch discarded remove patch
@@ -20,488 +20,488 @@  discard block
 block discarded – undo
20 20
 final class EE_Admin implements InterminableInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Admin $_instance
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
-     */
31
-    private $persistent_admin_notice_manager;
32
-
33
-    /**
34
-     * @var LoaderInterface
35
-     */
36
-    protected $loader;
37
-
38
-    /**
39
-     * @singleton method used to instantiate class object
40
-     * @return EE_Admin
41
-     * @throws EE_Error
42
-     */
43
-    public static function instance()
44
-    {
45
-        // check if class object is instantiated
46
-        if (! self::$_instance instanceof EE_Admin) {
47
-            self::$_instance = new self();
48
-        }
49
-        return self::$_instance;
50
-    }
51
-
52
-
53
-    /**
54
-     * @return EE_Admin
55
-     * @throws EE_Error
56
-     */
57
-    public static function reset()
58
-    {
59
-        self::$_instance = null;
60
-        return self::instance();
61
-    }
62
-
63
-
64
-    /**
65
-     * class constructor
66
-     *
67
-     * @throws EE_Error
68
-     * @throws InvalidDataTypeException
69
-     * @throws InvalidInterfaceException
70
-     * @throws InvalidArgumentException
71
-     */
72
-    protected function __construct()
73
-    {
74
-        // define global EE_Admin constants
75
-        $this->_define_all_constants();
76
-        // set autoloaders for our admin page classes based on included path information
77
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
78
-        // admin hooks
79
-        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
80
-        // load EE_Request_Handler early
81
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
82
-        add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
83
-        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
84
-        add_action('wp_loaded', array($this, 'wp_loaded'), 100);
85
-        add_action('admin_init', array($this, 'admin_init'), 100);
86
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
87
-        add_action('admin_notices', array($this, 'display_admin_notices'), 10);
88
-        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
89
-        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
90
-        add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
91
-        add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage'));
92
-        add_action('display_post_states', array($this, 'displayStateForCriticalPages'), 10, 2);
93
-        add_filter('plugin_row_meta', array($this, 'addLinksToPluginRowMeta'), 10, 2);
94
-        // reset Environment config (we only do this on admin page loads);
95
-        EE_Registry::instance()->CFG->environment->recheck_values();
96
-        do_action('AHEE__EE_Admin__loaded');
97
-    }
98
-
99
-
100
-    /**
101
-     * _define_all_constants
102
-     * define constants that are set globally for all admin pages
103
-     *
104
-     * @return void
105
-     */
106
-    private function _define_all_constants()
107
-    {
108
-        if (! defined('EE_ADMIN_URL')) {
109
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
110
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
111
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
112
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
113
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
114
-        }
115
-    }
116
-
117
-
118
-    /**
119
-     * filter_plugin_actions - adds links to the Plugins page listing
120
-     *
121
-     * @param    array  $links
122
-     * @param    string $plugin
123
-     * @return    array
124
-     */
125
-    public function filter_plugin_actions($links, $plugin)
126
-    {
127
-        // set $main_file in stone
128
-        static $main_file;
129
-        // if $main_file is not set yet
130
-        if (! $main_file) {
131
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
132
-        }
133
-        if ($plugin === $main_file) {
134
-            // compare current plugin to this one
135
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
136
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
137
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
138
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
139
-                                    . '</a>';
140
-                array_unshift($links, $maintenance_link);
141
-            } else {
142
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
143
-                                     . esc_html__('Settings', 'event_espresso')
144
-                                     . '</a>';
145
-                $events_link = '<a href="admin.php?page=espresso_events">'
146
-                               . esc_html__('Events', 'event_espresso')
147
-                               . '</a>';
148
-                // add before other links
149
-                array_unshift($links, $org_settings_link, $events_link);
150
-            }
151
-        }
152
-        return $links;
153
-    }
154
-
155
-
156
-    /**
157
-     * _get_request
158
-     *
159
-     * @return void
160
-     * @throws EE_Error
161
-     * @throws InvalidArgumentException
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     * @throws ReflectionException
165
-     */
166
-    public function get_request()
167
-    {
168
-        EE_Registry::instance()->load_core('Request_Handler');
169
-    }
170
-
171
-
172
-    /**
173
-     * hide_admin_pages_except_maintenance_mode
174
-     *
175
-     * @param array $admin_page_folder_names
176
-     * @return array
177
-     */
178
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
179
-    {
180
-        return array(
181
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
182
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
183
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
184
-        );
185
-    }
186
-
187
-
188
-    /**
189
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
-     * EE_Front_Controller's init phases have run
191
-     *
192
-     * @return void
193
-     * @throws EE_Error
194
-     * @throws InvalidArgumentException
195
-     * @throws InvalidDataTypeException
196
-     * @throws InvalidInterfaceException
197
-     * @throws ReflectionException
198
-     * @throws ServiceNotFoundException
199
-     */
200
-    public function init()
201
-    {
202
-        // only enable most of the EE_Admin IF we're not in full maintenance mode
203
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
-            $this->initModelsReady();
205
-        }
206
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
207
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
208
-            try {
209
-                // this loads the controller for the admin pages which will setup routing etc
210
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
211
-            } catch (EE_Error $e) {
212
-                $e->get_error();
213
-            }
214
-        }
215
-        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
216
-        // make sure our CPTs and custom taxonomy metaboxes get shown for first time users
217
-        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
218
-        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
219
-        // exclude EE critical pages from all nav menus and wp_list_pages
220
-        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
221
-    }
222
-
223
-
224
-    /**
225
-     * Gets the loader (and if it wasn't previously set, sets it)
226
-     * @return LoaderInterface
227
-     * @throws InvalidArgumentException
228
-     * @throws InvalidDataTypeException
229
-     * @throws InvalidInterfaceException
230
-     */
231
-    protected function getLoader()
232
-    {
233
-        if (! $this->loader instanceof LoaderInterface) {
234
-            $this->loader = LoaderFactory::getLoader();
235
-        }
236
-        return $this->loader;
237
-    }
238
-
239
-
240
-    /**
241
-     * Method that's fired on admin requests (including admin ajax) but only when the models are usable
242
-     * (ie, the site isn't in maintenance mode)
243
-     * @since 4.9.63.p
244
-     * @return void
245
-     */
246
-    protected function initModelsReady()
247
-    {
248
-        // ok so we want to enable the entire admin
249
-        $this->persistent_admin_notice_manager = $this->getLoader()->getShared(
250
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
251
-        );
252
-        $this->persistent_admin_notice_manager->setReturnUrl(
253
-            EE_Admin_Page::add_query_args_and_nonce(
254
-                array(
255
-                    'page'   => EE_Registry::instance()->REQ->get('page', ''),
256
-                    'action' => EE_Registry::instance()->REQ->get('action', ''),
257
-                ),
258
-                EE_ADMIN_URL
259
-            )
260
-        );
261
-        $this->maybeSetDatetimeWarningNotice();
262
-        // at a glance dashboard widget
263
-        add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
264
-        // filter for get_edit_post_link used on comments for custom post types
265
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
266
-    }
267
-
268
-
269
-    /**
270
-     *    get_persistent_admin_notices
271
-     *
272
-     * @access    public
273
-     * @return void
274
-     * @throws EE_Error
275
-     * @throws InvalidArgumentException
276
-     * @throws InvalidDataTypeException
277
-     * @throws InvalidInterfaceException
278
-     */
279
-    public function maybeSetDatetimeWarningNotice()
280
-    {
281
-        // add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
282
-        // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
283
-        // with this.  But after enough time (indeterminate at this point) we can just remove this notice.
284
-        // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
285
-        if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
286
-            && ! get_option('timezone_string')
287
-            && EEM_Event::instance()->count() > 0
288
-        ) {
289
-            new PersistentAdminNotice(
290
-                'datetime_fix_notice',
291
-                sprintf(
292
-                    esc_html__(
293
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
294
-                        'event_espresso'
295
-                    ),
296
-                    '<strong>',
297
-                    '</strong>',
298
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
299
-                    '</a>',
300
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
301
-                        array(
302
-                            'page'   => 'espresso_maintenance_settings',
303
-                            'action' => 'datetime_tools',
304
-                        ),
305
-                        admin_url('admin.php')
306
-                    ) . '">'
307
-                ),
308
-                false,
309
-                'manage_options',
310
-                'datetime_fix_persistent_notice'
311
-            );
312
-        }
313
-    }
314
-
315
-
316
-    /**
317
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
318
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
319
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
320
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
321
-     * normal property on the post_type object.  It's found ONLY in this particular context.
322
-     *
323
-     * @param WP_Post $post_type WP post type object
324
-     * @return WP_Post
325
-     * @throws InvalidArgumentException
326
-     * @throws InvalidDataTypeException
327
-     * @throws InvalidInterfaceException
328
-     */
329
-    public function remove_pages_from_nav_menu($post_type)
330
-    {
331
-        // if this isn't the "pages" post type let's get out
332
-        if ($post_type->name !== 'page') {
333
-            return $post_type;
334
-        }
335
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
336
-        $post_type->_default_query = array(
337
-            'post__not_in' => $critical_pages,
338
-        );
339
-        return $post_type;
340
-    }
341
-
342
-
343
-    /**
344
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
345
-     * metaboxes get shown as well
346
-     *
347
-     * @return void
348
-     */
349
-    public function enable_hidden_ee_nav_menu_metaboxes()
350
-    {
351
-        global $wp_meta_boxes, $pagenow;
352
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
353
-            return;
354
-        }
355
-        $user = wp_get_current_user();
356
-        // has this been done yet?
357
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
358
-            return;
359
-        }
360
-
361
-        $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
362
-        $initial_meta_boxes = apply_filters(
363
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
364
-            array(
365
-                'nav-menu-theme-locations',
366
-                'add-page',
367
-                'add-custom-links',
368
-                'add-category',
369
-                'add-espresso_events',
370
-                'add-espresso_venues',
371
-                'add-espresso_event_categories',
372
-                'add-espresso_venue_categories',
373
-                'add-post-type-post',
374
-                'add-post-type-page',
375
-            )
376
-        );
377
-
378
-        if (is_array($hidden_meta_boxes)) {
379
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
380
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
381
-                    unset($hidden_meta_boxes[ $key ]);
382
-                }
383
-            }
384
-        }
385
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
386
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
387
-    }
388
-
389
-
390
-    /**
391
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
392
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
393
-     *
394
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
395
-     *         addons etc.
396
-     * @return void
397
-     */
398
-    public function register_custom_nav_menu_boxes()
399
-    {
400
-        add_meta_box(
401
-            'add-extra-nav-menu-pages',
402
-            esc_html__('Event Espresso Pages', 'event_espresso'),
403
-            array($this, 'ee_cpt_archive_pages'),
404
-            'nav-menus',
405
-            'side',
406
-            'core'
407
-        );
408
-    }
409
-
410
-
411
-    /**
412
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
413
-     *
414
-     * @since   4.3.0
415
-     * @param string $link the original link generated by wp
416
-     * @param int    $id   post id
417
-     * @return string  the (maybe) modified link
418
-     */
419
-    public function modify_edit_post_link($link, $id)
420
-    {
421
-        if (! $post = get_post($id)) {
422
-            return $link;
423
-        }
424
-        if ($post->post_type === 'espresso_attendees') {
425
-            $query_args = array(
426
-                'action' => 'edit_attendee',
427
-                'post'   => $id,
428
-            );
429
-            return EEH_URL::add_query_args_and_nonce(
430
-                $query_args,
431
-                admin_url('admin.php?page=espresso_registrations')
432
-            );
433
-        }
434
-        return $link;
435
-    }
436
-
437
-
438
-    public function ee_cpt_archive_pages()
439
-    {
440
-        global $nav_menu_selected_id;
441
-        $db_fields = false;
442
-        $walker = new Walker_Nav_Menu_Checklist($db_fields);
443
-        $current_tab = 'event-archives';
444
-        $removed_args = array(
445
-            'action',
446
-            'customlink-tab',
447
-            'edit-menu-item',
448
-            'menu-item',
449
-            'page-tab',
450
-            '_wpnonce',
451
-        );
452
-        ?>
23
+	/**
24
+	 * @var EE_Admin $_instance
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
+	 */
31
+	private $persistent_admin_notice_manager;
32
+
33
+	/**
34
+	 * @var LoaderInterface
35
+	 */
36
+	protected $loader;
37
+
38
+	/**
39
+	 * @singleton method used to instantiate class object
40
+	 * @return EE_Admin
41
+	 * @throws EE_Error
42
+	 */
43
+	public static function instance()
44
+	{
45
+		// check if class object is instantiated
46
+		if (! self::$_instance instanceof EE_Admin) {
47
+			self::$_instance = new self();
48
+		}
49
+		return self::$_instance;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @return EE_Admin
55
+	 * @throws EE_Error
56
+	 */
57
+	public static function reset()
58
+	{
59
+		self::$_instance = null;
60
+		return self::instance();
61
+	}
62
+
63
+
64
+	/**
65
+	 * class constructor
66
+	 *
67
+	 * @throws EE_Error
68
+	 * @throws InvalidDataTypeException
69
+	 * @throws InvalidInterfaceException
70
+	 * @throws InvalidArgumentException
71
+	 */
72
+	protected function __construct()
73
+	{
74
+		// define global EE_Admin constants
75
+		$this->_define_all_constants();
76
+		// set autoloaders for our admin page classes based on included path information
77
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
78
+		// admin hooks
79
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
80
+		// load EE_Request_Handler early
81
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
82
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
83
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
84
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
85
+		add_action('admin_init', array($this, 'admin_init'), 100);
86
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
87
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
88
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
89
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
90
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
91
+		add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage'));
92
+		add_action('display_post_states', array($this, 'displayStateForCriticalPages'), 10, 2);
93
+		add_filter('plugin_row_meta', array($this, 'addLinksToPluginRowMeta'), 10, 2);
94
+		// reset Environment config (we only do this on admin page loads);
95
+		EE_Registry::instance()->CFG->environment->recheck_values();
96
+		do_action('AHEE__EE_Admin__loaded');
97
+	}
98
+
99
+
100
+	/**
101
+	 * _define_all_constants
102
+	 * define constants that are set globally for all admin pages
103
+	 *
104
+	 * @return void
105
+	 */
106
+	private function _define_all_constants()
107
+	{
108
+		if (! defined('EE_ADMIN_URL')) {
109
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
110
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
111
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
112
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
113
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
114
+		}
115
+	}
116
+
117
+
118
+	/**
119
+	 * filter_plugin_actions - adds links to the Plugins page listing
120
+	 *
121
+	 * @param    array  $links
122
+	 * @param    string $plugin
123
+	 * @return    array
124
+	 */
125
+	public function filter_plugin_actions($links, $plugin)
126
+	{
127
+		// set $main_file in stone
128
+		static $main_file;
129
+		// if $main_file is not set yet
130
+		if (! $main_file) {
131
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
132
+		}
133
+		if ($plugin === $main_file) {
134
+			// compare current plugin to this one
135
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
136
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
137
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
138
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
139
+									. '</a>';
140
+				array_unshift($links, $maintenance_link);
141
+			} else {
142
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
143
+									 . esc_html__('Settings', 'event_espresso')
144
+									 . '</a>';
145
+				$events_link = '<a href="admin.php?page=espresso_events">'
146
+							   . esc_html__('Events', 'event_espresso')
147
+							   . '</a>';
148
+				// add before other links
149
+				array_unshift($links, $org_settings_link, $events_link);
150
+			}
151
+		}
152
+		return $links;
153
+	}
154
+
155
+
156
+	/**
157
+	 * _get_request
158
+	 *
159
+	 * @return void
160
+	 * @throws EE_Error
161
+	 * @throws InvalidArgumentException
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 * @throws ReflectionException
165
+	 */
166
+	public function get_request()
167
+	{
168
+		EE_Registry::instance()->load_core('Request_Handler');
169
+	}
170
+
171
+
172
+	/**
173
+	 * hide_admin_pages_except_maintenance_mode
174
+	 *
175
+	 * @param array $admin_page_folder_names
176
+	 * @return array
177
+	 */
178
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
179
+	{
180
+		return array(
181
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
182
+			'about'       => EE_ADMIN_PAGES . 'about' . DS,
183
+			'support'     => EE_ADMIN_PAGES . 'support' . DS,
184
+		);
185
+	}
186
+
187
+
188
+	/**
189
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
+	 * EE_Front_Controller's init phases have run
191
+	 *
192
+	 * @return void
193
+	 * @throws EE_Error
194
+	 * @throws InvalidArgumentException
195
+	 * @throws InvalidDataTypeException
196
+	 * @throws InvalidInterfaceException
197
+	 * @throws ReflectionException
198
+	 * @throws ServiceNotFoundException
199
+	 */
200
+	public function init()
201
+	{
202
+		// only enable most of the EE_Admin IF we're not in full maintenance mode
203
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
+			$this->initModelsReady();
205
+		}
206
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
207
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
208
+			try {
209
+				// this loads the controller for the admin pages which will setup routing etc
210
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
211
+			} catch (EE_Error $e) {
212
+				$e->get_error();
213
+			}
214
+		}
215
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
216
+		// make sure our CPTs and custom taxonomy metaboxes get shown for first time users
217
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
218
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
219
+		// exclude EE critical pages from all nav menus and wp_list_pages
220
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
221
+	}
222
+
223
+
224
+	/**
225
+	 * Gets the loader (and if it wasn't previously set, sets it)
226
+	 * @return LoaderInterface
227
+	 * @throws InvalidArgumentException
228
+	 * @throws InvalidDataTypeException
229
+	 * @throws InvalidInterfaceException
230
+	 */
231
+	protected function getLoader()
232
+	{
233
+		if (! $this->loader instanceof LoaderInterface) {
234
+			$this->loader = LoaderFactory::getLoader();
235
+		}
236
+		return $this->loader;
237
+	}
238
+
239
+
240
+	/**
241
+	 * Method that's fired on admin requests (including admin ajax) but only when the models are usable
242
+	 * (ie, the site isn't in maintenance mode)
243
+	 * @since 4.9.63.p
244
+	 * @return void
245
+	 */
246
+	protected function initModelsReady()
247
+	{
248
+		// ok so we want to enable the entire admin
249
+		$this->persistent_admin_notice_manager = $this->getLoader()->getShared(
250
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
251
+		);
252
+		$this->persistent_admin_notice_manager->setReturnUrl(
253
+			EE_Admin_Page::add_query_args_and_nonce(
254
+				array(
255
+					'page'   => EE_Registry::instance()->REQ->get('page', ''),
256
+					'action' => EE_Registry::instance()->REQ->get('action', ''),
257
+				),
258
+				EE_ADMIN_URL
259
+			)
260
+		);
261
+		$this->maybeSetDatetimeWarningNotice();
262
+		// at a glance dashboard widget
263
+		add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
264
+		// filter for get_edit_post_link used on comments for custom post types
265
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
266
+	}
267
+
268
+
269
+	/**
270
+	 *    get_persistent_admin_notices
271
+	 *
272
+	 * @access    public
273
+	 * @return void
274
+	 * @throws EE_Error
275
+	 * @throws InvalidArgumentException
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws InvalidInterfaceException
278
+	 */
279
+	public function maybeSetDatetimeWarningNotice()
280
+	{
281
+		// add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
282
+		// @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
283
+		// with this.  But after enough time (indeterminate at this point) we can just remove this notice.
284
+		// this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
285
+		if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
286
+			&& ! get_option('timezone_string')
287
+			&& EEM_Event::instance()->count() > 0
288
+		) {
289
+			new PersistentAdminNotice(
290
+				'datetime_fix_notice',
291
+				sprintf(
292
+					esc_html__(
293
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
294
+						'event_espresso'
295
+					),
296
+					'<strong>',
297
+					'</strong>',
298
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
299
+					'</a>',
300
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
301
+						array(
302
+							'page'   => 'espresso_maintenance_settings',
303
+							'action' => 'datetime_tools',
304
+						),
305
+						admin_url('admin.php')
306
+					) . '">'
307
+				),
308
+				false,
309
+				'manage_options',
310
+				'datetime_fix_persistent_notice'
311
+			);
312
+		}
313
+	}
314
+
315
+
316
+	/**
317
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
318
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
319
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
320
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
321
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
322
+	 *
323
+	 * @param WP_Post $post_type WP post type object
324
+	 * @return WP_Post
325
+	 * @throws InvalidArgumentException
326
+	 * @throws InvalidDataTypeException
327
+	 * @throws InvalidInterfaceException
328
+	 */
329
+	public function remove_pages_from_nav_menu($post_type)
330
+	{
331
+		// if this isn't the "pages" post type let's get out
332
+		if ($post_type->name !== 'page') {
333
+			return $post_type;
334
+		}
335
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
336
+		$post_type->_default_query = array(
337
+			'post__not_in' => $critical_pages,
338
+		);
339
+		return $post_type;
340
+	}
341
+
342
+
343
+	/**
344
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
345
+	 * metaboxes get shown as well
346
+	 *
347
+	 * @return void
348
+	 */
349
+	public function enable_hidden_ee_nav_menu_metaboxes()
350
+	{
351
+		global $wp_meta_boxes, $pagenow;
352
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
353
+			return;
354
+		}
355
+		$user = wp_get_current_user();
356
+		// has this been done yet?
357
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
358
+			return;
359
+		}
360
+
361
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
362
+		$initial_meta_boxes = apply_filters(
363
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
364
+			array(
365
+				'nav-menu-theme-locations',
366
+				'add-page',
367
+				'add-custom-links',
368
+				'add-category',
369
+				'add-espresso_events',
370
+				'add-espresso_venues',
371
+				'add-espresso_event_categories',
372
+				'add-espresso_venue_categories',
373
+				'add-post-type-post',
374
+				'add-post-type-page',
375
+			)
376
+		);
377
+
378
+		if (is_array($hidden_meta_boxes)) {
379
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
380
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
381
+					unset($hidden_meta_boxes[ $key ]);
382
+				}
383
+			}
384
+		}
385
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
386
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
387
+	}
388
+
389
+
390
+	/**
391
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
392
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
393
+	 *
394
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
395
+	 *         addons etc.
396
+	 * @return void
397
+	 */
398
+	public function register_custom_nav_menu_boxes()
399
+	{
400
+		add_meta_box(
401
+			'add-extra-nav-menu-pages',
402
+			esc_html__('Event Espresso Pages', 'event_espresso'),
403
+			array($this, 'ee_cpt_archive_pages'),
404
+			'nav-menus',
405
+			'side',
406
+			'core'
407
+		);
408
+	}
409
+
410
+
411
+	/**
412
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
413
+	 *
414
+	 * @since   4.3.0
415
+	 * @param string $link the original link generated by wp
416
+	 * @param int    $id   post id
417
+	 * @return string  the (maybe) modified link
418
+	 */
419
+	public function modify_edit_post_link($link, $id)
420
+	{
421
+		if (! $post = get_post($id)) {
422
+			return $link;
423
+		}
424
+		if ($post->post_type === 'espresso_attendees') {
425
+			$query_args = array(
426
+				'action' => 'edit_attendee',
427
+				'post'   => $id,
428
+			);
429
+			return EEH_URL::add_query_args_and_nonce(
430
+				$query_args,
431
+				admin_url('admin.php?page=espresso_registrations')
432
+			);
433
+		}
434
+		return $link;
435
+	}
436
+
437
+
438
+	public function ee_cpt_archive_pages()
439
+	{
440
+		global $nav_menu_selected_id;
441
+		$db_fields = false;
442
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
443
+		$current_tab = 'event-archives';
444
+		$removed_args = array(
445
+			'action',
446
+			'customlink-tab',
447
+			'edit-menu-item',
448
+			'menu-item',
449
+			'page-tab',
450
+			'_wpnonce',
451
+		);
452
+		?>
453 453
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
454 454
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
455 455
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
456 456
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
457 457
                        href="<?php
458
-                        if ($nav_menu_selected_id) {
459
-                            echo esc_url(
460
-                                add_query_arg(
461
-                                    'extra-nav-menu-pages-tab',
462
-                                    'event-archives',
463
-                                    remove_query_arg($removed_args)
464
-                                )
465
-                            );
466
-                        }
467
-                        ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
458
+						if ($nav_menu_selected_id) {
459
+							echo esc_url(
460
+								add_query_arg(
461
+									'extra-nav-menu-pages-tab',
462
+									'event-archives',
463
+									remove_query_arg($removed_args)
464
+								)
465
+							);
466
+						}
467
+						?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
468 468
                         <?php esc_html_e('Event Archive Pages', 'event_espresso'); ?>
469 469
                     </a>
470 470
                 </li>
471 471
             </ul><!-- .posttype-tabs -->
472 472
 
473 473
             <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
474
-            echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
475
-            ?>">
474
+			echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
475
+			?>">
476 476
                 <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
477 477
                     <?php
478
-                    $pages = $this->_get_extra_nav_menu_pages_items();
479
-                    $args['walker'] = $walker;
480
-                    echo walk_nav_menu_tree(
481
-                        array_map(
482
-                            array($this, '_setup_extra_nav_menu_pages_items'),
483
-                            $pages
484
-                        ),
485
-                        0,
486
-                        (object) $args
487
-                    );
488
-                    ?>
478
+					$pages = $this->_get_extra_nav_menu_pages_items();
479
+					$args['walker'] = $walker;
480
+					echo walk_nav_menu_tree(
481
+						array_map(
482
+							array($this, '_setup_extra_nav_menu_pages_items'),
483
+							$pages
484
+						),
485
+						0,
486
+						(object) $args
487
+					);
488
+					?>
489 489
                 </ul>
490 490
             </div><!-- /.tabs-panel -->
491 491
 
492 492
             <p class="button-controls">
493 493
                 <span class="list-controls">
494 494
                     <a href="<?php
495
-                             echo esc_url(
496
-                                 add_query_arg(
497
-                                     array(
498
-                                         'extra-nav-menu-pages-tab' => 'event-archives',
499
-                                         'selectall'                => 1,
500
-                                     ),
501
-                                     remove_query_arg($removed_args)
502
-                                 )
503
-                             );
504
-                        ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a>
495
+							 echo esc_url(
496
+								 add_query_arg(
497
+									 array(
498
+										 'extra-nav-menu-pages-tab' => 'event-archives',
499
+										 'selectall'                => 1,
500
+									 ),
501
+									 remove_query_arg($removed_args)
502
+								 )
503
+							 );
504
+						?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a>
505 505
                 </span>
506 506
                 <span class="add-to-menu">
507 507
                     <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>
@@ -514,566 +514,566 @@  discard block
 block discarded – undo
514 514
 
515 515
         </div><!-- /.posttypediv -->
516 516
         <?php
517
-    }
518
-
519
-
520
-    /**
521
-     * Returns an array of event archive nav items.
522
-     *
523
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
524
-     *        method we use for getting the extra nav menu items
525
-     * @return array
526
-     */
527
-    private function _get_extra_nav_menu_pages_items()
528
-    {
529
-        $menuitems[] = array(
530
-            'title'       => esc_html__('Event List', 'event_espresso'),
531
-            'url'         => get_post_type_archive_link('espresso_events'),
532
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
533
-        );
534
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
535
-    }
536
-
537
-
538
-    /**
539
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
540
-     * the properties and converts it to the menu item object.
541
-     *
542
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
543
-     * @param $menu_item_values
544
-     * @return stdClass
545
-     */
546
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
547
-    {
548
-        $menu_item = new stdClass();
549
-        $keys = array(
550
-            'ID'               => 0,
551
-            'db_id'            => 0,
552
-            'menu_item_parent' => 0,
553
-            'object_id'        => -1,
554
-            'post_parent'      => 0,
555
-            'type'             => 'custom',
556
-            'object'           => '',
557
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
558
-            'title'            => '',
559
-            'url'              => '',
560
-            'target'           => '',
561
-            'attr_title'       => '',
562
-            'description'      => '',
563
-            'classes'          => array(),
564
-            'xfn'              => '',
565
-        );
566
-
567
-        foreach ($keys as $key => $value) {
568
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
569
-        }
570
-        return $menu_item;
571
-    }
572
-
573
-
574
-    /**
575
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
576
-     * EE_Admin_Page route is called.
577
-     *
578
-     * @return void
579
-     */
580
-    public function route_admin_request()
581
-    {
582
-    }
583
-
584
-
585
-    /**
586
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
587
-     *
588
-     * @return void
589
-     */
590
-    public function wp_loaded()
591
-    {
592
-    }
593
-
594
-
595
-    /**
596
-     * admin_init
597
-     *
598
-     * @return void
599
-     * @throws EE_Error
600
-     * @throws InvalidArgumentException
601
-     * @throws InvalidDataTypeException
602
-     * @throws InvalidInterfaceException
603
-     * @throws ReflectionException
604
-     */
605
-    public function admin_init()
606
-    {
607
-        /**
608
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
609
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
610
-         * - check if doing post processing.
611
-         * - check if doing post processing of one of EE CPTs
612
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
613
-         */
614
-        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
615
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
616
-            $custom_post_types = $this->getLoader()->getShared(
617
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
618
-            );
619
-            $custom_post_types->getCustomPostTypeModels($_POST['post_type']);
620
-        }
621
-
622
-
623
-        /**
624
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
625
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
626
-         * Pages" tab in the EE General Settings Admin page.
627
-         * This is for user-proofing.
628
-         */
629
-        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
630
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
631
-            $this->adminInitModelsReady();
632
-        }
633
-    }
634
-
635
-
636
-    /**
637
-     * Runs on admin_init but only if models are usable (ie, we're not in maintenanc emode)
638
-     */
639
-    protected function adminInitModelsReady()
640
-    {
641
-        if (function_exists('wp_add_privacy_policy_content')) {
642
-            $this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
643
-        }
644
-    }
645
-
646
-
647
-    /**
648
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
649
-     *
650
-     * @param string $output Current output.
651
-     * @return string
652
-     * @throws InvalidArgumentException
653
-     * @throws InvalidDataTypeException
654
-     * @throws InvalidInterfaceException
655
-     */
656
-    public function modify_dropdown_pages($output)
657
-    {
658
-        // get critical pages
659
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
660
-
661
-        // split current output by line break for easier parsing.
662
-        $split_output = explode("\n", $output);
663
-
664
-        // loop through to remove any critical pages from the array.
665
-        foreach ($critical_pages as $page_id) {
666
-            $needle = 'value="' . $page_id . '"';
667
-            foreach ($split_output as $key => $haystack) {
668
-                if (strpos($haystack, $needle) !== false) {
669
-                    unset($split_output[ $key ]);
670
-                }
671
-            }
672
-        }
673
-        // replace output with the new contents
674
-        return implode("\n", $split_output);
675
-    }
676
-
677
-
678
-    /**
679
-     * enqueue all admin scripts that need loaded for admin pages
680
-     *
681
-     * @return void
682
-     */
683
-    public function enqueue_admin_scripts()
684
-    {
685
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
686
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
687
-        // calls.
688
-        wp_enqueue_script(
689
-            'ee-inject-wp',
690
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
691
-            array('jquery'),
692
-            EVENT_ESPRESSO_VERSION,
693
-            true
694
-        );
695
-        // register cookie script for future dependencies
696
-        wp_register_script(
697
-            'jquery-cookie',
698
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
699
-            array('jquery'),
700
-            '2.1',
701
-            true
702
-        );
703
-        // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
704
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
705
-        if (apply_filters('FHEE_load_joyride', false)) {
706
-            // joyride style
707
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
708
-            wp_register_style(
709
-                'ee-joyride-css',
710
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
711
-                array('joyride-css'),
712
-                EVENT_ESPRESSO_VERSION
713
-            );
714
-            wp_register_script(
715
-                'joyride-modernizr',
716
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
717
-                array(),
718
-                '2.1',
719
-                true
720
-            );
721
-            // joyride JS
722
-            wp_register_script(
723
-                'jquery-joyride',
724
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
725
-                array('jquery-cookie', 'joyride-modernizr'),
726
-                '2.1',
727
-                true
728
-            );
729
-            // wanna go for a joyride?
730
-            wp_enqueue_style('ee-joyride-css');
731
-            wp_enqueue_script('jquery-joyride');
732
-        }
733
-    }
734
-
735
-
736
-    /**
737
-     * display_admin_notices
738
-     *
739
-     * @return void
740
-     */
741
-    public function display_admin_notices()
742
-    {
743
-        echo EE_Error::get_notices();
744
-    }
745
-
746
-
747
-    /**
748
-     * @param array $elements
749
-     * @return array
750
-     * @throws EE_Error
751
-     * @throws InvalidArgumentException
752
-     * @throws InvalidDataTypeException
753
-     * @throws InvalidInterfaceException
754
-     */
755
-    public function dashboard_glance_items($elements)
756
-    {
757
-        $elements = is_array($elements) ? $elements : array($elements);
758
-        $events = EEM_Event::instance()->count();
759
-        $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(
760
-            array('page' => 'espresso_events'),
761
-            admin_url('admin.php')
762
-        );
763
-        $items['events']['text'] = sprintf(
764
-            esc_html(
765
-                _n('%s Event', '%s Events', $events, 'event_espresso')
766
-            ),
767
-            number_format_i18n($events)
768
-        );
769
-        $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso');
770
-        $registrations = EEM_Registration::instance()->count(
771
-            array(
772
-                array(
773
-                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
774
-                ),
775
-            )
776
-        );
777
-        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
778
-            array('page' => 'espresso_registrations'),
779
-            admin_url('admin.php')
780
-        );
781
-        $items['registrations']['text'] = sprintf(
782
-            esc_html(
783
-                _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
784
-            ),
785
-            number_format_i18n($registrations)
786
-        );
787
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
788
-
789
-        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
790
-
791
-        foreach ($items as $type => $item_properties) {
792
-            $elements[] = sprintf(
793
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
794
-                $item_properties['url'],
795
-                $item_properties['title'],
796
-                $item_properties['text']
797
-            );
798
-        }
799
-        return $elements;
800
-    }
801
-
802
-
803
-    /**
804
-     * check_for_invalid_datetime_formats
805
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
806
-     * their selected format can be parsed by PHP
807
-     *
808
-     * @param    $value
809
-     * @param    $option
810
-     * @throws EE_Error
811
-     * @return    string
812
-     */
813
-    public function check_for_invalid_datetime_formats($value, $option)
814
-    {
815
-        // check for date_format or time_format
816
-        switch ($option) {
817
-            case 'date_format':
818
-                $date_time_format = $value . ' ' . get_option('time_format');
819
-                break;
820
-            case 'time_format':
821
-                $date_time_format = get_option('date_format') . ' ' . $value;
822
-                break;
823
-            default:
824
-                $date_time_format = false;
825
-        }
826
-        // do we have a date_time format to check ?
827
-        if ($date_time_format) {
828
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
829
-
830
-            if (is_array($error_msg)) {
831
-                $msg = '<p>'
832
-                       . sprintf(
833
-                           esc_html__(
834
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
835
-                               'event_espresso'
836
-                           ),
837
-                           date($date_time_format),
838
-                           $date_time_format
839
-                       )
840
-                       . '</p><p><ul>';
841
-
842
-
843
-                foreach ($error_msg as $error) {
844
-                    $msg .= '<li>' . $error . '</li>';
845
-                }
846
-
847
-                $msg .= '</ul></p><p>'
848
-                        . sprintf(
849
-                            esc_html__(
850
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
851
-                                'event_espresso'
852
-                            ),
853
-                            '<span style="color:#D54E21;">',
854
-                            '</span>'
855
-                        )
856
-                        . '</p>';
857
-
858
-                // trigger WP settings error
859
-                add_settings_error(
860
-                    'date_format',
861
-                    'date_format',
862
-                    $msg
863
-                );
864
-
865
-                // set format to something valid
866
-                switch ($option) {
867
-                    case 'date_format':
868
-                        $value = 'F j, Y';
869
-                        break;
870
-                    case 'time_format':
871
-                        $value = 'g:i a';
872
-                        break;
873
-                }
874
-            }
875
-        }
876
-        return $value;
877
-    }
878
-
879
-
880
-    /**
881
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
882
-     *
883
-     * @param $content
884
-     * @return    string
885
-     */
886
-    public function its_eSpresso($content)
887
-    {
888
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
889
-    }
890
-
891
-
892
-    /**
893
-     * espresso_admin_footer
894
-     *
895
-     * @return    string
896
-     */
897
-    public function espresso_admin_footer()
898
-    {
899
-        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
900
-    }
901
-
902
-
903
-    /**
904
-     * static method for registering ee admin page.
905
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
906
-     *
907
-     * @since      4.3.0
908
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
909
-     * @see        EE_Register_Admin_Page::register()
910
-     * @param       $page_basename
911
-     * @param       $page_path
912
-     * @param array $config
913
-     * @return void
914
-     * @throws EE_Error
915
-     */
916
-    public static function register_ee_admin_page($page_basename, $page_path, $config = array())
917
-    {
918
-        EE_Error::doing_it_wrong(
919
-            __METHOD__,
920
-            sprintf(
921
-                esc_html__(
922
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
923
-                    'event_espresso'
924
-                ),
925
-                $page_basename
926
-            ),
927
-            '4.3'
928
-        );
929
-        if (class_exists('EE_Register_Admin_Page')) {
930
-            $config['page_path'] = $page_path;
931
-        }
932
-        EE_Register_Admin_Page::register($page_basename, $config);
933
-    }
934
-
935
-
936
-    /**
937
-     * @deprecated 4.8.41
938
-     * @param  int      $post_ID
939
-     * @param  \WP_Post $post
940
-     * @return void
941
-     */
942
-    public static function parse_post_content_on_save($post_ID, $post)
943
-    {
944
-        EE_Error::doing_it_wrong(
945
-            __METHOD__,
946
-            esc_html__('Usage is deprecated', 'event_espresso'),
947
-            '4.8.41'
948
-        );
949
-    }
950
-
951
-
952
-    /**
953
-     * @deprecated 4.8.41
954
-     * @param  $option
955
-     * @param  $old_value
956
-     * @param  $value
957
-     * @return void
958
-     */
959
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
960
-    {
961
-        EE_Error::doing_it_wrong(
962
-            __METHOD__,
963
-            esc_html__('Usage is deprecated', 'event_espresso'),
964
-            '4.8.41'
965
-        );
966
-    }
967
-
968
-
969
-    /**
970
-     * @deprecated 4.9.27
971
-     * @return void
972
-     */
973
-    public function get_persistent_admin_notices()
974
-    {
975
-        EE_Error::doing_it_wrong(
976
-            __METHOD__,
977
-            sprintf(
978
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
979
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
980
-            ),
981
-            '4.9.27'
982
-        );
983
-    }
984
-
985
-
986
-    /**
987
-     * @deprecated 4.9.27
988
-     * @throws InvalidInterfaceException
989
-     * @throws InvalidDataTypeException
990
-     * @throws DomainException
991
-     */
992
-    public function dismiss_ee_nag_notice_callback()
993
-    {
994
-        EE_Error::doing_it_wrong(
995
-            __METHOD__,
996
-            sprintf(
997
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
998
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
999
-            ),
1000
-            '4.9.27'
1001
-        );
1002
-        $this->persistent_admin_notice_manager->dismissNotice();
1003
-    }
1004
-
1005
-
1006
-    /**
1007
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
1008
-     *
1009
-     * @throws InvalidArgumentException
1010
-     * @throws InvalidDataTypeException
1011
-     * @throws InvalidInterfaceException
1012
-     */
1013
-    public function hookIntoWpPluginsPage()
1014
-    {
1015
-        $this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
1016
-        $this->getLoader()
1017
-                     ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
1018
-                     ->decafUpsells();
1019
-    }
1020
-
1021
-
1022
-    /**
1023
-     * Hooks into the "post states" filter in a wp post type list table.
1024
-     *
1025
-     * @param array   $post_states
1026
-     * @param WP_Post $post
1027
-     * @return array
1028
-     * @throws InvalidArgumentException
1029
-     * @throws InvalidDataTypeException
1030
-     * @throws InvalidInterfaceException
1031
-     */
1032
-    public function displayStateForCriticalPages($post_states, $post)
1033
-    {
1034
-        $post_states = (array) $post_states;
1035
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1036
-            return $post_states;
1037
-        }
1038
-        /** @var EE_Core_Config $config */
1039
-        $config = $this->getLoader()->getShared('EE_Config')->core;
1040
-        if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
1041
-            $post_states[] = sprintf(
1042
-                /* Translators: Using company name - Event Espresso Critical Page */
1043
-                esc_html__('%s Critical Page', 'event_espresso'),
1044
-                'Event Espresso'
1045
-            );
1046
-        }
1047
-        return $post_states;
1048
-    }
1049
-
1050
-
1051
-    /**
1052
-     * Show documentation links on the plugins page
1053
-     *
1054
-     * @param mixed $meta Plugin Row Meta
1055
-     * @param mixed $file Plugin Base file
1056
-     * @return array
1057
-     */
1058
-    public function addLinksToPluginRowMeta($meta, $file)
1059
-    {
1060
-        if (EE_PLUGIN_BASENAME === $file) {
1061
-            $row_meta = array(
1062
-                'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1063
-                          . ' aria-label="'
1064
-                          . esc_attr__('View Event Espresso documentation', 'event_espresso')
1065
-                          . '">'
1066
-                          . esc_html__('Docs', 'event_espresso')
1067
-                          . '</a>',
1068
-                'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1069
-                          . ' aria-label="'
1070
-                          . esc_attr__('View Event Espresso API docs', 'event_espresso')
1071
-                          . '">'
1072
-                          . esc_html__('API docs', 'event_espresso')
1073
-                          . '</a>',
1074
-            );
1075
-            return array_merge($meta, $row_meta);
1076
-        }
1077
-        return (array) $meta;
1078
-    }
517
+	}
518
+
519
+
520
+	/**
521
+	 * Returns an array of event archive nav items.
522
+	 *
523
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
524
+	 *        method we use for getting the extra nav menu items
525
+	 * @return array
526
+	 */
527
+	private function _get_extra_nav_menu_pages_items()
528
+	{
529
+		$menuitems[] = array(
530
+			'title'       => esc_html__('Event List', 'event_espresso'),
531
+			'url'         => get_post_type_archive_link('espresso_events'),
532
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
533
+		);
534
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
535
+	}
536
+
537
+
538
+	/**
539
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
540
+	 * the properties and converts it to the menu item object.
541
+	 *
542
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
543
+	 * @param $menu_item_values
544
+	 * @return stdClass
545
+	 */
546
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
547
+	{
548
+		$menu_item = new stdClass();
549
+		$keys = array(
550
+			'ID'               => 0,
551
+			'db_id'            => 0,
552
+			'menu_item_parent' => 0,
553
+			'object_id'        => -1,
554
+			'post_parent'      => 0,
555
+			'type'             => 'custom',
556
+			'object'           => '',
557
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
558
+			'title'            => '',
559
+			'url'              => '',
560
+			'target'           => '',
561
+			'attr_title'       => '',
562
+			'description'      => '',
563
+			'classes'          => array(),
564
+			'xfn'              => '',
565
+		);
566
+
567
+		foreach ($keys as $key => $value) {
568
+			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
569
+		}
570
+		return $menu_item;
571
+	}
572
+
573
+
574
+	/**
575
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
576
+	 * EE_Admin_Page route is called.
577
+	 *
578
+	 * @return void
579
+	 */
580
+	public function route_admin_request()
581
+	{
582
+	}
583
+
584
+
585
+	/**
586
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
587
+	 *
588
+	 * @return void
589
+	 */
590
+	public function wp_loaded()
591
+	{
592
+	}
593
+
594
+
595
+	/**
596
+	 * admin_init
597
+	 *
598
+	 * @return void
599
+	 * @throws EE_Error
600
+	 * @throws InvalidArgumentException
601
+	 * @throws InvalidDataTypeException
602
+	 * @throws InvalidInterfaceException
603
+	 * @throws ReflectionException
604
+	 */
605
+	public function admin_init()
606
+	{
607
+		/**
608
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
609
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
610
+		 * - check if doing post processing.
611
+		 * - check if doing post processing of one of EE CPTs
612
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
613
+		 */
614
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
615
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
616
+			$custom_post_types = $this->getLoader()->getShared(
617
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
618
+			);
619
+			$custom_post_types->getCustomPostTypeModels($_POST['post_type']);
620
+		}
621
+
622
+
623
+		/**
624
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
625
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
626
+		 * Pages" tab in the EE General Settings Admin page.
627
+		 * This is for user-proofing.
628
+		 */
629
+		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
630
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
631
+			$this->adminInitModelsReady();
632
+		}
633
+	}
634
+
635
+
636
+	/**
637
+	 * Runs on admin_init but only if models are usable (ie, we're not in maintenanc emode)
638
+	 */
639
+	protected function adminInitModelsReady()
640
+	{
641
+		if (function_exists('wp_add_privacy_policy_content')) {
642
+			$this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
643
+		}
644
+	}
645
+
646
+
647
+	/**
648
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
649
+	 *
650
+	 * @param string $output Current output.
651
+	 * @return string
652
+	 * @throws InvalidArgumentException
653
+	 * @throws InvalidDataTypeException
654
+	 * @throws InvalidInterfaceException
655
+	 */
656
+	public function modify_dropdown_pages($output)
657
+	{
658
+		// get critical pages
659
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
660
+
661
+		// split current output by line break for easier parsing.
662
+		$split_output = explode("\n", $output);
663
+
664
+		// loop through to remove any critical pages from the array.
665
+		foreach ($critical_pages as $page_id) {
666
+			$needle = 'value="' . $page_id . '"';
667
+			foreach ($split_output as $key => $haystack) {
668
+				if (strpos($haystack, $needle) !== false) {
669
+					unset($split_output[ $key ]);
670
+				}
671
+			}
672
+		}
673
+		// replace output with the new contents
674
+		return implode("\n", $split_output);
675
+	}
676
+
677
+
678
+	/**
679
+	 * enqueue all admin scripts that need loaded for admin pages
680
+	 *
681
+	 * @return void
682
+	 */
683
+	public function enqueue_admin_scripts()
684
+	{
685
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
686
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
687
+		// calls.
688
+		wp_enqueue_script(
689
+			'ee-inject-wp',
690
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
691
+			array('jquery'),
692
+			EVENT_ESPRESSO_VERSION,
693
+			true
694
+		);
695
+		// register cookie script for future dependencies
696
+		wp_register_script(
697
+			'jquery-cookie',
698
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
699
+			array('jquery'),
700
+			'2.1',
701
+			true
702
+		);
703
+		// joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
704
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
705
+		if (apply_filters('FHEE_load_joyride', false)) {
706
+			// joyride style
707
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
708
+			wp_register_style(
709
+				'ee-joyride-css',
710
+				EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
711
+				array('joyride-css'),
712
+				EVENT_ESPRESSO_VERSION
713
+			);
714
+			wp_register_script(
715
+				'joyride-modernizr',
716
+				EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
717
+				array(),
718
+				'2.1',
719
+				true
720
+			);
721
+			// joyride JS
722
+			wp_register_script(
723
+				'jquery-joyride',
724
+				EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
725
+				array('jquery-cookie', 'joyride-modernizr'),
726
+				'2.1',
727
+				true
728
+			);
729
+			// wanna go for a joyride?
730
+			wp_enqueue_style('ee-joyride-css');
731
+			wp_enqueue_script('jquery-joyride');
732
+		}
733
+	}
734
+
735
+
736
+	/**
737
+	 * display_admin_notices
738
+	 *
739
+	 * @return void
740
+	 */
741
+	public function display_admin_notices()
742
+	{
743
+		echo EE_Error::get_notices();
744
+	}
745
+
746
+
747
+	/**
748
+	 * @param array $elements
749
+	 * @return array
750
+	 * @throws EE_Error
751
+	 * @throws InvalidArgumentException
752
+	 * @throws InvalidDataTypeException
753
+	 * @throws InvalidInterfaceException
754
+	 */
755
+	public function dashboard_glance_items($elements)
756
+	{
757
+		$elements = is_array($elements) ? $elements : array($elements);
758
+		$events = EEM_Event::instance()->count();
759
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(
760
+			array('page' => 'espresso_events'),
761
+			admin_url('admin.php')
762
+		);
763
+		$items['events']['text'] = sprintf(
764
+			esc_html(
765
+				_n('%s Event', '%s Events', $events, 'event_espresso')
766
+			),
767
+			number_format_i18n($events)
768
+		);
769
+		$items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso');
770
+		$registrations = EEM_Registration::instance()->count(
771
+			array(
772
+				array(
773
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
774
+				),
775
+			)
776
+		);
777
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
778
+			array('page' => 'espresso_registrations'),
779
+			admin_url('admin.php')
780
+		);
781
+		$items['registrations']['text'] = sprintf(
782
+			esc_html(
783
+				_n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
784
+			),
785
+			number_format_i18n($registrations)
786
+		);
787
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
788
+
789
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
790
+
791
+		foreach ($items as $type => $item_properties) {
792
+			$elements[] = sprintf(
793
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
794
+				$item_properties['url'],
795
+				$item_properties['title'],
796
+				$item_properties['text']
797
+			);
798
+		}
799
+		return $elements;
800
+	}
801
+
802
+
803
+	/**
804
+	 * check_for_invalid_datetime_formats
805
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
806
+	 * their selected format can be parsed by PHP
807
+	 *
808
+	 * @param    $value
809
+	 * @param    $option
810
+	 * @throws EE_Error
811
+	 * @return    string
812
+	 */
813
+	public function check_for_invalid_datetime_formats($value, $option)
814
+	{
815
+		// check for date_format or time_format
816
+		switch ($option) {
817
+			case 'date_format':
818
+				$date_time_format = $value . ' ' . get_option('time_format');
819
+				break;
820
+			case 'time_format':
821
+				$date_time_format = get_option('date_format') . ' ' . $value;
822
+				break;
823
+			default:
824
+				$date_time_format = false;
825
+		}
826
+		// do we have a date_time format to check ?
827
+		if ($date_time_format) {
828
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
829
+
830
+			if (is_array($error_msg)) {
831
+				$msg = '<p>'
832
+					   . sprintf(
833
+						   esc_html__(
834
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
835
+							   'event_espresso'
836
+						   ),
837
+						   date($date_time_format),
838
+						   $date_time_format
839
+					   )
840
+					   . '</p><p><ul>';
841
+
842
+
843
+				foreach ($error_msg as $error) {
844
+					$msg .= '<li>' . $error . '</li>';
845
+				}
846
+
847
+				$msg .= '</ul></p><p>'
848
+						. sprintf(
849
+							esc_html__(
850
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
851
+								'event_espresso'
852
+							),
853
+							'<span style="color:#D54E21;">',
854
+							'</span>'
855
+						)
856
+						. '</p>';
857
+
858
+				// trigger WP settings error
859
+				add_settings_error(
860
+					'date_format',
861
+					'date_format',
862
+					$msg
863
+				);
864
+
865
+				// set format to something valid
866
+				switch ($option) {
867
+					case 'date_format':
868
+						$value = 'F j, Y';
869
+						break;
870
+					case 'time_format':
871
+						$value = 'g:i a';
872
+						break;
873
+				}
874
+			}
875
+		}
876
+		return $value;
877
+	}
878
+
879
+
880
+	/**
881
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
882
+	 *
883
+	 * @param $content
884
+	 * @return    string
885
+	 */
886
+	public function its_eSpresso($content)
887
+	{
888
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
889
+	}
890
+
891
+
892
+	/**
893
+	 * espresso_admin_footer
894
+	 *
895
+	 * @return    string
896
+	 */
897
+	public function espresso_admin_footer()
898
+	{
899
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
900
+	}
901
+
902
+
903
+	/**
904
+	 * static method for registering ee admin page.
905
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
906
+	 *
907
+	 * @since      4.3.0
908
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
909
+	 * @see        EE_Register_Admin_Page::register()
910
+	 * @param       $page_basename
911
+	 * @param       $page_path
912
+	 * @param array $config
913
+	 * @return void
914
+	 * @throws EE_Error
915
+	 */
916
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array())
917
+	{
918
+		EE_Error::doing_it_wrong(
919
+			__METHOD__,
920
+			sprintf(
921
+				esc_html__(
922
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
923
+					'event_espresso'
924
+				),
925
+				$page_basename
926
+			),
927
+			'4.3'
928
+		);
929
+		if (class_exists('EE_Register_Admin_Page')) {
930
+			$config['page_path'] = $page_path;
931
+		}
932
+		EE_Register_Admin_Page::register($page_basename, $config);
933
+	}
934
+
935
+
936
+	/**
937
+	 * @deprecated 4.8.41
938
+	 * @param  int      $post_ID
939
+	 * @param  \WP_Post $post
940
+	 * @return void
941
+	 */
942
+	public static function parse_post_content_on_save($post_ID, $post)
943
+	{
944
+		EE_Error::doing_it_wrong(
945
+			__METHOD__,
946
+			esc_html__('Usage is deprecated', 'event_espresso'),
947
+			'4.8.41'
948
+		);
949
+	}
950
+
951
+
952
+	/**
953
+	 * @deprecated 4.8.41
954
+	 * @param  $option
955
+	 * @param  $old_value
956
+	 * @param  $value
957
+	 * @return void
958
+	 */
959
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
960
+	{
961
+		EE_Error::doing_it_wrong(
962
+			__METHOD__,
963
+			esc_html__('Usage is deprecated', 'event_espresso'),
964
+			'4.8.41'
965
+		);
966
+	}
967
+
968
+
969
+	/**
970
+	 * @deprecated 4.9.27
971
+	 * @return void
972
+	 */
973
+	public function get_persistent_admin_notices()
974
+	{
975
+		EE_Error::doing_it_wrong(
976
+			__METHOD__,
977
+			sprintf(
978
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
979
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
980
+			),
981
+			'4.9.27'
982
+		);
983
+	}
984
+
985
+
986
+	/**
987
+	 * @deprecated 4.9.27
988
+	 * @throws InvalidInterfaceException
989
+	 * @throws InvalidDataTypeException
990
+	 * @throws DomainException
991
+	 */
992
+	public function dismiss_ee_nag_notice_callback()
993
+	{
994
+		EE_Error::doing_it_wrong(
995
+			__METHOD__,
996
+			sprintf(
997
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
998
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
999
+			),
1000
+			'4.9.27'
1001
+		);
1002
+		$this->persistent_admin_notice_manager->dismissNotice();
1003
+	}
1004
+
1005
+
1006
+	/**
1007
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
1008
+	 *
1009
+	 * @throws InvalidArgumentException
1010
+	 * @throws InvalidDataTypeException
1011
+	 * @throws InvalidInterfaceException
1012
+	 */
1013
+	public function hookIntoWpPluginsPage()
1014
+	{
1015
+		$this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
1016
+		$this->getLoader()
1017
+					 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
1018
+					 ->decafUpsells();
1019
+	}
1020
+
1021
+
1022
+	/**
1023
+	 * Hooks into the "post states" filter in a wp post type list table.
1024
+	 *
1025
+	 * @param array   $post_states
1026
+	 * @param WP_Post $post
1027
+	 * @return array
1028
+	 * @throws InvalidArgumentException
1029
+	 * @throws InvalidDataTypeException
1030
+	 * @throws InvalidInterfaceException
1031
+	 */
1032
+	public function displayStateForCriticalPages($post_states, $post)
1033
+	{
1034
+		$post_states = (array) $post_states;
1035
+		if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1036
+			return $post_states;
1037
+		}
1038
+		/** @var EE_Core_Config $config */
1039
+		$config = $this->getLoader()->getShared('EE_Config')->core;
1040
+		if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
1041
+			$post_states[] = sprintf(
1042
+				/* Translators: Using company name - Event Espresso Critical Page */
1043
+				esc_html__('%s Critical Page', 'event_espresso'),
1044
+				'Event Espresso'
1045
+			);
1046
+		}
1047
+		return $post_states;
1048
+	}
1049
+
1050
+
1051
+	/**
1052
+	 * Show documentation links on the plugins page
1053
+	 *
1054
+	 * @param mixed $meta Plugin Row Meta
1055
+	 * @param mixed $file Plugin Base file
1056
+	 * @return array
1057
+	 */
1058
+	public function addLinksToPluginRowMeta($meta, $file)
1059
+	{
1060
+		if (EE_PLUGIN_BASENAME === $file) {
1061
+			$row_meta = array(
1062
+				'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1063
+						  . ' aria-label="'
1064
+						  . esc_attr__('View Event Espresso documentation', 'event_espresso')
1065
+						  . '">'
1066
+						  . esc_html__('Docs', 'event_espresso')
1067
+						  . '</a>',
1068
+				'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1069
+						  . ' aria-label="'
1070
+						  . esc_attr__('View Event Espresso API docs', 'event_espresso')
1071
+						  . '">'
1072
+						  . esc_html__('API docs', 'event_espresso')
1073
+						  . '</a>',
1074
+			);
1075
+			return array_merge($meta, $row_meta);
1076
+		}
1077
+		return (array) $meta;
1078
+	}
1079 1079
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.80.rc.013');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.80.rc.013');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.