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