@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * |
113 | 113 | * @throws EE_Error |
114 | - */ |
|
114 | + */ |
|
115 | 115 | protected function _load_active_messenger_objects() { |
116 | 116 | foreach ( $this->_active_messengers as $messenger => $values ) { |
117 | 117 | $ref = ucwords( str_replace( '_' , ' ', $messenger) ); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * loads messenger objects into the $_active_messengers property (so we can access the needed methods) |
134 | 134 | * |
135 | 135 | * @throws EE_Error |
136 | - */ |
|
136 | + */ |
|
137 | 137 | protected function _load_active_message_type_objects() { |
138 | 138 | if ( empty($this->_active_message_types) ) {return;} |
139 | 139 | foreach ( $this->_active_message_types as $message_type ) { |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | |
185 | 185 | /** |
186 | 186 | * an array for storing key => value pairs of request actions and their corresponding methods |
187 | - * @access protected |
|
188 | - * @return void |
|
189 | - */ |
|
187 | + * @access protected |
|
188 | + * @return void |
|
189 | + */ |
|
190 | 190 | protected function _set_page_routes() { |
191 | 191 | $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
192 | 192 | $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $grp_id; |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | protected function _add_screen_options_global_mtps() { |
487 | 487 | /** |
488 | 488 | * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options |
489 | - * uses the $_admin_page_title property and we want different outputs in the different spots. |
|
490 | - */ |
|
489 | + * uses the $_admin_page_title property and we want different outputs in the different spots. |
|
490 | + */ |
|
491 | 491 | $page_title = $this->_admin_page_title; |
492 | 492 | $this->_admin_page_title = __('Global Message Templates', 'event_espresso'); |
493 | 493 | $this->_per_page_screen_option(); |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
698 | 698 | ? array( |
699 | 699 | 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
700 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
701 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
702 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
700 | + 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
701 | + 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
702 | + 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
703 | 703 | ) |
704 | 704 | : array(); |
705 | 705 | |
@@ -710,10 +710,10 @@ discard block |
||
710 | 710 | |
711 | 711 | $this->_views = array( |
712 | 712 | 'all' => array( |
713 | - 'slug' => 'all', |
|
714 | - 'label' => __( 'All', 'event_espresso' ), |
|
715 | - 'count' => 0, |
|
716 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
713 | + 'slug' => 'all', |
|
714 | + 'label' => __( 'All', 'event_espresso' ), |
|
715 | + 'count' => 0, |
|
716 | + 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
717 | 717 | ) |
718 | 718 | ); |
719 | 719 | |
@@ -1359,8 +1359,8 @@ discard block |
||
1359 | 1359 | $GRP_ID, |
1360 | 1360 | false, |
1361 | 1361 | add_query_arg( |
1362 | - array( 'action' => 'global_mtps' ), |
|
1363 | - $this->_admin_base_url |
|
1362 | + array( 'action' => 'global_mtps' ), |
|
1363 | + $this->_admin_base_url |
|
1364 | 1364 | ) |
1365 | 1365 | ); |
1366 | 1366 | |
@@ -1750,14 +1750,14 @@ discard block |
||
1750 | 1750 | |
1751 | 1751 | |
1752 | 1752 | /** |
1753 | - * This returns the shortcode selector skeleton for a given context and field. |
|
1754 | - * |
|
1755 | - * @since 4.9.rc.000 |
|
1756 | - * |
|
1753 | + * This returns the shortcode selector skeleton for a given context and field. |
|
1754 | + * |
|
1755 | + * @since 4.9.rc.000 |
|
1756 | + * |
|
1757 | 1757 | * @param string $field The name of the field retrieving shortcodes for. |
1758 | - * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
|
1759 | - * @return string |
|
1760 | - */ |
|
1758 | + * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
|
1759 | + * @return string |
|
1760 | + */ |
|
1761 | 1761 | protected function _get_shortcode_selector( $field, $linked_input_id ) { |
1762 | 1762 | $template_args = array( |
1763 | 1763 | 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
@@ -2316,9 +2316,9 @@ discard block |
||
2316 | 2316 | |
2317 | 2317 | /** |
2318 | 2318 | * _learn_more_about_message_templates_link |
2319 | - * @access protected |
|
2320 | - * @return string |
|
2321 | - */ |
|
2319 | + * @access protected |
|
2320 | + * @return string |
|
2321 | + */ |
|
2322 | 2322 | protected function _learn_more_about_message_templates_link() { |
2323 | 2323 | return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
2324 | 2324 | } |
@@ -3029,10 +3029,10 @@ discard block |
||
3029 | 3029 | |
3030 | 3030 | /** |
3031 | 3031 | * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete |
3032 | - * However, this does not send immediately, it just queues for sending. |
|
3033 | - * |
|
3034 | - * @since 4.9.0 |
|
3035 | - */ |
|
3032 | + * However, this does not send immediately, it just queues for sending. |
|
3033 | + * |
|
3034 | + * @since 4.9.0 |
|
3035 | + */ |
|
3036 | 3036 | protected function _generate_now() { |
3037 | 3037 | $msg_ids = $this->_get_msg_ids_from_request(); |
3038 | 3038 | EED_Messages::generate_now( $msg_ids ); |
@@ -3043,11 +3043,11 @@ discard block |
||
3043 | 3043 | |
3044 | 3044 | /** |
3045 | 3045 | * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that are |
3046 | - * EEM_Message::status_resend or EEM_Message::status_idle |
|
3047 | - * |
|
3048 | - * @since 4.9.0 |
|
3049 | - * |
|
3050 | - */ |
|
3046 | + * EEM_Message::status_resend or EEM_Message::status_idle |
|
3047 | + * |
|
3048 | + * @since 4.9.0 |
|
3049 | + * |
|
3050 | + */ |
|
3051 | 3051 | protected function _generate_and_send_now() { |
3052 | 3052 | $this->_generate_now(); |
3053 | 3053 | $this->_send_now(); |
@@ -3060,9 +3060,9 @@ discard block |
||
3060 | 3060 | |
3061 | 3061 | /** |
3062 | 3062 | * This queues any EEM_Message::status_sent EE_Message ids in the request for resending. |
3063 | - * |
|
3064 | - * @since 4.9.0 |
|
3065 | - */ |
|
3063 | + * |
|
3064 | + * @since 4.9.0 |
|
3065 | + */ |
|
3066 | 3066 | protected function _queue_for_resending() { |
3067 | 3067 | $msg_ids = $this->_get_msg_ids_from_request(); |
3068 | 3068 | EED_Messages::queue_for_resending( $msg_ids ); |
@@ -3074,9 +3074,9 @@ discard block |
||
3074 | 3074 | |
3075 | 3075 | /** |
3076 | 3076 | * This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue |
3077 | - * |
|
3078 | - * @since 4.9.0 |
|
3079 | - */ |
|
3077 | + * |
|
3078 | + * @since 4.9.0 |
|
3079 | + */ |
|
3080 | 3080 | protected function _send_now() { |
3081 | 3081 | $msg_ids = $this->_get_msg_ids_from_request(); |
3082 | 3082 | EED_Messages::send_now( $msg_ids ); |
@@ -3088,9 +3088,9 @@ discard block |
||
3088 | 3088 | |
3089 | 3089 | /** |
3090 | 3090 | * Deletes EE_Messages for IDs in the request. |
3091 | - * |
|
3092 | - * @since 4.9.0 |
|
3093 | - */ |
|
3091 | + * |
|
3092 | + * @since 4.9.0 |
|
3093 | + */ |
|
3094 | 3094 | protected function _delete_ee_messages() { |
3095 | 3095 | $msg_ids = $this->_get_msg_ids_from_request(); |
3096 | 3096 | $deleted_count = 0; |
@@ -3119,9 +3119,9 @@ discard block |
||
3119 | 3119 | |
3120 | 3120 | /** |
3121 | 3121 | * This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present. |
3122 | - * @since 4.9.0 |
|
3123 | - * @return array |
|
3124 | - */ |
|
3122 | + * @since 4.9.0 |
|
3123 | + * @return array |
|
3124 | + */ |
|
3125 | 3125 | protected function _get_msg_ids_from_request() { |
3126 | 3126 | if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
3127 | 3127 | return array(); |
@@ -2337,7 +2337,7 @@ discard block |
||
2337 | 2337 | * @param int $GRP_ID The group being deleted |
2338 | 2338 | * @param bool $include_group whether to delete the Message Template Group as well. |
2339 | 2339 | * |
2340 | - * @return bool boolean to indicate the success of the deletes or not. |
|
2340 | + * @return integer boolean to indicate the success of the deletes or not. |
|
2341 | 2341 | */ |
2342 | 2342 | private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
2343 | 2343 | $success = 1; |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | * This just prepares the content for the message type settings |
2475 | 2475 | * |
2476 | 2476 | * @param object $message_type The message type object |
2477 | - * @param object $messenger The messenger object |
|
2477 | + * @param EE_Messenger $messenger The messenger object |
|
2478 | 2478 | * @param boolean $active Whether the message type is active or not |
2479 | 2479 | * |
2480 | 2480 | * @return string html output for the content |
@@ -2834,7 +2834,7 @@ discard block |
||
2834 | 2834 | * |
2835 | 2835 | * @param string $messenger What messenger we're toggling |
2836 | 2836 | * @param boolean $deactivate if true then we deactivate |
2837 | - * @param mixed $message_type if present what message type we're toggling |
|
2837 | + * @param null|string $message_type if present what message type we're toggling |
|
2838 | 2838 | * |
2839 | 2839 | * @return bool |
2840 | 2840 | */ |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | - {exit('NO direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | + {exit('NO direct script access allowed'); } |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @param bool $routing |
96 | 96 | */ |
97 | - public function __construct( $routing = true ) { |
|
97 | + public function __construct($routing = true) { |
|
98 | 98 | //make sure MSG Template helper is loaded. |
99 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
99 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
100 | 100 | //make sure messages autoloader is running |
101 | 101 | EED_Messages::set_autoloaders(); |
102 | - parent::__construct( $routing ); |
|
102 | + parent::__construct($routing); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
115 | 115 | |
116 | - $this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null; |
|
116 | + $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
|
117 | 117 | $this->_load_message_resource_manager(); |
118 | 118 | //we're also going to set the active messengers and active message types in here. |
119 | 119 | $this->_active_messengers = $this->_message_resource_manager->active_messengers(); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @throws EE_Error |
135 | 135 | */ |
136 | 136 | protected function _load_message_resource_manager() { |
137 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
137 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | $messengers = $this->_message_resource_manager->active_messengers(); |
151 | 151 | //setup messengers for selects |
152 | 152 | $i = 1; |
153 | - foreach ( $messengers as $messenger_name => $messenger ) { |
|
154 | - if ( $messenger instanceof EE_Messenger ) { |
|
155 | - $m_values[ $i ][ 'id' ] = $messenger_name; |
|
156 | - $m_values[ $i ][ 'text' ] = ucwords( $messenger->label[ 'singular' ] ); |
|
153 | + foreach ($messengers as $messenger_name => $messenger) { |
|
154 | + if ($messenger instanceof EE_Messenger) { |
|
155 | + $m_values[$i]['id'] = $messenger_name; |
|
156 | + $m_values[$i]['text'] = ucwords($messenger->label['singular']); |
|
157 | 157 | $i++; |
158 | 158 | } |
159 | 159 | } |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | $mt_values = array(); |
173 | 173 | $message_types = $this->_message_resource_manager->active_message_types(); |
174 | 174 | $i = 1; |
175 | - foreach ( $message_types as $messenger_name => $message_type ) { |
|
176 | - foreach ( $message_type as $message_type_name => $args ) { |
|
177 | - $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
178 | - if ( $message_type instanceof EE_Message_Type ) { |
|
179 | - $mt_values[ $i ][ 'id' ] = $message_type_name; |
|
180 | - $mt_values[ $i ][ 'text' ] = ucwords( $message_type->label[ 'singular' ] ); |
|
175 | + foreach ($message_types as $messenger_name => $message_type) { |
|
176 | + foreach ($message_type as $message_type_name => $args) { |
|
177 | + $message_type = $this->_message_resource_manager->get_message_type($message_type_name); |
|
178 | + if ($message_type instanceof EE_Message_Type) { |
|
179 | + $mt_values[$i]['id'] = $message_type_name; |
|
180 | + $mt_values[$i]['text'] = ucwords($message_type->label['singular']); |
|
181 | 181 | $i++; |
182 | 182 | } |
183 | 183 | } |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | protected function _ajax_hooks() { |
191 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
192 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
193 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
194 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
195 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
191 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
192 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
193 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
194 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
195 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | * @return void |
225 | 225 | */ |
226 | 226 | protected function _set_page_routes() { |
227 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
227 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
228 | 228 | ? $this->_req_data['GRP_ID'] |
229 | 229 | : 0; |
230 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
230 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
231 | 231 | ? $this->_req_data['id'] |
232 | 232 | : $grp_id; |
233 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
233 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
234 | 234 | ? $this->_req_data['MSG_ID'] |
235 | 235 | : 0; |
236 | 236 | |
@@ -272,35 +272,35 @@ discard block |
||
272 | 272 | 'insert_message_template' => array( |
273 | 273 | 'func' => '_insert_or_update_message_template', |
274 | 274 | 'capability' => 'ee_edit_messages', |
275 | - 'args' => array( 'new_template' => true ), |
|
275 | + 'args' => array('new_template' => true), |
|
276 | 276 | 'noheader' => true |
277 | 277 | ), |
278 | 278 | 'update_message_template' => array( |
279 | 279 | 'func' => '_insert_or_update_message_template', |
280 | 280 | 'capability' => 'ee_edit_message', |
281 | 281 | 'obj_id' => $grp_id, |
282 | - 'args' => array( 'new_template' => false ), |
|
282 | + 'args' => array('new_template' => false), |
|
283 | 283 | 'noheader' => true |
284 | 284 | ), |
285 | 285 | 'trash_message_template' => array( |
286 | 286 | 'func' => '_trash_or_restore_message_template', |
287 | 287 | 'capability' => 'ee_delete_message', |
288 | 288 | 'obj_id' => $grp_id, |
289 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
289 | + 'args' => array('trash' => true, 'all' => true), |
|
290 | 290 | 'noheader' => true |
291 | 291 | ), |
292 | 292 | 'trash_message_template_context' => array( |
293 | 293 | 'func' => '_trash_or_restore_message_template', |
294 | 294 | 'capability' => 'ee_delete_message', |
295 | 295 | 'obj_id' => $grp_id, |
296 | - 'args' => array( 'trash' => true ), |
|
296 | + 'args' => array('trash' => true), |
|
297 | 297 | 'noheader' => true |
298 | 298 | ), |
299 | 299 | 'restore_message_template' => array( |
300 | 300 | 'func' => '_trash_or_restore_message_template', |
301 | 301 | 'capability' => 'ee_delete_message', |
302 | 302 | 'obj_id' => $grp_id, |
303 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
303 | + 'args' => array('trash' => false, 'all' => true), |
|
304 | 304 | 'noheader' => true |
305 | 305 | ), |
306 | 306 | 'restore_message_template_context' => array( |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | 'order' => 10 |
376 | 376 | ), |
377 | 377 | 'list_table' => 'EE_Message_List_Table', |
378 | - 'qtips' => array( 'EE_Message_List_Table_Tips' ), |
|
378 | + 'qtips' => array('EE_Message_List_Table_Tips'), |
|
379 | 379 | 'require_nonce' => false |
380 | 380 | ), |
381 | 381 | 'global_mtps' => array( |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'messages_overview_other', |
415 | 415 | ), |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
417 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
418 | 418 | 'require_nonce' => false |
419 | 419 | ), |
420 | 420 | 'custom_mtps' => array( |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | ), |
450 | 450 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
451 | 451 | 'has_metaboxes' => true, |
452 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
452 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
453 | 453 | 'help_tabs' => array( |
454 | 454 | 'edit_message_template' => array( |
455 | 455 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | 'filename' => 'messages_settings_messengers' |
506 | 506 | ), |
507 | 507 | ), |
508 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
508 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
509 | 509 | 'require_nonce' => false |
510 | 510 | ) |
511 | 511 | ); |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | |
539 | 539 | |
540 | 540 | protected function _add_screen_options_default() { |
541 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
541 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
542 | 542 | $this->_per_page_screen_option(); |
543 | 543 | } |
544 | 544 | |
@@ -560,37 +560,37 @@ discard block |
||
560 | 560 | |
561 | 561 | |
562 | 562 | public function messages_help_tab() { |
563 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
563 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | |
567 | 567 | public function messengers_help_tab() { |
568 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
568 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
572 | 572 | public function message_types_help_tab() { |
573 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
573 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | |
577 | 577 | public function messages_overview_help_tab() { |
578 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
578 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
582 | 582 | public function message_templates_help_tab() { |
583 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
583 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
587 | 587 | public function edit_message_template_help_tab() { |
588 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
589 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
590 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
591 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
592 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
593 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
588 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
589 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
590 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
591 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
592 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
593 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | |
@@ -598,22 +598,22 @@ discard block |
||
598 | 598 | public function message_template_shortcodes_help_tab() { |
599 | 599 | $this->_set_shortcodes(); |
600 | 600 | $args['shortcodes'] = $this->_shortcodes; |
601 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
601 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
605 | 605 | |
606 | 606 | public function preview_message_help_tab() { |
607 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
607 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
611 | 611 | public function settings_help_tab() { |
612 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
613 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
612 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
613 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
614 | 614 | $args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>'; |
615 | 615 | $args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>'; |
616 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
616 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | |
@@ -621,31 +621,31 @@ discard block |
||
621 | 621 | |
622 | 622 | |
623 | 623 | public function load_scripts_styles() { |
624 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
624 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
625 | 625 | wp_enqueue_style('espresso_ee_msg'); |
626 | 626 | |
627 | - wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true ); |
|
628 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
627 | + wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true); |
|
628 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
632 | 632 | |
633 | 633 | public function load_scripts_styles_default() { |
634 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
634 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
638 | 638 | |
639 | 639 | |
640 | 640 | |
641 | - public function wp_editor_css( $mce_css ) { |
|
641 | + public function wp_editor_css($mce_css) { |
|
642 | 642 | //if we're on the edit_message_template route |
643 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger ) { |
|
643 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger) { |
|
644 | 644 | $message_type_name = $this->_active_message_type_name; |
645 | 645 | |
646 | 646 | //we're going to REPLACE the existing mce css |
647 | 647 | //we need to get the css file location from the active messenger |
648 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
648 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | return $mce_css; |
@@ -663,37 +663,37 @@ discard block |
||
663 | 663 | $this->_message_template_group->messenger_obj()->label['singular'], |
664 | 664 | $this->_message_template_group->message_type_obj()->label['singular'] |
665 | 665 | ); |
666 | - EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' ); |
|
666 | + EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso'); |
|
667 | 667 | |
668 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
668 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
669 | 669 | |
670 | 670 | wp_enqueue_script('ee_admin_js'); |
671 | 671 | wp_enqueue_script('ee_msgs_edit_js'); |
672 | 672 | |
673 | 673 | //add in special css for tiny_mce |
674 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
674 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
678 | 678 | |
679 | 679 | public function load_scripts_styles_display_preview_message() { |
680 | 680 | $this->_set_message_template_group(); |
681 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
681 | + if (isset($this->_req_data['messenger'])) { |
|
682 | 682 | $this->_active_messenger = $this->_active_messengers[$this->_req_data['messenger']]; |
683 | 683 | } |
684 | 684 | |
685 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
685 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
686 | 686 | |
687 | 687 | |
688 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
688 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
692 | 692 | |
693 | 693 | public function load_scripts_styles_settings() { |
694 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
695 | - wp_enqueue_style( 'ee-text-links' ); |
|
696 | - wp_enqueue_style( 'ee-message-settings' ); |
|
694 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
695 | + wp_enqueue_style('ee-text-links'); |
|
696 | + wp_enqueue_style('ee-message-settings'); |
|
697 | 697 | |
698 | 698 | wp_enqueue_script('ee-messages-settings'); |
699 | 699 | } |
@@ -723,37 +723,37 @@ discard block |
||
723 | 723 | * set views array for message queue list table |
724 | 724 | */ |
725 | 725 | public function _set_list_table_views_default() { |
726 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
726 | + EE_Registry::instance()->load_helper('Template'); |
|
727 | 727 | |
728 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
728 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
729 | 729 | ? array( |
730 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
731 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
732 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
733 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
730 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
731 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
732 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
733 | + 'send_now' => __('Send Now', 'event_espresso') |
|
734 | 734 | ) |
735 | 735 | : array(); |
736 | 736 | |
737 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
738 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
737 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
738 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
739 | 739 | : array(); |
740 | 740 | |
741 | 741 | |
742 | 742 | $this->_views = array( |
743 | 743 | 'all' => array( |
744 | 744 | 'slug' => 'all', |
745 | - 'label' => __( 'All', 'event_espresso' ), |
|
745 | + 'label' => __('All', 'event_espresso'), |
|
746 | 746 | 'count' => 0, |
747 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
747 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
748 | 748 | ) |
749 | 749 | ); |
750 | 750 | |
751 | 751 | |
752 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
752 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
753 | 753 | $status_bulk_actions = $common_bulk_actions; |
754 | 754 | //unset bulk actions not applying to status |
755 | - if ( ! empty( $status_bulk_actions ) ) { |
|
756 | - switch ( $status ) { |
|
755 | + if ( ! empty($status_bulk_actions)) { |
|
756 | + switch ($status) { |
|
757 | 757 | case EEM_Message::status_idle : |
758 | 758 | case EEM_Message::status_resend : |
759 | 759 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -764,20 +764,20 @@ discard block |
||
764 | 764 | break; |
765 | 765 | |
766 | 766 | case EEM_Message::status_incomplete : |
767 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
767 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
768 | 768 | break; |
769 | 769 | |
770 | 770 | case EEM_Message::status_retry : |
771 | 771 | case EEM_Message::status_sent : |
772 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
772 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
773 | 773 | break; |
774 | 774 | } |
775 | 775 | } |
776 | - $this->_views[ strtolower( $status ) ] = array( |
|
777 | - 'slug' => strtolower( $status ), |
|
778 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
776 | + $this->_views[strtolower($status)] = array( |
|
777 | + 'slug' => strtolower($status), |
|
778 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
779 | 779 | 'count' => 0, |
780 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
780 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
781 | 781 | ); |
782 | 782 | } |
783 | 783 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | protected function _message_queue_list_table() { |
797 | 797 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
798 | 798 | $this->_template_args['per_column'] = 6; |
799 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
799 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
800 | 800 | $this->display_admin_list_table_page_with_no_sidebar(); |
801 | 801 | } |
802 | 802 | |
@@ -808,8 +808,8 @@ discard block |
||
808 | 808 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
809 | 809 | $action_items = array(); |
810 | 810 | |
811 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
812 | - if ( $action_item === 'see_notifications_for' ) { |
|
811 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
812 | + if ($action_item === 'see_notifications_for') { |
|
813 | 813 | continue; |
814 | 814 | } |
815 | 815 | $action_items[$action_item] = array( |
@@ -821,31 +821,31 @@ discard block |
||
821 | 821 | /** @type array $status_items status legend setup*/ |
822 | 822 | $status_items = array( |
823 | 823 | 'sent_status' => array( |
824 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
825 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, FALSE, 'sentence' ) |
|
824 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
825 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, FALSE, 'sentence') |
|
826 | 826 | ), |
827 | 827 | 'idle_status' => array( |
828 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
829 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, FALSE, 'sentence' ) |
|
828 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
829 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, FALSE, 'sentence') |
|
830 | 830 | ), |
831 | 831 | 'failed_status' => array( |
832 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
833 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, FALSE, 'sentence' ) |
|
832 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
833 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, FALSE, 'sentence') |
|
834 | 834 | ), |
835 | 835 | 'resend_status' => array( |
836 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
837 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, FALSE, 'sentence' ) |
|
836 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
837 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, FALSE, 'sentence') |
|
838 | 838 | ), |
839 | 839 | 'incomplete_status' => array( |
840 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
841 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, FALSE, 'sentence' ) |
|
840 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
841 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, FALSE, 'sentence') |
|
842 | 842 | ), |
843 | 843 | 'retry_status' => array( |
844 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
845 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, FALSE, 'sentence' ) |
|
844 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
845 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, FALSE, 'sentence') |
|
846 | 846 | ) |
847 | 847 | ); |
848 | - return array_merge( $action_items, $status_items ); |
|
848 | + return array_merge($action_items, $status_items); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | |
@@ -855,9 +855,9 @@ discard block |
||
855 | 855 | |
856 | 856 | protected function _custom_mtps_preview() { |
857 | 857 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
858 | - $this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />'; |
|
858 | + $this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />'; |
|
859 | 859 | $this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso. With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>'; |
860 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
860 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | |
@@ -881,31 +881,31 @@ discard block |
||
881 | 881 | * |
882 | 882 | * @return array |
883 | 883 | */ |
884 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
884 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
885 | 885 | |
886 | 886 | $MTP = EEM_Message_Template_Group::instance(); |
887 | 887 | |
888 | 888 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
889 | 889 | $orderby = $this->_req_data['orderby']; |
890 | 890 | |
891 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
891 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
892 | 892 | |
893 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
894 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
893 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
894 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
895 | 895 | |
896 | - $offset = ($current_page-1)*$per_page; |
|
897 | - $limit = $all ? null : array( $offset, $per_page ); |
|
896 | + $offset = ($current_page - 1) * $per_page; |
|
897 | + $limit = $all ? null : array($offset, $per_page); |
|
898 | 898 | |
899 | 899 | |
900 | 900 | //options will match what is in the _views array property |
901 | - switch( $type ) { |
|
901 | + switch ($type) { |
|
902 | 902 | |
903 | 903 | case 'in_use': |
904 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
904 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
905 | 905 | break; |
906 | 906 | |
907 | 907 | default: |
908 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
908 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
909 | 909 | |
910 | 910 | } |
911 | 911 | |
@@ -940,8 +940,8 @@ discard block |
||
940 | 940 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
941 | 941 | $installed = array(); |
942 | 942 | |
943 | - foreach ( $installed_message_types as $message_type ) { |
|
944 | - $installed[ $message_type->name ] = $message_type; |
|
943 | + foreach ($installed_message_types as $message_type) { |
|
944 | + $installed[$message_type->name] = $message_type; |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | return $installed; |
@@ -960,24 +960,24 @@ discard block |
||
960 | 960 | * |
961 | 961 | * @throws EE_error |
962 | 962 | */ |
963 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
963 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
964 | 964 | //set values override any request data |
965 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
966 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
965 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
966 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
967 | 967 | |
968 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
969 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
968 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
969 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
970 | 970 | |
971 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
972 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
971 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
972 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
973 | 973 | |
974 | 974 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
975 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
976 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
975 | + if (empty($message_type) || empty($messenger)) |
|
976 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
977 | 977 | |
978 | 978 | //we need the GRP_ID for the template being used as the base for the new template |
979 | - if ( empty( $GRP_ID ) ) |
|
980 | - {throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );} |
|
979 | + if (empty($GRP_ID)) |
|
980 | + {throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); } |
|
981 | 981 | |
982 | 982 | //let's just make sure the template gets generated! |
983 | 983 | |
@@ -998,8 +998,8 @@ discard block |
||
998 | 998 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
999 | 999 | * off of. |
1000 | 1000 | */ |
1001 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
1002 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
1001 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
1002 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | |
@@ -1010,53 +1010,53 @@ discard block |
||
1010 | 1010 | * @return void |
1011 | 1011 | */ |
1012 | 1012 | protected function _edit_message_template() { |
1013 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1013 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1014 | 1014 | $template_fields = ''; |
1015 | 1015 | $sidebar_fields = ''; |
1016 | 1016 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
1017 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
1017 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
1018 | 1018 | |
1019 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1019 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1020 | 1020 | |
1021 | 1021 | $this->_set_shortcodes(); //this also sets the _message_template property. |
1022 | 1022 | $message_template_group = $this->_message_template_group; |
1023 | 1023 | $c_label = $message_template_group->context_label(); |
1024 | 1024 | $c_config = $message_template_group->contexts_config(); |
1025 | 1025 | |
1026 | - reset( $c_config ); |
|
1027 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) ? strtolower($this->_req_data['context']) : key($c_config); |
|
1026 | + reset($c_config); |
|
1027 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) ? strtolower($this->_req_data['context']) : key($c_config); |
|
1028 | 1028 | |
1029 | 1029 | |
1030 | - if ( empty($GRP_ID) ) { |
|
1030 | + if (empty($GRP_ID)) { |
|
1031 | 1031 | $action = 'insert_message_template'; |
1032 | 1032 | //$button_both = false; |
1033 | 1033 | //$button_text = array( __( 'Save','event_espresso') ); |
1034 | 1034 | //$button_actions = array('something_different'); |
1035 | 1035 | //$referrer = false; |
1036 | - $edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL ); |
|
1036 | + $edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL); |
|
1037 | 1037 | } else { |
1038 | 1038 | $action = 'update_message_template'; |
1039 | 1039 | //$button_both = true; |
1040 | 1040 | //$button_text = array(); |
1041 | 1041 | //$button_actions = array(); |
1042 | 1042 | //$referrer = $this->_admin_base_url; |
1043 | - $edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL ); |
|
1043 | + $edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | //set active messenger for this view |
1047 | - $this->_active_messenger = $this->_active_messengers[ $message_template_group->messenger() ]; |
|
1047 | + $this->_active_messenger = $this->_active_messengers[$message_template_group->messenger()]; |
|
1048 | 1048 | $this->_active_message_type_name = $message_template_group->message_type(); |
1049 | 1049 | |
1050 | 1050 | |
1051 | 1051 | //Do we have any validation errors? |
1052 | 1052 | $validators = $this->_get_transient(); |
1053 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1053 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1054 | 1054 | |
1055 | 1055 | |
1056 | 1056 | //we need to assemble the title from Various details |
1057 | - $context_label = sprintf( __('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'] )); |
|
1057 | + $context_label = sprintf(__('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'])); |
|
1058 | 1058 | |
1059 | - $title = sprintf( __(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label ); |
|
1059 | + $title = sprintf(__(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label); |
|
1060 | 1060 | |
1061 | 1061 | $this->_template_args['GRP_ID'] = $GRP_ID; |
1062 | 1062 | $this->_template_args['message_template'] = $message_template_group; |
@@ -1064,9 +1064,9 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | |
1066 | 1066 | //let's get EEH_MSG_Template so we can get template form fields |
1067 | - $template_field_structure = EEH_MSG_Template::get_fields( $message_template_group->messenger(), $message_template_group->message_type()); |
|
1067 | + $template_field_structure = EEH_MSG_Template::get_fields($message_template_group->messenger(), $message_template_group->message_type()); |
|
1068 | 1068 | |
1069 | - if ( !$template_field_structure ) { |
|
1069 | + if ( ! $template_field_structure) { |
|
1070 | 1070 | $template_field_structure = false; |
1071 | 1071 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1072 | 1072 | } |
@@ -1076,47 +1076,47 @@ discard block |
||
1076 | 1076 | |
1077 | 1077 | |
1078 | 1078 | //if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array. |
1079 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1080 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1081 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1079 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1080 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1081 | + unset($template_field_structure[$context][$reference_field]); |
|
1082 | 1082 | } |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | //let's loop through the template_field_structure and actually assemble the input fields! |
1086 | - if ( !empty($template_field_structure) ) { |
|
1086 | + if ( ! empty($template_field_structure)) { |
|
1087 | 1087 | //$id_prefix= 'ee-msg-edit-template-fields-'; |
1088 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1088 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1089 | 1089 | //if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them. |
1090 | - if ( $template_field == 'extra' ) { |
|
1090 | + if ($template_field == 'extra') { |
|
1091 | 1091 | $this->_template_args['is_extra_fields'] = true; |
1092 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1093 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1092 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1093 | + $message_template = $message_templates[$context][$reference_field]; |
|
1094 | 1094 | $content = $message_template instanceof EE_Message_Template |
1095 | - ? $message_template->get( 'MTP_content' ) |
|
1095 | + ? $message_template->get('MTP_content') |
|
1096 | 1096 | : ''; |
1097 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1097 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1098 | 1098 | //let's verify if we need this extra field via the shortcodes parameter. |
1099 | 1099 | $continue = false; |
1100 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1101 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1102 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1103 | - {$continue = true;} |
|
1100 | + if (isset($extra_array['shortcodes_required'])) { |
|
1101 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1102 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1103 | + {$continue = true; } |
|
1104 | 1104 | } |
1105 | - if ( $continue ) {continue;} |
|
1105 | + if ($continue) {continue; } |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1108 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1109 | 1109 | $template_form_fields[$field_id] = $extra_array; |
1110 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1111 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1112 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1110 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1111 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1112 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1113 | 1113 | && in_array($extra_field, $v_fields) |
1114 | - && ( is_array($validators[$extra_field] ) |
|
1115 | - && isset( $validators[$extra_field]['msg'] ) ) |
|
1116 | - ? 'validate-error ' . $css_class |
|
1114 | + && (is_array($validators[$extra_field]) |
|
1115 | + && isset($validators[$extra_field]['msg'])) |
|
1116 | + ? 'validate-error '.$css_class |
|
1117 | 1117 | : $css_class; |
1118 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1119 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1118 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1119 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1120 | 1120 | : ''; |
1121 | 1121 | |
1122 | 1122 | //do we have a validation error? if we do then let's use that value instead |
@@ -1127,32 +1127,32 @@ discard block |
||
1127 | 1127 | |
1128 | 1128 | //shortcode selector |
1129 | 1129 | $field_name_to_use = $extra_field == 'main' ? 'content' : $extra_field; |
1130 | - $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $field_name_to_use, $field_id ); |
|
1130 | + $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($field_name_to_use, $field_id); |
|
1131 | 1131 | |
1132 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1132 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1133 | 1133 | //we want to decode the entities |
1134 | - $template_form_fields[$field_id]['value'] = stripslashes( html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") ); |
|
1134 | + $template_form_fields[$field_id]['value'] = stripslashes(html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")); |
|
1135 | 1135 | |
1136 | 1136 | }/**/ |
1137 | 1137 | } |
1138 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1139 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1138 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1139 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1140 | 1140 | |
1141 | 1141 | $template_form_fields[$templatefield_MTP_id] = array( |
1142 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1142 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1143 | 1143 | 'label' => null, |
1144 | 1144 | 'input' => 'hidden', |
1145 | 1145 | 'type' => 'int', |
1146 | 1146 | 'required' => false, |
1147 | 1147 | 'validation' => false, |
1148 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1148 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1149 | 1149 | 'css_class' => '', |
1150 | 1150 | 'format' => '%d', |
1151 | 1151 | 'db-col' => 'MTP_ID' |
1152 | 1152 | ); |
1153 | 1153 | |
1154 | 1154 | $template_form_fields[$templatefield_templatename_id] = array( |
1155 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1155 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1156 | 1156 | 'label' => null, |
1157 | 1157 | 'input' => 'hidden', |
1158 | 1158 | 'type' => 'string', |
@@ -1166,11 +1166,11 @@ discard block |
||
1166 | 1166 | } |
1167 | 1167 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1168 | 1168 | } else { |
1169 | - $field_id = $template_field . '-content'; |
|
1169 | + $field_id = $template_field.'-content'; |
|
1170 | 1170 | $template_form_fields[$field_id] = $field_setup_array; |
1171 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1172 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1173 | - ? isset( $message_templates[ $context ][ $template_field ] ) |
|
1171 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1172 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1173 | + ? isset($message_templates[$context][$template_field]) |
|
1174 | 1174 | : null; |
1175 | 1175 | $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
1176 | 1176 | && is_array($message_templates[$context]) |
@@ -1184,10 +1184,10 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1186 | 1186 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1187 | - $template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array( $template_field, $v_fields ) && isset( $validators[$template_field]['msg'] ) ? 'validate-error ' . $css_class : $css_class; |
|
1187 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($template_field, $v_fields) && isset($validators[$template_field]['msg']) ? 'validate-error '.$css_class : $css_class; |
|
1188 | 1188 | |
1189 | 1189 | //shortcode selector |
1190 | - $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $template_field, $field_id ); |
|
1190 | + $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($template_field, $field_id); |
|
1191 | 1191 | |
1192 | 1192 | //if ( isset( $field_setup_array['input'] ) && $field_setup_array['input'] == 'wp_editor' ) { |
1193 | 1193 | // //we want to decode the entities |
@@ -1197,12 +1197,12 @@ discard block |
||
1197 | 1197 | |
1198 | 1198 | //k took care of content field(s) now let's take care of others. |
1199 | 1199 | |
1200 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1201 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1200 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1201 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1202 | 1202 | |
1203 | 1203 | //foreach template field there are actually two form fields created |
1204 | 1204 | $template_form_fields[$templatefield_MTP_id] = array( |
1205 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1205 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1206 | 1206 | 'label' => null, |
1207 | 1207 | 'input' => 'hidden', |
1208 | 1208 | 'type' => 'int', |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | ); |
1216 | 1216 | |
1217 | 1217 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1218 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1218 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1219 | 1219 | 'label' => null, |
1220 | 1220 | 'input' => 'hidden', |
1221 | 1221 | 'type' => 'string', |
@@ -1359,15 +1359,15 @@ discard block |
||
1359 | 1359 | 'value' => $GRP_ID |
1360 | 1360 | ); |
1361 | 1361 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1362 | - 'name' => $action . '_nonce', |
|
1362 | + 'name' => $action.'_nonce', |
|
1363 | 1363 | 'input' => 'hidden', |
1364 | 1364 | 'type' => 'string', |
1365 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1365 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1366 | 1366 | ); |
1367 | 1367 | |
1368 | 1368 | //$sidebar_array = array('ee-msg-is-global', 'ee-msg-is-override', 'ee-msg-deleted', 'ee-msg-is-active'); |
1369 | 1369 | |
1370 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1370 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1371 | 1371 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1372 | 1372 | 'name' => 'template_switch', |
1373 | 1373 | 'input' => 'hidden', |
@@ -1377,8 +1377,8 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | |
1380 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1381 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1380 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1381 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1382 | 1382 | |
1383 | 1383 | |
1384 | 1384 | } //end if ( !empty($template_field_structure) ) |
@@ -1390,14 +1390,14 @@ discard block |
||
1390 | 1390 | $GRP_ID, |
1391 | 1391 | false, |
1392 | 1392 | add_query_arg( |
1393 | - array( 'action' => 'global_mtps' ), |
|
1393 | + array('action' => 'global_mtps'), |
|
1394 | 1394 | $this->_admin_base_url |
1395 | 1395 | ) |
1396 | 1396 | ); |
1397 | 1397 | |
1398 | 1398 | //add preview button |
1399 | - $preview_url = parent::add_query_args_and_nonce( array( 'message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context,'GRP_ID' => $GRP_ID, 'action' => 'preview_message' ), $this->_admin_base_url ); |
|
1400 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1399 | + $preview_url = parent::add_query_args_and_nonce(array('message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context, 'GRP_ID' => $GRP_ID, 'action' => 'preview_message'), $this->_admin_base_url); |
|
1400 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1401 | 1401 | |
1402 | 1402 | |
1403 | 1403 | //setup context switcher |
@@ -1425,17 +1425,17 @@ discard block |
||
1425 | 1425 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1426 | 1426 | |
1427 | 1427 | $this->_template_path = $this->_template_args['GRP_ID'] |
1428 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1429 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1428 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1429 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1430 | 1430 | |
1431 | 1431 | //send along EE_Message_Template_Group object for further template use. |
1432 | 1432 | $this->_template_args['MTP'] = $message_template_group; |
1433 | 1433 | |
1434 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1434 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1435 | 1435 | |
1436 | 1436 | |
1437 | 1437 | //finally, let's set the admin_page title |
1438 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1438 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1439 | 1439 | |
1440 | 1440 | |
1441 | 1441 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | |
1451 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1451 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1452 | 1452 | return $mceInit; |
1453 | 1453 | } |
1454 | 1454 | |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | } |
1460 | 1460 | |
1461 | 1461 | public function _add_form_element_before() { |
1462 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1462 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1463 | 1463 | } |
1464 | 1464 | |
1465 | 1465 | public function _add_form_element_after() { |
@@ -1477,33 +1477,33 @@ discard block |
||
1477 | 1477 | * @return string json object |
1478 | 1478 | */ |
1479 | 1479 | public function switch_template_pack() { |
1480 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1481 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1480 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1481 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1482 | 1482 | |
1483 | 1483 | //verify we have needed values. |
1484 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1484 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1485 | 1485 | $this->_template_args['error'] = true; |
1486 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1486 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1487 | 1487 | } else { |
1488 | 1488 | //get template, set the new template_pack and then reset to default |
1489 | 1489 | /** @type EE_Message_Template_Group $message_template_group */ |
1490 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1490 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1491 | 1491 | |
1492 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1492 | + $message_template_group->set_template_pack_name($template_pack); |
|
1493 | 1493 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1494 | 1494 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1495 | 1495 | |
1496 | 1496 | $query_args = $this->_reset_to_default_template(); |
1497 | 1497 | |
1498 | - if ( empty( $query_args['id'] ) ) { |
|
1499 | - EE_Error::add_error( __('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1498 | + if (empty($query_args['id'])) { |
|
1499 | + EE_Error::add_error(__('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1500 | 1500 | $this->_template_args['error'] = true; |
1501 | 1501 | } else { |
1502 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1502 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1503 | 1503 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1504 | - EE_Error::add_success( sprintf( __('This message template has been successfully switched to use the %s %s. Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack ) ); |
|
1504 | + EE_Error::add_success(sprintf(__('This message template has been successfully switched to use the %s %s. Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack)); |
|
1505 | 1505 | //generate the redirect url for js. |
1506 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1506 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1507 | 1507 | $this->_template_args['data']['redirect_url'] = $url; |
1508 | 1508 | $this->_template_args['success'] = true; |
1509 | 1509 | } |
@@ -1525,16 +1525,16 @@ discard block |
||
1525 | 1525 | protected function _reset_to_default_template() { |
1526 | 1526 | |
1527 | 1527 | $templates = array(); |
1528 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1528 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1529 | 1529 | //we need to make sure we've got the info we need. |
1530 | - if ( !isset( $this->_req_data['msgr'] ) && !isset( $this->_req_data['mt'] ) && !isset( $this->_req_data['GRP_ID'] ) ) { |
|
1531 | - EE_Error::add_error( __('In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset. At least one of these is missing.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1530 | + if ( ! isset($this->_req_data['msgr']) && ! isset($this->_req_data['mt']) && ! isset($this->_req_data['GRP_ID'])) { |
|
1531 | + EE_Error::add_error(__('In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset. At least one of these is missing.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | //all templates will be reset to whatever the defaults are for the global template matching the messenger and message type. |
1535 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1535 | + $success = ! empty($GRP_ID) ? true : false; |
|
1536 | 1536 | |
1537 | - if ( $success ) { |
|
1537 | + if ($success) { |
|
1538 | 1538 | |
1539 | 1539 | //let's first determine if the incoming template is a global template, |
1540 | 1540 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1542,39 +1542,39 @@ discard block |
||
1542 | 1542 | |
1543 | 1543 | |
1544 | 1544 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1545 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1545 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1546 | 1546 | |
1547 | - if ( $success ) { |
|
1547 | + if ($success) { |
|
1548 | 1548 | //if successfully deleted, lets generate the new ones. Note. We set GLOBAL to true, because resets on ANY template will use the related global template defaults for regeneration. This means that if a custom template is reset it resets to whatever the related global template is. HOWEVER, we DO keep the template pack and template variation set for the current custom template when resetting. |
1549 | - $templates = $this->_generate_new_templates( $this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true ); |
|
1549 | + $templates = $this->_generate_new_templates($this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | //any error messages? |
1555 | - if ( !$success ) { |
|
1556 | - EE_Error::add_error( __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1555 | + if ( ! $success) { |
|
1556 | + EE_Error::add_error(__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | //all good, let's add a success message! |
1560 | - if ( $success && ! empty( $templates ) ) { |
|
1560 | + if ($success && ! empty($templates)) { |
|
1561 | 1561 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1562 | 1562 | EE_Error::overwrite_success(); |
1563 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1563 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | |
1567 | 1567 | $query_args = array( |
1568 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1569 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1570 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1568 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1569 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1570 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1571 | 1571 | ); |
1572 | 1572 | |
1573 | 1573 | //if called via ajax then we return query args otherwise redirect |
1574 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1574 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1575 | 1575 | return $query_args; |
1576 | 1576 | } else { |
1577 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1577 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1578 | 1578 | return null; |
1579 | 1579 | } |
1580 | 1580 | } |
@@ -1587,19 +1587,19 @@ discard block |
||
1587 | 1587 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1588 | 1588 | * @return string |
1589 | 1589 | */ |
1590 | - public function _preview_message( $send = false ) { |
|
1590 | + public function _preview_message($send = false) { |
|
1591 | 1591 | //first make sure we've got the necessary parameters |
1592 | - if ( !isset( $this->_req_data['message_type'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['GRP_ID'] ) ) { |
|
1593 | - EE_Error::add_error( __('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1592 | + if ( ! isset($this->_req_data['message_type']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['GRP_ID'])) { |
|
1593 | + EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1594 | 1594 | } |
1595 | 1595 | |
1596 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1596 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1597 | 1597 | |
1598 | 1598 | |
1599 | 1599 | //get the preview! |
1600 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1600 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1601 | 1601 | |
1602 | - if ( $send ) { |
|
1602 | + if ($send) { |
|
1603 | 1603 | return $preview; |
1604 | 1604 | } |
1605 | 1605 | |
@@ -1609,18 +1609,18 @@ discard block |
||
1609 | 1609 | 'context' => $this->_req_data['context'], |
1610 | 1610 | 'action' => 'edit_message_template' |
1611 | 1611 | ); |
1612 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1613 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1612 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1613 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1614 | 1614 | |
1615 | 1615 | //let's provide a helpful title for context |
1616 | 1616 | $preview_title = sprintf( |
1617 | - __( 'Viewing Preview for %s %s Message Template', 'event_espresso' ), |
|
1618 | - ucwords( $this->_active_messengers[ $this->_req_data[ 'messenger' ] ]->label[ 'singular' ] ), |
|
1619 | - ucwords( $this->_active_message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] ) |
|
1617 | + __('Viewing Preview for %s %s Message Template', 'event_espresso'), |
|
1618 | + ucwords($this->_active_messengers[$this->_req_data['messenger']]->label['singular']), |
|
1619 | + ucwords($this->_active_message_types[$this->_req_data['message_type']]->label['singular']) |
|
1620 | 1620 | ); |
1621 | 1621 | //setup display of preview. |
1622 | 1622 | $this->_admin_page_title = $preview_title; |
1623 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1623 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1624 | 1624 | $this->_template_args['data']['force_json'] = true; |
1625 | 1625 | return ''; |
1626 | 1626 | } |
@@ -1650,9 +1650,9 @@ discard block |
||
1650 | 1650 | * @return void |
1651 | 1651 | */ |
1652 | 1652 | protected function _register_edit_meta_boxes() { |
1653 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1654 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1655 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1653 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1654 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1655 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | 1658 | |
@@ -1671,10 +1671,10 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | $tp_select_values = array(); |
1673 | 1673 | |
1674 | - foreach ( $tp_collection as $tp ) { |
|
1674 | + foreach ($tp_collection as $tp) { |
|
1675 | 1675 | //only include template packs that support this messenger and message type! |
1676 | 1676 | $supports = $tp->get_supports(); |
1677 | - if ( ! isset( $supports[$this->_message_template_group->messenger()] ) || ! in_array( $this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()] ) ) { |
|
1677 | + if ( ! isset($supports[$this->_message_template_group->messenger()]) || ! in_array($this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()])) { |
|
1678 | 1678 | //not supported |
1679 | 1679 | continue; |
1680 | 1680 | } |
@@ -1686,7 +1686,7 @@ discard block |
||
1686 | 1686 | } |
1687 | 1687 | |
1688 | 1688 | //if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack. This still allows for the odd template pack to override. |
1689 | - if ( empty( $tp_select_values ) ) { |
|
1689 | + if (empty($tp_select_values)) { |
|
1690 | 1690 | $tp_select_values[] = array( |
1691 | 1691 | 'text' => __('Default', 'event_espresso'), |
1692 | 1692 | 'id' => 'default' |
@@ -1694,27 +1694,27 @@ discard block |
||
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | //setup variation select values for the currently selected template. |
1697 | - $variations = $this->_message_template_group->get_template_pack()->get_variations( $this->_message_template_group->messenger(), $this->_message_template_group->message_type() ); |
|
1697 | + $variations = $this->_message_template_group->get_template_pack()->get_variations($this->_message_template_group->messenger(), $this->_message_template_group->message_type()); |
|
1698 | 1698 | $variations_select_values = array(); |
1699 | - foreach ( $variations as $variation => $label ) { |
|
1699 | + foreach ($variations as $variation => $label) { |
|
1700 | 1700 | $variations_select_values[] = array( |
1701 | 1701 | 'text' => $label, |
1702 | 1702 | 'id' => $variation |
1703 | 1703 | ); |
1704 | 1704 | } |
1705 | 1705 | |
1706 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1706 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1707 | 1707 | |
1708 | - $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( 'MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name() ); |
|
1709 | - $template_args['variations_selector'] = EEH_Form_Fields::select_input( 'MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation() ); |
|
1708 | + $template_args['template_packs_selector'] = EEH_Form_Fields::select_input('MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name()); |
|
1709 | + $template_args['variations_selector'] = EEH_Form_Fields::select_input('MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation()); |
|
1710 | 1710 | $template_args['template_pack_label'] = $template_pack_labels->template_pack; |
1711 | 1711 | $template_args['template_variation_label'] = $template_pack_labels->template_variation; |
1712 | 1712 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1713 | 1713 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1714 | 1714 | |
1715 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1715 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1716 | 1716 | |
1717 | - EEH_Template::display_template( $template, $template_args ); |
|
1717 | + EEH_Template::display_template($template, $template_args); |
|
1718 | 1718 | } |
1719 | 1719 | |
1720 | 1720 | |
@@ -1735,52 +1735,52 @@ discard block |
||
1735 | 1735 | 'GRP_ID' => $this->_message_template_group->GRP_ID() |
1736 | 1736 | ); |
1737 | 1737 | |
1738 | - $button = $this->get_action_link_or_button( 'reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button' ); |
|
1738 | + $button = $this->get_action_link_or_button('reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button'); |
|
1739 | 1739 | |
1740 | 1740 | |
1741 | 1741 | //test button |
1742 | 1742 | //first we need to see if there are any fields |
1743 | 1743 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1744 | 1744 | |
1745 | - if ( !empty( $fields ) ) { |
|
1745 | + if ( ! empty($fields)) { |
|
1746 | 1746 | //yup there be fields |
1747 | - foreach ( $fields as $field => $config ) { |
|
1748 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1747 | + foreach ($fields as $field => $config) { |
|
1748 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1749 | 1749 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1750 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1751 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1750 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1751 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1752 | 1752 | |
1753 | 1753 | //if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults |
1754 | 1754 | $fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : ''; |
1755 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix; |
|
1755 | + $existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix; |
|
1756 | 1756 | |
1757 | 1757 | $template_form_fields[$field_id] = array( |
1758 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1758 | + 'name' => 'test_settings_fld['.$field.']', |
|
1759 | 1759 | 'label' => $config['label'], |
1760 | 1760 | 'input' => $config['input'], |
1761 | 1761 | 'type' => $config['type'], |
1762 | 1762 | 'required' => $config['required'], |
1763 | 1763 | 'validation' => $config['validation'], |
1764 | - 'value' => isset( $existing[$field] ) ? $existing[$field] : $default, |
|
1764 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1765 | 1765 | 'css_class' => $config['css_class'], |
1766 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1766 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1767 | 1767 | 'default' => $default, |
1768 | 1768 | 'format' => $config['format'] |
1769 | 1769 | ); |
1770 | 1770 | } |
1771 | 1771 | } |
1772 | 1772 | |
1773 | - $test_settings_fields = !empty( $template_form_fields) ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) : ''; |
|
1773 | + $test_settings_fields = ! empty($template_form_fields) ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') : ''; |
|
1774 | 1774 | |
1775 | 1775 | $test_settings_html = ''; |
1776 | 1776 | //print out $test_settings_fields |
1777 | - if ( !empty( $test_settings_fields ) ) { |
|
1777 | + if ( ! empty($test_settings_fields)) { |
|
1778 | 1778 | echo $test_settings_fields; |
1779 | - $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="' . __('Test Send', 'event_espresso') . '" /><div style="clear:both"></div>'; |
|
1779 | + $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="'.__('Test Send', 'event_espresso').'" /><div style="clear:both"></div>'; |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | //and button |
1783 | - echo $test_settings_html . '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>' . '<div class="publishing-action alignright resetbutton">' . $button . '</div><div style="clear:both"></div>'; |
|
1783 | + echo $test_settings_html.'<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'.'<div class="publishing-action alignright resetbutton">'.$button.'</div><div style="clear:both"></div>'; |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | |
@@ -1795,13 +1795,13 @@ discard block |
||
1795 | 1795 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
1796 | 1796 | * @return string |
1797 | 1797 | */ |
1798 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
1798 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
1799 | 1799 | $template_args = array( |
1800 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
1800 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
1801 | 1801 | 'fieldname' => $field, |
1802 | 1802 | 'linked_input_id' => $linked_input_id |
1803 | 1803 | ); |
1804 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
1804 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
1805 | 1805 | } |
1806 | 1806 | |
1807 | 1807 | |
@@ -1816,13 +1816,13 @@ discard block |
||
1816 | 1816 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
1817 | 1817 | //$messenger = $this->_message_template_group->messenger_obj(); |
1818 | 1818 | //now let's set the content depending on the status of the shortcodes array |
1819 | - if ( empty( $shortcodes ) ) { |
|
1820 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
1819 | + if (empty($shortcodes)) { |
|
1820 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
1821 | 1821 | echo $content; |
1822 | 1822 | } else { |
1823 | 1823 | //$alt = 0; |
1824 | 1824 | ?> |
1825 | - <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p> |
|
1825 | + <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p> |
|
1826 | 1826 | <?php |
1827 | 1827 | } |
1828 | 1828 | |
@@ -1839,7 +1839,7 @@ discard block |
||
1839 | 1839 | protected function _set_shortcodes() { |
1840 | 1840 | |
1841 | 1841 | //no need to run this if the property is already set |
1842 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
1842 | + if ( ! empty($this->_shortcodes)) {return; } |
|
1843 | 1843 | |
1844 | 1844 | $this->_shortcodes = $this->_get_shortcodes(); |
1845 | 1845 | } |
@@ -1861,14 +1861,14 @@ discard block |
||
1861 | 1861 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
1862 | 1862 | * just an array of shortcode/label pairs. |
1863 | 1863 | */ |
1864 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
1864 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
1865 | 1865 | $this->_set_message_template_group(); |
1866 | 1866 | |
1867 | 1867 | //we need the messenger and message template to retrieve the valid shortcodes array. |
1868 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1869 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
1868 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1869 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
1870 | 1870 | |
1871 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
1871 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
1872 | 1872 | } |
1873 | 1873 | |
1874 | 1874 | |
@@ -1881,19 +1881,19 @@ discard block |
||
1881 | 1881 | */ |
1882 | 1882 | protected function _set_message_template_group() { |
1883 | 1883 | |
1884 | - if ( !empty( $this->_message_template_group ) ) |
|
1885 | - {return;} //get out if this is already set. |
|
1884 | + if ( ! empty($this->_message_template_group)) |
|
1885 | + {return; } //get out if this is already set. |
|
1886 | 1886 | |
1887 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
1888 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
1887 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
1888 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
1889 | 1889 | |
1890 | 1890 | //let's get the message templates |
1891 | 1891 | $MTP = EEM_Message_Template_Group::instance(); |
1892 | 1892 | |
1893 | - if ( empty($GRP_ID) ) |
|
1894 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
1893 | + if (empty($GRP_ID)) |
|
1894 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
1895 | 1895 | else |
1896 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
1896 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
1897 | 1897 | |
1898 | 1898 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
1899 | 1899 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -1912,7 +1912,7 @@ discard block |
||
1912 | 1912 | * @param array $args various things the context switcher needs. |
1913 | 1913 | * |
1914 | 1914 | */ |
1915 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
1915 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
1916 | 1916 | $context_details = $template_group_object->contexts_config(); |
1917 | 1917 | $context_label = $template_group_object->context_label(); |
1918 | 1918 | ob_start(); |
@@ -1920,26 +1920,26 @@ discard block |
||
1920 | 1920 | <div class="ee-msg-switcher-container"> |
1921 | 1921 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
1922 | 1922 | <?php |
1923 | - foreach ( $args as $name => $value ) { |
|
1924 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
1923 | + foreach ($args as $name => $value) { |
|
1924 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
1925 | 1925 | ?> |
1926 | 1926 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
1927 | 1927 | <?php |
1928 | 1928 | } |
1929 | 1929 | //setup nonce_url |
1930 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
1930 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
1931 | 1931 | ?> |
1932 | 1932 | <select name="context"> |
1933 | 1933 | <?php |
1934 | 1934 | $context_templates = $template_group_object->context_templates(); |
1935 | - if ( is_array($context_templates) ) : |
|
1936 | - foreach ( $context_templates as $context => $template_fields ) : |
|
1935 | + if (is_array($context_templates)) : |
|
1936 | + foreach ($context_templates as $context => $template_fields) : |
|
1937 | 1937 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
1938 | 1938 | ?> |
1939 | 1939 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>><?php echo $context_details[$context]['label']; ?></option> |
1940 | 1940 | <?php endforeach; endif; ?> |
1941 | 1941 | </select> |
1942 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
1942 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
1943 | 1943 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
1944 | 1944 | </form> |
1945 | 1945 | <?php echo $args['extra']; ?> |
@@ -1966,8 +1966,8 @@ discard block |
||
1966 | 1966 | * @return array |
1967 | 1967 | */ |
1968 | 1968 | protected function _set_message_template_column_values($index) { |
1969 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
1970 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
1969 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
1970 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
1971 | 1971 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
1972 | 1972 | } |
1973 | 1973 | } /*else { |
@@ -1976,22 +1976,22 @@ discard block |
||
1976 | 1976 | |
1977 | 1977 | |
1978 | 1978 | $set_column_values = array( |
1979 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
1980 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
1981 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
1982 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
1983 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
1984 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
1985 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
1986 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
1987 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
1988 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
1979 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
1980 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
1981 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
1982 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
1983 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
1984 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
1985 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
1986 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
1987 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
1988 | + ? absint($this->_req_data['MTP_is_global']) |
|
1989 | 1989 | : 0, |
1990 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
1991 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
1990 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
1991 | + ? absint($this->_req_data['MTP_is_override']) |
|
1992 | 1992 | : 0, |
1993 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
1994 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
1993 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
1994 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
1995 | 1995 | ); |
1996 | 1996 | |
1997 | 1997 | |
@@ -2003,28 +2003,28 @@ discard block |
||
2003 | 2003 | |
2004 | 2004 | |
2005 | 2005 | |
2006 | - protected function _insert_or_update_message_template($new = false ) { |
|
2006 | + protected function _insert_or_update_message_template($new = false) { |
|
2007 | 2007 | |
2008 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2008 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2009 | 2009 | $success = 0; |
2010 | 2010 | $override = false; |
2011 | 2011 | |
2012 | 2012 | //setup notices description |
2013 | - $messenger = !empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'] ) ) : false; |
|
2014 | - $message_type = !empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'] ) ) : false; |
|
2015 | - $context = !empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'] ) ) : false; |
|
2013 | + $messenger = ! empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) : false; |
|
2014 | + $message_type = ! empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) : false; |
|
2015 | + $context = ! empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) : false; |
|
2016 | 2016 | |
2017 | - $item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : ''; |
|
2017 | + $item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : ''; |
|
2018 | 2018 | $item_desc .= 'Message Template'; |
2019 | 2019 | $query_args = array(); |
2020 | 2020 | $edit_array = array(); |
2021 | 2021 | $action_desc = ''; |
2022 | 2022 | |
2023 | 2023 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2024 | - if ( $new ) { |
|
2025 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2026 | - if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) { |
|
2027 | - if ( empty($edit_array) ) { |
|
2024 | + if ($new) { |
|
2025 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2026 | + if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) { |
|
2027 | + if (empty($edit_array)) { |
|
2028 | 2028 | $success = 0; |
2029 | 2029 | } else { |
2030 | 2030 | $success = 1; |
@@ -2043,33 +2043,33 @@ discard block |
||
2043 | 2043 | |
2044 | 2044 | |
2045 | 2045 | //run update for each template field in displayed context |
2046 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2047 | - EE_Error::add_error( __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2046 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2047 | + EE_Error::add_error(__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2048 | 2048 | $success = 0; |
2049 | 2049 | |
2050 | 2050 | } else { |
2051 | 2051 | //first validate all fields! |
2052 | - $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2052 | + $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2053 | 2053 | |
2054 | 2054 | //if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array. WE need to make sure there is no actual error messages in validates. |
2055 | - if ( is_array($validates) && !empty($validates) ) { |
|
2055 | + if (is_array($validates) && ! empty($validates)) { |
|
2056 | 2056 | //add the transient so when the form loads we know which fields to highlight |
2057 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2057 | + $this->_add_transient('edit_message_template', $validates); |
|
2058 | 2058 | |
2059 | 2059 | $success = 0; |
2060 | 2060 | |
2061 | 2061 | //setup notices |
2062 | - foreach ( $validates as $field => $error ) { |
|
2063 | - if ( isset($error['msg'] ) ) |
|
2064 | - {EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );} |
|
2062 | + foreach ($validates as $field => $error) { |
|
2063 | + if (isset($error['msg'])) |
|
2064 | + {EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); } |
|
2065 | 2065 | } |
2066 | 2066 | |
2067 | 2067 | } else { |
2068 | 2068 | $set_column_values = array(); |
2069 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2069 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2070 | 2070 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2071 | 2071 | |
2072 | - $where_cols_n_values = array( 'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']); |
|
2072 | + $where_cols_n_values = array('MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']); |
|
2073 | 2073 | |
2074 | 2074 | $message_template_fields = array( |
2075 | 2075 | 'GRP_ID' => $set_column_values['GRP_ID'], |
@@ -2077,10 +2077,10 @@ discard block |
||
2077 | 2077 | 'MTP_context' => $set_column_values['MTP_context'], |
2078 | 2078 | 'MTP_content' => $set_column_values['MTP_content'] |
2079 | 2079 | ); |
2080 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2081 | - if ( $updated === false ) { |
|
2082 | - $msg = sprintf( __('%s field was NOT updated for some reason', 'event_espresso'), $template_field ); |
|
2083 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2080 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2081 | + if ($updated === false) { |
|
2082 | + $msg = sprintf(__('%s field was NOT updated for some reason', 'event_espresso'), $template_field); |
|
2083 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2084 | 2084 | } else { |
2085 | 2085 | $success = 1; |
2086 | 2086 | } |
@@ -2090,40 +2090,40 @@ discard block |
||
2090 | 2090 | |
2091 | 2091 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2092 | 2092 | $mtpg_fields = array( |
2093 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2094 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2095 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2096 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2097 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2098 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2099 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2100 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2101 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2093 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2094 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2095 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2096 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2097 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2098 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2099 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2100 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2101 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2102 | 2102 | : '', |
2103 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2104 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2103 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2104 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2105 | 2105 | : '' |
2106 | 2106 | ); |
2107 | 2107 | |
2108 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2109 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2108 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2109 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2110 | 2110 | |
2111 | - if ( $updated === false ) { |
|
2111 | + if ($updated === false) { |
|
2112 | 2112 | EE_Error::add_error( |
2113 | 2113 | sprintf( |
2114 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2115 | - $set_column_values[ 'GRP_ID' ] |
|
2114 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2115 | + $set_column_values['GRP_ID'] |
|
2116 | 2116 | ), |
2117 | 2117 | __FILE__, __FUNCTION__, __LINE__ |
2118 | 2118 | ); |
2119 | 2119 | } else { |
2120 | 2120 | //k now we need to ensure the template_pack and template_variation fields are set. |
2121 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) ? $this->_req_data['MTP_template_pack'] : 'default'; |
|
2122 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) ? $this->_req_data['MTP_template_variation'] : 'default'; |
|
2123 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2124 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2125 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2126 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2121 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) ? $this->_req_data['MTP_template_pack'] : 'default'; |
|
2122 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) ? $this->_req_data['MTP_template_variation'] : 'default'; |
|
2123 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2124 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2125 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2126 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2127 | 2127 | } |
2128 | 2128 | $success = 1; |
2129 | 2129 | } |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | } |
2134 | 2134 | |
2135 | 2135 | //we return things differently if doing ajax |
2136 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2136 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2137 | 2137 | $this->_template_args['success'] = $success; |
2138 | 2138 | $this->_template_args['error'] = ! $success ? true : false; |
2139 | 2139 | $this->_template_args['content'] = ''; |
@@ -2141,9 +2141,9 @@ discard block |
||
2141 | 2141 | 'grpID' => $edit_array['GRP_ID'], |
2142 | 2142 | 'templateName' => $edit_array['template_name'] |
2143 | 2143 | ); |
2144 | - if ( $success ) { |
|
2144 | + if ($success) { |
|
2145 | 2145 | EE_Error::overwrite_success(); |
2146 | - EE_Error::add_success( __('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso') ); |
|
2146 | + EE_Error::add_success(__('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso')); |
|
2147 | 2147 | } |
2148 | 2148 | |
2149 | 2149 | $this->_return_json(); |
@@ -2151,13 +2151,13 @@ discard block |
||
2151 | 2151 | |
2152 | 2152 | |
2153 | 2153 | //was a test send triggered? |
2154 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2154 | + if (isset($this->_req_data['test_button'])) { |
|
2155 | 2155 | EE_Error::overwrite_success(); |
2156 | - $this->_do_test_send( $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] ); |
|
2156 | + $this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2157 | 2157 | $override = true; |
2158 | 2158 | } |
2159 | 2159 | |
2160 | - if ( empty( $query_args ) ) { |
|
2160 | + if (empty($query_args)) { |
|
2161 | 2161 | $query_args = array( |
2162 | 2162 | 'id' => $this->_req_data['GRP_ID'], |
2163 | 2163 | 'context' => $this->_req_data['MTP_context'], |
@@ -2165,7 +2165,7 @@ discard block |
||
2165 | 2165 | ); |
2166 | 2166 | } |
2167 | 2167 | |
2168 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2168 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2169 | 2169 | } |
2170 | 2170 | |
2171 | 2171 | |
@@ -2179,28 +2179,28 @@ discard block |
||
2179 | 2179 | * @param string $message_type message type being tested |
2180 | 2180 | * |
2181 | 2181 | */ |
2182 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2182 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2183 | 2183 | //set things up for preview |
2184 | 2184 | $this->_req_data['messenger'] = $messenger; |
2185 | 2185 | $this->_req_data['message_type'] = $message_type; |
2186 | 2186 | $this->_req_data['context'] = $context; |
2187 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2188 | - $active_messenger = $this->_active_messengers[ $messenger ]; |
|
2187 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2188 | + $active_messenger = $this->_active_messengers[$messenger]; |
|
2189 | 2189 | |
2190 | 2190 | //let's save any existing fields that might be required by the messenger |
2191 | 2191 | if ( |
2192 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2192 | + isset($this->_req_data['test_settings_fld']) |
|
2193 | 2193 | && $active_messenger instanceof EE_Messenger |
2194 | 2194 | ) { |
2195 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2195 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | $success = $this->_preview_message(true); |
2199 | 2199 | |
2200 | - if ( $success ) { |
|
2201 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2200 | + if ($success) { |
|
2201 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2202 | 2202 | } else { |
2203 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2203 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2204 | 2204 | } |
2205 | 2205 | } |
2206 | 2206 | |
@@ -2226,11 +2226,11 @@ discard block |
||
2226 | 2226 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2227 | 2227 | |
2228 | 2228 | //if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates. |
2229 | - if ( empty( $message_types ) ) { |
|
2229 | + if (empty($message_types)) { |
|
2230 | 2230 | return true; |
2231 | 2231 | } |
2232 | 2232 | |
2233 | - return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2233 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2234 | 2234 | |
2235 | 2235 | } |
2236 | 2236 | |
@@ -2247,33 +2247,33 @@ discard block |
||
2247 | 2247 | * |
2248 | 2248 | * @return void |
2249 | 2249 | */ |
2250 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2251 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2250 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2251 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2252 | 2252 | $MTP = EEM_Message_Template_Group::instance(); |
2253 | 2253 | |
2254 | 2254 | $success = 1; |
2255 | 2255 | |
2256 | 2256 | //incoming GRP_IDs |
2257 | - if ( $all ) { |
|
2257 | + if ($all) { |
|
2258 | 2258 | //Checkboxes |
2259 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2259 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2260 | 2260 | //if array has more than one element then success message should be plural. |
2261 | 2261 | //todo: what about nonce? |
2262 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2262 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2263 | 2263 | |
2264 | 2264 | //cycle through checkboxes |
2265 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2266 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2267 | - if ( ! $trashed_or_restored ) { |
|
2265 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2266 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2267 | + if ( ! $trashed_or_restored) { |
|
2268 | 2268 | $success = 0; |
2269 | 2269 | } |
2270 | 2270 | } |
2271 | 2271 | } else { |
2272 | 2272 | //grab single GRP_ID and handle |
2273 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2274 | - if ( ! empty( $GRP_ID ) ) { |
|
2275 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2276 | - if ( ! $trashed_or_restored ) { |
|
2273 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2274 | + if ( ! empty($GRP_ID)) { |
|
2275 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2276 | + if ( ! $trashed_or_restored) { |
|
2277 | 2277 | $success = 0; |
2278 | 2278 | } |
2279 | 2279 | } else { |
@@ -2285,13 +2285,13 @@ discard block |
||
2285 | 2285 | |
2286 | 2286 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2287 | 2287 | |
2288 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2288 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2289 | 2289 | |
2290 | 2290 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2291 | 2291 | |
2292 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2292 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2293 | 2293 | |
2294 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2294 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2295 | 2295 | |
2296 | 2296 | } |
2297 | 2297 | |
@@ -2307,24 +2307,24 @@ discard block |
||
2307 | 2307 | * @return void |
2308 | 2308 | */ |
2309 | 2309 | protected function _delete_message_template() { |
2310 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2310 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2311 | 2311 | |
2312 | 2312 | //checkboxes |
2313 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2313 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2314 | 2314 | //if array has more than one element then success message should be plural |
2315 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2315 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2316 | 2316 | |
2317 | 2317 | //cycle through bulk action checkboxes |
2318 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2319 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2318 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2319 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2320 | 2320 | } |
2321 | 2321 | } else { |
2322 | 2322 | //grab single grp_id and delete |
2323 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2324 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2323 | + $GRP_ID = absint($this->_req_data['id']); |
|
2324 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2325 | 2325 | } |
2326 | 2326 | |
2327 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2327 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2328 | 2328 | |
2329 | 2329 | } |
2330 | 2330 | |
@@ -2339,20 +2339,20 @@ discard block |
||
2339 | 2339 | * |
2340 | 2340 | * @return bool boolean to indicate the success of the deletes or not. |
2341 | 2341 | */ |
2342 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2342 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2343 | 2343 | $success = 1; |
2344 | 2344 | $MTPG = EEM_Message_Template_Group::instance(); |
2345 | 2345 | //first let's GET this group |
2346 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2346 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2347 | 2347 | //then delete permanently all the related Message Templates |
2348 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2348 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2349 | 2349 | |
2350 | - if ( $deleted === 0 ) |
|
2351 | - {$success = 0;} |
|
2350 | + if ($deleted === 0) |
|
2351 | + {$success = 0; } |
|
2352 | 2352 | |
2353 | 2353 | //now delete permanently this particular group |
2354 | 2354 | |
2355 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2355 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2356 | 2356 | $success = 0; |
2357 | 2357 | } |
2358 | 2358 | return $success; |
@@ -2370,7 +2370,7 @@ discard block |
||
2370 | 2370 | * @return string |
2371 | 2371 | */ |
2372 | 2372 | protected function _learn_more_about_message_templates_link() { |
2373 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2373 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2374 | 2374 | } |
2375 | 2375 | |
2376 | 2376 | |
@@ -2385,14 +2385,14 @@ discard block |
||
2385 | 2385 | */ |
2386 | 2386 | protected function _settings() { |
2387 | 2387 | |
2388 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
2388 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
2389 | 2389 | |
2390 | 2390 | $this->_set_m_mt_settings(); |
2391 | 2391 | |
2392 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2392 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2393 | 2393 | |
2394 | 2394 | //let's setup the messenger tabs |
2395 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2395 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2396 | 2396 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2397 | 2397 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2398 | 2398 | |
@@ -2411,7 +2411,7 @@ discard block |
||
2411 | 2411 | */ |
2412 | 2412 | protected function _set_m_mt_settings() { |
2413 | 2413 | //first if this is already set then lets get out no need to regenerate data. |
2414 | - if ( !empty($this->_m_mt_settings) ) { |
|
2414 | + if ( ! empty($this->_m_mt_settings)) { |
|
2415 | 2415 | return; |
2416 | 2416 | } |
2417 | 2417 | |
@@ -2425,10 +2425,10 @@ discard block |
||
2425 | 2425 | |
2426 | 2426 | //assemble the array for the _tab_text_links helper |
2427 | 2427 | |
2428 | - foreach ( $messengers as $messenger ) { |
|
2428 | + foreach ($messengers as $messenger) { |
|
2429 | 2429 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2430 | 2430 | 'label' => ucwords($messenger->label['singular']), |
2431 | - 'class' => isset( $this->_active_messengers[$messenger->name] ) ? 'messenger-active' : '', |
|
2431 | + 'class' => isset($this->_active_messengers[$messenger->name]) ? 'messenger-active' : '', |
|
2432 | 2432 | 'href' => $messenger->name, |
2433 | 2433 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2434 | 2434 | 'slug' => $messenger->name, |
@@ -2438,29 +2438,29 @@ discard block |
||
2438 | 2438 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2439 | 2439 | |
2440 | 2440 | //assemble the array for the ACTIVE and INACTIVE message types with the selected messenger //note that all message types will be in the inactive box if the messenger is NOT active. |
2441 | - $selected_settings = isset( $this->_active_messengers[$messenger->name]['settings'] ) |
|
2441 | + $selected_settings = isset($this->_active_messengers[$messenger->name]['settings']) |
|
2442 | 2442 | ? $this->_active_messengers[$messenger->name]['settings'] |
2443 | 2443 | : array(); |
2444 | - foreach ( $message_types as $message_type ) { |
|
2444 | + foreach ($message_types as $message_type) { |
|
2445 | 2445 | //first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox. |
2446 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2446 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2447 | 2447 | continue; |
2448 | 2448 | } |
2449 | 2449 | |
2450 | - $a_or_i = isset( $selected_settings[$messenger->name . '-message_types'][$message_type->name] ) && $selected_settings[$messenger->name . '-message_types'][$message_type->name] ? 'active' : 'inactive'; |
|
2450 | + $a_or_i = isset($selected_settings[$messenger->name.'-message_types'][$message_type->name]) && $selected_settings[$messenger->name.'-message_types'][$message_type->name] ? 'active' : 'inactive'; |
|
2451 | 2451 | |
2452 | 2452 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2453 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2454 | - 'class' => 'message-type-' . $a_or_i, |
|
2455 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2456 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2457 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2453 | + 'label' => ucwords($message_type->label['singular']), |
|
2454 | + 'class' => 'message-type-'.$a_or_i, |
|
2455 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2456 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2457 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2458 | 2458 | 'title' => $a_or_i == 'active' |
2459 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2460 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2459 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2460 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2461 | 2461 | 'content' => $a_or_i == 'active' |
2462 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2463 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2462 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2463 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2464 | 2464 | 'slug' => $message_type->name, |
2465 | 2465 | 'active' => $a_or_i == 'active' ? true : false, |
2466 | 2466 | 'obj' => $message_type |
@@ -2479,34 +2479,34 @@ discard block |
||
2479 | 2479 | * |
2480 | 2480 | * @return string html output for the content |
2481 | 2481 | */ |
2482 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2482 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2483 | 2483 | //get message type fields |
2484 | 2484 | $fields = $message_type->get_admin_settings_fields(); |
2485 | - $settings_template_args['template_form_fields']= ''; |
|
2485 | + $settings_template_args['template_form_fields'] = ''; |
|
2486 | 2486 | |
2487 | - if ( !empty( $fields ) && $active ) { |
|
2487 | + if ( ! empty($fields) && $active) { |
|
2488 | 2488 | |
2489 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2489 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2490 | 2490 | |
2491 | - foreach( $fields as $fldname => $fldprops ) { |
|
2492 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2491 | + foreach ($fields as $fldname => $fldprops) { |
|
2492 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2493 | 2493 | $template_form_field[$field_id] = array( |
2494 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2494 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2495 | 2495 | 'label' => $fldprops['label'], |
2496 | 2496 | 'input' => $fldprops['field_type'], |
2497 | 2497 | 'type' => $fldprops['value_type'], |
2498 | 2498 | 'required' => $fldprops['required'], |
2499 | 2499 | 'validation' => $fldprops['validation'], |
2500 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2501 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2502 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2500 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2501 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2502 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2503 | 2503 | 'css_class' => 'no-drag', |
2504 | 2504 | 'format' => $fldprops['format'] |
2505 | 2505 | ); |
2506 | 2506 | } |
2507 | 2507 | |
2508 | 2508 | |
2509 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2509 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2510 | 2510 | } |
2511 | 2511 | |
2512 | 2512 | $settings_template_args['description'] = $message_type->description; |
@@ -2526,13 +2526,13 @@ discard block |
||
2526 | 2526 | ) |
2527 | 2527 | ); |
2528 | 2528 | |
2529 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2530 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2529 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2530 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2531 | 2531 | |
2532 | 2532 | |
2533 | 2533 | |
2534 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2535 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2534 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2535 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2536 | 2536 | return $content; |
2537 | 2537 | } |
2538 | 2538 | |
@@ -2549,21 +2549,21 @@ discard block |
||
2549 | 2549 | $m_boxes = $mt_boxes = array(); |
2550 | 2550 | $m_template_args = $mt_template_args = array(); |
2551 | 2551 | |
2552 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2552 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2553 | 2553 | |
2554 | - foreach ( $this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array ) { |
|
2554 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2555 | 2555 | |
2556 | - $hide_on_message = isset( $this->_active_messengers[$messenger] ) ? '' : 'hidden'; |
|
2557 | - $hide_off_message = isset( $this->_active_messengers[$messenger] ) ? 'hidden' : ''; |
|
2556 | + $hide_on_message = isset($this->_active_messengers[$messenger]) ? '' : 'hidden'; |
|
2557 | + $hide_off_message = isset($this->_active_messengers[$messenger]) ? 'hidden' : ''; |
|
2558 | 2558 | |
2559 | 2559 | //messenger meta boxes |
2560 | 2560 | $active = $selected_messenger == $messenger ? true : false; |
2561 | - $active_mt_tabs = isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] ) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : ''; |
|
2562 | - $m_boxes[$messenger . '_a_box'] = sprintf( __('%s Settings', 'event_espresso'), $tab_array['label'] ); |
|
2563 | - $m_template_args[$messenger . '_a_box'] = array( |
|
2564 | - 'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2565 | - 'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '', |
|
2566 | - 'content' => $this->_get_messenger_box_content( $tab_array['obj'] ), |
|
2561 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : ''; |
|
2562 | + $m_boxes[$messenger.'_a_box'] = sprintf(__('%s Settings', 'event_espresso'), $tab_array['label']); |
|
2563 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2564 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2565 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '', |
|
2566 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2567 | 2567 | 'hidden' => $active ? '' : ' hidden', |
2568 | 2568 | 'hide_on_message' => $hide_on_message, |
2569 | 2569 | 'messenger' => $messenger, |
@@ -2572,10 +2572,10 @@ discard block |
||
2572 | 2572 | |
2573 | 2573 | |
2574 | 2574 | //message type meta boxes (which is really just the inactive container for each messenger showing inactive message types for that messenger) |
2575 | - $mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2576 | - $mt_template_args[$messenger . '_i_box'] = array( |
|
2577 | - 'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2578 | - 'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '', |
|
2575 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2576 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2577 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2578 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '', |
|
2579 | 2579 | 'hidden' => $active ? '' : ' hidden', |
2580 | 2580 | 'hide_on_message' => $hide_on_message, |
2581 | 2581 | 'hide_off_message' => $hide_off_message, |
@@ -2585,19 +2585,19 @@ discard block |
||
2585 | 2585 | } |
2586 | 2586 | |
2587 | 2587 | //register messenger metaboxes |
2588 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2589 | - foreach ( $m_boxes as $box => $label ) { |
|
2590 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2591 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2592 | - add_meta_box( 'espresso_' . $msgr . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args ); |
|
2588 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2589 | + foreach ($m_boxes as $box => $label) { |
|
2590 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2591 | + $msgr = str_replace('_a_box', '', $box); |
|
2592 | + add_meta_box('espresso_'.$msgr.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
2593 | 2593 | } |
2594 | 2594 | |
2595 | 2595 | //register message type metaboxes |
2596 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2597 | - foreach ( $mt_boxes as $box => $label ) { |
|
2598 | - $callback_args = array( 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] ); |
|
2599 | - $mt = str_replace( '_i_box', '', $box ); |
|
2600 | - add_meta_box( 'espresso_' . $mt . '_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args ); |
|
2596 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2597 | + foreach ($mt_boxes as $box => $label) { |
|
2598 | + $callback_args = array('template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]); |
|
2599 | + $mt = str_replace('_i_box', '', $box); |
|
2600 | + add_meta_box('espresso_'.$mt.'_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args); |
|
2601 | 2601 | } |
2602 | 2602 | |
2603 | 2603 | } |
@@ -2610,13 +2610,13 @@ discard block |
||
2610 | 2610 | * |
2611 | 2611 | * @return string html formatted tabs |
2612 | 2612 | */ |
2613 | - protected function _get_mt_tabs( $tab_array ) { |
|
2613 | + protected function _get_mt_tabs($tab_array) { |
|
2614 | 2614 | $tab_array = (array) $tab_array; |
2615 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2615 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2616 | 2616 | $tabs = ''; |
2617 | 2617 | |
2618 | - foreach ( $tab_array as $tab ) { |
|
2619 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
2618 | + foreach ($tab_array as $tab) { |
|
2619 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
2620 | 2620 | } |
2621 | 2621 | |
2622 | 2622 | return $tabs; |
@@ -2632,7 +2632,7 @@ discard block |
||
2632 | 2632 | * |
2633 | 2633 | * @return string html formatted content |
2634 | 2634 | */ |
2635 | - protected function _get_messenger_box_content( $messenger ) { |
|
2635 | + protected function _get_messenger_box_content($messenger) { |
|
2636 | 2636 | |
2637 | 2637 | $fields = $messenger->get_admin_settings_fields(); |
2638 | 2638 | $settings_template_args['template_form_fields'] = ''; |
@@ -2641,27 +2641,27 @@ discard block |
||
2641 | 2641 | $settings_template_args['active'] = isset($this->_active_messengers[$messenger->name]) ? true : false; |
2642 | 2642 | |
2643 | 2643 | |
2644 | - if ( !empty( $fields ) ) { |
|
2644 | + if ( ! empty($fields)) { |
|
2645 | 2645 | |
2646 | 2646 | $existing_settings = $messenger->get_existing_admin_settings(); |
2647 | 2647 | |
2648 | - foreach( $fields as $fldname => $fldprops ) { |
|
2649 | - $field_id = $messenger->name . '-' . $fldname; |
|
2648 | + foreach ($fields as $fldname => $fldprops) { |
|
2649 | + $field_id = $messenger->name.'-'.$fldname; |
|
2650 | 2650 | $template_form_field[$field_id] = array( |
2651 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
2651 | + 'name' => 'messenger_settings['.$field_id.']', |
|
2652 | 2652 | 'label' => $fldprops['label'], |
2653 | 2653 | 'input' => $fldprops['field_type'], |
2654 | 2654 | 'type' => $fldprops['value_type'], |
2655 | 2655 | 'required' => $fldprops['required'], |
2656 | 2656 | 'validation' => $fldprops['validation'], |
2657 | - 'value' => isset( $existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'], |
|
2657 | + 'value' => isset($existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'], |
|
2658 | 2658 | 'css_class' => '', |
2659 | 2659 | 'format' => $fldprops['format'] |
2660 | 2660 | ); |
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | |
2664 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) : ''; |
|
2664 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') : ''; |
|
2665 | 2665 | } |
2666 | 2666 | |
2667 | 2667 | //we also need some hidden fields |
@@ -2677,8 +2677,8 @@ discard block |
||
2677 | 2677 | ); |
2678 | 2678 | |
2679 | 2679 | //make sure any active message types that are existing are included in the hidden fields |
2680 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
2681 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
2680 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
2681 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
2682 | 2682 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
2683 | 2683 | 'type' => 'hidden', |
2684 | 2684 | 'value' => $mt |
@@ -2686,25 +2686,25 @@ discard block |
||
2686 | 2686 | } |
2687 | 2687 | } |
2688 | 2688 | |
2689 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2689 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2690 | 2690 | |
2691 | - $active = isset( $this->_active_messengers[$messenger->name] ) ? true : false; |
|
2691 | + $active = isset($this->_active_messengers[$messenger->name]) ? true : false; |
|
2692 | 2692 | |
2693 | 2693 | $settings_template_args['messenger'] = $messenger->name; |
2694 | 2694 | $settings_template_args['description'] = $messenger->description; |
2695 | 2695 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
2696 | 2696 | |
2697 | 2697 | |
2698 | - $settings_template_args['show_hide_edit_form'] = isset( $this->_active_messengers[$messenger->name] ) ? $settings_template_args['show_hide_edit_form'] : ' hidden'; |
|
2698 | + $settings_template_args['show_hide_edit_form'] = isset($this->_active_messengers[$messenger->name]) ? $settings_template_args['show_hide_edit_form'] : ' hidden'; |
|
2699 | 2699 | |
2700 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : $settings_template_args['show_hide_edit_form']; |
|
2700 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : $settings_template_args['show_hide_edit_form']; |
|
2701 | 2701 | |
2702 | 2702 | |
2703 | 2703 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
2704 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
2704 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
2705 | 2705 | $settings_template_args['on_off_status'] = $active ? true : false; |
2706 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
2707 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
2706 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
2707 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2708 | 2708 | return $content; |
2709 | 2709 | } |
2710 | 2710 | |
@@ -2718,39 +2718,39 @@ discard block |
||
2718 | 2718 | public function activate_messenger_toggle() { |
2719 | 2719 | $success = true; |
2720 | 2720 | //let's check that we have required data |
2721 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2722 | - EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2721 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2722 | + EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2723 | 2723 | $success = false; |
2724 | 2724 | } |
2725 | 2725 | |
2726 | 2726 | //do a nonce check here since we're not arriving via a normal route |
2727 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
2728 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
2727 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
2728 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
2729 | 2729 | |
2730 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2730 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2731 | 2731 | |
2732 | 2732 | |
2733 | 2733 | |
2734 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2735 | - EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2734 | + if ( ! isset($this->_req_data['status'])) { |
|
2735 | + EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2736 | 2736 | $success = false; |
2737 | 2737 | } |
2738 | 2738 | |
2739 | 2739 | //do check to verify we have a valid status. |
2740 | 2740 | $status = $this->_req_data['status']; |
2741 | 2741 | |
2742 | - if ( $status != 'off' && $status != 'on' ) { |
|
2743 | - EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2742 | + if ($status != 'off' && $status != 'on') { |
|
2743 | + EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__); |
|
2744 | 2744 | $success = false; |
2745 | 2745 | } |
2746 | 2746 | |
2747 | - if ( $success ) { |
|
2747 | + if ($success) { |
|
2748 | 2748 | //made it here? Stop dawdling then!! |
2749 | - if ( $status == 'off' ) { |
|
2749 | + if ($status == 'off') { |
|
2750 | 2750 | //off = deactivate. get it? |
2751 | - $success = $this->_activate_messenger( $this->_req_data['messenger'], true ); |
|
2751 | + $success = $this->_activate_messenger($this->_req_data['messenger'], true); |
|
2752 | 2752 | } else { |
2753 | - $success = $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
2753 | + $success = $this->_activate_messenger($this->_req_data['messenger']); |
|
2754 | 2754 | } |
2755 | 2755 | } |
2756 | 2756 | |
@@ -2776,26 +2776,26 @@ discard block |
||
2776 | 2776 | |
2777 | 2777 | |
2778 | 2778 | //let's make sure we have the necessary data |
2779 | - if ( !isset( $this->_req_data[ 'message_type' ] ) ) { |
|
2780 | - EE_Error::add_error( __('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2779 | + if ( ! isset($this->_req_data['message_type'])) { |
|
2780 | + EE_Error::add_error(__('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2781 | 2781 | $success = false; |
2782 | 2782 | } |
2783 | 2783 | |
2784 | 2784 | |
2785 | 2785 | //do a nonce check here since we're not arriving via a normal route |
2786 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
2787 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
2786 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
2787 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
2788 | 2788 | |
2789 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2789 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2790 | 2790 | |
2791 | 2791 | |
2792 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2793 | - EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2792 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2793 | + EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2794 | 2794 | $success = false; |
2795 | 2795 | } |
2796 | 2796 | |
2797 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2798 | - EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2797 | + if ( ! isset($this->_req_data['status'])) { |
|
2798 | + EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2799 | 2799 | $success = false; |
2800 | 2800 | } |
2801 | 2801 | |
@@ -2803,16 +2803,16 @@ discard block |
||
2803 | 2803 | //do check to verify we have a valid status. |
2804 | 2804 | $status = $this->_req_data['status']; |
2805 | 2805 | |
2806 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
2807 | - EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2806 | + if ($status != 'activate' && $status != 'deactivate') { |
|
2807 | + EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__); |
|
2808 | 2808 | $success = false; |
2809 | 2809 | } |
2810 | 2810 | |
2811 | 2811 | |
2812 | - if ( $success ) { |
|
2812 | + if ($success) { |
|
2813 | 2813 | //made it here? um, what are you waiting for then? |
2814 | 2814 | $deactivate = $status == 'deactivate' ? true : false; |
2815 | - $success = $this->_activate_messenger( $this->_req_data['messenger'], $deactivate, $this->_req_data['message_type'] ); |
|
2815 | + $success = $this->_activate_messenger($this->_req_data['messenger'], $deactivate, $this->_req_data['message_type']); |
|
2816 | 2816 | } |
2817 | 2817 | |
2818 | 2818 | $this->_template_args['success'] = $success; |
@@ -2842,19 +2842,19 @@ discard block |
||
2842 | 2842 | |
2843 | 2843 | $this->_set_m_mt_settings(); |
2844 | 2844 | |
2845 | - if ( !$deactivate ) { |
|
2845 | + if ( ! $deactivate) { |
|
2846 | 2846 | |
2847 | 2847 | |
2848 | 2848 | //we are activating. we can use $this->_m_mt_settings to get all the installed messengers |
2849 | - $this->_active_messengers[$messenger]['settings'] = !isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings']; |
|
2849 | + $this->_active_messengers[$messenger]['settings'] = ! isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings']; |
|
2850 | 2850 | $this->_active_messengers[$messenger]['obj'] = $this->_m_mt_settings['messenger_tabs'][$messenger]['obj']; |
2851 | 2851 | /** @type EE_Messenger $active_messenger */ |
2852 | - $active_messenger = $this->_active_messengers[ $messenger ][ 'obj' ]; |
|
2852 | + $active_messenger = $this->_active_messengers[$messenger]['obj']; |
|
2853 | 2853 | |
2854 | 2854 | //get has_active so we can sure its kept up to date. |
2855 | - $has_activated = get_option( 'ee_has_activated_messages' ); |
|
2855 | + $has_activated = get_option('ee_has_activated_messages'); |
|
2856 | 2856 | |
2857 | - if ( empty( $has_activated[$messenger] ) ) { |
|
2857 | + if (empty($has_activated[$messenger])) { |
|
2858 | 2858 | $has_activated[$messenger] = array(); |
2859 | 2859 | } |
2860 | 2860 | |
@@ -2863,22 +2863,22 @@ discard block |
||
2863 | 2863 | ? (array) $message_type |
2864 | 2864 | : $active_messenger->get_default_message_types(); |
2865 | 2865 | |
2866 | - foreach ( $default_types as $type ) { |
|
2866 | + foreach ($default_types as $type) { |
|
2867 | 2867 | /** @type EE_Message_Type $active_message_type */ |
2868 | - $active_message_type = $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ][ $type ][ 'obj' ]; |
|
2868 | + $active_message_type = $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$type]['obj']; |
|
2869 | 2869 | $settings_fields = $active_message_type->get_admin_settings_fields(); |
2870 | 2870 | $settings = array(); |
2871 | - if ( !empty( $settings_fields ) ) { |
|
2871 | + if ( ! empty($settings_fields)) { |
|
2872 | 2872 | //we have fields for this message type so let's get the defaults for saving. |
2873 | - foreach ( $settings_fields as $field => $values ) { |
|
2873 | + foreach ($settings_fields as $field => $values) { |
|
2874 | 2874 | $settings[$field] = $values['default']; |
2875 | 2875 | } |
2876 | 2876 | //let's set the data for reloading this message type form in ajax |
2877 | 2877 | $this->_template_args['data']['mt_reload'][] = $type; |
2878 | 2878 | } |
2879 | - $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$type]['settings'] = $settings; |
|
2879 | + $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$type]['settings'] = $settings; |
|
2880 | 2880 | |
2881 | - if ( ! in_array( $type, $has_activated[$messenger] ) ) { |
|
2881 | + if ( ! in_array($type, $has_activated[$messenger])) { |
|
2882 | 2882 | $has_activated[$messenger][] = $type; |
2883 | 2883 | } |
2884 | 2884 | } |
@@ -2886,41 +2886,41 @@ discard block |
||
2886 | 2886 | //any default settings for the messenger? |
2887 | 2887 | $msgr_settings = $active_messenger->get_admin_settings_fields(); |
2888 | 2888 | |
2889 | - if ( !empty( $msgr_settings ) ) { |
|
2890 | - foreach ( $msgr_settings as $field => $value ) { |
|
2889 | + if ( ! empty($msgr_settings)) { |
|
2890 | + foreach ($msgr_settings as $field => $value) { |
|
2891 | 2891 | $this->_active_messengers[$messenger]['settings'][$field] = $value; |
2892 | 2892 | } |
2893 | 2893 | } |
2894 | 2894 | |
2895 | 2895 | //update settings in database |
2896 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
2897 | - update_option( 'ee_has_activated_messages', $has_activated ); |
|
2896 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
2897 | + update_option('ee_has_activated_messages', $has_activated); |
|
2898 | 2898 | |
2899 | 2899 | |
2900 | 2900 | //generate new templates (if necessary) |
2901 | - $templates = $this->_generate_new_templates( $messenger, $default_types, 0, true ); |
|
2901 | + $templates = $this->_generate_new_templates($messenger, $default_types, 0, true); |
|
2902 | 2902 | |
2903 | 2903 | EE_Error::overwrite_success(); |
2904 | 2904 | |
2905 | 2905 | //if generation failed then we need to remove the active messenger. |
2906 | - if ( !$templates ) { |
|
2906 | + if ( ! $templates) { |
|
2907 | 2907 | unset($this->_active_messengers[$messenger]); |
2908 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
2908 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
2909 | 2909 | } else { |
2910 | 2910 | //all is good let's do a success message |
2911 | - if ( $message_type ) { |
|
2912 | - EE_Error::add_success( sprintf( __('%s message type has been successfully activated with the %s messenger', 'event_espresso'),ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords( $this->_active_messengers[$messenger]->label['singular'] ) ) ); |
|
2911 | + if ($message_type) { |
|
2912 | + EE_Error::add_success(sprintf(__('%s message type has been successfully activated with the %s messenger', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords($this->_active_messengers[$messenger]->label['singular']))); |
|
2913 | 2913 | |
2914 | 2914 | //if message type was invoice then let's make sure we activate the invoice payment method. |
2915 | - if ( $message_type == 'invoice' ) { |
|
2916 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
2917 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
2918 | - if ( $pm instanceof EE_Payment_Method ) { |
|
2919 | - EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) ); |
|
2915 | + if ($message_type == 'invoice') { |
|
2916 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
2917 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
2918 | + if ($pm instanceof EE_Payment_Method) { |
|
2919 | + EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso')); |
|
2920 | 2920 | } |
2921 | 2921 | } |
2922 | 2922 | } else { |
2923 | - EE_Error::add_success( sprintf( __('%s messenger has been successfully activated', 'event_espresso'), ucwords( $this->_active_messengers[$messenger]->label['singular'] ) ) ); |
|
2923 | + EE_Error::add_success(sprintf(__('%s messenger has been successfully activated', 'event_espresso'), ucwords($this->_active_messengers[$messenger]->label['singular']))); |
|
2924 | 2924 | } |
2925 | 2925 | } |
2926 | 2926 | |
@@ -2933,37 +2933,37 @@ discard block |
||
2933 | 2933 | $update_array = array( |
2934 | 2934 | 'MTP_messenger' => $messenger); |
2935 | 2935 | |
2936 | - if ( $message_type ) { |
|
2936 | + if ($message_type) { |
|
2937 | 2937 | $update_array['MTP_message_type'] = $message_type; |
2938 | 2938 | } |
2939 | - EEM_Message_Template_Group::instance()->update( array( 'MTP_is_active' => 0 ), array($update_array) ); |
|
2939 | + EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => 0), array($update_array)); |
|
2940 | 2940 | |
2941 | 2941 | $messenger_obj = $this->_active_messengers[$messenger]; |
2942 | 2942 | |
2943 | 2943 | //if this is a message type deactivation then we're only unsetting the message type otherwise unset the messenger |
2944 | - if ( $message_type ) { |
|
2945 | - unset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] ); |
|
2944 | + if ($message_type) { |
|
2945 | + unset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type]); |
|
2946 | 2946 | } else { |
2947 | - unset( $this->_active_messengers[$messenger] ); |
|
2947 | + unset($this->_active_messengers[$messenger]); |
|
2948 | 2948 | } |
2949 | 2949 | |
2950 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
2950 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
2951 | 2951 | EE_Error::overwrite_success(); |
2952 | - if ( $message_type ) { |
|
2953 | - EE_Error::add_success( sprintf( __('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']) ) ); |
|
2952 | + if ($message_type) { |
|
2953 | + EE_Error::add_success(sprintf(__('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']))); |
|
2954 | 2954 | } else { |
2955 | - EE_Error::add_success( sprintf( __('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'] ) ) ); |
|
2955 | + EE_Error::add_success(sprintf(__('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular']))); |
|
2956 | 2956 | } |
2957 | 2957 | |
2958 | 2958 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
2959 | - if ( $messenger == 'html' || $message_type == 'invoice') { |
|
2960 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
2961 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
2962 | - if ( $count_updated > 0 ) { |
|
2959 | + if ($messenger == 'html' || $message_type == 'invoice') { |
|
2960 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
2961 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
2962 | + if ($count_updated > 0) { |
|
2963 | 2963 | $msg = $message_type == 'invoice' |
2964 | - ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) |
|
2965 | - : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ); |
|
2966 | - EE_Error::add_attention( $msg ); |
|
2964 | + ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') |
|
2965 | + : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso'); |
|
2966 | + EE_Error::add_attention($msg); |
|
2967 | 2967 | } |
2968 | 2968 | } |
2969 | 2969 | |
@@ -2980,17 +2980,17 @@ discard block |
||
2980 | 2980 | * @return string html data |
2981 | 2981 | */ |
2982 | 2982 | public function update_mt_form() { |
2983 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
2984 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2983 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
2984 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
2985 | 2985 | return $this->_return_json(); |
2986 | 2986 | } |
2987 | 2987 | |
2988 | 2988 | $message_types = $this->get_installed_message_types(); |
2989 | 2989 | |
2990 | - $message_type = $message_types[ $this->_req_data['message_type'] ]; |
|
2991 | - $messenger = $this->_active_messengers[ $this->_req_data['messenger'] ]; |
|
2990 | + $message_type = $message_types[$this->_req_data['message_type']]; |
|
2991 | + $messenger = $this->_active_messengers[$this->_req_data['messenger']]; |
|
2992 | 2992 | |
2993 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
2993 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
2994 | 2994 | $this->_template_args['success'] = true; |
2995 | 2995 | $this->_template_args['content'] = $content; |
2996 | 2996 | return $this->_return_json(); |
@@ -3005,36 +3005,36 @@ discard block |
||
3005 | 3005 | * @return string json success or fail message |
3006 | 3006 | */ |
3007 | 3007 | public function save_settings() { |
3008 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3009 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3008 | + if ( ! isset($this->_req_data['type'])) { |
|
3009 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3010 | 3010 | $this->_template_args['error'] = true; |
3011 | 3011 | $this->_return_json(); |
3012 | 3012 | } |
3013 | 3013 | |
3014 | 3014 | |
3015 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3015 | + if ($this->_req_data['type'] == 'messenger') { |
|
3016 | 3016 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3017 | 3017 | $messenger = $settings['messenger']; |
3018 | 3018 | //let's setup the settings data |
3019 | - foreach ( $settings as $key => $value ) { |
|
3020 | - switch ( $key ) { |
|
3019 | + foreach ($settings as $key => $value) { |
|
3020 | + switch ($key) { |
|
3021 | 3021 | case 'messenger' : |
3022 | - unset( $settings['messenger'] ); |
|
3022 | + unset($settings['messenger']); |
|
3023 | 3023 | break; |
3024 | 3024 | case 'message_types' : |
3025 | - if ( isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] ) ) { |
|
3026 | - foreach ( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v ) { |
|
3027 | - if ( isset( $settings['message_types'][$mt] ) ) |
|
3028 | - {$settings[$messenger . '-message_types'][$mt]['settings'] = isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ? $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] : array();} |
|
3025 | + if (isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'])) { |
|
3026 | + foreach ($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'] as $mt => $v) { |
|
3027 | + if (isset($settings['message_types'][$mt])) |
|
3028 | + {$settings[$messenger.'-message_types'][$mt]['settings'] = isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) ? $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt] : array(); } |
|
3029 | 3029 | } |
3030 | 3030 | } else { |
3031 | - foreach ( $value as $mt => $v ) { |
|
3031 | + foreach ($value as $mt => $v) { |
|
3032 | 3032 | //let's see if this message type is already present and has settings. |
3033 | - $settings[$messenger . '-message_types'][$mt]['settings'] = array(); |
|
3033 | + $settings[$messenger.'-message_types'][$mt]['settings'] = array(); |
|
3034 | 3034 | } |
3035 | 3035 | } |
3036 | 3036 | //k settings are set let's get rid of the message types index |
3037 | - unset( $settings['message_types'] ); |
|
3037 | + unset($settings['message_types']); |
|
3038 | 3038 | break; |
3039 | 3039 | default : |
3040 | 3040 | $settings[$key] = $value; |
@@ -3044,36 +3044,36 @@ discard block |
||
3044 | 3044 | $this->_active_messengers[$messenger]['settings'] = $settings; |
3045 | 3045 | } |
3046 | 3046 | |
3047 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3047 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3048 | 3048 | $settings = $this->_req_data['message_type_settings']; |
3049 | 3049 | $messenger = $settings['messenger']; |
3050 | 3050 | $message_type = $settings['message_type']; |
3051 | 3051 | |
3052 | - foreach ( $settings as $key => $value ) { |
|
3053 | - switch ( $key ) { |
|
3052 | + foreach ($settings as $key => $value) { |
|
3053 | + switch ($key) { |
|
3054 | 3054 | case 'messenger' : |
3055 | - unset( $settings['messenger'] ); |
|
3055 | + unset($settings['messenger']); |
|
3056 | 3056 | break; |
3057 | 3057 | case 'message_type' : |
3058 | - unset( $settings['message_type'] ); |
|
3058 | + unset($settings['message_type']); |
|
3059 | 3059 | break; |
3060 | 3060 | default : |
3061 | 3061 | $settings['settings'][$key] = $value; |
3062 | - unset( $settings[$key] ); |
|
3062 | + unset($settings[$key]); |
|
3063 | 3063 | break; |
3064 | 3064 | } |
3065 | 3065 | } |
3066 | 3066 | |
3067 | - $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings; |
|
3067 | + $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type] = $settings; |
|
3068 | 3068 | } |
3069 | 3069 | |
3070 | 3070 | //okay we should have the data all setup. Now we just update! |
3071 | - $success = EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
3071 | + $success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
3072 | 3072 | |
3073 | - if ( $success ) { |
|
3074 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3073 | + if ($success) { |
|
3074 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3075 | 3075 | } else { |
3076 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3076 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3077 | 3077 | } |
3078 | 3078 | |
3079 | 3079 | $this->_template_args['success'] = $success; |
@@ -3095,8 +3095,8 @@ discard block |
||
3095 | 3095 | */ |
3096 | 3096 | protected function _generate_now() { |
3097 | 3097 | $msg_ids = $this->_get_msg_ids_from_request(); |
3098 | - EED_Messages::generate_now( $msg_ids ); |
|
3099 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3098 | + EED_Messages::generate_now($msg_ids); |
|
3099 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3100 | 3100 | } |
3101 | 3101 | |
3102 | 3102 | |
@@ -3111,7 +3111,7 @@ discard block |
||
3111 | 3111 | protected function _generate_and_send_now() { |
3112 | 3112 | $this->_generate_now(); |
3113 | 3113 | $this->_send_now(); |
3114 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3114 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3115 | 3115 | } |
3116 | 3116 | |
3117 | 3117 | |
@@ -3125,8 +3125,8 @@ discard block |
||
3125 | 3125 | */ |
3126 | 3126 | protected function _queue_for_resending() { |
3127 | 3127 | $msg_ids = $this->_get_msg_ids_from_request(); |
3128 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3129 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3128 | + EED_Messages::queue_for_resending($msg_ids); |
|
3129 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3130 | 3130 | } |
3131 | 3131 | |
3132 | 3132 | |
@@ -3139,8 +3139,8 @@ discard block |
||
3139 | 3139 | */ |
3140 | 3140 | protected function _send_now() { |
3141 | 3141 | $msg_ids = $this->_get_msg_ids_from_request(); |
3142 | - EED_Messages::send_now( $msg_ids ); |
|
3143 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3142 | + EED_Messages::send_now($msg_ids); |
|
3143 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3144 | 3144 | } |
3145 | 3145 | |
3146 | 3146 | |
@@ -3154,23 +3154,23 @@ discard block |
||
3154 | 3154 | protected function _delete_ee_messages() { |
3155 | 3155 | $msg_ids = $this->_get_msg_ids_from_request(); |
3156 | 3156 | $deleted_count = 0; |
3157 | - foreach ( $msg_ids as $msg_id ) { |
|
3158 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3157 | + foreach ($msg_ids as $msg_id) { |
|
3158 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3159 | 3159 | $deleted_count++; |
3160 | 3160 | } |
3161 | 3161 | } |
3162 | - if ( $deleted_count ) { |
|
3162 | + if ($deleted_count) { |
|
3163 | 3163 | $this->_redirect_after_action( |
3164 | 3164 | true, |
3165 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3165 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3166 | 3166 | __('deleted', 'event_espresso') |
3167 | 3167 | ); |
3168 | 3168 | } else { |
3169 | 3169 | EE_Error::add_error( |
3170 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3170 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3171 | 3171 | __FILE__, __FUNCTION__, __LINE__ |
3172 | 3172 | ); |
3173 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3173 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3174 | 3174 | } |
3175 | 3175 | } |
3176 | 3176 | |
@@ -3183,10 +3183,10 @@ discard block |
||
3183 | 3183 | * @return array |
3184 | 3184 | */ |
3185 | 3185 | protected function _get_msg_ids_from_request() { |
3186 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3186 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3187 | 3187 | return array(); |
3188 | 3188 | } |
3189 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3189 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3190 | 3190 | } |
3191 | 3191 | |
3192 | 3192 |
@@ -93,7 +93,7 @@ |
||
93 | 93 | * |
94 | 94 | * @abstract |
95 | 95 | * @access protected |
96 | - * @return array |
|
96 | + * @return string[] |
|
97 | 97 | */ |
98 | 98 | protected function _get_table_filters() { |
99 | 99 | $filters = array(); |
@@ -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 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | class Custom_Messages_Template_List_Table extends EE_Admin_List_Table { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $admin_page ) { |
|
33 | + public function __construct($admin_page) { |
|
34 | 34 | //Set parent defaults |
35 | 35 | parent::__construct($admin_page); |
36 | 36 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | protected function _setup_data() { |
52 | - $this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE, FALSE, FALSE ); |
|
53 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE, FALSE ); |
|
52 | + $this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE, FALSE, FALSE); |
|
53 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE, FALSE); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | protected function _set_properties() { |
61 | 61 | $this->_wp_list_args = array( |
62 | - 'singular' => __('Message Template Group', 'event_espresso' ), |
|
63 | - 'plural' => __('Message Template', 'event_espresso' ), |
|
62 | + 'singular' => __('Message Template Group', 'event_espresso'), |
|
63 | + 'plural' => __('Message Template', 'event_espresso'), |
|
64 | 64 | 'ajax' => TRUE, //for now, |
65 | 65 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
66 | 66 | ); |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | 'cb' => '<input type="checkbox" />', |
70 | 70 | 'name' => __('Template Name', 'event_espresso'), |
71 | 71 | 'message_type' => __('Message Type', 'event_espresso'), |
72 | - 'messenger' => __( 'Messenger', 'event_espresso'), |
|
73 | - 'description' => __( 'Description', 'event_espresso' ), |
|
74 | - 'events' => __( 'Events', 'event_espresso'), //count of events using this template. |
|
72 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
73 | + 'description' => __('Description', 'event_espresso'), |
|
74 | + 'events' => __('Events', 'event_espresso'), //count of events using this template. |
|
75 | 75 | 'actions' => '' |
76 | 76 | //'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place. |
77 | 77 | ); |
78 | 78 | |
79 | 79 | $this->_sortable_columns = array( |
80 | - 'messenger' => array( 'MTP_messenger' => TRUE ), |
|
80 | + 'messenger' => array('MTP_messenger' => TRUE), |
|
81 | 81 | //'message_type' => array( 'MTP_message_type' => FALSE ) |
82 | 82 | ); |
83 | 83 | |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return string |
98 | 98 | */ |
99 | - public function single_row( $item ) { |
|
99 | + public function single_row($item) { |
|
100 | 100 | $message_type = $item->message_type_obj(); |
101 | 101 | $messenger = $item->messenger_obj(); |
102 | 102 | |
103 | - if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_Messenger ) { |
|
103 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_Messenger) { |
|
104 | 104 | echo ''; |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - parent::single_row( $item ); |
|
108 | + parent::single_row($item); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function _get_table_filters() { |
117 | 117 | $filters = array(); |
118 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
118 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
119 | 119 | //setup messengers for selects |
120 | 120 | $m_values = $this->get_admin_page()->get_messengers_for_list_table(); |
121 | 121 | //lets do the same for message types |
122 | 122 | $mt_values = $this->get_admin_page()->get_message_types_for_list_table(); |
123 | 123 | //setup messengers for selects |
124 | 124 | $m_values[0]['id'] = 'all'; |
125 | - $m_values[0]['text'] = __('All Messengers', 'event_espresso' ); |
|
125 | + $m_values[0]['text'] = __('All Messengers', 'event_espresso'); |
|
126 | 126 | |
127 | 127 | $msgr_default[0] = array( |
128 | 128 | 'id' => 'none_selected', |
@@ -134,28 +134,28 @@ discard block |
||
134 | 134 | 'text' => __('Show All', 'event_espresso') |
135 | 135 | ); |
136 | 136 | |
137 | - $msgr_filters = !empty($m_values) ? array_merge( $msgr_default, $m_values ) : array(); |
|
138 | - $mt_filters = !empty($mt_values) ? array_merge( $mt_default, $mt_values ) : array(); |
|
137 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
138 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
139 | 139 | |
140 | - if ( empty( $m_values ) ) |
|
140 | + if (empty($m_values)) |
|
141 | 141 | $msgr_filters[0] = array( |
142 | 142 | 'id' => 'no_messenger_options', |
143 | 143 | 'text' => __('No Messengers active', 'event_espresso') |
144 | 144 | ); |
145 | 145 | |
146 | - if ( empty($mt_values) ) |
|
146 | + if (empty($mt_values)) |
|
147 | 147 | $mt_filters[0] = array( |
148 | 148 | 'id' => 'no_message_type_options', |
149 | 149 | 'text' => __('No Message Types active', 'event_espresso') |
150 | 150 | ); |
151 | 151 | |
152 | - if ( count( $m_values ) >= 1 && !empty( $m_values ) ) { |
|
153 | - unset( $msgr_filters[0] ); |
|
154 | - $msgr_filters = array_values( $msgr_filters ); //reindex keys |
|
152 | + if (count($m_values) >= 1 && ! empty($m_values)) { |
|
153 | + unset($msgr_filters[0]); |
|
154 | + $msgr_filters = array_values($msgr_filters); //reindex keys |
|
155 | 155 | } |
156 | 156 | |
157 | - $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key( $this->_req_data['ee_messenger_filter_by']) : '' ); |
|
158 | - $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key( $this->_req_data['ee_message_type_filter_by']) : ''); |
|
157 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key($this->_req_data['ee_messenger_filter_by']) : ''); |
|
158 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key($this->_req_data['ee_message_type_filter_by']) : ''); |
|
159 | 159 | return $filters; |
160 | 160 | } |
161 | 161 | |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | * we're just removing the search box for message templates, not needed. |
164 | 164 | * @return string (empty); |
165 | 165 | */ |
166 | - function search_box( $text, $input_id ) { |
|
166 | + function search_box($text, $input_id) { |
|
167 | 167 | return ''; |
168 | 168 | } |
169 | 169 | |
170 | 170 | |
171 | 171 | protected function _add_view_counts() { |
172 | - foreach ( $this->_views as $view => $args ) { |
|
173 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE, FALSE ); |
|
172 | + foreach ($this->_views as $view => $args) { |
|
173 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE, FALSE); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -184,16 +184,16 @@ discard block |
||
184 | 184 | * @return string |
185 | 185 | */ |
186 | 186 | public function no_items() { |
187 | - if ( $this->_view !== 'trashed' ) |
|
188 | - printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' ); |
|
187 | + if ($this->_view !== 'trashed') |
|
188 | + printf(__('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>'); |
|
189 | 189 | else |
190 | 190 | parent::no_items(); |
191 | 191 | } |
192 | 192 | |
193 | 193 | |
194 | 194 | |
195 | - public function column_cb( $item ) { |
|
196 | - return sprintf( '<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID() ); |
|
195 | + public function column_cb($item) { |
|
196 | + return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID()); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -201,29 +201,29 @@ discard block |
||
201 | 201 | |
202 | 202 | |
203 | 203 | |
204 | - function column_name( $item ) { |
|
205 | - return '<p>' . $item->name() . '</p>'; |
|
204 | + function column_name($item) { |
|
205 | + return '<p>'.$item->name().'</p>'; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | 210 | |
211 | - function column_description( $item ) { |
|
212 | - return '<p>' . $item->description() . '</p>'; |
|
211 | + function column_description($item) { |
|
212 | + return '<p>'.$item->description().'</p>'; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
216 | 216 | |
217 | - function column_actions( $item ) { |
|
218 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ) { |
|
217 | + function column_actions($item) { |
|
218 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template')) { |
|
219 | 219 | $create_args = array( |
220 | 220 | 'GRP_ID' => $item->ID(), |
221 | 221 | 'messenger' => $item->messenger(), |
222 | 222 | 'message_type' => $item->message_type(), |
223 | 223 | 'action' => 'add_new_message_template' |
224 | 224 | ); |
225 | - $create_link = EE_Admin_Page::add_query_args_and_nonce( $create_args, EE_MSG_ADMIN_URL ); |
|
226 | - return sprintf( '<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso') ); |
|
225 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
226 | + return sprintf('<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso')); |
|
227 | 227 | } |
228 | 228 | return ''; |
229 | 229 | } |
@@ -240,27 +240,27 @@ discard block |
||
240 | 240 | $actions = array(); |
241 | 241 | |
242 | 242 | // edit link but only if item isn't trashed. |
243 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) { |
|
244 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL ); |
|
245 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
243 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) { |
|
244 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL); |
|
245 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
246 | 246 | } |
247 | 247 | |
248 | - $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() )? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] ); |
|
249 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
248 | + $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']); |
|
249 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
250 | 250 | // restore link |
251 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
251 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
252 | 252 | // delete price link |
253 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
253 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
254 | 254 | |
255 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_trash_message_template', $item->ID() ) ) { |
|
256 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Template Group to Trash', 'event_espresso' ) . '">' . __( 'Move to Trash', 'event_espresso' ) . '</a>'; |
|
255 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_trash_message_template', $item->ID())) { |
|
256 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Template Group to Trash', 'event_espresso').'">'.__('Move to Trash', 'event_espresso').'</a>'; |
|
257 | 257 | } else { |
258 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_restore_message_template', $item->ID() ) ) { |
|
259 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Message Template', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
258 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_restore_message_template', $item->ID())) { |
|
259 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Message Template', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
260 | 260 | } |
261 | 261 | |
262 | - if ( $this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_delete_message_template', $item->ID() ) ) { |
|
263 | - $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Template Group Permanently', 'event_espresso' ) . '">' . __( 'Delete Permanently', 'event_espresso' ) . '</a>'; |
|
262 | + if ($this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_delete_message_template', $item->ID())) { |
|
263 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Template Group Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>'; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
@@ -269,15 +269,15 @@ discard block |
||
269 | 269 | $c_configs = $item->contexts_config(); |
270 | 270 | $ctxt = array(); |
271 | 271 | $context_templates = $item->context_templates(); |
272 | - foreach ( $context_templates as $context => $template_fields ) { |
|
273 | - $mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
274 | - $inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : ''; |
|
272 | + foreach ($context_templates as $context => $template_fields) { |
|
273 | + $mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
274 | + $inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : ''; |
|
275 | 275 | $context_title = ucwords($c_configs[$context]['label']); |
276 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL ); |
|
277 | - $ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title; |
|
276 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL); |
|
277 | + $ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title; |
|
278 | 278 | } |
279 | 279 | |
280 | - $ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : ''; |
|
280 | + $ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : ''; |
|
281 | 281 | |
282 | 282 | |
283 | 283 | //Return the name contents |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | /* $1%s */ $name_link, |
286 | 286 | /* $2%s */ $item->GRP_ID(), |
287 | 287 | /* %4$s */ $ctx_content, |
288 | - /* $3%s */ $this->row_actions( $actions ) |
|
288 | + /* $3%s */ $this->row_actions($actions) |
|
289 | 289 | ); |
290 | 290 | } |
291 | 291 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @return string message_type name |
307 | 307 | */ |
308 | 308 | function column_message_type($item) { |
309 | - return ucwords($item->message_type_obj()->label['singular'] ); |
|
309 | + return ucwords($item->message_type_obj()->label['singular']); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @deprecated 4.9.0 |
203 | 203 | * @param string $message_type message type name |
204 | - * @param $messenger |
|
204 | + * @param string $messenger |
|
205 | 205 | * @return bool true if it got activated (or was active) and false if not. |
206 | 206 | * @throws \EE_Error |
207 | 207 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * @param string $context This should correspond with a valid context for the message type |
613 | 613 | * @param string $messenger This should correspond with a valid messenger. |
614 | 614 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
615 | - * @return string The body of the message. |
|
615 | + * @return boolean The body of the message. |
|
616 | 616 | */ |
617 | 617 | public function preview_message( $type, $context, $messenger, $send = FALSE ) { |
618 | 618 | return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | * >>>>>>>>>>>> 1 usage in \EE_Messages::get_installed() |
1143 | 1143 | * |
1144 | 1144 | * @deprecated 4.9.0 |
1145 | - * @return array |
|
1145 | + * @return EE_Messenger[] |
|
1146 | 1146 | */ |
1147 | 1147 | public function get_installed_messengers() { |
1148 | 1148 | return $this->_message_resource_manager->installed_messengers(); |
@@ -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 | /** |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | // not yet |
121 | 121 | EE_Error::doing_it_wrong( |
122 | 122 | 'EE_messages::__construct', |
123 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
123 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
124 | 124 | '4.9.0' |
125 | 125 | ); |
126 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
126 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
127 | 127 | // get list of active messengers and active message types |
128 | 128 | //$this->_set_active_messengers_and_message_types(); |
129 | 129 | } |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @param string $messenger_name |
179 | 179 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
180 | 180 | */ |
181 | - public function ensure_messenger_is_active( $messenger_name ){ |
|
182 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
181 | + public function ensure_messenger_is_active($messenger_name) { |
|
182 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
183 | 183 | //note: active messengers indexed by their names |
184 | 184 | //$active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
185 | 185 | //if( ! isset( $active_messengers[ $messenger_name ] ) ) { |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @return bool true if it got activated (or was active) and false if not. |
206 | 206 | * @throws \EE_Error |
207 | 207 | */ |
208 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
209 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
208 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
209 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
210 | 210 | //first validate that the incoming messenger allows this message type to be activated. |
211 | 211 | //$messengers = $this->get_installed_messengers(); |
212 | 212 | //if ( ! isset( $messengers[$messenger] ) ) { |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * they are already setup.) |
243 | 243 | * @return boolean an array of generated templates or false if nothing generated/activated. |
244 | 244 | */ |
245 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ){ |
|
246 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
245 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
246 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
247 | 247 | //$active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
248 | 248 | //$message_types = $this->get_installed_message_types(); |
249 | 249 | //$installed_messengers = $this->get_installed_messengers(); |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
407 | 407 | */ |
408 | - public function is_generating_messenger_and_active( EE_Messenger $messenger, EE_message_type $message_type ) { |
|
409 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
408 | + public function is_generating_messenger_and_active(EE_Messenger $messenger, EE_message_type $message_type) { |
|
409 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
410 | 410 | //get the $messengers the message type says it can be used with. |
411 | 411 | //$used_with = $message_type->with_messengers(); |
412 | 412 | //foreach ( $used_with as $generating_msgr => $secondary_msgrs ) { |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | * @param string $messenger |
434 | 434 | * @return EE_Messenger | null |
435 | 435 | */ |
436 | - public function get_messenger_if_active( $messenger ) { |
|
437 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
436 | + public function get_messenger_if_active($messenger) { |
|
437 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
438 | 438 | //return ! empty( $this->_active_messengers[$messenger] ) ? $this->_active_messengers[$messenger] : null; |
439 | 439 | } |
440 | 440 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * 'message_type' => null |
463 | 463 | * ) |
464 | 464 | */ |
465 | - public function validate_for_use( EE_Message $message ) { |
|
465 | + public function validate_for_use(EE_Message $message) { |
|
466 | 466 | return array( |
467 | 467 | 'messenger' => $message->messenger_object(), |
468 | 468 | 'message_type' => $message->message_type_object(), |
@@ -490,35 +490,35 @@ discard block |
||
490 | 490 | * @param bool $send Default TRUE. If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it). |
491 | 491 | * @return bool |
492 | 492 | */ |
493 | - public function send_message( $type, $vars, $sending_messenger = '', $generating_messenger='', $context='', $send = TRUE ) { |
|
494 | - $processor = new EE_Messages_Processor( $this ); |
|
493 | + public function send_message($type, $vars, $sending_messenger = '', $generating_messenger = '', $context = '', $send = TRUE) { |
|
494 | + $processor = new EE_Messages_Processor($this); |
|
495 | 495 | $error = FALSE; |
496 | 496 | |
497 | 497 | //try to intelligently determine what method we'll call based on the incoming data. |
498 | 498 | //if generating and sending are different then generate and send immediately. |
499 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
499 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
500 | 500 | //in the legacy system, when generating and sending were different, that means all the |
501 | 501 | //vars are already in the request object. So let's just use that. |
502 | 502 | try { |
503 | - $mtg = new EE_Message_To_Generate_From_Request( $this, EE_Registry::instance()->REQ ); |
|
504 | - $processor->generate_and_send_now( $mtg ); |
|
505 | - } catch ( EE_Error $e ) { |
|
506 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
503 | + $mtg = new EE_Message_To_Generate_From_Request($this, EE_Registry::instance()->REQ); |
|
504 | + $processor->generate_and_send_now($mtg); |
|
505 | + } catch (EE_Error $e) { |
|
506 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
507 | 507 | // add specific message for developers if WP_DEBUG in on |
508 | - $error_msg .= '||' . $e->getMessage(); |
|
509 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
508 | + $error_msg .= '||'.$e->getMessage(); |
|
509 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
510 | 510 | $error = true; |
511 | 511 | } |
512 | 512 | } else { |
513 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
513 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
514 | 514 | //let's find out if there were any errors and how many successfully were queued. |
515 | - $count_errors = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_failed ); |
|
516 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
517 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
515 | + $count_errors = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_failed); |
|
516 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
517 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
518 | 518 | $count_errors = $count_errors + $count_retry; |
519 | - if ( $count_errors > 0 ) { |
|
519 | + if ($count_errors > 0) { |
|
520 | 520 | $error = true; |
521 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
521 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
522 | 522 | $message = sprintf( |
523 | 523 | __( |
524 | 524 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | $count_errors, |
528 | 528 | $count_queued |
529 | 529 | ); |
530 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
530 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
531 | 531 | $message = sprintf( |
532 | 532 | __( |
533 | 533 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | $count_errors, |
537 | 537 | $count_queued |
538 | 538 | ); |
539 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
539 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
540 | 540 | $message = sprintf( |
541 | 541 | __( |
542 | 542 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -554,9 +554,9 @@ discard block |
||
554 | 554 | $count_errors |
555 | 555 | ); |
556 | 556 | } |
557 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
557 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
558 | 558 | } else { |
559 | - if ( $count_queued === 1 ) { |
|
559 | + if ($count_queued === 1) { |
|
560 | 560 | $message = sprintf( |
561 | 561 | __( |
562 | 562 | '%d message successfully queued for generation.', |
@@ -573,18 +573,18 @@ discard block |
||
573 | 573 | $count_queued |
574 | 574 | ); |
575 | 575 | } |
576 | - EE_Error::add_success( $message ); |
|
576 | + EE_Error::add_success($message); |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | //if no error then return the generated message(s). |
580 | - if ( ! $error && ! $send ) { |
|
581 | - $generated_queue = $processor->generate_queue( false ); |
|
580 | + if ( ! $error && ! $send) { |
|
581 | + $generated_queue = $processor->generate_queue(false); |
|
582 | 582 | //get message and return. |
583 | 583 | $generated_queue->get_queue()->rewind(); |
584 | 584 | $messages = array(); |
585 | - while( $generated_queue->get_queue()->valid() ) { |
|
585 | + while ($generated_queue->get_queue()->valid()) { |
|
586 | 586 | $message = $generated_queue->get_queue()->current(); |
587 | - if ( $message instanceof EE_Message ) { |
|
587 | + if ($message instanceof EE_Message) { |
|
588 | 588 | //set properties that might be expected by add-ons (backward compat) |
589 | 589 | $message->content = $message->content(); |
590 | 590 | $message->template_pack = $message->get_template_pack(); |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
615 | 615 | * @return string The body of the message. |
616 | 616 | */ |
617 | - public function preview_message( $type, $context, $messenger, $send = FALSE ) { |
|
618 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
617 | + public function preview_message($type, $context, $messenger, $send = FALSE) { |
|
618 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -632,11 +632,11 @@ discard block |
||
632 | 632 | * |
633 | 633 | * @return bool success or fail. |
634 | 634 | */ |
635 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
635 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
636 | 636 | //setup for sending to new method. |
637 | - $queue = new EE_Messages_Queue( $this ); |
|
637 | + $queue = new EE_Messages_Queue($this); |
|
638 | 638 | //make sure we have a proper message object |
639 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
639 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
640 | 640 | $msg = EE_Message_Factory::create( |
641 | 641 | array( |
642 | 642 | 'MSG_messenger' => $messenger, |
@@ -649,15 +649,15 @@ discard block |
||
649 | 649 | $msg = $message; |
650 | 650 | } |
651 | 651 | |
652 | - if ( ! $msg instanceof EE_Message ) { |
|
652 | + if ( ! $msg instanceof EE_Message) { |
|
653 | 653 | return false; |
654 | 654 | } |
655 | 655 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
656 | - if ( ! empty( $msg->content ) ) { |
|
657 | - $msg->set( 'MSG_content', $msg->content ); |
|
656 | + if ( ! empty($msg->content)) { |
|
657 | + $msg->set('MSG_content', $msg->content); |
|
658 | 658 | } |
659 | - $queue->add( $msg ); |
|
660 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
659 | + $queue->add($msg); |
|
660 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | |
@@ -745,9 +745,9 @@ discard block |
||
745 | 745 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
746 | 746 | * @throws \EE_Error |
747 | 747 | */ |
748 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
749 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
750 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
748 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
749 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
750 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
751 | 751 | //$valid_mt = $this->_validate_setup($messenger, $message_type, $is_global); |
752 | 752 | // |
753 | 753 | //if ( is_wp_error($valid_mt) && $is_global ) { |
@@ -868,9 +868,9 @@ discard block |
||
868 | 868 | * @param string $message_type_name name of EE_message_type |
869 | 869 | * @return array |
870 | 870 | */ |
871 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
872 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
873 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
871 | + public function get_fields($messenger_name, $message_type_name) { |
|
872 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
873 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
874 | 874 | //$template_fields = array(); |
875 | 875 | ///** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
876 | 876 | //$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
@@ -914,11 +914,11 @@ discard block |
||
914 | 914 | * @return array multidimensional array of messenger and message_type objects |
915 | 915 | * (messengers index, and message_type index); |
916 | 916 | */ |
917 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
918 | - if ( $skip_cache ) { |
|
917 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
918 | + if ($skip_cache) { |
|
919 | 919 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
920 | 920 | } |
921 | - switch ( $type ) { |
|
921 | + switch ($type) { |
|
922 | 922 | |
923 | 923 | case 'messengers' : |
924 | 924 | return array( |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | * @param string $messenger The messenger being checked |
1069 | 1069 | * @return EE_message_type[] (or empty array if none present) |
1070 | 1070 | */ |
1071 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
1072 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
1071 | + public function get_active_message_types_per_messenger($messenger) { |
|
1072 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1073 | 1073 | //$messenger = (string) $messenger; |
1074 | 1074 | //if ( empty( $this->_active_message_types[$messenger] ) ) { |
1075 | 1075 | // return array(); |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param string $message_type The string should correspond to a message type. |
1099 | 1099 | * @return EE_Message_Type|null |
1100 | 1100 | */ |
1101 | - public function get_active_message_type( $messenger, $message_type ) { |
|
1102 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
1101 | + public function get_active_message_type($messenger, $message_type) { |
|
1102 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1103 | 1103 | //$installed_message_types = $this->get_installed_message_types(); |
1104 | 1104 | //if ( !empty( $this->_active_message_types[$messenger][$message_type] ) && !empty( $installed_message_types[$message_type] ) ) { |
1105 | 1105 | // return $installed_message_types[$message_type]; |
@@ -1183,8 +1183,8 @@ discard block |
||
1183 | 1183 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
1184 | 1184 | * @return array |
1185 | 1185 | */ |
1186 | - public function get_all_contexts( $slugs_only = true ) { |
|
1187 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
1186 | + public function get_all_contexts($slugs_only = true) { |
|
1187 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1188 | 1188 | //$key = $slugs_only ? 'slugs' : 'all'; |
1189 | 1189 | //if ( ! empty( $this->_contexts[$key] ) ) { |
1190 | 1190 | // return $this->_contexts[$key]; |
@@ -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 | /** |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | |
28 | 28 | protected function _setup_data() { |
29 | - $this->_data = $this->_get_messages( $this->_per_page, $this->_view ); |
|
30 | - $this->_all_data_count = $this->_get_messages( $this->_per_page, $this->_view, true ); |
|
29 | + $this->_data = $this->_get_messages($this->_per_page, $this->_view); |
|
30 | + $this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | protected function _set_properties() { |
37 | 37 | $this->_wp_list_args = array( |
38 | - 'singular' => __( 'Message', 'event_espresso' ), |
|
39 | - 'plural' => __( 'Messages', 'event_espresso' ), |
|
38 | + 'singular' => __('Message', 'event_espresso'), |
|
39 | + 'plural' => __('Messages', 'event_espresso'), |
|
40 | 40 | 'ajax' => true, |
41 | 41 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
42 | 42 | ); |
@@ -44,24 +44,24 @@ discard block |
||
44 | 44 | $this->_columns = array( |
45 | 45 | 'msg_status' => '', |
46 | 46 | 'cb' => '<input type="checkbox" />', |
47 | - 'msg_id' => __( 'ID', 'event_espresso' ), |
|
48 | - 'to' => __( 'To', 'event_espresso' ), |
|
49 | - 'from' => __( 'From', 'event_espresso' ), |
|
50 | - 'messenger' => __( 'Messenger', 'event_espresso' ), |
|
51 | - 'message_type' => __( 'Message Type', 'event_espresso' ), |
|
52 | - 'context' => __( 'Context', 'event_espresso' ), |
|
53 | - 'modified' => __( 'Modified', 'event_espresso' ), |
|
54 | - 'action' => __( 'Actions', 'event_espresso' ) |
|
47 | + 'msg_id' => __('ID', 'event_espresso'), |
|
48 | + 'to' => __('To', 'event_espresso'), |
|
49 | + 'from' => __('From', 'event_espresso'), |
|
50 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
51 | + 'message_type' => __('Message Type', 'event_espresso'), |
|
52 | + 'context' => __('Context', 'event_espresso'), |
|
53 | + 'modified' => __('Modified', 'event_espresso'), |
|
54 | + 'action' => __('Actions', 'event_espresso') |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | $this->_sortable_columns = array( |
58 | - 'modified' => array( 'MSG_modified' => true ), |
|
59 | - 'msg_id' => array( 'MSG_ID', false ), |
|
60 | - 'message_type' => array( 'MSG_message_type' => false ), |
|
61 | - 'messenger' => array( 'MSG_messenger' => false ), |
|
62 | - 'to' => array( 'MSG_to' => false ), |
|
63 | - 'from' => array( 'MSG_from' => false ), |
|
64 | - 'context' => array( 'MSG_context' => false ) |
|
58 | + 'modified' => array('MSG_modified' => true), |
|
59 | + 'msg_id' => array('MSG_ID', false), |
|
60 | + 'message_type' => array('MSG_message_type' => false), |
|
61 | + 'messenger' => array('MSG_messenger' => false), |
|
62 | + 'to' => array('MSG_to' => false), |
|
63 | + 'from' => array('MSG_from' => false), |
|
64 | + 'context' => array('MSG_context' => false) |
|
65 | 65 | ); |
66 | 66 | |
67 | 67 | $this->_hidden_columns = array( |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | |
74 | 74 | protected function _get_table_filters() { |
75 | 75 | $filters = array(); |
76 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
76 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
77 | 77 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
78 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
78 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
79 | 79 | $contexts = $message_resource_manager->get_all_contexts(); |
80 | 80 | //setup messengers for selects |
81 | 81 | $m_values = $this->get_admin_page()->get_messengers_for_list_table(); |
@@ -84,70 +84,70 @@ discard block |
||
84 | 84 | //and the same for contexts |
85 | 85 | $i = 1; |
86 | 86 | $labels = $c_values = array(); |
87 | - foreach ( $contexts as $context => $label ) { |
|
87 | + foreach ($contexts as $context => $label) { |
|
88 | 88 | //some message types may have the same label for a different context, so we're grouping these together so the end user |
89 | 89 | //doesn't get confused. |
90 | - if ( isset( $labels[ $label ] ) ) { |
|
91 | - $c_values[ $labels[ $label ] ]['id'] .= ',' . $context; |
|
90 | + if (isset($labels[$label])) { |
|
91 | + $c_values[$labels[$label]]['id'] .= ','.$context; |
|
92 | 92 | continue; |
93 | 93 | } |
94 | - $c_values[ $i ]['id'] = $context; |
|
95 | - $c_values[ $i ]['text'] = $label; |
|
96 | - $labels[ $label ] = $i; |
|
94 | + $c_values[$i]['id'] = $context; |
|
95 | + $c_values[$i]['text'] = $label; |
|
96 | + $labels[$label] = $i; |
|
97 | 97 | $i++; |
98 | 98 | } |
99 | 99 | |
100 | 100 | $msgr_default[0] = array( |
101 | 101 | 'id' => 'none_selected', |
102 | - 'text' => __( 'All Messengers', 'event_espresso' ) |
|
102 | + 'text' => __('All Messengers', 'event_espresso') |
|
103 | 103 | ); |
104 | 104 | |
105 | 105 | $mt_default[0] = array( |
106 | 106 | 'id' => 'none_selected', |
107 | - 'text' => __( 'All Message Types', 'event_espresso' ) |
|
107 | + 'text' => __('All Message Types', 'event_espresso') |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | $c_default[0] = array( |
111 | 111 | 'id' => 'none_selected', |
112 | - 'text' => __( 'All Contexts', 'event_espresso ' ) |
|
112 | + 'text' => __('All Contexts', 'event_espresso ') |
|
113 | 113 | ); |
114 | 114 | |
115 | - $msgr_filters = ! empty( $m_values ) ? array_merge( $msgr_default, $m_values ) : array(); |
|
116 | - $mt_filters = ! empty( $mt_values ) ? array_merge( $mt_default, $mt_values ) : array(); |
|
117 | - $c_filters = ! empty( $c_values ) ? array_merge( $c_default, $c_values ): array(); |
|
115 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
116 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
117 | + $c_filters = ! empty($c_values) ? array_merge($c_default, $c_values) : array(); |
|
118 | 118 | |
119 | - if ( empty( $m_values ) ) { |
|
119 | + if (empty($m_values)) { |
|
120 | 120 | $msgr_filters[0] = array( |
121 | 121 | 'id' => 'none_selected', |
122 | - 'text' => __( 'No Messengers active', 'event_espresso' ) |
|
122 | + 'text' => __('No Messengers active', 'event_espresso') |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
126 | - if ( empty( $mt_values ) ) { |
|
126 | + if (empty($mt_values)) { |
|
127 | 127 | $mt_filters[0] = array( |
128 | 128 | 'id' => 'none_selected', |
129 | - 'text' => __( 'No Message Types active', 'event_espresso' ) |
|
129 | + 'text' => __('No Message Types active', 'event_espresso') |
|
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - if ( empty( $c_values ) ) { |
|
133 | + if (empty($c_values)) { |
|
134 | 134 | $c_filters[0] = array( |
135 | 135 | 'id' => 'none_selected', |
136 | - 'text' => __( 'No Contexts (because no message types active)', 'event_espresso' ) |
|
136 | + 'text' => __('No Contexts (because no message types active)', 'event_espresso') |
|
137 | 137 | ); |
138 | 138 | } |
139 | 139 | |
140 | - $filters[] = EEH_Form_Fields::select_input( 'ee_messenger_filter_by', $msgr_filters, isset( $this->_req_data['ee_messenger_filter_by'] ) ? sanitize_title( $this->_req_data['ee_messenger_filter_by'] ) : '' ); |
|
141 | - $filters[] = EEH_Form_Fields::select_input( 'ee_message_type_filter_by', $mt_filters, isset( $this->_req_data['ee_message_type_filter_by'] ) ? sanitize_title( $this->_req_data['ee_message_type_filter_by'] ) : '' ); |
|
142 | - $filters[] = EEH_Form_Fields::select_input( 'ee_context_filter_by', $c_filters, isset( $this->_req_data['ee_context_filter_by'] ) ? sanitize_text_field( $this->_req_data['ee_context_filter_by'] ) : '' ); |
|
140 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_title($this->_req_data['ee_messenger_filter_by']) : ''); |
|
141 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_title($this->_req_data['ee_message_type_filter_by']) : ''); |
|
142 | + $filters[] = EEH_Form_Fields::select_input('ee_context_filter_by', $c_filters, isset($this->_req_data['ee_context_filter_by']) ? sanitize_text_field($this->_req_data['ee_context_filter_by']) : ''); |
|
143 | 143 | return $filters; |
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | 147 | |
148 | 148 | protected function _add_view_counts() { |
149 | - foreach ( $this->_views as $view => $args ) { |
|
150 | - $this->_views[ $view ]['count'] = $this->_get_messages( $this->_per_page, $view, true, true ); |
|
149 | + foreach ($this->_views as $view => $args) { |
|
150 | + $this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return string EE_Message status. |
159 | 159 | */ |
160 | - public function column_msg_status( $message ) { |
|
161 | - return '<span class="ee-status-strip ee-status-strip-td msg-status-' . $message->STS_ID() . '"></span>'; |
|
160 | + public function column_msg_status($message) { |
|
161 | + return '<span class="ee-status-strip ee-status-strip-td msg-status-'.$message->STS_ID().'"></span>'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return string checkbox |
169 | 169 | */ |
170 | - public function column_cb( $message ) { |
|
171 | - return sprintf( '<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID() ); |
|
170 | + public function column_cb($message) { |
|
171 | + return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID()); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
175 | 175 | |
176 | 176 | |
177 | - public function column_msg_id( $message ) { |
|
177 | + public function column_msg_id($message) { |
|
178 | 178 | return $message->ID(); |
179 | 179 | } |
180 | 180 | |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @param EE_Message $message |
185 | 185 | * @return string The recipient of the message |
186 | 186 | */ |
187 | - public function column_to( $message ) { |
|
188 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
187 | + public function column_to($message) { |
|
188 | + EE_Registry::instance()->load_helper('URL'); |
|
189 | 189 | $actions = array(); |
190 | - if ( $recipient_object = $message->recipient_object() ) { |
|
190 | + if ($recipient_object = $message->recipient_object()) { |
|
191 | 191 | $view_details_link = $recipient_object instanceof EEI_Admin_Links ? $recipient_object->get_admin_details_link() : ''; |
192 | - if ( ! empty( $view_details_link ) ) { |
|
193 | - $actions['view'] = '<a href="' . $view_details_link . '">' . __( 'View Recipient Details', 'event_espresso' ) . '</a>'; |
|
192 | + if ( ! empty($view_details_link)) { |
|
193 | + $actions['view'] = '<a href="'.$view_details_link.'">'.__('View Recipient Details', 'event_espresso').'</a>'; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | 'action' => 'delete_ee_message', |
202 | 202 | 'MSG_ID' => $message->ID() |
203 | 203 | ), |
204 | - admin_url( 'admin.php' ) |
|
204 | + admin_url('admin.php') |
|
205 | 205 | ) |
206 | - . '">' . __( 'Delete', 'event_espresso' ) . '</a>'; |
|
207 | - return $message->to() . $this->row_actions( $actions ); |
|
206 | + . '">'.__('Delete', 'event_espresso').'</a>'; |
|
207 | + return $message->to().$this->row_actions($actions); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param EE_Message $message |
213 | 213 | * @return string The sender of the message |
214 | 214 | */ |
215 | - public function column_from( $message ) { |
|
215 | + public function column_from($message) { |
|
216 | 216 | return $message->from(); |
217 | 217 | } |
218 | 218 | |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * @param EE_Message $message |
223 | 223 | * @return string The messenger used to send the message. |
224 | 224 | */ |
225 | - public function column_messenger( $message ) { |
|
226 | - return ucwords( $message->messenger_label() ); |
|
225 | + public function column_messenger($message) { |
|
226 | + return ucwords($message->messenger_label()); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param EE_Message $message |
232 | 232 | * @return string The message type used to generate the message. |
233 | 233 | */ |
234 | - public function column_message_type( $message ) { |
|
235 | - return ucwords( $message->message_type_label() ); |
|
234 | + public function column_message_type($message) { |
|
235 | + return ucwords($message->message_type_label()); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param EE_Message $message |
241 | 241 | * @return string The context the message was generated for. |
242 | 242 | */ |
243 | - public function column_context( $message ) { |
|
243 | + public function column_context($message) { |
|
244 | 244 | return $message->context_label(); |
245 | 245 | } |
246 | 246 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param EE_Message $message |
250 | 250 | * @return string The timestamp when this message was last modified. |
251 | 251 | */ |
252 | - public function column_modified( $message ) { |
|
252 | + public function column_modified($message) { |
|
253 | 253 | return $message->modified(); |
254 | 254 | } |
255 | 255 | |
@@ -258,35 +258,35 @@ discard block |
||
258 | 258 | * @param EE_Message $message |
259 | 259 | * @return string Actions that can be done on the current message. |
260 | 260 | */ |
261 | - public function column_action( $message ) { |
|
262 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
261 | + public function column_action($message) { |
|
262 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
263 | 263 | $action_links = array( |
264 | - 'view' => EEH_MSG_Template::get_message_action_link( 'view', $message ), |
|
265 | - 'error' => EEH_MSG_Template::get_message_action_link( 'error', $message ), |
|
266 | - 'generate_now' => EEH_MSG_Template::get_message_action_link( 'generate_now', $message ), |
|
267 | - 'send_now' => EEH_MSG_Template::get_message_action_link( 'send_now', $message ), |
|
268 | - 'queue_for_resending' => EEH_MSG_Template::get_message_action_link( 'queue_for_resending', $message ), |
|
269 | - 'view_transaction' => EEH_MSG_Template::get_message_action_link( 'view_transaction', $message ), |
|
264 | + 'view' => EEH_MSG_Template::get_message_action_link('view', $message), |
|
265 | + 'error' => EEH_MSG_Template::get_message_action_link('error', $message), |
|
266 | + 'generate_now' => EEH_MSG_Template::get_message_action_link('generate_now', $message), |
|
267 | + 'send_now' => EEH_MSG_Template::get_message_action_link('send_now', $message), |
|
268 | + 'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message), |
|
269 | + 'view_transaction' => EEH_MSG_Template::get_message_action_link('view_transaction', $message), |
|
270 | 270 | ); |
271 | 271 | $content = ''; |
272 | - switch ( $message->STS_ID() ) { |
|
272 | + switch ($message->STS_ID()) { |
|
273 | 273 | case EEM_Message::status_sent : |
274 | - $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction']; |
|
274 | + $content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction']; |
|
275 | 275 | break; |
276 | 276 | case EEM_Message::status_resend : |
277 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
277 | + $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction']; |
|
278 | 278 | break; |
279 | 279 | case EEM_Message::status_retry : |
280 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction']; |
|
280 | + $content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction']; |
|
281 | 281 | break; |
282 | 282 | case EEM_Message::status_failed : |
283 | - $content = $action_links['error'] . $action_links['view_transaction']; |
|
283 | + $content = $action_links['error'].$action_links['view_transaction']; |
|
284 | 284 | break; |
285 | 285 | case EEM_Message::status_idle : |
286 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
286 | + $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction']; |
|
287 | 287 | break; |
288 | 288 | case EEM_Message::status_incomplete; |
289 | - $content = $action_links['generate_now'] . $action_links['view_transaction']; |
|
289 | + $content = $action_links['generate_now'].$action_links['view_transaction']; |
|
290 | 290 | break; |
291 | 291 | } |
292 | 292 | return $content; |
@@ -301,51 +301,51 @@ discard block |
||
301 | 301 | * @param bool $all Disregard any paging info (no limit on data returned). |
302 | 302 | * @return int | EE_Message[] |
303 | 303 | */ |
304 | - protected function _get_messages( $perpage = 10, $view = 'all', $count = false, $all = false ) { |
|
305 | - $current_page = isset( $this->_req_data['paged'] ) && ! empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
306 | - $per_page = isset( $this->_req_data['perpage'] ) && ! empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
307 | - $offset = ( $current_page - 1 ) * $per_page; |
|
308 | - $limit = $all || $count ? null : array( $offset, $per_page ); |
|
304 | + protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false) { |
|
305 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
306 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
307 | + $offset = ($current_page - 1) * $per_page; |
|
308 | + $limit = $all || $count ? null : array($offset, $per_page); |
|
309 | 309 | |
310 | 310 | $query_params = array( |
311 | - 'order_by' => empty( $this->_req_data['orderby'] ) ? 'MSG_modified' : $this->_req_data['orderby'], |
|
312 | - 'order' => empty( $this->_req_data['order'] ) ? 'DESC' : $this->_req_data['order'], |
|
311 | + 'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'], |
|
312 | + 'order' => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'], |
|
313 | 313 | 'limit' => $limit, |
314 | 314 | ); |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Any filters coming in from other routes? |
318 | 318 | */ |
319 | - if ( ! $all && isset( $this->_req_data['filterby'] ) ) { |
|
320 | - $query_params = array_merge( $query_params, EEM_Message::instance()->filter_by_query_params() ); |
|
319 | + if ( ! $all && isset($this->_req_data['filterby'])) { |
|
320 | + $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params()); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | //view conditionals |
324 | - if ( $view !== 'all' && $count && $all ) { |
|
324 | + if ($view !== 'all' && $count && $all) { |
|
325 | 325 | $query_params[0]['AND*view_conditional'] = array( |
326 | - 'STS_ID' => strtoupper( $view ), |
|
326 | + 'STS_ID' => strtoupper($view), |
|
327 | 327 | ); |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! empty( $this->_req_data['status'] ) && ! $all && $this->_req_data['status'] !== 'all' ) { |
|
330 | + if ( ! empty($this->_req_data['status']) && ! $all && $this->_req_data['status'] !== 'all') { |
|
331 | 331 | $query_params[0]['AND*view_conditional'] = array( |
332 | - 'STS_ID' => strtoupper( $this->_req_data['status'] ), |
|
332 | + 'STS_ID' => strtoupper($this->_req_data['status']), |
|
333 | 333 | ); |
334 | 334 | } |
335 | 335 | |
336 | - if ( ! $all && ! empty( $this->_req_data['s'] ) ) { |
|
337 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
336 | + if ( ! $all && ! empty($this->_req_data['s'])) { |
|
337 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
338 | 338 | $query_params[0]['OR'] = array( |
339 | - 'MSG_to' => array( 'LIKE', $search_string ), |
|
340 | - 'MSG_from' => array( 'LIKE', $search_string ), |
|
341 | - 'MSG_subject' => array( 'LIKE', $search_string ), |
|
342 | - 'MSG_content' => array( 'LIKE', $search_string ), |
|
339 | + 'MSG_to' => array('LIKE', $search_string), |
|
340 | + 'MSG_from' => array('LIKE', $search_string), |
|
341 | + 'MSG_subject' => array('LIKE', $search_string), |
|
342 | + 'MSG_content' => array('LIKE', $search_string), |
|
343 | 343 | ); |
344 | 344 | } |
345 | 345 | |
346 | 346 | //account for filters |
347 | 347 | if ( ! $all |
348 | - && isset( $this->_req_data['ee_messenger_filter_by'] ) |
|
348 | + && isset($this->_req_data['ee_messenger_filter_by']) |
|
349 | 349 | && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected' |
350 | 350 | ) { |
351 | 351 | $query_params[0]['AND*messenger_filter'] = array( |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | ); |
354 | 354 | } |
355 | 355 | if ( ! $all |
356 | - && ! empty( $this->_req_data['ee_message_type_filter_by'] ) |
|
356 | + && ! empty($this->_req_data['ee_message_type_filter_by']) |
|
357 | 357 | && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected' |
358 | 358 | ) { |
359 | 359 | $query_params[0]['AND*message_type_filter'] = array( |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | if ( ! $all |
365 | - && ! empty( $this->_req_data['ee_context_filter_by'] ) |
|
365 | + && ! empty($this->_req_data['ee_context_filter_by']) |
|
366 | 366 | && $this->_req_data['ee_context_filter_by'] !== 'none_selected' |
367 | 367 | ) { |
368 | 368 | $query_params[0]['AND*context_filter'] = array( |
369 | - 'MSG_context' => array( 'IN', explode( ',', $this->_req_data['ee_context_filter_by'] ) ) |
|
369 | + 'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])) |
|
370 | 370 | ); |
371 | 371 | } |
372 | 372 | |
373 | - return $count ? EEM_Message::instance()->count( $query_params ) : EEM_Message::instance()->get_all( $query_params ); |
|
373 | + return $count ? EEM_Message::instance()->count($query_params) : EEM_Message::instance()->get_all($query_params); |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | } //end EE_Message_List_Table class |
377 | 377 | \ No newline at end of file |
@@ -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 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | protected function _setup_data() { |
44 | - $this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE); |
|
45 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE ); |
|
44 | + $this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE); |
|
45 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | |
52 | 52 | protected function _set_properties() { |
53 | 53 | $this->_wp_list_args = array( |
54 | - 'singular' => __('Message Template Group', 'event_espresso' ), |
|
55 | - 'plural' => __('Message Template', 'event_espresso' ), |
|
54 | + 'singular' => __('Message Template Group', 'event_espresso'), |
|
55 | + 'plural' => __('Message Template', 'event_espresso'), |
|
56 | 56 | 'ajax' => TRUE, //for now, |
57 | 57 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
58 | 58 | ); |
59 | 59 | $this->_columns = array( |
60 | 60 | //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
61 | 61 | 'message_type' => __('Message Type', 'event_espresso'), |
62 | - 'messenger' => __( 'Messenger', 'event_espresso'), |
|
63 | - 'description' => __( 'Description', 'event_espresso' ), |
|
62 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
63 | + 'description' => __('Description', 'event_espresso'), |
|
64 | 64 | //'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place. |
65 | 65 | ); |
66 | 66 | |
67 | 67 | $this->_sortable_columns = array( |
68 | - 'messenger' => array( 'MTP_messenger' => TRUE ), |
|
68 | + 'messenger' => array('MTP_messenger' => TRUE), |
|
69 | 69 | //'message_type' => array( 'MTP_message_type' => FALSE ) |
70 | 70 | ); |
71 | 71 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function single_row( $item ) { |
|
87 | + public function single_row($item) { |
|
88 | 88 | $message_type = $item->message_type_obj(); |
89 | 89 | $messenger = $item->messenger_obj(); |
90 | 90 | |
91 | - if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_Messenger ) { |
|
91 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_Messenger) { |
|
92 | 92 | echo ''; |
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | - parent::single_row( $item ); |
|
96 | + parent::single_row($item); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | protected function _get_table_filters() { |
104 | 104 | $filters = array(); |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | //setup messengers for selects |
107 | 107 | $m_values = $this->get_admin_page()->get_messengers_for_list_table(); |
108 | 108 | //lets do the same for message types |
@@ -110,38 +110,38 @@ discard block |
||
110 | 110 | |
111 | 111 | $msgr_default[0] = array( |
112 | 112 | 'id' => 'none_selected', |
113 | - 'text' => __( 'Show All', 'event_espresso' ) |
|
113 | + 'text' => __('Show All', 'event_espresso') |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 | $mt_default[0] = array( |
117 | 117 | 'id' => 'none_selected', |
118 | - 'text' => __( 'Show All', 'event_espresso' ) |
|
118 | + 'text' => __('Show All', 'event_espresso') |
|
119 | 119 | ); |
120 | 120 | |
121 | - $msgr_filters = ! empty( $m_values ) ? array_merge( $msgr_default, $m_values ) : array(); |
|
122 | - $mt_filters = ! empty( $mt_values ) ? array_merge( $mt_default, $mt_values ) : array(); |
|
121 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
122 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
123 | 123 | |
124 | - if ( empty( $m_values ) ) { |
|
124 | + if (empty($m_values)) { |
|
125 | 125 | $msgr_filters[0] = array( |
126 | 126 | 'id' => 'no_messenger_options', |
127 | - 'text' => __( 'No Messengers active', 'event_espresso' ) |
|
127 | + 'text' => __('No Messengers active', 'event_espresso') |
|
128 | 128 | ); |
129 | 129 | } |
130 | 130 | |
131 | - if ( empty( $mt_values ) ) { |
|
131 | + if (empty($mt_values)) { |
|
132 | 132 | $mt_filters[0] = array( |
133 | 133 | 'id' => 'no_message_type_options', |
134 | - 'text' => __( 'No Message Types active', 'event_espresso' ) |
|
134 | + 'text' => __('No Message Types active', 'event_espresso') |
|
135 | 135 | ); |
136 | 136 | } |
137 | 137 | |
138 | - if ( count( $m_values ) >= 1 && ! empty( $m_values ) ) { |
|
139 | - unset( $msgr_filters[0] ); |
|
140 | - $msgr_filters = array_values( $msgr_filters ); //reindex keys |
|
138 | + if (count($m_values) >= 1 && ! empty($m_values)) { |
|
139 | + unset($msgr_filters[0]); |
|
140 | + $msgr_filters = array_values($msgr_filters); //reindex keys |
|
141 | 141 | } |
142 | 142 | |
143 | - $filters[] = EEH_Form_Fields::select_input( 'ee_messenger_filter_by', $msgr_filters, isset( $this->_req_data['ee_messenger_filter_by'] ) ? sanitize_key( $this->_req_data['ee_messenger_filter_by'] ) : '' ); |
|
144 | - $filters[] = EEH_Form_Fields::select_input( 'ee_message_type_filter_by', $mt_filters, isset( $this->_req_data['ee_message_type_filter_by'] ) ? sanitize_key( $this->_req_data['ee_message_type_filter_by'] ) : '' ); |
|
143 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key($this->_req_data['ee_messenger_filter_by']) : ''); |
|
144 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key($this->_req_data['ee_message_type_filter_by']) : ''); |
|
145 | 145 | return $filters; |
146 | 146 | } |
147 | 147 | |
@@ -149,20 +149,20 @@ discard block |
||
149 | 149 | * we're just removing the search box for message templates, not needed. |
150 | 150 | * @return string (empty); |
151 | 151 | */ |
152 | - function search_box( $text, $input_id ) { |
|
152 | + function search_box($text, $input_id) { |
|
153 | 153 | return ''; |
154 | 154 | } |
155 | 155 | |
156 | 156 | |
157 | 157 | protected function _add_view_counts() { |
158 | - foreach ( $this->_views as $view => $args ) { |
|
159 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE ); |
|
158 | + foreach ($this->_views as $view => $args) { |
|
159 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | |
164 | 164 | |
165 | - public function column_cb( $item ) { |
|
165 | + public function column_cb($item) { |
|
166 | 166 | return ''; |
167 | 167 | } |
168 | 168 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | |
171 | 171 | |
172 | 172 | |
173 | - function column_description( $item ) { |
|
174 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
173 | + function column_description($item) { |
|
174 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -186,27 +186,27 @@ discard block |
||
186 | 186 | $actions = array(); |
187 | 187 | |
188 | 188 | // edit link but only if item isn't trashed. |
189 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) { |
|
190 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL ); |
|
191 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
189 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) { |
|
190 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL); |
|
191 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
192 | 192 | } |
193 | 193 | |
194 | - $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] ); |
|
194 | + $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']); |
|
195 | 195 | |
196 | 196 | //we want to display the contexts in here so we need to set them up |
197 | 197 | $c_label = $item->context_label(); |
198 | 198 | $c_configs = $item->contexts_config(); |
199 | 199 | $ctxt = array(); |
200 | 200 | $context_templates = $item->context_templates(); |
201 | - foreach ( $context_templates as $context => $template_fields ) { |
|
202 | - $mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
203 | - $inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : ''; |
|
201 | + foreach ($context_templates as $context => $template_fields) { |
|
202 | + $mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
203 | + $inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : ''; |
|
204 | 204 | $context_title = ucwords($c_configs[$context]['label']); |
205 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL ); |
|
206 | - $ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title; |
|
205 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL); |
|
206 | + $ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title; |
|
207 | 207 | } |
208 | 208 | |
209 | - $ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : ''; |
|
209 | + $ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : ''; |
|
210 | 210 | |
211 | 211 | |
212 | 212 | //Return the name contents |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | /* $1%s */ $name_link, |
215 | 215 | /* $2%s */ $item->GRP_ID(), |
216 | 216 | /* %4$s */ $ctx_content, |
217 | - /* $3%s */ $this->row_actions( $actions ) |
|
217 | + /* $3%s */ $this->row_actions($actions) |
|
218 | 218 | ); |
219 | 219 | } |
220 | 220 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return string message_type name |
225 | 225 | */ |
226 | 226 | function column_message_type($item) { |
227 | - return ucwords($item->message_type_obj()->label['singular'] ); |
|
227 | + return ucwords($item->message_type_obj()->label['singular']); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,22 +299,22 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - $error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version); |
|
306 | 306 | |
307 | 307 | //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request. |
308 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
309 | - $error_message .= ' ' . esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso' ); |
|
308 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
309 | + $error_message .= ' '.esc_html__('This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso'); |
|
310 | 310 | $error_message .= '<ul><li>'; |
311 | - $error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() ); |
|
311 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
312 | 312 | $error_message .= '</ul>'; |
313 | - EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' ); |
|
313 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
314 | 314 | //now we set this on the transient so it shows up on the next request. |
315 | - EE_Error::get_notices( is_admin(), true ); |
|
315 | + EE_Error::get_notices(is_admin(), true); |
|
316 | 316 | } else { |
317 | - trigger_error( $error_message, $error_type ); |
|
317 | + trigger_error($error_message, $error_type); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * @param string $debug_index |
337 | 337 | * @param string $debug_key |
338 | 338 | */ |
339 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
340 | - if ( WP_DEBUG && false ) { |
|
341 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
342 | - $debug_data = get_option( $debug_key, array() ); |
|
339 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
340 | + if (WP_DEBUG && false) { |
|
341 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
342 | + $debug_data = get_option($debug_key, array()); |
|
343 | 343 | $default_data = array( |
344 | - $class => $func . '() : ' . $line, |
|
344 | + $class => $func.'() : '.$line, |
|
345 | 345 | 'REQ' => $display_request ? $_REQUEST : '', |
346 | 346 | ); |
347 | 347 | // don't serialize objects |
348 | - $info = self::strip_objects( $info ); |
|
349 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
350 | - if ( ! isset( $debug_data[$index] ) ) { |
|
348 | + $info = self::strip_objects($info); |
|
349 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
350 | + if ( ! isset($debug_data[$index])) { |
|
351 | 351 | $debug_data[$index] = array(); |
352 | 352 | } |
353 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
354 | - update_option( $debug_key, $debug_data ); |
|
353 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
354 | + update_option($debug_key, $debug_data); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -363,26 +363,26 @@ discard block |
||
363 | 363 | * @param array $info |
364 | 364 | * @return array |
365 | 365 | */ |
366 | - public static function strip_objects( $info = array() ) { |
|
367 | - foreach ( $info as $key => $value ) { |
|
368 | - if ( is_array( $value ) ) { |
|
369 | - $info[ $key ] = self::strip_objects( $value ); |
|
370 | - } else if ( is_object( $value ) ) { |
|
371 | - $object_class = get_class( $value ); |
|
372 | - $info[ $object_class ] = array(); |
|
373 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
374 | - if ( method_exists( $value, 'ID' ) ) { |
|
375 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
366 | + public static function strip_objects($info = array()) { |
|
367 | + foreach ($info as $key => $value) { |
|
368 | + if (is_array($value)) { |
|
369 | + $info[$key] = self::strip_objects($value); |
|
370 | + } else if (is_object($value)) { |
|
371 | + $object_class = get_class($value); |
|
372 | + $info[$object_class] = array(); |
|
373 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
374 | + if (method_exists($value, 'ID')) { |
|
375 | + $info[$object_class]['ID'] = $value->ID(); |
|
376 | 376 | } |
377 | - if ( method_exists( $value, 'status' ) ) { |
|
378 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
379 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
380 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
377 | + if (method_exists($value, 'status')) { |
|
378 | + $info[$object_class]['status'] = $value->status(); |
|
379 | + } else if (method_exists($value, 'status_ID')) { |
|
380 | + $info[$object_class]['status'] = $value->status_ID(); |
|
381 | 381 | } |
382 | - unset( $info[ $key ] ); |
|
382 | + unset($info[$key]); |
|
383 | 383 | } |
384 | 384 | } |
385 | - return (array)$info; |
|
385 | + return (array) $info; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -399,31 +399,31 @@ discard block |
||
399 | 399 | * @param string $height |
400 | 400 | * @param bool $die |
401 | 401 | */ |
402 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false ) { |
|
402 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false) { |
|
403 | 403 | //$print_r = false; |
404 | - if ( is_object( $var ) ) { |
|
404 | + if (is_object($var)) { |
|
405 | 405 | $var_name = ! $var_name ? 'object' : $var_name; |
406 | 406 | //$print_r = true; |
407 | - } else if ( is_array( $var ) ) { |
|
407 | + } else if (is_array($var)) { |
|
408 | 408 | $var_name = ! $var_name ? 'array' : $var_name; |
409 | 409 | //$print_r = true; |
410 | - } else if ( is_numeric( $var ) ) { |
|
410 | + } else if (is_numeric($var)) { |
|
411 | 411 | $var_name = ! $var_name ? 'numeric' : $var_name; |
412 | - } else if ( is_string( $var ) ) { |
|
412 | + } else if (is_string($var)) { |
|
413 | 413 | $var_name = ! $var_name ? 'string' : $var_name; |
414 | - } else if ( is_null( $var ) ) { |
|
414 | + } else if (is_null($var)) { |
|
415 | 415 | $var_name = ! $var_name ? 'null' : $var_name; |
416 | 416 | } |
417 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
417 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
418 | 418 | ob_start(); |
419 | - echo '<pre style="display:block; width:100%; height:' . $height . '; border:2px solid light-blue;">'; |
|
420 | - echo '<h5 style="color:#2EA2CC;"><b>' . $var_name . '</b></h5><span style="color:#E76700">'; |
|
419 | + echo '<pre style="display:block; width:100%; height:'.$height.'; border:2px solid light-blue;">'; |
|
420 | + echo '<h5 style="color:#2EA2CC;"><b>'.$var_name.'</b></h5><span style="color:#E76700">'; |
|
421 | 421 | //$print_r ? print_r( $var ) : var_dump( $var ); |
422 | - var_dump( $var ); |
|
423 | - echo '</span><br /><span style="font-size:10px;font-weight:normal;">' . $file . '<br />line no: ' . $line . '</span></pre>'; |
|
422 | + var_dump($var); |
|
423 | + echo '</span><br /><span style="font-size:10px;font-weight:normal;">'.$file.'<br />line no: '.$line.'</span></pre>'; |
|
424 | 424 | $result = ob_get_clean(); |
425 | - if ( $die ) { |
|
426 | - die( $result ); |
|
425 | + if ($die) { |
|
426 | + die($result); |
|
427 | 427 | } else { |
428 | 428 | echo $result; |
429 | 429 | } |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * borrowed from Kint Debugger |
441 | 441 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
442 | 442 | */ |
443 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
444 | - function dump_wp_query(){ |
|
443 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
444 | + function dump_wp_query() { |
|
445 | 445 | global $wp_query; |
446 | 446 | d($wp_query); |
447 | 447 | } |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * borrowed from Kint Debugger |
452 | 452 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
453 | 453 | */ |
454 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
455 | - function dump_wp(){ |
|
454 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
455 | + function dump_wp() { |
|
456 | 456 | global $wp; |
457 | 457 | d($wp); |
458 | 458 | } |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | * borrowed from Kint Debugger |
463 | 463 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
464 | 464 | */ |
465 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
466 | - function dump_post(){ |
|
465 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
466 | + function dump_post() { |
|
467 | 467 | global $post; |
468 | 468 | d($post); |
469 | 469 | } |
@@ -1100,14 +1100,14 @@ discard block |
||
1100 | 1100 | $QSG_ID = reset( $id_col ); |
1101 | 1101 | } else { |
1102 | 1102 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1103 | - EE_Log::instance()->log( |
|
1104 | - __FILE__, |
|
1105 | - __FUNCTION__, |
|
1106 | - sprintf( |
|
1107 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1108 | - $QST_ID ), |
|
1109 | - 'error' ); |
|
1110 | - continue; |
|
1103 | + EE_Log::instance()->log( |
|
1104 | + __FILE__, |
|
1105 | + __FUNCTION__, |
|
1106 | + sprintf( |
|
1107 | + __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1108 | + $QST_ID ), |
|
1109 | + 'error' ); |
|
1110 | + continue; |
|
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | |
@@ -1509,8 +1509,8 @@ discard block |
||
1509 | 1509 | } |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1513 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1512 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1513 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1514 | 1514 | |
1515 | 1515 | if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
1516 | 1516 | $db_update_sans_ee4 = array(); |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param $table_name |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
60 | + public static function ensure_table_name_has_prefix($table_name) { |
|
61 | 61 | global $wpdb; |
62 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
62 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * be called on plugin activation and reactivation |
86 | 86 | * @return boolean success, whether the database and folders are setup properly |
87 | 87 | */ |
88 | - public static function initialize_db_and_folders(){ |
|
88 | + public static function initialize_db_and_folders() { |
|
89 | 89 | $good_filesystem = EEH_Activation::create_upload_directories(); |
90 | 90 | $good_db = EEH_Activation::create_database_tables(); |
91 | 91 | return $good_filesystem && $good_db; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * upon activation of a new plugin, reactivation, and at the end |
100 | 100 | * of running migration scripts |
101 | 101 | */ |
102 | - public static function initialize_db_content(){ |
|
102 | + public static function initialize_db_content() { |
|
103 | 103 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
104 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
104 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | EEH_Activation::remove_cron_tasks(); |
119 | 119 | EEH_Activation::create_cron_tasks(); |
120 | 120 | //also, check for CAF default db content |
121 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
121 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
122 | 122 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
123 | 123 | //which users really won't care about on initial activation |
124 | 124 | EE_Error::overwrite_success(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return array |
138 | 138 | * @throws \EE_Error |
139 | 139 | */ |
140 | - public static function get_cron_tasks( $which_to_include ) { |
|
140 | + public static function get_cron_tasks($which_to_include) { |
|
141 | 141 | $cron_tasks = apply_filters( |
142 | 142 | 'FHEE__EEH_Activation__get_cron_tasks', |
143 | 143 | array( |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
147 | 147 | ) |
148 | 148 | ); |
149 | - if( $which_to_include === 'all' ) { |
|
149 | + if ($which_to_include === 'all') { |
|
150 | 150 | //leave as-is |
151 | - }elseif( $which_to_include === 'old' ) { |
|
152 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
151 | + }elseif ($which_to_include === 'old') { |
|
152 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
153 | 153 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
154 | 154 | }); |
155 | - }elseif( $which_to_include === 'current' ) { |
|
156 | - $cron_tasks = array_filter( $cron_tasks ); |
|
157 | - }elseif( WP_DEBUG ) { |
|
158 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
159 | - }else{ |
|
155 | + }elseif ($which_to_include === 'current') { |
|
156 | + $cron_tasks = array_filter($cron_tasks); |
|
157 | + }elseif (WP_DEBUG) { |
|
158 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
159 | + } else { |
|
160 | 160 | //leave as-is |
161 | 161 | } |
162 | 162 | return $cron_tasks; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public static function create_cron_tasks() { |
169 | 169 | |
170 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
171 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
172 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
170 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
171 | + if ( ! wp_next_scheduled($hook_name)) { |
|
172 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * Remove the currently-existing and now-removed cron tasks. |
180 | 180 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
181 | 181 | */ |
182 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
182 | + public static function remove_cron_tasks($remove_all = true) { |
|
183 | 183 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
184 | 184 | $crons = _get_cron_array(); |
185 | - $crons = is_array( $crons ) ? $crons : array(); |
|
185 | + $crons = is_array($crons) ? $crons : array(); |
|
186 | 186 | /* reminder that $crons looks like: top-level keys are timestamps, |
187 | 187 | * and their values are arrays. |
188 | 188 | * The 2nd level arrays have keys with each of the cron task hooknames to run at that time |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | * ... |
201 | 201 | * ... |
202 | 202 | */ |
203 | - foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) { |
|
204 | - foreach( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
205 | - if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) ) { |
|
206 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
203 | + foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) { |
|
204 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
205 | + if (array_key_exists($hook_name, $hooks_to_fire_at_time)) { |
|
206 | + unset($crons[$timestamp][$hook_name]); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
210 | - _set_cron_array( $crons ); |
|
210 | + _set_cron_array($crons); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public static function CPT_initialization() { |
224 | 224 | // register Custom Post Types |
225 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
225 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
226 | 226 | flush_rewrite_rules(); |
227 | 227 | } |
228 | 228 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @return void |
241 | 241 | */ |
242 | 242 | public static function reset_and_update_config() { |
243 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
244 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
243 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
244 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
245 | 245 | //EE_Config::reset(); |
246 | 246 | } |
247 | 247 | |
@@ -254,23 +254,23 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public static function load_calendar_config() { |
256 | 256 | // grab array of all plugin folders and loop thru it |
257 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
258 | - if ( empty( $plugins ) ) { |
|
257 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
258 | + if (empty($plugins)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | - foreach ( $plugins as $plugin_path ) { |
|
261 | + foreach ($plugins as $plugin_path) { |
|
262 | 262 | // grab plugin folder name from path |
263 | - $plugin = basename( $plugin_path ); |
|
263 | + $plugin = basename($plugin_path); |
|
264 | 264 | // drill down to Espresso plugins |
265 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
265 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
266 | 266 | // then to calendar related plugins |
267 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
267 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
268 | 268 | // this is what we are looking for |
269 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
269 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
270 | 270 | // does it exist in this folder ? |
271 | - if ( is_readable( $calendar_config )) { |
|
271 | + if (is_readable($calendar_config)) { |
|
272 | 272 | // YEAH! let's load it |
273 | - require_once( $calendar_config ); |
|
273 | + require_once($calendar_config); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -287,21 +287,21 @@ discard block |
||
287 | 287 | * @param \EE_Config $EE_Config |
288 | 288 | * @return \stdClass |
289 | 289 | */ |
290 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
291 | - $convert_from_array = array( 'addons' ); |
|
290 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
291 | + $convert_from_array = array('addons'); |
|
292 | 292 | // in case old settings were saved as an array |
293 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
293 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
294 | 294 | // convert existing settings to an object |
295 | 295 | $config_array = $settings; |
296 | 296 | $settings = new stdClass(); |
297 | - foreach ( $config_array as $key => $value ){ |
|
298 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
299 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
297 | + foreach ($config_array as $key => $value) { |
|
298 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
299 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
300 | 300 | } else { |
301 | 301 | $settings->$key = $value; |
302 | 302 | } |
303 | 303 | } |
304 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
304 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
305 | 305 | } |
306 | 306 | return $settings; |
307 | 307 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public static function deactivate_event_espresso() { |
319 | 319 | // check permissions |
320 | - if ( current_user_can( 'activate_plugins' )) { |
|
321 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
320 | + if (current_user_can('activate_plugins')) { |
|
321 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -340,79 +340,79 @@ discard block |
||
340 | 340 | $critical_pages = array( |
341 | 341 | array( |
342 | 342 | 'id' =>'reg_page_id', |
343 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
343 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
344 | 344 | 'post' => NULL, |
345 | 345 | 'code' => 'ESPRESSO_CHECKOUT' |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'id' => 'txn_page_id', |
349 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
349 | + 'name' => __('Transactions', 'event_espresso'), |
|
350 | 350 | 'post' => NULL, |
351 | 351 | 'code' => 'ESPRESSO_TXN_PAGE' |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'id' => 'thank_you_page_id', |
355 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
355 | + 'name' => __('Thank You', 'event_espresso'), |
|
356 | 356 | 'post' => NULL, |
357 | 357 | 'code' => 'ESPRESSO_THANK_YOU' |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'id' => 'cancel_page_id', |
361 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
361 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
362 | 362 | 'post' => NULL, |
363 | 363 | 'code' => 'ESPRESSO_CANCELLED' |
364 | 364 | ), |
365 | 365 | ); |
366 | 366 | |
367 | - foreach ( $critical_pages as $critical_page ) { |
|
367 | + foreach ($critical_pages as $critical_page) { |
|
368 | 368 | // is critical page ID set in config ? |
369 | - if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) { |
|
369 | + if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) { |
|
370 | 370 | // attempt to find post by ID |
371 | - $critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] ); |
|
371 | + $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']); |
|
372 | 372 | } |
373 | 373 | // no dice? |
374 | - if ( $critical_page['post'] == NULL ) { |
|
374 | + if ($critical_page['post'] == NULL) { |
|
375 | 375 | // attempt to find post by title |
376 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
376 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
377 | 377 | // still nothing? |
378 | - if ( $critical_page['post'] == NULL ) { |
|
379 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
378 | + if ($critical_page['post'] == NULL) { |
|
379 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
380 | 380 | // REALLY? Still nothing ??!?!? |
381 | - if ( $critical_page['post'] == NULL ) { |
|
382 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
383 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
381 | + if ($critical_page['post'] == NULL) { |
|
382 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
383 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
384 | 384 | break; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
388 | 388 | // track post_shortcodes |
389 | - if ( $critical_page['post'] ) { |
|
390 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
389 | + if ($critical_page['post']) { |
|
390 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
391 | 391 | } |
392 | 392 | // check that Post ID matches critical page ID in config |
393 | - if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) { |
|
393 | + if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) { |
|
394 | 394 | //update Config with post ID |
395 | 395 | EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID; |
396 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
397 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
398 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
396 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
397 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
398 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | - $critical_page_problem = ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem; |
|
402 | + $critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | - if ( $critical_page_problem ) { |
|
406 | + if ($critical_page_problem) { |
|
407 | 407 | $msg = sprintf( |
408 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
409 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
408 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
409 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
410 | 410 | ); |
411 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
411 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
412 | 412 | } |
413 | 413 | |
414 | - if ( EE_Error::has_notices() ) { |
|
415 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
414 | + if (EE_Error::has_notices()) { |
|
415 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | } |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | * parameter to the shortcode |
426 | 426 | * @return WP_Post or NULl |
427 | 427 | */ |
428 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
428 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
429 | 429 | global $wpdb; |
430 | 430 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
431 | 431 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
432 | - if($post_id){ |
|
432 | + if ($post_id) { |
|
433 | 433 | return get_post($post_id); |
434 | - }else{ |
|
434 | + } else { |
|
435 | 435 | return NULL; |
436 | 436 | } |
437 | 437 | |
@@ -448,32 +448,32 @@ discard block |
||
448 | 448 | * @param array $critical_page |
449 | 449 | * @return array |
450 | 450 | */ |
451 | - public static function create_critical_page( $critical_page ) { |
|
451 | + public static function create_critical_page($critical_page) { |
|
452 | 452 | |
453 | 453 | $post_args = array( |
454 | 454 | 'post_title' => $critical_page['name'], |
455 | 455 | 'post_status' => 'publish', |
456 | 456 | 'post_type' => 'page', |
457 | 457 | 'comment_status' => 'closed', |
458 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
458 | + 'post_content' => '['.$critical_page['code'].']' |
|
459 | 459 | ); |
460 | 460 | |
461 | - $post_id = wp_insert_post( $post_args ); |
|
462 | - if ( ! $post_id ) { |
|
461 | + $post_id = wp_insert_post($post_args); |
|
462 | + if ( ! $post_id) { |
|
463 | 463 | $msg = sprintf( |
464 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
464 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
465 | 465 | $critical_page['name'] |
466 | 466 | ); |
467 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
467 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
468 | 468 | return $critical_page; |
469 | 469 | } |
470 | 470 | // get newly created post's details |
471 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
471 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
472 | 472 | $msg = sprintf( |
473 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
473 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
474 | 474 | $critical_page['name'] |
475 | 475 | ); |
476 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
476 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | return $critical_page; |
@@ -492,34 +492,34 @@ discard block |
||
492 | 492 | * @param array $critical_page |
493 | 493 | * @return void |
494 | 494 | */ |
495 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
495 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
496 | 496 | // check the goods |
497 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
497 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
498 | 498 | $msg = sprintf( |
499 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
499 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
500 | 500 | $critical_page['name'] |
501 | 501 | ); |
502 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
502 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
503 | 503 | return; |
504 | 504 | } |
505 | 505 | // map shortcode to post |
506 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
506 | + EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
507 | 507 | // and make sure it's NOT added to the WP "Posts Page" |
508 | 508 | // name of the WP Posts Page |
509 | 509 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
510 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) { |
|
511 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
510 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) { |
|
511 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]); |
|
512 | 512 | } |
513 | - if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) { |
|
514 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
513 | + if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) { |
|
514 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]); |
|
515 | 515 | } |
516 | 516 | // update post_shortcode CFG |
517 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
517 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
518 | 518 | $msg = sprintf( |
519 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
519 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
520 | 520 | $critical_page['name'] |
521 | 521 | ); |
522 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
522 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
@@ -537,24 +537,24 @@ discard block |
||
537 | 537 | public static function get_default_creator_id() { |
538 | 538 | global $wpdb; |
539 | 539 | |
540 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
540 | + if ( ! empty(self::$_default_creator_id)) { |
|
541 | 541 | return self::$_default_creator_id; |
542 | 542 | }/**/ |
543 | 543 | |
544 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
544 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
545 | 545 | |
546 | 546 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
547 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
548 | - if ( $pre_filtered_id !== false ) { |
|
547 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
548 | + if ($pre_filtered_id !== false) { |
|
549 | 549 | return (int) $pre_filtered_id; |
550 | 550 | } |
551 | 551 | |
552 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
553 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
554 | - $user_id = $wpdb->get_var( $query ); |
|
555 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
556 | - if ( $user_id && intval( $user_id ) ) { |
|
557 | - self::$_default_creator_id = intval( $user_id ); |
|
552 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
553 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
554 | + $user_id = $wpdb->get_var($query); |
|
555 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
556 | + if ($user_id && intval($user_id)) { |
|
557 | + self::$_default_creator_id = intval($user_id); |
|
558 | 558 | return self::$_default_creator_id; |
559 | 559 | } else { |
560 | 560 | return NULL; |
@@ -581,29 +581,29 @@ discard block |
||
581 | 581 | * @return void |
582 | 582 | * @throws EE_Error if there are database errors |
583 | 583 | */ |
584 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
585 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
584 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
585 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
586 | 586 | return; |
587 | 587 | } |
588 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
589 | - if ( ! function_exists( 'dbDelta' )) { |
|
590 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
588 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
589 | + if ( ! function_exists('dbDelta')) { |
|
590 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
591 | 591 | } |
592 | 592 | /** @var WPDB $wpdb */ |
593 | 593 | global $wpdb; |
594 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
594 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
595 | 595 | // do we need to first delete an existing version of this table ? |
596 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
596 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
597 | 597 | // ok, delete the table... but ONLY if it's empty |
598 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
598 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
599 | 599 | // table is NOT empty, are you SURE you want to delete this table ??? |
600 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
601 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
602 | - } else if ( ! $deleted_safely ) { |
|
600 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
601 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
602 | + } else if ( ! $deleted_safely) { |
|
603 | 603 | // so we should be more cautious rather than just dropping tables so easily |
604 | 604 | EE_Error::add_persistent_admin_notice( |
605 | - 'bad_table_' . $wp_table_name . '_detected', |
|
606 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
605 | + 'bad_table_'.$wp_table_name.'_detected', |
|
606 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
607 | 607 | $wp_table_name, |
608 | 608 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
609 | 609 | '<b>wp-config.php</b>', |
@@ -612,25 +612,25 @@ discard block |
||
612 | 612 | } |
613 | 613 | } |
614 | 614 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
615 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
615 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
616 | 616 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
617 | 617 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
618 | 618 | //happened. And then we can choose to tell the end user |
619 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
620 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
619 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
620 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
621 | 621 | ob_start(); |
622 | - dbDelta( $SQL ); |
|
622 | + dbDelta($SQL); |
|
623 | 623 | $output = ob_get_contents(); |
624 | 624 | ob_end_clean(); |
625 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
626 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
627 | - if( ! empty( $output ) ){ |
|
628 | - throw new EE_Error( $output ); |
|
625 | + $wpdb->show_errors($old_show_errors_policy); |
|
626 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
627 | + if ( ! empty($output)) { |
|
628 | + throw new EE_Error($output); |
|
629 | 629 | } |
630 | 630 | } else { |
631 | 631 | throw new EE_Error( |
632 | 632 | sprintf( |
633 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
633 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
634 | 634 | '<br />', |
635 | 635 | $sql |
636 | 636 | ) |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)' |
653 | 653 | * @return bool|int |
654 | 654 | */ |
655 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
656 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
655 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
656 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
657 | 657 | return FALSE; |
658 | 658 | } |
659 | 659 | global $wpdb; |
660 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
660 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
661 | 661 | $fields = self::get_fields_on_table($table_name); |
662 | - if (!in_array($column_name, $fields)){ |
|
663 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
662 | + if ( ! in_array($column_name, $fields)) { |
|
663 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
664 | 664 | //echo "alter query:$alter_query"; |
665 | 665 | return $wpdb->query($alter_query); |
666 | 666 | } |
@@ -679,15 +679,15 @@ discard block |
||
679 | 679 | * @param string $table_name, without prefixed $wpdb->prefix |
680 | 680 | * @return array of database column names |
681 | 681 | */ |
682 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
682 | + public static function get_fields_on_table($table_name = NULL) { |
|
683 | 683 | global $wpdb; |
684 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
685 | - if ( ! empty( $table_name )) { |
|
684 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
685 | + if ( ! empty($table_name)) { |
|
686 | 686 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
687 | 687 | if ($columns !== FALSE) { |
688 | 688 | $field_array = array(); |
689 | - foreach($columns as $column ){ |
|
690 | - $field_array[] = $column->Field;; |
|
689 | + foreach ($columns as $column) { |
|
690 | + $field_array[] = $column->Field; ; |
|
691 | 691 | } |
692 | 692 | return $field_array; |
693 | 693 | } |
@@ -705,12 +705,12 @@ discard block |
||
705 | 705 | * @param string $table_name |
706 | 706 | * @return bool |
707 | 707 | */ |
708 | - public static function db_table_is_empty( $table_name ) { |
|
708 | + public static function db_table_is_empty($table_name) { |
|
709 | 709 | global $wpdb; |
710 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
711 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
712 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
713 | - return absint( $count ) === 0 ? true : false; |
|
710 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
711 | + if (EEH_Activation::table_exists($table_name)) { |
|
712 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
713 | + return absint($count) === 0 ? true : false; |
|
714 | 714 | } |
715 | 715 | return false; |
716 | 716 | } |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | * @param string $table_name |
726 | 726 | * @return bool | int |
727 | 727 | */ |
728 | - public static function delete_db_table_if_empty( $table_name ) { |
|
729 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
730 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
728 | + public static function delete_db_table_if_empty($table_name) { |
|
729 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
730 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
731 | 731 | } |
732 | 732 | return false; |
733 | 733 | } |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | * @param string $table_name |
743 | 743 | * @return bool | int |
744 | 744 | */ |
745 | - public static function delete_unused_db_table( $table_name ) { |
|
745 | + public static function delete_unused_db_table($table_name) { |
|
746 | 746 | global $wpdb; |
747 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
748 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
749 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
747 | + if (EEH_Activation::table_exists($table_name)) { |
|
748 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
749 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
750 | 750 | } |
751 | 751 | return false; |
752 | 752 | } |
@@ -762,18 +762,18 @@ discard block |
||
762 | 762 | * @param string $index_name |
763 | 763 | * @return bool | int |
764 | 764 | */ |
765 | - public static function drop_index( $table_name, $index_name ) { |
|
766 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
765 | + public static function drop_index($table_name, $index_name) { |
|
766 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
767 | 767 | return FALSE; |
768 | 768 | } |
769 | 769 | global $wpdb; |
770 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
770 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
771 | 771 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
772 | 772 | if ( |
773 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
774 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
773 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
774 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
775 | 775 | ) { |
776 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
776 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
777 | 777 | } |
778 | 778 | return TRUE; |
779 | 779 | } |
@@ -789,27 +789,27 @@ discard block |
||
789 | 789 | * @return boolean success (whether database is setup properly or not) |
790 | 790 | */ |
791 | 791 | public static function create_database_tables() { |
792 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
792 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
793 | 793 | //find the migration script that sets the database to be compatible with the code |
794 | 794 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
795 | - if( $dms_name ){ |
|
796 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
797 | - $current_data_migration_script->set_migrating( false ); |
|
795 | + if ($dms_name) { |
|
796 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
797 | + $current_data_migration_script->set_migrating(false); |
|
798 | 798 | $current_data_migration_script->schema_changes_before_migration(); |
799 | 799 | $current_data_migration_script->schema_changes_after_migration(); |
800 | - if( $current_data_migration_script->get_errors() ){ |
|
801 | - if( WP_DEBUG ){ |
|
802 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
803 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
800 | + if ($current_data_migration_script->get_errors()) { |
|
801 | + if (WP_DEBUG) { |
|
802 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
803 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
804 | 804 | } |
805 | - }else{ |
|
806 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
805 | + } else { |
|
806 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
807 | 807 | } |
808 | 808 | return false; |
809 | 809 | } |
810 | 810 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
811 | - }else{ |
|
812 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
811 | + } else { |
|
812 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | return true; |
@@ -829,27 +829,27 @@ discard block |
||
829 | 829 | public static function initialize_system_questions() { |
830 | 830 | // QUESTION GROUPS |
831 | 831 | global $wpdb; |
832 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
832 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
833 | 833 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
834 | 834 | // what we have |
835 | - $question_groups = $wpdb->get_col( $SQL ); |
|
835 | + $question_groups = $wpdb->get_col($SQL); |
|
836 | 836 | // check the response |
837 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
837 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
838 | 838 | // what we should have |
839 | - $QSG_systems = array( 1, 2 ); |
|
839 | + $QSG_systems = array(1, 2); |
|
840 | 840 | // loop thru what we should have and compare to what we have |
841 | - foreach ( $QSG_systems as $QSG_system ) { |
|
841 | + foreach ($QSG_systems as $QSG_system) { |
|
842 | 842 | // reset values array |
843 | 843 | $QSG_values = array(); |
844 | 844 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
845 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
845 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
846 | 846 | // add it |
847 | - switch ( $QSG_system ) { |
|
847 | + switch ($QSG_system) { |
|
848 | 848 | |
849 | 849 | case 1: |
850 | 850 | $QSG_values = array( |
851 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
852 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
851 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
852 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
853 | 853 | 'QSG_desc' => '', |
854 | 854 | 'QSG_order' => 1, |
855 | 855 | 'QSG_show_group_name' => 1, |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | |
862 | 862 | case 2: |
863 | 863 | $QSG_values = array( |
864 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
865 | - 'QSG_identifier' => 'address-information-' . time(), |
|
864 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
865 | + 'QSG_identifier' => 'address-information-'.time(), |
|
866 | 866 | 'QSG_desc' => '', |
867 | 867 | 'QSG_order' => 2, |
868 | 868 | 'QSG_show_group_name' => 1, |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | |
875 | 875 | } |
876 | 876 | // make sure we have some values before inserting them |
877 | - if ( ! empty( $QSG_values )) { |
|
877 | + if ( ! empty($QSG_values)) { |
|
878 | 878 | // insert system question |
879 | 879 | $wpdb->insert( |
880 | 880 | $table_name, |
881 | 881 | $QSG_values, |
882 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
882 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
883 | 883 | ); |
884 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
884 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | } |
@@ -890,10 +890,10 @@ discard block |
||
890 | 890 | |
891 | 891 | // QUESTIONS |
892 | 892 | global $wpdb; |
893 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
893 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
894 | 894 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
895 | 895 | // what we have |
896 | - $questions = $wpdb->get_col( $SQL ); |
|
896 | + $questions = $wpdb->get_col($SQL); |
|
897 | 897 | // what we should have |
898 | 898 | $QST_systems = array( |
899 | 899 | 'fname', |
@@ -910,25 +910,25 @@ discard block |
||
910 | 910 | $order_for_group_1 = 1; |
911 | 911 | $order_for_group_2 = 1; |
912 | 912 | // loop thru what we should have and compare to what we have |
913 | - foreach ( $QST_systems as $QST_system ) { |
|
913 | + foreach ($QST_systems as $QST_system) { |
|
914 | 914 | // reset values array |
915 | 915 | $QST_values = array(); |
916 | 916 | // if we don't have what we should have |
917 | - if ( ! in_array( $QST_system, $questions )) { |
|
917 | + if ( ! in_array($QST_system, $questions)) { |
|
918 | 918 | // add it |
919 | - switch ( $QST_system ) { |
|
919 | + switch ($QST_system) { |
|
920 | 920 | |
921 | 921 | case 'fname': |
922 | 922 | $QST_values = array( |
923 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
924 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
923 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
924 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
925 | 925 | 'QST_system' => 'fname', |
926 | 926 | 'QST_type' => 'TEXT', |
927 | 927 | 'QST_required' => 1, |
928 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
928 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
929 | 929 | 'QST_order' => 1, |
930 | 930 | 'QST_admin_only' => 0, |
931 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
931 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
932 | 932 | 'QST_wp_user' => self::get_default_creator_id(), |
933 | 933 | 'QST_deleted' => 0 |
934 | 934 | ); |
@@ -936,15 +936,15 @@ discard block |
||
936 | 936 | |
937 | 937 | case 'lname': |
938 | 938 | $QST_values = array( |
939 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
940 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
939 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
940 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
941 | 941 | 'QST_system' => 'lname', |
942 | 942 | 'QST_type' => 'TEXT', |
943 | 943 | 'QST_required' => 1, |
944 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
944 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
945 | 945 | 'QST_order' => 2, |
946 | 946 | 'QST_admin_only' => 0, |
947 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
947 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
948 | 948 | 'QST_wp_user' => self::get_default_creator_id(), |
949 | 949 | 'QST_deleted' => 0 |
950 | 950 | ); |
@@ -952,15 +952,15 @@ discard block |
||
952 | 952 | |
953 | 953 | case 'email': |
954 | 954 | $QST_values = array( |
955 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
956 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
955 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
956 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
957 | 957 | 'QST_system' => 'email', |
958 | 958 | 'QST_type' => 'TEXT', |
959 | 959 | 'QST_required' => 1, |
960 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
960 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
961 | 961 | 'QST_order' => 3, |
962 | 962 | 'QST_admin_only' => 0, |
963 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
963 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
964 | 964 | 'QST_wp_user' => self::get_default_creator_id(), |
965 | 965 | 'QST_deleted' => 0 |
966 | 966 | ); |
@@ -968,15 +968,15 @@ discard block |
||
968 | 968 | |
969 | 969 | case 'address': |
970 | 970 | $QST_values = array( |
971 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
972 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
971 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
972 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
973 | 973 | 'QST_system' => 'address', |
974 | 974 | 'QST_type' => 'TEXT', |
975 | 975 | 'QST_required' => 0, |
976 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
976 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
977 | 977 | 'QST_order' => 4, |
978 | 978 | 'QST_admin_only' => 0, |
979 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
979 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
980 | 980 | 'QST_wp_user' => self::get_default_creator_id(), |
981 | 981 | 'QST_deleted' => 0 |
982 | 982 | ); |
@@ -984,15 +984,15 @@ discard block |
||
984 | 984 | |
985 | 985 | case 'address2': |
986 | 986 | $QST_values = array( |
987 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
988 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
987 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
988 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
989 | 989 | 'QST_system' => 'address2', |
990 | 990 | 'QST_type' => 'TEXT', |
991 | 991 | 'QST_required' => 0, |
992 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
992 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
993 | 993 | 'QST_order' => 5, |
994 | 994 | 'QST_admin_only' => 0, |
995 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
995 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
996 | 996 | 'QST_wp_user' => self::get_default_creator_id(), |
997 | 997 | 'QST_deleted' => 0 |
998 | 998 | ); |
@@ -1000,15 +1000,15 @@ discard block |
||
1000 | 1000 | |
1001 | 1001 | case 'city': |
1002 | 1002 | $QST_values = array( |
1003 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1004 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1003 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1004 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1005 | 1005 | 'QST_system' => 'city', |
1006 | 1006 | 'QST_type' => 'TEXT', |
1007 | 1007 | 'QST_required' => 0, |
1008 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1008 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1009 | 1009 | 'QST_order' => 6, |
1010 | 1010 | 'QST_admin_only' => 0, |
1011 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1011 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1012 | 1012 | 'QST_wp_user' => self::get_default_creator_id(), |
1013 | 1013 | 'QST_deleted' => 0 |
1014 | 1014 | ); |
@@ -1016,12 +1016,12 @@ discard block |
||
1016 | 1016 | |
1017 | 1017 | case 'state': |
1018 | 1018 | $QST_values = array( |
1019 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1020 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1019 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1020 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1021 | 1021 | 'QST_system' => 'state', |
1022 | 1022 | 'QST_type' => 'STATE', |
1023 | 1023 | 'QST_required' => 0, |
1024 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1024 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1025 | 1025 | 'QST_order' => 7, |
1026 | 1026 | 'QST_admin_only' => 0, |
1027 | 1027 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1031,12 +1031,12 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | case 'country' : |
1033 | 1033 | $QST_values = array( |
1034 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1035 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1034 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1035 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1036 | 1036 | 'QST_system' => 'country', |
1037 | 1037 | 'QST_type' => 'COUNTRY', |
1038 | 1038 | 'QST_required' => 0, |
1039 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1039 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1040 | 1040 | 'QST_order' => 8, |
1041 | 1041 | 'QST_admin_only' => 0, |
1042 | 1042 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1046,15 +1046,15 @@ discard block |
||
1046 | 1046 | |
1047 | 1047 | case 'zip': |
1048 | 1048 | $QST_values = array( |
1049 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1050 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1049 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1050 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1051 | 1051 | 'QST_system' => 'zip', |
1052 | 1052 | 'QST_type' => 'TEXT', |
1053 | 1053 | 'QST_required' => 0, |
1054 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1054 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1055 | 1055 | 'QST_order' => 9, |
1056 | 1056 | 'QST_admin_only' => 0, |
1057 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1057 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1058 | 1058 | 'QST_wp_user' => self::get_default_creator_id(), |
1059 | 1059 | 'QST_deleted' => 0 |
1060 | 1060 | ); |
@@ -1062,49 +1062,49 @@ discard block |
||
1062 | 1062 | |
1063 | 1063 | case 'phone': |
1064 | 1064 | $QST_values = array( |
1065 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1066 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1065 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1066 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1067 | 1067 | 'QST_system' => 'phone', |
1068 | 1068 | 'QST_type' => 'TEXT', |
1069 | 1069 | 'QST_required' => 0, |
1070 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1070 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1071 | 1071 | 'QST_order' => 10, |
1072 | 1072 | 'QST_admin_only' => 0, |
1073 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1073 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1074 | 1074 | 'QST_wp_user' => self::get_default_creator_id(), |
1075 | 1075 | 'QST_deleted' => 0 |
1076 | 1076 | ); |
1077 | 1077 | break; |
1078 | 1078 | |
1079 | 1079 | } |
1080 | - if ( ! empty( $QST_values )) { |
|
1080 | + if ( ! empty($QST_values)) { |
|
1081 | 1081 | // insert system question |
1082 | 1082 | $wpdb->insert( |
1083 | 1083 | $table_name, |
1084 | 1084 | $QST_values, |
1085 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1085 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1086 | 1086 | ); |
1087 | 1087 | $QST_ID = $wpdb->insert_id; |
1088 | 1088 | |
1089 | 1089 | // QUESTION GROUP QUESTIONS |
1090 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1090 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1091 | 1091 | $system_question_we_want = EEM_Question_Group::system_personal; |
1092 | 1092 | } else { |
1093 | 1093 | $system_question_we_want = EEM_Question_Group::system_address; |
1094 | 1094 | } |
1095 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1096 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1095 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1096 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1097 | 1097 | } else { |
1098 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1099 | - if( is_array( $id_col ) ) { |
|
1100 | - $QSG_ID = reset( $id_col ); |
|
1098 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1099 | + if (is_array($id_col)) { |
|
1100 | + $QSG_ID = reset($id_col); |
|
1101 | 1101 | } else { |
1102 | 1102 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1103 | 1103 | EE_Log::instance()->log( |
1104 | 1104 | __FILE__, |
1105 | 1105 | __FUNCTION__, |
1106 | 1106 | sprintf( |
1107 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1107 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1108 | 1108 | $QST_ID ), |
1109 | 1109 | 'error' ); |
1110 | 1110 | continue; |
@@ -1113,9 +1113,9 @@ discard block |
||
1113 | 1113 | |
1114 | 1114 | // add system questions to groups |
1115 | 1115 | $wpdb->insert( |
1116 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1117 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1118 | - array( '%d', '%d','%d' ) |
|
1116 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1117 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1118 | + array('%d', '%d', '%d') |
|
1119 | 1119 | ); |
1120 | 1120 | } |
1121 | 1121 | } |
@@ -1127,11 +1127,11 @@ discard block |
||
1127 | 1127 | * Makes sure the default payment method (Invoice) is active. |
1128 | 1128 | * This used to be done automatically as part of constructing the old gateways config |
1129 | 1129 | */ |
1130 | - public static function insert_default_payment_methods(){ |
|
1131 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1132 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1133 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1134 | - }else{ |
|
1130 | + public static function insert_default_payment_methods() { |
|
1131 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1132 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1133 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1134 | + } else { |
|
1135 | 1135 | EEM_Payment_Method::instance()->verify_button_urls(); |
1136 | 1136 | } |
1137 | 1137 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | global $wpdb; |
1149 | 1149 | |
1150 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1150 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1151 | 1151 | |
1152 | 1152 | $table_name = EEM_Status::instance()->table(); |
1153 | 1153 | |
@@ -1218,38 +1218,38 @@ discard block |
||
1218 | 1218 | * @return boolean success of verifying upload directories exist |
1219 | 1219 | */ |
1220 | 1220 | public static function create_upload_directories() { |
1221 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1221 | + EE_Registry::instance()->load_helper('File'); |
|
1222 | 1222 | // Create the required folders |
1223 | 1223 | $folders = array( |
1224 | 1224 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1225 | 1225 | EVENT_ESPRESSO_GATEWAY_DIR, |
1226 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1227 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1228 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1226 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1227 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1228 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1229 | 1229 | ); |
1230 | - foreach ( $folders as $folder ) { |
|
1230 | + foreach ($folders as $folder) { |
|
1231 | 1231 | try { |
1232 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1233 | - @ chmod( $folder, 0755 ); |
|
1234 | - } catch( EE_Error $e ){ |
|
1232 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1233 | + @ chmod($folder, 0755); |
|
1234 | + } catch (EE_Error $e) { |
|
1235 | 1235 | EE_Error::add_error( |
1236 | 1236 | sprintf( |
1237 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1237 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1238 | 1238 | $folder, |
1239 | - '<br />' . $e->getMessage() |
|
1239 | + '<br />'.$e->getMessage() |
|
1240 | 1240 | ), |
1241 | 1241 | __FILE__, __FUNCTION__, __LINE__ |
1242 | 1242 | ); |
1243 | 1243 | //indicate we'll need to fix this later |
1244 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1244 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1245 | 1245 | return FALSE; |
1246 | 1246 | } |
1247 | 1247 | } |
1248 | 1248 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1249 | 1249 | //is disabled, there might be activation errors recorded in there |
1250 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1250 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1251 | 1251 | //remember EE's folders are all good |
1252 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1252 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1253 | 1253 | return TRUE; |
1254 | 1254 | } |
1255 | 1255 | |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | * @return boolean |
1263 | 1263 | */ |
1264 | 1264 | public static function upload_directories_incomplete() { |
1265 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1265 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | |
@@ -1276,17 +1276,17 @@ discard block |
||
1276 | 1276 | * @return bool |
1277 | 1277 | */ |
1278 | 1278 | public static function generate_default_message_templates() { |
1279 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1279 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1280 | 1280 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1281 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1281 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1282 | 1282 | //get all installed messenger objects |
1283 | 1283 | $installed_messengers = $message_resource_manager->installed_messengers(); |
1284 | 1284 | //let's setup the $installed messengers in an array AND the messengers that are set to be activated on install. |
1285 | - foreach ( $installed_messengers as $messenger ) { |
|
1286 | - if ( $messenger instanceof EE_Messenger && $messenger->activate_on_install ) { |
|
1285 | + foreach ($installed_messengers as $messenger) { |
|
1286 | + if ($messenger instanceof EE_Messenger && $messenger->activate_on_install) { |
|
1287 | 1287 | $default_message_types = $messenger->get_default_message_types(); |
1288 | - if ( ! empty( $default_message_types ) ) { |
|
1289 | - EEH_MSG_Template::generate_new_templates( $messenger->name, $default_message_types ); |
|
1288 | + if ( ! empty($default_message_types)) { |
|
1289 | + EEH_MSG_Template::generate_new_templates($messenger->name, $default_message_types); |
|
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | } |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | */ |
1308 | 1308 | public static function validate_messages_system() { |
1309 | 1309 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1310 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1310 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1311 | 1311 | // ******************************************************** |
1312 | 1312 | // as soon as EE_Message_Resource_Manager is instantiated, |
1313 | 1313 | // it runs _set_active_messengers_and_message_types() |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | // |
1343 | 1343 | ////all done! let's update the active_messengers. |
1344 | 1344 | //EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
1345 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1345 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1346 | 1346 | return; |
1347 | 1347 | } |
1348 | 1348 | |
@@ -1356,12 +1356,12 @@ discard block |
||
1356 | 1356 | * @static |
1357 | 1357 | * @return void |
1358 | 1358 | */ |
1359 | - public static function create_no_ticket_prices_array(){ |
|
1359 | + public static function create_no_ticket_prices_array() { |
|
1360 | 1360 | // this creates an array for tracking events that have no active ticket prices created |
1361 | 1361 | // this allows us to warn admins of the situation so that it can be corrected |
1362 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1363 | - if ( ! $espresso_no_ticket_prices ) { |
|
1364 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1362 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1363 | + if ( ! $espresso_no_ticket_prices) { |
|
1364 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1365 | 1365 | } |
1366 | 1366 | } |
1367 | 1367 | |
@@ -1383,24 +1383,24 @@ discard block |
||
1383 | 1383 | * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/ |
1384 | 1384 | * @global wpdb $wpdb |
1385 | 1385 | */ |
1386 | - public static function delete_all_espresso_cpt_data(){ |
|
1386 | + public static function delete_all_espresso_cpt_data() { |
|
1387 | 1387 | global $wpdb; |
1388 | 1388 | //get all the CPT post_types |
1389 | 1389 | $ee_post_types = array(); |
1390 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1391 | - if ( method_exists( $model_name, 'instance' )) { |
|
1392 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1393 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1394 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1390 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1391 | + if (method_exists($model_name, 'instance')) { |
|
1392 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1393 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1394 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1395 | 1395 | } |
1396 | 1396 | } |
1397 | 1397 | } |
1398 | 1398 | //get all our CPTs |
1399 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1399 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1400 | 1400 | $cpt_ids = $wpdb->get_col($query); |
1401 | 1401 | //delete each post meta and term relations too |
1402 | - foreach($cpt_ids as $post_id){ |
|
1403 | - wp_delete_post($post_id,true); |
|
1402 | + foreach ($cpt_ids as $post_id) { |
|
1403 | + wp_delete_post($post_id, true); |
|
1404 | 1404 | } |
1405 | 1405 | } |
1406 | 1406 | |
@@ -1414,18 +1414,18 @@ discard block |
||
1414 | 1414 | * @param bool $remove_all |
1415 | 1415 | * @return void |
1416 | 1416 | */ |
1417 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1417 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1418 | 1418 | global $wpdb; |
1419 | 1419 | $undeleted_tables = array(); |
1420 | 1420 | |
1421 | 1421 | // load registry |
1422 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1423 | - if ( method_exists( $model_name, 'instance' )) { |
|
1424 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1425 | - if ( $model_obj instanceof EEM_Base ) { |
|
1426 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1427 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1428 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1422 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1423 | + if (method_exists($model_name, 'instance')) { |
|
1424 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1425 | + if ($model_obj instanceof EEM_Base) { |
|
1426 | + foreach ($model_obj->get_tables() as $table) { |
|
1427 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1428 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1429 | 1429 | case false : |
1430 | 1430 | $undeleted_tables[] = $table->get_table_name(); |
1431 | 1431 | break; |
@@ -1450,8 +1450,8 @@ discard block |
||
1450 | 1450 | 'esp_promotion_rule', |
1451 | 1451 | 'esp_rule' |
1452 | 1452 | ); |
1453 | - foreach( $tables_without_models as $table ){ |
|
1454 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1453 | + foreach ($tables_without_models as $table) { |
|
1454 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | |
@@ -1489,58 +1489,58 @@ discard block |
||
1489 | 1489 | 'ee_job_parameters_' => false, |
1490 | 1490 | 'ee_upload_directories_incomplete' => true, |
1491 | 1491 | ); |
1492 | - if( is_main_site() ) { |
|
1493 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1492 | + if (is_main_site()) { |
|
1493 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1494 | 1494 | } |
1495 | 1495 | |
1496 | 1496 | $undeleted_options = array(); |
1497 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1497 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1498 | 1498 | |
1499 | - if( $no_wildcard ){ |
|
1500 | - if( ! delete_option( $option_name ) ){ |
|
1499 | + if ($no_wildcard) { |
|
1500 | + if ( ! delete_option($option_name)) { |
|
1501 | 1501 | $undeleted_options[] = $option_name; |
1502 | 1502 | } |
1503 | - }else{ |
|
1504 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1505 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1506 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1503 | + } else { |
|
1504 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1505 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1506 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1507 | 1507 | $undeleted_options[] = $option_name_from_wildcard; |
1508 | 1508 | } |
1509 | 1509 | } |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | 1512 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1513 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1513 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1514 | 1514 | |
1515 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1515 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1516 | 1516 | $db_update_sans_ee4 = array(); |
1517 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1518 | - if( $version[0] =='3'){//if its NON EE4 |
|
1517 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1518 | + if ($version[0] == '3') {//if its NON EE4 |
|
1519 | 1519 | $db_update_sans_ee4[$version] = $times_activated; |
1520 | 1520 | } |
1521 | 1521 | } |
1522 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1522 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | $errors = ''; |
1526 | - if ( ! empty( $undeleted_tables )) { |
|
1526 | + if ( ! empty($undeleted_tables)) { |
|
1527 | 1527 | $errors .= sprintf( |
1528 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1528 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1529 | 1529 | '<br/>', |
1530 | - implode( ',<br/>', $undeleted_tables ) |
|
1530 | + implode(',<br/>', $undeleted_tables) |
|
1531 | 1531 | ); |
1532 | 1532 | } |
1533 | - if ( ! empty( $undeleted_options )) { |
|
1534 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1533 | + if ( ! empty($undeleted_options)) { |
|
1534 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1535 | 1535 | $errors .= sprintf( |
1536 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1536 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1537 | 1537 | '<br/>', |
1538 | - implode( ',<br/>', $undeleted_options ) |
|
1538 | + implode(',<br/>', $undeleted_options) |
|
1539 | 1539 | ); |
1540 | 1540 | |
1541 | 1541 | } |
1542 | - if ( $errors != '' ) { |
|
1543 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1542 | + if ($errors != '') { |
|
1543 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | |
@@ -1550,23 +1550,23 @@ discard block |
||
1550 | 1550 | * @param string $table_name with or without $wpdb->prefix |
1551 | 1551 | * @return boolean |
1552 | 1552 | */ |
1553 | - public static function table_exists( $table_name ){ |
|
1553 | + public static function table_exists($table_name) { |
|
1554 | 1554 | global $wpdb, $EZSQL_ERROR; |
1555 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1555 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1556 | 1556 | //ignore if this causes an sql error |
1557 | 1557 | $old_error = $wpdb->last_error; |
1558 | 1558 | $old_suppress_errors = $wpdb->suppress_errors(); |
1559 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1559 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1560 | 1560 | $ezsql_error_cache = $EZSQL_ERROR; |
1561 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1562 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1563 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1561 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1562 | + $wpdb->show_errors($old_show_errors_value); |
|
1563 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1564 | 1564 | $new_error = $wpdb->last_error; |
1565 | 1565 | $wpdb->last_error = $old_error; |
1566 | 1566 | $EZSQL_ERROR = $ezsql_error_cache; |
1567 | - if( empty( $new_error ) ){ |
|
1567 | + if (empty($new_error)) { |
|
1568 | 1568 | return TRUE; |
1569 | - }else{ |
|
1569 | + } else { |
|
1570 | 1570 | return FALSE; |
1571 | 1571 | } |
1572 | 1572 | } |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | /** |
1575 | 1575 | * Resets the cache on EEH_Activation |
1576 | 1576 | */ |
1577 | - public static function reset(){ |
|
1577 | + public static function reset() { |
|
1578 | 1578 | self::$_default_creator_id = NULL; |
1579 | 1579 | self::$_initialized_db_content_already_in_this_request = false; |
1580 | 1580 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -148,15 +150,15 @@ discard block |
||
148 | 150 | ); |
149 | 151 | if( $which_to_include === 'all' ) { |
150 | 152 | //leave as-is |
151 | - }elseif( $which_to_include === 'old' ) { |
|
153 | + } elseif( $which_to_include === 'old' ) { |
|
152 | 154 | $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
153 | 155 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
154 | 156 | }); |
155 | - }elseif( $which_to_include === 'current' ) { |
|
157 | + } elseif( $which_to_include === 'current' ) { |
|
156 | 158 | $cron_tasks = array_filter( $cron_tasks ); |
157 | - }elseif( WP_DEBUG ) { |
|
159 | + } elseif( WP_DEBUG ) { |
|
158 | 160 | throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
159 | - }else{ |
|
161 | + } else{ |
|
160 | 162 | //leave as-is |
161 | 163 | } |
162 | 164 | return $cron_tasks; |
@@ -431,7 +433,7 @@ discard block |
||
431 | 433 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
432 | 434 | if($post_id){ |
433 | 435 | return get_post($post_id); |
434 | - }else{ |
|
436 | + } else{ |
|
435 | 437 | return NULL; |
436 | 438 | } |
437 | 439 | |
@@ -802,13 +804,13 @@ discard block |
||
802 | 804 | foreach( $current_data_migration_script->get_errors() as $error ){ |
803 | 805 | EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
804 | 806 | } |
805 | - }else{ |
|
807 | + } else{ |
|
806 | 808 | EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
807 | 809 | } |
808 | 810 | return false; |
809 | 811 | } |
810 | 812 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
811 | - }else{ |
|
813 | + } else{ |
|
812 | 814 | EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
813 | 815 | return false; |
814 | 816 | } |
@@ -1131,7 +1133,7 @@ discard block |
||
1131 | 1133 | if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
1132 | 1134 | EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
1133 | 1135 | EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
1134 | - }else{ |
|
1136 | + } else{ |
|
1135 | 1137 | EEM_Payment_Method::instance()->verify_button_urls(); |
1136 | 1138 | } |
1137 | 1139 | } |
@@ -1500,7 +1502,7 @@ discard block |
||
1500 | 1502 | if( ! delete_option( $option_name ) ){ |
1501 | 1503 | $undeleted_options[] = $option_name; |
1502 | 1504 | } |
1503 | - }else{ |
|
1505 | + } else{ |
|
1504 | 1506 | $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
1505 | 1507 | foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
1506 | 1508 | if( ! delete_option( $option_name_from_wildcard ) ){ |
@@ -1566,7 +1568,7 @@ discard block |
||
1566 | 1568 | $EZSQL_ERROR = $ezsql_error_cache; |
1567 | 1569 | if( empty( $new_error ) ){ |
1568 | 1570 | return TRUE; |
1569 | - }else{ |
|
1571 | + } else{ |
|
1570 | 1572 | return FALSE; |
1571 | 1573 | } |
1572 | 1574 | } |
@@ -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 | /** |
@@ -55,39 +55,39 @@ discard block |
||
55 | 55 | * @throws \EE_Error |
56 | 56 | * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems. |
57 | 57 | */ |
58 | - public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) { |
|
58 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) { |
|
59 | 59 | //make sure message_type is an array. |
60 | 60 | $message_types = (array) $message_types; |
61 | 61 | $templates = array(); |
62 | 62 | $success = TRUE; |
63 | - if ( empty($messenger) ) { |
|
64 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
63 | + if (empty($messenger)) { |
|
64 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
68 | - if ( empty($message_types) ) { |
|
69 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
68 | + if (empty($message_types)) { |
|
69 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | self::_set_autoloader(); |
73 | - foreach ( $message_types as $message_type ) { |
|
73 | + foreach ($message_types as $message_type) { |
|
74 | 74 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
75 | - if ( $global && empty( $GRP_ID ) ) { |
|
76 | - $GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) ); |
|
75 | + if ($global && empty($GRP_ID)) { |
|
76 | + $GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE))); |
|
77 | 77 | $GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0; |
78 | 78 | } |
79 | 79 | //if this is global template generation. First let's determine if we already HAVE global templates for this messenger and message_type combination. If we do then NO generation!! |
80 | - if ( $global && self::already_generated($messenger, $message_type, $GRP_ID ) ) { |
|
80 | + if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) { |
|
81 | 81 | $templates = TRUE; |
82 | 82 | continue; //get out we've already got generated templates for this. |
83 | 83 | } |
84 | 84 | $new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global); |
85 | 85 | |
86 | - if ( !$new_message_template_group ) { |
|
86 | + if ( ! $new_message_template_group) { |
|
87 | 87 | $success = FALSE; |
88 | 88 | continue; |
89 | 89 | } |
90 | - if ( $templates === TRUE ) $templates = array(); |
|
90 | + if ($templates === TRUE) $templates = array(); |
|
91 | 91 | $templates[] = $new_message_template_group; |
92 | 92 | } |
93 | 93 | |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | * @param bool $update_to_active if true then we also toggle the template to active. |
104 | 104 | * @return bool true = generated, false = hasn't been generated. |
105 | 105 | */ |
106 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) { |
|
106 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) { |
|
107 | 107 | self::_set_autoloader(); |
108 | 108 | $MTP = EEM_Message_Template::instance(); |
109 | 109 | |
110 | 110 | //what method we use depends on whether we have an GRP_ID or not |
111 | - $count = empty( $GRP_ID ) ? EEM_Message_Template::instance()->count( array( array( 'Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE ) ) ) : $MTP->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
111 | + $count = empty($GRP_ID) ? EEM_Message_Template::instance()->count(array(array('Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE))) : $MTP->count(array(array('GRP_ID' => $GRP_ID))); |
|
112 | 112 | |
113 | - if ( $update_to_active ) { |
|
114 | - self::update_to_active( $messenger, $message_type ); |
|
113 | + if ($update_to_active) { |
|
114 | + self::update_to_active($messenger, $message_type); |
|
115 | 115 | } |
116 | 116 | |
117 | - return ( $count > 0 ) ? TRUE : FALSE; |
|
117 | + return ($count > 0) ? TRUE : FALSE; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * @static |
129 | 129 | * @return int count of updated records. |
130 | 130 | */ |
131 | - public static function update_to_active( $messenger, $message_type ) { |
|
131 | + public static function update_to_active($messenger, $message_type) { |
|
132 | 132 | return EEM_Message_Template_Group::instance()->update( |
133 | - array( 'MTP_is_active' => 1 ), |
|
133 | + array('MTP_is_active' => 1), |
|
134 | 134 | array( |
135 | 135 | array( |
136 | 136 | 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @return int count of updated records. |
155 | 155 | */ |
156 | - public static function update_to_inactive( $messenger = '', $message_type = '' ) { |
|
156 | + public static function update_to_inactive($messenger = '', $message_type = '') { |
|
157 | 157 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
158 | 158 | $messenger, |
159 | 159 | $message_type |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $type |
169 | 169 | * @return array array consisting of installed messenger objects and installed message type objects. |
170 | 170 | */ |
171 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
171 | + public static function get_installed_message_objects($type = 'all') { |
|
172 | 172 | self::_set_autoloader(); |
173 | 173 | //get all installed messengers and message_types |
174 | 174 | /** @type EE_Messages $messages_controller */ |
175 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
175 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
176 | 176 | return $messages_controller->get_installed($type); |
177 | 177 | } |
178 | 178 | |
@@ -205,38 +205,38 @@ discard block |
||
205 | 205 | $context = 'admin', |
206 | 206 | $merged = false |
207 | 207 | ) { |
208 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
209 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
208 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
209 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
210 | 210 | |
211 | 211 | //convert slug to object |
212 | - $messenger = self::messenger_obj( $messenger ); |
|
212 | + $messenger = self::messenger_obj($messenger); |
|
213 | 213 | |
214 | 214 | //validate class for getting our list of shortcodes |
215 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
216 | - if ( !class_exists( $classname ) ) { |
|
217 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
215 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
216 | + if ( ! class_exists($classname)) { |
|
217 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
218 | 218 | $msg[] = sprintf( |
219 | 219 | __('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', 'event_espresso'), |
220 | 220 | $classname |
221 | 221 | ); |
222 | - throw new EE_Error( implode( '||', $msg ) ); |
|
222 | + throw new EE_Error(implode('||', $msg)); |
|
223 | 223 | } |
224 | 224 | /** @type EE_Messages_Validator $_VLD */ |
225 | - $_VLD = new $classname( array(), $context ); |
|
225 | + $_VLD = new $classname(array(), $context); |
|
226 | 226 | $valid_shortcodes = $_VLD->get_validators(); |
227 | 227 | |
228 | 228 | //let's make sure we're only getting the shortcode part of the validators |
229 | 229 | $shortcodes = array(); |
230 | - foreach( $valid_shortcodes as $field => $validators ) { |
|
230 | + foreach ($valid_shortcodes as $field => $validators) { |
|
231 | 231 | $shortcodes[$field] = $validators['shortcodes']; |
232 | 232 | } |
233 | 233 | $valid_shortcodes = $shortcodes; |
234 | 234 | |
235 | 235 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
236 | - if ( ! empty( $fields ) ) { |
|
236 | + if ( ! empty($fields)) { |
|
237 | 237 | $specified_shortcodes = array(); |
238 | - foreach ( $fields as $field ) { |
|
239 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
238 | + foreach ($fields as $field) { |
|
239 | + if (isset($valid_shortcodes[$field])) |
|
240 | 240 | $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
241 | 241 | } |
242 | 242 | $valid_shortcodes = $specified_shortcodes; |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | |
245 | 245 | |
246 | 246 | //if not merged then let's replace the fields with the localized fields |
247 | - if ( ! $merged ) { |
|
247 | + if ( ! $merged) { |
|
248 | 248 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
249 | 249 | $field_settings = $messenger->get_template_fields(); |
250 | 250 | $localized = array(); |
251 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
251 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
252 | 252 | //get localized field label |
253 | - if ( isset( $field_settings[$field] ) ) { |
|
253 | + if (isset($field_settings[$field])) { |
|
254 | 254 | //possible that this is used as a main field. |
255 | - if ( empty( $field_settings[$field] ) ) { |
|
256 | - if ( isset( $field_settings['extra'][$field] ) ) { |
|
255 | + if (empty($field_settings[$field])) { |
|
256 | + if (isset($field_settings['extra'][$field])) { |
|
257 | 257 | $_field = $field_settings['extra'][$field]['main']['label']; |
258 | 258 | } else { |
259 | 259 | $_field = $field; |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | } else { |
262 | 262 | $_field = $field_settings[$field]['label']; |
263 | 263 | } |
264 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
264 | + } else if (isset($field_settings['extra'])) { |
|
265 | 265 | //loop through extra "main fields" and see if any of their children have our field |
266 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
267 | - if ( isset( $fields[$field] ) ) |
|
266 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
267 | + if (isset($fields[$field])) |
|
268 | 268 | $_field = $fields[$field]['label']; |
269 | 269 | else |
270 | 270 | $_field = $field; |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | } else { |
273 | 273 | $_field = $field; |
274 | 274 | } |
275 | - if ( isset( $_field )) { |
|
276 | - $localized[ $_field ] = $shortcodes; |
|
275 | + if (isset($_field)) { |
|
276 | + $localized[$_field] = $shortcodes; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | $valid_shortcodes = $localized; |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | |
282 | 282 | |
283 | 283 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
284 | - if ( $merged ) { |
|
284 | + if ($merged) { |
|
285 | 285 | $merged_codes = array(); |
286 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
287 | - foreach ( $shortcode as $code => $label ) { |
|
288 | - if ( isset( $merged_codes[$code] ) ) |
|
286 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
287 | + foreach ($shortcode as $code => $label) { |
|
288 | + if (isset($merged_codes[$code])) |
|
289 | 289 | continue; |
290 | 290 | else |
291 | 291 | $merged_codes[$code] = $label; |
@@ -307,11 +307,11 @@ discard block |
||
307 | 307 | * @throws \EE_Error |
308 | 308 | * @return EE_Messenger |
309 | 309 | */ |
310 | - public static function messenger_obj( $messenger ) { |
|
310 | + public static function messenger_obj($messenger) { |
|
311 | 311 | /** @type EE_Messages $messages_controller */ |
312 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
312 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
313 | 313 | $installed_messengers = $messages_controller->get_installed_messengers(); |
314 | - return isset( $installed_messengers[ $messenger ] ) ? $installed_messengers[ $messenger ] : null; |
|
314 | + return isset($installed_messengers[$messenger]) ? $installed_messengers[$messenger] : null; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * @throws \EE_Error |
325 | 325 | * @return EE_message_type |
326 | 326 | */ |
327 | - public static function message_type_obj( $message_type ) { |
|
327 | + public static function message_type_obj($message_type) { |
|
328 | 328 | /** @type EE_Messages $messages_controller */ |
329 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
329 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
330 | 330 | $installed_message_types = $messages_controller->get_installed_message_types(); |
331 | - return isset( $installed_message_types[ $message_type ] ) ? $installed_message_types[ $message_type ] : null; |
|
331 | + return isset($installed_message_types[$message_type]) ? $installed_message_types[$message_type] : null; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | * @param string $message_type message type to check for. |
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | - public static function is_mt_active( $message_type ) { |
|
345 | + public static function is_mt_active($message_type) { |
|
346 | 346 | self::_set_autoloader(); |
347 | 347 | /** @type EE_Messages $messages_controller */ |
348 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
348 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
349 | 349 | $active_mts = $messages_controller->get_active_message_types(); |
350 | - return in_array( $message_type, $active_mts ); |
|
350 | + return in_array($message_type, $active_mts); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | * @param string $messenger slug for messenger to check. |
361 | 361 | * @return boolean |
362 | 362 | */ |
363 | - public static function is_messenger_active( $messenger ) { |
|
363 | + public static function is_messenger_active($messenger) { |
|
364 | 364 | self::_set_autoloader(); |
365 | 365 | /** @type EE_Messages $messages_controller */ |
366 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
366 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
367 | 367 | $active_messengers = $messages_controller->get_active_messengers(); |
368 | - return isset( $active_messengers[ $messenger ] ); |
|
368 | + return isset($active_messengers[$messenger]); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | public static function get_active_messengers_in_db() { |
382 | 382 | return apply_filters( |
383 | 383 | 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', |
384 | - get_option( 'ee_active_messengers', array() ) |
|
384 | + get_option('ee_active_messengers', array()) |
|
385 | 385 | ); |
386 | 386 | } |
387 | 387 | |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @return bool FALSE if not updated, TRUE if updated. |
399 | 399 | */ |
400 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
401 | - return update_option( 'ee_active_messengers', $data_to_save ); |
|
400 | + public static function update_active_messengers_in_db($data_to_save) { |
|
401 | + return update_option('ee_active_messengers', $data_to_save); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -422,34 +422,34 @@ discard block |
||
422 | 422 | $sending_messenger = '' |
423 | 423 | ) { |
424 | 424 | //first determine if the url can be to the EE_Message object. |
425 | - if ( ! $message_type->always_generate() ) { |
|
426 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
425 | + if ( ! $message_type->always_generate()) { |
|
426 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
430 | - if ( ! $registration instanceof EE_Registration ) { |
|
430 | + if ( ! $registration instanceof EE_Registration) { |
|
431 | 431 | throw new EE_Error( |
432 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
432 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
433 | 433 | ); |
434 | 434 | } |
435 | 435 | |
436 | 436 | //validate given context |
437 | 437 | $contexts = $message_type->get_contexts(); |
438 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
438 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
439 | 439 | throw new EE_Error( |
440 | 440 | sprintf( |
441 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
441 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
442 | 442 | $message->context(), |
443 | - get_class( $message_type ) |
|
443 | + get_class($message_type) |
|
444 | 444 | ) |
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
448 | 448 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
449 | - if ( ! empty( $sending_messenger ) ) { |
|
449 | + if ( ! empty($sending_messenger)) { |
|
450 | 450 | $with_messengers = $message_type->with_messengers(); |
451 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
452 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
451 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
452 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
453 | 453 | throw new EE_Error( |
454 | 454 | sprintf( |
455 | 455 | __( |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | 'event_espresso' |
458 | 458 | ), |
459 | 459 | $sending_messenger, |
460 | - get_class( $message_type ) |
|
460 | + get_class($message_type) |
|
461 | 461 | ) |
462 | 462 | ); |
463 | 463 | } |
@@ -480,14 +480,14 @@ discard block |
||
480 | 480 | * @param EE_Message $message |
481 | 481 | * @return string. |
482 | 482 | */ |
483 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
483 | + public static function generate_browser_trigger(EE_Message $message) { |
|
484 | 484 | $query_args = array( |
485 | 485 | 'ee' => 'msg_browser_trigger', |
486 | 486 | 'token' => $message->MSG_token() |
487 | 487 | ); |
488 | 488 | return apply_filters( |
489 | 489 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
490 | - add_query_arg( $query_args, site_url() ), |
|
490 | + add_query_arg($query_args, site_url()), |
|
491 | 491 | $message |
492 | 492 | ); |
493 | 493 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param EE_Message $message |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
505 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
506 | 506 | return apply_filters( |
507 | 507 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
508 | 508 | add_query_arg( |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | 'GRP_ID' => $message_template_group, |
553 | 553 | 'id' => $data_id |
554 | 554 | ); |
555 | - $url = add_query_arg( $query_args, get_site_url() ); |
|
555 | + $url = add_query_arg($query_args, get_site_url()); |
|
556 | 556 | |
557 | 557 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
558 | 558 | $url = apply_filters( |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | * @param string $type What action to return. |
581 | 581 | * @return string |
582 | 582 | */ |
583 | - public static function get_message_action_icon( $type ) { |
|
583 | + public static function get_message_action_icon($type) { |
|
584 | 584 | $action_icons = self::get_message_action_icons(); |
585 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
585 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | |
@@ -594,34 +594,34 @@ discard block |
||
594 | 594 | * @return array |
595 | 595 | */ |
596 | 596 | public static function get_message_action_icons() { |
597 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
597 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
598 | 598 | array( |
599 | 599 | 'view' => array( |
600 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
600 | + 'label' => __('View Message', 'event_espresso'), |
|
601 | 601 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
602 | 602 | ), |
603 | 603 | 'error' => array( |
604 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
604 | + 'label' => __('View Error Message', 'event_espresso'), |
|
605 | 605 | 'css_class' => 'dashicons dashicons-info', |
606 | 606 | ), |
607 | 607 | 'see_notifications_for' => array( |
608 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
608 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
609 | 609 | 'css_class' => 'dashicons dashicons-images-alt', |
610 | 610 | ), |
611 | 611 | 'generate_now' => array( |
612 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
612 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
613 | 613 | 'css_class' => 'dashicons dashicons-admin-tools', |
614 | 614 | ), |
615 | 615 | 'send_now' => array( |
616 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
616 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
617 | 617 | 'css_class' => 'dashicons dashicons-controls-forward', |
618 | 618 | ), |
619 | 619 | 'queue_for_resending' => array( |
620 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
620 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
621 | 621 | 'css_class' => 'dashicons dashicons-controls-repeat', |
622 | 622 | ), |
623 | 623 | 'view_transaction' => array( |
624 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
624 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
625 | 625 | 'css_class' => 'dashicons dashicons-cart', |
626 | 626 | ) |
627 | 627 | ) |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @return string |
642 | 642 | */ |
643 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
644 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
645 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
643 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
644 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
645 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -656,15 +656,15 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @return array |
658 | 658 | */ |
659 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
660 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
659 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
660 | + EE_Registry::instance()->load_helper('URL'); |
|
661 | 661 | //if $message is not an instance of EE_Message then let's just do a dummy. |
662 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
663 | - $action_urls = apply_filters( |
|
662 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
663 | + $action_urls = apply_filters( |
|
664 | 664 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
665 | 665 | array( |
666 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
667 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
666 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
667 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
668 | 668 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
669 | 669 | array_merge( |
670 | 670 | array( |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | ), |
675 | 675 | $query_params |
676 | 676 | ), |
677 | - admin_url( 'admin.php' ) |
|
677 | + admin_url('admin.php') |
|
678 | 678 | ), |
679 | 679 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
680 | 680 | array( |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | 'action' => 'generate_now', |
683 | 683 | 'MSG_ID' => $message->ID() |
684 | 684 | ), |
685 | - admin_url( 'admin.php' ) |
|
685 | + admin_url('admin.php') |
|
686 | 686 | ), |
687 | 687 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
688 | 688 | array( |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | 'action' => 'send_now', |
691 | 691 | 'MSG_ID' => $message->ID() |
692 | 692 | ), |
693 | - admin_url( 'admin.php' ) |
|
693 | + admin_url('admin.php') |
|
694 | 694 | ), |
695 | 695 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
696 | 696 | array( |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'action' => 'queue_for_resending', |
699 | 699 | 'MSG_ID' => $message->ID() |
700 | 700 | ), |
701 | - admin_url( 'admin.php' ) |
|
701 | + admin_url('admin.php') |
|
702 | 702 | ), |
703 | 703 | ) |
704 | 704 | ); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | 'action' => 'view_transaction', |
717 | 717 | 'TXN_ID' => $message->TXN_ID() |
718 | 718 | ), |
719 | - admin_url( 'admin.php' ) |
|
719 | + admin_url('admin.php') |
|
720 | 720 | ); |
721 | 721 | } else { |
722 | 722 | $action_urls['view_transaction'] = ''; |
@@ -737,24 +737,24 @@ discard block |
||
737 | 737 | * |
738 | 738 | * @return string |
739 | 739 | */ |
740 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
741 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
742 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
743 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
740 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
741 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
742 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
743 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
744 | 744 | return ''; |
745 | 745 | } |
746 | 746 | |
747 | 747 | $icon_css['css_class'] .= esc_attr( |
748 | 748 | apply_filters( |
749 | 749 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
750 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
750 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
751 | 751 | $type, |
752 | 752 | $message, |
753 | 753 | $query_params |
754 | 754 | ) |
755 | 755 | ); |
756 | 756 | |
757 | - return '<a href="' . $url . '"><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
757 | + return '<a href="'.$url.'"><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
758 | 758 | |
759 | 759 | } |
760 | 760 | |
@@ -792,9 +792,9 @@ discard block |
||
792 | 792 | * @param $reg_status |
793 | 793 | * @return string |
794 | 794 | */ |
795 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
795 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
796 | 796 | $reg_status_array = self::reg_status_to_message_type_array(); |
797 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
797 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -828,9 +828,9 @@ discard block |
||
828 | 828 | * @param $payment_status |
829 | 829 | * @return string |
830 | 830 | */ |
831 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
831 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
832 | 832 | $payment_status_array = self::payment_status_to_message_type_array(); |
833 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
833 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | |
@@ -841,32 +841,32 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return EE_Messages_Template_Pack |
843 | 843 | */ |
844 | - public static function get_template_pack( $template_pack_name ) { |
|
845 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
844 | + public static function get_template_pack($template_pack_name) { |
|
845 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
846 | 846 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
847 | 847 | } |
848 | 848 | |
849 | 849 | //first see if in collection already |
850 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
850 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
851 | 851 | |
852 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
852 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
853 | 853 | return $template_pack; |
854 | 854 | } |
855 | 855 | |
856 | 856 | //nope...let's get it. |
857 | 857 | //not set yet so let's attempt to get it. |
858 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
858 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
859 | 859 | ' ', |
860 | 860 | '_', |
861 | 861 | ucwords( |
862 | - str_replace( '_', ' ', $template_pack_name ) |
|
862 | + str_replace('_', ' ', $template_pack_name) |
|
863 | 863 | ) |
864 | 864 | ); |
865 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
866 | - return self::get_template_pack( 'default' ); |
|
865 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
866 | + return self::get_template_pack('default'); |
|
867 | 867 | } else { |
868 | 868 | $template_pack = new $pack_class_name; |
869 | - self::$_template_pack_collection->add( $template_pack ); |
|
869 | + self::$_template_pack_collection->add($template_pack); |
|
870 | 870 | return $template_pack; |
871 | 871 | } |
872 | 872 | } |
@@ -884,26 +884,26 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public static function get_template_pack_collection() { |
886 | 886 | $new_collection = false; |
887 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
887 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
888 | 888 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
889 | 889 | $new_collection = true; |
890 | 890 | } |
891 | 891 | |
892 | 892 | //glob the defaults directory for messages |
893 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
894 | - foreach( $templates as $template_path ) { |
|
893 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
894 | + foreach ($templates as $template_path) { |
|
895 | 895 | //grab folder name |
896 | - $template = basename( $template_path ); |
|
896 | + $template = basename($template_path); |
|
897 | 897 | |
898 | - if ( ! $new_collection ) { |
|
898 | + if ( ! $new_collection) { |
|
899 | 899 | //already have it? |
900 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
900 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
901 | 901 | continue; |
902 | 902 | } |
903 | 903 | } |
904 | 904 | |
905 | 905 | //setup classname. |
906 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
906 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
907 | 907 | ' ', |
908 | 908 | '_', |
909 | 909 | ucwords( |
@@ -914,20 +914,20 @@ discard block |
||
914 | 914 | ) |
915 | 915 | ) |
916 | 916 | ); |
917 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
917 | + if ( ! class_exists($template_pack_class_name)) { |
|
918 | 918 | continue; |
919 | 919 | } |
920 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
920 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
924 | 924 | * Filter for plugins to add in any additional template packs |
925 | 925 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
926 | 926 | */ |
927 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
928 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
929 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
930 | - self::$_template_pack_collection->add( $template_pack ); |
|
927 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
928 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
929 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
930 | + self::$_template_pack_collection->add($template_pack); |
|
931 | 931 | } |
932 | 932 | } |
933 | 933 | return self::$_template_pack_collection; |
@@ -945,16 +945,16 @@ discard block |
||
945 | 945 | * @return array |
946 | 946 | * @throws \EE_Error |
947 | 947 | */ |
948 | - public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
948 | + public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
949 | 949 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
950 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
951 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
952 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
953 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
950 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
951 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
952 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
953 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
954 | 954 | return array(); |
955 | 955 | } |
956 | 956 | //whew made it this far! Okay, let's go ahead and create the templates then |
957 | - return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
957 | + return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | * @param $global |
967 | 967 | * @return array|mixed |
968 | 968 | */ |
969 | - protected static function _create_new_templates( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
969 | + protected static function _create_new_templates(EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
970 | 970 | //if we're creating a custom template then we don't need to use the defaults class |
971 | - if ( ! $global ) { |
|
972 | - return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
971 | + if ( ! $global) { |
|
972 | + return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
973 | 973 | } |
974 | 974 | $Message_Template_Defaults = new EE_Message_Template_Defaults( |
975 | - EE_Registry::instance()->load_lib( 'messages' ), |
|
975 | + EE_Registry::instance()->load_lib('messages'), |
|
976 | 976 | $messenger->name, |
977 | 977 | $message_type->name, |
978 | 978 | $GRP_ID |
@@ -1004,11 +1004,11 @@ discard block |
||
1004 | 1004 | * ) |
1005 | 1005 | * @access private |
1006 | 1006 | */ |
1007 | - private static function _create_custom_template_group( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1007 | + private static function _create_custom_template_group(EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1008 | 1008 | //defaults |
1009 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1009 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1010 | 1010 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
1011 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1011 | + $Message_Template_Group = empty($GRP_ID) |
|
1012 | 1012 | ? EEM_Message_Template_Group::instance()->get_one( |
1013 | 1013 | array( |
1014 | 1014 | array( |
@@ -1018,9 +1018,9 @@ discard block |
||
1018 | 1018 | ) |
1019 | 1019 | ) |
1020 | 1020 | ) |
1021 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1021 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1022 | 1022 | //if we don't have a mtg at this point then we need to bail. |
1023 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1023 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1024 | 1024 | EE_Error::add_error( |
1025 | 1025 | sprintf( |
1026 | 1026 | __( |
@@ -1039,42 +1039,42 @@ discard block |
||
1039 | 1039 | $mtts = $Message_Template_Group->message_templates(); |
1040 | 1040 | //now we have what we need to setup the new template |
1041 | 1041 | $new_mtg = clone $Message_Template_Group; |
1042 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1043 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1044 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1045 | - ? $_POST[ 'templateName' ] |
|
1042 | + $new_mtg->set('GRP_ID', 0); |
|
1043 | + $new_mtg->set('MTP_is_global', false); |
|
1044 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1045 | + ? $_POST['templateName'] |
|
1046 | 1046 | : __( |
1047 | 1047 | 'New Custom Template', |
1048 | 1048 | 'event_espresso' |
1049 | 1049 | ); |
1050 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1051 | - ? $_POST[ 'templateDescription' ] |
|
1050 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1051 | + ? $_POST['templateDescription'] |
|
1052 | 1052 | : sprintf( |
1053 | 1053 | __( |
1054 | 1054 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1055 | 1055 | 'event_espresso' |
1056 | 1056 | ), |
1057 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1058 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1057 | + $new_mtg->messenger_obj()->label['singular'], |
|
1058 | + $new_mtg->message_type_obj()->label['singular'] |
|
1059 | 1059 | ); |
1060 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1061 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1060 | + $new_mtg->set('MTP_name', $template_name); |
|
1061 | + $new_mtg->set('MTP_description', $template_description); |
|
1062 | 1062 | //remove ALL relations on this template group so they don't get saved! |
1063 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1063 | + $new_mtg->_remove_relations('Message_Template'); |
|
1064 | 1064 | $new_mtg->save(); |
1065 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1066 | - $success[ 'template_name' ] = $template_name; |
|
1065 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1066 | + $success['template_name'] = $template_name; |
|
1067 | 1067 | //add new message templates and add relation to. |
1068 | - foreach ( $mtts as $mtt ) { |
|
1069 | - if ( ! $mtt instanceof EE_Message_Template ) { |
|
1068 | + foreach ($mtts as $mtt) { |
|
1069 | + if ( ! $mtt instanceof EE_Message_Template) { |
|
1070 | 1070 | continue; |
1071 | 1071 | } |
1072 | 1072 | $nmtt = clone $mtt; |
1073 | - $nmtt->set( 'MTP_ID', 0 ); |
|
1074 | - $nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1073 | + $nmtt->set('MTP_ID', 0); |
|
1074 | + $nmtt->set('GRP_ID', $new_mtg->ID()); //relation |
|
1075 | 1075 | $nmtt->save(); |
1076 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1077 | - $success[ 'MTP_context' ] = $nmtt->get( 'MTP_context' ); |
|
1076 | + if (empty($success['MTP_context'])) { |
|
1077 | + $success['MTP_context'] = $nmtt->get('MTP_context'); |
|
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | return $success; |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | $global = false |
1097 | 1097 | ) { |
1098 | 1098 | //is given message_type valid for given messenger (if this is not a global save) |
1099 | - if ( $global ) { |
|
1099 | + if ($global) { |
|
1100 | 1100 | return true; |
1101 | 1101 | } |
1102 | 1102 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | ) |
1109 | 1109 | ) |
1110 | 1110 | ); |
1111 | - if ( $active_templates > 0 ) { |
|
1111 | + if ($active_templates > 0) { |
|
1112 | 1112 | return true; |
1113 | 1113 | } |
1114 | 1114 | EE_Error::add_error( |
@@ -1137,24 +1137,24 @@ discard block |
||
1137 | 1137 | * @param string $message_type_name name of EE_message_type |
1138 | 1138 | * @return array |
1139 | 1139 | */ |
1140 | - public static function get_fields( $messenger_name, $message_type_name ) { |
|
1140 | + public static function get_fields($messenger_name, $message_type_name) { |
|
1141 | 1141 | $template_fields = array(); |
1142 | 1142 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1143 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1144 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1145 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1146 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1143 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1144 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1145 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1146 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1147 | 1147 | return array(); |
1148 | 1148 | } |
1149 | 1149 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1150 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1151 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1152 | - $template_fields[ $context ][ $field ] = $value; |
|
1150 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1151 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1152 | + $template_fields[$context][$field] = $value; |
|
1153 | 1153 | } |
1154 | 1154 | } |
1155 | - if ( empty( $template_fields ) ) { |
|
1155 | + if (empty($template_fields)) { |
|
1156 | 1156 | EE_Error::add_error( |
1157 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1157 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1158 | 1158 | __FILE__, |
1159 | 1159 | __FUNCTION__, |
1160 | 1160 | __LINE__ |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | class EE_Register_Message_Type implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Holds values for registered message types |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_message_type_registry = array(); |
|
21 | + /** |
|
22 | + * Holds values for registered message types |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_message_type_registry = array(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * @throws \EE_Error |
51 | 51 | * } |
52 | 52 | */ |
53 | - public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
53 | + public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
54 | 54 | //required fields MUST be present, so let's make sure they are. |
55 | - if ( |
|
55 | + if ( |
|
56 | 56 | ! isset( $mt_name ) |
57 | 57 | || ! is_array( $setup_args ) |
58 | 58 | || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) |
59 | 59 | ){ |
60 | - throw new EE_Error( |
|
60 | + throw new EE_Error( |
|
61 | 61 | __( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' ) |
62 | 62 | ); |
63 | 63 | } |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - //make sure this was called in the right place! |
|
71 | - if ( |
|
70 | + //make sure this was called in the right place! |
|
71 | + if ( |
|
72 | 72 | ! did_action( 'EE_Brewing_Regular___messages_caf' ) |
73 | 73 | || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ) |
74 | 74 | ) { |
75 | - EE_Error::doing_it_wrong( |
|
75 | + EE_Error::doing_it_wrong( |
|
76 | 76 | __METHOD__, |
77 | 77 | sprintf( |
78 | 78 | __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'), |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | ), |
81 | 81 | '4.3.0' |
82 | 82 | ); |
83 | - } |
|
83 | + } |
|
84 | 84 | //setup $__ee_message_type_registry array from incoming values. |
85 | 85 | self::$_ee_message_type_registry[ $mt_name ] = array( |
86 | 86 | 'mtfilename' => (string) $setup_args['mtfilename'], |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | |
129 | 129 | |
130 | 130 | |
131 | - /** |
|
132 | - * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of. |
|
133 | - */ |
|
134 | - public static function set_defaults() { |
|
131 | + /** |
|
132 | + * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of. |
|
133 | + */ |
|
134 | + public static function set_defaults() { |
|
135 | 135 | //only set defaults if we're not in EE_Maintenance mode |
136 | - EE_Registry::instance()->load_helper('Activation'); |
|
137 | - EEH_Activation::generate_default_message_templates(); |
|
136 | + EE_Registry::instance()->load_helper('Activation'); |
|
137 | + EEH_Activation::generate_default_message_templates(); |
|
138 | 138 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
139 | 139 | $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
140 | 140 | //for any message types with force activation, let's ensure they are activated |
@@ -145,20 +145,20 @@ discard block |
||
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | - /** |
|
153 | - * This deregisters a message type that was previously registered with a specific message_type_name. |
|
154 | - * |
|
155 | - * @since 4.3.0 |
|
156 | - * |
|
157 | - * @param string $message_type_name the name for the message type that was previously registered |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public static function deregister( $message_type_name = NULL ) { |
|
161 | - if ( ! empty( self::$_ee_message_type_registry[$message_type_name] ) ) { |
|
152 | + /** |
|
153 | + * This deregisters a message type that was previously registered with a specific message_type_name. |
|
154 | + * |
|
155 | + * @since 4.3.0 |
|
156 | + * |
|
157 | + * @param string $message_type_name the name for the message type that was previously registered |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public static function deregister( $message_type_name = NULL ) { |
|
161 | + if ( ! empty( self::$_ee_message_type_registry[$message_type_name] ) ) { |
|
162 | 162 | //let's make sure that we remove any place this message type was made active |
163 | 163 | EE_Registry::instance()->load_helper( 'MSG_Template' ); |
164 | 164 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
@@ -169,118 +169,118 @@ discard block |
||
169 | 169 | } |
170 | 170 | EEH_MSG_Template::update_to_inactive( '', $message_type_name ); |
171 | 171 | EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
172 | - unset( self::$_ee_message_type_registry[$message_type_name] ); |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
180 | - * |
|
181 | - * @since 4.3.0 |
|
182 | - * |
|
183 | - * @param array $messagetype_files The current array of message type file names |
|
184 | - * @return array Array of message type file names |
|
185 | - */ |
|
186 | - public static function register_messagetype_files( $messagetype_files ) { |
|
187 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
188 | - return $messagetype_files; |
|
172 | + unset( self::$_ee_message_type_registry[$message_type_name] ); |
|
189 | 173 | } |
190 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
191 | - if ( empty( $mt_reg['mtfilename' ] ) ) { |
|
192 | - continue; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
180 | + * |
|
181 | + * @since 4.3.0 |
|
182 | + * |
|
183 | + * @param array $messagetype_files The current array of message type file names |
|
184 | + * @return array Array of message type file names |
|
185 | + */ |
|
186 | + public static function register_messagetype_files( $messagetype_files ) { |
|
187 | + if ( empty( self::$_ee_message_type_registry ) ) { |
|
188 | + return $messagetype_files; |
|
189 | + } |
|
190 | + foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
191 | + if ( empty( $mt_reg['mtfilename' ] ) ) { |
|
192 | + continue; |
|
193 | 193 | } |
194 | - $messagetype_files[] = $mt_reg['mtfilename']; |
|
195 | - } |
|
196 | - return $messagetype_files; |
|
197 | - } |
|
194 | + $messagetype_files[] = $mt_reg['mtfilename']; |
|
195 | + } |
|
196 | + return $messagetype_files; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | 201 | |
202 | 202 | |
203 | - /** |
|
204 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
205 | - * |
|
206 | - * @since 4.3.0 |
|
207 | - * |
|
208 | - * @param array $paths array of paths to be checked by EE_Messages autoloader. |
|
209 | - * @return array |
|
210 | - */ |
|
211 | - public static function register_msgs_autoload_paths( $paths ) { |
|
212 | - if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
213 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
214 | - if ( empty( $mt_reg['autoloadpaths'] ) ) { |
|
215 | - continue; |
|
203 | + /** |
|
204 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
205 | + * |
|
206 | + * @since 4.3.0 |
|
207 | + * |
|
208 | + * @param array $paths array of paths to be checked by EE_Messages autoloader. |
|
209 | + * @return array |
|
210 | + */ |
|
211 | + public static function register_msgs_autoload_paths( $paths ) { |
|
212 | + if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
213 | + foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
214 | + if ( empty( $mt_reg['autoloadpaths'] ) ) { |
|
215 | + continue; |
|
216 | 216 | } |
217 | - $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
218 | - } |
|
219 | - } |
|
220 | - return $paths; |
|
221 | - } |
|
217 | + $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
218 | + } |
|
219 | + } |
|
220 | + return $paths; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | |
224 | 224 | |
225 | 225 | |
226 | 226 | |
227 | - /** |
|
228 | - * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
229 | - * |
|
230 | - * @since 4.3.0 |
|
231 | - * @param array $default_types array of message types activated with messenger ( |
|
232 | - * corresponds to the $name property of message type) |
|
233 | - * @param EE_Messenger $messenger The EE_messenger the filter is called from. |
|
234 | - * @return array |
|
235 | - */ |
|
236 | - public static function register_messengers_to_activate_mt_with( $default_types, EE_Messenger $messenger ) { |
|
237 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
238 | - return $default_types; |
|
227 | + /** |
|
228 | + * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
229 | + * |
|
230 | + * @since 4.3.0 |
|
231 | + * @param array $default_types array of message types activated with messenger ( |
|
232 | + * corresponds to the $name property of message type) |
|
233 | + * @param EE_Messenger $messenger The EE_messenger the filter is called from. |
|
234 | + * @return array |
|
235 | + */ |
|
236 | + public static function register_messengers_to_activate_mt_with( $default_types, EE_Messenger $messenger ) { |
|
237 | + if ( empty( self::$_ee_message_type_registry ) ) { |
|
238 | + return $default_types; |
|
239 | 239 | } |
240 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
241 | - if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
242 | - continue; |
|
240 | + foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
241 | + if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
242 | + continue; |
|
243 | 243 | } |
244 | - // loop through each of the messengers and if it matches the loaded class |
|
244 | + // loop through each of the messengers and if it matches the loaded class |
|
245 | 245 | // then we add this message type to the |
246 | - foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
247 | - if ( $messenger->name == $msgr ) { |
|
248 | - $default_types[] = $message_type_name; |
|
249 | - } |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - return $default_types; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
260 | - * |
|
261 | - * @since 4.3.0 |
|
262 | - * @param array $valid_types array of message types valid with messenger ( |
|
263 | - * corresponds to the $name property of message type) |
|
264 | - * @param EE_Messenger $messenger The EE_messenger the filter is called from. |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - public static function register_messengers_to_validate_mt_with( $valid_types, EE_Messenger $messenger ) { |
|
268 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
269 | - return $valid_types; |
|
246 | + foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
247 | + if ( $messenger->name == $msgr ) { |
|
248 | + $default_types[] = $message_type_name; |
|
249 | + } |
|
250 | + } |
|
270 | 251 | } |
271 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
272 | - if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
273 | - continue; |
|
252 | + |
|
253 | + return $default_types; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
260 | + * |
|
261 | + * @since 4.3.0 |
|
262 | + * @param array $valid_types array of message types valid with messenger ( |
|
263 | + * corresponds to the $name property of message type) |
|
264 | + * @param EE_Messenger $messenger The EE_messenger the filter is called from. |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + public static function register_messengers_to_validate_mt_with( $valid_types, EE_Messenger $messenger ) { |
|
268 | + if ( empty( self::$_ee_message_type_registry ) ) { |
|
269 | + return $valid_types; |
|
270 | + } |
|
271 | + foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
272 | + if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
273 | + continue; |
|
274 | 274 | } |
275 | - // loop through each of the messengers and if it matches the loaded class |
|
275 | + // loop through each of the messengers and if it matches the loaded class |
|
276 | 276 | // then we add this message type to the |
277 | - foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
278 | - if ( $messenger->name == $msgr ) { |
|
279 | - $valid_types[] = $message_type_name; |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
283 | - |
|
284 | - return $valid_types; |
|
285 | - } |
|
277 | + foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
278 | + if ( $messenger->name == $msgr ) { |
|
279 | + $valid_types[] = $message_type_name; |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + |
|
284 | + return $valid_types; |
|
285 | + } |
|
286 | 286 | } |
@@ -50,79 +50,79 @@ discard block |
||
50 | 50 | * @throws \EE_Error |
51 | 51 | * } |
52 | 52 | */ |
53 | - public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
53 | + public static function register($mt_name = NULL, $setup_args = array()) { |
|
54 | 54 | //required fields MUST be present, so let's make sure they are. |
55 | 55 | if ( |
56 | - ! isset( $mt_name ) |
|
57 | - || ! is_array( $setup_args ) |
|
58 | - || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) |
|
59 | - ){ |
|
56 | + ! isset($mt_name) |
|
57 | + || ! is_array($setup_args) |
|
58 | + || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
59 | + ) { |
|
60 | 60 | throw new EE_Error( |
61 | - __( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' ) |
|
61 | + __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | //make sure we don't register twice |
66 | - if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){ |
|
66 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | 70 | //make sure this was called in the right place! |
71 | 71 | if ( |
72 | - ! did_action( 'EE_Brewing_Regular___messages_caf' ) |
|
73 | - || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ) |
|
72 | + ! did_action('EE_Brewing_Regular___messages_caf') |
|
73 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
74 | 74 | ) { |
75 | 75 | EE_Error::doing_it_wrong( |
76 | 76 | __METHOD__, |
77 | 77 | sprintf( |
78 | - __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'), |
|
78 | + __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', 'event_espresso'), |
|
79 | 79 | $mt_name |
80 | 80 | ), |
81 | 81 | '4.3.0' |
82 | 82 | ); |
83 | 83 | } |
84 | 84 | //setup $__ee_message_type_registry array from incoming values. |
85 | - self::$_ee_message_type_registry[ $mt_name ] = array( |
|
85 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
86 | 86 | 'mtfilename' => (string) $setup_args['mtfilename'], |
87 | 87 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
88 | - 'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) |
|
88 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
89 | 89 | ? (array) $setup_args['messengers_to_activate_with'] |
90 | 90 | : array(), |
91 | - 'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) |
|
91 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
92 | 92 | ? (array) $setup_args['messengers_to_validate_with'] |
93 | 93 | : array(), |
94 | - 'force_activation' => ! empty( $setup_args['force_activation'] ) |
|
94 | + 'force_activation' => ! empty($setup_args['force_activation']) |
|
95 | 95 | ? (bool) $setup_args['force_activation'] |
96 | 96 | : array() |
97 | 97 | ); |
98 | 98 | //add filters |
99 | 99 | add_filter( |
100 | 100 | 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
101 | - array( 'EE_Register_Message_Type', 'register_msgs_autoload_paths' ), |
|
101 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
102 | 102 | 10 |
103 | 103 | ); |
104 | 104 | add_filter( |
105 | 105 | 'FHEE__EE_messages__get_installed__messagetype_files', |
106 | - array( 'EE_Register_Message_Type', 'register_messagetype_files' ), |
|
106 | + array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
107 | 107 | 10, |
108 | 108 | 1 |
109 | 109 | ); |
110 | 110 | add_filter( |
111 | 111 | 'FHEE__EE_messenger__get_default_message_types__default_types', |
112 | - array( 'EE_Register_Message_Type', 'register_messengers_to_activate_mt_with' ), |
|
112 | + array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
113 | 113 | 10, |
114 | 114 | 2 |
115 | 115 | ); |
116 | 116 | add_filter( |
117 | 117 | 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
118 | - array( 'EE_Register_Message_Type', 'register_messengers_to_validate_mt_with' ), |
|
118 | + array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
119 | 119 | 10, |
120 | 120 | 2 |
121 | 121 | ); |
122 | 122 | //actions |
123 | 123 | add_action( |
124 | 124 | 'AHEE__EE_Addon__initialize_default_data__begin', |
125 | - array( 'EE_Register_Message_Type', 'set_defaults' ) |
|
125 | + array('EE_Register_Message_Type', 'set_defaults') |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 | |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | EE_Registry::instance()->load_helper('Activation'); |
137 | 137 | EEH_Activation::generate_default_message_templates(); |
138 | 138 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
139 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
139 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
140 | 140 | //for any message types with force activation, let's ensure they are activated |
141 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $settings ) { |
|
142 | - if ( $settings['force_activation'] ) { |
|
143 | - foreach ( $settings['messengers_to_activate_with'] as $messenger ) { |
|
144 | - $message_resource_manager->ensure_message_type_is_active( $message_type_name, $messenger ); |
|
141 | + foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
142 | + if ($settings['force_activation']) { |
|
143 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
144 | + $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | * @param string $message_type_name the name for the message type that was previously registered |
158 | 158 | * @return void |
159 | 159 | */ |
160 | - public static function deregister( $message_type_name = NULL ) { |
|
161 | - if ( ! empty( self::$_ee_message_type_registry[$message_type_name] ) ) { |
|
160 | + public static function deregister($message_type_name = NULL) { |
|
161 | + if ( ! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
162 | 162 | //let's make sure that we remove any place this message type was made active |
163 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
163 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
164 | 164 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
165 | - foreach( $active_messengers as $messenger => $settings ) { |
|
166 | - if ( !empty( $settings['settings'][$messenger . '-message_types'][$message_type_name] ) ) { |
|
167 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type_name] ); |
|
165 | + foreach ($active_messengers as $messenger => $settings) { |
|
166 | + if ( ! empty($settings['settings'][$messenger.'-message_types'][$message_type_name])) { |
|
167 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type_name]); |
|
168 | 168 | } |
169 | 169 | } |
170 | - EEH_MSG_Template::update_to_inactive( '', $message_type_name ); |
|
171 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
172 | - unset( self::$_ee_message_type_registry[$message_type_name] ); |
|
170 | + EEH_MSG_Template::update_to_inactive('', $message_type_name); |
|
171 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
172 | + unset(self::$_ee_message_type_registry[$message_type_name]); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | * @param array $messagetype_files The current array of message type file names |
184 | 184 | * @return array Array of message type file names |
185 | 185 | */ |
186 | - public static function register_messagetype_files( $messagetype_files ) { |
|
187 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
186 | + public static function register_messagetype_files($messagetype_files) { |
|
187 | + if (empty(self::$_ee_message_type_registry)) { |
|
188 | 188 | return $messagetype_files; |
189 | 189 | } |
190 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
191 | - if ( empty( $mt_reg['mtfilename' ] ) ) { |
|
190 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
191 | + if (empty($mt_reg['mtfilename'])) { |
|
192 | 192 | continue; |
193 | 193 | } |
194 | 194 | $messagetype_files[] = $mt_reg['mtfilename']; |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | * @param array $paths array of paths to be checked by EE_Messages autoloader. |
209 | 209 | * @return array |
210 | 210 | */ |
211 | - public static function register_msgs_autoload_paths( $paths ) { |
|
212 | - if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
213 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
214 | - if ( empty( $mt_reg['autoloadpaths'] ) ) { |
|
211 | + public static function register_msgs_autoload_paths($paths) { |
|
212 | + if ( ! empty(self::$_ee_message_type_registry)) { |
|
213 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
214 | + if (empty($mt_reg['autoloadpaths'])) { |
|
215 | 215 | continue; |
216 | 216 | } |
217 | - $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
217 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | return $paths; |
@@ -233,18 +233,18 @@ discard block |
||
233 | 233 | * @param EE_Messenger $messenger The EE_messenger the filter is called from. |
234 | 234 | * @return array |
235 | 235 | */ |
236 | - public static function register_messengers_to_activate_mt_with( $default_types, EE_Messenger $messenger ) { |
|
237 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
236 | + public static function register_messengers_to_activate_mt_with($default_types, EE_Messenger $messenger) { |
|
237 | + if (empty(self::$_ee_message_type_registry)) { |
|
238 | 238 | return $default_types; |
239 | 239 | } |
240 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
241 | - if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
240 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
241 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | // loop through each of the messengers and if it matches the loaded class |
245 | 245 | // then we add this message type to the |
246 | - foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
247 | - if ( $messenger->name == $msgr ) { |
|
246 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
247 | + if ($messenger->name == $msgr) { |
|
248 | 248 | $default_types[] = $message_type_name; |
249 | 249 | } |
250 | 250 | } |
@@ -264,18 +264,18 @@ discard block |
||
264 | 264 | * @param EE_Messenger $messenger The EE_messenger the filter is called from. |
265 | 265 | * @return array |
266 | 266 | */ |
267 | - public static function register_messengers_to_validate_mt_with( $valid_types, EE_Messenger $messenger ) { |
|
268 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
267 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_Messenger $messenger) { |
|
268 | + if (empty(self::$_ee_message_type_registry)) { |
|
269 | 269 | return $valid_types; |
270 | 270 | } |
271 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
272 | - if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
271 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
272 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
273 | 273 | continue; |
274 | 274 | } |
275 | 275 | // loop through each of the messengers and if it matches the loaded class |
276 | 276 | // then we add this message type to the |
277 | - foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
278 | - if ( $messenger->name == $msgr ) { |
|
277 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
278 | + if ($messenger->name == $msgr) { |
|
279 | 279 | $valid_types[] = $message_type_name; |
280 | 280 | } |
281 | 281 | } |