@@ -120,7 +120,7 @@ |
||
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
123 | - * @param $field_name |
|
123 | + * @param string $field_name |
|
124 | 124 | * @param int $row_number |
125 | 125 | * @return string |
126 | 126 | */ |
@@ -14,181 +14,181 @@ |
||
14 | 14 | class EventsAdmin extends CoreAdmin |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Selector for the Add new Event button in the admin. |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * Selector for the Event Title field in the event editor |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']"; |
|
29 | - |
|
30 | - /** |
|
31 | - * Selector for the publish submit button in the event editor. |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish"; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
41 | - |
|
42 | - /** |
|
43 | - * Selector for the view link after publishing an event. |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a"; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Selector for the ID of the event in the event editor |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * Selector for the search input on the event list table page. |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @param string $additional_params |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public static function defaultEventsListTableUrl($additional_params = '') |
|
70 | - { |
|
71 | - return self::adminUrl('espresso_events', 'default', $additional_params); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * The selector for the DTTname field for the given row in the event editor. |
|
77 | - * @param int $row_number |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
81 | - { |
|
82 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
88 | - * @param int $row_number |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
92 | - { |
|
93 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
99 | - * |
|
100 | - * @param string $field_name |
|
101 | - * @param int $row_number |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
105 | - { |
|
106 | - return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * The selector for the TKT_name field for the given display row in the event editor. |
|
112 | - * @param int $row_number |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
116 | - { |
|
117 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
123 | - * @param $field_name |
|
124 | - * @param int $row_number |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
128 | - { |
|
129 | - return "//tr[@id='display-ticketrow-$row_number']" |
|
130 | - . "/td[2]/input[@class='edit-ticket-$field_name ee-large-text-inp']"; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
136 | - * @param string $event_title |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
140 | - { |
|
141 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Locator for for the ID column in the event list table for a given event title. |
|
147 | - * @param string $event_title |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public static function eventListTableEventIdSelectorForTitle($event_title) |
|
151 | - { |
|
152 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
153 | - . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * Locator for the view link in the row of an event list table for the given event title. |
|
159 | - * @param string $event_title |
|
160 | - * @return string |
|
161 | - */ |
|
162 | - public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
163 | - { |
|
164 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
165 | - . "//ancestor::td//span[@class='view']/a"; |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
171 | - * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
175 | - { |
|
176 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
177 | - . "//a[@rel='ee-tab-$messenger_slug']"; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * Locator for the select input within the notifications metabox. |
|
183 | - * Note, this assumes the tab content for the related messenger is already visible. |
|
184 | - * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
188 | - { |
|
189 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
190 | - . "//table[@class='messages-custom-template-switcher']" |
|
191 | - . "//tr/td[contains(.,'Registration Approved')]" |
|
192 | - . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
193 | - } |
|
17 | + /** |
|
18 | + * Selector for the Add new Event button in the admin. |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * Selector for the Event Title field in the event editor |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']"; |
|
29 | + |
|
30 | + /** |
|
31 | + * Selector for the publish submit button in the event editor. |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish"; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
41 | + |
|
42 | + /** |
|
43 | + * Selector for the view link after publishing an event. |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a"; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Selector for the ID of the event in the event editor |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * Selector for the search input on the event list table page. |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @param string $additional_params |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public static function defaultEventsListTableUrl($additional_params = '') |
|
70 | + { |
|
71 | + return self::adminUrl('espresso_events', 'default', $additional_params); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * The selector for the DTTname field for the given row in the event editor. |
|
77 | + * @param int $row_number |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
81 | + { |
|
82 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
88 | + * @param int $row_number |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
92 | + { |
|
93 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
99 | + * |
|
100 | + * @param string $field_name |
|
101 | + * @param int $row_number |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
105 | + { |
|
106 | + return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * The selector for the TKT_name field for the given display row in the event editor. |
|
112 | + * @param int $row_number |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
116 | + { |
|
117 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
123 | + * @param $field_name |
|
124 | + * @param int $row_number |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
128 | + { |
|
129 | + return "//tr[@id='display-ticketrow-$row_number']" |
|
130 | + . "/td[2]/input[@class='edit-ticket-$field_name ee-large-text-inp']"; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
136 | + * @param string $event_title |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
140 | + { |
|
141 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Locator for for the ID column in the event list table for a given event title. |
|
147 | + * @param string $event_title |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public static function eventListTableEventIdSelectorForTitle($event_title) |
|
151 | + { |
|
152 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
153 | + . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * Locator for the view link in the row of an event list table for the given event title. |
|
159 | + * @param string $event_title |
|
160 | + * @return string |
|
161 | + */ |
|
162 | + public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
163 | + { |
|
164 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
165 | + . "//ancestor::td//span[@class='view']/a"; |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
171 | + * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
175 | + { |
|
176 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
177 | + . "//a[@rel='ee-tab-$messenger_slug']"; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * Locator for the select input within the notifications metabox. |
|
183 | + * Note, this assumes the tab content for the related messenger is already visible. |
|
184 | + * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
188 | + { |
|
189 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
190 | + . "//table[@class='messages-custom-template-switcher']" |
|
191 | + . "//tr/td[contains(.,'Registration Approved')]" |
|
192 | + . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
193 | + } |
|
194 | 194 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.41.rc.004'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.41.rc.004'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -13,58 +13,58 @@ |
||
13 | 13 | trait BaseCoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Core method for going to an Event Espresso Admin page. |
|
18 | - * @param string $page |
|
19 | - * @param string $action |
|
20 | - * @param string $additional_params |
|
21 | - */ |
|
22 | - public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | - { |
|
24 | - $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | - } |
|
16 | + /** |
|
17 | + * Core method for going to an Event Espresso Admin page. |
|
18 | + * @param string $page |
|
19 | + * @param string $action |
|
20 | + * @param string $additional_params |
|
21 | + */ |
|
22 | + public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | + { |
|
24 | + $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | - * @return \EventEspressoAcceptanceTester; |
|
31 | - */ |
|
32 | - protected function actor() |
|
33 | - { |
|
34 | - /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | - return $this; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | + * @return \EventEspressoAcceptanceTester; |
|
31 | + */ |
|
32 | + protected function actor() |
|
33 | + { |
|
34 | + /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | + return $this; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Use this to set the per page option for a list table page. |
|
41 | - * Assumes you are on a page that has this field exposed. |
|
42 | - * |
|
43 | - * @param int|string $per_page_value |
|
44 | - * @throws \Codeception\Exception\TestRuntimeException |
|
45 | - */ |
|
46 | - public function setPerPageOptionForScreen($per_page_value) |
|
47 | - { |
|
48 | - $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | - $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | - $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | - $this->actor()->wait(8); |
|
52 | - } |
|
39 | + /** |
|
40 | + * Use this to set the per page option for a list table page. |
|
41 | + * Assumes you are on a page that has this field exposed. |
|
42 | + * |
|
43 | + * @param int|string $per_page_value |
|
44 | + * @throws \Codeception\Exception\TestRuntimeException |
|
45 | + */ |
|
46 | + public function setPerPageOptionForScreen($per_page_value) |
|
47 | + { |
|
48 | + $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | + $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | + $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | + $this->actor()->wait(8); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Use this to append a given value to a wpEditor instance. |
|
58 | - * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | - * the value is added to the text area. |
|
60 | - * |
|
61 | - * @param $field_reference |
|
62 | - * @param $value |
|
63 | - * @throws \Codeception\Exception\ElementNotFound |
|
64 | - */ |
|
65 | - public function appendToWPEditorField($field_reference, $value) |
|
66 | - { |
|
67 | - $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | - $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | - } |
|
56 | + /** |
|
57 | + * Use this to append a given value to a wpEditor instance. |
|
58 | + * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | + * the value is added to the text area. |
|
60 | + * |
|
61 | + * @param $field_reference |
|
62 | + * @param $value |
|
63 | + * @throws \Codeception\Exception\ElementNotFound |
|
64 | + */ |
|
65 | + public function appendToWPEditorField($field_reference, $value) |
|
66 | + { |
|
67 | + $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | + $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | + } |
|
70 | 70 | } |
@@ -10,228 +10,228 @@ |
||
10 | 10 | */ |
11 | 11 | trait MessagesAdmin |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | - * a string. |
|
16 | - */ |
|
17 | - public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | - { |
|
19 | - $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | - * a string. |
|
25 | - */ |
|
26 | - public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | - { |
|
28 | - $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | - * a string. |
|
35 | - */ |
|
36 | - public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | - { |
|
38 | - $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Directs to message settings page |
|
44 | - */ |
|
45 | - public function amOnMessageSettingsPage() |
|
46 | - { |
|
47 | - $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
52 | - { |
|
53 | - $this->actor()->dragAndDrop( |
|
54 | - MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
55 | - MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Assumes you are already on the list table page that has the ui for editing the template. |
|
62 | - * @param string $message_type_slug |
|
63 | - * @param string $context [optional] if you want to click directly to the given context in the editor |
|
64 | - */ |
|
65 | - public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
66 | - { |
|
67 | - $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
73 | - * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
74 | - * |
|
75 | - * @param int $expected_occurence_count |
|
76 | - * @param string $text_to_check_for |
|
77 | - * @param string $field |
|
78 | - * @param string $message_type_label |
|
79 | - * @param string $message_status |
|
80 | - * @param string $messenger |
|
81 | - * @param string $context |
|
82 | - */ |
|
83 | - public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
84 | - $expected_occurence_count, |
|
85 | - $text_to_check_for, |
|
86 | - $field, |
|
87 | - $message_type_label, |
|
88 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
89 | - $messenger = 'Email', |
|
90 | - $context = 'Event Admin' |
|
91 | - ) { |
|
92 | - $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
93 | - $field, |
|
94 | - $message_type_label, |
|
95 | - $message_status, |
|
96 | - $messenger, |
|
97 | - $context, |
|
98 | - $text_to_check_for, |
|
99 | - 0 |
|
100 | - )); |
|
101 | - $actual_count = count($elements); |
|
102 | - $this->actor()->assertEquals( |
|
103 | - $expected_occurence_count, |
|
104 | - $actual_count, |
|
105 | - sprintf( |
|
106 | - 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
107 | - $expected_occurence_count, |
|
108 | - $text_to_check_for, |
|
109 | - $field, |
|
110 | - $actual_count |
|
111 | - ) |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * This will create a custom message template for the given messenger and message type from the context of the |
|
118 | - * default (global) message template list table. |
|
119 | - * Also takes care of verifying the template was created. |
|
120 | - * @param string $message_type_label |
|
121 | - * @param string $messenger_label |
|
122 | - */ |
|
123 | - public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
124 | - { |
|
125 | - $this->amOnDefaultMessageTemplateListTablePage(); |
|
126 | - $this->actor()->click( |
|
127 | - MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
128 | - $message_type_label, |
|
129 | - $messenger_label |
|
130 | - ) |
|
131 | - ); |
|
132 | - $this->actor()->seeInField('#title', 'New Custom Template'); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * This switches the context of the current messages template to the given reference. |
|
138 | - * @param string $context_reference This should be the visible label for the option. |
|
139 | - */ |
|
140 | - public function switchContextTo($context_reference) |
|
141 | - { |
|
142 | - $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
143 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
144 | - $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * This takes care of clicking the View Message icon for the given parameters. |
|
150 | - * Assumes you are already viewing the messages activity list table. |
|
151 | - * @param $message_type_label |
|
152 | - * @param $message_status |
|
153 | - * @param string $messenger |
|
154 | - * @param string $context |
|
155 | - * @param int $number_in_set |
|
156 | - */ |
|
157 | - public function viewMessageInMessagesListTableFor( |
|
158 | - $message_type_label, |
|
159 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
160 | - $messenger = 'Email', |
|
161 | - $context = 'Event Admin', |
|
162 | - $number_in_set = 1 |
|
163 | - ) { |
|
164 | - $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
165 | - $message_type_label, |
|
166 | - $message_status, |
|
167 | - $messenger, |
|
168 | - $context, |
|
169 | - $number_in_set |
|
170 | - )); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
176 | - * Assumes you are already viewing the messages activity list table. |
|
177 | - * @param $message_type_label |
|
178 | - * @param $message_status |
|
179 | - * @param string $messenger |
|
180 | - * @param string $context |
|
181 | - * @param int $number_in_set |
|
182 | - */ |
|
183 | - public function deleteMessageInMessagesListTableFor( |
|
184 | - $message_type_label, |
|
185 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
186 | - $messenger = 'Email', |
|
187 | - $context = 'Event Admin', |
|
188 | - $number_in_set = 1 |
|
189 | - ) { |
|
190 | - $this->actor()->moveMouseOver( |
|
191 | - MessagesPage::messagesActivityListTableCellSelectorFor( |
|
192 | - 'to', |
|
193 | - $message_type_label, |
|
194 | - $message_status, |
|
195 | - $messenger, |
|
196 | - $context, |
|
197 | - '', |
|
198 | - $number_in_set |
|
199 | - ) |
|
200 | - ); |
|
201 | - $this->actor()->click( |
|
202 | - MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
203 | - $message_type_label, |
|
204 | - $message_status, |
|
205 | - $messenger, |
|
206 | - $context, |
|
207 | - $number_in_set |
|
208 | - ) |
|
209 | - ); |
|
210 | - $this->actor()->waitForText('successfully deleted'); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
216 | - * list table, this will take care of validating the given text is in that window. |
|
217 | - * @param string $text_to_view |
|
218 | - */ |
|
219 | - public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
220 | - { |
|
221 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
222 | - $this->actor()->switchToIframe('message-view-window'); |
|
223 | - $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
224 | - $this->actor()->switchToIframe(); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
230 | - * list table, this will take care of validating the given text is NOT that window. |
|
231 | - * @param string $text_to_view |
|
232 | - */ |
|
233 | - public function dontSeeTextInViewMessageModal($text_to_view) |
|
234 | - { |
|
235 | - $this->seeTextInViewMessageModal($text_to_view, true); |
|
236 | - } |
|
13 | + /** |
|
14 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | + * a string. |
|
16 | + */ |
|
17 | + public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | + { |
|
19 | + $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | + * a string. |
|
25 | + */ |
|
26 | + public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | + { |
|
28 | + $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | + * a string. |
|
35 | + */ |
|
36 | + public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | + { |
|
38 | + $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Directs to message settings page |
|
44 | + */ |
|
45 | + public function amOnMessageSettingsPage() |
|
46 | + { |
|
47 | + $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
52 | + { |
|
53 | + $this->actor()->dragAndDrop( |
|
54 | + MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
55 | + MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Assumes you are already on the list table page that has the ui for editing the template. |
|
62 | + * @param string $message_type_slug |
|
63 | + * @param string $context [optional] if you want to click directly to the given context in the editor |
|
64 | + */ |
|
65 | + public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
66 | + { |
|
67 | + $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
73 | + * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
74 | + * |
|
75 | + * @param int $expected_occurence_count |
|
76 | + * @param string $text_to_check_for |
|
77 | + * @param string $field |
|
78 | + * @param string $message_type_label |
|
79 | + * @param string $message_status |
|
80 | + * @param string $messenger |
|
81 | + * @param string $context |
|
82 | + */ |
|
83 | + public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
84 | + $expected_occurence_count, |
|
85 | + $text_to_check_for, |
|
86 | + $field, |
|
87 | + $message_type_label, |
|
88 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
89 | + $messenger = 'Email', |
|
90 | + $context = 'Event Admin' |
|
91 | + ) { |
|
92 | + $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
93 | + $field, |
|
94 | + $message_type_label, |
|
95 | + $message_status, |
|
96 | + $messenger, |
|
97 | + $context, |
|
98 | + $text_to_check_for, |
|
99 | + 0 |
|
100 | + )); |
|
101 | + $actual_count = count($elements); |
|
102 | + $this->actor()->assertEquals( |
|
103 | + $expected_occurence_count, |
|
104 | + $actual_count, |
|
105 | + sprintf( |
|
106 | + 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
107 | + $expected_occurence_count, |
|
108 | + $text_to_check_for, |
|
109 | + $field, |
|
110 | + $actual_count |
|
111 | + ) |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * This will create a custom message template for the given messenger and message type from the context of the |
|
118 | + * default (global) message template list table. |
|
119 | + * Also takes care of verifying the template was created. |
|
120 | + * @param string $message_type_label |
|
121 | + * @param string $messenger_label |
|
122 | + */ |
|
123 | + public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
124 | + { |
|
125 | + $this->amOnDefaultMessageTemplateListTablePage(); |
|
126 | + $this->actor()->click( |
|
127 | + MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
128 | + $message_type_label, |
|
129 | + $messenger_label |
|
130 | + ) |
|
131 | + ); |
|
132 | + $this->actor()->seeInField('#title', 'New Custom Template'); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * This switches the context of the current messages template to the given reference. |
|
138 | + * @param string $context_reference This should be the visible label for the option. |
|
139 | + */ |
|
140 | + public function switchContextTo($context_reference) |
|
141 | + { |
|
142 | + $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
143 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
144 | + $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * This takes care of clicking the View Message icon for the given parameters. |
|
150 | + * Assumes you are already viewing the messages activity list table. |
|
151 | + * @param $message_type_label |
|
152 | + * @param $message_status |
|
153 | + * @param string $messenger |
|
154 | + * @param string $context |
|
155 | + * @param int $number_in_set |
|
156 | + */ |
|
157 | + public function viewMessageInMessagesListTableFor( |
|
158 | + $message_type_label, |
|
159 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
160 | + $messenger = 'Email', |
|
161 | + $context = 'Event Admin', |
|
162 | + $number_in_set = 1 |
|
163 | + ) { |
|
164 | + $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
165 | + $message_type_label, |
|
166 | + $message_status, |
|
167 | + $messenger, |
|
168 | + $context, |
|
169 | + $number_in_set |
|
170 | + )); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
176 | + * Assumes you are already viewing the messages activity list table. |
|
177 | + * @param $message_type_label |
|
178 | + * @param $message_status |
|
179 | + * @param string $messenger |
|
180 | + * @param string $context |
|
181 | + * @param int $number_in_set |
|
182 | + */ |
|
183 | + public function deleteMessageInMessagesListTableFor( |
|
184 | + $message_type_label, |
|
185 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
186 | + $messenger = 'Email', |
|
187 | + $context = 'Event Admin', |
|
188 | + $number_in_set = 1 |
|
189 | + ) { |
|
190 | + $this->actor()->moveMouseOver( |
|
191 | + MessagesPage::messagesActivityListTableCellSelectorFor( |
|
192 | + 'to', |
|
193 | + $message_type_label, |
|
194 | + $message_status, |
|
195 | + $messenger, |
|
196 | + $context, |
|
197 | + '', |
|
198 | + $number_in_set |
|
199 | + ) |
|
200 | + ); |
|
201 | + $this->actor()->click( |
|
202 | + MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
203 | + $message_type_label, |
|
204 | + $message_status, |
|
205 | + $messenger, |
|
206 | + $context, |
|
207 | + $number_in_set |
|
208 | + ) |
|
209 | + ); |
|
210 | + $this->actor()->waitForText('successfully deleted'); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
216 | + * list table, this will take care of validating the given text is in that window. |
|
217 | + * @param string $text_to_view |
|
218 | + */ |
|
219 | + public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
220 | + { |
|
221 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
222 | + $this->actor()->switchToIframe('message-view-window'); |
|
223 | + $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
224 | + $this->actor()->switchToIframe(); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
230 | + * list table, this will take care of validating the given text is NOT that window. |
|
231 | + * @param string $text_to_view |
|
232 | + */ |
|
233 | + public function dontSeeTextInViewMessageModal($text_to_view) |
|
234 | + { |
|
235 | + $this->seeTextInViewMessageModal($text_to_view, true); |
|
236 | + } |
|
237 | 237 | } |
@@ -14,84 +14,84 @@ |
||
14 | 14 | trait EventsAdmin |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @param string $additional_params |
|
19 | - */ |
|
20 | - public function amOnDefaultEventsListTablePage($additional_params = '') |
|
21 | - { |
|
22 | - $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params)); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @param string $additional_params |
|
19 | + */ |
|
20 | + public function amOnDefaultEventsListTablePage($additional_params = '') |
|
21 | + { |
|
22 | + $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params)); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Triggers the publishing of the Event. |
|
28 | - */ |
|
29 | - public function publishEvent() |
|
30 | - { |
|
31 | - $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR); |
|
32 | - } |
|
26 | + /** |
|
27 | + * Triggers the publishing of the Event. |
|
28 | + */ |
|
29 | + public function publishEvent() |
|
30 | + { |
|
31 | + $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Navigates the actor to the event list table page and will attempt to edit the event for the given title. |
|
37 | - * First this will search using the given title and then attempt to edit from the results of the search. |
|
38 | - * |
|
39 | - * Assumes actor is already logged in. |
|
40 | - * @param $event_title |
|
41 | - */ |
|
42 | - public function amEditingTheEventWithTitle($event_title) |
|
43 | - { |
|
44 | - $this->amOnDefaultEventsListTablePage(); |
|
45 | - $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title); |
|
46 | - $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR); |
|
47 | - $this->actor()->waitForText('Displaying search results for'); |
|
48 | - $this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title)); |
|
49 | - } |
|
35 | + /** |
|
36 | + * Navigates the actor to the event list table page and will attempt to edit the event for the given title. |
|
37 | + * First this will search using the given title and then attempt to edit from the results of the search. |
|
38 | + * |
|
39 | + * Assumes actor is already logged in. |
|
40 | + * @param $event_title |
|
41 | + */ |
|
42 | + public function amEditingTheEventWithTitle($event_title) |
|
43 | + { |
|
44 | + $this->amOnDefaultEventsListTablePage(); |
|
45 | + $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title); |
|
46 | + $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR); |
|
47 | + $this->actor()->waitForText('Displaying search results for'); |
|
48 | + $this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title)); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View" |
|
54 | - * link for the event in the event list table. |
|
55 | - * Assumes the actor is already logged in and on the Event list table page. |
|
56 | - * |
|
57 | - * @param string $event_title |
|
58 | - */ |
|
59 | - public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title) |
|
60 | - { |
|
61 | - $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title)); |
|
62 | - $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title)); |
|
63 | - } |
|
52 | + /** |
|
53 | + * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View" |
|
54 | + * link for the event in the event list table. |
|
55 | + * Assumes the actor is already logged in and on the Event list table page. |
|
56 | + * |
|
57 | + * @param string $event_title |
|
58 | + */ |
|
59 | + public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title) |
|
60 | + { |
|
61 | + $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title)); |
|
62 | + $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title)); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * Use to change the default registration status for the event. |
|
68 | - * Assumes the view is already on the event editor. |
|
69 | - * @param $registration_status |
|
70 | - */ |
|
71 | - public function changeDefaultRegistrationStatusTo($registration_status) |
|
72 | - { |
|
73 | - $this->actor()->selectOption( |
|
74 | - EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR, |
|
75 | - $registration_status |
|
76 | - ); |
|
77 | - } |
|
66 | + /** |
|
67 | + * Use to change the default registration status for the event. |
|
68 | + * Assumes the view is already on the event editor. |
|
69 | + * @param $registration_status |
|
70 | + */ |
|
71 | + public function changeDefaultRegistrationStatusTo($registration_status) |
|
72 | + { |
|
73 | + $this->actor()->selectOption( |
|
74 | + EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR, |
|
75 | + $registration_status |
|
76 | + ); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Use this from the context of the event editor to select the given custom template for a given message type and |
|
82 | - * messenger. |
|
83 | - * |
|
84 | - * @param string $message_type_label The visible label for the message type (eg Registration Approved) |
|
85 | - * @param string $messenger_slug The slug for the messenger (eg 'email') |
|
86 | - * @param string $custom_template_label The visible label in the select input for the custom template you want |
|
87 | - * selected. |
|
88 | - */ |
|
89 | - public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label) |
|
90 | - { |
|
91 | - $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)); |
|
92 | - $this->actor()->selectOption( |
|
93 | - EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label), |
|
94 | - $custom_template_label |
|
95 | - ); |
|
96 | - } |
|
80 | + /** |
|
81 | + * Use this from the context of the event editor to select the given custom template for a given message type and |
|
82 | + * messenger. |
|
83 | + * |
|
84 | + * @param string $message_type_label The visible label for the message type (eg Registration Approved) |
|
85 | + * @param string $messenger_slug The slug for the messenger (eg 'email') |
|
86 | + * @param string $custom_template_label The visible label in the select input for the custom template you want |
|
87 | + * selected. |
|
88 | + */ |
|
89 | + public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label) |
|
90 | + { |
|
91 | + $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)); |
|
92 | + $this->actor()->selectOption( |
|
93 | + EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label), |
|
94 | + $custom_template_label |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -13,84 +13,84 @@ |
||
13 | 13 | class CoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - const URL_PREFIX = 'admin.php?page='; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * This is the selector for the next page button on list tables. |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * The selector for the search input submit button on list table pages |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit'; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Selector for the screen options dropdown. |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link'; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Selector for the per page field setting selector (found within screen options dropdown) |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page'; |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Selector for apply screen options settings. |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply'; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Get the EE admin url for the given properties. |
|
59 | - * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
60 | - * with `amOnAdminPage` action. |
|
61 | - * |
|
62 | - * @param string $page |
|
63 | - * @param string $action |
|
64 | - * @param string $additional_params |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
68 | - { |
|
69 | - $url = self::URL_PREFIX . $page; |
|
70 | - $url .= $action ? '&action=' . $action : ''; |
|
71 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
72 | - return $url; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Returns the selector for the text tab switcher for a wp-editor instance. |
|
78 | - * @param $field_reference |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public static function wpEditorTextTabSelector($field_reference) |
|
82 | - { |
|
83 | - return '#content-' . $field_reference . '-content-html'; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance. |
|
89 | - * @param $field_reference |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public static function wpEditorTextAreaSelector($field_reference) |
|
93 | - { |
|
94 | - return '#content-' . $field_reference . '-content'; |
|
95 | - } |
|
16 | + /** |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + const URL_PREFIX = 'admin.php?page='; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * This is the selector for the next page button on list tables. |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * The selector for the search input submit button on list table pages |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit'; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Selector for the screen options dropdown. |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link'; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * Selector for the per page field setting selector (found within screen options dropdown) |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page'; |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Selector for apply screen options settings. |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply'; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Get the EE admin url for the given properties. |
|
59 | + * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
60 | + * with `amOnAdminPage` action. |
|
61 | + * |
|
62 | + * @param string $page |
|
63 | + * @param string $action |
|
64 | + * @param string $additional_params |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
68 | + { |
|
69 | + $url = self::URL_PREFIX . $page; |
|
70 | + $url .= $action ? '&action=' . $action : ''; |
|
71 | + $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
72 | + return $url; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Returns the selector for the text tab switcher for a wp-editor instance. |
|
78 | + * @param $field_reference |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public static function wpEditorTextTabSelector($field_reference) |
|
82 | + { |
|
83 | + return '#content-' . $field_reference . '-content-html'; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance. |
|
89 | + * @param $field_reference |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public static function wpEditorTextAreaSelector($field_reference) |
|
93 | + { |
|
94 | + return '#content-' . $field_reference . '-content'; |
|
95 | + } |
|
96 | 96 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
68 | 68 | { |
69 | - $url = self::URL_PREFIX . $page; |
|
70 | - $url .= $action ? '&action=' . $action : ''; |
|
71 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
69 | + $url = self::URL_PREFIX.$page; |
|
70 | + $url .= $action ? '&action='.$action : ''; |
|
71 | + $url .= $additional_params ? '&'.ltrim('&', ltrim('?', $additional_params)) : ''; |
|
72 | 72 | return $url; |
73 | 73 | } |
74 | 74 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function wpEditorTextTabSelector($field_reference) |
82 | 82 | { |
83 | - return '#content-' . $field_reference . '-content-html'; |
|
83 | + return '#content-'.$field_reference.'-content-html'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,6 +91,6 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function wpEditorTextAreaSelector($field_reference) |
93 | 93 | { |
94 | - return '#content-' . $field_reference . '-content'; |
|
94 | + return '#content-'.$field_reference.'-content'; |
|
95 | 95 | } |
96 | 96 | } |
@@ -12,255 +12,255 @@ |
||
12 | 12 | class MessagesAdmin extends CoreAdmin |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Context slug for the admin messages context. |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - const ADMIN_CONTEXT_SLUG = 'admin'; |
|
15 | + /** |
|
16 | + * Context slug for the admin messages context. |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + const ADMIN_CONTEXT_SLUG = 'admin'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Context slug for the primary attendee messages context |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee'; |
|
21 | + /** |
|
22 | + * Context slug for the primary attendee messages context |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee'; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Status reference for the EEM_Message::status_sent status. |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - const MESSAGE_STATUS_SENT = 'MSN'; |
|
28 | + /** |
|
29 | + * Status reference for the EEM_Message::status_sent status. |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + const MESSAGE_STATUS_SENT = 'MSN'; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Message type slug for the Payment Failed message type |
|
37 | - */ |
|
38 | - const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed'; |
|
35 | + /** |
|
36 | + * Message type slug for the Payment Failed message type |
|
37 | + */ |
|
38 | + const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed'; |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Selector for the Global Messages "Send on same request" field in the Messages Settings tab. |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = |
|
46 | - '#global_messages_settings-do-messages-on-same-request'; |
|
47 | - |
|
41 | + /** |
|
42 | + * Selector for the Global Messages "Send on same request" field in the Messages Settings tab. |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = |
|
46 | + '#global_messages_settings-do-messages-on-same-request'; |
|
47 | + |
|
48 | 48 | |
49 | - /** |
|
50 | - * Selector for the Global Messages Settings submit button in the Messages Settings tab. |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit'; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * This is the container where active message types for a messenger are found/dragged to. |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types'; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Locator for the context switcher selector on the Message Template Editor page. |
|
65 | - * @var string |
|
66 | - */ |
|
67 | - const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select"; |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Locator for the context switcher submit button in the Message Template Editor page. |
|
72 | - * @var string |
|
73 | - */ |
|
74 | - const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt"; |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Locator for the dialog container used for housing viewed messages in the message activity list table. |
|
79 | - * @var string |
|
80 | - */ |
|
81 | - const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content'; |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
87 | - * a string. |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public static function messageActivityListTableUrl($additional_params = '') |
|
91 | - { |
|
92 | - return self::adminUrl('espresso_messages', 'default', $additional_params); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
98 | - * a string. |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public static function defaultMessageTemplateListTableUrl($additional_params = '') |
|
102 | - { |
|
103 | - return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
109 | - * a string. |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public static function customMessageTemplateListTableUrl($additional_params = '') |
|
113 | - { |
|
114 | - return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public static function messageSettingsUrl() |
|
122 | - { |
|
123 | - return self::adminUrl('espresso_messages', 'settings'); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger( |
|
129 | - $message_type_slug, |
|
130 | - $messenger_slug = 'email' |
|
131 | - ) { |
|
132 | - return "#$message_type_slug-messagetype-$messenger_slug"; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @param string $message_type_slug |
|
138 | - * @param string $context |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
|
142 | - { |
|
143 | - return $context |
|
144 | - ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
145 | - : '.' . $message_type_slug . '-edit-link'; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters. |
|
151 | - * |
|
152 | - * @param $field |
|
153 | - * @param $message_type_label |
|
154 | - * @param string $message_status |
|
155 | - * @param string $messenger |
|
156 | - * @param string $context |
|
157 | - * @param string $table_cell_content_for_field |
|
158 | - * @param int $number_in_set It's possible that the given parameters could match multiple items in the view. |
|
159 | - * This allows you to indicate which item from the set to match. If this is set to 0 |
|
160 | - * then all matches for the locator will be returned. |
|
161 | - * @return string |
|
162 | - */ |
|
163 | - public static function messagesActivityListTableCellSelectorFor( |
|
164 | - $field, |
|
165 | - $message_type_label, |
|
166 | - $message_status = self::MESSAGE_STATUS_SENT, |
|
167 | - $messenger = 'Email', |
|
168 | - $context = 'Event Admin', |
|
169 | - $table_cell_content_for_field = '', |
|
170 | - $number_in_set = 1 |
|
171 | - ) { |
|
172 | - $selector = $number_in_set > 0 ? '(' : ''; |
|
173 | - $selector .= "//tr[contains(@class, 'msg-status-$message_status')]" |
|
174 | - . "//td[contains(@class, 'message_type') and text()='$message_type_label']"; |
|
175 | - if ($messenger) { |
|
176 | - $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']"; |
|
177 | - } |
|
178 | - $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']"; |
|
179 | - $selector .= $table_cell_content_for_field |
|
180 | - ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']" |
|
181 | - : "/ancestor::tr/td[contains(@class, 'column-$field')]"; |
|
182 | - $selector .= $number_in_set > 0 ? ")[$number_in_set]" : ''; |
|
183 | - return $selector; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Selector for the Create Custom button found in the message template list table. |
|
189 | - * @param string $message_type_label |
|
190 | - * @param string $messenger_label |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label) |
|
194 | - { |
|
195 | - $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']" |
|
196 | - . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]" |
|
197 | - . "//ancestor::tr/td/a[@class='button button-small']"; |
|
198 | - return $selector; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to |
|
204 | - * the FIRST match (which will be the latest message sent if the table is default sorted). |
|
205 | - * |
|
206 | - * @param string $message_type_label The visible message type label for the row you want to match |
|
207 | - * @param string $message_status The status of the message for the row you want to match. |
|
208 | - * @param string $messenger The visible messenger label for the row you want to match. |
|
209 | - * @param string $context The visible context label for the row you want to match. |
|
210 | - * @param int $number_in_set It's possible that the given parameters could match multiple items in the |
|
211 | - * view. This allows you to indicate which item from the set to match. |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public static function messagesActivityListTableViewButtonSelectorFor( |
|
215 | - $message_type_label, |
|
216 | - $message_status = self::MESSAGE_STATUS_SENT, |
|
217 | - $messenger = 'Email', |
|
218 | - $context = 'Event Admin', |
|
219 | - $number_in_set = 1 |
|
220 | - ) { |
|
221 | - $selector = self::messagesActivityListTableCellSelectorFor( |
|
222 | - 'action', |
|
223 | - $message_type_label, |
|
224 | - $message_status, |
|
225 | - $messenger, |
|
226 | - $context, |
|
227 | - '', |
|
228 | - $number_in_set |
|
229 | - ); |
|
230 | - $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')" |
|
231 | - . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]"; |
|
232 | - return $selector; |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * Locator for the delete action link for a message item in the message activity list table. |
|
239 | - * Note: The link is not visible by default, so the column would need hovered over for the link to appear. |
|
240 | - * @param $message_type_label |
|
241 | - * @param string $message_status |
|
242 | - * @param string $messenger |
|
243 | - * @param string $context |
|
244 | - * @param int $number_in_set |
|
245 | - * @return string |
|
246 | - */ |
|
247 | - public static function messagesActivityListTableDeleteActionSelectorFor( |
|
248 | - $message_type_label, |
|
249 | - $message_status = self::MESSAGE_STATUS_SENT, |
|
250 | - $messenger = 'Email', |
|
251 | - $context = 'Event Admin', |
|
252 | - $number_in_set = 1 |
|
253 | - ) { |
|
254 | - $selector = self::messagesActivityListTableCellSelectorFor( |
|
255 | - 'to', |
|
256 | - $message_type_label, |
|
257 | - $message_status, |
|
258 | - $messenger, |
|
259 | - $context, |
|
260 | - '', |
|
261 | - $number_in_set |
|
262 | - ); |
|
263 | - $selector .= "/div/span[@class='delete']/a"; |
|
264 | - return $selector; |
|
265 | - } |
|
49 | + /** |
|
50 | + * Selector for the Global Messages Settings submit button in the Messages Settings tab. |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit'; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * This is the container where active message types for a messenger are found/dragged to. |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types'; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Locator for the context switcher selector on the Message Template Editor page. |
|
65 | + * @var string |
|
66 | + */ |
|
67 | + const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select"; |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Locator for the context switcher submit button in the Message Template Editor page. |
|
72 | + * @var string |
|
73 | + */ |
|
74 | + const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt"; |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Locator for the dialog container used for housing viewed messages in the message activity list table. |
|
79 | + * @var string |
|
80 | + */ |
|
81 | + const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content'; |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
87 | + * a string. |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public static function messageActivityListTableUrl($additional_params = '') |
|
91 | + { |
|
92 | + return self::adminUrl('espresso_messages', 'default', $additional_params); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
98 | + * a string. |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public static function defaultMessageTemplateListTableUrl($additional_params = '') |
|
102 | + { |
|
103 | + return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
109 | + * a string. |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public static function customMessageTemplateListTableUrl($additional_params = '') |
|
113 | + { |
|
114 | + return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public static function messageSettingsUrl() |
|
122 | + { |
|
123 | + return self::adminUrl('espresso_messages', 'settings'); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger( |
|
129 | + $message_type_slug, |
|
130 | + $messenger_slug = 'email' |
|
131 | + ) { |
|
132 | + return "#$message_type_slug-messagetype-$messenger_slug"; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @param string $message_type_slug |
|
138 | + * @param string $context |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
|
142 | + { |
|
143 | + return $context |
|
144 | + ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
145 | + : '.' . $message_type_slug . '-edit-link'; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters. |
|
151 | + * |
|
152 | + * @param $field |
|
153 | + * @param $message_type_label |
|
154 | + * @param string $message_status |
|
155 | + * @param string $messenger |
|
156 | + * @param string $context |
|
157 | + * @param string $table_cell_content_for_field |
|
158 | + * @param int $number_in_set It's possible that the given parameters could match multiple items in the view. |
|
159 | + * This allows you to indicate which item from the set to match. If this is set to 0 |
|
160 | + * then all matches for the locator will be returned. |
|
161 | + * @return string |
|
162 | + */ |
|
163 | + public static function messagesActivityListTableCellSelectorFor( |
|
164 | + $field, |
|
165 | + $message_type_label, |
|
166 | + $message_status = self::MESSAGE_STATUS_SENT, |
|
167 | + $messenger = 'Email', |
|
168 | + $context = 'Event Admin', |
|
169 | + $table_cell_content_for_field = '', |
|
170 | + $number_in_set = 1 |
|
171 | + ) { |
|
172 | + $selector = $number_in_set > 0 ? '(' : ''; |
|
173 | + $selector .= "//tr[contains(@class, 'msg-status-$message_status')]" |
|
174 | + . "//td[contains(@class, 'message_type') and text()='$message_type_label']"; |
|
175 | + if ($messenger) { |
|
176 | + $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']"; |
|
177 | + } |
|
178 | + $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']"; |
|
179 | + $selector .= $table_cell_content_for_field |
|
180 | + ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']" |
|
181 | + : "/ancestor::tr/td[contains(@class, 'column-$field')]"; |
|
182 | + $selector .= $number_in_set > 0 ? ")[$number_in_set]" : ''; |
|
183 | + return $selector; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Selector for the Create Custom button found in the message template list table. |
|
189 | + * @param string $message_type_label |
|
190 | + * @param string $messenger_label |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label) |
|
194 | + { |
|
195 | + $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']" |
|
196 | + . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]" |
|
197 | + . "//ancestor::tr/td/a[@class='button button-small']"; |
|
198 | + return $selector; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to |
|
204 | + * the FIRST match (which will be the latest message sent if the table is default sorted). |
|
205 | + * |
|
206 | + * @param string $message_type_label The visible message type label for the row you want to match |
|
207 | + * @param string $message_status The status of the message for the row you want to match. |
|
208 | + * @param string $messenger The visible messenger label for the row you want to match. |
|
209 | + * @param string $context The visible context label for the row you want to match. |
|
210 | + * @param int $number_in_set It's possible that the given parameters could match multiple items in the |
|
211 | + * view. This allows you to indicate which item from the set to match. |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public static function messagesActivityListTableViewButtonSelectorFor( |
|
215 | + $message_type_label, |
|
216 | + $message_status = self::MESSAGE_STATUS_SENT, |
|
217 | + $messenger = 'Email', |
|
218 | + $context = 'Event Admin', |
|
219 | + $number_in_set = 1 |
|
220 | + ) { |
|
221 | + $selector = self::messagesActivityListTableCellSelectorFor( |
|
222 | + 'action', |
|
223 | + $message_type_label, |
|
224 | + $message_status, |
|
225 | + $messenger, |
|
226 | + $context, |
|
227 | + '', |
|
228 | + $number_in_set |
|
229 | + ); |
|
230 | + $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')" |
|
231 | + . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]"; |
|
232 | + return $selector; |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * Locator for the delete action link for a message item in the message activity list table. |
|
239 | + * Note: The link is not visible by default, so the column would need hovered over for the link to appear. |
|
240 | + * @param $message_type_label |
|
241 | + * @param string $message_status |
|
242 | + * @param string $messenger |
|
243 | + * @param string $context |
|
244 | + * @param int $number_in_set |
|
245 | + * @return string |
|
246 | + */ |
|
247 | + public static function messagesActivityListTableDeleteActionSelectorFor( |
|
248 | + $message_type_label, |
|
249 | + $message_status = self::MESSAGE_STATUS_SENT, |
|
250 | + $messenger = 'Email', |
|
251 | + $context = 'Event Admin', |
|
252 | + $number_in_set = 1 |
|
253 | + ) { |
|
254 | + $selector = self::messagesActivityListTableCellSelectorFor( |
|
255 | + 'to', |
|
256 | + $message_type_label, |
|
257 | + $message_status, |
|
258 | + $messenger, |
|
259 | + $context, |
|
260 | + '', |
|
261 | + $number_in_set |
|
262 | + ); |
|
263 | + $selector .= "/div/span[@class='delete']/a"; |
|
264 | + return $selector; |
|
265 | + } |
|
266 | 266 | } |
267 | 267 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\services\shortcodes\ShortcodesManager; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,1437 +21,1437 @@ discard block |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
26 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
27 | - */ |
|
28 | - const req_type_normal = 0; |
|
29 | - |
|
30 | - /** |
|
31 | - * Indicates this is a brand new installation of EE so we should install |
|
32 | - * tables and default data etc |
|
33 | - */ |
|
34 | - const req_type_new_activation = 1; |
|
35 | - |
|
36 | - /** |
|
37 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
38 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
39 | - * and that default data is setup too |
|
40 | - */ |
|
41 | - const req_type_reactivation = 2; |
|
42 | - |
|
43 | - /** |
|
44 | - * indicates that EE has been upgraded since its previous request. |
|
45 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
46 | - */ |
|
47 | - const req_type_upgrade = 3; |
|
48 | - |
|
49 | - /** |
|
50 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
51 | - */ |
|
52 | - const req_type_downgrade = 4; |
|
53 | - |
|
54 | - /** |
|
55 | - * @deprecated since version 4.6.0.dev.006 |
|
56 | - * Now whenever a new_activation is detected the request type is still just |
|
57 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
58 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
59 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
60 | - * (Specifically, when the migration manager indicates migrations are finished |
|
61 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
62 | - */ |
|
63 | - const req_type_activation_but_not_installed = 5; |
|
64 | - |
|
65 | - /** |
|
66 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
67 | - */ |
|
68 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * instance of the EE_System object |
|
73 | - * |
|
74 | - * @var $_instance |
|
75 | - * @access private |
|
76 | - */ |
|
77 | - private static $_instance = null; |
|
78 | - |
|
79 | - /** |
|
80 | - * @type EE_Registry $Registry |
|
81 | - * @access protected |
|
82 | - */ |
|
83 | - protected $registry; |
|
84 | - |
|
85 | - /** |
|
86 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
87 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
88 | - * |
|
89 | - * @var int |
|
90 | - */ |
|
91 | - private $_req_type; |
|
92 | - |
|
93 | - /** |
|
94 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
95 | - * |
|
96 | - * @var boolean |
|
97 | - */ |
|
98 | - private $_major_version_change = false; |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @singleton method used to instantiate class object |
|
104 | - * @access public |
|
105 | - * @param \EE_Registry $Registry |
|
106 | - * @return \EE_System |
|
107 | - */ |
|
108 | - public static function instance(EE_Registry $Registry = null) |
|
109 | - { |
|
110 | - // check if class object is instantiated |
|
111 | - if ( ! self::$_instance instanceof EE_System) { |
|
112 | - self::$_instance = new self($Registry); |
|
113 | - } |
|
114 | - return self::$_instance; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * resets the instance and returns it |
|
121 | - * |
|
122 | - * @return EE_System |
|
123 | - */ |
|
124 | - public static function reset() |
|
125 | - { |
|
126 | - self::$_instance->_req_type = null; |
|
127 | - //make sure none of the old hooks are left hanging around |
|
128 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
129 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
130 | - EE_Data_Migration_Manager::reset(); |
|
131 | - self::instance()->detect_activations_or_upgrades(); |
|
132 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
133 | - return self::instance(); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * sets hooks for running rest of system |
|
140 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
141 | - * starting EE Addons from any other point may lead to problems |
|
142 | - * |
|
143 | - * @access private |
|
144 | - * @param \EE_Registry $Registry |
|
145 | - */ |
|
146 | - private function __construct(EE_Registry $Registry) |
|
147 | - { |
|
148 | - $this->registry = $Registry; |
|
149 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
150 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
151 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
152 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
153 | - // because the newly-activated addon didn't get a chance to run at all |
|
154 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
155 | - // detect whether install or upgrade |
|
156 | - add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
157 | - 3); |
|
158 | - // load EE_Config, EE_Textdomain, etc |
|
159 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
160 | - // load EE_Config, EE_Textdomain, etc |
|
161 | - add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
162 | - array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
163 | - // you wanna get going? I wanna get going... let's get going! |
|
164 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
165 | - //other housekeeping |
|
166 | - //exclude EE critical pages from wp_list_pages |
|
167 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
168 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
169 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when |
|
170 | - // the EE_Config loads |
|
171 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * load_espresso_addons |
|
177 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
178 | - * this is hooked into both: |
|
179 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
180 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
181 | - * and the WP 'activate_plugin' hookpoint |
|
182 | - * |
|
183 | - * @access public |
|
184 | - * @return void |
|
185 | - * @throws EE_Error |
|
186 | - * @throws \EventEspresso\core\exceptions\InvalidExecutionPathException |
|
187 | - */ |
|
188 | - public function load_espresso_addons() |
|
189 | - { |
|
190 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
191 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
192 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
193 | - //load and setup EE_Capabilities |
|
194 | - $this->registry->load_core('Capabilities'); |
|
195 | - |
|
196 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
197 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
198 | - //We want it for mobile apps. Just include the entire plugin |
|
199 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
200 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
201 | - //and causes a fatal error |
|
202 | - if ( ! function_exists('json_basic_auth_handler') |
|
203 | - && ! function_exists('json_basic_auth_error') |
|
204 | - && ! ( |
|
205 | - isset($_GET['action']) |
|
206 | - && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
207 | - ) |
|
208 | - && ! ( |
|
209 | - isset($_GET['activate']) |
|
210 | - && $_GET['activate'] === 'true' |
|
211 | - ) |
|
212 | - ) { |
|
213 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
214 | - } |
|
215 | - $this->_maybe_brew_regular(); |
|
216 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
217 | - $this->registry->CAP->init_caps(); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * detect_activations_or_upgrades |
|
224 | - * Checks for activation or upgrade of core first; |
|
225 | - * then also checks if any registered addons have been activated or upgraded |
|
226 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
227 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
228 | - * |
|
229 | - * @access public |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function detect_activations_or_upgrades() |
|
233 | - { |
|
234 | - //first off: let's make sure to handle core |
|
235 | - $this->detect_if_activation_or_upgrade(); |
|
236 | - foreach ($this->registry->addons as $addon) { |
|
237 | - //detect teh request type for that addon |
|
238 | - $addon->detect_activation_or_upgrade(); |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * detect_if_activation_or_upgrade |
|
246 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
247 | - * and either setting up the DB or setting up maintenance mode etc. |
|
248 | - * |
|
249 | - * @access public |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - public function detect_if_activation_or_upgrade() |
|
253 | - { |
|
254 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
255 | - // load M-Mode class |
|
256 | - $this->registry->load_core('Maintenance_Mode'); |
|
257 | - // check if db has been updated, or if its a brand-new installation |
|
258 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
259 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
260 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
261 | - switch ($request_type) { |
|
262 | - case EE_System::req_type_new_activation: |
|
263 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
264 | - $this->_handle_core_version_change($espresso_db_update); |
|
265 | - break; |
|
266 | - case EE_System::req_type_reactivation: |
|
267 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
268 | - $this->_handle_core_version_change($espresso_db_update); |
|
269 | - break; |
|
270 | - case EE_System::req_type_upgrade: |
|
271 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
272 | - //migrations may be required now that we've upgraded |
|
273 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
274 | - $this->_handle_core_version_change($espresso_db_update); |
|
275 | - // echo "done upgrade";die; |
|
276 | - break; |
|
277 | - case EE_System::req_type_downgrade: |
|
278 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
279 | - //its possible migrations are no longer required |
|
280 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
281 | - $this->_handle_core_version_change($espresso_db_update); |
|
282 | - break; |
|
283 | - case EE_System::req_type_normal: |
|
284 | - default: |
|
285 | - // $this->_maybe_redirect_to_ee_about(); |
|
286 | - break; |
|
287 | - } |
|
288 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Updates the list of installed versions and sets hooks for |
|
295 | - * initializing the database later during the request |
|
296 | - * |
|
297 | - * @param array $espresso_db_update |
|
298 | - */ |
|
299 | - protected function _handle_core_version_change($espresso_db_update) |
|
300 | - { |
|
301 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
302 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
303 | - add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
304 | - array($this, 'initialize_db_if_no_migrations_required')); |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
311 | - * information about what versions of EE have been installed and activated, |
|
312 | - * NOT necessarily the state of the database |
|
313 | - * |
|
314 | - * @param null $espresso_db_update |
|
315 | - * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
316 | - * from the options table |
|
317 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
318 | - */ |
|
319 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
320 | - { |
|
321 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
322 | - if ( ! $espresso_db_update) { |
|
323 | - $espresso_db_update = get_option('espresso_db_update'); |
|
324 | - } |
|
325 | - // check that option is an array |
|
326 | - if ( ! is_array($espresso_db_update)) { |
|
327 | - // if option is FALSE, then it never existed |
|
328 | - if ($espresso_db_update === false) { |
|
329 | - // make $espresso_db_update an array and save option with autoload OFF |
|
330 | - $espresso_db_update = array(); |
|
331 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
332 | - } else { |
|
333 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
334 | - $espresso_db_update = array($espresso_db_update => array()); |
|
335 | - update_option('espresso_db_update', $espresso_db_update); |
|
336 | - } |
|
337 | - } else { |
|
338 | - $corrected_db_update = array(); |
|
339 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
340 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
341 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
342 | - //the key is an int, and the value IS NOT an array |
|
343 | - //so it must be numerically-indexed, where values are versions installed... |
|
344 | - //fix it! |
|
345 | - $version_string = $should_be_array; |
|
346 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
347 | - } else { |
|
348 | - //ok it checks out |
|
349 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
350 | - } |
|
351 | - } |
|
352 | - $espresso_db_update = $corrected_db_update; |
|
353 | - update_option('espresso_db_update', $espresso_db_update); |
|
354 | - } |
|
355 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
356 | - return $espresso_db_update; |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
362 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
363 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
364 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
365 | - * so that it will be done when migrations are finished |
|
366 | - * |
|
367 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
368 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
369 | - * This is a resource-intensive job |
|
370 | - * so we prefer to only do it when necessary |
|
371 | - * @return void |
|
372 | - * @throws EE_Error |
|
373 | - */ |
|
374 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
375 | - { |
|
376 | - $request_type = $this->detect_req_type(); |
|
377 | - //only initialize system if we're not in maintenance mode. |
|
378 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
379 | - update_option('ee_flush_rewrite_rules', true); |
|
380 | - if ($verify_schema) { |
|
381 | - EEH_Activation::initialize_db_and_folders(); |
|
382 | - } |
|
383 | - EEH_Activation::initialize_db_content(); |
|
384 | - EEH_Activation::system_initialization(); |
|
385 | - if ($initialize_addons_too) { |
|
386 | - $this->initialize_addons(); |
|
387 | - } |
|
388 | - } else { |
|
389 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
390 | - } |
|
391 | - if ($request_type === EE_System::req_type_new_activation |
|
392 | - || $request_type === EE_System::req_type_reactivation |
|
393 | - || ( |
|
394 | - $request_type === EE_System::req_type_upgrade |
|
395 | - && $this->is_major_version_change() |
|
396 | - ) |
|
397 | - ) { |
|
398 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * Initializes the db for all registered addons |
|
406 | - */ |
|
407 | - public function initialize_addons() |
|
408 | - { |
|
409 | - //foreach registered addon, make sure its db is up-to-date too |
|
410 | - foreach ($this->registry->addons as $addon) { |
|
411 | - $addon->initialize_db_if_no_migrations_required(); |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
419 | - * |
|
420 | - * @param array $version_history |
|
421 | - * @param string $current_version_to_add version to be added to the version history |
|
422 | - * @return boolean success as to whether or not this option was changed |
|
423 | - */ |
|
424 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
425 | - { |
|
426 | - if ( ! $version_history) { |
|
427 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
428 | - } |
|
429 | - if ($current_version_to_add == null) { |
|
430 | - $current_version_to_add = espresso_version(); |
|
431 | - } |
|
432 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
433 | - // re-save |
|
434 | - return update_option('espresso_db_update', $version_history); |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Detects if the current version indicated in the has existed in the list of |
|
441 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
442 | - * |
|
443 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
444 | - * If not supplied, fetches it from the options table. |
|
445 | - * Also, caches its result so later parts of the code can also know whether |
|
446 | - * there's been an update or not. This way we can add the current version to |
|
447 | - * espresso_db_update, but still know if this is a new install or not |
|
448 | - * @return int one of the constants on EE_System::req_type_ |
|
449 | - */ |
|
450 | - public function detect_req_type($espresso_db_update = null) |
|
451 | - { |
|
452 | - if ($this->_req_type === null) { |
|
453 | - $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
454 | - : $this->fix_espresso_db_upgrade_option(); |
|
455 | - $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
456 | - 'ee_espresso_activation', espresso_version()); |
|
457 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
458 | - } |
|
459 | - return $this->_req_type; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
466 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
467 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
468 | - * |
|
469 | - * @param $activation_history |
|
470 | - * @return bool |
|
471 | - */ |
|
472 | - protected function _detect_major_version_change($activation_history) |
|
473 | - { |
|
474 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
475 | - $previous_version_parts = explode('.', $previous_version); |
|
476 | - $current_version_parts = explode('.', espresso_version()); |
|
477 | - return isset( |
|
478 | - $previous_version_parts[0], |
|
479 | - $previous_version_parts[1], |
|
480 | - $current_version_parts[0], |
|
481 | - $current_version_parts[1] |
|
482 | - ) |
|
483 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
484 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
485 | - ); |
|
486 | - } |
|
487 | - |
|
488 | - |
|
489 | - |
|
490 | - /** |
|
491 | - * Returns true if either the major or minor version of EE changed during this request. |
|
492 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
493 | - * |
|
494 | - * @return bool |
|
495 | - */ |
|
496 | - public function is_major_version_change() |
|
497 | - { |
|
498 | - return $this->_major_version_change; |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
505 | - * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
506 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
507 | - * just activated to (for core that will always be espresso_version()) |
|
508 | - * |
|
509 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
510 | - * ee plugin. for core that's 'espresso_db_update' |
|
511 | - * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
512 | - * indicate that this plugin was just activated |
|
513 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
514 | - * espresso_version()) |
|
515 | - * @return int one of the constants on EE_System::req_type_* |
|
516 | - */ |
|
517 | - public static function detect_req_type_given_activation_history( |
|
518 | - $activation_history_for_addon, |
|
519 | - $activation_indicator_option_name, |
|
520 | - $version_to_upgrade_to |
|
521 | - ) { |
|
522 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
523 | - if ($activation_history_for_addon) { |
|
524 | - //it exists, so this isn't a completely new install |
|
525 | - //check if this version already in that list of previously installed versions |
|
526 | - if (! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
527 | - //it a version we haven't seen before |
|
528 | - if ($version_is_higher === 1) { |
|
529 | - $req_type = EE_System::req_type_upgrade; |
|
530 | - } else { |
|
531 | - $req_type = EE_System::req_type_downgrade; |
|
532 | - } |
|
533 | - delete_option($activation_indicator_option_name); |
|
534 | - } else { |
|
535 | - // its not an update. maybe a reactivation? |
|
536 | - if (get_option($activation_indicator_option_name, false)) { |
|
537 | - if ($version_is_higher === -1) { |
|
538 | - $req_type = EE_System::req_type_downgrade; |
|
539 | - } elseif ($version_is_higher === 0) { |
|
540 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
541 | - $req_type = EE_System::req_type_reactivation; |
|
542 | - } else {//$version_is_higher === 1 |
|
543 | - $req_type = EE_System::req_type_upgrade; |
|
544 | - } |
|
545 | - delete_option($activation_indicator_option_name); |
|
546 | - } else { |
|
547 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
548 | - if ($version_is_higher === -1) { |
|
549 | - $req_type = EE_System::req_type_downgrade; |
|
550 | - } elseif ($version_is_higher === 0) { |
|
551 | - //we've seen this version before and it's not an activation. its normal request |
|
552 | - $req_type = EE_System::req_type_normal; |
|
553 | - } else {//$version_is_higher === 1 |
|
554 | - $req_type = EE_System::req_type_upgrade; |
|
555 | - } |
|
556 | - } |
|
557 | - } |
|
558 | - } else { |
|
559 | - //brand new install |
|
560 | - $req_type = EE_System::req_type_new_activation; |
|
561 | - delete_option($activation_indicator_option_name); |
|
562 | - } |
|
563 | - return $req_type; |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
570 | - * the $activation_history_for_addon |
|
571 | - * |
|
572 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
573 | - * sometimes containing 'unknown-date' |
|
574 | - * @param string $version_to_upgrade_to (current version) |
|
575 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
576 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
577 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
578 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
579 | - */ |
|
580 | - protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
581 | - { |
|
582 | - //find the most recently-activated version |
|
583 | - $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history( |
|
584 | - $activation_history_for_addon |
|
585 | - ); |
|
586 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - |
|
591 | - /** |
|
592 | - * Gets the most recently active version listed in the activation history, |
|
593 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
594 | - * |
|
595 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
596 | - * sometimes containing 'unknown-date' |
|
597 | - * @return string |
|
598 | - */ |
|
599 | - protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
600 | - { |
|
601 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
602 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
603 | - if (is_array($activation_history)) { |
|
604 | - foreach ($activation_history as $version => $times_activated) { |
|
605 | - //check there is a record of when this version was activated. Otherwise, |
|
606 | - //mark it as unknown |
|
607 | - if (! $times_activated) { |
|
608 | - $times_activated = array('unknown-date'); |
|
609 | - } |
|
610 | - if (is_string($times_activated)) { |
|
611 | - $times_activated = array($times_activated); |
|
612 | - } |
|
613 | - foreach ($times_activated as $an_activation) { |
|
614 | - if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
615 | - $most_recently_active_version = $version; |
|
616 | - $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
617 | - ? '1970-01-01 00:00:00' : $an_activation; |
|
618 | - } |
|
619 | - } |
|
620 | - } |
|
621 | - } |
|
622 | - return $most_recently_active_version; |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * This redirects to the about EE page after activation |
|
629 | - * |
|
630 | - * @return void |
|
631 | - */ |
|
632 | - public function redirect_to_about_ee() |
|
633 | - { |
|
634 | - $notices = EE_Error::get_notices(false); |
|
635 | - //if current user is an admin and it's not an ajax or rest request |
|
636 | - if (! (defined('DOING_AJAX') && DOING_AJAX) |
|
637 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
638 | - && ! isset($notices['errors']) |
|
639 | - && apply_filters( |
|
640 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
641 | - $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
642 | - ) |
|
643 | - ) { |
|
644 | - $query_params = array('page' => 'espresso_about'); |
|
645 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
646 | - $query_params['new_activation'] = true; |
|
647 | - } |
|
648 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
649 | - $query_params['reactivation'] = true; |
|
650 | - } |
|
651 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
652 | - wp_safe_redirect($url); |
|
653 | - exit(); |
|
654 | - } |
|
655 | - } |
|
656 | - |
|
657 | - |
|
658 | - |
|
659 | - /** |
|
660 | - * load_core_configuration |
|
661 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
662 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
663 | - * |
|
664 | - * @return void |
|
665 | - */ |
|
666 | - public function load_core_configuration() |
|
667 | - { |
|
668 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
669 | - $this->registry->load_core('EE_Load_Textdomain'); |
|
670 | - //load textdomain |
|
671 | - EE_Load_Textdomain::load_textdomain(); |
|
672 | - // load and setup EE_Config and EE_Network_Config |
|
673 | - $this->registry->load_core('Config'); |
|
674 | - $this->registry->load_core('Network_Config'); |
|
675 | - // setup autoloaders |
|
676 | - // enable logging? |
|
677 | - if ($this->registry->CFG->admin->use_full_logging) { |
|
678 | - $this->registry->load_core('Log'); |
|
679 | - } |
|
680 | - // check for activation errors |
|
681 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
682 | - if ($activation_errors) { |
|
683 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
684 | - update_option('ee_plugin_activation_errors', false); |
|
685 | - } |
|
686 | - // get model names |
|
687 | - $this->_parse_model_names(); |
|
688 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
695 | - * |
|
696 | - * @return void |
|
697 | - */ |
|
698 | - private function _parse_model_names() |
|
699 | - { |
|
700 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
701 | - $models = glob(EE_MODELS . '*.model.php'); |
|
702 | - $model_names = array(); |
|
703 | - $non_abstract_db_models = array(); |
|
704 | - foreach ($models as $model) { |
|
705 | - // get model classname |
|
706 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
707 | - $short_name = str_replace('EEM_', '', $classname); |
|
708 | - $reflectionClass = new ReflectionClass($classname); |
|
709 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
710 | - $non_abstract_db_models[$short_name] = $classname; |
|
711 | - } |
|
712 | - $model_names[$short_name] = $classname; |
|
713 | - } |
|
714 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
715 | - $this->registry->non_abstract_db_models = apply_filters( |
|
716 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
717 | - $non_abstract_db_models |
|
718 | - ); |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - |
|
723 | - /** |
|
724 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
725 | - * that need to be setup before our EE_System launches. |
|
726 | - * |
|
727 | - * @return void |
|
728 | - */ |
|
729 | - private function _maybe_brew_regular() |
|
730 | - { |
|
731 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
732 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
733 | - } |
|
734 | - } |
|
735 | - |
|
736 | - |
|
737 | - |
|
738 | - /** |
|
739 | - * register_shortcodes_modules_and_widgets |
|
740 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
741 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
742 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
743 | - * |
|
744 | - * @access public |
|
745 | - * @return void |
|
746 | - */ |
|
747 | - public function register_shortcodes_modules_and_widgets() |
|
748 | - { |
|
749 | - try { |
|
750 | - // load, register, and add shortcodes the new way |
|
751 | - new ShortcodesManager( |
|
752 | - // and the old way, but we'll put it under control of the new system |
|
753 | - EE_Config::getLegacyShortcodesManager() |
|
754 | - ); |
|
755 | - } catch (Exception $exception) { |
|
756 | - new ExceptionStackTraceDisplay($exception); |
|
757 | - } |
|
758 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
759 | - // check for addons using old hookpoint |
|
760 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
761 | - $this->_incompatible_addon_error(); |
|
762 | - } |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - |
|
767 | - /** |
|
768 | - * _incompatible_addon_error |
|
769 | - * |
|
770 | - * @access public |
|
771 | - * @return void |
|
772 | - */ |
|
773 | - private function _incompatible_addon_error() |
|
774 | - { |
|
775 | - // get array of classes hooking into here |
|
776 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
777 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
778 | - ); |
|
779 | - if (! empty($class_names)) { |
|
780 | - $msg = esc_html__( |
|
781 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
782 | - 'event_espresso' |
|
783 | - ); |
|
784 | - $msg .= '<ul>'; |
|
785 | - foreach ($class_names as $class_name) { |
|
786 | - $msg .= '<li><b>Event Espresso - ' |
|
787 | - . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name) |
|
788 | - . '</b></li>'; |
|
789 | - } |
|
790 | - $msg .= '</ul>'; |
|
791 | - $msg .= esc_html__( |
|
792 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
793 | - 'event_espresso' |
|
794 | - ); |
|
795 | - // save list of incompatible addons to wp-options for later use |
|
796 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
797 | - if (is_admin()) { |
|
798 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
799 | - } |
|
800 | - } |
|
801 | - } |
|
802 | - |
|
803 | - |
|
804 | - |
|
805 | - /** |
|
806 | - * brew_espresso |
|
807 | - * begins the process of setting hooks for initializing EE in the correct order |
|
808 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
809 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
810 | - * |
|
811 | - * @return void |
|
812 | - */ |
|
813 | - public function brew_espresso() |
|
814 | - { |
|
815 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
816 | - // load some final core systems |
|
817 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
818 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
819 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
820 | - add_action('init', array($this, 'load_controllers'), 7); |
|
821 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
822 | - add_action('init', array($this, 'initialize'), 10); |
|
823 | - add_action('init', array($this, 'initialize_last'), 100); |
|
824 | - add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
825 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
826 | - // pew pew pew |
|
827 | - $this->registry->load_core('PUE'); |
|
828 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
829 | - } |
|
830 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - |
|
835 | - /** |
|
836 | - * set_hooks_for_core |
|
837 | - * |
|
838 | - * @access public |
|
839 | - * @return void |
|
840 | - */ |
|
841 | - public function set_hooks_for_core() |
|
842 | - { |
|
843 | - $this->_deactivate_incompatible_addons(); |
|
844 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
845 | - } |
|
846 | - |
|
847 | - |
|
848 | - |
|
849 | - /** |
|
850 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
851 | - * deactivates any addons considered incompatible with the current version of EE |
|
852 | - */ |
|
853 | - private function _deactivate_incompatible_addons() |
|
854 | - { |
|
855 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
856 | - if (! empty($incompatible_addons)) { |
|
857 | - $active_plugins = get_option('active_plugins', array()); |
|
858 | - foreach ($active_plugins as $active_plugin) { |
|
859 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
860 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
861 | - unset($_GET['activate']); |
|
862 | - espresso_deactivate_plugin($active_plugin); |
|
863 | - } |
|
864 | - } |
|
865 | - } |
|
866 | - } |
|
867 | - } |
|
868 | - |
|
869 | - |
|
870 | - |
|
871 | - /** |
|
872 | - * perform_activations_upgrades_and_migrations |
|
873 | - * |
|
874 | - * @access public |
|
875 | - * @return void |
|
876 | - */ |
|
877 | - public function perform_activations_upgrades_and_migrations() |
|
878 | - { |
|
879 | - //first check if we had previously attempted to setup EE's directories but failed |
|
880 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
881 | - EEH_Activation::create_upload_directories(); |
|
882 | - } |
|
883 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
884 | - } |
|
885 | - |
|
886 | - |
|
887 | - |
|
888 | - /** |
|
889 | - * load_CPTs_and_session |
|
890 | - * |
|
891 | - * @access public |
|
892 | - * @return void |
|
893 | - */ |
|
894 | - public function load_CPTs_and_session() |
|
895 | - { |
|
896 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
897 | - // register Custom Post Types |
|
898 | - $this->registry->load_core('Register_CPTs'); |
|
899 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * load_controllers |
|
906 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
907 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
908 | - * time |
|
909 | - * |
|
910 | - * @access public |
|
911 | - * @return void |
|
912 | - */ |
|
913 | - public function load_controllers() |
|
914 | - { |
|
915 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
916 | - // let's get it started |
|
917 | - if (! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
918 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
919 | - $this->registry->load_core('Front_Controller'); |
|
920 | - } elseif (! EE_FRONT_AJAX) { |
|
921 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
922 | - EE_Registry::instance()->load_core('Admin'); |
|
923 | - } |
|
924 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
925 | - } |
|
926 | - |
|
927 | - |
|
928 | - |
|
929 | - /** |
|
930 | - * core_loaded_and_ready |
|
931 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
932 | - * |
|
933 | - * @access public |
|
934 | - * @return void |
|
935 | - */ |
|
936 | - public function core_loaded_and_ready() |
|
937 | - { |
|
938 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
939 | - // load_espresso_template_tags |
|
940 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
941 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
942 | - } |
|
943 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
944 | - $this->registry->load_core('Session'); |
|
945 | - $this->registry->create('EventEspresso\core\services\assets\Registry'); |
|
946 | - wp_enqueue_script('espresso_core'); |
|
947 | - } |
|
948 | - |
|
949 | - |
|
950 | - |
|
951 | - /** |
|
952 | - * initialize |
|
953 | - * this is the best place to begin initializing client code |
|
954 | - * |
|
955 | - * @access public |
|
956 | - * @return void |
|
957 | - */ |
|
958 | - public function initialize() |
|
959 | - { |
|
960 | - do_action('AHEE__EE_System__initialize'); |
|
961 | - } |
|
962 | - |
|
963 | - |
|
964 | - |
|
965 | - /** |
|
966 | - * initialize_last |
|
967 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
968 | - * initialize has done so |
|
969 | - * |
|
970 | - * @access public |
|
971 | - * @return void |
|
972 | - */ |
|
973 | - public function initialize_last() |
|
974 | - { |
|
975 | - do_action('AHEE__EE_System__initialize_last'); |
|
976 | - } |
|
977 | - |
|
978 | - |
|
979 | - |
|
980 | - /** |
|
981 | - * set_hooks_for_shortcodes_modules_and_addons |
|
982 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
983 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
984 | - * |
|
985 | - * @access public |
|
986 | - * @return void |
|
987 | - */ |
|
988 | - public function set_hooks_for_shortcodes_modules_and_addons() |
|
989 | - { |
|
990 | - // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
991 | - } |
|
992 | - |
|
993 | - |
|
994 | - |
|
995 | - /** |
|
996 | - * do_not_cache |
|
997 | - * sets no cache headers and defines no cache constants for WP plugins |
|
998 | - * |
|
999 | - * @access public |
|
1000 | - * @return void |
|
1001 | - */ |
|
1002 | - public static function do_not_cache() |
|
1003 | - { |
|
1004 | - // set no cache constants |
|
1005 | - if (! defined('DONOTCACHEPAGE')) { |
|
1006 | - define('DONOTCACHEPAGE', true); |
|
1007 | - } |
|
1008 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1009 | - define('DONOTCACHCEOBJECT', true); |
|
1010 | - } |
|
1011 | - if (! defined('DONOTCACHEDB')) { |
|
1012 | - define('DONOTCACHEDB', true); |
|
1013 | - } |
|
1014 | - // add no cache headers |
|
1015 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1016 | - // plus a little extra for nginx and Google Chrome |
|
1017 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1018 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes |
|
1019 | - // with the registration process |
|
1020 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1021 | - } |
|
1022 | - |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * extra_nocache_headers |
|
1027 | - * |
|
1028 | - * @access public |
|
1029 | - * @param $headers |
|
1030 | - * @return array |
|
1031 | - */ |
|
1032 | - public static function extra_nocache_headers($headers) |
|
1033 | - { |
|
1034 | - // for NGINX |
|
1035 | - $headers['X-Accel-Expires'] = 0; |
|
1036 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1037 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1038 | - return $headers; |
|
1039 | - } |
|
1040 | - |
|
1041 | - |
|
1042 | - |
|
1043 | - /** |
|
1044 | - * nocache_headers |
|
1045 | - * |
|
1046 | - * @access public |
|
1047 | - * @return void |
|
1048 | - */ |
|
1049 | - public static function nocache_headers() |
|
1050 | - { |
|
1051 | - nocache_headers(); |
|
1052 | - } |
|
1053 | - |
|
1054 | - |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * espresso_toolbar_items |
|
1058 | - * |
|
1059 | - * @access public |
|
1060 | - * @param WP_Admin_Bar $admin_bar |
|
1061 | - * @return void |
|
1062 | - */ |
|
1063 | - public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1064 | - { |
|
1065 | - // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1066 | - if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1067 | - || defined('DOING_AJAX') |
|
1068 | - || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1069 | - ) { |
|
1070 | - return; |
|
1071 | - } |
|
1072 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1073 | - $menu_class = 'espresso_menu_item_class'; |
|
1074 | - //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1075 | - //because they're only defined in each of their respective constructors |
|
1076 | - //and this might be a frontend request, in which case they aren't available |
|
1077 | - $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1078 | - $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1079 | - $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1080 | - //Top Level |
|
1081 | - $admin_bar->add_menu(array( |
|
1082 | - 'id' => 'espresso-toolbar', |
|
1083 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1084 | - . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1085 | - . '</span>', |
|
1086 | - 'href' => $events_admin_url, |
|
1087 | - 'meta' => array( |
|
1088 | - 'title' => esc_html__('Event Espresso', 'event_espresso'), |
|
1089 | - 'class' => $menu_class . 'first', |
|
1090 | - ), |
|
1091 | - )); |
|
1092 | - //Events |
|
1093 | - if ($this->registry->CAP->current_user_can( |
|
1094 | - 'ee_read_events', |
|
1095 | - 'ee_admin_bar_menu_espresso-toolbar-events' |
|
1096 | - )) { |
|
1097 | - $admin_bar->add_menu(array( |
|
1098 | - 'id' => 'espresso-toolbar-events', |
|
1099 | - 'parent' => 'espresso-toolbar', |
|
1100 | - 'title' => esc_html__('Events', 'event_espresso'), |
|
1101 | - 'href' => $events_admin_url, |
|
1102 | - 'meta' => array( |
|
1103 | - 'title' => esc_html__('Events', 'event_espresso'), |
|
1104 | - 'target' => '', |
|
1105 | - 'class' => $menu_class, |
|
1106 | - ), |
|
1107 | - )); |
|
1108 | - } |
|
1109 | - if ($this->registry->CAP->current_user_can( |
|
1110 | - 'ee_edit_events', |
|
1111 | - 'ee_admin_bar_menu_espresso-toolbar-events-new' |
|
1112 | - )) { |
|
1113 | - //Events Add New |
|
1114 | - $admin_bar->add_menu(array( |
|
1115 | - 'id' => 'espresso-toolbar-events-new', |
|
1116 | - 'parent' => 'espresso-toolbar-events', |
|
1117 | - 'title' => esc_html__('Add New', 'event_espresso'), |
|
1118 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1119 | - 'meta' => array( |
|
1120 | - 'title' => esc_html__('Add New', 'event_espresso'), |
|
1121 | - 'target' => '', |
|
1122 | - 'class' => $menu_class, |
|
1123 | - ), |
|
1124 | - )); |
|
1125 | - } |
|
1126 | - if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1127 | - //Current post |
|
1128 | - global $post; |
|
1129 | - if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1130 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1131 | - ) { |
|
1132 | - //Events Edit Current Event |
|
1133 | - $admin_bar->add_menu(array( |
|
1134 | - 'id' => 'espresso-toolbar-events-edit', |
|
1135 | - 'parent' => 'espresso-toolbar-events', |
|
1136 | - 'title' => esc_html__('Edit Event', 'event_espresso'), |
|
1137 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1138 | - $events_admin_url), |
|
1139 | - 'meta' => array( |
|
1140 | - 'title' => esc_html__('Edit Event', 'event_espresso'), |
|
1141 | - 'target' => '', |
|
1142 | - 'class' => $menu_class, |
|
1143 | - ), |
|
1144 | - )); |
|
1145 | - } |
|
1146 | - } |
|
1147 | - //Events View |
|
1148 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1149 | - 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1150 | - ) { |
|
1151 | - $admin_bar->add_menu(array( |
|
1152 | - 'id' => 'espresso-toolbar-events-view', |
|
1153 | - 'parent' => 'espresso-toolbar-events', |
|
1154 | - 'title' => esc_html__('View', 'event_espresso'), |
|
1155 | - 'href' => $events_admin_url, |
|
1156 | - 'meta' => array( |
|
1157 | - 'title' => esc_html__('View', 'event_espresso'), |
|
1158 | - 'target' => '', |
|
1159 | - 'class' => $menu_class, |
|
1160 | - ), |
|
1161 | - )); |
|
1162 | - } |
|
1163 | - if ($this->registry->CAP->current_user_can( |
|
1164 | - 'ee_read_events', |
|
1165 | - 'ee_admin_bar_menu_espresso-toolbar-events-all' |
|
1166 | - )) { |
|
1167 | - //Events View All |
|
1168 | - $admin_bar->add_menu(array( |
|
1169 | - 'id' => 'espresso-toolbar-events-all', |
|
1170 | - 'parent' => 'espresso-toolbar-events-view', |
|
1171 | - 'title' => esc_html__('All', 'event_espresso'), |
|
1172 | - 'href' => $events_admin_url, |
|
1173 | - 'meta' => array( |
|
1174 | - 'title' => esc_html__('All', 'event_espresso'), |
|
1175 | - 'target' => '', |
|
1176 | - 'class' => $menu_class, |
|
1177 | - ), |
|
1178 | - )); |
|
1179 | - } |
|
1180 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1181 | - 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1182 | - ) { |
|
1183 | - //Events View Today |
|
1184 | - $admin_bar->add_menu(array( |
|
1185 | - 'id' => 'espresso-toolbar-events-today', |
|
1186 | - 'parent' => 'espresso-toolbar-events-view', |
|
1187 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
1188 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1189 | - $events_admin_url), |
|
1190 | - 'meta' => array( |
|
1191 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
1192 | - 'target' => '', |
|
1193 | - 'class' => $menu_class, |
|
1194 | - ), |
|
1195 | - )); |
|
1196 | - } |
|
1197 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1198 | - 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1199 | - ) { |
|
1200 | - //Events View This Month |
|
1201 | - $admin_bar->add_menu(array( |
|
1202 | - 'id' => 'espresso-toolbar-events-month', |
|
1203 | - 'parent' => 'espresso-toolbar-events-view', |
|
1204 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
1205 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1206 | - $events_admin_url), |
|
1207 | - 'meta' => array( |
|
1208 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
1209 | - 'target' => '', |
|
1210 | - 'class' => $menu_class, |
|
1211 | - ), |
|
1212 | - )); |
|
1213 | - } |
|
1214 | - //Registration Overview |
|
1215 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1216 | - 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1217 | - ) { |
|
1218 | - $admin_bar->add_menu(array( |
|
1219 | - 'id' => 'espresso-toolbar-registrations', |
|
1220 | - 'parent' => 'espresso-toolbar', |
|
1221 | - 'title' => esc_html__('Registrations', 'event_espresso'), |
|
1222 | - 'href' => $reg_admin_url, |
|
1223 | - 'meta' => array( |
|
1224 | - 'title' => esc_html__('Registrations', 'event_espresso'), |
|
1225 | - 'target' => '', |
|
1226 | - 'class' => $menu_class, |
|
1227 | - ), |
|
1228 | - )); |
|
1229 | - } |
|
1230 | - //Registration Overview Today |
|
1231 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1232 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1233 | - ) { |
|
1234 | - $admin_bar->add_menu(array( |
|
1235 | - 'id' => 'espresso-toolbar-registrations-today', |
|
1236 | - 'parent' => 'espresso-toolbar-registrations', |
|
1237 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
1238 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1239 | - $reg_admin_url), |
|
1240 | - 'meta' => array( |
|
1241 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
1242 | - 'target' => '', |
|
1243 | - 'class' => $menu_class, |
|
1244 | - ), |
|
1245 | - )); |
|
1246 | - } |
|
1247 | - //Registration Overview Today Completed |
|
1248 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1249 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1250 | - ) { |
|
1251 | - $admin_bar->add_menu(array( |
|
1252 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1253 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1254 | - 'title' => esc_html__('Approved', 'event_espresso'), |
|
1255 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1256 | - 'action' => 'default', |
|
1257 | - 'status' => 'today', |
|
1258 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1259 | - ), $reg_admin_url), |
|
1260 | - 'meta' => array( |
|
1261 | - 'title' => esc_html__('Approved', 'event_espresso'), |
|
1262 | - 'target' => '', |
|
1263 | - 'class' => $menu_class, |
|
1264 | - ), |
|
1265 | - )); |
|
1266 | - } |
|
1267 | - //Registration Overview Today Pending\ |
|
1268 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1269 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1270 | - ) { |
|
1271 | - $admin_bar->add_menu(array( |
|
1272 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1273 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1274 | - 'title' => esc_html__('Pending', 'event_espresso'), |
|
1275 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1276 | - 'action' => 'default', |
|
1277 | - 'status' => 'today', |
|
1278 | - 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1279 | - ), $reg_admin_url), |
|
1280 | - 'meta' => array( |
|
1281 | - 'title' => esc_html__('Pending Payment', 'event_espresso'), |
|
1282 | - 'target' => '', |
|
1283 | - 'class' => $menu_class, |
|
1284 | - ), |
|
1285 | - )); |
|
1286 | - } |
|
1287 | - //Registration Overview Today Incomplete |
|
1288 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1289 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1290 | - ) { |
|
1291 | - $admin_bar->add_menu(array( |
|
1292 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1293 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1294 | - 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1295 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1296 | - 'action' => 'default', |
|
1297 | - 'status' => 'today', |
|
1298 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1299 | - ), $reg_admin_url), |
|
1300 | - 'meta' => array( |
|
1301 | - 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1302 | - 'target' => '', |
|
1303 | - 'class' => $menu_class, |
|
1304 | - ), |
|
1305 | - )); |
|
1306 | - } |
|
1307 | - //Registration Overview Today Incomplete |
|
1308 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1309 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1310 | - ) { |
|
1311 | - $admin_bar->add_menu(array( |
|
1312 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1313 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1314 | - 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1315 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1316 | - 'action' => 'default', |
|
1317 | - 'status' => 'today', |
|
1318 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1319 | - ), $reg_admin_url), |
|
1320 | - 'meta' => array( |
|
1321 | - 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1322 | - 'target' => '', |
|
1323 | - 'class' => $menu_class, |
|
1324 | - ), |
|
1325 | - )); |
|
1326 | - } |
|
1327 | - //Registration Overview This Month |
|
1328 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1329 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1330 | - ) { |
|
1331 | - $admin_bar->add_menu(array( |
|
1332 | - 'id' => 'espresso-toolbar-registrations-month', |
|
1333 | - 'parent' => 'espresso-toolbar-registrations', |
|
1334 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
1335 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1336 | - $reg_admin_url), |
|
1337 | - 'meta' => array( |
|
1338 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
1339 | - 'target' => '', |
|
1340 | - 'class' => $menu_class, |
|
1341 | - ), |
|
1342 | - )); |
|
1343 | - } |
|
1344 | - //Registration Overview This Month Approved |
|
1345 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1346 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1347 | - ) { |
|
1348 | - $admin_bar->add_menu(array( |
|
1349 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1350 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1351 | - 'title' => esc_html__('Approved', 'event_espresso'), |
|
1352 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1353 | - 'action' => 'default', |
|
1354 | - 'status' => 'month', |
|
1355 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1356 | - ), $reg_admin_url), |
|
1357 | - 'meta' => array( |
|
1358 | - 'title' => esc_html__('Approved', 'event_espresso'), |
|
1359 | - 'target' => '', |
|
1360 | - 'class' => $menu_class, |
|
1361 | - ), |
|
1362 | - )); |
|
1363 | - } |
|
1364 | - //Registration Overview This Month Pending |
|
1365 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1366 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1367 | - ) { |
|
1368 | - $admin_bar->add_menu(array( |
|
1369 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1370 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1371 | - 'title' => esc_html__('Pending', 'event_espresso'), |
|
1372 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1373 | - 'action' => 'default', |
|
1374 | - 'status' => 'month', |
|
1375 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1376 | - ), $reg_admin_url), |
|
1377 | - 'meta' => array( |
|
1378 | - 'title' => esc_html__('Pending', 'event_espresso'), |
|
1379 | - 'target' => '', |
|
1380 | - 'class' => $menu_class, |
|
1381 | - ), |
|
1382 | - )); |
|
1383 | - } |
|
1384 | - //Registration Overview This Month Not Approved |
|
1385 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1386 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1387 | - ) { |
|
1388 | - $admin_bar->add_menu(array( |
|
1389 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1390 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1391 | - 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1392 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1393 | - 'action' => 'default', |
|
1394 | - 'status' => 'month', |
|
1395 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1396 | - ), $reg_admin_url), |
|
1397 | - 'meta' => array( |
|
1398 | - 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1399 | - 'target' => '', |
|
1400 | - 'class' => $menu_class, |
|
1401 | - ), |
|
1402 | - )); |
|
1403 | - } |
|
1404 | - //Registration Overview This Month Cancelled |
|
1405 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1406 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1407 | - ) { |
|
1408 | - $admin_bar->add_menu(array( |
|
1409 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1410 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1411 | - 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1412 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1413 | - 'action' => 'default', |
|
1414 | - 'status' => 'month', |
|
1415 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1416 | - ), $reg_admin_url), |
|
1417 | - 'meta' => array( |
|
1418 | - 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1419 | - 'target' => '', |
|
1420 | - 'class' => $menu_class, |
|
1421 | - ), |
|
1422 | - )); |
|
1423 | - } |
|
1424 | - //Extensions & Services |
|
1425 | - if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1426 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1427 | - ) { |
|
1428 | - $admin_bar->add_menu(array( |
|
1429 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
1430 | - 'parent' => 'espresso-toolbar', |
|
1431 | - 'title' => esc_html__('Extensions & Services', 'event_espresso'), |
|
1432 | - 'href' => $extensions_admin_url, |
|
1433 | - 'meta' => array( |
|
1434 | - 'title' => esc_html__('Extensions & Services', 'event_espresso'), |
|
1435 | - 'target' => '', |
|
1436 | - 'class' => $menu_class, |
|
1437 | - ), |
|
1438 | - )); |
|
1439 | - } |
|
1440 | - } |
|
1441 | - |
|
1442 | - |
|
1443 | - |
|
1444 | - /** |
|
1445 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1446 | - * never returned with the function. |
|
1447 | - * |
|
1448 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1449 | - * @return array |
|
1450 | - */ |
|
1451 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1452 | - { |
|
1453 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1454 | - } |
|
24 | + /** |
|
25 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
26 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
27 | + */ |
|
28 | + const req_type_normal = 0; |
|
29 | + |
|
30 | + /** |
|
31 | + * Indicates this is a brand new installation of EE so we should install |
|
32 | + * tables and default data etc |
|
33 | + */ |
|
34 | + const req_type_new_activation = 1; |
|
35 | + |
|
36 | + /** |
|
37 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
38 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
39 | + * and that default data is setup too |
|
40 | + */ |
|
41 | + const req_type_reactivation = 2; |
|
42 | + |
|
43 | + /** |
|
44 | + * indicates that EE has been upgraded since its previous request. |
|
45 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
46 | + */ |
|
47 | + const req_type_upgrade = 3; |
|
48 | + |
|
49 | + /** |
|
50 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
51 | + */ |
|
52 | + const req_type_downgrade = 4; |
|
53 | + |
|
54 | + /** |
|
55 | + * @deprecated since version 4.6.0.dev.006 |
|
56 | + * Now whenever a new_activation is detected the request type is still just |
|
57 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
58 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
59 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
60 | + * (Specifically, when the migration manager indicates migrations are finished |
|
61 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
62 | + */ |
|
63 | + const req_type_activation_but_not_installed = 5; |
|
64 | + |
|
65 | + /** |
|
66 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
67 | + */ |
|
68 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * instance of the EE_System object |
|
73 | + * |
|
74 | + * @var $_instance |
|
75 | + * @access private |
|
76 | + */ |
|
77 | + private static $_instance = null; |
|
78 | + |
|
79 | + /** |
|
80 | + * @type EE_Registry $Registry |
|
81 | + * @access protected |
|
82 | + */ |
|
83 | + protected $registry; |
|
84 | + |
|
85 | + /** |
|
86 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
87 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
88 | + * |
|
89 | + * @var int |
|
90 | + */ |
|
91 | + private $_req_type; |
|
92 | + |
|
93 | + /** |
|
94 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
95 | + * |
|
96 | + * @var boolean |
|
97 | + */ |
|
98 | + private $_major_version_change = false; |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @singleton method used to instantiate class object |
|
104 | + * @access public |
|
105 | + * @param \EE_Registry $Registry |
|
106 | + * @return \EE_System |
|
107 | + */ |
|
108 | + public static function instance(EE_Registry $Registry = null) |
|
109 | + { |
|
110 | + // check if class object is instantiated |
|
111 | + if ( ! self::$_instance instanceof EE_System) { |
|
112 | + self::$_instance = new self($Registry); |
|
113 | + } |
|
114 | + return self::$_instance; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * resets the instance and returns it |
|
121 | + * |
|
122 | + * @return EE_System |
|
123 | + */ |
|
124 | + public static function reset() |
|
125 | + { |
|
126 | + self::$_instance->_req_type = null; |
|
127 | + //make sure none of the old hooks are left hanging around |
|
128 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
129 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
130 | + EE_Data_Migration_Manager::reset(); |
|
131 | + self::instance()->detect_activations_or_upgrades(); |
|
132 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
133 | + return self::instance(); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * sets hooks for running rest of system |
|
140 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
141 | + * starting EE Addons from any other point may lead to problems |
|
142 | + * |
|
143 | + * @access private |
|
144 | + * @param \EE_Registry $Registry |
|
145 | + */ |
|
146 | + private function __construct(EE_Registry $Registry) |
|
147 | + { |
|
148 | + $this->registry = $Registry; |
|
149 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
150 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
151 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
152 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
153 | + // because the newly-activated addon didn't get a chance to run at all |
|
154 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
155 | + // detect whether install or upgrade |
|
156 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
157 | + 3); |
|
158 | + // load EE_Config, EE_Textdomain, etc |
|
159 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
160 | + // load EE_Config, EE_Textdomain, etc |
|
161 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
162 | + array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
163 | + // you wanna get going? I wanna get going... let's get going! |
|
164 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
165 | + //other housekeeping |
|
166 | + //exclude EE critical pages from wp_list_pages |
|
167 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
168 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
169 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when |
|
170 | + // the EE_Config loads |
|
171 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * load_espresso_addons |
|
177 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
178 | + * this is hooked into both: |
|
179 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
180 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
181 | + * and the WP 'activate_plugin' hookpoint |
|
182 | + * |
|
183 | + * @access public |
|
184 | + * @return void |
|
185 | + * @throws EE_Error |
|
186 | + * @throws \EventEspresso\core\exceptions\InvalidExecutionPathException |
|
187 | + */ |
|
188 | + public function load_espresso_addons() |
|
189 | + { |
|
190 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
191 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
192 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
193 | + //load and setup EE_Capabilities |
|
194 | + $this->registry->load_core('Capabilities'); |
|
195 | + |
|
196 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
197 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
198 | + //We want it for mobile apps. Just include the entire plugin |
|
199 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
200 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
201 | + //and causes a fatal error |
|
202 | + if ( ! function_exists('json_basic_auth_handler') |
|
203 | + && ! function_exists('json_basic_auth_error') |
|
204 | + && ! ( |
|
205 | + isset($_GET['action']) |
|
206 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
207 | + ) |
|
208 | + && ! ( |
|
209 | + isset($_GET['activate']) |
|
210 | + && $_GET['activate'] === 'true' |
|
211 | + ) |
|
212 | + ) { |
|
213 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
214 | + } |
|
215 | + $this->_maybe_brew_regular(); |
|
216 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
217 | + $this->registry->CAP->init_caps(); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * detect_activations_or_upgrades |
|
224 | + * Checks for activation or upgrade of core first; |
|
225 | + * then also checks if any registered addons have been activated or upgraded |
|
226 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
227 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
228 | + * |
|
229 | + * @access public |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function detect_activations_or_upgrades() |
|
233 | + { |
|
234 | + //first off: let's make sure to handle core |
|
235 | + $this->detect_if_activation_or_upgrade(); |
|
236 | + foreach ($this->registry->addons as $addon) { |
|
237 | + //detect teh request type for that addon |
|
238 | + $addon->detect_activation_or_upgrade(); |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * detect_if_activation_or_upgrade |
|
246 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
247 | + * and either setting up the DB or setting up maintenance mode etc. |
|
248 | + * |
|
249 | + * @access public |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + public function detect_if_activation_or_upgrade() |
|
253 | + { |
|
254 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
255 | + // load M-Mode class |
|
256 | + $this->registry->load_core('Maintenance_Mode'); |
|
257 | + // check if db has been updated, or if its a brand-new installation |
|
258 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
259 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
260 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
261 | + switch ($request_type) { |
|
262 | + case EE_System::req_type_new_activation: |
|
263 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
264 | + $this->_handle_core_version_change($espresso_db_update); |
|
265 | + break; |
|
266 | + case EE_System::req_type_reactivation: |
|
267 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
268 | + $this->_handle_core_version_change($espresso_db_update); |
|
269 | + break; |
|
270 | + case EE_System::req_type_upgrade: |
|
271 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
272 | + //migrations may be required now that we've upgraded |
|
273 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
274 | + $this->_handle_core_version_change($espresso_db_update); |
|
275 | + // echo "done upgrade";die; |
|
276 | + break; |
|
277 | + case EE_System::req_type_downgrade: |
|
278 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
279 | + //its possible migrations are no longer required |
|
280 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
281 | + $this->_handle_core_version_change($espresso_db_update); |
|
282 | + break; |
|
283 | + case EE_System::req_type_normal: |
|
284 | + default: |
|
285 | + // $this->_maybe_redirect_to_ee_about(); |
|
286 | + break; |
|
287 | + } |
|
288 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Updates the list of installed versions and sets hooks for |
|
295 | + * initializing the database later during the request |
|
296 | + * |
|
297 | + * @param array $espresso_db_update |
|
298 | + */ |
|
299 | + protected function _handle_core_version_change($espresso_db_update) |
|
300 | + { |
|
301 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
302 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
303 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
304 | + array($this, 'initialize_db_if_no_migrations_required')); |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
311 | + * information about what versions of EE have been installed and activated, |
|
312 | + * NOT necessarily the state of the database |
|
313 | + * |
|
314 | + * @param null $espresso_db_update |
|
315 | + * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
316 | + * from the options table |
|
317 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
318 | + */ |
|
319 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
320 | + { |
|
321 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
322 | + if ( ! $espresso_db_update) { |
|
323 | + $espresso_db_update = get_option('espresso_db_update'); |
|
324 | + } |
|
325 | + // check that option is an array |
|
326 | + if ( ! is_array($espresso_db_update)) { |
|
327 | + // if option is FALSE, then it never existed |
|
328 | + if ($espresso_db_update === false) { |
|
329 | + // make $espresso_db_update an array and save option with autoload OFF |
|
330 | + $espresso_db_update = array(); |
|
331 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
332 | + } else { |
|
333 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
334 | + $espresso_db_update = array($espresso_db_update => array()); |
|
335 | + update_option('espresso_db_update', $espresso_db_update); |
|
336 | + } |
|
337 | + } else { |
|
338 | + $corrected_db_update = array(); |
|
339 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
340 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
341 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
342 | + //the key is an int, and the value IS NOT an array |
|
343 | + //so it must be numerically-indexed, where values are versions installed... |
|
344 | + //fix it! |
|
345 | + $version_string = $should_be_array; |
|
346 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
347 | + } else { |
|
348 | + //ok it checks out |
|
349 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
350 | + } |
|
351 | + } |
|
352 | + $espresso_db_update = $corrected_db_update; |
|
353 | + update_option('espresso_db_update', $espresso_db_update); |
|
354 | + } |
|
355 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
356 | + return $espresso_db_update; |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
362 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
363 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
364 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
365 | + * so that it will be done when migrations are finished |
|
366 | + * |
|
367 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
368 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
369 | + * This is a resource-intensive job |
|
370 | + * so we prefer to only do it when necessary |
|
371 | + * @return void |
|
372 | + * @throws EE_Error |
|
373 | + */ |
|
374 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
375 | + { |
|
376 | + $request_type = $this->detect_req_type(); |
|
377 | + //only initialize system if we're not in maintenance mode. |
|
378 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
379 | + update_option('ee_flush_rewrite_rules', true); |
|
380 | + if ($verify_schema) { |
|
381 | + EEH_Activation::initialize_db_and_folders(); |
|
382 | + } |
|
383 | + EEH_Activation::initialize_db_content(); |
|
384 | + EEH_Activation::system_initialization(); |
|
385 | + if ($initialize_addons_too) { |
|
386 | + $this->initialize_addons(); |
|
387 | + } |
|
388 | + } else { |
|
389 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
390 | + } |
|
391 | + if ($request_type === EE_System::req_type_new_activation |
|
392 | + || $request_type === EE_System::req_type_reactivation |
|
393 | + || ( |
|
394 | + $request_type === EE_System::req_type_upgrade |
|
395 | + && $this->is_major_version_change() |
|
396 | + ) |
|
397 | + ) { |
|
398 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * Initializes the db for all registered addons |
|
406 | + */ |
|
407 | + public function initialize_addons() |
|
408 | + { |
|
409 | + //foreach registered addon, make sure its db is up-to-date too |
|
410 | + foreach ($this->registry->addons as $addon) { |
|
411 | + $addon->initialize_db_if_no_migrations_required(); |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
419 | + * |
|
420 | + * @param array $version_history |
|
421 | + * @param string $current_version_to_add version to be added to the version history |
|
422 | + * @return boolean success as to whether or not this option was changed |
|
423 | + */ |
|
424 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
425 | + { |
|
426 | + if ( ! $version_history) { |
|
427 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
428 | + } |
|
429 | + if ($current_version_to_add == null) { |
|
430 | + $current_version_to_add = espresso_version(); |
|
431 | + } |
|
432 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
433 | + // re-save |
|
434 | + return update_option('espresso_db_update', $version_history); |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Detects if the current version indicated in the has existed in the list of |
|
441 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
442 | + * |
|
443 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
444 | + * If not supplied, fetches it from the options table. |
|
445 | + * Also, caches its result so later parts of the code can also know whether |
|
446 | + * there's been an update or not. This way we can add the current version to |
|
447 | + * espresso_db_update, but still know if this is a new install or not |
|
448 | + * @return int one of the constants on EE_System::req_type_ |
|
449 | + */ |
|
450 | + public function detect_req_type($espresso_db_update = null) |
|
451 | + { |
|
452 | + if ($this->_req_type === null) { |
|
453 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
454 | + : $this->fix_espresso_db_upgrade_option(); |
|
455 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
456 | + 'ee_espresso_activation', espresso_version()); |
|
457 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
458 | + } |
|
459 | + return $this->_req_type; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
466 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
467 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
468 | + * |
|
469 | + * @param $activation_history |
|
470 | + * @return bool |
|
471 | + */ |
|
472 | + protected function _detect_major_version_change($activation_history) |
|
473 | + { |
|
474 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
475 | + $previous_version_parts = explode('.', $previous_version); |
|
476 | + $current_version_parts = explode('.', espresso_version()); |
|
477 | + return isset( |
|
478 | + $previous_version_parts[0], |
|
479 | + $previous_version_parts[1], |
|
480 | + $current_version_parts[0], |
|
481 | + $current_version_parts[1] |
|
482 | + ) |
|
483 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
484 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
485 | + ); |
|
486 | + } |
|
487 | + |
|
488 | + |
|
489 | + |
|
490 | + /** |
|
491 | + * Returns true if either the major or minor version of EE changed during this request. |
|
492 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
493 | + * |
|
494 | + * @return bool |
|
495 | + */ |
|
496 | + public function is_major_version_change() |
|
497 | + { |
|
498 | + return $this->_major_version_change; |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
505 | + * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
506 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
507 | + * just activated to (for core that will always be espresso_version()) |
|
508 | + * |
|
509 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
510 | + * ee plugin. for core that's 'espresso_db_update' |
|
511 | + * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
512 | + * indicate that this plugin was just activated |
|
513 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
514 | + * espresso_version()) |
|
515 | + * @return int one of the constants on EE_System::req_type_* |
|
516 | + */ |
|
517 | + public static function detect_req_type_given_activation_history( |
|
518 | + $activation_history_for_addon, |
|
519 | + $activation_indicator_option_name, |
|
520 | + $version_to_upgrade_to |
|
521 | + ) { |
|
522 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
523 | + if ($activation_history_for_addon) { |
|
524 | + //it exists, so this isn't a completely new install |
|
525 | + //check if this version already in that list of previously installed versions |
|
526 | + if (! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
527 | + //it a version we haven't seen before |
|
528 | + if ($version_is_higher === 1) { |
|
529 | + $req_type = EE_System::req_type_upgrade; |
|
530 | + } else { |
|
531 | + $req_type = EE_System::req_type_downgrade; |
|
532 | + } |
|
533 | + delete_option($activation_indicator_option_name); |
|
534 | + } else { |
|
535 | + // its not an update. maybe a reactivation? |
|
536 | + if (get_option($activation_indicator_option_name, false)) { |
|
537 | + if ($version_is_higher === -1) { |
|
538 | + $req_type = EE_System::req_type_downgrade; |
|
539 | + } elseif ($version_is_higher === 0) { |
|
540 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
541 | + $req_type = EE_System::req_type_reactivation; |
|
542 | + } else {//$version_is_higher === 1 |
|
543 | + $req_type = EE_System::req_type_upgrade; |
|
544 | + } |
|
545 | + delete_option($activation_indicator_option_name); |
|
546 | + } else { |
|
547 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
548 | + if ($version_is_higher === -1) { |
|
549 | + $req_type = EE_System::req_type_downgrade; |
|
550 | + } elseif ($version_is_higher === 0) { |
|
551 | + //we've seen this version before and it's not an activation. its normal request |
|
552 | + $req_type = EE_System::req_type_normal; |
|
553 | + } else {//$version_is_higher === 1 |
|
554 | + $req_type = EE_System::req_type_upgrade; |
|
555 | + } |
|
556 | + } |
|
557 | + } |
|
558 | + } else { |
|
559 | + //brand new install |
|
560 | + $req_type = EE_System::req_type_new_activation; |
|
561 | + delete_option($activation_indicator_option_name); |
|
562 | + } |
|
563 | + return $req_type; |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
570 | + * the $activation_history_for_addon |
|
571 | + * |
|
572 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
573 | + * sometimes containing 'unknown-date' |
|
574 | + * @param string $version_to_upgrade_to (current version) |
|
575 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
576 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
577 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
578 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
579 | + */ |
|
580 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
581 | + { |
|
582 | + //find the most recently-activated version |
|
583 | + $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history( |
|
584 | + $activation_history_for_addon |
|
585 | + ); |
|
586 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + |
|
591 | + /** |
|
592 | + * Gets the most recently active version listed in the activation history, |
|
593 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
594 | + * |
|
595 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
596 | + * sometimes containing 'unknown-date' |
|
597 | + * @return string |
|
598 | + */ |
|
599 | + protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
600 | + { |
|
601 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
602 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
603 | + if (is_array($activation_history)) { |
|
604 | + foreach ($activation_history as $version => $times_activated) { |
|
605 | + //check there is a record of when this version was activated. Otherwise, |
|
606 | + //mark it as unknown |
|
607 | + if (! $times_activated) { |
|
608 | + $times_activated = array('unknown-date'); |
|
609 | + } |
|
610 | + if (is_string($times_activated)) { |
|
611 | + $times_activated = array($times_activated); |
|
612 | + } |
|
613 | + foreach ($times_activated as $an_activation) { |
|
614 | + if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
615 | + $most_recently_active_version = $version; |
|
616 | + $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
617 | + ? '1970-01-01 00:00:00' : $an_activation; |
|
618 | + } |
|
619 | + } |
|
620 | + } |
|
621 | + } |
|
622 | + return $most_recently_active_version; |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * This redirects to the about EE page after activation |
|
629 | + * |
|
630 | + * @return void |
|
631 | + */ |
|
632 | + public function redirect_to_about_ee() |
|
633 | + { |
|
634 | + $notices = EE_Error::get_notices(false); |
|
635 | + //if current user is an admin and it's not an ajax or rest request |
|
636 | + if (! (defined('DOING_AJAX') && DOING_AJAX) |
|
637 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
638 | + && ! isset($notices['errors']) |
|
639 | + && apply_filters( |
|
640 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
641 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
642 | + ) |
|
643 | + ) { |
|
644 | + $query_params = array('page' => 'espresso_about'); |
|
645 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
646 | + $query_params['new_activation'] = true; |
|
647 | + } |
|
648 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
649 | + $query_params['reactivation'] = true; |
|
650 | + } |
|
651 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
652 | + wp_safe_redirect($url); |
|
653 | + exit(); |
|
654 | + } |
|
655 | + } |
|
656 | + |
|
657 | + |
|
658 | + |
|
659 | + /** |
|
660 | + * load_core_configuration |
|
661 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
662 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
663 | + * |
|
664 | + * @return void |
|
665 | + */ |
|
666 | + public function load_core_configuration() |
|
667 | + { |
|
668 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
669 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
670 | + //load textdomain |
|
671 | + EE_Load_Textdomain::load_textdomain(); |
|
672 | + // load and setup EE_Config and EE_Network_Config |
|
673 | + $this->registry->load_core('Config'); |
|
674 | + $this->registry->load_core('Network_Config'); |
|
675 | + // setup autoloaders |
|
676 | + // enable logging? |
|
677 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
678 | + $this->registry->load_core('Log'); |
|
679 | + } |
|
680 | + // check for activation errors |
|
681 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
682 | + if ($activation_errors) { |
|
683 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
684 | + update_option('ee_plugin_activation_errors', false); |
|
685 | + } |
|
686 | + // get model names |
|
687 | + $this->_parse_model_names(); |
|
688 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
695 | + * |
|
696 | + * @return void |
|
697 | + */ |
|
698 | + private function _parse_model_names() |
|
699 | + { |
|
700 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
701 | + $models = glob(EE_MODELS . '*.model.php'); |
|
702 | + $model_names = array(); |
|
703 | + $non_abstract_db_models = array(); |
|
704 | + foreach ($models as $model) { |
|
705 | + // get model classname |
|
706 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
707 | + $short_name = str_replace('EEM_', '', $classname); |
|
708 | + $reflectionClass = new ReflectionClass($classname); |
|
709 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
710 | + $non_abstract_db_models[$short_name] = $classname; |
|
711 | + } |
|
712 | + $model_names[$short_name] = $classname; |
|
713 | + } |
|
714 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
715 | + $this->registry->non_abstract_db_models = apply_filters( |
|
716 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
717 | + $non_abstract_db_models |
|
718 | + ); |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + |
|
723 | + /** |
|
724 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
725 | + * that need to be setup before our EE_System launches. |
|
726 | + * |
|
727 | + * @return void |
|
728 | + */ |
|
729 | + private function _maybe_brew_regular() |
|
730 | + { |
|
731 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
732 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
733 | + } |
|
734 | + } |
|
735 | + |
|
736 | + |
|
737 | + |
|
738 | + /** |
|
739 | + * register_shortcodes_modules_and_widgets |
|
740 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
741 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
742 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
743 | + * |
|
744 | + * @access public |
|
745 | + * @return void |
|
746 | + */ |
|
747 | + public function register_shortcodes_modules_and_widgets() |
|
748 | + { |
|
749 | + try { |
|
750 | + // load, register, and add shortcodes the new way |
|
751 | + new ShortcodesManager( |
|
752 | + // and the old way, but we'll put it under control of the new system |
|
753 | + EE_Config::getLegacyShortcodesManager() |
|
754 | + ); |
|
755 | + } catch (Exception $exception) { |
|
756 | + new ExceptionStackTraceDisplay($exception); |
|
757 | + } |
|
758 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
759 | + // check for addons using old hookpoint |
|
760 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
761 | + $this->_incompatible_addon_error(); |
|
762 | + } |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + |
|
767 | + /** |
|
768 | + * _incompatible_addon_error |
|
769 | + * |
|
770 | + * @access public |
|
771 | + * @return void |
|
772 | + */ |
|
773 | + private function _incompatible_addon_error() |
|
774 | + { |
|
775 | + // get array of classes hooking into here |
|
776 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
777 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
778 | + ); |
|
779 | + if (! empty($class_names)) { |
|
780 | + $msg = esc_html__( |
|
781 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
782 | + 'event_espresso' |
|
783 | + ); |
|
784 | + $msg .= '<ul>'; |
|
785 | + foreach ($class_names as $class_name) { |
|
786 | + $msg .= '<li><b>Event Espresso - ' |
|
787 | + . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name) |
|
788 | + . '</b></li>'; |
|
789 | + } |
|
790 | + $msg .= '</ul>'; |
|
791 | + $msg .= esc_html__( |
|
792 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
793 | + 'event_espresso' |
|
794 | + ); |
|
795 | + // save list of incompatible addons to wp-options for later use |
|
796 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
797 | + if (is_admin()) { |
|
798 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
799 | + } |
|
800 | + } |
|
801 | + } |
|
802 | + |
|
803 | + |
|
804 | + |
|
805 | + /** |
|
806 | + * brew_espresso |
|
807 | + * begins the process of setting hooks for initializing EE in the correct order |
|
808 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
809 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
810 | + * |
|
811 | + * @return void |
|
812 | + */ |
|
813 | + public function brew_espresso() |
|
814 | + { |
|
815 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
816 | + // load some final core systems |
|
817 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
818 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
819 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
820 | + add_action('init', array($this, 'load_controllers'), 7); |
|
821 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
822 | + add_action('init', array($this, 'initialize'), 10); |
|
823 | + add_action('init', array($this, 'initialize_last'), 100); |
|
824 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
825 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
826 | + // pew pew pew |
|
827 | + $this->registry->load_core('PUE'); |
|
828 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
829 | + } |
|
830 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + |
|
835 | + /** |
|
836 | + * set_hooks_for_core |
|
837 | + * |
|
838 | + * @access public |
|
839 | + * @return void |
|
840 | + */ |
|
841 | + public function set_hooks_for_core() |
|
842 | + { |
|
843 | + $this->_deactivate_incompatible_addons(); |
|
844 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
845 | + } |
|
846 | + |
|
847 | + |
|
848 | + |
|
849 | + /** |
|
850 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
851 | + * deactivates any addons considered incompatible with the current version of EE |
|
852 | + */ |
|
853 | + private function _deactivate_incompatible_addons() |
|
854 | + { |
|
855 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
856 | + if (! empty($incompatible_addons)) { |
|
857 | + $active_plugins = get_option('active_plugins', array()); |
|
858 | + foreach ($active_plugins as $active_plugin) { |
|
859 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
860 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
861 | + unset($_GET['activate']); |
|
862 | + espresso_deactivate_plugin($active_plugin); |
|
863 | + } |
|
864 | + } |
|
865 | + } |
|
866 | + } |
|
867 | + } |
|
868 | + |
|
869 | + |
|
870 | + |
|
871 | + /** |
|
872 | + * perform_activations_upgrades_and_migrations |
|
873 | + * |
|
874 | + * @access public |
|
875 | + * @return void |
|
876 | + */ |
|
877 | + public function perform_activations_upgrades_and_migrations() |
|
878 | + { |
|
879 | + //first check if we had previously attempted to setup EE's directories but failed |
|
880 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
881 | + EEH_Activation::create_upload_directories(); |
|
882 | + } |
|
883 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
884 | + } |
|
885 | + |
|
886 | + |
|
887 | + |
|
888 | + /** |
|
889 | + * load_CPTs_and_session |
|
890 | + * |
|
891 | + * @access public |
|
892 | + * @return void |
|
893 | + */ |
|
894 | + public function load_CPTs_and_session() |
|
895 | + { |
|
896 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
897 | + // register Custom Post Types |
|
898 | + $this->registry->load_core('Register_CPTs'); |
|
899 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * load_controllers |
|
906 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
907 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
908 | + * time |
|
909 | + * |
|
910 | + * @access public |
|
911 | + * @return void |
|
912 | + */ |
|
913 | + public function load_controllers() |
|
914 | + { |
|
915 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
916 | + // let's get it started |
|
917 | + if (! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
918 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
919 | + $this->registry->load_core('Front_Controller'); |
|
920 | + } elseif (! EE_FRONT_AJAX) { |
|
921 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
922 | + EE_Registry::instance()->load_core('Admin'); |
|
923 | + } |
|
924 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
925 | + } |
|
926 | + |
|
927 | + |
|
928 | + |
|
929 | + /** |
|
930 | + * core_loaded_and_ready |
|
931 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
932 | + * |
|
933 | + * @access public |
|
934 | + * @return void |
|
935 | + */ |
|
936 | + public function core_loaded_and_ready() |
|
937 | + { |
|
938 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
939 | + // load_espresso_template_tags |
|
940 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
941 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
942 | + } |
|
943 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
944 | + $this->registry->load_core('Session'); |
|
945 | + $this->registry->create('EventEspresso\core\services\assets\Registry'); |
|
946 | + wp_enqueue_script('espresso_core'); |
|
947 | + } |
|
948 | + |
|
949 | + |
|
950 | + |
|
951 | + /** |
|
952 | + * initialize |
|
953 | + * this is the best place to begin initializing client code |
|
954 | + * |
|
955 | + * @access public |
|
956 | + * @return void |
|
957 | + */ |
|
958 | + public function initialize() |
|
959 | + { |
|
960 | + do_action('AHEE__EE_System__initialize'); |
|
961 | + } |
|
962 | + |
|
963 | + |
|
964 | + |
|
965 | + /** |
|
966 | + * initialize_last |
|
967 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
968 | + * initialize has done so |
|
969 | + * |
|
970 | + * @access public |
|
971 | + * @return void |
|
972 | + */ |
|
973 | + public function initialize_last() |
|
974 | + { |
|
975 | + do_action('AHEE__EE_System__initialize_last'); |
|
976 | + } |
|
977 | + |
|
978 | + |
|
979 | + |
|
980 | + /** |
|
981 | + * set_hooks_for_shortcodes_modules_and_addons |
|
982 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
983 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
984 | + * |
|
985 | + * @access public |
|
986 | + * @return void |
|
987 | + */ |
|
988 | + public function set_hooks_for_shortcodes_modules_and_addons() |
|
989 | + { |
|
990 | + // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
991 | + } |
|
992 | + |
|
993 | + |
|
994 | + |
|
995 | + /** |
|
996 | + * do_not_cache |
|
997 | + * sets no cache headers and defines no cache constants for WP plugins |
|
998 | + * |
|
999 | + * @access public |
|
1000 | + * @return void |
|
1001 | + */ |
|
1002 | + public static function do_not_cache() |
|
1003 | + { |
|
1004 | + // set no cache constants |
|
1005 | + if (! defined('DONOTCACHEPAGE')) { |
|
1006 | + define('DONOTCACHEPAGE', true); |
|
1007 | + } |
|
1008 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
1009 | + define('DONOTCACHCEOBJECT', true); |
|
1010 | + } |
|
1011 | + if (! defined('DONOTCACHEDB')) { |
|
1012 | + define('DONOTCACHEDB', true); |
|
1013 | + } |
|
1014 | + // add no cache headers |
|
1015 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1016 | + // plus a little extra for nginx and Google Chrome |
|
1017 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1018 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes |
|
1019 | + // with the registration process |
|
1020 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1021 | + } |
|
1022 | + |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * extra_nocache_headers |
|
1027 | + * |
|
1028 | + * @access public |
|
1029 | + * @param $headers |
|
1030 | + * @return array |
|
1031 | + */ |
|
1032 | + public static function extra_nocache_headers($headers) |
|
1033 | + { |
|
1034 | + // for NGINX |
|
1035 | + $headers['X-Accel-Expires'] = 0; |
|
1036 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1037 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1038 | + return $headers; |
|
1039 | + } |
|
1040 | + |
|
1041 | + |
|
1042 | + |
|
1043 | + /** |
|
1044 | + * nocache_headers |
|
1045 | + * |
|
1046 | + * @access public |
|
1047 | + * @return void |
|
1048 | + */ |
|
1049 | + public static function nocache_headers() |
|
1050 | + { |
|
1051 | + nocache_headers(); |
|
1052 | + } |
|
1053 | + |
|
1054 | + |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * espresso_toolbar_items |
|
1058 | + * |
|
1059 | + * @access public |
|
1060 | + * @param WP_Admin_Bar $admin_bar |
|
1061 | + * @return void |
|
1062 | + */ |
|
1063 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1064 | + { |
|
1065 | + // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1066 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1067 | + || defined('DOING_AJAX') |
|
1068 | + || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1069 | + ) { |
|
1070 | + return; |
|
1071 | + } |
|
1072 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1073 | + $menu_class = 'espresso_menu_item_class'; |
|
1074 | + //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1075 | + //because they're only defined in each of their respective constructors |
|
1076 | + //and this might be a frontend request, in which case they aren't available |
|
1077 | + $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1078 | + $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1079 | + $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1080 | + //Top Level |
|
1081 | + $admin_bar->add_menu(array( |
|
1082 | + 'id' => 'espresso-toolbar', |
|
1083 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1084 | + . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1085 | + . '</span>', |
|
1086 | + 'href' => $events_admin_url, |
|
1087 | + 'meta' => array( |
|
1088 | + 'title' => esc_html__('Event Espresso', 'event_espresso'), |
|
1089 | + 'class' => $menu_class . 'first', |
|
1090 | + ), |
|
1091 | + )); |
|
1092 | + //Events |
|
1093 | + if ($this->registry->CAP->current_user_can( |
|
1094 | + 'ee_read_events', |
|
1095 | + 'ee_admin_bar_menu_espresso-toolbar-events' |
|
1096 | + )) { |
|
1097 | + $admin_bar->add_menu(array( |
|
1098 | + 'id' => 'espresso-toolbar-events', |
|
1099 | + 'parent' => 'espresso-toolbar', |
|
1100 | + 'title' => esc_html__('Events', 'event_espresso'), |
|
1101 | + 'href' => $events_admin_url, |
|
1102 | + 'meta' => array( |
|
1103 | + 'title' => esc_html__('Events', 'event_espresso'), |
|
1104 | + 'target' => '', |
|
1105 | + 'class' => $menu_class, |
|
1106 | + ), |
|
1107 | + )); |
|
1108 | + } |
|
1109 | + if ($this->registry->CAP->current_user_can( |
|
1110 | + 'ee_edit_events', |
|
1111 | + 'ee_admin_bar_menu_espresso-toolbar-events-new' |
|
1112 | + )) { |
|
1113 | + //Events Add New |
|
1114 | + $admin_bar->add_menu(array( |
|
1115 | + 'id' => 'espresso-toolbar-events-new', |
|
1116 | + 'parent' => 'espresso-toolbar-events', |
|
1117 | + 'title' => esc_html__('Add New', 'event_espresso'), |
|
1118 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1119 | + 'meta' => array( |
|
1120 | + 'title' => esc_html__('Add New', 'event_espresso'), |
|
1121 | + 'target' => '', |
|
1122 | + 'class' => $menu_class, |
|
1123 | + ), |
|
1124 | + )); |
|
1125 | + } |
|
1126 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1127 | + //Current post |
|
1128 | + global $post; |
|
1129 | + if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1130 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1131 | + ) { |
|
1132 | + //Events Edit Current Event |
|
1133 | + $admin_bar->add_menu(array( |
|
1134 | + 'id' => 'espresso-toolbar-events-edit', |
|
1135 | + 'parent' => 'espresso-toolbar-events', |
|
1136 | + 'title' => esc_html__('Edit Event', 'event_espresso'), |
|
1137 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1138 | + $events_admin_url), |
|
1139 | + 'meta' => array( |
|
1140 | + 'title' => esc_html__('Edit Event', 'event_espresso'), |
|
1141 | + 'target' => '', |
|
1142 | + 'class' => $menu_class, |
|
1143 | + ), |
|
1144 | + )); |
|
1145 | + } |
|
1146 | + } |
|
1147 | + //Events View |
|
1148 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1149 | + 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1150 | + ) { |
|
1151 | + $admin_bar->add_menu(array( |
|
1152 | + 'id' => 'espresso-toolbar-events-view', |
|
1153 | + 'parent' => 'espresso-toolbar-events', |
|
1154 | + 'title' => esc_html__('View', 'event_espresso'), |
|
1155 | + 'href' => $events_admin_url, |
|
1156 | + 'meta' => array( |
|
1157 | + 'title' => esc_html__('View', 'event_espresso'), |
|
1158 | + 'target' => '', |
|
1159 | + 'class' => $menu_class, |
|
1160 | + ), |
|
1161 | + )); |
|
1162 | + } |
|
1163 | + if ($this->registry->CAP->current_user_can( |
|
1164 | + 'ee_read_events', |
|
1165 | + 'ee_admin_bar_menu_espresso-toolbar-events-all' |
|
1166 | + )) { |
|
1167 | + //Events View All |
|
1168 | + $admin_bar->add_menu(array( |
|
1169 | + 'id' => 'espresso-toolbar-events-all', |
|
1170 | + 'parent' => 'espresso-toolbar-events-view', |
|
1171 | + 'title' => esc_html__('All', 'event_espresso'), |
|
1172 | + 'href' => $events_admin_url, |
|
1173 | + 'meta' => array( |
|
1174 | + 'title' => esc_html__('All', 'event_espresso'), |
|
1175 | + 'target' => '', |
|
1176 | + 'class' => $menu_class, |
|
1177 | + ), |
|
1178 | + )); |
|
1179 | + } |
|
1180 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1181 | + 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1182 | + ) { |
|
1183 | + //Events View Today |
|
1184 | + $admin_bar->add_menu(array( |
|
1185 | + 'id' => 'espresso-toolbar-events-today', |
|
1186 | + 'parent' => 'espresso-toolbar-events-view', |
|
1187 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
1188 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1189 | + $events_admin_url), |
|
1190 | + 'meta' => array( |
|
1191 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
1192 | + 'target' => '', |
|
1193 | + 'class' => $menu_class, |
|
1194 | + ), |
|
1195 | + )); |
|
1196 | + } |
|
1197 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1198 | + 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1199 | + ) { |
|
1200 | + //Events View This Month |
|
1201 | + $admin_bar->add_menu(array( |
|
1202 | + 'id' => 'espresso-toolbar-events-month', |
|
1203 | + 'parent' => 'espresso-toolbar-events-view', |
|
1204 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
1205 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1206 | + $events_admin_url), |
|
1207 | + 'meta' => array( |
|
1208 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
1209 | + 'target' => '', |
|
1210 | + 'class' => $menu_class, |
|
1211 | + ), |
|
1212 | + )); |
|
1213 | + } |
|
1214 | + //Registration Overview |
|
1215 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1216 | + 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1217 | + ) { |
|
1218 | + $admin_bar->add_menu(array( |
|
1219 | + 'id' => 'espresso-toolbar-registrations', |
|
1220 | + 'parent' => 'espresso-toolbar', |
|
1221 | + 'title' => esc_html__('Registrations', 'event_espresso'), |
|
1222 | + 'href' => $reg_admin_url, |
|
1223 | + 'meta' => array( |
|
1224 | + 'title' => esc_html__('Registrations', 'event_espresso'), |
|
1225 | + 'target' => '', |
|
1226 | + 'class' => $menu_class, |
|
1227 | + ), |
|
1228 | + )); |
|
1229 | + } |
|
1230 | + //Registration Overview Today |
|
1231 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1232 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1233 | + ) { |
|
1234 | + $admin_bar->add_menu(array( |
|
1235 | + 'id' => 'espresso-toolbar-registrations-today', |
|
1236 | + 'parent' => 'espresso-toolbar-registrations', |
|
1237 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
1238 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1239 | + $reg_admin_url), |
|
1240 | + 'meta' => array( |
|
1241 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
1242 | + 'target' => '', |
|
1243 | + 'class' => $menu_class, |
|
1244 | + ), |
|
1245 | + )); |
|
1246 | + } |
|
1247 | + //Registration Overview Today Completed |
|
1248 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1249 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1250 | + ) { |
|
1251 | + $admin_bar->add_menu(array( |
|
1252 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1253 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1254 | + 'title' => esc_html__('Approved', 'event_espresso'), |
|
1255 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1256 | + 'action' => 'default', |
|
1257 | + 'status' => 'today', |
|
1258 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1259 | + ), $reg_admin_url), |
|
1260 | + 'meta' => array( |
|
1261 | + 'title' => esc_html__('Approved', 'event_espresso'), |
|
1262 | + 'target' => '', |
|
1263 | + 'class' => $menu_class, |
|
1264 | + ), |
|
1265 | + )); |
|
1266 | + } |
|
1267 | + //Registration Overview Today Pending\ |
|
1268 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1269 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1270 | + ) { |
|
1271 | + $admin_bar->add_menu(array( |
|
1272 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1273 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1274 | + 'title' => esc_html__('Pending', 'event_espresso'), |
|
1275 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1276 | + 'action' => 'default', |
|
1277 | + 'status' => 'today', |
|
1278 | + 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1279 | + ), $reg_admin_url), |
|
1280 | + 'meta' => array( |
|
1281 | + 'title' => esc_html__('Pending Payment', 'event_espresso'), |
|
1282 | + 'target' => '', |
|
1283 | + 'class' => $menu_class, |
|
1284 | + ), |
|
1285 | + )); |
|
1286 | + } |
|
1287 | + //Registration Overview Today Incomplete |
|
1288 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1289 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1290 | + ) { |
|
1291 | + $admin_bar->add_menu(array( |
|
1292 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1293 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1294 | + 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1295 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1296 | + 'action' => 'default', |
|
1297 | + 'status' => 'today', |
|
1298 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1299 | + ), $reg_admin_url), |
|
1300 | + 'meta' => array( |
|
1301 | + 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1302 | + 'target' => '', |
|
1303 | + 'class' => $menu_class, |
|
1304 | + ), |
|
1305 | + )); |
|
1306 | + } |
|
1307 | + //Registration Overview Today Incomplete |
|
1308 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1309 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1310 | + ) { |
|
1311 | + $admin_bar->add_menu(array( |
|
1312 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1313 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1314 | + 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1315 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1316 | + 'action' => 'default', |
|
1317 | + 'status' => 'today', |
|
1318 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1319 | + ), $reg_admin_url), |
|
1320 | + 'meta' => array( |
|
1321 | + 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1322 | + 'target' => '', |
|
1323 | + 'class' => $menu_class, |
|
1324 | + ), |
|
1325 | + )); |
|
1326 | + } |
|
1327 | + //Registration Overview This Month |
|
1328 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1329 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1330 | + ) { |
|
1331 | + $admin_bar->add_menu(array( |
|
1332 | + 'id' => 'espresso-toolbar-registrations-month', |
|
1333 | + 'parent' => 'espresso-toolbar-registrations', |
|
1334 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
1335 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1336 | + $reg_admin_url), |
|
1337 | + 'meta' => array( |
|
1338 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
1339 | + 'target' => '', |
|
1340 | + 'class' => $menu_class, |
|
1341 | + ), |
|
1342 | + )); |
|
1343 | + } |
|
1344 | + //Registration Overview This Month Approved |
|
1345 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1346 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1347 | + ) { |
|
1348 | + $admin_bar->add_menu(array( |
|
1349 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1350 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1351 | + 'title' => esc_html__('Approved', 'event_espresso'), |
|
1352 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1353 | + 'action' => 'default', |
|
1354 | + 'status' => 'month', |
|
1355 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1356 | + ), $reg_admin_url), |
|
1357 | + 'meta' => array( |
|
1358 | + 'title' => esc_html__('Approved', 'event_espresso'), |
|
1359 | + 'target' => '', |
|
1360 | + 'class' => $menu_class, |
|
1361 | + ), |
|
1362 | + )); |
|
1363 | + } |
|
1364 | + //Registration Overview This Month Pending |
|
1365 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1366 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1367 | + ) { |
|
1368 | + $admin_bar->add_menu(array( |
|
1369 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1370 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1371 | + 'title' => esc_html__('Pending', 'event_espresso'), |
|
1372 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1373 | + 'action' => 'default', |
|
1374 | + 'status' => 'month', |
|
1375 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1376 | + ), $reg_admin_url), |
|
1377 | + 'meta' => array( |
|
1378 | + 'title' => esc_html__('Pending', 'event_espresso'), |
|
1379 | + 'target' => '', |
|
1380 | + 'class' => $menu_class, |
|
1381 | + ), |
|
1382 | + )); |
|
1383 | + } |
|
1384 | + //Registration Overview This Month Not Approved |
|
1385 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1386 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1387 | + ) { |
|
1388 | + $admin_bar->add_menu(array( |
|
1389 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1390 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1391 | + 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1392 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1393 | + 'action' => 'default', |
|
1394 | + 'status' => 'month', |
|
1395 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1396 | + ), $reg_admin_url), |
|
1397 | + 'meta' => array( |
|
1398 | + 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
1399 | + 'target' => '', |
|
1400 | + 'class' => $menu_class, |
|
1401 | + ), |
|
1402 | + )); |
|
1403 | + } |
|
1404 | + //Registration Overview This Month Cancelled |
|
1405 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1406 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1407 | + ) { |
|
1408 | + $admin_bar->add_menu(array( |
|
1409 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1410 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1411 | + 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1412 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1413 | + 'action' => 'default', |
|
1414 | + 'status' => 'month', |
|
1415 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1416 | + ), $reg_admin_url), |
|
1417 | + 'meta' => array( |
|
1418 | + 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
1419 | + 'target' => '', |
|
1420 | + 'class' => $menu_class, |
|
1421 | + ), |
|
1422 | + )); |
|
1423 | + } |
|
1424 | + //Extensions & Services |
|
1425 | + if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1426 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1427 | + ) { |
|
1428 | + $admin_bar->add_menu(array( |
|
1429 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
1430 | + 'parent' => 'espresso-toolbar', |
|
1431 | + 'title' => esc_html__('Extensions & Services', 'event_espresso'), |
|
1432 | + 'href' => $extensions_admin_url, |
|
1433 | + 'meta' => array( |
|
1434 | + 'title' => esc_html__('Extensions & Services', 'event_espresso'), |
|
1435 | + 'target' => '', |
|
1436 | + 'class' => $menu_class, |
|
1437 | + ), |
|
1438 | + )); |
|
1439 | + } |
|
1440 | + } |
|
1441 | + |
|
1442 | + |
|
1443 | + |
|
1444 | + /** |
|
1445 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1446 | + * never returned with the function. |
|
1447 | + * |
|
1448 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1449 | + * @return array |
|
1450 | + */ |
|
1451 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1452 | + { |
|
1453 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1454 | + } |
|
1455 | 1455 | |
1456 | 1456 | |
1457 | 1457 |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
191 | 191 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
192 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
192 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
193 | 193 | //load and setup EE_Capabilities |
194 | 194 | $this->registry->load_core('Capabilities'); |
195 | 195 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | && $_GET['activate'] === 'true' |
211 | 211 | ) |
212 | 212 | ) { |
213 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
213 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
214 | 214 | } |
215 | 215 | $this->_maybe_brew_regular(); |
216 | 216 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | if ($activation_history_for_addon) { |
524 | 524 | //it exists, so this isn't a completely new install |
525 | 525 | //check if this version already in that list of previously installed versions |
526 | - if (! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
526 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
527 | 527 | //it a version we haven't seen before |
528 | 528 | if ($version_is_higher === 1) { |
529 | 529 | $req_type = EE_System::req_type_upgrade; |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | foreach ($activation_history as $version => $times_activated) { |
605 | 605 | //check there is a record of when this version was activated. Otherwise, |
606 | 606 | //mark it as unknown |
607 | - if (! $times_activated) { |
|
607 | + if ( ! $times_activated) { |
|
608 | 608 | $times_activated = array('unknown-date'); |
609 | 609 | } |
610 | 610 | if (is_string($times_activated)) { |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | { |
634 | 634 | $notices = EE_Error::get_notices(false); |
635 | 635 | //if current user is an admin and it's not an ajax or rest request |
636 | - if (! (defined('DOING_AJAX') && DOING_AJAX) |
|
636 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) |
|
637 | 637 | && ! (defined('REST_REQUEST') && REST_REQUEST) |
638 | 638 | && ! isset($notices['errors']) |
639 | 639 | && apply_filters( |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | private function _parse_model_names() |
699 | 699 | { |
700 | 700 | //get all the files in the EE_MODELS folder that end in .model.php |
701 | - $models = glob(EE_MODELS . '*.model.php'); |
|
701 | + $models = glob(EE_MODELS.'*.model.php'); |
|
702 | 702 | $model_names = array(); |
703 | 703 | $non_abstract_db_models = array(); |
704 | 704 | foreach ($models as $model) { |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | */ |
729 | 729 | private function _maybe_brew_regular() |
730 | 730 | { |
731 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
732 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
731 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
732 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
777 | 777 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
778 | 778 | ); |
779 | - if (! empty($class_names)) { |
|
779 | + if ( ! empty($class_names)) { |
|
780 | 780 | $msg = esc_html__( |
781 | 781 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
782 | 782 | 'event_espresso' |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | private function _deactivate_incompatible_addons() |
854 | 854 | { |
855 | 855 | $incompatible_addons = get_option('ee_incompatible_addons', array()); |
856 | - if (! empty($incompatible_addons)) { |
|
856 | + if ( ! empty($incompatible_addons)) { |
|
857 | 857 | $active_plugins = get_option('active_plugins', array()); |
858 | 858 | foreach ($active_plugins as $active_plugin) { |
859 | 859 | foreach ($incompatible_addons as $incompatible_addon) { |
@@ -914,10 +914,10 @@ discard block |
||
914 | 914 | { |
915 | 915 | do_action('AHEE__EE_System__load_controllers__start'); |
916 | 916 | // let's get it started |
917 | - if (! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
917 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
918 | 918 | do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
919 | 919 | $this->registry->load_core('Front_Controller'); |
920 | - } elseif (! EE_FRONT_AJAX) { |
|
920 | + } elseif ( ! EE_FRONT_AJAX) { |
|
921 | 921 | do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
922 | 922 | EE_Registry::instance()->load_core('Admin'); |
923 | 923 | } |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | { |
938 | 938 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
939 | 939 | // load_espresso_template_tags |
940 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
941 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
940 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
941 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
942 | 942 | } |
943 | 943 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
944 | 944 | $this->registry->load_core('Session'); |
@@ -1002,13 +1002,13 @@ discard block |
||
1002 | 1002 | public static function do_not_cache() |
1003 | 1003 | { |
1004 | 1004 | // set no cache constants |
1005 | - if (! defined('DONOTCACHEPAGE')) { |
|
1005 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
1006 | 1006 | define('DONOTCACHEPAGE', true); |
1007 | 1007 | } |
1008 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1008 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
1009 | 1009 | define('DONOTCACHCEOBJECT', true); |
1010 | 1010 | } |
1011 | - if (! defined('DONOTCACHEDB')) { |
|
1011 | + if ( ! defined('DONOTCACHEDB')) { |
|
1012 | 1012 | define('DONOTCACHEDB', true); |
1013 | 1013 | } |
1014 | 1014 | // add no cache headers |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | 'href' => $events_admin_url, |
1087 | 1087 | 'meta' => array( |
1088 | 1088 | 'title' => esc_html__('Event Espresso', 'event_espresso'), |
1089 | - 'class' => $menu_class . 'first', |
|
1089 | + 'class' => $menu_class.'first', |
|
1090 | 1090 | ), |
1091 | 1091 | )); |
1092 | 1092 | //Events |
@@ -17,872 +17,872 @@ discard block |
||
17 | 17 | final class EE_Capabilities extends EE_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * the name of the wp option used to store caps previously initialized |
|
22 | - */ |
|
23 | - const option_name = 'ee_caps_initialized'; |
|
24 | - |
|
25 | - /** |
|
26 | - * instance of EE_Capabilities object |
|
27 | - * |
|
28 | - * @var EE_Capabilities |
|
29 | - */ |
|
30 | - private static $_instance; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * This is a map of caps that correspond to a default WP_Role. |
|
35 | - * Array is indexed by Role and values are ee capabilities. |
|
36 | - * |
|
37 | - * @since 4.5.0 |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - private $_caps_map = array(); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
46 | - * a user depending on context. |
|
47 | - * |
|
48 | - * @var EE_Meta_Capability_Map[] |
|
49 | - */ |
|
50 | - private $_meta_caps = array(); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Used to track whether the capabilities have been initialized or not in this request. |
|
55 | - * @var bool |
|
56 | - */ |
|
57 | - private $_has_been_initialized = false; |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * singleton method used to instantiate class object |
|
64 | - * |
|
65 | - * @since 4.5.0 |
|
66 | - * |
|
67 | - * @return EE_Capabilities |
|
68 | - */ |
|
69 | - public static function instance() |
|
70 | - { |
|
71 | - //check if instantiated, and if not do so. |
|
72 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
73 | - self::$_instance = new self(); |
|
74 | - } |
|
75 | - return self::$_instance; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * private constructor |
|
81 | - * |
|
82 | - * @since 4.5.0 |
|
83 | - * |
|
84 | - * @return \EE_Capabilities |
|
85 | - */ |
|
86 | - private function __construct() |
|
87 | - { |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
93 | - * |
|
94 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
95 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
96 | - * ensures that they are up to date. |
|
97 | - * @return void |
|
98 | - * @throws EE_Error |
|
99 | - * @throws InvalidExecutionPathException |
|
100 | - * @since 4.5.0 |
|
101 | - */ |
|
102 | - public function init_caps($reset = false) |
|
103 | - { |
|
104 | - if (EE_Maintenance_Mode::instance()->models_can_query() |
|
105 | - && ! $this->has_been_initialized($reset) |
|
106 | - ) { |
|
107 | - do_action('AHEE__EE_Capabilities__init_caps__before_init_cap_logic_call', $this, $reset); |
|
108 | - $this->init_cap_logic($reset); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Executes the logic for initializing EE capabilities. |
|
115 | - * It is preferable to go through `init_caps` and this should not be called directly it's only public because of |
|
116 | - * that being a requirement of being a callback on a WordPress hook. |
|
117 | - * |
|
118 | - * @param bool $reset |
|
119 | - * @throws EE_Error |
|
120 | - * @throws InvalidExecutionPathException |
|
121 | - * @since 4.9.41.rc.006 |
|
122 | - */ |
|
123 | - public function init_cap_logic($reset = false) |
|
124 | - { |
|
125 | - if (! did_action('AHEE__EE_Capabilities__init_caps__before_init_cap_logic_call')) { |
|
126 | - throw new InvalidExecutionPathException( |
|
127 | - esc_html__( |
|
128 | - '%1$s should not be called before the %2$s hook has fired. It is recommended to instead use %s', |
|
129 | - 'event_espresso' |
|
130 | - ) |
|
131 | - ); |
|
132 | - } |
|
133 | - if (! $this->has_been_initialized($reset)) { |
|
134 | - $this->_caps_map = $this->_init_caps_map(); |
|
135 | - $this->init_role_caps($reset); |
|
136 | - $this->_set_meta_caps(); |
|
137 | - $this->_has_been_initialized = true; |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * Returns whether EE_Capabilities have been initialized or not. |
|
144 | - * @param bool $reset |
|
145 | - * @return bool |
|
146 | - */ |
|
147 | - public function has_been_initialized($reset = false) |
|
148 | - { |
|
149 | - return ! $reset ? $this->_has_been_initialized : false; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * This sets the meta caps property. |
|
155 | - * |
|
156 | - * @since 4.5.0 |
|
157 | - * @return void |
|
158 | - * @throws EE_Error |
|
159 | - */ |
|
160 | - private function _set_meta_caps() |
|
161 | - { |
|
162 | - //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
163 | - $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
164 | - $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
165 | - //add filter for map_meta_caps but only if models can query. |
|
166 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
167 | - add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
168 | - } |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * This builds and returns the default meta_caps array only once. |
|
174 | - * |
|
175 | - * @since 4.8.28.rc.012 |
|
176 | - * @return array |
|
177 | - * @throws \EE_Error |
|
178 | - */ |
|
179 | - private function _get_default_meta_caps_array() |
|
180 | - { |
|
181 | - static $default_meta_caps = array(); |
|
182 | - if (empty($default_meta_caps)) { |
|
183 | - $default_meta_caps = array( |
|
184 | - //edits |
|
185 | - new EE_Meta_Capability_Map_Edit( |
|
186 | - 'ee_edit_event', |
|
187 | - array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
188 | - ), |
|
189 | - new EE_Meta_Capability_Map_Edit( |
|
190 | - 'ee_edit_venue', |
|
191 | - array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
192 | - ), |
|
193 | - new EE_Meta_Capability_Map_Edit( |
|
194 | - 'ee_edit_registration', |
|
195 | - array('Registration', '', 'ee_edit_others_registrations', '') |
|
196 | - ), |
|
197 | - new EE_Meta_Capability_Map_Edit( |
|
198 | - 'ee_edit_checkin', |
|
199 | - array('Registration', '', 'ee_edit_others_checkins', '') |
|
200 | - ), |
|
201 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
202 | - 'ee_edit_message', |
|
203 | - array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
204 | - ), |
|
205 | - new EE_Meta_Capability_Map_Edit( |
|
206 | - 'ee_edit_default_ticket', |
|
207 | - array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
208 | - ), |
|
209 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
210 | - 'ee_edit_question', |
|
211 | - array('Question', '', '', 'ee_edit_system_questions') |
|
212 | - ), |
|
213 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
214 | - 'ee_edit_question_group', |
|
215 | - array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
216 | - ), |
|
217 | - new EE_Meta_Capability_Map_Edit( |
|
218 | - 'ee_edit_payment_method', |
|
219 | - array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
220 | - ), |
|
221 | - //reads |
|
222 | - new EE_Meta_Capability_Map_Read( |
|
223 | - 'ee_read_event', |
|
224 | - array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
225 | - ), |
|
226 | - new EE_Meta_Capability_Map_Read( |
|
227 | - 'ee_read_venue', |
|
228 | - array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
229 | - ), |
|
230 | - new EE_Meta_Capability_Map_Read( |
|
231 | - 'ee_read_registration', |
|
232 | - array('Registration', '', '', 'ee_edit_others_registrations') |
|
233 | - ), |
|
234 | - new EE_Meta_Capability_Map_Read( |
|
235 | - 'ee_read_checkin', |
|
236 | - array('Registration', '', '', 'ee_read_others_checkins') |
|
237 | - ), |
|
238 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
239 | - 'ee_read_message', |
|
240 | - array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
241 | - ), |
|
242 | - new EE_Meta_Capability_Map_Read( |
|
243 | - 'ee_read_default_ticket', |
|
244 | - array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
245 | - ), |
|
246 | - new EE_Meta_Capability_Map_Read( |
|
247 | - 'ee_read_payment_method', |
|
248 | - array('Payment_Method', '', '', 'ee_read_others_payment_methods') |
|
249 | - ), |
|
250 | - |
|
251 | - //deletes |
|
252 | - new EE_Meta_Capability_Map_Delete( |
|
253 | - 'ee_delete_event', |
|
254 | - array( |
|
255 | - 'Event', |
|
256 | - 'ee_delete_published_events', |
|
257 | - 'ee_delete_others_events', |
|
258 | - 'ee_delete_private_events', |
|
259 | - ) |
|
260 | - ), |
|
261 | - new EE_Meta_Capability_Map_Delete( |
|
262 | - 'ee_delete_venue', |
|
263 | - array( |
|
264 | - 'Venue', |
|
265 | - 'ee_delete_published_venues', |
|
266 | - 'ee_delete_others_venues', |
|
267 | - 'ee_delete_private_venues', |
|
268 | - ) |
|
269 | - ), |
|
270 | - new EE_Meta_Capability_Map_Delete( |
|
271 | - 'ee_delete_registration', |
|
272 | - array('Registration', '', 'ee_delete_others_registrations', '') |
|
273 | - ), |
|
274 | - new EE_Meta_Capability_Map_Delete( |
|
275 | - 'ee_delete_checkin', |
|
276 | - array('Registration', '', 'ee_delete_others_checkins', '') |
|
277 | - ), |
|
278 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
279 | - 'ee_delete_message', |
|
280 | - array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
281 | - ), |
|
282 | - new EE_Meta_Capability_Map_Delete( |
|
283 | - 'ee_delete_default_ticket', |
|
284 | - array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
285 | - ), |
|
286 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
287 | - 'ee_delete_question', |
|
288 | - array('Question', '', '', 'delete_system_questions') |
|
289 | - ), |
|
290 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
291 | - 'ee_delete_question_group', |
|
292 | - array('Question_Group', '', '', 'delete_system_question_groups') |
|
293 | - ), |
|
294 | - new EE_Meta_Capability_Map_Delete( |
|
295 | - 'ee_delete_payment_method', |
|
296 | - array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
297 | - ), |
|
298 | - ); |
|
299 | - } |
|
300 | - return $default_meta_caps; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
306 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
307 | - * |
|
308 | - * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
309 | - * |
|
310 | - * @since 4.5.0 |
|
311 | - * @see wp-includes/capabilities.php |
|
312 | - * |
|
313 | - * @param array $caps actual users capabilities |
|
314 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
315 | - * @param int $user_id The user id |
|
316 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
317 | - * @return array actual users capabilities |
|
318 | - * @throws EE_Error |
|
319 | - */ |
|
320 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
321 | - { |
|
322 | - if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
323 | - //loop through our _meta_caps array |
|
324 | - foreach ($this->_meta_caps as $meta_map) { |
|
325 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
326 | - continue; |
|
327 | - } |
|
328 | - // don't load models if there is no object ID in the args |
|
329 | - if (! empty($args[0])) { |
|
330 | - $meta_map->ensure_is_model(); |
|
331 | - } |
|
332 | - $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
333 | - } |
|
334 | - } |
|
335 | - return $caps; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * This sets up and returns the initial capabilities map for Event Espresso |
|
341 | - * |
|
342 | - * @since 4.5.0 |
|
343 | - * @return array |
|
344 | - */ |
|
345 | - private function _init_caps_map() |
|
346 | - { |
|
347 | - $caps = array( |
|
348 | - 'administrator' => array( |
|
349 | - //basic access |
|
350 | - 'ee_read_ee', |
|
351 | - //gateways |
|
352 | - /** |
|
353 | - * note that with payment method capabilities, although we've implemented |
|
354 | - * capability mapping which will be used for accessing payment methods owned by |
|
355 | - * other users. This is not fully implemented yet in the payment method ui. |
|
356 | - * Currently only the "plural" caps are in active use. |
|
357 | - * (Specific payment method caps are in use as well). |
|
358 | - **/ |
|
359 | - 'ee_manage_gateways', |
|
360 | - 'ee_read_payment_method', |
|
361 | - 'ee_read_payment_methods', |
|
362 | - 'ee_read_others_payment_methods', |
|
363 | - 'ee_edit_payment_method', |
|
364 | - 'ee_edit_payment_methods', |
|
365 | - 'ee_edit_others_payment_methods', |
|
366 | - 'ee_delete_payment_method', |
|
367 | - 'ee_delete_payment_methods', |
|
368 | - //events |
|
369 | - 'ee_publish_events', |
|
370 | - 'ee_read_private_events', |
|
371 | - 'ee_read_others_events', |
|
372 | - 'ee_read_event', |
|
373 | - 'ee_read_events', |
|
374 | - 'ee_edit_event', |
|
375 | - 'ee_edit_events', |
|
376 | - 'ee_edit_published_events', |
|
377 | - 'ee_edit_others_events', |
|
378 | - 'ee_edit_private_events', |
|
379 | - 'ee_delete_published_events', |
|
380 | - 'ee_delete_private_events', |
|
381 | - 'ee_delete_event', |
|
382 | - 'ee_delete_events', |
|
383 | - 'ee_delete_others_events', |
|
384 | - //event categories |
|
385 | - 'ee_manage_event_categories', |
|
386 | - 'ee_edit_event_category', |
|
387 | - 'ee_delete_event_category', |
|
388 | - 'ee_assign_event_category', |
|
389 | - //venues |
|
390 | - 'ee_publish_venues', |
|
391 | - 'ee_read_venue', |
|
392 | - 'ee_read_venues', |
|
393 | - 'ee_read_others_venues', |
|
394 | - 'ee_read_private_venues', |
|
395 | - 'ee_edit_venue', |
|
396 | - 'ee_edit_venues', |
|
397 | - 'ee_edit_others_venues', |
|
398 | - 'ee_edit_published_venues', |
|
399 | - 'ee_edit_private_venues', |
|
400 | - 'ee_delete_venue', |
|
401 | - 'ee_delete_venues', |
|
402 | - 'ee_delete_others_venues', |
|
403 | - 'ee_delete_private_venues', |
|
404 | - 'ee_delete_published_venues', |
|
405 | - //venue categories |
|
406 | - 'ee_manage_venue_categories', |
|
407 | - 'ee_edit_venue_category', |
|
408 | - 'ee_delete_venue_category', |
|
409 | - 'ee_assign_venue_category', |
|
410 | - //contacts |
|
411 | - 'ee_read_contact', |
|
412 | - 'ee_read_contacts', |
|
413 | - 'ee_edit_contact', |
|
414 | - 'ee_edit_contacts', |
|
415 | - 'ee_delete_contact', |
|
416 | - 'ee_delete_contacts', |
|
417 | - //registrations |
|
418 | - 'ee_read_registration', |
|
419 | - 'ee_read_registrations', |
|
420 | - 'ee_read_others_registrations', |
|
421 | - 'ee_edit_registration', |
|
422 | - 'ee_edit_registrations', |
|
423 | - 'ee_edit_others_registrations', |
|
424 | - 'ee_delete_registration', |
|
425 | - 'ee_delete_registrations', |
|
426 | - //checkins |
|
427 | - 'ee_read_checkin', |
|
428 | - 'ee_read_others_checkins', |
|
429 | - 'ee_read_checkins', |
|
430 | - 'ee_edit_checkin', |
|
431 | - 'ee_edit_checkins', |
|
432 | - 'ee_edit_others_checkins', |
|
433 | - 'ee_delete_checkin', |
|
434 | - 'ee_delete_checkins', |
|
435 | - 'ee_delete_others_checkins', |
|
436 | - //transactions && payments |
|
437 | - 'ee_read_transaction', |
|
438 | - 'ee_read_transactions', |
|
439 | - 'ee_edit_payments', |
|
440 | - 'ee_delete_payments', |
|
441 | - //messages |
|
442 | - 'ee_read_message', |
|
443 | - 'ee_read_messages', |
|
444 | - 'ee_read_others_messages', |
|
445 | - 'ee_read_global_messages', |
|
446 | - 'ee_edit_global_messages', |
|
447 | - 'ee_edit_message', |
|
448 | - 'ee_edit_messages', |
|
449 | - 'ee_edit_others_messages', |
|
450 | - 'ee_delete_message', |
|
451 | - 'ee_delete_messages', |
|
452 | - 'ee_delete_others_messages', |
|
453 | - 'ee_delete_global_messages', |
|
454 | - 'ee_send_message', |
|
455 | - //tickets |
|
456 | - 'ee_read_default_ticket', |
|
457 | - 'ee_read_default_tickets', |
|
458 | - 'ee_read_others_default_tickets', |
|
459 | - 'ee_edit_default_ticket', |
|
460 | - 'ee_edit_default_tickets', |
|
461 | - 'ee_edit_others_default_tickets', |
|
462 | - 'ee_delete_default_ticket', |
|
463 | - 'ee_delete_default_tickets', |
|
464 | - 'ee_delete_others_default_tickets', |
|
465 | - //prices |
|
466 | - 'ee_edit_default_price', |
|
467 | - 'ee_edit_default_prices', |
|
468 | - 'ee_delete_default_price', |
|
469 | - 'ee_delete_default_prices', |
|
470 | - 'ee_edit_default_price_type', |
|
471 | - 'ee_edit_default_price_types', |
|
472 | - 'ee_delete_default_price_type', |
|
473 | - 'ee_delete_default_price_types', |
|
474 | - 'ee_read_default_prices', |
|
475 | - 'ee_read_default_price_types', |
|
476 | - //registration form |
|
477 | - 'ee_edit_question', |
|
478 | - 'ee_edit_questions', |
|
479 | - 'ee_edit_system_questions', |
|
480 | - 'ee_read_questions', |
|
481 | - 'ee_delete_question', |
|
482 | - 'ee_delete_questions', |
|
483 | - 'ee_edit_question_group', |
|
484 | - 'ee_edit_question_groups', |
|
485 | - 'ee_read_question_groups', |
|
486 | - 'ee_edit_system_question_groups', |
|
487 | - 'ee_delete_question_group', |
|
488 | - 'ee_delete_question_groups', |
|
489 | - //event_type taxonomy |
|
490 | - 'ee_assign_event_type', |
|
491 | - 'ee_manage_event_types', |
|
492 | - 'ee_edit_event_type', |
|
493 | - 'ee_delete_event_type', |
|
494 | - ), |
|
495 | - 'ee_events_administrator' => array( |
|
496 | - //core wp caps |
|
497 | - 'read', |
|
498 | - 'read_private_pages', |
|
499 | - 'read_private_posts', |
|
500 | - 'edit_users', |
|
501 | - 'edit_posts', |
|
502 | - 'edit_pages', |
|
503 | - 'edit_published_posts', |
|
504 | - 'edit_published_pages', |
|
505 | - 'edit_private_pages', |
|
506 | - 'edit_private_posts', |
|
507 | - 'edit_others_posts', |
|
508 | - 'edit_others_pages', |
|
509 | - 'publish_posts', |
|
510 | - 'publish_pages', |
|
511 | - 'delete_posts', |
|
512 | - 'delete_pages', |
|
513 | - 'delete_private_pages', |
|
514 | - 'delete_private_posts', |
|
515 | - 'delete_published_pages', |
|
516 | - 'delete_published_posts', |
|
517 | - 'delete_others_posts', |
|
518 | - 'delete_others_pages', |
|
519 | - 'manage_categories', |
|
520 | - 'manage_links', |
|
521 | - 'moderate_comments', |
|
522 | - 'unfiltered_html', |
|
523 | - 'upload_files', |
|
524 | - 'export', |
|
525 | - 'import', |
|
526 | - 'list_users', |
|
527 | - 'level_1', //required if user with this role shows up in author dropdowns |
|
528 | - //basic ee access |
|
529 | - 'ee_read_ee', |
|
530 | - //events |
|
531 | - 'ee_publish_events', |
|
532 | - 'ee_read_private_events', |
|
533 | - 'ee_read_others_events', |
|
534 | - 'ee_read_event', |
|
535 | - 'ee_read_events', |
|
536 | - 'ee_edit_event', |
|
537 | - 'ee_edit_events', |
|
538 | - 'ee_edit_published_events', |
|
539 | - 'ee_edit_others_events', |
|
540 | - 'ee_edit_private_events', |
|
541 | - 'ee_delete_published_events', |
|
542 | - 'ee_delete_private_events', |
|
543 | - 'ee_delete_event', |
|
544 | - 'ee_delete_events', |
|
545 | - 'ee_delete_others_events', |
|
546 | - //event categories |
|
547 | - 'ee_manage_event_categories', |
|
548 | - 'ee_edit_event_category', |
|
549 | - 'ee_delete_event_category', |
|
550 | - 'ee_assign_event_category', |
|
551 | - //venues |
|
552 | - 'ee_publish_venues', |
|
553 | - 'ee_read_venue', |
|
554 | - 'ee_read_venues', |
|
555 | - 'ee_read_others_venues', |
|
556 | - 'ee_read_private_venues', |
|
557 | - 'ee_edit_venue', |
|
558 | - 'ee_edit_venues', |
|
559 | - 'ee_edit_others_venues', |
|
560 | - 'ee_edit_published_venues', |
|
561 | - 'ee_edit_private_venues', |
|
562 | - 'ee_delete_venue', |
|
563 | - 'ee_delete_venues', |
|
564 | - 'ee_delete_others_venues', |
|
565 | - 'ee_delete_private_venues', |
|
566 | - 'ee_delete_published_venues', |
|
567 | - //venue categories |
|
568 | - 'ee_manage_venue_categories', |
|
569 | - 'ee_edit_venue_category', |
|
570 | - 'ee_delete_venue_category', |
|
571 | - 'ee_assign_venue_category', |
|
572 | - //contacts |
|
573 | - 'ee_read_contact', |
|
574 | - 'ee_read_contacts', |
|
575 | - 'ee_edit_contact', |
|
576 | - 'ee_edit_contacts', |
|
577 | - 'ee_delete_contact', |
|
578 | - 'ee_delete_contacts', |
|
579 | - //registrations |
|
580 | - 'ee_read_registration', |
|
581 | - 'ee_read_registrations', |
|
582 | - 'ee_read_others_registrations', |
|
583 | - 'ee_edit_registration', |
|
584 | - 'ee_edit_registrations', |
|
585 | - 'ee_edit_others_registrations', |
|
586 | - 'ee_delete_registration', |
|
587 | - 'ee_delete_registrations', |
|
588 | - //checkins |
|
589 | - 'ee_read_checkin', |
|
590 | - 'ee_read_others_checkins', |
|
591 | - 'ee_read_checkins', |
|
592 | - 'ee_edit_checkin', |
|
593 | - 'ee_edit_checkins', |
|
594 | - 'ee_edit_others_checkins', |
|
595 | - 'ee_delete_checkin', |
|
596 | - 'ee_delete_checkins', |
|
597 | - 'ee_delete_others_checkins', |
|
598 | - //transactions && payments |
|
599 | - 'ee_read_transaction', |
|
600 | - 'ee_read_transactions', |
|
601 | - 'ee_edit_payments', |
|
602 | - 'ee_delete_payments', |
|
603 | - //messages |
|
604 | - 'ee_read_message', |
|
605 | - 'ee_read_messages', |
|
606 | - 'ee_read_others_messages', |
|
607 | - 'ee_read_global_messages', |
|
608 | - 'ee_edit_global_messages', |
|
609 | - 'ee_edit_message', |
|
610 | - 'ee_edit_messages', |
|
611 | - 'ee_edit_others_messages', |
|
612 | - 'ee_delete_message', |
|
613 | - 'ee_delete_messages', |
|
614 | - 'ee_delete_others_messages', |
|
615 | - 'ee_delete_global_messages', |
|
616 | - 'ee_send_message', |
|
617 | - //tickets |
|
618 | - 'ee_read_default_ticket', |
|
619 | - 'ee_read_default_tickets', |
|
620 | - 'ee_read_others_default_tickets', |
|
621 | - 'ee_edit_default_ticket', |
|
622 | - 'ee_edit_default_tickets', |
|
623 | - 'ee_edit_others_default_tickets', |
|
624 | - 'ee_delete_default_ticket', |
|
625 | - 'ee_delete_default_tickets', |
|
626 | - 'ee_delete_others_default_tickets', |
|
627 | - //prices |
|
628 | - 'ee_edit_default_price', |
|
629 | - 'ee_edit_default_prices', |
|
630 | - 'ee_delete_default_price', |
|
631 | - 'ee_delete_default_prices', |
|
632 | - 'ee_edit_default_price_type', |
|
633 | - 'ee_edit_default_price_types', |
|
634 | - 'ee_delete_default_price_type', |
|
635 | - 'ee_delete_default_price_types', |
|
636 | - 'ee_read_default_prices', |
|
637 | - 'ee_read_default_price_types', |
|
638 | - //registration form |
|
639 | - 'ee_edit_question', |
|
640 | - 'ee_edit_questions', |
|
641 | - 'ee_edit_system_questions', |
|
642 | - 'ee_read_questions', |
|
643 | - 'ee_delete_question', |
|
644 | - 'ee_delete_questions', |
|
645 | - 'ee_edit_question_group', |
|
646 | - 'ee_edit_question_groups', |
|
647 | - 'ee_read_question_groups', |
|
648 | - 'ee_edit_system_question_groups', |
|
649 | - 'ee_delete_question_group', |
|
650 | - 'ee_delete_question_groups', |
|
651 | - //event_type taxonomy |
|
652 | - 'ee_assign_event_type', |
|
653 | - 'ee_manage_event_types', |
|
654 | - 'ee_edit_event_type', |
|
655 | - 'ee_delete_event_type', |
|
656 | - ) |
|
657 | - ); |
|
658 | - $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
659 | - //add payment method caps. |
|
660 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
661 | - return EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
662 | - } |
|
663 | - |
|
664 | - |
|
665 | - /** |
|
666 | - * This adds all the default caps to roles as registered in the _caps_map property. |
|
667 | - * |
|
668 | - * @since 4.5.0 |
|
669 | - * |
|
670 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
671 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
672 | - * and ensures that they are up to date. |
|
673 | - * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
674 | - * up. Note that this should ONLY be called on activation hook or some other one-time |
|
675 | - * task otherwise the caps will be added on every request. |
|
676 | - * |
|
677 | - * @return void |
|
678 | - */ |
|
679 | - public function init_role_caps($reset = false, $custom_map = array()) |
|
680 | - { |
|
681 | - //if reset, then completely delete the cache option. |
|
682 | - if ($reset) { |
|
683 | - delete_option(self::option_name); |
|
684 | - } |
|
685 | - $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
686 | - //first let's determine if these caps have already been set. |
|
687 | - $caps_set_before = $reset ? array() : get_option(self::option_name, array()); |
|
688 | - $update_caps_set_before_option = false; |
|
689 | - //if not reset, see what caps are new for each role. if they're new, add them. |
|
690 | - foreach ($caps_map as $role => $caps_for_role) { |
|
691 | - foreach ($caps_for_role as $cap) { |
|
692 | - //first check we haven't already added this cap before, or it's a reset |
|
693 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
694 | - if ($this->add_cap_to_role($role, $cap)) { |
|
695 | - $caps_set_before[ $role ][] = $cap; |
|
696 | - $update_caps_set_before_option = true; |
|
697 | - } |
|
698 | - } |
|
699 | - } |
|
700 | - } |
|
701 | - //now let's just save the cap that has been set but only if there's been a change. |
|
702 | - if ($update_caps_set_before_option) { |
|
703 | - update_option(self::option_name, $caps_set_before); |
|
704 | - } |
|
705 | - do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
706 | - } |
|
707 | - |
|
708 | - |
|
709 | - /** |
|
710 | - * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
711 | - * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
712 | - * this is a wrapper for $wp_role->add_cap() |
|
713 | - * |
|
714 | - * @see wp-includes/capabilities.php |
|
715 | - * |
|
716 | - * @since 4.5.0 |
|
717 | - * |
|
718 | - * @param string $role A WordPress role the capability is being added to |
|
719 | - * @param string $cap The capability being added to the role |
|
720 | - * @param bool $grant Whether to grant access to this cap on this role. |
|
721 | - * |
|
722 | - * @return bool |
|
723 | - */ |
|
724 | - public function add_cap_to_role($role, $cap, $grant = true) |
|
725 | - { |
|
726 | - $role_object = get_role($role); |
|
727 | - //if the role isn't available then we create it. |
|
728 | - if (! $role_object instanceof WP_Role) { |
|
729 | - //if a plugin wants to create a specific role name then they should create the role before |
|
730 | - //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
731 | - // - removes any `ee_` namespacing from the start of the slug. |
|
732 | - // - replaces `_` with ` ` (empty space). |
|
733 | - // - sentence case on the resulting string. |
|
734 | - $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
735 | - $role_object = add_role($role, $role_label); |
|
736 | - } |
|
737 | - if ($role_object instanceof WP_Role) { |
|
738 | - $role_object->add_cap($cap, $grant); |
|
739 | - return true; |
|
740 | - } |
|
741 | - return false; |
|
742 | - } |
|
743 | - |
|
744 | - |
|
745 | - /** |
|
746 | - * Functions similarly to add_cap_to_role except removes cap from given role. |
|
747 | - * Wrapper for $wp_role->remove_cap() |
|
748 | - * |
|
749 | - * @see wp-includes/capabilities.php |
|
750 | - * @since 4.5.0 |
|
751 | - * |
|
752 | - * @param string $role A WordPress role the capability is being removed from. |
|
753 | - * @param string $cap The capability being removed |
|
754 | - * |
|
755 | - * @return void |
|
756 | - */ |
|
757 | - public function remove_cap_from_role($role, $cap) |
|
758 | - { |
|
759 | - $role = get_role($role); |
|
760 | - if ($role instanceof WP_Role) { |
|
761 | - $role->remove_cap($cap); |
|
762 | - } |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - /** |
|
767 | - * Wrapper for the native WP current_user_can() method. |
|
768 | - * This is provided as a handy method for a couple things: |
|
769 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
770 | - * write those filters wherever current_user_can is called). |
|
771 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
772 | - * |
|
773 | - * @since 4.5.0 |
|
774 | - * |
|
775 | - * @param string $cap The cap being checked. |
|
776 | - * @param string $context The context where the current_user_can is being called from. |
|
777 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
778 | - * filters. |
|
779 | - * |
|
780 | - * @return bool Whether user can or not. |
|
781 | - */ |
|
782 | - public function current_user_can($cap, $context, $id = 0) |
|
783 | - { |
|
784 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
785 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
786 | - $filtered_cap = apply_filters( |
|
787 | - 'FHEE__EE_Capabilities__current_user_can__cap', |
|
788 | - $filtered_cap, |
|
789 | - $context, |
|
790 | - $cap, |
|
791 | - $id |
|
792 | - ); |
|
793 | - return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
794 | - } |
|
795 | - |
|
796 | - |
|
797 | - /** |
|
798 | - * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
799 | - * |
|
800 | - * @param int|WP_User $user Either the user_id or a WP_User object |
|
801 | - * @param string $cap The capability string being checked |
|
802 | - * @param string $context The context where the user_can is being called from (used in filters). |
|
803 | - * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
804 | - * filters) |
|
805 | - * |
|
806 | - * @return bool Whether user can or not. |
|
807 | - */ |
|
808 | - public function user_can($user, $cap, $context, $id = 0) |
|
809 | - { |
|
810 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
811 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
812 | - $filtered_cap = apply_filters( |
|
813 | - 'FHEE__EE_Capabilities__user_can__cap', |
|
814 | - $filtered_cap, |
|
815 | - $context, |
|
816 | - $cap, |
|
817 | - $user, |
|
818 | - $id |
|
819 | - ); |
|
820 | - return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
821 | - } |
|
822 | - |
|
823 | - |
|
824 | - /** |
|
825 | - * Wrapper for the native WP current_user_can_for_blog() method. |
|
826 | - * This is provided as a handy method for a couple things: |
|
827 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
828 | - * write those filters wherever current_user_can is called). |
|
829 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
830 | - * |
|
831 | - * @since 4.5.0 |
|
832 | - * |
|
833 | - * @param int $blog_id The blog id that is being checked for. |
|
834 | - * @param string $cap The cap being checked. |
|
835 | - * @param string $context The context where the current_user_can is being called from. |
|
836 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
837 | - * filters. |
|
838 | - * |
|
839 | - * @return bool Whether user can or not. |
|
840 | - */ |
|
841 | - public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
842 | - { |
|
843 | - $user_can = ! empty($id) |
|
844 | - ? current_user_can_for_blog($blog_id, $cap, $id) |
|
845 | - : current_user_can($blog_id, $cap); |
|
846 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
847 | - $user_can = apply_filters( |
|
848 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
849 | - $user_can, |
|
850 | - $blog_id, |
|
851 | - $cap, |
|
852 | - $id |
|
853 | - ); |
|
854 | - $user_can = apply_filters( |
|
855 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
856 | - $user_can, |
|
857 | - $context, |
|
858 | - $blog_id, |
|
859 | - $cap, |
|
860 | - $id |
|
861 | - ); |
|
862 | - return $user_can; |
|
863 | - } |
|
864 | - |
|
865 | - |
|
866 | - /** |
|
867 | - * This helper method just returns an array of registered EE capabilities. |
|
868 | - * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
869 | - * role. |
|
870 | - * |
|
871 | - * @since 4.5.0 |
|
872 | - * |
|
873 | - * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
874 | - * for the given role are returned. |
|
875 | - * |
|
876 | - * @return array |
|
877 | - */ |
|
878 | - public function get_ee_capabilities($role = 'administrator') |
|
879 | - { |
|
880 | - $capabilities = $this->_init_caps_map(); |
|
881 | - if (empty($role)) { |
|
882 | - return $capabilities; |
|
883 | - } |
|
884 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
885 | - } |
|
20 | + /** |
|
21 | + * the name of the wp option used to store caps previously initialized |
|
22 | + */ |
|
23 | + const option_name = 'ee_caps_initialized'; |
|
24 | + |
|
25 | + /** |
|
26 | + * instance of EE_Capabilities object |
|
27 | + * |
|
28 | + * @var EE_Capabilities |
|
29 | + */ |
|
30 | + private static $_instance; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * This is a map of caps that correspond to a default WP_Role. |
|
35 | + * Array is indexed by Role and values are ee capabilities. |
|
36 | + * |
|
37 | + * @since 4.5.0 |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + private $_caps_map = array(); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
46 | + * a user depending on context. |
|
47 | + * |
|
48 | + * @var EE_Meta_Capability_Map[] |
|
49 | + */ |
|
50 | + private $_meta_caps = array(); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Used to track whether the capabilities have been initialized or not in this request. |
|
55 | + * @var bool |
|
56 | + */ |
|
57 | + private $_has_been_initialized = false; |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * singleton method used to instantiate class object |
|
64 | + * |
|
65 | + * @since 4.5.0 |
|
66 | + * |
|
67 | + * @return EE_Capabilities |
|
68 | + */ |
|
69 | + public static function instance() |
|
70 | + { |
|
71 | + //check if instantiated, and if not do so. |
|
72 | + if (! self::$_instance instanceof EE_Capabilities) { |
|
73 | + self::$_instance = new self(); |
|
74 | + } |
|
75 | + return self::$_instance; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * private constructor |
|
81 | + * |
|
82 | + * @since 4.5.0 |
|
83 | + * |
|
84 | + * @return \EE_Capabilities |
|
85 | + */ |
|
86 | + private function __construct() |
|
87 | + { |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
93 | + * |
|
94 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
95 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
96 | + * ensures that they are up to date. |
|
97 | + * @return void |
|
98 | + * @throws EE_Error |
|
99 | + * @throws InvalidExecutionPathException |
|
100 | + * @since 4.5.0 |
|
101 | + */ |
|
102 | + public function init_caps($reset = false) |
|
103 | + { |
|
104 | + if (EE_Maintenance_Mode::instance()->models_can_query() |
|
105 | + && ! $this->has_been_initialized($reset) |
|
106 | + ) { |
|
107 | + do_action('AHEE__EE_Capabilities__init_caps__before_init_cap_logic_call', $this, $reset); |
|
108 | + $this->init_cap_logic($reset); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Executes the logic for initializing EE capabilities. |
|
115 | + * It is preferable to go through `init_caps` and this should not be called directly it's only public because of |
|
116 | + * that being a requirement of being a callback on a WordPress hook. |
|
117 | + * |
|
118 | + * @param bool $reset |
|
119 | + * @throws EE_Error |
|
120 | + * @throws InvalidExecutionPathException |
|
121 | + * @since 4.9.41.rc.006 |
|
122 | + */ |
|
123 | + public function init_cap_logic($reset = false) |
|
124 | + { |
|
125 | + if (! did_action('AHEE__EE_Capabilities__init_caps__before_init_cap_logic_call')) { |
|
126 | + throw new InvalidExecutionPathException( |
|
127 | + esc_html__( |
|
128 | + '%1$s should not be called before the %2$s hook has fired. It is recommended to instead use %s', |
|
129 | + 'event_espresso' |
|
130 | + ) |
|
131 | + ); |
|
132 | + } |
|
133 | + if (! $this->has_been_initialized($reset)) { |
|
134 | + $this->_caps_map = $this->_init_caps_map(); |
|
135 | + $this->init_role_caps($reset); |
|
136 | + $this->_set_meta_caps(); |
|
137 | + $this->_has_been_initialized = true; |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * Returns whether EE_Capabilities have been initialized or not. |
|
144 | + * @param bool $reset |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | + public function has_been_initialized($reset = false) |
|
148 | + { |
|
149 | + return ! $reset ? $this->_has_been_initialized : false; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * This sets the meta caps property. |
|
155 | + * |
|
156 | + * @since 4.5.0 |
|
157 | + * @return void |
|
158 | + * @throws EE_Error |
|
159 | + */ |
|
160 | + private function _set_meta_caps() |
|
161 | + { |
|
162 | + //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
163 | + $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
164 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
165 | + //add filter for map_meta_caps but only if models can query. |
|
166 | + if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
167 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
168 | + } |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * This builds and returns the default meta_caps array only once. |
|
174 | + * |
|
175 | + * @since 4.8.28.rc.012 |
|
176 | + * @return array |
|
177 | + * @throws \EE_Error |
|
178 | + */ |
|
179 | + private function _get_default_meta_caps_array() |
|
180 | + { |
|
181 | + static $default_meta_caps = array(); |
|
182 | + if (empty($default_meta_caps)) { |
|
183 | + $default_meta_caps = array( |
|
184 | + //edits |
|
185 | + new EE_Meta_Capability_Map_Edit( |
|
186 | + 'ee_edit_event', |
|
187 | + array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
188 | + ), |
|
189 | + new EE_Meta_Capability_Map_Edit( |
|
190 | + 'ee_edit_venue', |
|
191 | + array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
192 | + ), |
|
193 | + new EE_Meta_Capability_Map_Edit( |
|
194 | + 'ee_edit_registration', |
|
195 | + array('Registration', '', 'ee_edit_others_registrations', '') |
|
196 | + ), |
|
197 | + new EE_Meta_Capability_Map_Edit( |
|
198 | + 'ee_edit_checkin', |
|
199 | + array('Registration', '', 'ee_edit_others_checkins', '') |
|
200 | + ), |
|
201 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
202 | + 'ee_edit_message', |
|
203 | + array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
204 | + ), |
|
205 | + new EE_Meta_Capability_Map_Edit( |
|
206 | + 'ee_edit_default_ticket', |
|
207 | + array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
208 | + ), |
|
209 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
210 | + 'ee_edit_question', |
|
211 | + array('Question', '', '', 'ee_edit_system_questions') |
|
212 | + ), |
|
213 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
214 | + 'ee_edit_question_group', |
|
215 | + array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
216 | + ), |
|
217 | + new EE_Meta_Capability_Map_Edit( |
|
218 | + 'ee_edit_payment_method', |
|
219 | + array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
220 | + ), |
|
221 | + //reads |
|
222 | + new EE_Meta_Capability_Map_Read( |
|
223 | + 'ee_read_event', |
|
224 | + array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
225 | + ), |
|
226 | + new EE_Meta_Capability_Map_Read( |
|
227 | + 'ee_read_venue', |
|
228 | + array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
229 | + ), |
|
230 | + new EE_Meta_Capability_Map_Read( |
|
231 | + 'ee_read_registration', |
|
232 | + array('Registration', '', '', 'ee_edit_others_registrations') |
|
233 | + ), |
|
234 | + new EE_Meta_Capability_Map_Read( |
|
235 | + 'ee_read_checkin', |
|
236 | + array('Registration', '', '', 'ee_read_others_checkins') |
|
237 | + ), |
|
238 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
239 | + 'ee_read_message', |
|
240 | + array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
241 | + ), |
|
242 | + new EE_Meta_Capability_Map_Read( |
|
243 | + 'ee_read_default_ticket', |
|
244 | + array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
245 | + ), |
|
246 | + new EE_Meta_Capability_Map_Read( |
|
247 | + 'ee_read_payment_method', |
|
248 | + array('Payment_Method', '', '', 'ee_read_others_payment_methods') |
|
249 | + ), |
|
250 | + |
|
251 | + //deletes |
|
252 | + new EE_Meta_Capability_Map_Delete( |
|
253 | + 'ee_delete_event', |
|
254 | + array( |
|
255 | + 'Event', |
|
256 | + 'ee_delete_published_events', |
|
257 | + 'ee_delete_others_events', |
|
258 | + 'ee_delete_private_events', |
|
259 | + ) |
|
260 | + ), |
|
261 | + new EE_Meta_Capability_Map_Delete( |
|
262 | + 'ee_delete_venue', |
|
263 | + array( |
|
264 | + 'Venue', |
|
265 | + 'ee_delete_published_venues', |
|
266 | + 'ee_delete_others_venues', |
|
267 | + 'ee_delete_private_venues', |
|
268 | + ) |
|
269 | + ), |
|
270 | + new EE_Meta_Capability_Map_Delete( |
|
271 | + 'ee_delete_registration', |
|
272 | + array('Registration', '', 'ee_delete_others_registrations', '') |
|
273 | + ), |
|
274 | + new EE_Meta_Capability_Map_Delete( |
|
275 | + 'ee_delete_checkin', |
|
276 | + array('Registration', '', 'ee_delete_others_checkins', '') |
|
277 | + ), |
|
278 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
279 | + 'ee_delete_message', |
|
280 | + array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
281 | + ), |
|
282 | + new EE_Meta_Capability_Map_Delete( |
|
283 | + 'ee_delete_default_ticket', |
|
284 | + array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
285 | + ), |
|
286 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
287 | + 'ee_delete_question', |
|
288 | + array('Question', '', '', 'delete_system_questions') |
|
289 | + ), |
|
290 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
291 | + 'ee_delete_question_group', |
|
292 | + array('Question_Group', '', '', 'delete_system_question_groups') |
|
293 | + ), |
|
294 | + new EE_Meta_Capability_Map_Delete( |
|
295 | + 'ee_delete_payment_method', |
|
296 | + array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
297 | + ), |
|
298 | + ); |
|
299 | + } |
|
300 | + return $default_meta_caps; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
306 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
307 | + * |
|
308 | + * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
309 | + * |
|
310 | + * @since 4.5.0 |
|
311 | + * @see wp-includes/capabilities.php |
|
312 | + * |
|
313 | + * @param array $caps actual users capabilities |
|
314 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
315 | + * @param int $user_id The user id |
|
316 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
317 | + * @return array actual users capabilities |
|
318 | + * @throws EE_Error |
|
319 | + */ |
|
320 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
321 | + { |
|
322 | + if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
323 | + //loop through our _meta_caps array |
|
324 | + foreach ($this->_meta_caps as $meta_map) { |
|
325 | + if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
326 | + continue; |
|
327 | + } |
|
328 | + // don't load models if there is no object ID in the args |
|
329 | + if (! empty($args[0])) { |
|
330 | + $meta_map->ensure_is_model(); |
|
331 | + } |
|
332 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
333 | + } |
|
334 | + } |
|
335 | + return $caps; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * This sets up and returns the initial capabilities map for Event Espresso |
|
341 | + * |
|
342 | + * @since 4.5.0 |
|
343 | + * @return array |
|
344 | + */ |
|
345 | + private function _init_caps_map() |
|
346 | + { |
|
347 | + $caps = array( |
|
348 | + 'administrator' => array( |
|
349 | + //basic access |
|
350 | + 'ee_read_ee', |
|
351 | + //gateways |
|
352 | + /** |
|
353 | + * note that with payment method capabilities, although we've implemented |
|
354 | + * capability mapping which will be used for accessing payment methods owned by |
|
355 | + * other users. This is not fully implemented yet in the payment method ui. |
|
356 | + * Currently only the "plural" caps are in active use. |
|
357 | + * (Specific payment method caps are in use as well). |
|
358 | + **/ |
|
359 | + 'ee_manage_gateways', |
|
360 | + 'ee_read_payment_method', |
|
361 | + 'ee_read_payment_methods', |
|
362 | + 'ee_read_others_payment_methods', |
|
363 | + 'ee_edit_payment_method', |
|
364 | + 'ee_edit_payment_methods', |
|
365 | + 'ee_edit_others_payment_methods', |
|
366 | + 'ee_delete_payment_method', |
|
367 | + 'ee_delete_payment_methods', |
|
368 | + //events |
|
369 | + 'ee_publish_events', |
|
370 | + 'ee_read_private_events', |
|
371 | + 'ee_read_others_events', |
|
372 | + 'ee_read_event', |
|
373 | + 'ee_read_events', |
|
374 | + 'ee_edit_event', |
|
375 | + 'ee_edit_events', |
|
376 | + 'ee_edit_published_events', |
|
377 | + 'ee_edit_others_events', |
|
378 | + 'ee_edit_private_events', |
|
379 | + 'ee_delete_published_events', |
|
380 | + 'ee_delete_private_events', |
|
381 | + 'ee_delete_event', |
|
382 | + 'ee_delete_events', |
|
383 | + 'ee_delete_others_events', |
|
384 | + //event categories |
|
385 | + 'ee_manage_event_categories', |
|
386 | + 'ee_edit_event_category', |
|
387 | + 'ee_delete_event_category', |
|
388 | + 'ee_assign_event_category', |
|
389 | + //venues |
|
390 | + 'ee_publish_venues', |
|
391 | + 'ee_read_venue', |
|
392 | + 'ee_read_venues', |
|
393 | + 'ee_read_others_venues', |
|
394 | + 'ee_read_private_venues', |
|
395 | + 'ee_edit_venue', |
|
396 | + 'ee_edit_venues', |
|
397 | + 'ee_edit_others_venues', |
|
398 | + 'ee_edit_published_venues', |
|
399 | + 'ee_edit_private_venues', |
|
400 | + 'ee_delete_venue', |
|
401 | + 'ee_delete_venues', |
|
402 | + 'ee_delete_others_venues', |
|
403 | + 'ee_delete_private_venues', |
|
404 | + 'ee_delete_published_venues', |
|
405 | + //venue categories |
|
406 | + 'ee_manage_venue_categories', |
|
407 | + 'ee_edit_venue_category', |
|
408 | + 'ee_delete_venue_category', |
|
409 | + 'ee_assign_venue_category', |
|
410 | + //contacts |
|
411 | + 'ee_read_contact', |
|
412 | + 'ee_read_contacts', |
|
413 | + 'ee_edit_contact', |
|
414 | + 'ee_edit_contacts', |
|
415 | + 'ee_delete_contact', |
|
416 | + 'ee_delete_contacts', |
|
417 | + //registrations |
|
418 | + 'ee_read_registration', |
|
419 | + 'ee_read_registrations', |
|
420 | + 'ee_read_others_registrations', |
|
421 | + 'ee_edit_registration', |
|
422 | + 'ee_edit_registrations', |
|
423 | + 'ee_edit_others_registrations', |
|
424 | + 'ee_delete_registration', |
|
425 | + 'ee_delete_registrations', |
|
426 | + //checkins |
|
427 | + 'ee_read_checkin', |
|
428 | + 'ee_read_others_checkins', |
|
429 | + 'ee_read_checkins', |
|
430 | + 'ee_edit_checkin', |
|
431 | + 'ee_edit_checkins', |
|
432 | + 'ee_edit_others_checkins', |
|
433 | + 'ee_delete_checkin', |
|
434 | + 'ee_delete_checkins', |
|
435 | + 'ee_delete_others_checkins', |
|
436 | + //transactions && payments |
|
437 | + 'ee_read_transaction', |
|
438 | + 'ee_read_transactions', |
|
439 | + 'ee_edit_payments', |
|
440 | + 'ee_delete_payments', |
|
441 | + //messages |
|
442 | + 'ee_read_message', |
|
443 | + 'ee_read_messages', |
|
444 | + 'ee_read_others_messages', |
|
445 | + 'ee_read_global_messages', |
|
446 | + 'ee_edit_global_messages', |
|
447 | + 'ee_edit_message', |
|
448 | + 'ee_edit_messages', |
|
449 | + 'ee_edit_others_messages', |
|
450 | + 'ee_delete_message', |
|
451 | + 'ee_delete_messages', |
|
452 | + 'ee_delete_others_messages', |
|
453 | + 'ee_delete_global_messages', |
|
454 | + 'ee_send_message', |
|
455 | + //tickets |
|
456 | + 'ee_read_default_ticket', |
|
457 | + 'ee_read_default_tickets', |
|
458 | + 'ee_read_others_default_tickets', |
|
459 | + 'ee_edit_default_ticket', |
|
460 | + 'ee_edit_default_tickets', |
|
461 | + 'ee_edit_others_default_tickets', |
|
462 | + 'ee_delete_default_ticket', |
|
463 | + 'ee_delete_default_tickets', |
|
464 | + 'ee_delete_others_default_tickets', |
|
465 | + //prices |
|
466 | + 'ee_edit_default_price', |
|
467 | + 'ee_edit_default_prices', |
|
468 | + 'ee_delete_default_price', |
|
469 | + 'ee_delete_default_prices', |
|
470 | + 'ee_edit_default_price_type', |
|
471 | + 'ee_edit_default_price_types', |
|
472 | + 'ee_delete_default_price_type', |
|
473 | + 'ee_delete_default_price_types', |
|
474 | + 'ee_read_default_prices', |
|
475 | + 'ee_read_default_price_types', |
|
476 | + //registration form |
|
477 | + 'ee_edit_question', |
|
478 | + 'ee_edit_questions', |
|
479 | + 'ee_edit_system_questions', |
|
480 | + 'ee_read_questions', |
|
481 | + 'ee_delete_question', |
|
482 | + 'ee_delete_questions', |
|
483 | + 'ee_edit_question_group', |
|
484 | + 'ee_edit_question_groups', |
|
485 | + 'ee_read_question_groups', |
|
486 | + 'ee_edit_system_question_groups', |
|
487 | + 'ee_delete_question_group', |
|
488 | + 'ee_delete_question_groups', |
|
489 | + //event_type taxonomy |
|
490 | + 'ee_assign_event_type', |
|
491 | + 'ee_manage_event_types', |
|
492 | + 'ee_edit_event_type', |
|
493 | + 'ee_delete_event_type', |
|
494 | + ), |
|
495 | + 'ee_events_administrator' => array( |
|
496 | + //core wp caps |
|
497 | + 'read', |
|
498 | + 'read_private_pages', |
|
499 | + 'read_private_posts', |
|
500 | + 'edit_users', |
|
501 | + 'edit_posts', |
|
502 | + 'edit_pages', |
|
503 | + 'edit_published_posts', |
|
504 | + 'edit_published_pages', |
|
505 | + 'edit_private_pages', |
|
506 | + 'edit_private_posts', |
|
507 | + 'edit_others_posts', |
|
508 | + 'edit_others_pages', |
|
509 | + 'publish_posts', |
|
510 | + 'publish_pages', |
|
511 | + 'delete_posts', |
|
512 | + 'delete_pages', |
|
513 | + 'delete_private_pages', |
|
514 | + 'delete_private_posts', |
|
515 | + 'delete_published_pages', |
|
516 | + 'delete_published_posts', |
|
517 | + 'delete_others_posts', |
|
518 | + 'delete_others_pages', |
|
519 | + 'manage_categories', |
|
520 | + 'manage_links', |
|
521 | + 'moderate_comments', |
|
522 | + 'unfiltered_html', |
|
523 | + 'upload_files', |
|
524 | + 'export', |
|
525 | + 'import', |
|
526 | + 'list_users', |
|
527 | + 'level_1', //required if user with this role shows up in author dropdowns |
|
528 | + //basic ee access |
|
529 | + 'ee_read_ee', |
|
530 | + //events |
|
531 | + 'ee_publish_events', |
|
532 | + 'ee_read_private_events', |
|
533 | + 'ee_read_others_events', |
|
534 | + 'ee_read_event', |
|
535 | + 'ee_read_events', |
|
536 | + 'ee_edit_event', |
|
537 | + 'ee_edit_events', |
|
538 | + 'ee_edit_published_events', |
|
539 | + 'ee_edit_others_events', |
|
540 | + 'ee_edit_private_events', |
|
541 | + 'ee_delete_published_events', |
|
542 | + 'ee_delete_private_events', |
|
543 | + 'ee_delete_event', |
|
544 | + 'ee_delete_events', |
|
545 | + 'ee_delete_others_events', |
|
546 | + //event categories |
|
547 | + 'ee_manage_event_categories', |
|
548 | + 'ee_edit_event_category', |
|
549 | + 'ee_delete_event_category', |
|
550 | + 'ee_assign_event_category', |
|
551 | + //venues |
|
552 | + 'ee_publish_venues', |
|
553 | + 'ee_read_venue', |
|
554 | + 'ee_read_venues', |
|
555 | + 'ee_read_others_venues', |
|
556 | + 'ee_read_private_venues', |
|
557 | + 'ee_edit_venue', |
|
558 | + 'ee_edit_venues', |
|
559 | + 'ee_edit_others_venues', |
|
560 | + 'ee_edit_published_venues', |
|
561 | + 'ee_edit_private_venues', |
|
562 | + 'ee_delete_venue', |
|
563 | + 'ee_delete_venues', |
|
564 | + 'ee_delete_others_venues', |
|
565 | + 'ee_delete_private_venues', |
|
566 | + 'ee_delete_published_venues', |
|
567 | + //venue categories |
|
568 | + 'ee_manage_venue_categories', |
|
569 | + 'ee_edit_venue_category', |
|
570 | + 'ee_delete_venue_category', |
|
571 | + 'ee_assign_venue_category', |
|
572 | + //contacts |
|
573 | + 'ee_read_contact', |
|
574 | + 'ee_read_contacts', |
|
575 | + 'ee_edit_contact', |
|
576 | + 'ee_edit_contacts', |
|
577 | + 'ee_delete_contact', |
|
578 | + 'ee_delete_contacts', |
|
579 | + //registrations |
|
580 | + 'ee_read_registration', |
|
581 | + 'ee_read_registrations', |
|
582 | + 'ee_read_others_registrations', |
|
583 | + 'ee_edit_registration', |
|
584 | + 'ee_edit_registrations', |
|
585 | + 'ee_edit_others_registrations', |
|
586 | + 'ee_delete_registration', |
|
587 | + 'ee_delete_registrations', |
|
588 | + //checkins |
|
589 | + 'ee_read_checkin', |
|
590 | + 'ee_read_others_checkins', |
|
591 | + 'ee_read_checkins', |
|
592 | + 'ee_edit_checkin', |
|
593 | + 'ee_edit_checkins', |
|
594 | + 'ee_edit_others_checkins', |
|
595 | + 'ee_delete_checkin', |
|
596 | + 'ee_delete_checkins', |
|
597 | + 'ee_delete_others_checkins', |
|
598 | + //transactions && payments |
|
599 | + 'ee_read_transaction', |
|
600 | + 'ee_read_transactions', |
|
601 | + 'ee_edit_payments', |
|
602 | + 'ee_delete_payments', |
|
603 | + //messages |
|
604 | + 'ee_read_message', |
|
605 | + 'ee_read_messages', |
|
606 | + 'ee_read_others_messages', |
|
607 | + 'ee_read_global_messages', |
|
608 | + 'ee_edit_global_messages', |
|
609 | + 'ee_edit_message', |
|
610 | + 'ee_edit_messages', |
|
611 | + 'ee_edit_others_messages', |
|
612 | + 'ee_delete_message', |
|
613 | + 'ee_delete_messages', |
|
614 | + 'ee_delete_others_messages', |
|
615 | + 'ee_delete_global_messages', |
|
616 | + 'ee_send_message', |
|
617 | + //tickets |
|
618 | + 'ee_read_default_ticket', |
|
619 | + 'ee_read_default_tickets', |
|
620 | + 'ee_read_others_default_tickets', |
|
621 | + 'ee_edit_default_ticket', |
|
622 | + 'ee_edit_default_tickets', |
|
623 | + 'ee_edit_others_default_tickets', |
|
624 | + 'ee_delete_default_ticket', |
|
625 | + 'ee_delete_default_tickets', |
|
626 | + 'ee_delete_others_default_tickets', |
|
627 | + //prices |
|
628 | + 'ee_edit_default_price', |
|
629 | + 'ee_edit_default_prices', |
|
630 | + 'ee_delete_default_price', |
|
631 | + 'ee_delete_default_prices', |
|
632 | + 'ee_edit_default_price_type', |
|
633 | + 'ee_edit_default_price_types', |
|
634 | + 'ee_delete_default_price_type', |
|
635 | + 'ee_delete_default_price_types', |
|
636 | + 'ee_read_default_prices', |
|
637 | + 'ee_read_default_price_types', |
|
638 | + //registration form |
|
639 | + 'ee_edit_question', |
|
640 | + 'ee_edit_questions', |
|
641 | + 'ee_edit_system_questions', |
|
642 | + 'ee_read_questions', |
|
643 | + 'ee_delete_question', |
|
644 | + 'ee_delete_questions', |
|
645 | + 'ee_edit_question_group', |
|
646 | + 'ee_edit_question_groups', |
|
647 | + 'ee_read_question_groups', |
|
648 | + 'ee_edit_system_question_groups', |
|
649 | + 'ee_delete_question_group', |
|
650 | + 'ee_delete_question_groups', |
|
651 | + //event_type taxonomy |
|
652 | + 'ee_assign_event_type', |
|
653 | + 'ee_manage_event_types', |
|
654 | + 'ee_edit_event_type', |
|
655 | + 'ee_delete_event_type', |
|
656 | + ) |
|
657 | + ); |
|
658 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
659 | + //add payment method caps. |
|
660 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
661 | + return EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
662 | + } |
|
663 | + |
|
664 | + |
|
665 | + /** |
|
666 | + * This adds all the default caps to roles as registered in the _caps_map property. |
|
667 | + * |
|
668 | + * @since 4.5.0 |
|
669 | + * |
|
670 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
671 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
672 | + * and ensures that they are up to date. |
|
673 | + * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
674 | + * up. Note that this should ONLY be called on activation hook or some other one-time |
|
675 | + * task otherwise the caps will be added on every request. |
|
676 | + * |
|
677 | + * @return void |
|
678 | + */ |
|
679 | + public function init_role_caps($reset = false, $custom_map = array()) |
|
680 | + { |
|
681 | + //if reset, then completely delete the cache option. |
|
682 | + if ($reset) { |
|
683 | + delete_option(self::option_name); |
|
684 | + } |
|
685 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
686 | + //first let's determine if these caps have already been set. |
|
687 | + $caps_set_before = $reset ? array() : get_option(self::option_name, array()); |
|
688 | + $update_caps_set_before_option = false; |
|
689 | + //if not reset, see what caps are new for each role. if they're new, add them. |
|
690 | + foreach ($caps_map as $role => $caps_for_role) { |
|
691 | + foreach ($caps_for_role as $cap) { |
|
692 | + //first check we haven't already added this cap before, or it's a reset |
|
693 | + if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
694 | + if ($this->add_cap_to_role($role, $cap)) { |
|
695 | + $caps_set_before[ $role ][] = $cap; |
|
696 | + $update_caps_set_before_option = true; |
|
697 | + } |
|
698 | + } |
|
699 | + } |
|
700 | + } |
|
701 | + //now let's just save the cap that has been set but only if there's been a change. |
|
702 | + if ($update_caps_set_before_option) { |
|
703 | + update_option(self::option_name, $caps_set_before); |
|
704 | + } |
|
705 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
706 | + } |
|
707 | + |
|
708 | + |
|
709 | + /** |
|
710 | + * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
711 | + * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
712 | + * this is a wrapper for $wp_role->add_cap() |
|
713 | + * |
|
714 | + * @see wp-includes/capabilities.php |
|
715 | + * |
|
716 | + * @since 4.5.0 |
|
717 | + * |
|
718 | + * @param string $role A WordPress role the capability is being added to |
|
719 | + * @param string $cap The capability being added to the role |
|
720 | + * @param bool $grant Whether to grant access to this cap on this role. |
|
721 | + * |
|
722 | + * @return bool |
|
723 | + */ |
|
724 | + public function add_cap_to_role($role, $cap, $grant = true) |
|
725 | + { |
|
726 | + $role_object = get_role($role); |
|
727 | + //if the role isn't available then we create it. |
|
728 | + if (! $role_object instanceof WP_Role) { |
|
729 | + //if a plugin wants to create a specific role name then they should create the role before |
|
730 | + //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
731 | + // - removes any `ee_` namespacing from the start of the slug. |
|
732 | + // - replaces `_` with ` ` (empty space). |
|
733 | + // - sentence case on the resulting string. |
|
734 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
735 | + $role_object = add_role($role, $role_label); |
|
736 | + } |
|
737 | + if ($role_object instanceof WP_Role) { |
|
738 | + $role_object->add_cap($cap, $grant); |
|
739 | + return true; |
|
740 | + } |
|
741 | + return false; |
|
742 | + } |
|
743 | + |
|
744 | + |
|
745 | + /** |
|
746 | + * Functions similarly to add_cap_to_role except removes cap from given role. |
|
747 | + * Wrapper for $wp_role->remove_cap() |
|
748 | + * |
|
749 | + * @see wp-includes/capabilities.php |
|
750 | + * @since 4.5.0 |
|
751 | + * |
|
752 | + * @param string $role A WordPress role the capability is being removed from. |
|
753 | + * @param string $cap The capability being removed |
|
754 | + * |
|
755 | + * @return void |
|
756 | + */ |
|
757 | + public function remove_cap_from_role($role, $cap) |
|
758 | + { |
|
759 | + $role = get_role($role); |
|
760 | + if ($role instanceof WP_Role) { |
|
761 | + $role->remove_cap($cap); |
|
762 | + } |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + /** |
|
767 | + * Wrapper for the native WP current_user_can() method. |
|
768 | + * This is provided as a handy method for a couple things: |
|
769 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
770 | + * write those filters wherever current_user_can is called). |
|
771 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
772 | + * |
|
773 | + * @since 4.5.0 |
|
774 | + * |
|
775 | + * @param string $cap The cap being checked. |
|
776 | + * @param string $context The context where the current_user_can is being called from. |
|
777 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
778 | + * filters. |
|
779 | + * |
|
780 | + * @return bool Whether user can or not. |
|
781 | + */ |
|
782 | + public function current_user_can($cap, $context, $id = 0) |
|
783 | + { |
|
784 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
785 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
786 | + $filtered_cap = apply_filters( |
|
787 | + 'FHEE__EE_Capabilities__current_user_can__cap', |
|
788 | + $filtered_cap, |
|
789 | + $context, |
|
790 | + $cap, |
|
791 | + $id |
|
792 | + ); |
|
793 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
794 | + } |
|
795 | + |
|
796 | + |
|
797 | + /** |
|
798 | + * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
799 | + * |
|
800 | + * @param int|WP_User $user Either the user_id or a WP_User object |
|
801 | + * @param string $cap The capability string being checked |
|
802 | + * @param string $context The context where the user_can is being called from (used in filters). |
|
803 | + * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
804 | + * filters) |
|
805 | + * |
|
806 | + * @return bool Whether user can or not. |
|
807 | + */ |
|
808 | + public function user_can($user, $cap, $context, $id = 0) |
|
809 | + { |
|
810 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
811 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
812 | + $filtered_cap = apply_filters( |
|
813 | + 'FHEE__EE_Capabilities__user_can__cap', |
|
814 | + $filtered_cap, |
|
815 | + $context, |
|
816 | + $cap, |
|
817 | + $user, |
|
818 | + $id |
|
819 | + ); |
|
820 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
821 | + } |
|
822 | + |
|
823 | + |
|
824 | + /** |
|
825 | + * Wrapper for the native WP current_user_can_for_blog() method. |
|
826 | + * This is provided as a handy method for a couple things: |
|
827 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
828 | + * write those filters wherever current_user_can is called). |
|
829 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
830 | + * |
|
831 | + * @since 4.5.0 |
|
832 | + * |
|
833 | + * @param int $blog_id The blog id that is being checked for. |
|
834 | + * @param string $cap The cap being checked. |
|
835 | + * @param string $context The context where the current_user_can is being called from. |
|
836 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
837 | + * filters. |
|
838 | + * |
|
839 | + * @return bool Whether user can or not. |
|
840 | + */ |
|
841 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
842 | + { |
|
843 | + $user_can = ! empty($id) |
|
844 | + ? current_user_can_for_blog($blog_id, $cap, $id) |
|
845 | + : current_user_can($blog_id, $cap); |
|
846 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
847 | + $user_can = apply_filters( |
|
848 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
849 | + $user_can, |
|
850 | + $blog_id, |
|
851 | + $cap, |
|
852 | + $id |
|
853 | + ); |
|
854 | + $user_can = apply_filters( |
|
855 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
856 | + $user_can, |
|
857 | + $context, |
|
858 | + $blog_id, |
|
859 | + $cap, |
|
860 | + $id |
|
861 | + ); |
|
862 | + return $user_can; |
|
863 | + } |
|
864 | + |
|
865 | + |
|
866 | + /** |
|
867 | + * This helper method just returns an array of registered EE capabilities. |
|
868 | + * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
869 | + * role. |
|
870 | + * |
|
871 | + * @since 4.5.0 |
|
872 | + * |
|
873 | + * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
874 | + * for the given role are returned. |
|
875 | + * |
|
876 | + * @return array |
|
877 | + */ |
|
878 | + public function get_ee_capabilities($role = 'administrator') |
|
879 | + { |
|
880 | + $capabilities = $this->_init_caps_map(); |
|
881 | + if (empty($role)) { |
|
882 | + return $capabilities; |
|
883 | + } |
|
884 | + return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
885 | + } |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | |
@@ -899,142 +899,142 @@ discard block |
||
899 | 899 | abstract class EE_Meta_Capability_Map |
900 | 900 | { |
901 | 901 | |
902 | - public $meta_cap; |
|
903 | - |
|
904 | - /** |
|
905 | - * @var EEM_Base |
|
906 | - */ |
|
907 | - protected $_model; |
|
908 | - |
|
909 | - protected $_model_name; |
|
910 | - |
|
911 | - public $published_cap = ''; |
|
912 | - |
|
913 | - public $others_cap = ''; |
|
914 | - |
|
915 | - public $private_cap = ''; |
|
916 | - |
|
917 | - |
|
918 | - /** |
|
919 | - * constructor. |
|
920 | - * Receives the setup arguments for the map. |
|
921 | - * |
|
922 | - * @since 4.5.0 |
|
923 | - * |
|
924 | - * @param string $meta_cap What meta capability is this mapping. |
|
925 | - * @param array $map_values array { |
|
926 | - * //array of values that MUST match a count of 4. It's okay to send an empty string for |
|
927 | - * capabilities that don't get mapped to. |
|
928 | - * |
|
929 | - * @type $map_values [0] string A string representing the model name. Required. String's |
|
930 | - * should always be used when Menu Maps are registered via the |
|
931 | - * plugin API as models are not allowed to be instantiated when |
|
932 | - * in maintenance mode 2 (migrations). |
|
933 | - * @type $map_values [1] string represents the capability used for published. Optional. |
|
934 | - * @type $map_values [2] string represents the capability used for "others". Optional. |
|
935 | - * @type $map_values [3] string represents the capability used for private. Optional. |
|
936 | - * } |
|
937 | - * @throws EE_Error |
|
938 | - */ |
|
939 | - public function __construct($meta_cap, $map_values) |
|
940 | - { |
|
941 | - $this->meta_cap = $meta_cap; |
|
942 | - //verify there are four args in the $map_values array; |
|
943 | - if (count($map_values) !== 4) { |
|
944 | - throw new EE_Error( |
|
945 | - sprintf( |
|
946 | - esc_html__( |
|
947 | - 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
948 | - 'event_espresso' |
|
949 | - ), |
|
950 | - '<br>' . print_r($map_values, true) |
|
951 | - ) |
|
952 | - ); |
|
953 | - } |
|
954 | - //set properties |
|
955 | - $this->_model = null; |
|
956 | - $this->_model_name = $map_values[0]; |
|
957 | - $this->published_cap = (string)$map_values[1]; |
|
958 | - $this->others_cap = (string)$map_values[2]; |
|
959 | - $this->private_cap = (string)$map_values[3]; |
|
960 | - } |
|
961 | - |
|
962 | - /** |
|
963 | - * Makes it so this object stops filtering caps |
|
964 | - */ |
|
965 | - public function remove_filters() |
|
966 | - { |
|
967 | - remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
968 | - } |
|
969 | - |
|
970 | - |
|
971 | - /** |
|
972 | - * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
973 | - * |
|
974 | - * @since 4.5.0 |
|
975 | - * @throws EE_Error |
|
976 | - * |
|
977 | - * @return void |
|
978 | - */ |
|
979 | - public function ensure_is_model() |
|
980 | - { |
|
981 | - //is it already instantiated? |
|
982 | - if ($this->_model instanceof EEM_Base) { |
|
983 | - return; |
|
984 | - } |
|
985 | - //ensure model name is string |
|
986 | - $this->_model_name = (string)$this->_model_name; |
|
987 | - //error proof if the name has EEM in it |
|
988 | - $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
989 | - $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
990 | - if (! $this->_model instanceof EEM_Base) { |
|
991 | - throw new EE_Error( |
|
992 | - sprintf( |
|
993 | - esc_html__( |
|
994 | - 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
995 | - 'event_espresso' |
|
996 | - ), |
|
997 | - get_class($this), |
|
998 | - $this->_model |
|
999 | - ) |
|
1000 | - ); |
|
1001 | - } |
|
1002 | - } |
|
1003 | - |
|
1004 | - |
|
1005 | - /** |
|
1006 | - * |
|
1007 | - * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
1008 | - * @since 4.6.x |
|
1009 | - * |
|
1010 | - * @param $caps |
|
1011 | - * @param $cap |
|
1012 | - * @param $user_id |
|
1013 | - * @param $args |
|
1014 | - * |
|
1015 | - * @return array |
|
1016 | - */ |
|
1017 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
1018 | - { |
|
1019 | - return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
1020 | - } |
|
1021 | - |
|
1022 | - |
|
1023 | - /** |
|
1024 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1025 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1026 | - * |
|
1027 | - * @since 4.5.0 |
|
1028 | - * @see wp-includes/capabilities.php |
|
1029 | - * |
|
1030 | - * @param array $caps actual users capabilities |
|
1031 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1032 | - * @param int $user_id The user id |
|
1033 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1034 | - * |
|
1035 | - * @return array actual users capabilities |
|
1036 | - */ |
|
1037 | - abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
902 | + public $meta_cap; |
|
903 | + |
|
904 | + /** |
|
905 | + * @var EEM_Base |
|
906 | + */ |
|
907 | + protected $_model; |
|
908 | + |
|
909 | + protected $_model_name; |
|
910 | + |
|
911 | + public $published_cap = ''; |
|
912 | + |
|
913 | + public $others_cap = ''; |
|
914 | + |
|
915 | + public $private_cap = ''; |
|
916 | + |
|
917 | + |
|
918 | + /** |
|
919 | + * constructor. |
|
920 | + * Receives the setup arguments for the map. |
|
921 | + * |
|
922 | + * @since 4.5.0 |
|
923 | + * |
|
924 | + * @param string $meta_cap What meta capability is this mapping. |
|
925 | + * @param array $map_values array { |
|
926 | + * //array of values that MUST match a count of 4. It's okay to send an empty string for |
|
927 | + * capabilities that don't get mapped to. |
|
928 | + * |
|
929 | + * @type $map_values [0] string A string representing the model name. Required. String's |
|
930 | + * should always be used when Menu Maps are registered via the |
|
931 | + * plugin API as models are not allowed to be instantiated when |
|
932 | + * in maintenance mode 2 (migrations). |
|
933 | + * @type $map_values [1] string represents the capability used for published. Optional. |
|
934 | + * @type $map_values [2] string represents the capability used for "others". Optional. |
|
935 | + * @type $map_values [3] string represents the capability used for private. Optional. |
|
936 | + * } |
|
937 | + * @throws EE_Error |
|
938 | + */ |
|
939 | + public function __construct($meta_cap, $map_values) |
|
940 | + { |
|
941 | + $this->meta_cap = $meta_cap; |
|
942 | + //verify there are four args in the $map_values array; |
|
943 | + if (count($map_values) !== 4) { |
|
944 | + throw new EE_Error( |
|
945 | + sprintf( |
|
946 | + esc_html__( |
|
947 | + 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
948 | + 'event_espresso' |
|
949 | + ), |
|
950 | + '<br>' . print_r($map_values, true) |
|
951 | + ) |
|
952 | + ); |
|
953 | + } |
|
954 | + //set properties |
|
955 | + $this->_model = null; |
|
956 | + $this->_model_name = $map_values[0]; |
|
957 | + $this->published_cap = (string)$map_values[1]; |
|
958 | + $this->others_cap = (string)$map_values[2]; |
|
959 | + $this->private_cap = (string)$map_values[3]; |
|
960 | + } |
|
961 | + |
|
962 | + /** |
|
963 | + * Makes it so this object stops filtering caps |
|
964 | + */ |
|
965 | + public function remove_filters() |
|
966 | + { |
|
967 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
968 | + } |
|
969 | + |
|
970 | + |
|
971 | + /** |
|
972 | + * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
973 | + * |
|
974 | + * @since 4.5.0 |
|
975 | + * @throws EE_Error |
|
976 | + * |
|
977 | + * @return void |
|
978 | + */ |
|
979 | + public function ensure_is_model() |
|
980 | + { |
|
981 | + //is it already instantiated? |
|
982 | + if ($this->_model instanceof EEM_Base) { |
|
983 | + return; |
|
984 | + } |
|
985 | + //ensure model name is string |
|
986 | + $this->_model_name = (string)$this->_model_name; |
|
987 | + //error proof if the name has EEM in it |
|
988 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
989 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
990 | + if (! $this->_model instanceof EEM_Base) { |
|
991 | + throw new EE_Error( |
|
992 | + sprintf( |
|
993 | + esc_html__( |
|
994 | + 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
995 | + 'event_espresso' |
|
996 | + ), |
|
997 | + get_class($this), |
|
998 | + $this->_model |
|
999 | + ) |
|
1000 | + ); |
|
1001 | + } |
|
1002 | + } |
|
1003 | + |
|
1004 | + |
|
1005 | + /** |
|
1006 | + * |
|
1007 | + * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
1008 | + * @since 4.6.x |
|
1009 | + * |
|
1010 | + * @param $caps |
|
1011 | + * @param $cap |
|
1012 | + * @param $user_id |
|
1013 | + * @param $args |
|
1014 | + * |
|
1015 | + * @return array |
|
1016 | + */ |
|
1017 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
1018 | + { |
|
1019 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
1020 | + } |
|
1021 | + |
|
1022 | + |
|
1023 | + /** |
|
1024 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1025 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1026 | + * |
|
1027 | + * @since 4.5.0 |
|
1028 | + * @see wp-includes/capabilities.php |
|
1029 | + * |
|
1030 | + * @param array $caps actual users capabilities |
|
1031 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1032 | + * @param int $user_id The user id |
|
1033 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1034 | + * |
|
1035 | + * @return array actual users capabilities |
|
1036 | + */ |
|
1037 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
@@ -1050,83 +1050,83 @@ discard block |
||
1050 | 1050 | class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map |
1051 | 1051 | { |
1052 | 1052 | |
1053 | - /** |
|
1054 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1055 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1056 | - * |
|
1057 | - * @since 4.5.0 |
|
1058 | - * @see wp-includes/capabilities.php |
|
1059 | - * |
|
1060 | - * @param array $caps actual users capabilities |
|
1061 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1062 | - * @param int $user_id The user id |
|
1063 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1064 | - * |
|
1065 | - * @return array actual users capabilities |
|
1066 | - */ |
|
1067 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1068 | - { |
|
1069 | - //only process if we're checking our mapped_cap |
|
1070 | - if ($cap !== $this->meta_cap) { |
|
1071 | - return $caps; |
|
1072 | - } |
|
1073 | - |
|
1074 | - //cast $user_id to int for later explicit comparisons |
|
1075 | - $user_id = (int) $user_id; |
|
1076 | - |
|
1077 | - /** @var EE_Base_Class $obj */ |
|
1078 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1079 | - //if no obj then let's just do cap |
|
1080 | - if (! $obj instanceof EE_Base_Class) { |
|
1081 | - $caps[] = $cap; |
|
1082 | - return $caps; |
|
1083 | - } |
|
1084 | - if ($obj instanceof EE_CPT_Base) { |
|
1085 | - //if the item author is set and the user is the author... |
|
1086 | - if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1087 | - if (empty($this->published_cap)) { |
|
1088 | - $caps[] = $cap; |
|
1089 | - } else { |
|
1090 | - //if obj is published... |
|
1091 | - if ($obj->status() === 'publish') { |
|
1092 | - $caps[] = $this->published_cap; |
|
1093 | - } else { |
|
1094 | - $caps[] = $cap; |
|
1095 | - } |
|
1096 | - } |
|
1097 | - } else { |
|
1098 | - //the user is trying to edit someone else's obj |
|
1099 | - if (! empty($this->others_cap)) { |
|
1100 | - $caps[] = $this->others_cap; |
|
1101 | - } |
|
1102 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1103 | - $caps[] = $this->published_cap; |
|
1104 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1105 | - $caps[] = $this->private_cap; |
|
1106 | - } |
|
1107 | - } |
|
1108 | - } else { |
|
1109 | - //not a cpt object so handled differently |
|
1110 | - $has_cap = false; |
|
1111 | - try { |
|
1112 | - $has_cap = method_exists($obj, 'wp_user') |
|
1113 | - && $obj->wp_user() |
|
1114 | - && $obj->wp_user() === $user_id; |
|
1115 | - } catch (Exception $e) { |
|
1116 | - if (WP_DEBUG) { |
|
1117 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1118 | - } |
|
1119 | - } |
|
1120 | - if ($has_cap) { |
|
1121 | - $caps[] = $cap; |
|
1122 | - } else { |
|
1123 | - if (! empty($this->others_cap)) { |
|
1124 | - $caps[] = $this->others_cap; |
|
1125 | - } |
|
1126 | - } |
|
1127 | - } |
|
1128 | - return $caps; |
|
1129 | - } |
|
1053 | + /** |
|
1054 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1055 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1056 | + * |
|
1057 | + * @since 4.5.0 |
|
1058 | + * @see wp-includes/capabilities.php |
|
1059 | + * |
|
1060 | + * @param array $caps actual users capabilities |
|
1061 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1062 | + * @param int $user_id The user id |
|
1063 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1064 | + * |
|
1065 | + * @return array actual users capabilities |
|
1066 | + */ |
|
1067 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1068 | + { |
|
1069 | + //only process if we're checking our mapped_cap |
|
1070 | + if ($cap !== $this->meta_cap) { |
|
1071 | + return $caps; |
|
1072 | + } |
|
1073 | + |
|
1074 | + //cast $user_id to int for later explicit comparisons |
|
1075 | + $user_id = (int) $user_id; |
|
1076 | + |
|
1077 | + /** @var EE_Base_Class $obj */ |
|
1078 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1079 | + //if no obj then let's just do cap |
|
1080 | + if (! $obj instanceof EE_Base_Class) { |
|
1081 | + $caps[] = $cap; |
|
1082 | + return $caps; |
|
1083 | + } |
|
1084 | + if ($obj instanceof EE_CPT_Base) { |
|
1085 | + //if the item author is set and the user is the author... |
|
1086 | + if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1087 | + if (empty($this->published_cap)) { |
|
1088 | + $caps[] = $cap; |
|
1089 | + } else { |
|
1090 | + //if obj is published... |
|
1091 | + if ($obj->status() === 'publish') { |
|
1092 | + $caps[] = $this->published_cap; |
|
1093 | + } else { |
|
1094 | + $caps[] = $cap; |
|
1095 | + } |
|
1096 | + } |
|
1097 | + } else { |
|
1098 | + //the user is trying to edit someone else's obj |
|
1099 | + if (! empty($this->others_cap)) { |
|
1100 | + $caps[] = $this->others_cap; |
|
1101 | + } |
|
1102 | + if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1103 | + $caps[] = $this->published_cap; |
|
1104 | + } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1105 | + $caps[] = $this->private_cap; |
|
1106 | + } |
|
1107 | + } |
|
1108 | + } else { |
|
1109 | + //not a cpt object so handled differently |
|
1110 | + $has_cap = false; |
|
1111 | + try { |
|
1112 | + $has_cap = method_exists($obj, 'wp_user') |
|
1113 | + && $obj->wp_user() |
|
1114 | + && $obj->wp_user() === $user_id; |
|
1115 | + } catch (Exception $e) { |
|
1116 | + if (WP_DEBUG) { |
|
1117 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1118 | + } |
|
1119 | + } |
|
1120 | + if ($has_cap) { |
|
1121 | + $caps[] = $cap; |
|
1122 | + } else { |
|
1123 | + if (! empty($this->others_cap)) { |
|
1124 | + $caps[] = $this->others_cap; |
|
1125 | + } |
|
1126 | + } |
|
1127 | + } |
|
1128 | + return $caps; |
|
1129 | + } |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | |
@@ -1143,24 +1143,24 @@ discard block |
||
1143 | 1143 | class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit |
1144 | 1144 | { |
1145 | 1145 | |
1146 | - /** |
|
1147 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1148 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1149 | - * |
|
1150 | - * @since 4.5.0 |
|
1151 | - * @see wp-includes/capabilities.php |
|
1152 | - * |
|
1153 | - * @param array $caps actual users capabilities |
|
1154 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1155 | - * @param int $user_id The user id |
|
1156 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1157 | - * |
|
1158 | - * @return array actual users capabilities |
|
1159 | - */ |
|
1160 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1161 | - { |
|
1162 | - return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1163 | - } |
|
1146 | + /** |
|
1147 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1148 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1149 | + * |
|
1150 | + * @since 4.5.0 |
|
1151 | + * @see wp-includes/capabilities.php |
|
1152 | + * |
|
1153 | + * @param array $caps actual users capabilities |
|
1154 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1155 | + * @param int $user_id The user id |
|
1156 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1157 | + * |
|
1158 | + * @return array actual users capabilities |
|
1159 | + */ |
|
1160 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1161 | + { |
|
1162 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1163 | + } |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1176,77 +1176,77 @@ discard block |
||
1176 | 1176 | class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map |
1177 | 1177 | { |
1178 | 1178 | |
1179 | - /** |
|
1180 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1181 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1182 | - * |
|
1183 | - * @since 4.5.0 |
|
1184 | - * @see wp-includes/capabilities.php |
|
1185 | - * |
|
1186 | - * @param array $caps actual users capabilities |
|
1187 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1188 | - * @param int $user_id The user id |
|
1189 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1190 | - * |
|
1191 | - * @return array actual users capabilities |
|
1192 | - */ |
|
1193 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1194 | - { |
|
1195 | - //only process if we're checking our mapped cap; |
|
1196 | - if ($cap !== $this->meta_cap) { |
|
1197 | - return $caps; |
|
1198 | - } |
|
1199 | - |
|
1200 | - //cast $user_id to int for later explicit comparisons |
|
1201 | - $user_id = (int) $user_id; |
|
1202 | - |
|
1203 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1204 | - //if no obj then let's just do cap |
|
1205 | - if (! $obj instanceof EE_Base_Class) { |
|
1206 | - $caps[] = $cap; |
|
1207 | - return $caps; |
|
1208 | - } |
|
1209 | - if ($obj instanceof EE_CPT_Base) { |
|
1210 | - $status_obj = get_post_status_object($obj->status()); |
|
1211 | - if ($status_obj->public) { |
|
1212 | - $caps[] = $cap; |
|
1213 | - return $caps; |
|
1214 | - } |
|
1215 | - //if the item author is set and the user is the author... |
|
1216 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1217 | - $caps[] = $cap; |
|
1218 | - } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1219 | - //the user is trying to view someone else's obj |
|
1220 | - $caps[] = $this->private_cap; |
|
1221 | - } elseif (! empty($this->others_cap)) { |
|
1222 | - $caps[] = $this->others_cap; |
|
1223 | - } else { |
|
1224 | - $caps[] = $cap; |
|
1225 | - } |
|
1226 | - } else { |
|
1227 | - //not a cpt object so handled differently |
|
1228 | - $has_cap = false; |
|
1229 | - try { |
|
1230 | - $has_cap = method_exists($obj, 'wp_user') |
|
1231 | - && $obj->wp_user() |
|
1232 | - && $obj->wp_user() === $user_id; |
|
1233 | - } catch (Exception $e) { |
|
1234 | - if (WP_DEBUG) { |
|
1235 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1236 | - } |
|
1237 | - } |
|
1238 | - if ($has_cap) { |
|
1239 | - $caps[] = $cap; |
|
1240 | - } elseif (! empty($this->private_cap)) { |
|
1241 | - $caps[] = $this->private_cap; |
|
1242 | - } elseif (! empty($this->others_cap)) { |
|
1243 | - $caps[] = $this->others_cap; |
|
1244 | - } else { |
|
1245 | - $caps[] = $cap; |
|
1246 | - } |
|
1247 | - } |
|
1248 | - return $caps; |
|
1249 | - } |
|
1179 | + /** |
|
1180 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1181 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1182 | + * |
|
1183 | + * @since 4.5.0 |
|
1184 | + * @see wp-includes/capabilities.php |
|
1185 | + * |
|
1186 | + * @param array $caps actual users capabilities |
|
1187 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1188 | + * @param int $user_id The user id |
|
1189 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1190 | + * |
|
1191 | + * @return array actual users capabilities |
|
1192 | + */ |
|
1193 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1194 | + { |
|
1195 | + //only process if we're checking our mapped cap; |
|
1196 | + if ($cap !== $this->meta_cap) { |
|
1197 | + return $caps; |
|
1198 | + } |
|
1199 | + |
|
1200 | + //cast $user_id to int for later explicit comparisons |
|
1201 | + $user_id = (int) $user_id; |
|
1202 | + |
|
1203 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1204 | + //if no obj then let's just do cap |
|
1205 | + if (! $obj instanceof EE_Base_Class) { |
|
1206 | + $caps[] = $cap; |
|
1207 | + return $caps; |
|
1208 | + } |
|
1209 | + if ($obj instanceof EE_CPT_Base) { |
|
1210 | + $status_obj = get_post_status_object($obj->status()); |
|
1211 | + if ($status_obj->public) { |
|
1212 | + $caps[] = $cap; |
|
1213 | + return $caps; |
|
1214 | + } |
|
1215 | + //if the item author is set and the user is the author... |
|
1216 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1217 | + $caps[] = $cap; |
|
1218 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1219 | + //the user is trying to view someone else's obj |
|
1220 | + $caps[] = $this->private_cap; |
|
1221 | + } elseif (! empty($this->others_cap)) { |
|
1222 | + $caps[] = $this->others_cap; |
|
1223 | + } else { |
|
1224 | + $caps[] = $cap; |
|
1225 | + } |
|
1226 | + } else { |
|
1227 | + //not a cpt object so handled differently |
|
1228 | + $has_cap = false; |
|
1229 | + try { |
|
1230 | + $has_cap = method_exists($obj, 'wp_user') |
|
1231 | + && $obj->wp_user() |
|
1232 | + && $obj->wp_user() === $user_id; |
|
1233 | + } catch (Exception $e) { |
|
1234 | + if (WP_DEBUG) { |
|
1235 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1236 | + } |
|
1237 | + } |
|
1238 | + if ($has_cap) { |
|
1239 | + $caps[] = $cap; |
|
1240 | + } elseif (! empty($this->private_cap)) { |
|
1241 | + $caps[] = $this->private_cap; |
|
1242 | + } elseif (! empty($this->others_cap)) { |
|
1243 | + $caps[] = $this->others_cap; |
|
1244 | + } else { |
|
1245 | + $caps[] = $cap; |
|
1246 | + } |
|
1247 | + } |
|
1248 | + return $caps; |
|
1249 | + } |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | |
@@ -1263,52 +1263,52 @@ discard block |
||
1263 | 1263 | class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map |
1264 | 1264 | { |
1265 | 1265 | |
1266 | - /** |
|
1267 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1268 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1269 | - * |
|
1270 | - * @since 4.5.0 |
|
1271 | - * @see wp-includes/capabilities.php |
|
1272 | - * |
|
1273 | - * @param array $caps actual users capabilities |
|
1274 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1275 | - * @param int $user_id The user id |
|
1276 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1277 | - * |
|
1278 | - * @return array actual users capabilities |
|
1279 | - */ |
|
1280 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1281 | - { |
|
1282 | - //only process if we're checking our mapped_cap |
|
1283 | - if ($cap !== $this->meta_cap) { |
|
1284 | - return $caps; |
|
1285 | - } |
|
1286 | - |
|
1287 | - //cast $user_id to int for later explicit comparisons |
|
1288 | - $user_id = (int) $user_id; |
|
1289 | - |
|
1290 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1291 | - //if no obj then let's just do cap |
|
1292 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1293 | - $caps[] = $cap; |
|
1294 | - return $caps; |
|
1295 | - } |
|
1296 | - $is_global = $obj->is_global(); |
|
1297 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1298 | - if ($is_global) { |
|
1299 | - $caps[] = $this->private_cap; |
|
1300 | - } else { |
|
1301 | - $caps[] = $cap; |
|
1302 | - } |
|
1303 | - } else { |
|
1304 | - if ($is_global) { |
|
1305 | - $caps[] = $this->private_cap; |
|
1306 | - } else { |
|
1307 | - $caps[] = $this->others_cap; |
|
1308 | - } |
|
1309 | - } |
|
1310 | - return $caps; |
|
1311 | - } |
|
1266 | + /** |
|
1267 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1268 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1269 | + * |
|
1270 | + * @since 4.5.0 |
|
1271 | + * @see wp-includes/capabilities.php |
|
1272 | + * |
|
1273 | + * @param array $caps actual users capabilities |
|
1274 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1275 | + * @param int $user_id The user id |
|
1276 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1277 | + * |
|
1278 | + * @return array actual users capabilities |
|
1279 | + */ |
|
1280 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1281 | + { |
|
1282 | + //only process if we're checking our mapped_cap |
|
1283 | + if ($cap !== $this->meta_cap) { |
|
1284 | + return $caps; |
|
1285 | + } |
|
1286 | + |
|
1287 | + //cast $user_id to int for later explicit comparisons |
|
1288 | + $user_id = (int) $user_id; |
|
1289 | + |
|
1290 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1291 | + //if no obj then let's just do cap |
|
1292 | + if (! $obj instanceof EE_Message_Template_Group) { |
|
1293 | + $caps[] = $cap; |
|
1294 | + return $caps; |
|
1295 | + } |
|
1296 | + $is_global = $obj->is_global(); |
|
1297 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1298 | + if ($is_global) { |
|
1299 | + $caps[] = $this->private_cap; |
|
1300 | + } else { |
|
1301 | + $caps[] = $cap; |
|
1302 | + } |
|
1303 | + } else { |
|
1304 | + if ($is_global) { |
|
1305 | + $caps[] = $this->private_cap; |
|
1306 | + } else { |
|
1307 | + $caps[] = $this->others_cap; |
|
1308 | + } |
|
1309 | + } |
|
1310 | + return $caps; |
|
1311 | + } |
|
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | |
@@ -1325,41 +1325,41 @@ discard block |
||
1325 | 1325 | class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map |
1326 | 1326 | { |
1327 | 1327 | |
1328 | - /** |
|
1329 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1330 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1331 | - * |
|
1332 | - * @since 4.5.0 |
|
1333 | - * @see wp-includes/capabilities.php |
|
1334 | - * |
|
1335 | - * @param array $caps actual users capabilities |
|
1336 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1337 | - * @param int $user_id The user id |
|
1338 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1339 | - * |
|
1340 | - * @return array actual users capabilities |
|
1341 | - */ |
|
1342 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1343 | - { |
|
1344 | - //only process if we're checking our mapped_cap |
|
1345 | - if ($cap !== $this->meta_cap) { |
|
1346 | - return $caps; |
|
1347 | - } |
|
1348 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1349 | - //if no obj then let's just do cap |
|
1350 | - if (! $obj instanceof EE_Base_Class) { |
|
1351 | - $caps[] = $cap; |
|
1352 | - return $caps; |
|
1353 | - } |
|
1354 | - $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1355 | - $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1356 | - if ($is_system) { |
|
1357 | - $caps[] = $this->private_cap; |
|
1358 | - } else { |
|
1359 | - $caps[] = $cap; |
|
1360 | - } |
|
1361 | - return $caps; |
|
1362 | - } |
|
1328 | + /** |
|
1329 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1330 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1331 | + * |
|
1332 | + * @since 4.5.0 |
|
1333 | + * @see wp-includes/capabilities.php |
|
1334 | + * |
|
1335 | + * @param array $caps actual users capabilities |
|
1336 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1337 | + * @param int $user_id The user id |
|
1338 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1339 | + * |
|
1340 | + * @return array actual users capabilities |
|
1341 | + */ |
|
1342 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1343 | + { |
|
1344 | + //only process if we're checking our mapped_cap |
|
1345 | + if ($cap !== $this->meta_cap) { |
|
1346 | + return $caps; |
|
1347 | + } |
|
1348 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1349 | + //if no obj then let's just do cap |
|
1350 | + if (! $obj instanceof EE_Base_Class) { |
|
1351 | + $caps[] = $cap; |
|
1352 | + return $caps; |
|
1353 | + } |
|
1354 | + $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1355 | + $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1356 | + if ($is_system) { |
|
1357 | + $caps[] = $this->private_cap; |
|
1358 | + } else { |
|
1359 | + $caps[] = $cap; |
|
1360 | + } |
|
1361 | + return $caps; |
|
1362 | + } |
|
1363 | 1363 | |
1364 | 1364 | |
1365 | 1365 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public static function instance() |
70 | 70 | { |
71 | 71 | //check if instantiated, and if not do so. |
72 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
72 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | } |
75 | 75 | return self::$_instance; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function init_cap_logic($reset = false) |
124 | 124 | { |
125 | - if (! did_action('AHEE__EE_Capabilities__init_caps__before_init_cap_logic_call')) { |
|
125 | + if ( ! did_action('AHEE__EE_Capabilities__init_caps__before_init_cap_logic_call')) { |
|
126 | 126 | throw new InvalidExecutionPathException( |
127 | 127 | esc_html__( |
128 | 128 | '%1$s should not be called before the %2$s hook has fired. It is recommended to instead use %s', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ) |
131 | 131 | ); |
132 | 132 | } |
133 | - if (! $this->has_been_initialized($reset)) { |
|
133 | + if ( ! $this->has_been_initialized($reset)) { |
|
134 | 134 | $this->_caps_map = $this->_init_caps_map(); |
135 | 135 | $this->init_role_caps($reset); |
136 | 136 | $this->_set_meta_caps(); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
164 | 164 | $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
165 | 165 | //add filter for map_meta_caps but only if models can query. |
166 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
166 | + if ( ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
167 | 167 | add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
168 | 168 | } |
169 | 169 | } |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
323 | 323 | //loop through our _meta_caps array |
324 | 324 | foreach ($this->_meta_caps as $meta_map) { |
325 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
325 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
326 | 326 | continue; |
327 | 327 | } |
328 | 328 | // don't load models if there is no object ID in the args |
329 | - if (! empty($args[0])) { |
|
329 | + if ( ! empty($args[0])) { |
|
330 | 330 | $meta_map->ensure_is_model(); |
331 | 331 | } |
332 | 332 | $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
@@ -690,9 +690,9 @@ discard block |
||
690 | 690 | foreach ($caps_map as $role => $caps_for_role) { |
691 | 691 | foreach ($caps_for_role as $cap) { |
692 | 692 | //first check we haven't already added this cap before, or it's a reset |
693 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
693 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
694 | 694 | if ($this->add_cap_to_role($role, $cap)) { |
695 | - $caps_set_before[ $role ][] = $cap; |
|
695 | + $caps_set_before[$role][] = $cap; |
|
696 | 696 | $update_caps_set_before_option = true; |
697 | 697 | } |
698 | 698 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | { |
726 | 726 | $role_object = get_role($role); |
727 | 727 | //if the role isn't available then we create it. |
728 | - if (! $role_object instanceof WP_Role) { |
|
728 | + if ( ! $role_object instanceof WP_Role) { |
|
729 | 729 | //if a plugin wants to create a specific role name then they should create the role before |
730 | 730 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
731 | 731 | // - removes any `ee_` namespacing from the start of the slug. |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | public function current_user_can($cap, $context, $id = 0) |
783 | 783 | { |
784 | 784 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
785 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
785 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
786 | 786 | $filtered_cap = apply_filters( |
787 | 787 | 'FHEE__EE_Capabilities__current_user_can__cap', |
788 | 788 | $filtered_cap, |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | public function user_can($user, $cap, $context, $id = 0) |
809 | 809 | { |
810 | 810 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
811 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
811 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
812 | 812 | $filtered_cap = apply_filters( |
813 | 813 | 'FHEE__EE_Capabilities__user_can__cap', |
814 | 814 | $filtered_cap, |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | : current_user_can($blog_id, $cap); |
846 | 846 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
847 | 847 | $user_can = apply_filters( |
848 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
848 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, |
|
849 | 849 | $user_can, |
850 | 850 | $blog_id, |
851 | 851 | $cap, |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | if (empty($role)) { |
882 | 882 | return $capabilities; |
883 | 883 | } |
884 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
884 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | |
@@ -947,16 +947,16 @@ discard block |
||
947 | 947 | 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
948 | 948 | 'event_espresso' |
949 | 949 | ), |
950 | - '<br>' . print_r($map_values, true) |
|
950 | + '<br>'.print_r($map_values, true) |
|
951 | 951 | ) |
952 | 952 | ); |
953 | 953 | } |
954 | 954 | //set properties |
955 | 955 | $this->_model = null; |
956 | 956 | $this->_model_name = $map_values[0]; |
957 | - $this->published_cap = (string)$map_values[1]; |
|
958 | - $this->others_cap = (string)$map_values[2]; |
|
959 | - $this->private_cap = (string)$map_values[3]; |
|
957 | + $this->published_cap = (string) $map_values[1]; |
|
958 | + $this->others_cap = (string) $map_values[2]; |
|
959 | + $this->private_cap = (string) $map_values[3]; |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | /** |
@@ -983,11 +983,11 @@ discard block |
||
983 | 983 | return; |
984 | 984 | } |
985 | 985 | //ensure model name is string |
986 | - $this->_model_name = (string)$this->_model_name; |
|
986 | + $this->_model_name = (string) $this->_model_name; |
|
987 | 987 | //error proof if the name has EEM in it |
988 | 988 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
989 | 989 | $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
990 | - if (! $this->_model instanceof EEM_Base) { |
|
990 | + if ( ! $this->_model instanceof EEM_Base) { |
|
991 | 991 | throw new EE_Error( |
992 | 992 | sprintf( |
993 | 993 | esc_html__( |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | /** @var EE_Base_Class $obj */ |
1078 | 1078 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1079 | 1079 | //if no obj then let's just do cap |
1080 | - if (! $obj instanceof EE_Base_Class) { |
|
1080 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1081 | 1081 | $caps[] = $cap; |
1082 | 1082 | return $caps; |
1083 | 1083 | } |
@@ -1096,12 +1096,12 @@ discard block |
||
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | 1098 | //the user is trying to edit someone else's obj |
1099 | - if (! empty($this->others_cap)) { |
|
1099 | + if ( ! empty($this->others_cap)) { |
|
1100 | 1100 | $caps[] = $this->others_cap; |
1101 | 1101 | } |
1102 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1102 | + if ( ! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1103 | 1103 | $caps[] = $this->published_cap; |
1104 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1104 | + } elseif ( ! empty($this->private_cap) && $obj->status() === 'private') { |
|
1105 | 1105 | $caps[] = $this->private_cap; |
1106 | 1106 | } |
1107 | 1107 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | if ($has_cap) { |
1121 | 1121 | $caps[] = $cap; |
1122 | 1122 | } else { |
1123 | - if (! empty($this->others_cap)) { |
|
1123 | + if ( ! empty($this->others_cap)) { |
|
1124 | 1124 | $caps[] = $this->others_cap; |
1125 | 1125 | } |
1126 | 1126 | } |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | |
1203 | 1203 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1204 | 1204 | //if no obj then let's just do cap |
1205 | - if (! $obj instanceof EE_Base_Class) { |
|
1205 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1206 | 1206 | $caps[] = $cap; |
1207 | 1207 | return $caps; |
1208 | 1208 | } |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | } elseif ($status_obj->private && ! empty($this->private_cap)) { |
1219 | 1219 | //the user is trying to view someone else's obj |
1220 | 1220 | $caps[] = $this->private_cap; |
1221 | - } elseif (! empty($this->others_cap)) { |
|
1221 | + } elseif ( ! empty($this->others_cap)) { |
|
1222 | 1222 | $caps[] = $this->others_cap; |
1223 | 1223 | } else { |
1224 | 1224 | $caps[] = $cap; |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | } |
1238 | 1238 | if ($has_cap) { |
1239 | 1239 | $caps[] = $cap; |
1240 | - } elseif (! empty($this->private_cap)) { |
|
1240 | + } elseif ( ! empty($this->private_cap)) { |
|
1241 | 1241 | $caps[] = $this->private_cap; |
1242 | - } elseif (! empty($this->others_cap)) { |
|
1242 | + } elseif ( ! empty($this->others_cap)) { |
|
1243 | 1243 | $caps[] = $this->others_cap; |
1244 | 1244 | } else { |
1245 | 1245 | $caps[] = $cap; |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | |
1290 | 1290 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1291 | 1291 | //if no obj then let's just do cap |
1292 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1292 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1293 | 1293 | $caps[] = $cap; |
1294 | 1294 | return $caps; |
1295 | 1295 | } |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | } |
1348 | 1348 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1349 | 1349 | //if no obj then let's just do cap |
1350 | - if (! $obj instanceof EE_Base_Class) { |
|
1350 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1351 | 1351 | $caps[] = $cap; |
1352 | 1352 | return $caps; |
1353 | 1353 | } |