@@ -95,7 +95,7 @@ |
||
95 | 95 | * |
96 | 96 | * @param EE_Event $event EE event object |
97 | 97 | * @param array $data The request data from the form |
98 | - * @return bool success or fail |
|
98 | + * @return integer success or fail |
|
99 | 99 | */ |
100 | 100 | public function attach_evt_message_templates( $event, $data ) { |
101 | 101 | //first we remove all existing relations on the Event for message types. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param \EE_Admin_Page $admin_page |
24 | 24 | */ |
25 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
25 | + public function __construct(EE_Admin_Page $admin_page) { |
|
26 | 26 | /** |
27 | 27 | * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
28 | 28 | */ |
29 | 29 | if ( |
30 | - ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'messages_events_editor_metabox' ) |
|
30 | + ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'messages_events_editor_metabox') |
|
31 | 31 | ) { |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | add_filter( |
35 | 35 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
36 | - array( $this, 'caf_updates' ), |
|
36 | + array($this, 'caf_updates'), |
|
37 | 37 | 10 |
38 | 38 | ); |
39 | - parent::__construct( $admin_page ); |
|
39 | + parent::__construct($admin_page); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function _extend_properties() { |
51 | 51 | |
52 | - define( 'EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/' ); |
|
52 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/'); |
|
53 | 53 | $this->_ajax_func = array( |
54 | 54 | 'ee_msgs_create_new_custom' => 'create_new_custom' |
55 | 55 | ); |
56 | 56 | $this->_metaboxes = array( |
57 | 57 | 0 => array( |
58 | - 'page_route' => array('edit','create_new'), |
|
58 | + 'page_route' => array('edit', 'create_new'), |
|
59 | 59 | 'func' => 'messages_metabox', |
60 | 60 | 'label' => __('Notifications', 'event_espresso'), |
61 | 61 | 'priority' => 'high' |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | $this->_scripts_styles = array( |
67 | 67 | 'registers' => array( |
68 | 68 | 'events_msg_admin' => array( |
69 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
69 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js', |
|
70 | 70 | 'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array') |
71 | 71 | ), |
72 | 72 | 'events_msg_admin_css' => array( |
73 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
73 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css', |
|
74 | 74 | 'type' => 'css' |
75 | 75 | ) |
76 | 76 | ), |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | - public function caf_updates( $update_callbacks ) { |
|
86 | - $update_callbacks[] = array( $this, 'attach_evt_message_templates' ); |
|
85 | + public function caf_updates($update_callbacks) { |
|
86 | + $update_callbacks[] = array($this, 'attach_evt_message_templates'); |
|
87 | 87 | return $update_callbacks; |
88 | 88 | } |
89 | 89 | |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | * @param array $data The request data from the form |
98 | 98 | * @return bool success or fail |
99 | 99 | */ |
100 | - public function attach_evt_message_templates( $event, $data ) { |
|
100 | + public function attach_evt_message_templates($event, $data) { |
|
101 | 101 | //first we remove all existing relations on the Event for message types. |
102 | 102 | $event->_remove_relations('Message_Template_Group'); |
103 | 103 | //now let's just loop through the selected templates and add relations! |
104 | - if ( isset( $data[ 'event_message_templates_relation' ] ) ) { |
|
105 | - foreach ( $data[ 'event_message_templates_relation' ] as $grp_ID ) { |
|
106 | - $event->_add_relation_to( $grp_ID, 'Message_Template_Group' ); |
|
104 | + if (isset($data['event_message_templates_relation'])) { |
|
105 | + foreach ($data['event_message_templates_relation'] as $grp_ID) { |
|
106 | + $event->_add_relation_to($grp_ID, 'Message_Template_Group'); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | //now save |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | * @return string |
119 | 119 | * @throws \EE_Error |
120 | 120 | */ |
121 | - public function messages_metabox( $event, $callback_args ) { |
|
121 | + public function messages_metabox($event, $callback_args) { |
|
122 | 122 | //let's get the active messengers (b/c messenger objects have the active message templates) |
123 | 123 | //convert 'evt_id' to 'EVT_ID' |
124 | - $this->_req_data['EVT_ID'] = isset( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : NULL; |
|
125 | - $this->_req_data['EVT_ID'] = isset( $this->_req_data['post'] ) && empty( $this->_req_data['EVT_ID'] ) |
|
124 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; |
|
125 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID']) |
|
126 | 126 | ? $this->_req_data['post'] |
127 | 127 | : $this->_req_data['EVT_ID']; |
128 | 128 | |
129 | - $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID'] ) && isset($this->_req_data['evt_id'] ) |
|
129 | + $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id']) |
|
130 | 130 | ? $this->_req_data['evt_id'] |
131 | 131 | : $this->_req_data['EVT_ID']; |
132 | 132 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
133 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
133 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
134 | 134 | $active_messengers = $message_resource_manager->active_messengers(); |
135 | 135 | $tabs = array(); |
136 | 136 | |
137 | 137 | //empty messengers? |
138 | 138 | //Note message types will always have at least one available because every messenger has a default message type associated with it (payment) if no other message types are selected. |
139 | - if ( empty( $active_messengers ) ) { |
|
139 | + if (empty($active_messengers)) { |
|
140 | 140 | $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
141 | 141 | array('action' => 'settings'), |
142 | 142 | EE_MSG_ADMIN_URL |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | __('There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', 'event_espresso'), |
146 | 146 | '<strong>', |
147 | 147 | '</strong>', |
148 | - '<a href="' . $msg_activate_url . '">', |
|
148 | + '<a href="'.$msg_activate_url.'">', |
|
149 | 149 | '</a>' |
150 | 150 | ); |
151 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
152 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
151 | + $error_content = '<div class="error"><p>'.$error_msg.'</p></div>'; |
|
152 | + $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>'; |
|
153 | 153 | |
154 | 154 | echo $error_content; |
155 | 155 | echo $internal_content; |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | |
159 | 159 | $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; |
160 | 160 | //get content for active messengers |
161 | - foreach ( $active_messengers as $name => $messenger ) { |
|
161 | + foreach ($active_messengers as $name => $messenger) { |
|
162 | 162 | //first check if there are any active message types for this messenger. |
163 | - $active_mts = $message_resource_manager->get_active_message_types_for_messenger( $name ); |
|
164 | - if ( empty( $active_mts ) ) { |
|
163 | + $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
164 | + if (empty($active_mts)) { |
|
165 | 165 | continue; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $tab_content = $messenger->get_messenger_admin_page_content( |
169 | 169 | 'events', |
170 | 170 | 'edit', |
171 | - array( 'event' => $event_id ) |
|
171 | + array('event' => $event_id) |
|
172 | 172 | ); |
173 | 173 | |
174 | - if ( ! empty( $tab_content ) ) { |
|
174 | + if ( ! empty($tab_content)) { |
|
175 | 175 | $tabs[$name] = $tab_content; |
176 | 176 | } |
177 | 177 | } |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | |
180 | 180 | //we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
181 | 181 | $tabbed_content = EEH_Tabbed_Content::display($tabs); |
182 | - if ( $tabbed_content instanceof WP_Error ) { |
|
182 | + if ($tabbed_content instanceof WP_Error) { |
|
183 | 183 | $tabbed_content = $tabbed_content->get_error_message(); |
184 | 184 | } |
185 | 185 | |
186 | 186 | $notices = ' |
187 | 187 | <div id="espresso-ajax-loading" class="ajax-loader-grey"> |
188 | - <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso') . '</span> |
|
188 | + <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso').'</span> |
|
189 | 189 | </div> |
190 | 190 | <div class="ee-notices"></div>'; |
191 | 191 | |
192 | - if ( defined('DOING_AJAX' ) ) { |
|
192 | + if (defined('DOING_AJAX')) { |
|
193 | 193 | return $tabbed_content; |
194 | 194 | } |
195 | 195 | |
196 | - do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content' ); |
|
197 | - echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; |
|
198 | - do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content' ); |
|
196 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
197 | + echo $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>'; |
|
198 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function create_new_custom() { |
212 | 212 | |
213 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'create_new_custom_ajax' ) ) { |
|
214 | - wp_die( __('You don\'t have privileges to do this action', 'event_espresso' ) ); |
|
213 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
214 | + wp_die(__('You don\'t have privileges to do this action', 'event_espresso')); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | //let's clean up the _POST global a bit for downstream usage of name and description. |
218 | - $_POST['templateName'] = !empty( $this->_req_data['custom_template_args']['MTP_name'] ) |
|
218 | + $_POST['templateName'] = ! empty($this->_req_data['custom_template_args']['MTP_name']) |
|
219 | 219 | ? $this->_req_data['custom_template_args']['MTP_name'] |
220 | 220 | : ''; |
221 | - $_POST['templateDescription'] = !empty( $this->_req_data['custom_template_args']['MTP_description'] ) |
|
221 | + $_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description']) |
|
222 | 222 | ? $this->_req_data['custom_template_args']['MTP_description'] |
223 | 223 | : ''; |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $this->_set_page_object(); |
228 | 228 | |
229 | 229 | // is this a template switch if so EE_Admin_Page child needs this object |
230 | - $this->_page_object->set_hook_object( $this ); |
|
230 | + $this->_page_object->set_hook_object($this); |
|
231 | 231 | |
232 | 232 | $this->_page_object->add_message_template( |
233 | 233 | $this->_req_data['messageType'], |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function edit_admin_footer() { |
253 | 253 | EEH_Template::display_template( |
254 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
254 | + EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php' |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 |
@@ -594,7 +594,7 @@ |
||
594 | 594 | * @since 4.1 |
595 | 595 | * @access public |
596 | 596 | * |
597 | - * @param object $item The current item |
|
597 | + * @param EE_Message_Template_Group $item The current item |
|
598 | 598 | */ |
599 | 599 | public function single_row( $item ) { |
600 | 600 | $row_class = $this->_get_row_class( $item ); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param $messenger |
85 | 85 | * @param string $orderby |
86 | 86 | * @param string $order |
87 | - * @return array all (including trashed or inactive) message template group objects for the given messenger |
|
87 | + * @return EE_Base_Class[] all (including trashed or inactive) message template group objects for the given messenger |
|
88 | 88 | */ |
89 | 89 | public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC' ) { |
90 | 90 | return $this->get_all_deleted_and_undeleted( |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * This sends things to the validator for the given messenger and message type. |
345 | 345 | * |
346 | - * @param array $fields the incoming fields to check. |
|
346 | + * @param string $fields the incoming fields to check. |
|
347 | 347 | * Note this array is in the formatted fields from the form fields setup. |
348 | 348 | * So we need to reformat this into an array of expected field refs by the validator. |
349 | 349 | * Note also that this is not only the fields for the Message Template Group |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
2 | 2 | exit('NO direct script access allowed'); |
3 | 3 | /** |
4 | - * EEM_Message_Template_Group |
|
5 | - * |
|
6 | - * @package Event Espresso |
|
7 | - * @subpackage includes/models/EEM_Message_Template_Group.model.php |
|
8 | - * @author Darren Ethier |
|
9 | - * |
|
10 | - * |
|
11 | - */ |
|
4 | + * EEM_Message_Template_Group |
|
5 | + * |
|
6 | + * @package Event Espresso |
|
7 | + * @subpackage includes/models/EEM_Message_Template_Group.model.php |
|
8 | + * @author Darren Ethier |
|
9 | + * |
|
10 | + * |
|
11 | + */ |
|
12 | 12 | require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
13 | 13 | class EEM_Message_Template_Group extends EEM_Soft_Delete_Base { |
14 | 14 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | 2 | exit('NO direct script access allowed'); |
3 | 3 | /** |
4 | 4 | * EEM_Message_Template_Group |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * |
11 | 11 | */ |
12 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
12 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
13 | 13 | class EEM_Message_Template_Group extends EEM_Soft_Delete_Base { |
14 | 14 | |
15 | 15 | // private instance of the EEM_Message_Template_Group object |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | |
19 | 19 | |
20 | - protected function __construct( $timezone = NULL ) { |
|
20 | + protected function __construct($timezone = NULL) { |
|
21 | 21 | $this->singular_item = __('Message Template Group', 'event_espresso'); |
22 | 22 | $this->plural_item = __('Message Template Groups', 'event_espresso'); |
23 | 23 | $this->_tables = array( |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | $this->_fields = array( |
27 | 27 | 'Message_Template_Group' => array( |
28 | 28 | 'GRP_ID' => new EE_Primary_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso')), |
29 | - 'MTP_name' => new EE_Plain_Text_Field( 'MTP_name', __('The name of the template group', 'event_espresso'), FALSE, '' ), |
|
30 | - 'MTP_description' => new EE_Simple_HTML_Field( 'MTP_description', __('A brief description about this template.', 'event_espresso' ), FALSE, '' ), |
|
31 | - 'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), FALSE, get_current_user_id() ), |
|
32 | - 'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), FALSE, 'email' ), |
|
33 | - 'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'),false,'registration'), |
|
29 | + 'MTP_name' => new EE_Plain_Text_Field('MTP_name', __('The name of the template group', 'event_espresso'), FALSE, ''), |
|
30 | + 'MTP_description' => new EE_Simple_HTML_Field('MTP_description', __('A brief description about this template.', 'event_espresso'), FALSE, ''), |
|
31 | + 'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), FALSE, get_current_user_id()), |
|
32 | + 'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), FALSE, 'email'), |
|
33 | + 'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'), false, 'registration'), |
|
34 | 34 | 'MTP_is_global'=>new EE_Boolean_Field('MTP_is_global', __('Flag indicating if Template Group is Global', 'event_espresso'), false, true), |
35 | 35 | 'MTP_is_override'=>new EE_Boolean_Field('MTP_is_override', __('Flag indicating if Template Group overrides any other Templates for the messenger/messagetype combination', 'event_espresso'), false, false), |
36 | 36 | 'MTP_deleted'=>new EE_Trashed_Flag_Field('MTP_deleted', __('Flag indicating whether this has been trashed', 'event_espresso'), false, false), |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | 'Event' => new EE_HABTM_Relation('Event_Message_Template'), |
44 | 44 | 'WP_User' => new EE_Belongs_To_Relation() |
45 | 45 | ); |
46 | - foreach( $this->_cap_contexts_to_cap_action_map as $context => $action ){ |
|
47 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global( 'MTP_is_global'); |
|
46 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
47 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global('MTP_is_global'); |
|
48 | 48 | } |
49 | 49 | $this->_caps_slug = 'messages'; |
50 | 50 | |
51 | - parent::__construct( $timezone ); |
|
51 | + parent::__construct($timezone); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $limit = null, |
72 | 72 | $count = false |
73 | 73 | ) { |
74 | - $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
75 | - return $count ? $this->count_deleted( $query_params, 'GRP_ID', TRUE ) : $this->get_all_deleted( $query_params ); |
|
74 | + $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
75 | + return $count ? $this->count_deleted($query_params, 'GRP_ID', TRUE) : $this->get_all_deleted($query_params); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param string $order |
87 | 87 | * @return array all (including trashed or inactive) message template group objects for the given messenger |
88 | 88 | */ |
89 | - public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC' ) { |
|
89 | + public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC') { |
|
90 | 90 | return $this->get_all_deleted_and_undeleted( |
91 | - array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) ) |
|
91 | + array(array('MTP_messenger' => $messenger), 'order_by' => array($orderby => $order)) |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | * @param array $_where any existing where conditions to append these to. |
100 | 100 | * @return array original where conditions or original with additional filters. |
101 | 101 | */ |
102 | - protected function _maybe_mtp_filters( $_where = array() ) { |
|
102 | + protected function _maybe_mtp_filters($_where = array()) { |
|
103 | 103 | //account for messenger or message type filters |
104 | 104 | if ( |
105 | - isset( $_REQUEST[ 'ee_messenger_filter_by' ] ) |
|
106 | - && $_REQUEST[ 'ee_messenger_filter_by' ] != 'none_selected' |
|
107 | - && $_REQUEST[ 'ee_messenger_filter_by' ] != 'all' |
|
105 | + isset($_REQUEST['ee_messenger_filter_by']) |
|
106 | + && $_REQUEST['ee_messenger_filter_by'] != 'none_selected' |
|
107 | + && $_REQUEST['ee_messenger_filter_by'] != 'all' |
|
108 | 108 | ) { |
109 | - $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by'] ; |
|
109 | + $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by']; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if ( |
113 | - isset( $_REQUEST['ee_message_type_filter_by']) |
|
113 | + isset($_REQUEST['ee_message_type_filter_by']) |
|
114 | 114 | && $_REQUEST['ee_message_type_filter_by'] != 'none_selected' |
115 | 115 | ) { |
116 | 116 | $_where['MTP_message_type'] = $_REQUEST['ee_message_type_filter_by']; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $global = true, |
142 | 142 | $user_check = false |
143 | 143 | ) { |
144 | - $_where = $global ? array('MTP_is_global' => TRUE ) : array('MTP_is_global' => FALSE ); |
|
144 | + $_where = $global ? array('MTP_is_global' => TRUE) : array('MTP_is_global' => FALSE); |
|
145 | 145 | $_where['MTP_is_active'] = TRUE; |
146 | 146 | $_where = $this->_maybe_mtp_filters($_where); |
147 | 147 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | $_where['MTP_user_id'] = get_current_user_id(); |
157 | 157 | } |
158 | 158 | |
159 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
159 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
160 | 160 | |
161 | - return $count ? $this->count($query_params, 'GRP_ID', TRUE ) : $this->get_all($query_params); |
|
161 | + return $count ? $this->count($query_params, 'GRP_ID', TRUE) : $this->get_all($query_params); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * @param bool $count |
174 | 174 | * @return mixed array on success, FALSE on fail |
175 | 175 | */ |
176 | - public function get_all_message_templates( $orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false ) { |
|
176 | + public function get_all_message_templates($orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false) { |
|
177 | 177 | $_where = $this->_maybe_mtp_filters(); |
178 | 178 | |
179 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
179 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
180 | 180 | |
181 | 181 | $r_templates = $count |
182 | - ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', TRUE ) |
|
183 | - : $this->get_all_deleted_and_undeleted( $query_params ); |
|
182 | + ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', TRUE) |
|
183 | + : $this->get_all_deleted_and_undeleted($query_params); |
|
184 | 184 | |
185 | 185 | return $r_templates; |
186 | 186 | } |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | * @param array $query_params same as EEM_Base::get_all() |
195 | 195 | * @return EE_Message_Template_Group[] |
196 | 196 | */ |
197 | - public function get_all_custom_templates_by_event( $EVT_ID, $query_params = array() ) { |
|
198 | - $where = array_merge( $query_params, array( 'Event.EVT_ID' => $EVT_ID ) ); |
|
197 | + public function get_all_custom_templates_by_event($EVT_ID, $query_params = array()) { |
|
198 | + $where = array_merge($query_params, array('Event.EVT_ID' => $EVT_ID)); |
|
199 | 199 | return $this->get_all( |
200 | - array( $where ) |
|
200 | + array($where) |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | $count = false, |
223 | 223 | $global = true |
224 | 224 | ) { |
225 | - $_where = $global ? array('MTP_is_global' => TRUE ) : array('MTP_is_global' => FALSE ); |
|
225 | + $_where = $global ? array('MTP_is_global' => TRUE) : array('MTP_is_global' => FALSE); |
|
226 | 226 | $_where['MTP_is_active'] = TRUE; |
227 | 227 | $_where = $this->_maybe_mtp_filters($_where); |
228 | 228 | |
229 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
229 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
230 | 230 | |
231 | - return $count ? $this->count_deleted($query_params, 'GRP_ID', TRUE ) : $this->get_all_deleted( $query_params ); |
|
231 | + return $count ? $this->count_deleted($query_params, 'GRP_ID', TRUE) : $this->get_all_deleted($query_params); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | 'MTP_is_active' => $active |
265 | 265 | ); |
266 | 266 | |
267 | - $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit ); |
|
267 | + $query_params = array($_where, 'order_by' => array($orderby=>$order), 'limit' => $limit); |
|
268 | 268 | |
269 | - return $count ? $this->count($query_params, 'GRP_ID', TRUE ) : $this->get_all( $query_params ); |
|
269 | + return $count ? $this->count($query_params, 'GRP_ID', TRUE) : $this->get_all($query_params); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | 'MTP_is_global' => TRUE, |
301 | 301 | ); |
302 | 302 | |
303 | - if ( $active != 'all' ) { |
|
303 | + if ($active != 'all') { |
|
304 | 304 | $_where['MTP_is_active'] = $active; |
305 | 305 | } |
306 | 306 | |
307 | - $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit ); |
|
307 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
308 | 308 | |
309 | - return $count ? $this->count( $query_params, 'GRP_ID', TRUE ) : $this->get_all( $query_params ); |
|
309 | + return $count ? $this->count($query_params, 'GRP_ID', TRUE) : $this->get_all($query_params); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param array $query_params same as EEM_Base->get_all() |
320 | 320 | * @return EE_Message_Template_Group[] |
321 | 321 | */ |
322 | - public function get_custom_message_template_by_m_and_mt( $messenger, $message_type, $query_params = array() ) { |
|
322 | + public function get_custom_message_template_by_m_and_mt($messenger, $message_type, $query_params = array()) { |
|
323 | 323 | return $this->get_all( |
324 | 324 | array_merge( |
325 | 325 | $query_params, |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | $assembled_fields = array(); |
357 | 357 | |
358 | 358 | //let's loop through all the fields and set them up in the right format |
359 | - foreach ( $fields as $index => $value ) { |
|
359 | + foreach ($fields as $index => $value) { |
|
360 | 360 | // first let's figure out if the value['content'] in the current index is an array. |
361 | 361 | // If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list'). |
362 | - if ( is_array($value['content']) ) { |
|
362 | + if (is_array($value['content'])) { |
|
363 | 363 | $assembled_fields[$value['name']] = $value['content']['main']; |
364 | 364 | //loop through the content and get the other fields. |
365 | - foreach ( $value['content'] as $name => $val ) { |
|
366 | - if ( $name == 'main' ) continue; |
|
365 | + foreach ($value['content'] as $name => $val) { |
|
366 | + if ($name == 'main') continue; |
|
367 | 367 | $assembled_fields[$name] = $val; |
368 | 368 | } |
369 | 369 | continue; |
@@ -375,15 +375,15 @@ discard block |
||
375 | 375 | |
376 | 376 | // now we've got the assembled_fields. |
377 | 377 | // We need to setup the string for the appropriate validator class and call that. |
378 | - $m_ref = ucwords( str_replace('_',' ', $messenger ) ); |
|
379 | - $m_ref = str_replace( ' ', '_', $m_ref ); |
|
380 | - $mt_ref = ucwords( str_replace('_', ' ', $message_type ) ); |
|
381 | - $mt_ref = str_replace( ' ', '_', $mt_ref ); |
|
378 | + $m_ref = ucwords(str_replace('_', ' ', $messenger)); |
|
379 | + $m_ref = str_replace(' ', '_', $m_ref); |
|
380 | + $mt_ref = ucwords(str_replace('_', ' ', $message_type)); |
|
381 | + $mt_ref = str_replace(' ', '_', $mt_ref); |
|
382 | 382 | |
383 | - $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator'; |
|
383 | + $classname = 'EE_Messages_'.$m_ref.'_'.$mt_ref.'_Validator'; |
|
384 | 384 | |
385 | - if ( !class_exists( $classname ) ) { |
|
386 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
385 | + if ( ! class_exists($classname)) { |
|
386 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
387 | 387 | $msg[] = sprintf( |
388 | 388 | __( |
389 | 389 | 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | ), |
392 | 392 | $classname |
393 | 393 | ); |
394 | - throw new EE_Error( implode( '||', $msg ) ); |
|
394 | + throw new EE_Error(implode('||', $msg)); |
|
395 | 395 | } |
396 | 396 | |
397 | - $a = new ReflectionClass( $classname ); |
|
398 | - $_VLD = $a->newInstance( $assembled_fields, $context ); |
|
397 | + $a = new ReflectionClass($classname); |
|
398 | + $_VLD = $a->newInstance($assembled_fields, $context); |
|
399 | 399 | $result = $_VLD->validate(); |
400 | 400 | return $result; |
401 | 401 | } |
@@ -414,18 +414,18 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return int count of updated records. |
416 | 416 | */ |
417 | - public function deactivate_message_template_groups_for( $messenger_names = array(), $message_type_names = array() ) { |
|
417 | + public function deactivate_message_template_groups_for($messenger_names = array(), $message_type_names = array()) { |
|
418 | 418 | $query_args = array(); |
419 | - if ( empty( $messenger_names ) && empty( $message_type_names ) ) { |
|
419 | + if (empty($messenger_names) && empty($message_type_names)) { |
|
420 | 420 | return 0; |
421 | 421 | } |
422 | - if ( ! empty( $messenger_names ) ) { |
|
423 | - $query_args[ 0 ][ 'MTP_messenger' ] = array( 'IN', (array) $messenger_names ); |
|
422 | + if ( ! empty($messenger_names)) { |
|
423 | + $query_args[0]['MTP_messenger'] = array('IN', (array) $messenger_names); |
|
424 | 424 | } |
425 | - if ( ! empty( $message_type_names ) ) { |
|
426 | - $query_args[ 0 ][ 'MTP_message_type' ] = array( 'IN', (array) $message_type_names ); |
|
425 | + if ( ! empty($message_type_names)) { |
|
426 | + $query_args[0]['MTP_message_type'] = array('IN', (array) $message_type_names); |
|
427 | 427 | } |
428 | - return $this->update( array( 'MTP_is_active' => false ), $query_args ); |
|
428 | + return $this->update(array('MTP_is_active' => false), $query_args); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 |
@@ -534,7 +534,7 @@ |
||
534 | 534 | *@param EE_Message $message |
535 | 535 | * @param EE_Messenger $messenger |
536 | 536 | * @param EE_message_type $message_type |
537 | - * @param $test_send |
|
537 | + * @param boolean $test_send |
|
538 | 538 | * @return bool true means all went well, false means, not so much. |
539 | 539 | */ |
540 | 540 | protected function _do_preview( EE_Message $message, EE_Messenger $messenger, EE_message_type $message_type, $test_send ) { |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_message_repository = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_message_repository->add( $message, $data ); |
|
97 | + return $this->_message_repository->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_message_repository->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_message_repository->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_message_repository->has( $message ) ) { |
|
112 | + if ($this->_message_repository->has($message)) { |
|
113 | 113 | $this->_message_repository->rewind(); |
114 | - while( $this->_message_repository->valid() ) { |
|
115 | - if ( $this->_message_repository->current() === $message ) { |
|
114 | + while ($this->_message_repository->valid()) { |
|
115 | + if ($this->_message_repository->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_message_repository->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message ); |
|
124 | + return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | 349 | return filter_var( |
350 | 350 | apply_filters( |
351 | 351 | 'FHEE__EE_Messages_Queue__is_locked', |
352 | - get_transient( $this->_get_lock_key( $type ) ), |
|
352 | + get_transient($this->_get_lock_key($type)), |
|
353 | 353 | $this |
354 | 354 | ), |
355 | 355 | FILTER_VALIDATE_BOOLEAN |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | * @return int |
369 | 369 | */ |
370 | 370 | public function get_rate_limit() { |
371 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
371 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
372 | 372 | $rate_limit = $this->_default_rate_limit(); |
373 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
373 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
374 | 374 | } |
375 | 375 | return $rate_limit; |
376 | 376 | } |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | * This updates existing rate limit with the new limit which is the old minus the batch. |
383 | 383 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
384 | 384 | */ |
385 | - public function set_rate_limit( $batch_completed ) { |
|
385 | + public function set_rate_limit($batch_completed) { |
|
386 | 386 | //first get the most up to date rate limit (in case its expired and reset) |
387 | 387 | $rate_limit = $this->get_rate_limit(); |
388 | 388 | $new_limit = $rate_limit - $batch_completed; |
389 | 389 | //updating the transient option directly to avoid resetting the expiry. |
390 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
390 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param string $task This indicates what type of request is going to be initiated. |
401 | 401 | * @param int $priority This indicates the priority that triggers initiating the request. |
402 | 402 | */ |
403 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
403 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
404 | 404 | //determine what status is matched with the priority as part of the trigger conditions. |
405 | 405 | $status = $task == 'generate' |
406 | 406 | ? EEM_Message::status_incomplete |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | // always make sure we save because either this will get executed immediately on a separate request |
409 | 409 | // or remains in the queue for the regularly scheduled queue batch. |
410 | 410 | $this->save(); |
411 | - if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) { |
|
412 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
411 | + if ($this->_message_repository->count_by_priority_and_status($priority, $status)) { |
|
412 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -434,53 +434,53 @@ discard block |
||
434 | 434 | * Also, if the messenger is an request type messenger (or a preview), |
435 | 435 | * its entirely possible that the messenger will exit before |
436 | 436 | */ |
437 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
437 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
438 | 438 | $messages_sent = 0; |
439 | 439 | $this->_did_hook = array(); |
440 | 440 | $this->_message_repository->rewind(); |
441 | 441 | |
442 | - while ( $this->_message_repository->valid() ) { |
|
442 | + while ($this->_message_repository->valid()) { |
|
443 | 443 | $error_messages = array(); |
444 | 444 | /** @type EE_Message $message */ |
445 | 445 | $message = $this->_message_repository->current(); |
446 | 446 | //if the message in the queue has a sent status, then skip |
447 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
447 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
448 | 448 | $this->_message_repository->next(); |
449 | 449 | continue; |
450 | 450 | } |
451 | 451 | //if $by_priority is set and does not match then continue; |
452 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
452 | + if ($by_priority && $by_priority != $message->priority()) { |
|
453 | 453 | $this->_message_repository->next(); |
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | //error checking |
457 | - if ( ! $message->valid_messenger() ) { |
|
457 | + if ( ! $message->valid_messenger()) { |
|
458 | 458 | $error_messages[] = sprintf( |
459 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
459 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
460 | 460 | $message->messenger() |
461 | 461 | ); |
462 | 462 | } |
463 | - if ( ! $message->valid_message_type() ) { |
|
463 | + if ( ! $message->valid_message_type()) { |
|
464 | 464 | $error_messages[] = sprintf( |
465 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
465 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
466 | 466 | $message->message_type() |
467 | 467 | ); |
468 | 468 | } |
469 | 469 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
470 | 470 | // then it will instead be an EE_Error object, so let's check for that |
471 | - if ( $sending_messenger instanceof EE_Error ) { |
|
471 | + if ($sending_messenger instanceof EE_Error) { |
|
472 | 472 | $error_messages[] = $sending_messenger->getMessage(); |
473 | 473 | } |
474 | 474 | // if there are no errors, then let's process the message |
475 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
475 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
476 | 476 | $messages_sent++; |
477 | 477 | } |
478 | - $this->_set_error_message( $message, $error_messages ); |
|
478 | + $this->_set_error_message($message, $error_messages); |
|
479 | 479 | //add modified time |
480 | - $message->set_modified( time() ); |
|
480 | + $message->set_modified(time()); |
|
481 | 481 | $this->_message_repository->next(); |
482 | 482 | } |
483 | - if ( $save ) { |
|
483 | + if ($save) { |
|
484 | 484 | $this->save(); |
485 | 485 | } |
486 | 486 | return $messages_sent; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @param mixed $sending_messenger (optional) |
496 | 496 | * @return bool |
497 | 497 | */ |
498 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
498 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
499 | 499 | // these *should* have been validated in the execute() method above |
500 | 500 | $messenger = $message->messenger_object(); |
501 | 501 | $message_type = $message->message_type_object(); |
@@ -505,20 +505,20 @@ discard block |
||
505 | 505 | && $messenger instanceof EE_messenger |
506 | 506 | && $sending_messenger->name != $messenger->name |
507 | 507 | ) { |
508 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
508 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
509 | 509 | $messenger = $sending_messenger; |
510 | 510 | } |
511 | 511 | // send using messenger, but double check objects |
512 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
512 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
513 | 513 | //set hook for message type (but only if not using another messenger to send). |
514 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
515 | - $message_type->do_messenger_hooks( $messenger ); |
|
516 | - $this->_did_hook[ $message_type->name ] = 1; |
|
514 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
515 | + $message_type->do_messenger_hooks($messenger); |
|
516 | + $this->_did_hook[$message_type->name] = 1; |
|
517 | 517 | } |
518 | 518 | //if preview then use preview method |
519 | 519 | return $this->_message_repository->is_preview() |
520 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() ) |
|
521 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
520 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send()) |
|
521 | + : $this->_do_send($message, $messenger, $message_type); |
|
522 | 522 | } |
523 | 523 | return false; |
524 | 524 | } |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | * @param array $status Stati to check for in queue |
537 | 537 | * @return int Count of EE_Message's matching the given status. |
538 | 538 | */ |
539 | - public function count_STS_in_queue( $status ) { |
|
539 | + public function count_STS_in_queue($status) { |
|
540 | 540 | $count = 0; |
541 | - $status = is_array( $status ) ? $status : array( $status ); |
|
541 | + $status = is_array($status) ? $status : array($status); |
|
542 | 542 | $this->_message_repository->rewind(); |
543 | - foreach( $this->_message_repository as $message ) { |
|
544 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
543 | + foreach ($this->_message_repository as $message) { |
|
544 | + if (in_array($message->STS_ID(), $status)) { |
|
545 | 545 | $count++; |
546 | 546 | } |
547 | 547 | } |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | * @param $test_send |
559 | 559 | * @return bool true means all went well, false means, not so much. |
560 | 560 | */ |
561 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
562 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
563 | - if ( ! $test_send ) { |
|
564 | - $message->set_content( $preview ); |
|
561 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
562 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
563 | + if ( ! $test_send) { |
|
564 | + $message->set_content($preview); |
|
565 | 565 | } |
566 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
566 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
567 | 567 | return true; |
568 | 568 | } else { |
569 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
569 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
570 | 570 | return false; |
571 | 571 | } |
572 | 572 | } |
@@ -582,12 +582,12 @@ discard block |
||
582 | 582 | * @param EE_message_type $message_type |
583 | 583 | * @return bool true means all went well, false means, not so much. |
584 | 584 | */ |
585 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
586 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
587 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
585 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
586 | + if ($messenger->send_message($message, $message_type)) { |
|
587 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
588 | 588 | return true; |
589 | 589 | } else { |
590 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
590 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | } |
@@ -601,21 +601,21 @@ discard block |
||
601 | 601 | * @param EE_Message $message |
602 | 602 | * @param array $error_messages the response from the messenger. |
603 | 603 | */ |
604 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
604 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
605 | 605 | $error_messages = (array) $error_messages; |
606 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
606 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
607 | 607 | $notices = EE_Error::has_notices(); |
608 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
609 | - if ( $notices === 1 ) { |
|
608 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
609 | + if ($notices === 1) { |
|
610 | 610 | $notices = EE_Error::get_vanilla_notices(); |
611 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
612 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
611 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
612 | + $error_messages[] = implode("\n", $notices['errors']); |
|
613 | 613 | } |
614 | 614 | } |
615 | - if ( count( $error_messages ) > 0 ) { |
|
616 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
617 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
618 | - $message->set_error_message( $msg ); |
|
615 | + if (count($error_messages) > 0) { |
|
616 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
617 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
618 | + $message->set_error_message($msg); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 |
@@ -200,7 +200,7 @@ |
||
200 | 200 | * generates an EE_Message using the supplied arguments and some defaults |
201 | 201 | * |
202 | 202 | * @param array $properties |
203 | - * @return string |
|
203 | + * @return EE_Message |
|
204 | 204 | */ |
205 | 205 | protected function _generate_message( $properties = array() ) { |
206 | 206 | $message = EE_Message_Factory::create( |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | public function __construct( |
106 | 106 | $messenger_name, |
107 | 107 | $message_type_name, |
108 | - $data = array(), |
|
108 | + $data = array(), |
|
109 | 109 | $context = '', |
110 | 110 | $preview = false, |
111 | 111 | $status = EEM_Message::status_incomplete |
112 | 112 | ) { |
113 | - $this->_messenger_name = $messenger_name; |
|
114 | - $this->_message_type_name = $message_type_name; |
|
115 | - $this->_data = is_array( $data ) ? $data : array( $data ); |
|
113 | + $this->_messenger_name = $messenger_name; |
|
114 | + $this->_message_type_name = $message_type_name; |
|
115 | + $this->_data = is_array($data) ? $data : array($data); |
|
116 | 116 | $this->_context = $context; |
117 | 117 | $this->_preview = $preview; |
118 | 118 | $this->_status = $status; |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * @param boolean $preview |
172 | 172 | */ |
173 | - public function set_preview( $preview ) { |
|
174 | - $this->_preview = filter_var( $preview, FILTER_VALIDATE_BOOLEAN ); |
|
173 | + public function set_preview($preview) { |
|
174 | + $this->_preview = filter_var($preview, FILTER_VALIDATE_BOOLEAN); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param array $properties |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - protected function _generate_message( $properties = array() ) { |
|
205 | + protected function _generate_message($properties = array()) { |
|
206 | 206 | $message = EE_Message_Factory::create( |
207 | 207 | array_merge( |
208 | 208 | array( |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | ); |
217 | 217 | // validate the message, and if it's good, set some properties |
218 | 218 | try { |
219 | - $message->is_valid_for_sending_or_generation( true ); |
|
219 | + $message->is_valid_for_sending_or_generation(true); |
|
220 | 220 | $this->_valid = true; |
221 | 221 | $this->_messenger = $message->messenger_object(); |
222 | 222 | $this->_message_type = $message->message_type_object(); |
223 | 223 | $this->_send_now = $message->send_now(); |
224 | - } catch ( Exception $e ) { |
|
224 | + } catch (Exception $e) { |
|
225 | 225 | $this->_valid = false; |
226 | 226 | $this->_error_msg[] = $e->getMessage(); |
227 | 227 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function get_EE_Message() { |
239 | 239 | // already set ? |
240 | - if ( $this->_message instanceof EE_Message ) { |
|
240 | + if ($this->_message instanceof EE_Message) { |
|
241 | 241 | return $this->_message; |
242 | 242 | } |
243 | 243 | // no? then let's create one |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | * @param bool $preview Used to indicate that the preview data handler is to be returned. |
256 | 256 | * @return string |
257 | 257 | */ |
258 | - public function get_data_handler_class_name( $preview = false ) { |
|
259 | - if ( $this->_data_handler_class_name === '' && $this->valid() ) { |
|
260 | - $ref = $preview ? 'Preview' : $this->_message_type->get_data_handler( $this->_data ); |
|
258 | + public function get_data_handler_class_name($preview = false) { |
|
259 | + if ($this->_data_handler_class_name === '' && $this->valid()) { |
|
260 | + $ref = $preview ? 'Preview' : $this->_message_type->get_data_handler($this->_data); |
|
261 | 261 | //make sure internal data is updated. |
262 | 262 | $this->_data = $this->_message_type->get_data(); |
263 | 263 | |
264 | 264 | //verify |
265 | - $this->_data_handler_class_name = EE_Message_To_Generate::verify_and_retrieve_class_name_for_data_handler_reference( $ref ); |
|
266 | - if ( $this->_data_handler_class_name === '' ) { |
|
265 | + $this->_data_handler_class_name = EE_Message_To_Generate::verify_and_retrieve_class_name_for_data_handler_reference($ref); |
|
266 | + if ($this->_data_handler_class_name === '') { |
|
267 | 267 | $this->_valid = false; |
268 | 268 | } |
269 | 269 | } |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * @param string $data_handler_reference |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public static function verify_and_retrieve_class_name_for_data_handler_reference( $data_handler_reference ) { |
|
283 | - $class_name = 'EE_Messages_' . $data_handler_reference . '_incoming_data'; |
|
284 | - if ( ! class_exists( $class_name ) ) { |
|
282 | + public static function verify_and_retrieve_class_name_for_data_handler_reference($data_handler_reference) { |
|
283 | + $class_name = 'EE_Messages_'.$data_handler_reference.'_incoming_data'; |
|
284 | + if ( ! class_exists($class_name)) { |
|
285 | 285 | EE_Error::add_error( |
286 | 286 | sprintf( |
287 | 287 | __( |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | |
197 | 197 | |
198 | 198 | /** |
199 | - * detect_if_activation_or_upgrade |
|
200 | - * |
|
201 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
202 | - * and either setting up the DB or setting up maintenance mode etc. |
|
203 | - * |
|
204 | - * @access public |
|
205 | - * @return void |
|
206 | - */ |
|
199 | + * detect_if_activation_or_upgrade |
|
200 | + * |
|
201 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
202 | + * and either setting up the DB or setting up maintenance mode etc. |
|
203 | + * |
|
204 | + * @access public |
|
205 | + * @return void |
|
206 | + */ |
|
207 | 207 | public function detect_if_activation_or_upgrade() { |
208 | 208 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
209 | 209 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | $query_params = array( 'page' => 'espresso_about' ); |
513 | 513 | |
514 | 514 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
515 | - $query_params['new_activation'] = TRUE; |
|
515 | + $query_params['new_activation'] = TRUE; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
519 | - $query_params['reactivation'] = TRUE; |
|
519 | + $query_params['reactivation'] = TRUE; |
|
520 | 520 | } |
521 | 521 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
522 | 522 | wp_safe_redirect( $url ); |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | |
620 | 620 | |
621 | 621 | /** |
622 | - * _incompatible_addon_error |
|
623 | - * |
|
624 | - * @access public |
|
625 | - * @return void |
|
626 | - */ |
|
622 | + * _incompatible_addon_error |
|
623 | + * |
|
624 | + * @access public |
|
625 | + * @return void |
|
626 | + */ |
|
627 | 627 | private function _incompatible_addon_error() { |
628 | 628 | // get array of classes hooking into here |
629 | 629 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | |
746 | 746 | |
747 | 747 | /** |
748 | - * load_controllers |
|
749 | - * |
|
750 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
751 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
752 | - * |
|
753 | - * @access public |
|
754 | - * @return void |
|
755 | - */ |
|
748 | + * load_controllers |
|
749 | + * |
|
750 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
751 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
752 | + * |
|
753 | + * @access public |
|
754 | + * @return void |
|
755 | + */ |
|
756 | 756 | public function load_controllers() { |
757 | 757 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
758 | 758 | // let's get it started |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | |
770 | 770 | |
771 | 771 | /** |
772 | - * core_loaded_and_ready |
|
773 | - * |
|
774 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
775 | - * |
|
776 | - * @access public |
|
777 | - * @return void |
|
778 | - */ |
|
772 | + * core_loaded_and_ready |
|
773 | + * |
|
774 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
775 | + * |
|
776 | + * @access public |
|
777 | + * @return void |
|
778 | + */ |
|
779 | 779 | public function core_loaded_and_ready() { |
780 | 780 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
781 | 781 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | |
787 | 787 | |
788 | 788 | /** |
789 | - * initialize |
|
790 | - * |
|
791 | - * this is the best place to begin initializing client code |
|
792 | - * |
|
793 | - * @access public |
|
794 | - * @return void |
|
795 | - */ |
|
789 | + * initialize |
|
790 | + * |
|
791 | + * this is the best place to begin initializing client code |
|
792 | + * |
|
793 | + * @access public |
|
794 | + * @return void |
|
795 | + */ |
|
796 | 796 | public function initialize() { |
797 | 797 | do_action( 'AHEE__EE_System__initialize' ); |
798 | 798 | } |
@@ -800,13 +800,13 @@ discard block |
||
800 | 800 | |
801 | 801 | |
802 | 802 | /** |
803 | - * initialize_last |
|
804 | - * |
|
805 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
806 | - * |
|
807 | - * @access public |
|
808 | - * @return void |
|
809 | - */ |
|
803 | + * initialize_last |
|
804 | + * |
|
805 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
806 | + * |
|
807 | + * @access public |
|
808 | + * @return void |
|
809 | + */ |
|
810 | 810 | public function initialize_last() { |
811 | 811 | do_action( 'AHEE__EE_System__initialize_last' ); |
812 | 812 | } |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | |
816 | 816 | |
817 | 817 | /** |
818 | - * set_hooks_for_shortcodes_modules_and_addons |
|
819 | - * |
|
820 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
821 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @return void |
|
825 | - */ |
|
818 | + * set_hooks_for_shortcodes_modules_and_addons |
|
819 | + * |
|
820 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
821 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @return void |
|
825 | + */ |
|
826 | 826 | public function set_hooks_for_shortcodes_modules_and_addons() { |
827 | 827 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
828 | 828 | } |
@@ -831,13 +831,13 @@ discard block |
||
831 | 831 | |
832 | 832 | |
833 | 833 | /** |
834 | - * do_not_cache |
|
835 | - * |
|
836 | - * sets no cache headers and defines no cache constants for WP plugins |
|
837 | - * |
|
838 | - * @access public |
|
839 | - * @return void |
|
840 | - */ |
|
834 | + * do_not_cache |
|
835 | + * |
|
836 | + * sets no cache headers and defines no cache constants for WP plugins |
|
837 | + * |
|
838 | + * @access public |
|
839 | + * @return void |
|
840 | + */ |
|
841 | 841 | public static function do_not_cache() { |
842 | 842 | // set no cache constants |
843 | 843 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | //Current post |
957 | 957 | global $post; |
958 | 958 | |
959 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
959 | + if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
960 | 960 | //Events Edit Current Event |
961 | 961 | $admin_bar->add_menu(array( |
962 | 962 | 'id' => 'espresso-toolbar-events-edit', |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * @param \EE_Registry $Registry |
89 | 89 | * @return \EE_System |
90 | 90 | */ |
91 | - public static function instance( EE_Registry $Registry = null ) { |
|
91 | + public static function instance(EE_Registry $Registry = null) { |
|
92 | 92 | // check if class object is instantiated |
93 | - if ( ! self::$_instance instanceof EE_System ) { |
|
94 | - self::$_instance = new self( $Registry ); |
|
93 | + if ( ! self::$_instance instanceof EE_System) { |
|
94 | + self::$_instance = new self($Registry); |
|
95 | 95 | } |
96 | 96 | return self::$_instance; |
97 | 97 | } |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | * resets the instance and returns it |
102 | 102 | * @return EE_System |
103 | 103 | */ |
104 | - public static function reset(){ |
|
104 | + public static function reset() { |
|
105 | 105 | self::$_instance->_req_type = NULL; |
106 | 106 | |
107 | 107 | //make sure none of the old hooks are left hanging around |
108 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
108 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
109 | 109 | |
110 | 110 | //we need to reset the migration manager in order for it to detect DMSs properly |
111 | 111 | EE_Data_Migration_Manager::reset(); |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | * @access private |
126 | 126 | * @param \EE_Registry $Registry |
127 | 127 | */ |
128 | - private function __construct( EE_Registry $Registry ) { |
|
128 | + private function __construct(EE_Registry $Registry) { |
|
129 | 129 | $this->registry = $Registry; |
130 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
130 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
131 | 131 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
132 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
132 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
133 | 133 | // when an ee addon is activated, we want to call the core hook(s) again |
134 | 134 | // because the newly-activated addon didn't get a chance to run at all |
135 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
135 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
136 | 136 | // detect whether install or upgrade |
137 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
137 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
138 | 138 | // load EE_Config, EE_Textdomain, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
140 | 140 | // load EE_Config, EE_Textdomain, etc |
141 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
141 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
142 | 142 | // you wanna get going? I wanna get going... let's get going! |
143 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
143 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
144 | 144 | //other housekeeping |
145 | 145 | //exclude EE critical pages from wp_list_pages |
146 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
146 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
147 | 147 | // ALL EE Addons should use the following hook point to attach their initial setup too |
148 | 148 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
149 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
149 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -166,30 +166,30 @@ discard block |
||
166 | 166 | public function load_espresso_addons() { |
167 | 167 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
168 | 168 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
169 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
169 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
170 | 170 | //load and setup EE_Capabilities |
171 | - $this->registry->load_core( 'Capabilities' ); |
|
171 | + $this->registry->load_core('Capabilities'); |
|
172 | 172 | //caps need to be initialized on every request so that capability maps are set. |
173 | 173 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
174 | 174 | $this->registry->CAP->init_caps(); |
175 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
175 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
176 | 176 | //if the WP API basic auth plugin isn't already loaded, load it now. |
177 | 177 | //We want it for mobile apps. Just include the entire plugin |
178 | 178 | //also, don't load the basic auth when a plugin is getting activated, because |
179 | 179 | //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
180 | 180 | //and causes a fatal error |
181 | - if( !function_exists( 'json_basic_auth_handler' ) |
|
182 | - && ! function_exists( 'json_basic_auth_error' ) |
|
181 | + if ( ! function_exists('json_basic_auth_handler') |
|
182 | + && ! function_exists('json_basic_auth_error') |
|
183 | 183 | && ! ( |
184 | - isset( $_GET[ 'action'] ) |
|
185 | - && in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) ) |
|
184 | + isset($_GET['action']) |
|
185 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
186 | 186 | ) |
187 | 187 | && ! ( |
188 | - isset( $_GET['activate' ] ) |
|
189 | - && $_GET['activate' ] === 'true' |
|
188 | + isset($_GET['activate']) |
|
189 | + && $_GET['activate'] === 'true' |
|
190 | 190 | ) |
191 | 191 | ) { |
192 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
192 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | * @access public |
206 | 206 | * @return void |
207 | 207 | */ |
208 | - public function detect_activations_or_upgrades(){ |
|
208 | + public function detect_activations_or_upgrades() { |
|
209 | 209 | //first off: let's make sure to handle core |
210 | 210 | $this->detect_if_activation_or_upgrade(); |
211 | - foreach($this->registry->addons as $addon){ |
|
211 | + foreach ($this->registry->addons as $addon) { |
|
212 | 212 | //detect teh request type for that addon |
213 | 213 | $addon->detect_activation_or_upgrade(); |
214 | 214 | } |
@@ -229,41 +229,41 @@ discard block |
||
229 | 229 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
230 | 230 | |
231 | 231 | // load M-Mode class |
232 | - $this->registry->load_core( 'Maintenance_Mode' ); |
|
232 | + $this->registry->load_core('Maintenance_Mode'); |
|
233 | 233 | // check if db has been updated, or if its a brand-new installation |
234 | 234 | |
235 | 235 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
236 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
236 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
237 | 237 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
238 | 238 | |
239 | - switch($request_type){ |
|
239 | + switch ($request_type) { |
|
240 | 240 | case EE_System::req_type_new_activation: |
241 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
242 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
241 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
242 | + $this->_handle_core_version_change($espresso_db_update); |
|
243 | 243 | break; |
244 | 244 | case EE_System::req_type_reactivation: |
245 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
246 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
245 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
246 | + $this->_handle_core_version_change($espresso_db_update); |
|
247 | 247 | break; |
248 | 248 | case EE_System::req_type_upgrade: |
249 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
249 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
250 | 250 | //migrations may be required now that we've upgraded |
251 | 251 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
252 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
252 | + $this->_handle_core_version_change($espresso_db_update); |
|
253 | 253 | // echo "done upgrade";die; |
254 | 254 | break; |
255 | 255 | case EE_System::req_type_downgrade: |
256 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
256 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
257 | 257 | //its possible migrations are no longer required |
258 | 258 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
259 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
259 | + $this->_handle_core_version_change($espresso_db_update); |
|
260 | 260 | break; |
261 | 261 | case EE_System::req_type_normal: |
262 | 262 | default: |
263 | 263 | // $this->_maybe_redirect_to_ee_about(); |
264 | 264 | break; |
265 | 265 | } |
266 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
266 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | * initializing the database later during the request |
272 | 272 | * @param array $espresso_db_update |
273 | 273 | */ |
274 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
275 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
274 | + protected function _handle_core_version_change($espresso_db_update) { |
|
275 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
276 | 276 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
277 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
277 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
@@ -289,44 +289,44 @@ discard block |
||
289 | 289 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
290 | 290 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
291 | 291 | */ |
292 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
293 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
294 | - if( ! $espresso_db_update){ |
|
295 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
292 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
293 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
294 | + if ( ! $espresso_db_update) { |
|
295 | + $espresso_db_update = get_option('espresso_db_update'); |
|
296 | 296 | } |
297 | 297 | // check that option is an array |
298 | - if( ! is_array( $espresso_db_update )) { |
|
298 | + if ( ! is_array($espresso_db_update)) { |
|
299 | 299 | // if option is FALSE, then it never existed |
300 | - if ( $espresso_db_update === FALSE ) { |
|
300 | + if ($espresso_db_update === FALSE) { |
|
301 | 301 | // make $espresso_db_update an array and save option with autoload OFF |
302 | - $espresso_db_update = array(); |
|
303 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
302 | + $espresso_db_update = array(); |
|
303 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
304 | 304 | } else { |
305 | 305 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
306 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
307 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
306 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
307 | + update_option('espresso_db_update', $espresso_db_update); |
|
308 | 308 | } |
309 | - }else{ |
|
309 | + } else { |
|
310 | 310 | $corrected_db_update = array(); |
311 | 311 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
312 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
313 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
312 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
313 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
314 | 314 | //the key is an int, and the value IS NOT an array |
315 | 315 | //so it must be numerically-indexed, where values are versions installed... |
316 | 316 | //fix it! |
317 | 317 | $version_string = $should_be_array; |
318 | 318 | $corrected_db_update[$version_string] = array('unknown-date'); |
319 | - }else{ |
|
319 | + } else { |
|
320 | 320 | //ok it checks out |
321 | 321 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
322 | 322 | } |
323 | 323 | } |
324 | 324 | $espresso_db_update = $corrected_db_update; |
325 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
325 | + update_option('espresso_db_update', $espresso_db_update); |
|
326 | 326 | |
327 | 327 | } |
328 | 328 | |
329 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
329 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
330 | 330 | return $espresso_db_update; |
331 | 331 | } |
332 | 332 | |
@@ -346,34 +346,34 @@ discard block |
||
346 | 346 | * so we prefer to only do it when necessary |
347 | 347 | * @return void |
348 | 348 | */ |
349 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
349 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
350 | 350 | $request_type = $this->detect_req_type(); |
351 | 351 | //only initialize system if we're not in maintenance mode. |
352 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
353 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
352 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
353 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
354 | 354 | |
355 | - if( $verify_schema ) { |
|
355 | + if ($verify_schema) { |
|
356 | 356 | EEH_Activation::initialize_db_and_folders(); |
357 | 357 | } |
358 | 358 | EEH_Activation::initialize_db_content(); |
359 | 359 | EEH_Activation::system_initialization(); |
360 | - if( $initialize_addons_too ) { |
|
360 | + if ($initialize_addons_too) { |
|
361 | 361 | $this->initialize_addons(); |
362 | 362 | } |
363 | - }else{ |
|
364 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
363 | + } else { |
|
364 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
365 | 365 | } |
366 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
367 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
366 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
367 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Initializes the db for all registered addons |
373 | 373 | */ |
374 | - public function initialize_addons(){ |
|
374 | + public function initialize_addons() { |
|
375 | 375 | //foreach registered addon, make sure its db is up-to-date too |
376 | - foreach($this->registry->addons as $addon){ |
|
376 | + foreach ($this->registry->addons as $addon) { |
|
377 | 377 | $addon->initialize_db_if_no_migrations_required(); |
378 | 378 | } |
379 | 379 | } |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @param string $current_version_to_add version to be added to the version history |
386 | 386 | * @return boolean success as to whether or not this option was changed |
387 | 387 | */ |
388 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
389 | - if( ! $version_history ) { |
|
388 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
389 | + if ( ! $version_history) { |
|
390 | 390 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
391 | 391 | } |
392 | - if( $current_version_to_add == NULL){ |
|
392 | + if ($current_version_to_add == NULL) { |
|
393 | 393 | $current_version_to_add = espresso_version(); |
394 | 394 | } |
395 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
395 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
396 | 396 | // re-save |
397 | - return update_option( 'espresso_db_update', $version_history ); |
|
397 | + return update_option('espresso_db_update', $version_history); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * but still know if this is a new install or not |
412 | 412 | * @return int one of the constants on EE_System::req_type_ |
413 | 413 | */ |
414 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
415 | - if ( $this->_req_type === NULL ){ |
|
416 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
417 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
414 | + public function detect_req_type($espresso_db_update = NULL) { |
|
415 | + if ($this->_req_type === NULL) { |
|
416 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
417 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
418 | 418 | } |
419 | 419 | return $this->_req_type; |
420 | 420 | } |
@@ -430,39 +430,39 @@ discard block |
||
430 | 430 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
431 | 431 | * @return int one of the constants on EE_System::req_type_* |
432 | 432 | */ |
433 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
434 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
435 | - if( $activation_history_for_addon ){ |
|
433 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
434 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
435 | + if ($activation_history_for_addon) { |
|
436 | 436 | //it exists, so this isn't a completely new install |
437 | 437 | //check if this version already in that list of previously installed versions |
438 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
438 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
439 | 439 | //it a version we haven't seen before |
440 | - if( $version_is_higher === 1 ){ |
|
440 | + if ($version_is_higher === 1) { |
|
441 | 441 | $req_type = EE_System::req_type_upgrade; |
442 | - }else{ |
|
442 | + } else { |
|
443 | 443 | $req_type = EE_System::req_type_downgrade; |
444 | 444 | } |
445 | - delete_option( $activation_indicator_option_name ); |
|
445 | + delete_option($activation_indicator_option_name); |
|
446 | 446 | } else { |
447 | 447 | // its not an update. maybe a reactivation? |
448 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
449 | - if ( $version_is_higher === -1 ){ |
|
448 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
449 | + if ($version_is_higher === -1) { |
|
450 | 450 | $req_type = EE_System::req_type_downgrade; |
451 | - }elseif( $version_is_higher === 0 ){ |
|
451 | + }elseif ($version_is_higher === 0) { |
|
452 | 452 | //we've seen this version before, but it's an activation. must be a reactivation |
453 | 453 | $req_type = EE_System::req_type_reactivation; |
454 | - }else{//$version_is_higher === 1 |
|
454 | + } else {//$version_is_higher === 1 |
|
455 | 455 | $req_type = EE_System::req_type_upgrade; |
456 | 456 | } |
457 | - delete_option( $activation_indicator_option_name ); |
|
457 | + delete_option($activation_indicator_option_name); |
|
458 | 458 | } else { |
459 | 459 | //we've seen this version before and the activation indicate doesn't show it was just activated |
460 | - if ( $version_is_higher === -1 ){ |
|
460 | + if ($version_is_higher === -1) { |
|
461 | 461 | $req_type = EE_System::req_type_downgrade; |
462 | - }elseif( $version_is_higher === 0 ){ |
|
462 | + }elseif ($version_is_higher === 0) { |
|
463 | 463 | //we've seen this version before and it's not an activation. its normal request |
464 | 464 | $req_type = EE_System::req_type_normal; |
465 | - }else{//$version_is_higher === 1 |
|
465 | + } else {//$version_is_higher === 1 |
|
466 | 466 | $req_type = EE_System::req_type_upgrade; |
467 | 467 | } |
468 | 468 | } |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | } else { |
471 | 471 | //brand new install |
472 | 472 | $req_type = EE_System::req_type_new_activation; |
473 | - delete_option( $activation_indicator_option_name ); |
|
473 | + delete_option($activation_indicator_option_name); |
|
474 | 474 | } |
475 | 475 | return $req_type; |
476 | 476 | } |
@@ -488,30 +488,30 @@ discard block |
||
488 | 488 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
489 | 489 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
490 | 490 | */ |
491 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
491 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
492 | 492 | //find the most recently-activated version |
493 | 493 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
494 | 494 | $most_recently_active_version = '0.0.0.dev.000'; |
495 | - if( is_array( $activation_history_for_addon ) ){ |
|
496 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
495 | + if (is_array($activation_history_for_addon)) { |
|
496 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
497 | 497 | //check there is a record of when this version was activated. Otherwise, |
498 | 498 | //mark it as unknown |
499 | - if( ! $times_activated ){ |
|
500 | - $times_activated = array( 'unknown-date'); |
|
499 | + if ( ! $times_activated) { |
|
500 | + $times_activated = array('unknown-date'); |
|
501 | 501 | } |
502 | - if( is_string( $times_activated ) ){ |
|
503 | - $times_activated = array( $times_activated ); |
|
502 | + if (is_string($times_activated)) { |
|
503 | + $times_activated = array($times_activated); |
|
504 | 504 | } |
505 | - foreach( $times_activated as $an_activation ){ |
|
506 | - if( $an_activation != 'unknown-date' && |
|
507 | - $an_activation > $most_recently_active_version_activation ){ |
|
505 | + foreach ($times_activated as $an_activation) { |
|
506 | + if ($an_activation != 'unknown-date' && |
|
507 | + $an_activation > $most_recently_active_version_activation) { |
|
508 | 508 | $most_recently_active_version = $version; |
509 | 509 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
510 | 510 | } |
511 | 511 | } |
512 | 512 | } |
513 | 513 | } |
514 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
514 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | |
@@ -521,24 +521,24 @@ discard block |
||
521 | 521 | * @return void |
522 | 522 | */ |
523 | 523 | public function redirect_to_about_ee() { |
524 | - $notices = EE_Error::get_notices( FALSE ); |
|
524 | + $notices = EE_Error::get_notices(FALSE); |
|
525 | 525 | //if current user is an admin and it's not an ajax request |
526 | 526 | if ( |
527 | - $this->registry->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) |
|
528 | - && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
529 | - && ! isset( $notices[ 'errors' ] ) |
|
527 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
528 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
529 | + && ! isset($notices['errors']) |
|
530 | 530 | ) { |
531 | - $query_params = array( 'page' => 'espresso_about' ); |
|
531 | + $query_params = array('page' => 'espresso_about'); |
|
532 | 532 | |
533 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
533 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
534 | 534 | $query_params['new_activation'] = TRUE; |
535 | 535 | } |
536 | 536 | |
537 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
537 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
538 | 538 | $query_params['reactivation'] = TRUE; |
539 | 539 | } |
540 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
541 | - wp_safe_redirect( $url ); |
|
540 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
541 | + wp_safe_redirect($url); |
|
542 | 542 | exit(); |
543 | 543 | } |
544 | 544 | } |
@@ -552,31 +552,31 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return void |
554 | 554 | */ |
555 | - public function load_core_configuration(){ |
|
556 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
557 | - $this->registry->load_core( 'EE_Load_Textdomain' ); |
|
555 | + public function load_core_configuration() { |
|
556 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
557 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
558 | 558 | //load textdomain |
559 | 559 | EE_Load_Textdomain::load_textdomain(); |
560 | 560 | // load and setup EE_Config and EE_Network_Config |
561 | - $this->registry->load_core( 'Config' ); |
|
562 | - $this->registry->load_core( 'Network_Config' ); |
|
561 | + $this->registry->load_core('Config'); |
|
562 | + $this->registry->load_core('Network_Config'); |
|
563 | 563 | // setup autoloaders |
564 | 564 | // enable logging? |
565 | - if ( $this->registry->CFG->admin->use_full_logging ) { |
|
566 | - $this->registry->load_core( 'Log' ); |
|
565 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
566 | + $this->registry->load_core('Log'); |
|
567 | 567 | } |
568 | 568 | // check for activation errors |
569 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
570 | - if ( $activation_errors ) { |
|
571 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
572 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
569 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
570 | + if ($activation_errors) { |
|
571 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
572 | + update_option('ee_plugin_activation_errors', FALSE); |
|
573 | 573 | } |
574 | 574 | // get model names |
575 | 575 | $this->_parse_model_names(); |
576 | 576 | |
577 | 577 | //load caf stuff a chance to play during the activation process too. |
578 | 578 | $this->_maybe_brew_regular(); |
579 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
579 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -585,23 +585,23 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return void |
587 | 587 | */ |
588 | - private function _parse_model_names(){ |
|
588 | + private function _parse_model_names() { |
|
589 | 589 | //get all the files in the EE_MODELS folder that end in .model.php |
590 | - $models = glob( EE_MODELS.'*.model.php'); |
|
590 | + $models = glob(EE_MODELS.'*.model.php'); |
|
591 | 591 | $model_names = array(); |
592 | 592 | $non_abstract_db_models = array(); |
593 | - foreach( $models as $model ){ |
|
593 | + foreach ($models as $model) { |
|
594 | 594 | // get model classname |
595 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
596 | - $short_name = str_replace( 'EEM_', '', $classname ); |
|
595 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
596 | + $short_name = str_replace('EEM_', '', $classname); |
|
597 | 597 | $reflectionClass = new ReflectionClass($classname); |
598 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
599 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
598 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
599 | + $non_abstract_db_models[$short_name] = $classname; |
|
600 | 600 | } |
601 | - $model_names[ $short_name ] = $classname; |
|
601 | + $model_names[$short_name] = $classname; |
|
602 | 602 | } |
603 | - $this->registry->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
604 | - $this->registry->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
603 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
604 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | |
@@ -611,8 +611,8 @@ discard block |
||
611 | 611 | * @return void |
612 | 612 | */ |
613 | 613 | private function _maybe_brew_regular() { |
614 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
615 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
614 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
615 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | * @return void |
630 | 630 | */ |
631 | 631 | public function register_shortcodes_modules_and_widgets() { |
632 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
632 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
633 | 633 | // check for addons using old hookpoint |
634 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
634 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
635 | 635 | $this->_incompatible_addon_error(); |
636 | 636 | } |
637 | 637 | } |
@@ -645,19 +645,19 @@ discard block |
||
645 | 645 | */ |
646 | 646 | private function _incompatible_addon_error() { |
647 | 647 | // get array of classes hooking into here |
648 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
649 | - if ( ! empty( $class_names )) { |
|
650 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
648 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
649 | + if ( ! empty($class_names)) { |
|
650 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
651 | 651 | $msg .= '<ul>'; |
652 | - foreach ( $class_names as $class_name ) { |
|
653 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
652 | + foreach ($class_names as $class_name) { |
|
653 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
654 | 654 | } |
655 | 655 | $msg .= '</ul>'; |
656 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
656 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
657 | 657 | // save list of incompatible addons to wp-options for later use |
658 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
659 | - if ( is_admin() ) { |
|
660 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
658 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
659 | + if (is_admin()) { |
|
660 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | } |
@@ -674,26 +674,26 @@ discard block |
||
674 | 674 | * |
675 | 675 | * @return void |
676 | 676 | */ |
677 | - public function brew_espresso(){ |
|
678 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
677 | + public function brew_espresso() { |
|
678 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
679 | 679 | // load some final core systems |
680 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
681 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
682 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
683 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
684 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
685 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
686 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
687 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
688 | - add_action('admin_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
689 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
690 | - |
|
691 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
680 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
681 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
682 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
683 | + add_action('init', array($this, 'load_controllers'), 7); |
|
684 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
685 | + add_action('init', array($this, 'initialize'), 10); |
|
686 | + add_action('init', array($this, 'initialize_last'), 100); |
|
687 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
688 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
689 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
690 | + |
|
691 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
692 | 692 | // pew pew pew |
693 | - $this->registry->load_core( 'PUE' ); |
|
694 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
693 | + $this->registry->load_core('PUE'); |
|
694 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
695 | 695 | } |
696 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
696 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | */ |
708 | 708 | public function set_hooks_for_core() { |
709 | 709 | $this->_deactivate_incompatible_addons(); |
710 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
710 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | |
@@ -716,15 +716,15 @@ discard block |
||
716 | 716 | * Using the information gathered in EE_System::_incompatible_addon_error, |
717 | 717 | * deactivates any addons considered incompatible with the current version of EE |
718 | 718 | */ |
719 | - private function _deactivate_incompatible_addons(){ |
|
720 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
721 | - if ( ! empty( $incompatible_addons )) { |
|
722 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
723 | - foreach ( $active_plugins as $active_plugin ) { |
|
724 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
725 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
726 | - unset( $_GET['activate'] ); |
|
727 | - espresso_deactivate_plugin( $active_plugin ); |
|
719 | + private function _deactivate_incompatible_addons() { |
|
720 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
721 | + if ( ! empty($incompatible_addons)) { |
|
722 | + $active_plugins = get_option('active_plugins', array()); |
|
723 | + foreach ($active_plugins as $active_plugin) { |
|
724 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
725 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
726 | + unset($_GET['activate']); |
|
727 | + espresso_deactivate_plugin($active_plugin); |
|
728 | 728 | } |
729 | 729 | } |
730 | 730 | } |
@@ -741,10 +741,10 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function perform_activations_upgrades_and_migrations() { |
743 | 743 | //first check if we had previously attempted to setup EE's directories but failed |
744 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
744 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
745 | 745 | EEH_Activation::create_upload_directories(); |
746 | 746 | } |
747 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
747 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | |
@@ -756,10 +756,10 @@ discard block |
||
756 | 756 | * @return void |
757 | 757 | */ |
758 | 758 | public function load_CPTs_and_session() { |
759 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
759 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
760 | 760 | // register Custom Post Types |
761 | - $this->registry->load_core( 'Register_CPTs' ); |
|
762 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
761 | + $this->registry->load_core('Register_CPTs'); |
|
762 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | |
@@ -774,16 +774,16 @@ discard block |
||
774 | 774 | * @return void |
775 | 775 | */ |
776 | 776 | public function load_controllers() { |
777 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
777 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
778 | 778 | // let's get it started |
779 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
780 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
781 | - $this->registry->load_core( 'Front_Controller', array(), false, true ); |
|
782 | - } else if ( ! EE_FRONT_AJAX ) { |
|
783 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
784 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
779 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
780 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
781 | + $this->registry->load_core('Front_Controller', array(), false, true); |
|
782 | + } else if ( ! EE_FRONT_AJAX) { |
|
783 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
784 | + EE_Registry::instance()->load_core('Admin'); |
|
785 | 785 | } |
786 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
786 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | * @return void |
798 | 798 | */ |
799 | 799 | public function core_loaded_and_ready() { |
800 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
801 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
802 | - $this->registry->load_core( 'Session' ); |
|
800 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
801 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
802 | + $this->registry->load_core('Session'); |
|
803 | 803 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
804 | 804 | } |
805 | 805 | |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | * @return void |
815 | 815 | */ |
816 | 816 | public function initialize() { |
817 | - do_action( 'AHEE__EE_System__initialize' ); |
|
817 | + do_action('AHEE__EE_System__initialize'); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | * @return void |
829 | 829 | */ |
830 | 830 | public function initialize_last() { |
831 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
831 | + do_action('AHEE__EE_System__initialize_last'); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | |
@@ -860,21 +860,21 @@ discard block |
||
860 | 860 | */ |
861 | 861 | public static function do_not_cache() { |
862 | 862 | // set no cache constants |
863 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
864 | - define( 'DONOTCACHEPAGE', true ); |
|
863 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
864 | + define('DONOTCACHEPAGE', true); |
|
865 | 865 | } |
866 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
867 | - define( 'DONOTCACHCEOBJECT', true ); |
|
866 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
867 | + define('DONOTCACHCEOBJECT', true); |
|
868 | 868 | } |
869 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
870 | - define( 'DONOTCACHEDB', true ); |
|
869 | + if ( ! defined('DONOTCACHEDB')) { |
|
870 | + define('DONOTCACHEDB', true); |
|
871 | 871 | } |
872 | 872 | // add no cache headers |
873 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
873 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
874 | 874 | // plus a little extra for nginx and Google Chrome |
875 | - add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 ); |
|
875 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
876 | 876 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
877 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
877 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * @param $headers |
887 | 887 | * @return array |
888 | 888 | */ |
889 | - public static function extra_nocache_headers ( $headers ) { |
|
889 | + public static function extra_nocache_headers($headers) { |
|
890 | 890 | // for NGINX |
891 | 891 | $headers['X-Accel-Expires'] = 0; |
892 | 892 | // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
@@ -915,14 +915,14 @@ discard block |
||
915 | 915 | * @param WP_Admin_Bar $admin_bar |
916 | 916 | * @return void |
917 | 917 | */ |
918 | - public function espresso_toolbar_items( WP_Admin_Bar $admin_bar ) { |
|
918 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) { |
|
919 | 919 | |
920 | 920 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
921 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
921 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
922 | 922 | return; |
923 | 923 | } |
924 | 924 | |
925 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
925 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
926 | 926 | $menu_class = 'espresso_menu_item_class'; |
927 | 927 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
928 | 928 | //because they're only defined in each of their respective constructors |
@@ -934,20 +934,20 @@ discard block |
||
934 | 934 | //Top Level |
935 | 935 | $admin_bar->add_menu(array( |
936 | 936 | 'id' => 'espresso-toolbar', |
937 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
937 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
938 | 938 | 'href' => $events_admin_url, |
939 | 939 | 'meta' => array( |
940 | 940 | 'title' => __('Event Espresso', 'event_espresso'), |
941 | - 'class' => $menu_class . 'first' |
|
941 | + 'class' => $menu_class.'first' |
|
942 | 942 | ), |
943 | 943 | )); |
944 | 944 | |
945 | 945 | //Events |
946 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
946 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
947 | 947 | $admin_bar->add_menu(array( |
948 | 948 | 'id' => 'espresso-toolbar-events', |
949 | 949 | 'parent' => 'espresso-toolbar', |
950 | - 'title' => __( 'Events', 'event_espresso' ), |
|
950 | + 'title' => __('Events', 'event_espresso'), |
|
951 | 951 | 'href' => $events_admin_url, |
952 | 952 | 'meta' => array( |
953 | 953 | 'title' => __('Events', 'event_espresso'), |
@@ -958,13 +958,13 @@ discard block |
||
958 | 958 | } |
959 | 959 | |
960 | 960 | |
961 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
961 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
962 | 962 | //Events Add New |
963 | 963 | $admin_bar->add_menu(array( |
964 | 964 | 'id' => 'espresso-toolbar-events-new', |
965 | 965 | 'parent' => 'espresso-toolbar-events', |
966 | 966 | 'title' => __('Add New', 'event_espresso'), |
967 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
967 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
968 | 968 | 'meta' => array( |
969 | 969 | 'title' => __('Add New', 'event_espresso'), |
970 | 970 | 'target' => '', |
@@ -973,18 +973,18 @@ discard block |
||
973 | 973 | )); |
974 | 974 | } |
975 | 975 | |
976 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
976 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
977 | 977 | |
978 | 978 | //Current post |
979 | 979 | global $post; |
980 | 980 | |
981 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
981 | + if ($this->registry->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
982 | 982 | //Events Edit Current Event |
983 | 983 | $admin_bar->add_menu(array( |
984 | 984 | 'id' => 'espresso-toolbar-events-edit', |
985 | 985 | 'parent' => 'espresso-toolbar-events', |
986 | 986 | 'title' => __('Edit Event', 'event_espresso'), |
987 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
987 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
988 | 988 | 'meta' => array( |
989 | 989 | 'title' => __('Edit Event', 'event_espresso'), |
990 | 990 | 'target' => '', |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | } |
997 | 997 | |
998 | 998 | //Events View |
999 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
999 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
1000 | 1000 | $admin_bar->add_menu(array( |
1001 | 1001 | 'id' => 'espresso-toolbar-events-view', |
1002 | 1002 | 'parent' => 'espresso-toolbar-events', |
1003 | - 'title' => __( 'View', 'event_espresso' ), |
|
1003 | + 'title' => __('View', 'event_espresso'), |
|
1004 | 1004 | 'href' => $events_admin_url, |
1005 | 1005 | 'meta' => array( |
1006 | 1006 | 'title' => __('View', 'event_espresso'), |
@@ -1010,12 +1010,12 @@ discard block |
||
1010 | 1010 | )); |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
1013 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1014 | 1014 | //Events View All |
1015 | 1015 | $admin_bar->add_menu(array( |
1016 | 1016 | 'id' => 'espresso-toolbar-events-all', |
1017 | 1017 | 'parent' => 'espresso-toolbar-events-view', |
1018 | - 'title' => __( 'All', 'event_espresso' ), |
|
1018 | + 'title' => __('All', 'event_espresso'), |
|
1019 | 1019 | 'href' => $events_admin_url, |
1020 | 1020 | 'meta' => array( |
1021 | 1021 | 'title' => __('All', 'event_espresso'), |
@@ -1026,13 +1026,13 @@ discard block |
||
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
1029 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1029 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1030 | 1030 | //Events View Today |
1031 | 1031 | $admin_bar->add_menu(array( |
1032 | 1032 | 'id' => 'espresso-toolbar-events-today', |
1033 | 1033 | 'parent' => 'espresso-toolbar-events-view', |
1034 | 1034 | 'title' => __('Today', 'event_espresso'), |
1035 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1035 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1036 | 1036 | 'meta' => array( |
1037 | 1037 | 'title' => __('Today', 'event_espresso'), |
1038 | 1038 | 'target' => '', |
@@ -1042,13 +1042,13 @@ discard block |
||
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | |
1045 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1045 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1046 | 1046 | //Events View This Month |
1047 | 1047 | $admin_bar->add_menu(array( |
1048 | 1048 | 'id' => 'espresso-toolbar-events-month', |
1049 | 1049 | 'parent' => 'espresso-toolbar-events-view', |
1050 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1051 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1050 | + 'title' => __('This Month', 'event_espresso'), |
|
1051 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1052 | 1052 | 'meta' => array( |
1053 | 1053 | 'title' => __('This Month', 'event_espresso'), |
1054 | 1054 | 'target' => '', |
@@ -1058,11 +1058,11 @@ discard block |
||
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | //Registration Overview |
1061 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1061 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1062 | 1062 | $admin_bar->add_menu(array( |
1063 | 1063 | 'id' => 'espresso-toolbar-registrations', |
1064 | 1064 | 'parent' => 'espresso-toolbar', |
1065 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1065 | + 'title' => __('Registrations', 'event_espresso'), |
|
1066 | 1066 | 'href' => $reg_admin_url, |
1067 | 1067 | 'meta' => array( |
1068 | 1068 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1073,12 +1073,12 @@ discard block |
||
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | //Registration Overview Today |
1076 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1076 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1077 | 1077 | $admin_bar->add_menu(array( |
1078 | 1078 | 'id' => 'espresso-toolbar-registrations-today', |
1079 | 1079 | 'parent' => 'espresso-toolbar-registrations', |
1080 | - 'title' => __( 'Today', 'event_espresso'), |
|
1081 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1080 | + 'title' => __('Today', 'event_espresso'), |
|
1081 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1082 | 1082 | 'meta' => array( |
1083 | 1083 | 'title' => __('Today', 'event_espresso'), |
1084 | 1084 | 'target' => '', |
@@ -1088,14 +1088,14 @@ discard block |
||
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | //Registration Overview Today Completed |
1091 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1091 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1092 | 1092 | $admin_bar->add_menu(array( |
1093 | 1093 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1094 | 1094 | 'parent' => 'espresso-toolbar-registrations-today', |
1095 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1096 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1095 | + 'title' => __('Approved', 'event_espresso'), |
|
1096 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1097 | 1097 | 'meta' => array( |
1098 | - 'title' => __('Approved', 'event_espresso' ), |
|
1098 | + 'title' => __('Approved', 'event_espresso'), |
|
1099 | 1099 | 'target' => '', |
1100 | 1100 | 'class' => $menu_class |
1101 | 1101 | ), |
@@ -1103,14 +1103,14 @@ discard block |
||
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | //Registration Overview Today Pending\ |
1106 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1106 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1107 | 1107 | $admin_bar->add_menu(array( |
1108 | 1108 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1109 | 1109 | 'parent' => 'espresso-toolbar-registrations-today', |
1110 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1111 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1110 | + 'title' => __('Pending', 'event_espresso'), |
|
1111 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1112 | 1112 | 'meta' => array( |
1113 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1113 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1114 | 1114 | 'target' => '', |
1115 | 1115 | 'class' => $menu_class |
1116 | 1116 | ), |
@@ -1118,14 +1118,14 @@ discard block |
||
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | //Registration Overview Today Incomplete |
1121 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1121 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1122 | 1122 | $admin_bar->add_menu(array( |
1123 | 1123 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1124 | 1124 | 'parent' => 'espresso-toolbar-registrations-today', |
1125 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1126 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1125 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1126 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1127 | 1127 | 'meta' => array( |
1128 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1128 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1129 | 1129 | 'target' => '', |
1130 | 1130 | 'class' => $menu_class |
1131 | 1131 | ), |
@@ -1133,12 +1133,12 @@ discard block |
||
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | //Registration Overview Today Incomplete |
1136 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1136 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1137 | 1137 | $admin_bar->add_menu(array( |
1138 | 1138 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1139 | 1139 | 'parent' => 'espresso-toolbar-registrations-today', |
1140 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1141 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1140 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1141 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1142 | 1142 | 'meta' => array( |
1143 | 1143 | 'title' => __('Cancelled', 'event_espresso'), |
1144 | 1144 | 'target' => '', |
@@ -1148,12 +1148,12 @@ discard block |
||
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | //Registration Overview This Month |
1151 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1151 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1152 | 1152 | $admin_bar->add_menu(array( |
1153 | 1153 | 'id' => 'espresso-toolbar-registrations-month', |
1154 | 1154 | 'parent' => 'espresso-toolbar-registrations', |
1155 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1156 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1155 | + 'title' => __('This Month', 'event_espresso'), |
|
1156 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1157 | 1157 | 'meta' => array( |
1158 | 1158 | 'title' => __('This Month', 'event_espresso'), |
1159 | 1159 | 'target' => '', |
@@ -1163,12 +1163,12 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | //Registration Overview This Month Approved |
1166 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1166 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1167 | 1167 | $admin_bar->add_menu(array( |
1168 | 1168 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1169 | 1169 | 'parent' => 'espresso-toolbar-registrations-month', |
1170 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1171 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1170 | + 'title' => __('Approved', 'event_espresso'), |
|
1171 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1172 | 1172 | 'meta' => array( |
1173 | 1173 | 'title' => __('Approved', 'event_espresso'), |
1174 | 1174 | 'target' => '', |
@@ -1178,12 +1178,12 @@ discard block |
||
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | //Registration Overview This Month Pending |
1181 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1181 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1182 | 1182 | $admin_bar->add_menu(array( |
1183 | 1183 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1184 | 1184 | 'parent' => 'espresso-toolbar-registrations-month', |
1185 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1186 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1185 | + 'title' => __('Pending', 'event_espresso'), |
|
1186 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1187 | 1187 | 'meta' => array( |
1188 | 1188 | 'title' => __('Pending', 'event_espresso'), |
1189 | 1189 | 'target' => '', |
@@ -1193,14 +1193,14 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | //Registration Overview This Month Not Approved |
1196 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1196 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1197 | 1197 | $admin_bar->add_menu(array( |
1198 | 1198 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1199 | 1199 | 'parent' => 'espresso-toolbar-registrations-month', |
1200 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1201 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1200 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1201 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1202 | 1202 | 'meta' => array( |
1203 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1203 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1204 | 1204 | 'target' => '', |
1205 | 1205 | 'class' => $menu_class |
1206 | 1206 | ), |
@@ -1209,12 +1209,12 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | |
1211 | 1211 | //Registration Overview This Month Cancelled |
1212 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1212 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1213 | 1213 | $admin_bar->add_menu(array( |
1214 | 1214 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1215 | 1215 | 'parent' => 'espresso-toolbar-registrations-month', |
1216 | 1216 | 'title' => __('Cancelled', 'event_espresso'), |
1217 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1217 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1218 | 1218 | 'meta' => array( |
1219 | 1219 | 'title' => __('Cancelled', 'event_espresso'), |
1220 | 1220 | 'target' => '', |
@@ -1224,11 +1224,11 @@ discard block |
||
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | //Extensions & Services |
1227 | - if ( $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1227 | + if ($this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1228 | 1228 | $admin_bar->add_menu(array( |
1229 | 1229 | 'id' => 'espresso-toolbar-extensions-and-services', |
1230 | 1230 | 'parent' => 'espresso-toolbar', |
1231 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1231 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1232 | 1232 | 'href' => $extensions_admin_url, |
1233 | 1233 | 'meta' => array( |
1234 | 1234 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1250,8 +1250,8 @@ discard block |
||
1250 | 1250 | * @param array $exclude_array any existing pages being excluded are in this array. |
1251 | 1251 | * @return array |
1252 | 1252 | */ |
1253 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1254 | - return array_merge( $exclude_array, $this->registry->CFG->core->get_critical_pages_array() ); |
|
1253 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1254 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
@@ -1271,15 +1271,15 @@ discard block |
||
1271 | 1271 | */ |
1272 | 1272 | public function wp_enqueue_scripts() { |
1273 | 1273 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1274 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1274 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1275 | 1275 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1276 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1276 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1277 | 1277 | // register jQuery Validate and additional methods |
1278 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE ); |
|
1279 | - wp_register_script( 'jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', array( 'jquery', 'jquery-validate' ), '1.15.0', TRUE ); |
|
1278 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
1279 | + wp_register_script('jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', array('jquery', 'jquery-validate'), '1.15.0', TRUE); |
|
1280 | 1280 | } |
1281 | - wp_register_script( 'select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true ); |
|
1282 | - wp_register_style( 'select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all' ); |
|
1281 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', array(), '4.0.2', true); |
|
1282 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
1283 | 1283 | } |
1284 | 1284 | } |
1285 | 1285 |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | * @param EE_Message_Resource_Manager $message_resource_manager |
39 | 39 | * @param EE_Request_Handler $request |
40 | 40 | */ |
41 | - public function __construct( EE_Message_Resource_Manager $message_resource_manager, EE_Request_Handler $request ) { |
|
41 | + public function __construct(EE_Message_Resource_Manager $message_resource_manager, EE_Request_Handler $request) { |
|
42 | 42 | parent::__construct( |
43 | - $request->get( 'gen_msgr' ), |
|
44 | - $request->get( 'message_type' ), |
|
43 | + $request->get('gen_msgr'), |
|
44 | + $request->get('message_type'), |
|
45 | 45 | array(), |
46 | - $request->get( 'context' ) |
|
46 | + $request->get('context') |
|
47 | 47 | ); |
48 | - if ( ! $this->valid() ) { |
|
48 | + if ( ! $this->valid()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | - $this->_sending_messenger = $message_resource_manager->get_active_messenger( $request->get( 'snd_msgr' ) ); |
|
52 | - $this->token = $request->get( 'token' ); |
|
51 | + $this->_sending_messenger = $message_resource_manager->get_active_messenger($request->get('snd_msgr')); |
|
52 | + $this->token = $request->get('token'); |
|
53 | 53 | $this->_validate_request(); |
54 | - $this->_data = $this->_get_data_from_request( $request->get( 'id' ) ); |
|
54 | + $this->_data = $this->_get_data_from_request($request->get('id')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | ! $this->_sending_messenger instanceof EE_Messenger |
76 | 76 | || ! $this->_messenger instanceof EE_Messenger |
77 | 77 | || ! $this->_message_type instanceof EE_message_type |
78 | - || empty( $this->_context ) |
|
79 | - || empty( $this->token ) |
|
78 | + || empty($this->_context) |
|
79 | + || empty($this->token) |
|
80 | 80 | ) { |
81 | - throw new EE_Error( __( 'The request for the "msg_url_trigger" route has a malformed url.', 'event_espresso' ) ); |
|
81 | + throw new EE_Error(__('The request for the "msg_url_trigger" route has a malformed url.', 'event_espresso')); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | * @throws EE_Error |
91 | 91 | * @return mixed (whatever the data is returned from the message type). |
92 | 92 | */ |
93 | - protected function _get_data_from_request( $id ) { |
|
93 | + protected function _get_data_from_request($id) { |
|
94 | 94 | //get the EE_Registration from the token |
95 | 95 | /** @type EE_Registration $registration */ |
96 | - $registration = EEM_Registration::instance()->get_one( array( array( 'REG_url_link' => $this->token ) ) ); |
|
96 | + $registration = EEM_Registration::instance()->get_one(array(array('REG_url_link' => $this->token))); |
|
97 | 97 | //if no registration then bail early. |
98 | - if ( ! $registration instanceof EE_Registration ) { |
|
99 | - throw new EE_Error( __( 'Unable to complete the request because the token is invalid.', 'event_espresso' ) ); |
|
98 | + if ( ! $registration instanceof EE_Registration) { |
|
99 | + throw new EE_Error(__('Unable to complete the request because the token is invalid.', 'event_espresso')); |
|
100 | 100 | } |
101 | 101 | |
102 | - return $this->_get_data_to_use( $registration, $id ); |
|
102 | + return $this->_get_data_to_use($registration, $id); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @param int $data_id This is sometimes used for secondary data a message type requires. |
112 | 112 | * @return mixed Data prepared as needed for generating this message. |
113 | 113 | */ |
114 | - protected function _get_data_to_use( $registration, $data_id ) { |
|
114 | + protected function _get_data_to_use($registration, $data_id) { |
|
115 | 115 | //use incoming data from url to setup data for the message type requirements |
116 | - return $this->_message_type->get_data_for_context( $this->_context, $registration, $data_id ); |
|
116 | + return $this->_message_type->get_data_for_context($this->_context, $registration, $data_id); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * EE_Messages_Validator class |
@@ -121,13 +122,14 @@ discard block |
||
121 | 122 | */ |
122 | 123 | public function __construct( $fields, $context ) { |
123 | 124 | //check that _m_name and _mt_name have been set by child class otherwise we get out. |
124 | - if ( empty($this->_m_name ) || empty( $this->_mt_name) ) |
|
125 | - throw new EE_Error( |
|
125 | + if ( empty($this->_m_name ) || empty( $this->_mt_name) ) { |
|
126 | + throw new EE_Error( |
|
126 | 127 | __( |
127 | 128 | 'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property. Check that the child class is doing this', |
128 | 129 | 'event_espresso' |
129 | 130 | ) |
130 | 131 | ); |
132 | + } |
|
131 | 133 | $this->_fields = $fields; |
132 | 134 | $this->_context = $context; |
133 | 135 | |
@@ -228,8 +230,10 @@ discard block |
||
228 | 230 | $groups_per_field = array(); |
229 | 231 | |
230 | 232 | foreach ( $msgr_validator as $field => $config ) { |
231 | - if ( empty($config) || !isset($config['shortcodes']) ) |
|
232 | - continue; //Nothing to see here. |
|
233 | + if ( empty($config) || !isset($config['shortcodes']) ) { |
|
234 | + continue; |
|
235 | + } |
|
236 | + //Nothing to see here. |
|
233 | 237 | $groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes ); |
234 | 238 | $shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups ); |
235 | 239 | } |
@@ -268,8 +272,9 @@ discard block |
||
268 | 272 | $required = isset($config['required']) |
269 | 273 | ? array_intersect($config['required'], array_keys($mt_codes)) |
270 | 274 | : true; |
271 | - if ( empty($required) ) |
|
272 | - continue; |
|
275 | + if ( empty($required) ) { |
|
276 | + continue; |
|
277 | + } |
|
273 | 278 | |
274 | 279 | //If we have an override then we use it to indicate the codes we want. |
275 | 280 | if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) { |
@@ -310,8 +315,9 @@ discard block |
||
310 | 315 | $specific_excludes = $this->get_specific_shortcode_excludes(); |
311 | 316 | if ( isset( $specific_excludes[$field] ) ) { |
312 | 317 | foreach( $specific_excludes[$field] as $sex ) { |
313 | - if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) |
|
314 | - unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
318 | + if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) { |
|
319 | + unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
320 | + } |
|
315 | 321 | } |
316 | 322 | } |
317 | 323 | |
@@ -385,10 +391,13 @@ discard block |
||
385 | 391 | //get the translated field label! |
386 | 392 | //first check if it's in the main fields list |
387 | 393 | if ( isset( $template_fields[$field] ) ) { |
388 | - if ( empty( $template_fields[$field] ) ) |
|
389 | - $field_label = $field; //most likely the field is found in the 'extra' array. |
|
390 | - else |
|
391 | - $field_label = $template_fields[$field]['label']; |
|
394 | + if ( empty( $template_fields[$field] ) ) { |
|
395 | + $field_label = $field; |
|
396 | + } |
|
397 | + //most likely the field is found in the 'extra' array. |
|
398 | + else { |
|
399 | + $field_label = $template_fields[$field]['label']; |
|
400 | + } |
|
392 | 401 | } |
393 | 402 | |
394 | 403 | // if field label is empty OR is equal to the current field |
@@ -402,8 +411,9 @@ discard block |
||
402 | 411 | |
403 | 412 | // if we've got a 'main' secondary field, let's see if that matches what field we're on |
404 | 413 | // which means it contains the label for this field. |
405 | - if ( $name == 'main' && $main_field == $field_label ) |
|
406 | - $field_label = $values['label']; |
|
414 | + if ( $name == 'main' && $main_field == $field_label ) { |
|
415 | + $field_label = $values['label']; |
|
416 | + } |
|
407 | 417 | } |
408 | 418 | } |
409 | 419 | } |
@@ -439,8 +449,8 @@ discard block |
||
439 | 449 | if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) { |
440 | 450 | switch ( $this->_validators[$field]['type'] ) { |
441 | 451 | case 'number' : |
442 | - if ( !is_numeric($value) ) |
|
443 | - $err_msg .= sprintf( |
|
452 | + if ( !is_numeric($value) ) { |
|
453 | + $err_msg .= sprintf( |
|
444 | 454 | __( |
445 | 455 | '%3$sThe %1$s field is supposed to be a number. The value given (%2$s) is not. Please double-check and make sure the field contains a number%4$s', |
446 | 456 | 'event_espresso' |
@@ -450,11 +460,12 @@ discard block |
||
450 | 460 | '<p>', |
451 | 461 | '</p >' |
452 | 462 | ); |
463 | + } |
|
453 | 464 | break; |
454 | 465 | case 'email' : |
455 | 466 | $valid_email = $this->_validate_email($value); |
456 | - if ( !$valid_email ) |
|
457 | - $err_msg .= htmlentities( |
|
467 | + if ( !$valid_email ) { |
|
468 | + $err_msg .= htmlentities( |
|
458 | 469 | sprintf( |
459 | 470 | __( |
460 | 471 | 'The %1$s field has at least one string that is not a valid email address record. Valid emails are in the format: "Name <[email protected]>" or "[email protected]" and multiple emails can be separated by a comma.' |
@@ -463,6 +474,7 @@ discard block |
||
463 | 474 | |
464 | 475 | ) |
465 | 476 | ); |
477 | + } |
|
466 | 478 | break; |
467 | 479 | default : |
468 | 480 | break; |
@@ -539,7 +551,10 @@ discard block |
||
539 | 551 | } |
540 | 552 | } |
541 | 553 | |
542 | - if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
554 | + if ( empty( $diff ) ) { |
|
555 | + return FALSE; |
|
556 | + } |
|
557 | + //there is no diff, we have no invalid shortcodes, so return |
|
543 | 558 | |
544 | 559 | //made it here? then let's assemble the error message |
545 | 560 | $invalid_shortcodes = implode( '</strong>,<strong>', $diff ); |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | |
562 | 577 | // empty strings will validate because this is how a message template |
563 | 578 | // for a particular context can be "turned off" (if there is no email then no message) |
564 | - if ( empty( $value ) ) |
|
565 | - return $validate; |
|
579 | + if ( empty( $value ) ) { |
|
580 | + return $validate; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | // first determine if there ARE any shortcodes. |
568 | 584 | // If there are shortcodes and then later we find that there were no other valid emails |
@@ -579,8 +595,9 @@ discard block |
||
579 | 595 | // its possible that this message is being "turned off" for a particular context |
580 | 596 | |
581 | 597 | |
582 | - if ( !empty($or_val) && empty($value) ) |
|
583 | - return $validate; |
|
598 | + if ( !empty($or_val) && empty($value) ) { |
|
599 | + return $validate; |
|
600 | + } |
|
584 | 601 | |
585 | 602 | //trim any commas from beginning and end of string ( after whitespace trimmed ); |
586 | 603 | $value = trim( trim($value), ',' ); |
@@ -601,12 +618,12 @@ discard block |
||
601 | 618 | //either its of type "[email protected]", or its of type "fname lname <[email protected]>" |
602 | 619 | if(is_email($email)){ |
603 | 620 | continue; |
604 | - }else{ |
|
621 | + } else{ |
|
605 | 622 | $matches = array(); |
606 | 623 | $validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE; |
607 | 624 | if( $validate && is_email($matches[2])){ |
608 | 625 | continue; |
609 | - }else{ |
|
626 | + } else{ |
|
610 | 627 | return false; |
611 | 628 | } |
612 | 629 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param $context |
120 | 120 | * @throws \EE_Error |
121 | 121 | */ |
122 | - public function __construct( $fields, $context ) { |
|
122 | + public function __construct($fields, $context) { |
|
123 | 123 | //check that _m_name and _mt_name have been set by child class otherwise we get out. |
124 | - if ( empty($this->_m_name ) || empty( $this->_mt_name) ) |
|
124 | + if (empty($this->_m_name) || empty($this->_mt_name)) |
|
125 | 125 | throw new EE_Error( |
126 | 126 | __( |
127 | 127 | 'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property. Check that the child class is doing this', |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function _load_objects() { |
169 | 169 | //load messenger |
170 | - $messenger = ucwords( str_replace( '_', ' ', $this->_m_name ) ); |
|
171 | - $messenger = str_replace( ' ', '_', $messenger ); |
|
172 | - $messenger = 'EE_' . $messenger . '_messenger'; |
|
170 | + $messenger = ucwords(str_replace('_', ' ', $this->_m_name)); |
|
171 | + $messenger = str_replace(' ', '_', $messenger); |
|
172 | + $messenger = 'EE_'.$messenger.'_messenger'; |
|
173 | 173 | |
174 | - if ( ! class_exists( $messenger ) ) { |
|
174 | + if ( ! class_exists($messenger)) { |
|
175 | 175 | throw new EE_Error( |
176 | 176 | sprintf( |
177 | - __( 'There is no messenger class for the given string (%s)', 'event_espresso' ), |
|
177 | + __('There is no messenger class for the given string (%s)', 'event_espresso'), |
|
178 | 178 | $this->_m_name |
179 | 179 | ) |
180 | 180 | ); |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | $this->_messenger = new $messenger(); |
184 | 184 | |
185 | 185 | //load message type |
186 | - $message_type = ucwords( str_replace( '_', ' ', $this->_mt_name ) ); |
|
187 | - $message_type = str_replace( ' ', '_', $message_type ); |
|
188 | - $message_type = 'EE_' . $message_type . '_message_type'; |
|
186 | + $message_type = ucwords(str_replace('_', ' ', $this->_mt_name)); |
|
187 | + $message_type = str_replace(' ', '_', $message_type); |
|
188 | + $message_type = 'EE_'.$message_type.'_message_type'; |
|
189 | 189 | |
190 | - if ( !class_exists( $message_type ) ) { |
|
190 | + if ( ! class_exists($message_type)) { |
|
191 | 191 | throw new EE_Error( |
192 | 192 | sprintf( |
193 | - __( 'There is no message type class for the given string (%s)', 'event_espresso' ), |
|
193 | + __('There is no message type class for the given string (%s)', 'event_espresso'), |
|
194 | 194 | $this->_mt_name |
195 | 195 | ) |
196 | 196 | ); |
@@ -227,25 +227,25 @@ discard block |
||
227 | 227 | $shortcode_groups = $mt_codes; |
228 | 228 | $groups_per_field = array(); |
229 | 229 | |
230 | - foreach ( $msgr_validator as $field => $config ) { |
|
231 | - if ( empty($config) || !isset($config['shortcodes']) ) |
|
232 | - continue; //Nothing to see here. |
|
233 | - $groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes ); |
|
234 | - $shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups ); |
|
230 | + foreach ($msgr_validator as $field => $config) { |
|
231 | + if (empty($config) || ! isset($config['shortcodes'])) |
|
232 | + continue; //Nothing to see here. |
|
233 | + $groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes); |
|
234 | + $shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups); |
|
235 | 235 | } |
236 | 236 | |
237 | - $shortcode_groups = array_unique( $shortcode_groups); |
|
237 | + $shortcode_groups = array_unique($shortcode_groups); |
|
238 | 238 | |
239 | 239 | // okay now we've got our groups. |
240 | 240 | // Let's get the codes from the objects into an array indexed by group for easy retrieval later. |
241 | 241 | $codes_from_objs = array(); |
242 | 242 | |
243 | - foreach ( $shortcode_groups as $group ) { |
|
244 | - $ref = ucwords( str_replace('_', ' ', $group ) ); |
|
245 | - $ref = str_replace( ' ', '_', $ref ); |
|
246 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
247 | - if ( class_exists( $classname ) ) { |
|
248 | - $a = new ReflectionClass( $classname ); |
|
243 | + foreach ($shortcode_groups as $group) { |
|
244 | + $ref = ucwords(str_replace('_', ' ', $group)); |
|
245 | + $ref = str_replace(' ', '_', $ref); |
|
246 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
247 | + if (class_exists($classname)) { |
|
248 | + $a = new ReflectionClass($classname); |
|
249 | 249 | $obj = $a->newInstance(); |
250 | 250 | $codes_from_objs[$group] = $obj->get_shortcodes(); |
251 | 251 | } |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | //let's just replace the $mt shortcode group indexes with the actual shortcodes (unique) |
256 | 256 | $final_mt_codes = array(); |
257 | - foreach ( $mt_codes as $group ) { |
|
258 | - $final_mt_codes = array_merge( $final_mt_codes, $codes_from_objs[$group] ); |
|
257 | + foreach ($mt_codes as $group) { |
|
258 | + $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $mt_codes = $final_mt_codes; |
@@ -263,60 +263,60 @@ discard block |
||
263 | 263 | |
264 | 264 | // k now in this next loop we're going to loop through $msgr_validator again |
265 | 265 | // and setup the _validators property from the data we've setup so far. |
266 | - foreach ( $msgr_validator as $field => $config ) { |
|
266 | + foreach ($msgr_validator as $field => $config) { |
|
267 | 267 | //if required shortcode is not in our list of codes for the given field, then we skip this field. |
268 | 268 | $required = isset($config['required']) |
269 | 269 | ? array_intersect($config['required'], array_keys($mt_codes)) |
270 | 270 | : true; |
271 | - if ( empty($required) ) |
|
271 | + if (empty($required)) |
|
272 | 272 | continue; |
273 | 273 | |
274 | 274 | //If we have an override then we use it to indicate the codes we want. |
275 | - if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) { |
|
276 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | - $this->_valid_shortcodes_modifier[ $context ][ $field ], |
|
275 | + if (isset($this->_valid_shortcodes_modifier[$context][$field])) { |
|
276 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | + $this->_valid_shortcodes_modifier[$context][$field], |
|
278 | 278 | $codes_from_objs |
279 | 279 | ); |
280 | 280 | } |
281 | 281 | |
282 | 282 | //if we have specific shortcodes for a field then we need to use them |
283 | - else if ( isset( $groups_per_field[$field] ) ) { |
|
284 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | - $groups_per_field[ $field ], |
|
283 | + else if (isset($groups_per_field[$field])) { |
|
284 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | + $groups_per_field[$field], |
|
286 | 286 | $codes_from_objs |
287 | 287 | ); |
288 | 288 | } |
289 | 289 | |
290 | 290 | //if empty config then we're assuming we're just going to use the shortcodes from the message type context |
291 | - else if ( empty( $config ) ) { |
|
291 | + else if (empty($config)) { |
|
292 | 292 | $this->_validators[$field]['shortcodes'] = $mt_codes; |
293 | 293 | } |
294 | 294 | |
295 | 295 | //if we have specific shortcodes then we need to use them |
296 | - else if ( isset($config['specific_shortcodes'] ) ) { |
|
296 | + else if (isset($config['specific_shortcodes'])) { |
|
297 | 297 | $this->_validators[$field]['shortcodes'] = $config['specific_shortcodes']; |
298 | 298 | } |
299 | 299 | |
300 | 300 | //otherwise the shortcodes are what is set by the messenger for that field |
301 | 301 | else { |
302 | - foreach ( $config['shortcodes'] as $group ) { |
|
302 | + foreach ($config['shortcodes'] as $group) { |
|
303 | 303 | $this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes']) |
304 | - ? array_merge( $this->_validators[$field]['shortcodes'], $codes_from_objs[$group] ) |
|
304 | + ? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group]) |
|
305 | 305 | : $codes_from_objs[$group]; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | //now let's just make sure that any excluded specific shortcodes are removed. |
310 | 310 | $specific_excludes = $this->get_specific_shortcode_excludes(); |
311 | - if ( isset( $specific_excludes[$field] ) ) { |
|
312 | - foreach( $specific_excludes[$field] as $sex ) { |
|
313 | - if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) |
|
314 | - unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
311 | + if (isset($specific_excludes[$field])) { |
|
312 | + foreach ($specific_excludes[$field] as $sex) { |
|
313 | + if (isset($this->_validators[$field]['shortcodes'][$sex])) |
|
314 | + unset($this->_validators[$field]['shortcodes'][$sex]); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | 318 | //hey! don't forget to include the type if present! |
319 | - $this->_validators[$field]['type'] = isset( $config['type'] ) ? $config['type'] : NULL; |
|
319 | + $this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : NULL; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function get_specific_shortcode_excludes() { |
345 | 345 | //specific validator filter |
346 | 346 | $shortcode_excludes = apply_filters( |
347 | - 'FHEE__' . get_class( $this ) . '__get_specific_shortcode_excludes;', |
|
347 | + 'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;', |
|
348 | 348 | $this->_specific_shortcode_excludes, |
349 | 349 | $this->_context |
350 | 350 | ); |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | //some defaults |
373 | 373 | $template_fields = $this->_messenger->get_template_fields(); |
374 | 374 | //loop through the fields and check! |
375 | - foreach ( $this->_fields as $field => $value ) { |
|
375 | + foreach ($this->_fields as $field => $value) { |
|
376 | 376 | $this->_errors[$field] = array(); |
377 | 377 | $err_msg = ''; |
378 | 378 | $field_label = ''; |
379 | 379 | //if field is not present in the _validators array then we continue |
380 | - if ( !isset( $this->_validators[$field] ) ) { |
|
381 | - unset( $this->_errors[$field] ); |
|
380 | + if ( ! isset($this->_validators[$field])) { |
|
381 | + unset($this->_errors[$field]); |
|
382 | 382 | continue; |
383 | 383 | } |
384 | 384 | |
385 | 385 | //get the translated field label! |
386 | 386 | //first check if it's in the main fields list |
387 | - if ( isset( $template_fields[$field] ) ) { |
|
388 | - if ( empty( $template_fields[$field] ) ) |
|
387 | + if (isset($template_fields[$field])) { |
|
388 | + if (empty($template_fields[$field])) |
|
389 | 389 | $field_label = $field; //most likely the field is found in the 'extra' array. |
390 | 390 | else |
391 | 391 | $field_label = $template_fields[$field]['label']; |
@@ -393,16 +393,16 @@ discard block |
||
393 | 393 | |
394 | 394 | // if field label is empty OR is equal to the current field |
395 | 395 | // then we need to loop through the 'extra' fields in the template_fields config (if present) |
396 | - if ( isset( $template_fields['extra'] ) && ( empty($field_label) ) || $field_label == $field ) { |
|
397 | - foreach( $template_fields['extra'] as $main_field => $secondary_field ) { |
|
398 | - foreach ( $secondary_field as $name => $values ) { |
|
399 | - if ( $name == $field ) { |
|
396 | + if (isset($template_fields['extra']) && (empty($field_label)) || $field_label == $field) { |
|
397 | + foreach ($template_fields['extra'] as $main_field => $secondary_field) { |
|
398 | + foreach ($secondary_field as $name => $values) { |
|
399 | + if ($name == $field) { |
|
400 | 400 | $field_label = $values['label']; |
401 | 401 | } |
402 | 402 | |
403 | 403 | // if we've got a 'main' secondary field, let's see if that matches what field we're on |
404 | 404 | // which means it contains the label for this field. |
405 | - if ( $name == 'main' && $main_field == $field_label ) |
|
405 | + if ($name == 'main' && $main_field == $field_label) |
|
406 | 406 | $field_label = $values['label']; |
407 | 407 | } |
408 | 408 | } |
@@ -410,27 +410,27 @@ discard block |
||
410 | 410 | |
411 | 411 | //field is present. Let's validate shortcodes first (but only if shortcodes present). |
412 | 412 | if ( |
413 | - isset( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
414 | - && ! empty( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
413 | + isset($this->_validators[$field]['shortcodes']) |
|
414 | + && ! empty($this->_validators[$field]['shortcodes']) |
|
415 | 415 | ) { |
416 | - $invalid_shortcodes = $this->_invalid_shortcodes( $value, $this->_validators[$field]['shortcodes'] ); |
|
416 | + $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']); |
|
417 | 417 | // if true then that means there is a returned error message |
418 | 418 | // that we'll need to add to the _errors array for this field. |
419 | - if ( $invalid_shortcodes ) { |
|
419 | + if ($invalid_shortcodes) { |
|
420 | 420 | $v_s = array_keys($this->_validators[$field]['shortcodes']); |
421 | 421 | $err_msg = sprintf( |
422 | 422 | __( |
423 | 423 | '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s', |
424 | 424 | 'event_espresso' |
425 | 425 | ), |
426 | - '<strong>' . $field_label . '</strong>', |
|
426 | + '<strong>'.$field_label.'</strong>', |
|
427 | 427 | $invalid_shortcodes, |
428 | 428 | '<p>', |
429 | 429 | '</p >' |
430 | 430 | ); |
431 | 431 | $err_msg .= sprintf( |
432 | - __( '%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso' ), |
|
433 | - implode( ', ', $v_s ), |
|
432 | + __('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'), |
|
433 | + implode(', ', $v_s), |
|
434 | 434 | '<strong>', |
435 | 435 | '</strong>' |
436 | 436 | ); |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | //if there's a "type" to be validated then let's do that too. |
441 | - if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) { |
|
442 | - switch ( $this->_validators[$field]['type'] ) { |
|
441 | + if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) { |
|
442 | + switch ($this->_validators[$field]['type']) { |
|
443 | 443 | case 'number' : |
444 | - if ( !is_numeric($value) ) |
|
444 | + if ( ! is_numeric($value)) |
|
445 | 445 | $err_msg .= sprintf( |
446 | 446 | __( |
447 | 447 | '%3$sThe %1$s field is supposed to be a number. The value given (%2$s) is not. Please double-check and make sure the field contains a number%4$s', |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | break; |
456 | 456 | case 'email' : |
457 | 457 | $valid_email = $this->_validate_email($value); |
458 | - if ( !$valid_email ) |
|
458 | + if ( ! $valid_email) |
|
459 | 459 | $err_msg .= htmlentities( |
460 | 460 | sprintf( |
461 | 461 | __( |
@@ -472,23 +472,23 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | //if $err_msg isn't empty let's setup the _errors array for this field. |
475 | - if ( !empty($err_msg ) ) { |
|
475 | + if ( ! empty($err_msg)) { |
|
476 | 476 | $this->_errors[$field]['msg'] = $err_msg; |
477 | 477 | } else { |
478 | - unset( $this->_errors[$field] ); |
|
478 | + unset($this->_errors[$field]); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | 482 | // if we have ANY errors, then we want to make sure we return the values |
483 | 483 | // for ALL the fields so the user doesn't have to retype them all. |
484 | - if ( !empty( $this->_errors ) ) { |
|
485 | - foreach ( $this->_fields as $field => $value ) { |
|
484 | + if ( ! empty($this->_errors)) { |
|
485 | + foreach ($this->_fields as $field => $value) { |
|
486 | 486 | $this->_errors[$field]['value'] = stripslashes($value); |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | 490 | //return any errors or just TRUE if everything validates |
491 | - return empty( $this->_errors ) ? TRUE : $this->_errors; |
|
491 | + return empty($this->_errors) ? TRUE : $this->_errors; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | * @param array $codes_from_objs All the codes available. |
502 | 502 | * @return array an array of actual shortcodes (that will be used for validation). |
503 | 503 | */ |
504 | - private function _reassemble_valid_shortcodes_from_group( $groups, $codes_from_objs ) { |
|
504 | + private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs) { |
|
505 | 505 | $shortcodes = array(); |
506 | - foreach ( $groups as $group ) { |
|
507 | - $shortcodes = array_merge( $shortcodes, $codes_from_objs[$group] ); |
|
506 | + foreach ($groups as $group) { |
|
507 | + $shortcodes = array_merge($shortcodes, $codes_from_objs[$group]); |
|
508 | 508 | } |
509 | 509 | return $shortcodes; |
510 | 510 | } |
@@ -523,29 +523,29 @@ discard block |
||
523 | 523 | */ |
524 | 524 | protected function _invalid_shortcodes($value, $valid_shortcodes) { |
525 | 525 | //first we need to go through the string and get the shortcodes in the string |
526 | - preg_match_all( '/(\[.+?\])/', $value, $matches ); |
|
526 | + preg_match_all('/(\[.+?\])/', $value, $matches); |
|
527 | 527 | $incoming_shortcodes = (array) $matches[0]; |
528 | 528 | |
529 | 529 | //get a diff of the shortcodes in the string vs the valid shortcodes |
530 | - $diff = array_diff( $incoming_shortcodes, array_keys($valid_shortcodes) ); |
|
530 | + $diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes)); |
|
531 | 531 | |
532 | 532 | //we need to account for custom codes so let's loop through the diff and remove any of those type of codes |
533 | - foreach ( $diff as $ind => $code ) { |
|
534 | - if ( preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code ) ) { |
|
533 | + foreach ($diff as $ind => $code) { |
|
534 | + if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) { |
|
535 | 535 | //strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] ) |
536 | 536 | $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code); |
537 | 537 | //does this exist in the $valid_shortcodes? If so then unset. |
538 | - if ( isset( $valid_shortcodes[$dynamic_sc] ) ) { |
|
539 | - unset( $diff[$ind] ); |
|
538 | + if (isset($valid_shortcodes[$dynamic_sc])) { |
|
539 | + unset($diff[$ind]); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | - if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
544 | + if (empty($diff)) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
545 | 545 | |
546 | 546 | //made it here? then let's assemble the error message |
547 | - $invalid_shortcodes = implode( '</strong>,<strong>', $diff ); |
|
548 | - $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>'; |
|
547 | + $invalid_shortcodes = implode('</strong>,<strong>', $diff); |
|
548 | + $invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>'; |
|
549 | 549 | return $invalid_shortcodes; |
550 | 550 | } |
551 | 551 | |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | * @param string $value incoming value to validate |
558 | 558 | * @return bool true if the string validates, false if it doesn't |
559 | 559 | */ |
560 | - protected function _validate_email( $value ) { |
|
560 | + protected function _validate_email($value) { |
|
561 | 561 | $validate = TRUE; |
562 | 562 | $or_val = $value; |
563 | 563 | |
564 | 564 | // empty strings will validate because this is how a message template |
565 | 565 | // for a particular context can be "turned off" (if there is no email then no message) |
566 | - if ( empty( $value ) ) |
|
566 | + if (empty($value)) |
|
567 | 567 | return $validate; |
568 | 568 | |
569 | 569 | // first determine if there ARE any shortcodes. |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | // its possible that this message is being "turned off" for a particular context |
582 | 582 | |
583 | 583 | |
584 | - if ( !empty($or_val) && empty($value) ) |
|
584 | + if ( ! empty($or_val) && empty($value)) |
|
585 | 585 | return $validate; |
586 | 586 | |
587 | 587 | //trim any commas from beginning and end of string ( after whitespace trimmed ); |
588 | - $value = trim( trim($value), ',' ); |
|
588 | + $value = trim(trim($value), ','); |
|
589 | 589 | |
590 | 590 | |
591 | 591 | //next we need to split up the string if its comma delimited. |
592 | 592 | $emails = explode(',', $value); |
593 | 593 | $empty = FALSE; //used to indicate that there is an empty comma. |
594 | 594 | //now let's loop through the emails and do our checks |
595 | - foreach ( $emails as $email ) { |
|
596 | - if ( empty($email) ) { |
|
595 | + foreach ($emails as $email) { |
|
596 | + if (empty($email)) { |
|
597 | 597 | $empty = TRUE; |
598 | 598 | continue; |
599 | 599 | } |
@@ -601,20 +601,20 @@ discard block |
||
601 | 601 | //trim whitespace |
602 | 602 | $email = trim($email); |
603 | 603 | //either its of type "[email protected]", or its of type "fname lname <[email protected]>" |
604 | - if(is_email($email)){ |
|
604 | + if (is_email($email)) { |
|
605 | 605 | continue; |
606 | - }else{ |
|
606 | + } else { |
|
607 | 607 | $matches = array(); |
608 | - $validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE; |
|
609 | - if( $validate && is_email($matches[2])){ |
|
608 | + $validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? TRUE : FALSE; |
|
609 | + if ($validate && is_email($matches[2])) { |
|
610 | 610 | continue; |
611 | - }else{ |
|
611 | + } else { |
|
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - $validate = $empty && !$has_shortcodes ? FALSE : $validate; |
|
617 | + $validate = $empty && ! $has_shortcodes ? FALSE : $validate; |
|
618 | 618 | |
619 | 619 | return $validate; |
620 | 620 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @throws Exception |
631 | 631 | * @return mixed |
632 | 632 | */ |
633 | - public function __get( $property ) { |
|
633 | + public function __get($property) { |
|
634 | 634 | $expected_properties_map = array( |
635 | 635 | /** |
636 | 636 | * @deprecated 4.9.0 |
@@ -642,15 +642,15 @@ discard block |
||
642 | 642 | '_MSGTYP' => '_message_type' |
643 | 643 | ); |
644 | 644 | |
645 | - if ( isset( $expected_properties_map[ $property ] ) ) { |
|
646 | - return $this->{$expected_properties_map[ $property ]}; |
|
645 | + if (isset($expected_properties_map[$property])) { |
|
646 | + return $this->{$expected_properties_map[$property]}; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | throw new Exception( |
650 | 650 | sprintf( |
651 | - __( 'The property %1$s being requested on %2$s does not exist', 'event_espresso' ), |
|
651 | + __('The property %1$s being requested on %2$s does not exist', 'event_espresso'), |
|
652 | 652 | $property, |
653 | - get_class( $this ) |
|
653 | + get_class($this) |
|
654 | 654 | ) |
655 | 655 | ); |
656 | 656 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class EE_Messages_Email_Payment_Reminder_Validator extends EE_Messages_Validator { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $fields, $context ) { |
|
33 | + public function __construct($fields, $context) { |
|
34 | 34 | $this->_m_name = 'email'; |
35 | 35 | $this->_mt_name = 'payment_reminder'; |
36 | 36 | |
37 | - parent::__construct( $fields, $context ); |
|
37 | + parent::__construct($fields, $context); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | //modify just event_list |
47 | 47 | $new_config['event_list'] = array( |
48 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
48 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list') |
|
49 | 49 | ); |
50 | 50 | $new_config['ticket_list'] = array( |
51 | 51 | 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction') |
52 | 52 | ); |
53 | 53 | $new_config['content'] = array( |
54 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
54 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger') |
|
55 | 55 | ); |
56 | - $this->_messenger->set_validator_config( $new_config ); |
|
56 | + $this->_messenger->set_validator_config($new_config); |
|
57 | 57 | |
58 | - if ( $this->_context != 'admin' ) |
|
58 | + if ($this->_context != 'admin') |
|
59 | 59 | $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'); |
60 | 60 | |
61 | 61 | $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'); |