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