@@ -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 | /** |
@@ -36,25 +36,25 @@ discard block |
||
36 | 36 | |
37 | 37 | |
38 | 38 | private function _do_hooks() { |
39 | - add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10 ); |
|
40 | - add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10 ); |
|
41 | - add_filter('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array( $this, 'forums_lazy_loading'), 10 ); |
|
42 | - add_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content', array( $this, 'extra_news_box_content' ), 10 ); |
|
39 | + add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10); |
|
40 | + add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10); |
|
41 | + add_filter('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array($this, 'forums_lazy_loading'), 10); |
|
42 | + add_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content', array($this, 'extra_news_box_content'), 10); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - public function extra_news_box_content( $content ) { |
|
49 | - echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
48 | + public function extra_news_box_content($content) { |
|
49 | + echo '<h3 style="margin:0">'.__('From the Forums', 'event_espresso').'</h3>'; |
|
50 | 50 | echo '<div id="ee_forum_posts_content">'; |
51 | 51 | $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
52 | - EE_Admin_Page::cached_rss_display( 'ee_forum_posts_content', $url); |
|
52 | + EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
|
53 | 53 | echo '</div>'; |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | - public function forums_lazy_loading( $ids ) { |
|
57 | + public function forums_lazy_loading($ids) { |
|
58 | 58 | $ids[] = 'ee_forum_posts_content'; |
59 | 59 | return $ids; |
60 | 60 | } |
@@ -2,18 +2,18 @@ |
||
2 | 2 | <p> |
3 | 3 | <?php _e('The importer can be used to import event information into Event Espresso using a CSV file.', 'event_espresso'); ?> |
4 | 4 | </p> |
5 | -<p><strong><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso');?></strong></p> |
|
5 | +<p><strong><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso'); ?></strong></p> |
|
6 | 6 | <p> |
7 | 7 | <?php _e('To import Event Espresso data from another Event Espresso 4 install, export a CSV file from the admin Events overview page, or anywhere you can generate a CSV export file from. Then upload that file here (regardless of what type of information was exported).', 'event_espresso'); ?> |
8 | 8 | </p> |
9 | 9 | <p> |
10 | 10 | <?php _e('Note: its possible that data from the other site have the same IDs as data in this site. The importer recognizes that this data is from a different database and inserts new items for each item in the CSV file, regardless of whether its ID matches that of an item in this site\'s database or not. However, the importer also remembers the mapping from the old site\'s database to this site\'s database, and on subsequent CSV importers from that site, the data in this database will be updated instead of re-inserting new items.', 'event_espresso'); ?> |
11 | 11 | </p> |
12 | -<p><strong><?php _e("Importing from this Site", 'event_espresso');?></strong></p> |
|
13 | -<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso');?></p> |
|
12 | +<p><strong><?php _e("Importing from this Site", 'event_espresso'); ?></strong></p> |
|
13 | +<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso'); ?></p> |
|
14 | 14 | |
15 | - <p><strong><?php _e("Notes about Generating your own CSV Import Files", "event_espresso");?></strong></p> |
|
16 | - <p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso");?></p> |
|
17 | - <p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso");?></p> |
|
18 | - <p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso");?></p> |
|
19 | - <p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso");?></p> |
|
20 | 15 | \ No newline at end of file |
16 | + <p><strong><?php _e("Notes about Generating your own CSV Import Files", "event_espresso"); ?></strong></p> |
|
17 | + <p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso"); ?></p> |
|
18 | + <p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso"); ?></p> |
|
19 | + <p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso"); ?></p> |
|
20 | + <p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso"); ?></p> |
|
21 | 21 | \ No newline at end of file |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Integer_Field.php'); |
|
3 | -class EE_Boolean_Field extends EE_Integer_Field{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Integer_Field.php'); |
|
3 | +class EE_Boolean_Field extends EE_Integer_Field { |
|
4 | 4 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
5 | - if ($value_inputted_for_field_on_model_object){ |
|
5 | + if ($value_inputted_for_field_on_model_object) { |
|
6 | 6 | return true; |
7 | - }else{ |
|
7 | + } else { |
|
8 | 8 | return false; |
9 | 9 | } |
10 | 10 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @return boolean |
15 | 15 | */ |
16 | 16 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
17 | - return intval( $value_inputted_for_field_on_model_object ) ? true : false; |
|
17 | + return intval($value_inputted_for_field_on_model_object) ? true : false; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @param boolean $value_on_field_to_be_outputted |
23 | 23 | * @return string Yes or No |
24 | 24 | */ |
25 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted ) { |
|
25 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted) { |
|
26 | 26 | return apply_filters( |
27 | 27 | 'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return', |
28 | - $value_on_field_to_be_outputted ? __( 'Yes', 'event_espresso' ) : __( 'No', 'event_espresso' ), |
|
28 | + $value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'), |
|
29 | 29 | $value_on_field_to_be_outputted |
30 | 30 | ); |
31 | 31 | } |
@@ -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 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @subpackage includes/classes/EE_Payment.class.php |
23 | 23 | * @author Brent Christensen |
24 | 24 | */ |
25 | -class EE_Payment extends EE_Base_Class implements EEI_Payment{ |
|
25 | +class EE_Payment extends EE_Base_Class implements EEI_Payment { |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * date_format and the second value is the time format |
34 | 34 | * @return EE_Attendee |
35 | 35 | */ |
36 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
37 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
38 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
36 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
37 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
38 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * the website will be used. |
47 | 47 | * @return EE_Attendee |
48 | 48 | */ |
49 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
50 | - return new self( $props_n_values, TRUE, $timezone ); |
|
49 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
50 | + return new self($props_n_values, TRUE, $timezone); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @access public |
59 | 59 | * @param int $TXN_ID |
60 | 60 | */ |
61 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
62 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
61 | + public function set_transaction_id($TXN_ID = 0) { |
|
62 | + $this->set('TXN_ID', $TXN_ID); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return EE_Transaction |
70 | 70 | */ |
71 | 71 | public function transaction() { |
72 | - return $this->get_first_related( 'Transaction' ); |
|
72 | + return $this->get_first_related('Transaction'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @access public |
81 | 81 | * @param string $STS_ID |
82 | 82 | */ |
83 | - public function set_status( $STS_ID = '' ) { |
|
84 | - $this->set( 'STS_ID', $STS_ID ); |
|
83 | + public function set_status($STS_ID = '') { |
|
84 | + $this->set('STS_ID', $STS_ID); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @access public |
93 | 93 | * @param int $timestamp |
94 | 94 | */ |
95 | - public function set_timestamp( $timestamp = 0 ) { |
|
96 | - $this->set( 'PAY_timestamp', $timestamp ); |
|
95 | + public function set_timestamp($timestamp = 0) { |
|
96 | + $this->set('PAY_timestamp', $timestamp); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @access public |
105 | 105 | * @param string $PAY_source |
106 | 106 | */ |
107 | - public function set_source( $PAY_source = '' ) { |
|
108 | - $this->set('PAY_source',$PAY_source); |
|
107 | + public function set_source($PAY_source = '') { |
|
108 | + $this->set('PAY_source', $PAY_source); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @access public |
117 | 117 | * @param float $amount |
118 | 118 | */ |
119 | - public function set_amount( $amount = 0.00 ) { |
|
120 | - $this->set( 'PAY_amount', $amount ); |
|
119 | + public function set_amount($amount = 0.00) { |
|
120 | + $this->set('PAY_amount', $amount); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @access public |
129 | 129 | * @param string $gateway_response |
130 | 130 | */ |
131 | - public function set_gateway_response( $gateway_response = '' ) { |
|
132 | - $this->set( 'PAY_gateway_response', $gateway_response ); |
|
131 | + public function set_gateway_response($gateway_response = '') { |
|
132 | + $this->set('PAY_gateway_response', $gateway_response); |
|
133 | 133 | } |
134 | 134 | /** |
135 | 135 | * Returns the name of the paymetn method used on this payment (previously known merely as 'gateway') |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @deprecated |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function gateway(){ |
|
142 | - EE_Error::doing_it_wrong('EE_Payment::gateway', __( 'The method EE_Payment::gateway() has been deprecated. Consider instead using EE_Payment::payment_method()->name()', 'event_espresso' ), '4.6.0' ); |
|
143 | - if( $this->payment_method() ){ |
|
141 | + public function gateway() { |
|
142 | + EE_Error::doing_it_wrong('EE_Payment::gateway', __('The method EE_Payment::gateway() has been deprecated. Consider instead using EE_Payment::payment_method()->name()', 'event_espresso'), '4.6.0'); |
|
143 | + if ($this->payment_method()) { |
|
144 | 144 | return $this->payment_method()->name(); |
145 | - }else{ |
|
146 | - return __( 'Unknown', 'event_espresso' ); |
|
145 | + } else { |
|
146 | + return __('Unknown', 'event_espresso'); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @access public |
156 | 156 | * @param string $txn_id_chq_nmbr |
157 | 157 | */ |
158 | - public function set_txn_id_chq_nmbr( $txn_id_chq_nmbr = '' ) { |
|
159 | - $this->set( 'PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr ); |
|
158 | + public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '') { |
|
159 | + $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @access public |
168 | 168 | * @param string $po_number |
169 | 169 | */ |
170 | - public function set_po_number( $po_number = '' ) { |
|
171 | - $this->set( 'PAY_po_number', $po_number ); |
|
170 | + public function set_po_number($po_number = '') { |
|
171 | + $this->set('PAY_po_number', $po_number); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * @access public |
180 | 180 | * @param string $extra_accntng |
181 | 181 | */ |
182 | - public function set_extra_accntng( $extra_accntng = '' ) { |
|
183 | - $this->set( 'PAY_extra_accntng', $extra_accntng ); |
|
182 | + public function set_extra_accntng($extra_accntng = '') { |
|
183 | + $this->set('PAY_extra_accntng', $extra_accntng); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | * @access public |
192 | 192 | * @param bool $via_admin |
193 | 193 | */ |
194 | - public function set_payment_made_via_admin( $via_admin = FALSE ) { |
|
195 | - if($via_admin){ |
|
196 | - $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
197 | - }else{ |
|
194 | + public function set_payment_made_via_admin($via_admin = FALSE) { |
|
195 | + if ($via_admin) { |
|
196 | + $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
197 | + } else { |
|
198 | 198 | $this->set('PAY_source', EEM_Payment_Method::scope_cart); |
199 | 199 | } |
200 | 200 | |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | * @access public |
209 | 209 | * @param string $details |
210 | 210 | */ |
211 | - public function set_details( $details = '' ) { |
|
212 | - if ( is_array( $details ) ) { |
|
213 | - array_walk_recursive( $details, array( $this, '_strip_all_tags_within_array' )); |
|
211 | + public function set_details($details = '') { |
|
212 | + if (is_array($details)) { |
|
213 | + array_walk_recursive($details, array($this, '_strip_all_tags_within_array')); |
|
214 | 214 | } else { |
215 | - $details = wp_strip_all_tags( $details ); |
|
215 | + $details = wp_strip_all_tags($details); |
|
216 | 216 | } |
217 | - $this->set( 'PAY_details', $details ); |
|
217 | + $this->set('PAY_details', $details); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @access public |
241 | 241 | */ |
242 | 242 | public function TXN_ID() { |
243 | - return $this->get( 'TXN_ID' ); |
|
243 | + return $this->get('TXN_ID'); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | * @param null $date_or_time |
272 | 272 | * @return string |
273 | 273 | */ |
274 | - public function timestamp( $dt_frmt = '', $tm_frmt = '', $date_or_time = NULL ) { |
|
275 | - return $this->get_datetime('PAY_timestamp', $dt_frmt, $tm_frmt, $date_or_time ); |
|
274 | + public function timestamp($dt_frmt = '', $tm_frmt = '', $date_or_time = NULL) { |
|
275 | + return $this->get_datetime('PAY_timestamp', $dt_frmt, $tm_frmt, $date_or_time); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @return float |
294 | 294 | */ |
295 | 295 | public function amount() { |
296 | - return $this->get( 'PAY_amount' ); |
|
296 | + return $this->get('PAY_amount'); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return mixed |
303 | 303 | */ |
304 | 304 | public function amount_no_code() { |
305 | - return $this->get_pretty( 'PAY_amount', 'no_currency_code' ); |
|
305 | + return $this->get_pretty('PAY_amount', 'no_currency_code'); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @access public |
313 | 313 | */ |
314 | 314 | public function gateway_response() { |
315 | - return $this->get( 'PAY_gateway_response' ); |
|
315 | + return $this->get('PAY_gateway_response'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @access public |
323 | 323 | */ |
324 | 324 | public function txn_id_chq_nmbr() { |
325 | - return $this->get( 'PAY_txn_id_chq_nmbr' ); |
|
325 | + return $this->get('PAY_txn_id_chq_nmbr'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @access public |
333 | 333 | */ |
334 | 334 | public function po_number() { |
335 | - return $this->get( 'PAY_po_number' ); |
|
335 | + return $this->get('PAY_po_number'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @access public |
343 | 343 | */ |
344 | 344 | public function extra_accntng() { |
345 | - return $this->get( 'PAY_extra_accntng' ); |
|
345 | + return $this->get('PAY_extra_accntng'); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @access public |
363 | 363 | */ |
364 | 364 | public function details() { |
365 | - return $this->get( 'PAY_details' ); |
|
365 | + return $this->get('PAY_details'); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | * @param bool $show_icons |
392 | 392 | * @return void |
393 | 393 | */ |
394 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
395 | - echo $this->pretty_status( $show_icons ); |
|
394 | + public function e_pretty_status($show_icons = FALSE) { |
|
395 | + echo $this->pretty_status($show_icons); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | * @param bool $show_icons |
403 | 403 | * @return string |
404 | 404 | */ |
405 | - public function pretty_status( $show_icons = FALSE ) { |
|
406 | - $status = EEM_Status::instance()->localized_status( array( $this->STS_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
405 | + public function pretty_status($show_icons = FALSE) { |
|
406 | + $status = EEM_Status::instance()->localized_status(array($this->STS_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
407 | 407 | $icon = ''; |
408 | - switch ( $this->STS_ID() ) { |
|
408 | + switch ($this->STS_ID()) { |
|
409 | 409 | case EEM_Payment::status_id_approved: |
410 | 410 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
411 | 411 | break; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
420 | 420 | break; |
421 | 421 | } |
422 | - return $icon . $status[ $this->STS_ID() ]; |
|
422 | + return $icon.$status[$this->STS_ID()]; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @return boolean whether the payment is approved or not |
431 | 431 | */ |
432 | 432 | public function is_approved() { |
433 | - return $this->status_is( EEM_Payment::status_id_approved ); |
|
433 | + return $this->status_is(EEM_Payment::status_id_approved); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * one of the status_id_* on the EEM_Payment model |
443 | 443 | * @return boolean whether the status of this payment equals the status id |
444 | 444 | */ |
445 | - protected function status_is( $STS_ID ) { |
|
446 | - if ( $STS_ID == $this->STS_ID() ) { |
|
445 | + protected function status_is($STS_ID) { |
|
446 | + if ($STS_ID == $this->STS_ID()) { |
|
447 | 447 | return TRUE; |
448 | 448 | } else { |
449 | 449 | return FALSE; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @return boolean whether the payment is pending or not |
458 | 458 | */ |
459 | 459 | public function is_pending() { |
460 | - return $this->status_is( EEM_Payment::status_id_pending ); |
|
460 | + return $this->status_is(EEM_Payment::status_id_pending); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @return boolean |
468 | 468 | */ |
469 | 469 | public function is_cancelled() { |
470 | - return $this->status_is( EEM_Payment::status_id_cancelled ); |
|
470 | + return $this->status_is(EEM_Payment::status_id_cancelled); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return boolean |
478 | 478 | */ |
479 | 479 | public function is_declined() { |
480 | - return $this->status_is( EEM_Payment::status_id_declined ); |
|
480 | + return $this->status_is(EEM_Payment::status_id_declined); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @return boolean |
488 | 488 | */ |
489 | 489 | public function is_failed() { |
490 | - return $this->status_is( EEM_Payment::status_id_failed ); |
|
490 | + return $this->status_is(EEM_Payment::status_id_failed); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @return EE_Status |
508 | 508 | */ |
509 | 509 | public function status_obj() { |
510 | - return $this->get_first_related( 'Status' ); |
|
510 | + return $this->get_first_related('Status'); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | * @param array $query_params like EEM_Base::get_all |
518 | 518 | * @return EE_Extra_Meta |
519 | 519 | */ |
520 | - public function extra_meta( $query_params = array() ) { |
|
521 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
520 | + public function extra_meta($query_params = array()) { |
|
521 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * offline ones, dont' create payments) |
530 | 530 | * @return EE_Payment_Method |
531 | 531 | */ |
532 | - function payment_method(){ |
|
532 | + function payment_method() { |
|
533 | 533 | return $this->get_first_related('Payment_Method'); |
534 | 534 | } |
535 | 535 | |
@@ -546,12 +546,12 @@ discard block |
||
546 | 546 | * @param string $inside_form_html |
547 | 547 | * @return string html |
548 | 548 | */ |
549 | - function redirect_form( $inside_form_html = NULL ) { |
|
549 | + function redirect_form($inside_form_html = NULL) { |
|
550 | 550 | $redirect_url = $this->redirect_url(); |
551 | - if ( ! empty( $redirect_url )) { |
|
551 | + if ( ! empty($redirect_url)) { |
|
552 | 552 | EE_Registry::instance()->load_helper('HTML'); |
553 | 553 | // what ? no inner form content? |
554 | - if( $inside_form_html === NULL ) { |
|
554 | + if ($inside_form_html === NULL) { |
|
555 | 555 | $inside_form_html = EEH_HTML::p( |
556 | 556 | sprintf( |
557 | 557 | __('If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s', 'event_espresso'), |
@@ -569,17 +569,17 @@ discard block |
||
569 | 569 | ); |
570 | 570 | //if it's a GET request, we need to remove all the GET params in the querystring |
571 | 571 | //and put them into the form instead |
572 | - if( $method == 'GET' ) { |
|
573 | - $querystring = parse_url( $redirect_url, PHP_URL_QUERY ); |
|
572 | + if ($method == 'GET') { |
|
573 | + $querystring = parse_url($redirect_url, PHP_URL_QUERY); |
|
574 | 574 | $get_params = null; |
575 | - parse_str( $querystring, $get_params ); |
|
576 | - $inside_form_html .= $this->_args_as_inputs( $get_params ); |
|
577 | - $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
|
575 | + parse_str($querystring, $get_params); |
|
576 | + $inside_form_html .= $this->_args_as_inputs($get_params); |
|
577 | + $redirect_url = str_replace('?'.$querystring, '', $redirect_url); |
|
578 | 578 | } |
579 | - $form = EEH_HTML::nl(1) . '<form method="' . $method . '" name="gateway_form" action="' . $redirect_url . '">'; |
|
580 | - $form .= EEH_HTML::nl(1) . $this->redirect_args_as_inputs(); |
|
579 | + $form = EEH_HTML::nl(1).'<form method="'.$method.'" name="gateway_form" action="'.$redirect_url.'">'; |
|
580 | + $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs(); |
|
581 | 581 | $form .= $inside_form_html; |
582 | - $form .= EEH_HTML::nl(-1) . '</form>' . EEH_HTML::nl(-1); |
|
582 | + $form .= EEH_HTML::nl(-1).'</form>'.EEH_HTML::nl(-1); |
|
583 | 583 | return $form; |
584 | 584 | } else { |
585 | 585 | return NULL; |
@@ -594,8 +594,8 @@ discard block |
||
594 | 594 | * and returns the html as a string |
595 | 595 | * @return string |
596 | 596 | */ |
597 | - function redirect_args_as_inputs(){ |
|
598 | - return $this->_args_as_inputs( $this->redirect_args() ); |
|
597 | + function redirect_args_as_inputs() { |
|
598 | + return $this->_args_as_inputs($this->redirect_args()); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -604,12 +604,12 @@ discard block |
||
604 | 604 | * @param array $args key-value pairs |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - protected function _args_as_inputs( $args ) { |
|
607 | + protected function _args_as_inputs($args) { |
|
608 | 608 | $html = ''; |
609 | - if( $args !== NULL && is_array( $args )) { |
|
609 | + if ($args !== NULL && is_array($args)) { |
|
610 | 610 | EE_Registry::instance()->load_helper('HTML'); |
611 | - foreach( $args as $name => $value){ |
|
612 | - $html .= EEH_HTML::nl(0) . '<input type="hidden" name="' . $name . '" value="' . esc_attr( $value ) . '"/>'; |
|
611 | + foreach ($args as $name => $value) { |
|
612 | + $html .= EEH_HTML::nl(0).'<input type="hidden" name="'.$name.'" value="'.esc_attr($value).'"/>'; |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | return $html; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * object itself) |
625 | 625 | * @return string for the currency code |
626 | 626 | */ |
627 | - public function currency_code(){ |
|
627 | + public function currency_code() { |
|
628 | 628 | return EE_Config::instance()->currency->code; |
629 | 629 | } |
630 | 630 | |
@@ -638,14 +638,14 @@ discard block |
||
638 | 638 | * @access private |
639 | 639 | * @param mixed $item |
640 | 640 | */ |
641 | - private function _strip_all_tags_within_array( &$item ) { |
|
642 | - if( is_object( $item ) ) { |
|
641 | + private function _strip_all_tags_within_array(&$item) { |
|
642 | + if (is_object($item)) { |
|
643 | 643 | $item = (array) $item; |
644 | 644 | } |
645 | - if( is_array( $item ) ){ |
|
646 | - array_walk_recursive( $item, array( $this, '_strip_all_tags_within_array' ) ); |
|
647 | - }else{ |
|
648 | - $item = wp_strip_all_tags( $item ); |
|
645 | + if (is_array($item)) { |
|
646 | + array_walk_recursive($item, array($this, '_strip_all_tags_within_array')); |
|
647 | + } else { |
|
648 | + $item = wp_strip_all_tags($item); |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * is approved and was created during this request). False otherwise. |
655 | 655 | * @return boolean |
656 | 656 | */ |
657 | - public function just_approved(){ |
|
658 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
659 | - $original_status =EEH_Array::is_set( $this->_props_n_values_provided_in_constructor, 'STS_ID', $this->get_model()->field_settings_for( 'STS_ID' )->get_default_value() ); |
|
657 | + public function just_approved() { |
|
658 | + EE_Registry::instance()->load_helper('Array'); |
|
659 | + $original_status = EEH_Array::is_set($this->_props_n_values_provided_in_constructor, 'STS_ID', $this->get_model()->field_settings_for('STS_ID')->get_default_value()); |
|
660 | 660 | $current_status = $this->status(); |
661 | - if( $original_status !== EEM_Payment::status_id_approved && $current_status === EEM_Payment::status_id_approved ){ |
|
661 | + if ($original_status !== EEM_Payment::status_id_approved && $current_status === EEM_Payment::status_id_approved) { |
|
662 | 662 | return TRUE; |
663 | - }else{ |
|
663 | + } else { |
|
664 | 664 | return FALSE; |
665 | 665 | } |
666 | 666 | } |
@@ -672,11 +672,11 @@ discard block |
||
672 | 672 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
673 | 673 | * @return mixed |
674 | 674 | */ |
675 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
676 | - if( $field_name == 'PAY_gateway' ){ |
|
675 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
676 | + if ($field_name == 'PAY_gateway') { |
|
677 | 677 | return $this->gateway(); |
678 | 678 | } |
679 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
679 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -686,8 +686,8 @@ discard block |
||
686 | 686 | * @param array $query_params like EEM_Base::get_all |
687 | 687 | * @return EE_Registration_Payment[] |
688 | 688 | */ |
689 | - public function registration_payments( $query_params = array() ) { |
|
690 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
689 | + public function registration_payments($query_params = array()) { |
|
690 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | * @since 4.8.30.rc.007 |
18 | 18 | * |
19 | 19 | */ |
20 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
21 | - exit( 'No direct script access allowed' ); |
|
20 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | + exit('No direct script access allowed'); |
|
22 | 22 | } |
23 | 23 | |
24 | -define( 'BATCH_URL', plugin_dir_url( __FILE__ ) ); |
|
24 | +define('BATCH_URL', plugin_dir_url(__FILE__)); |
|
25 | 25 | |
26 | -class EED_Batch extends EED_Module{ |
|
26 | +class EED_Batch extends EED_Module { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public static function set_hooks() { |
71 | 71 | //because this is a possibel attack vector, let's have this disabled until |
72 | 72 | //we at least have a real use for it on the frontend |
73 | - if( apply_filters( 'FHEE__EED_Batch__set_hooks__enable_frontend_batch', false ) ) { |
|
74 | - add_action( 'wp_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) ); |
|
75 | - add_filter( 'template_include', array( self::instance(), 'override_template' ), 99 ); |
|
73 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
74 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
75 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | * Initializes some hooks for the admin in order to run batch jobs |
81 | 81 | */ |
82 | 82 | public static function set_hooks_admin() { |
83 | - add_action( 'admin_menu', array( self::instance(), 'register_admin_pages' ) ); |
|
84 | - add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) ); |
|
83 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
84 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
85 | 85 | |
86 | 86 | //ajax |
87 | - add_action('wp_ajax_espresso_batch_continue',array(self::instance(),'batch_continue')); |
|
88 | - add_action('wp_ajax_espresso_batch_cleanup',array(self::instance(),'batch_cleanup')); |
|
89 | - add_action('wp_ajax_nopriv_espresso_batch_continue',array(self::instance(),'batch_continue')); |
|
90 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup',array(self::instance(),'batch_cleanup')); |
|
87 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
88 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
89 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
90 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Enqueues batch scripts on the frontend or admin, and creates a job |
95 | 95 | */ |
96 | 96 | public function enqueue_scripts() { |
97 | - if( isset( $_REQUEST[ 'espresso_batch' ] ) |
|
97 | + if (isset($_REQUEST['espresso_batch']) |
|
98 | 98 | || |
99 | 99 | ( |
100 | - isset( $_REQUEST[ 'page' ] ) |
|
101 | - && $_REQUEST[ 'page' ] == 'espresso_batch' |
|
100 | + isset($_REQUEST['page']) |
|
101 | + && $_REQUEST['page'] == 'espresso_batch' |
|
102 | 102 | ) |
103 | 103 | ) { |
104 | - switch( $this->batch_request_type() ) { |
|
104 | + switch ($this->batch_request_type()) { |
|
105 | 105 | case self::batch_job: |
106 | 106 | $this->enqueue_scripts_styles_batch_create(); |
107 | 107 | break; |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function enqueue_scripts_styles_batch_create() { |
119 | 119 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
120 | - wp_enqueue_script( 'batch_runner_init', BATCH_URL . '/assets/batch_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true ); |
|
121 | - wp_localize_script( 'batch_runner_init', 'ee_job_response', $job_response->to_array() ); |
|
122 | - wp_localize_script( 'batch_runner_init', 'ee_job_i18n', |
|
120 | + wp_enqueue_script('batch_runner_init', BATCH_URL.'/assets/batch_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
121 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
122 | + wp_localize_script('batch_runner_init', 'ee_job_i18n', |
|
123 | 123 | array( |
124 | - 'return_url' => $_REQUEST['return_url' ], |
|
124 | + 'return_url' => $_REQUEST['return_url'], |
|
125 | 125 | )); |
126 | 126 | } |
127 | 127 | |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | public function enqueue_scripts_styles_batch_file_create() { |
132 | 132 | //creates a job based on the request variable |
133 | 133 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
134 | - wp_enqueue_script( 'batch_file_runner_init', BATCH_URL . '/assets/batch_file_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true ); |
|
135 | - wp_localize_script( 'batch_file_runner_init', 'ee_job_response', $job_response->to_array() ); |
|
136 | - wp_localize_script( 'batch_file_runner_init', 'ee_job_i18n', |
|
134 | + wp_enqueue_script('batch_file_runner_init', BATCH_URL.'/assets/batch_file_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
135 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
136 | + wp_localize_script('batch_file_runner_init', 'ee_job_i18n', |
|
137 | 137 | array( |
138 | 138 | 'download_and_redirecting' => sprintf( |
139 | 139 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
140 | - '<a href="' . $_REQUEST['return_url' ] .'">', |
|
140 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
141 | 141 | '</a>' ), |
142 | - 'return_url' => $_REQUEST['return_url' ], |
|
142 | + 'return_url' => $_REQUEST['return_url'], |
|
143 | 143 | )); |
144 | 144 | } |
145 | 145 | |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
151 | 151 | */ |
152 | 152 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() { |
153 | - wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) ); |
|
154 | - wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION ); |
|
155 | - wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' )); |
|
153 | + wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery')); |
|
154 | + wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION); |
|
155 | + wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar')); |
|
156 | 156 | //just copy the bits of EE admin's eei18n that we need in the JS |
157 | - wp_localize_script( 'batch_runner', 'eei18n', array( 'ajax_url' => WP_AJAX_URL, 'is_admin' => (bool)is_admin() ) ); |
|
158 | - $job_handler_classname = stripslashes( $_GET[ 'job_handler' ] ); |
|
157 | + wp_localize_script('batch_runner', 'eei18n', array('ajax_url' => WP_AJAX_URL, 'is_admin' => (bool) is_admin())); |
|
158 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
159 | 159 | $request_data = array_diff_key( |
160 | 160 | $_REQUEST, |
161 | - array_flip( array( 'action', 'page', 'ee', 'batch' ) ) ); |
|
161 | + array_flip(array('action', 'page', 'ee', 'batch')) ); |
|
162 | 162 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
163 | 163 | //eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
164 | - $job_response = $batch_runner->create_job( $job_handler_classname, $request_data ); |
|
164 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
165 | 165 | //remember the response for later. We need it to display the page body |
166 | 166 | $this->_job_step_response = $job_response; |
167 | 167 | return $job_response; |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $template |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function override_template( $template ) { |
|
176 | - if( isset( $_REQUEST[ 'espresso_batch' ] ) && isset( $_REQUEST[ 'batch' ] ) ) { |
|
177 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
175 | + public function override_template($template) { |
|
176 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
177 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html'; |
|
178 | 178 | } |
179 | 179 | return $template; |
180 | 180 | } |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | public function register_admin_pages() { |
186 | 186 | add_submenu_page( |
187 | 187 | '', //parent slug. we don't want this to actually appear in the menu |
188 | - __( 'Batch Job', 'event_espresso' ), //page title |
|
188 | + __('Batch Job', 'event_espresso'), //page title |
|
189 | 189 | 'n/a', //menu title |
190 | 190 | 'read', //we want this page to actually be accessible to anyone, |
191 | 191 | 'espresso_batch', //menu slug |
192 | - array( self::instance(), 'show_admin_page' ) |
|
192 | + array(self::instance(), 'show_admin_page') |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function show_admin_page() { |
201 | 201 | echo EEH_Template::locate_template( |
202 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
203 | - array( 'batch_request_type' => $this->batch_request_type() ) |
|
202 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', |
|
203 | + array('batch_request_type' => $this->batch_request_type()) |
|
204 | 204 | ); |
205 | 205 | } |
206 | 206 | |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * Receives ajax calls for continuing a job |
209 | 209 | */ |
210 | 210 | public function batch_continue() { |
211 | - $job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] ); |
|
211 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
212 | 212 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
213 | - $response_obj = $batch_runner->continue_job( $job_id); |
|
214 | - $this->_return_json( $response_obj->to_array() ); |
|
213 | + $response_obj = $batch_runner->continue_job($job_id); |
|
214 | + $this->_return_json($response_obj->to_array()); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * @return type |
220 | 220 | */ |
221 | 221 | public function batch_cleanup() { |
222 | - $job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] ); |
|
222 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
223 | 223 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
224 | - $response_obj = $batch_runner->cleanup_job( $job_id ); |
|
225 | - $this->_return_json( $response_obj->to_array() ); |
|
224 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
225 | + $this->_return_json($response_obj->to_array()); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * 'isEEajax' => true,//indicates this is a response from EE |
239 | 239 | * ) |
240 | 240 | */ |
241 | - protected function _return_json( $data ) { |
|
241 | + protected function _return_json($data) { |
|
242 | 242 | $json = array( |
243 | 243 | 'notices' => EE_Error::get_notices(), |
244 | 244 | 'data' => $data, |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | |
248 | 248 | |
249 | 249 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
250 | - if ( NULL === error_get_last() || ! headers_sent() ) { |
|
250 | + if (NULL === error_get_last() || ! headers_sent()) { |
|
251 | 251 | header('Content-Type: application/json; charset=UTF-8'); |
252 | 252 | } |
253 | - if( function_exists( 'wp_json_encode' ) ) { |
|
254 | - echo wp_json_encode( $json ); |
|
253 | + if (function_exists('wp_json_encode')) { |
|
254 | + echo wp_json_encode($json); |
|
255 | 255 | } else { |
256 | - echo json_encode( $json ); |
|
256 | + echo json_encode($json); |
|
257 | 257 | } |
258 | 258 | exit(); |
259 | 259 | } |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
271 | 271 | */ |
272 | 272 | public function batch_request_type() { |
273 | - if( $this->_batch_request_type === null ) { |
|
274 | - if( isset( $_GET[ 'batch' ] ) ) { |
|
275 | - if( $_GET[ 'batch' ] == self::batch_job ) { |
|
273 | + if ($this->_batch_request_type === null) { |
|
274 | + if (isset($_GET['batch'])) { |
|
275 | + if ($_GET['batch'] == self::batch_job) { |
|
276 | 276 | $this->_batch_request_type = self::batch_job; |
277 | - } elseif( $_GET[ 'batch' ] == self::batch_file_job ) { |
|
277 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
278 | 278 | $this->_batch_request_type = self::batch_file_job; |
279 | 279 | } |
280 | 280 | } |
281 | 281 | //if we didn't find that it was a batch request, indicate it wasn't |
282 | - if( $this->_batch_request_type === null ) { |
|
282 | + if ($this->_batch_request_type === null) { |
|
283 | 283 | $this->_batch_request_type = self::batch_not_job; |
284 | 284 | } |
285 | 285 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * Unnecessary |
291 | 291 | * @param type $WP |
292 | 292 | */ |
293 | - public function run( $WP ) { |
|
293 | + public function run($WP) { |
|
294 | 294 | |
295 | 295 | } |
296 | 296 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | function ee_resurse_into_array($data) { |
9 | 9 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {//is_object($incomplete_class) actually returns false, hence why we check for it |
10 | - $data = (array)$data; |
|
10 | + $data = (array) $data; |
|
11 | 11 | } |
12 | 12 | if (is_array($data)) { |
13 | 13 | if (EEH_Array::is_associative_array($data)) { |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | ?> |
20 | 20 | <tr> |
21 | 21 | <td> |
22 | - <?php echo $data_key;?> |
|
22 | + <?php echo $data_key; ?> |
|
23 | 23 | </td> |
24 | 24 | <td> |
25 | - <?php ee_resurse_into_array($data_values);?> |
|
25 | + <?php ee_resurse_into_array($data_values); ?> |
|
26 | 26 | </td> |
27 | 27 | </tr> |
28 | 28 | <?php |
@@ -36,31 +36,31 @@ discard block |
||
36 | 36 | <ul> |
37 | 37 | <?php |
38 | 38 | foreach ($data as $datum) { |
39 | - echo "<li>";ee_resurse_into_array($datum);echo "</li>"; |
|
39 | + echo "<li>"; ee_resurse_into_array($datum); echo "</li>"; |
|
40 | 40 | }?> |
41 | 41 | </ul> |
42 | 42 | <?php |
43 | 43 | } |
44 | - }else { |
|
44 | + } else { |
|
45 | 45 | //simple value |
46 | 46 | echo $data; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | ?> |
50 | 50 | <h1> |
51 | - <?php _e("System Information", "event_espresso");?> |
|
51 | + <?php _e("System Information", "event_espresso"); ?> |
|
52 | 52 | </h1> |
53 | 53 | <div class="padding"> |
54 | - <h2><?php _e("Raw System Data", "event_espresso");?></h2> |
|
54 | + <h2><?php _e("Raw System Data", "event_espresso"); ?></h2> |
|
55 | 55 | <textarea class="system_status_info"> |
56 | 56 | <?php print_r($system_stati)?> |
57 | 57 | </textarea> |
58 | - <h2><?php _e("System Data (formatted)", "event_espresso");?></h2> |
|
58 | + <h2><?php _e("System Data (formatted)", "event_espresso"); ?></h2> |
|
59 | 59 | <table class="widefat"> |
60 | 60 | <?php |
61 | 61 | foreach ($system_stati as $status_category_slug => $data) { |
62 | 62 | if (is_object($data)) { |
63 | - $data = (array)$data; |
|
63 | + $data = (array) $data; |
|
64 | 64 | } |
65 | 65 | ?> |
66 | 66 | <thead> |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv"> |
2 | 2 | |
3 | - <h3 class="admin-primary-mbox-h4"><?php echo isset($event_name) ? $event_name . ' Custom Template' : ''; ?></h3> |
|
3 | + <h3 class="admin-primary-mbox-h4"><?php echo isset($event_name) ? $event_name.' Custom Template' : ''; ?></h3> |
|
4 | 4 | <input type="hidden" id="ee-msg-current-context" name="MTP_context" value="<?php echo $context; ?>" /> |
5 | 5 | <!-- if this is not a global template then let's show the name and description fields --> |
6 | - <?php if ( ! $MTP->is_global() ) : ?> |
|
6 | + <?php if ( ! $MTP->is_global()) : ?> |
|
7 | 7 | <div class="non-global-mtp-fields"> |
8 | 8 | <p> |
9 | 9 | <?php _e('This is a custom template. Custom Templates have an editable name and description to help you differentiate between templates.', 'event_espresso'); ?> |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | <?php endif; ?> |
26 | 26 | <!-- we need to loop through the template_fields so we know our structure --> |
27 | 27 | <?php |
28 | - if ( isset($template_fields) && !empty($template_fields) && !is_wp_error($template_fields) ) { |
|
28 | + if (isset($template_fields) && ! empty($template_fields) && ! is_wp_error($template_fields)) { |
|
29 | 29 | echo $template_fields; |
30 | 30 | } else { |
31 | 31 | ?> |
@@ -2341,7 +2341,7 @@ discard block |
||
2341 | 2341 | * @param int $GRP_ID The group being deleted |
2342 | 2342 | * @param bool $include_group whether to delete the Message Template Group as well. |
2343 | 2343 | * |
2344 | - * @return bool boolean to indicate the success of the deletes or not. |
|
2344 | + * @return integer boolean to indicate the success of the deletes or not. |
|
2345 | 2345 | */ |
2346 | 2346 | private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
2347 | 2347 | $success = 1; |
@@ -2835,7 +2835,7 @@ discard block |
||
2835 | 2835 | * |
2836 | 2836 | * @param string $messenger What messenger we're toggling |
2837 | 2837 | * @param boolean $deactivate if true then we deactivate |
2838 | - * @param mixed $message_type if present what message type we're toggling |
|
2838 | + * @param null|string $message_type if present what message type we're toggling |
|
2839 | 2839 | * |
2840 | 2840 | * @return bool |
2841 | 2841 | */ |
@@ -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->get_active_messengers_option(); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @throws EE_Error |
136 | 136 | */ |
137 | 137 | protected function _load_message_resource_manager() { |
138 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
138 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | |
192 | 192 | |
193 | 193 | protected function _ajax_hooks() { |
194 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
195 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
196 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
197 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
198 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
194 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
195 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
196 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
197 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
198 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | * @return void |
228 | 228 | */ |
229 | 229 | protected function _set_page_routes() { |
230 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
230 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
231 | 231 | ? $this->_req_data['GRP_ID'] |
232 | 232 | : 0; |
233 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
233 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
234 | 234 | ? $this->_req_data['id'] |
235 | 235 | : $grp_id; |
236 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
236 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
237 | 237 | ? $this->_req_data['MSG_ID'] |
238 | 238 | : 0; |
239 | 239 | |
@@ -275,35 +275,35 @@ discard block |
||
275 | 275 | 'insert_message_template' => array( |
276 | 276 | 'func' => '_insert_or_update_message_template', |
277 | 277 | 'capability' => 'ee_edit_messages', |
278 | - 'args' => array( 'new_template' => true ), |
|
278 | + 'args' => array('new_template' => true), |
|
279 | 279 | 'noheader' => true |
280 | 280 | ), |
281 | 281 | 'update_message_template' => array( |
282 | 282 | 'func' => '_insert_or_update_message_template', |
283 | 283 | 'capability' => 'ee_edit_message', |
284 | 284 | 'obj_id' => $grp_id, |
285 | - 'args' => array( 'new_template' => false ), |
|
285 | + 'args' => array('new_template' => false), |
|
286 | 286 | 'noheader' => true |
287 | 287 | ), |
288 | 288 | 'trash_message_template' => array( |
289 | 289 | 'func' => '_trash_or_restore_message_template', |
290 | 290 | 'capability' => 'ee_delete_message', |
291 | 291 | 'obj_id' => $grp_id, |
292 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
292 | + 'args' => array('trash' => true, 'all' => true), |
|
293 | 293 | 'noheader' => true |
294 | 294 | ), |
295 | 295 | 'trash_message_template_context' => array( |
296 | 296 | 'func' => '_trash_or_restore_message_template', |
297 | 297 | 'capability' => 'ee_delete_message', |
298 | 298 | 'obj_id' => $grp_id, |
299 | - 'args' => array( 'trash' => true ), |
|
299 | + 'args' => array('trash' => true), |
|
300 | 300 | 'noheader' => true |
301 | 301 | ), |
302 | 302 | 'restore_message_template' => array( |
303 | 303 | 'func' => '_trash_or_restore_message_template', |
304 | 304 | 'capability' => 'ee_delete_message', |
305 | 305 | 'obj_id' => $grp_id, |
306 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
306 | + 'args' => array('trash' => false, 'all' => true), |
|
307 | 307 | 'noheader' => true |
308 | 308 | ), |
309 | 309 | 'restore_message_template_context' => array( |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'order' => 10 |
379 | 379 | ), |
380 | 380 | 'list_table' => 'EE_Message_List_Table', |
381 | - 'qtips' => array( 'EE_Message_List_Table_Tips' ), |
|
381 | + 'qtips' => array('EE_Message_List_Table_Tips'), |
|
382 | 382 | 'require_nonce' => false |
383 | 383 | ), |
384 | 384 | 'global_mtps' => array( |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | 'filename' => 'messages_overview_other', |
418 | 418 | ), |
419 | 419 | ), |
420 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
420 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
421 | 421 | 'require_nonce' => false |
422 | 422 | ), |
423 | 423 | 'custom_mtps' => array( |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | ), |
453 | 453 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
454 | 454 | 'has_metaboxes' => true, |
455 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
455 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
456 | 456 | 'help_tabs' => array( |
457 | 457 | 'edit_message_template' => array( |
458 | 458 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | 'filename' => 'messages_settings_messengers' |
509 | 509 | ), |
510 | 510 | ), |
511 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
511 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
512 | 512 | 'require_nonce' => false |
513 | 513 | ) |
514 | 514 | ); |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | |
543 | 543 | protected function _add_screen_options_default() { |
544 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
544 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
545 | 545 | $this->_per_page_screen_option(); |
546 | 546 | } |
547 | 547 | |
@@ -563,37 +563,37 @@ discard block |
||
563 | 563 | |
564 | 564 | |
565 | 565 | public function messages_help_tab() { |
566 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
566 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
570 | 570 | public function messengers_help_tab() { |
571 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
571 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
575 | 575 | public function message_types_help_tab() { |
576 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
576 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | 580 | public function messages_overview_help_tab() { |
581 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
581 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
585 | 585 | public function message_templates_help_tab() { |
586 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
586 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
590 | 590 | public function edit_message_template_help_tab() { |
591 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
592 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
593 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
594 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
595 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
596 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
591 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
592 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
593 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
594 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
595 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
596 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
@@ -601,22 +601,22 @@ discard block |
||
601 | 601 | public function message_template_shortcodes_help_tab() { |
602 | 602 | $this->_set_shortcodes(); |
603 | 603 | $args['shortcodes'] = $this->_shortcodes; |
604 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
604 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | |
608 | 608 | |
609 | 609 | public function preview_message_help_tab() { |
610 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
610 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | |
614 | 614 | public function settings_help_tab() { |
615 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
616 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
615 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
616 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
617 | 617 | $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>'; |
618 | 618 | $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>'; |
619 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
619 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | |
@@ -624,31 +624,31 @@ discard block |
||
624 | 624 | |
625 | 625 | |
626 | 626 | public function load_scripts_styles() { |
627 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
627 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
628 | 628 | wp_enqueue_style('espresso_ee_msg'); |
629 | 629 | |
630 | - 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 ); |
|
631 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
630 | + 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); |
|
631 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
635 | 635 | |
636 | 636 | public function load_scripts_styles_default() { |
637 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
637 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | |
641 | 641 | |
642 | 642 | |
643 | 643 | |
644 | - public function wp_editor_css( $mce_css ) { |
|
644 | + public function wp_editor_css($mce_css) { |
|
645 | 645 | //if we're on the edit_message_template route |
646 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger ) { |
|
646 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger) { |
|
647 | 647 | $message_type_name = $this->_active_message_type_name; |
648 | 648 | |
649 | 649 | //we're going to REPLACE the existing mce css |
650 | 650 | //we need to get the css file location from the active messenger |
651 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
651 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | return $mce_css; |
@@ -666,37 +666,37 @@ discard block |
||
666 | 666 | $this->_message_template_group->messenger_obj()->label['singular'], |
667 | 667 | $this->_message_template_group->message_type_obj()->label['singular'] |
668 | 668 | ); |
669 | - 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' ); |
|
669 | + 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'); |
|
670 | 670 | |
671 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
671 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
672 | 672 | |
673 | 673 | wp_enqueue_script('ee_admin_js'); |
674 | 674 | wp_enqueue_script('ee_msgs_edit_js'); |
675 | 675 | |
676 | 676 | //add in special css for tiny_mce |
677 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
677 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | |
681 | 681 | |
682 | 682 | public function load_scripts_styles_display_preview_message() { |
683 | 683 | $this->_set_message_template_group(); |
684 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
684 | + if (isset($this->_req_data['messenger'])) { |
|
685 | 685 | $this->_active_messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj']; |
686 | 686 | } |
687 | 687 | |
688 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
688 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
689 | 689 | |
690 | 690 | |
691 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
691 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
695 | 695 | |
696 | 696 | public function load_scripts_styles_settings() { |
697 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
698 | - wp_enqueue_style( 'ee-text-links' ); |
|
699 | - wp_enqueue_style( 'ee-message-settings' ); |
|
697 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
698 | + wp_enqueue_style('ee-text-links'); |
|
699 | + wp_enqueue_style('ee-message-settings'); |
|
700 | 700 | |
701 | 701 | wp_enqueue_script('ee-messages-settings'); |
702 | 702 | } |
@@ -726,37 +726,37 @@ discard block |
||
726 | 726 | * set views array for message queue list table |
727 | 727 | */ |
728 | 728 | public function _set_list_table_views_default() { |
729 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
729 | + EE_Registry::instance()->load_helper('Template'); |
|
730 | 730 | |
731 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
731 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
732 | 732 | ? array( |
733 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
734 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
735 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
736 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
733 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
734 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
735 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
736 | + 'send_now' => __('Send Now', 'event_espresso') |
|
737 | 737 | ) |
738 | 738 | : array(); |
739 | 739 | |
740 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
741 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
740 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
741 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
742 | 742 | : array(); |
743 | 743 | |
744 | 744 | |
745 | 745 | $this->_views = array( |
746 | 746 | 'all' => array( |
747 | 747 | 'slug' => 'all', |
748 | - 'label' => __( 'All', 'event_espresso' ), |
|
748 | + 'label' => __('All', 'event_espresso'), |
|
749 | 749 | 'count' => 0, |
750 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
750 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
751 | 751 | ) |
752 | 752 | ); |
753 | 753 | |
754 | 754 | |
755 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
755 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
756 | 756 | $status_bulk_actions = $common_bulk_actions; |
757 | 757 | //unset bulk actions not applying to status |
758 | - if ( ! empty( $status_bulk_actions ) ) { |
|
759 | - switch ( $status ) { |
|
758 | + if ( ! empty($status_bulk_actions)) { |
|
759 | + switch ($status) { |
|
760 | 760 | case EEM_Message::status_idle : |
761 | 761 | case EEM_Message::status_resend : |
762 | 762 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -767,20 +767,20 @@ discard block |
||
767 | 767 | break; |
768 | 768 | |
769 | 769 | case EEM_Message::status_incomplete : |
770 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
770 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
771 | 771 | break; |
772 | 772 | |
773 | 773 | case EEM_Message::status_retry : |
774 | 774 | case EEM_Message::status_sent : |
775 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
775 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
776 | 776 | break; |
777 | 777 | } |
778 | 778 | } |
779 | - $this->_views[ strtolower( $status ) ] = array( |
|
780 | - 'slug' => strtolower( $status ), |
|
781 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
779 | + $this->_views[strtolower($status)] = array( |
|
780 | + 'slug' => strtolower($status), |
|
781 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
782 | 782 | 'count' => 0, |
783 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
783 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
784 | 784 | ); |
785 | 785 | } |
786 | 786 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | protected function _message_queue_list_table() { |
800 | 800 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
801 | 801 | $this->_template_args['per_column'] = 6; |
802 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
802 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
803 | 803 | $this->display_admin_list_table_page_with_no_sidebar(); |
804 | 804 | } |
805 | 805 | |
@@ -807,12 +807,12 @@ discard block |
||
807 | 807 | |
808 | 808 | |
809 | 809 | protected function _message_legend_items() { |
810 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
810 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
811 | 811 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
812 | 812 | $action_items = array(); |
813 | 813 | |
814 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
815 | - if ( $action_item === 'see_notifications_for' ) { |
|
814 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
815 | + if ($action_item === 'see_notifications_for') { |
|
816 | 816 | continue; |
817 | 817 | } |
818 | 818 | $action_items[$action_item] = array( |
@@ -824,31 +824,31 @@ discard block |
||
824 | 824 | /** @type array $status_items status legend setup*/ |
825 | 825 | $status_items = array( |
826 | 826 | 'sent_status' => array( |
827 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
828 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, FALSE, 'sentence' ) |
|
827 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
828 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, FALSE, 'sentence') |
|
829 | 829 | ), |
830 | 830 | 'idle_status' => array( |
831 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
832 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, FALSE, 'sentence' ) |
|
831 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
832 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, FALSE, 'sentence') |
|
833 | 833 | ), |
834 | 834 | 'failed_status' => array( |
835 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
836 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, FALSE, 'sentence' ) |
|
835 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
836 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, FALSE, 'sentence') |
|
837 | 837 | ), |
838 | 838 | 'resend_status' => array( |
839 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
840 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, FALSE, 'sentence' ) |
|
839 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
840 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, FALSE, 'sentence') |
|
841 | 841 | ), |
842 | 842 | 'incomplete_status' => array( |
843 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
844 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, FALSE, 'sentence' ) |
|
843 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
844 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, FALSE, 'sentence') |
|
845 | 845 | ), |
846 | 846 | 'retry_status' => array( |
847 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
848 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, FALSE, 'sentence' ) |
|
847 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
848 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, FALSE, 'sentence') |
|
849 | 849 | ) |
850 | 850 | ); |
851 | - return array_merge( $action_items, $status_items ); |
|
851 | + return array_merge($action_items, $status_items); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | |
@@ -858,9 +858,9 @@ discard block |
||
858 | 858 | |
859 | 859 | protected function _custom_mtps_preview() { |
860 | 860 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
861 | - $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' ) . '" />'; |
|
861 | + $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').'" />'; |
|
862 | 862 | $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>'; |
863 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
863 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | |
@@ -884,31 +884,31 @@ discard block |
||
884 | 884 | * |
885 | 885 | * @return array |
886 | 886 | */ |
887 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
887 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
888 | 888 | |
889 | 889 | $MTP = EEM_Message_Template_Group::instance(); |
890 | 890 | |
891 | 891 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
892 | 892 | $orderby = $this->_req_data['orderby']; |
893 | 893 | |
894 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
894 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
895 | 895 | |
896 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
897 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
896 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
897 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
898 | 898 | |
899 | - $offset = ($current_page-1)*$per_page; |
|
900 | - $limit = $all ? null : array( $offset, $per_page ); |
|
899 | + $offset = ($current_page - 1) * $per_page; |
|
900 | + $limit = $all ? null : array($offset, $per_page); |
|
901 | 901 | |
902 | 902 | |
903 | 903 | //options will match what is in the _views array property |
904 | - switch( $type ) { |
|
904 | + switch ($type) { |
|
905 | 905 | |
906 | 906 | case 'in_use': |
907 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
907 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
908 | 908 | break; |
909 | 909 | |
910 | 910 | default: |
911 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
911 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
912 | 912 | |
913 | 913 | } |
914 | 914 | |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
944 | 944 | $installed = array(); |
945 | 945 | |
946 | - foreach ( $installed_message_types as $message_type ) { |
|
946 | + foreach ($installed_message_types as $message_type) { |
|
947 | 947 | $installed[$message_type->name]['obj'] = $message_type; |
948 | 948 | } |
949 | 949 | |
@@ -963,24 +963,24 @@ discard block |
||
963 | 963 | * |
964 | 964 | * @throws EE_error |
965 | 965 | */ |
966 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
966 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
967 | 967 | //set values override any request data |
968 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
969 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
968 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
969 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
970 | 970 | |
971 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
972 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
971 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
972 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
973 | 973 | |
974 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
975 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
974 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
975 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
976 | 976 | |
977 | 977 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
978 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
979 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
978 | + if (empty($message_type) || empty($messenger)) |
|
979 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
980 | 980 | |
981 | 981 | //we need the GRP_ID for the template being used as the base for the new template |
982 | - if ( empty( $GRP_ID ) ) |
|
983 | - {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' ) );} |
|
982 | + if (empty($GRP_ID)) |
|
983 | + {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')); } |
|
984 | 984 | |
985 | 985 | //let's just make sure the template gets generated! |
986 | 986 | |
@@ -1001,8 +1001,8 @@ discard block |
||
1001 | 1001 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
1002 | 1002 | * off of. |
1003 | 1003 | */ |
1004 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
1005 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
1004 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
1005 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | |
@@ -1013,37 +1013,37 @@ discard block |
||
1013 | 1013 | * @return void |
1014 | 1014 | */ |
1015 | 1015 | protected function _edit_message_template() { |
1016 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1016 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1017 | 1017 | $template_fields = ''; |
1018 | 1018 | $sidebar_fields = ''; |
1019 | 1019 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
1020 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
1020 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
1021 | 1021 | |
1022 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1022 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1023 | 1023 | |
1024 | 1024 | $this->_set_shortcodes(); //this also sets the _message_template property. |
1025 | 1025 | $message_template_group = $this->_message_template_group; |
1026 | 1026 | $c_label = $message_template_group->context_label(); |
1027 | 1027 | $c_config = $message_template_group->contexts_config(); |
1028 | 1028 | |
1029 | - reset( $c_config ); |
|
1030 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) ? strtolower($this->_req_data['context']) : key($c_config); |
|
1029 | + reset($c_config); |
|
1030 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) ? strtolower($this->_req_data['context']) : key($c_config); |
|
1031 | 1031 | |
1032 | 1032 | |
1033 | - if ( empty($GRP_ID) ) { |
|
1033 | + if (empty($GRP_ID)) { |
|
1034 | 1034 | $action = 'insert_message_template'; |
1035 | 1035 | //$button_both = false; |
1036 | 1036 | //$button_text = array( __( 'Save','event_espresso') ); |
1037 | 1037 | //$button_actions = array('something_different'); |
1038 | 1038 | //$referrer = false; |
1039 | - $edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL ); |
|
1039 | + $edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL); |
|
1040 | 1040 | } else { |
1041 | 1041 | $action = 'update_message_template'; |
1042 | 1042 | //$button_both = true; |
1043 | 1043 | //$button_text = array(); |
1044 | 1044 | //$button_actions = array(); |
1045 | 1045 | //$referrer = $this->_admin_base_url; |
1046 | - $edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL ); |
|
1046 | + $edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL); |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | //set active messenger for this view |
@@ -1053,13 +1053,13 @@ discard block |
||
1053 | 1053 | |
1054 | 1054 | //Do we have any validation errors? |
1055 | 1055 | $validators = $this->_get_transient(); |
1056 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1056 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1057 | 1057 | |
1058 | 1058 | |
1059 | 1059 | //we need to assemble the title from Various details |
1060 | - $context_label = sprintf( __('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'] )); |
|
1060 | + $context_label = sprintf(__('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'])); |
|
1061 | 1061 | |
1062 | - $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 ); |
|
1062 | + $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); |
|
1063 | 1063 | |
1064 | 1064 | $this->_template_args['GRP_ID'] = $GRP_ID; |
1065 | 1065 | $this->_template_args['message_template'] = $message_template_group; |
@@ -1068,10 +1068,10 @@ discard block |
||
1068 | 1068 | |
1069 | 1069 | //let's get EEH_MSG_Template so we can get template form fields |
1070 | 1070 | /** @type EEH_MSG_Template $MSG_Template */ |
1071 | - $MSG_Template = EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1072 | - $template_field_structure = $MSG_Template->get_fields( $message_template_group->messenger(), $message_template_group->message_type()); |
|
1071 | + $MSG_Template = EE_Registry::instance()->load_helper('MSG_Template'); |
|
1072 | + $template_field_structure = $MSG_Template->get_fields($message_template_group->messenger(), $message_template_group->message_type()); |
|
1073 | 1073 | |
1074 | - if ( !$template_field_structure ) { |
|
1074 | + if ( ! $template_field_structure) { |
|
1075 | 1075 | $template_field_structure = false; |
1076 | 1076 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1077 | 1077 | } |
@@ -1081,47 +1081,47 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | |
1083 | 1083 | //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. |
1084 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1085 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1086 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1084 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1085 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1086 | + unset($template_field_structure[$context][$reference_field]); |
|
1087 | 1087 | } |
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | //let's loop through the template_field_structure and actually assemble the input fields! |
1091 | - if ( !empty($template_field_structure) ) { |
|
1091 | + if ( ! empty($template_field_structure)) { |
|
1092 | 1092 | //$id_prefix= 'ee-msg-edit-template-fields-'; |
1093 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1093 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1094 | 1094 | //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. |
1095 | - if ( $template_field == 'extra' ) { |
|
1095 | + if ($template_field == 'extra') { |
|
1096 | 1096 | $this->_template_args['is_extra_fields'] = true; |
1097 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1098 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1097 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1098 | + $message_template = $message_templates[$context][$reference_field]; |
|
1099 | 1099 | $content = $message_template instanceof EE_Message_Template |
1100 | - ? $message_template->get( 'MTP_content' ) |
|
1100 | + ? $message_template->get('MTP_content') |
|
1101 | 1101 | : ''; |
1102 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1102 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1103 | 1103 | //let's verify if we need this extra field via the shortcodes parameter. |
1104 | 1104 | $continue = false; |
1105 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1106 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1107 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1108 | - {$continue = true;} |
|
1105 | + if (isset($extra_array['shortcodes_required'])) { |
|
1106 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1107 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1108 | + {$continue = true; } |
|
1109 | 1109 | } |
1110 | - if ( $continue ) {continue;} |
|
1110 | + if ($continue) {continue; } |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1113 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1114 | 1114 | $template_form_fields[$field_id] = $extra_array; |
1115 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1116 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1117 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1115 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1116 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1117 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1118 | 1118 | && in_array($extra_field, $v_fields) |
1119 | - && ( is_array($validators[$extra_field] ) |
|
1120 | - && isset( $validators[$extra_field]['msg'] ) ) |
|
1121 | - ? 'validate-error ' . $css_class |
|
1119 | + && (is_array($validators[$extra_field]) |
|
1120 | + && isset($validators[$extra_field]['msg'])) |
|
1121 | + ? 'validate-error '.$css_class |
|
1122 | 1122 | : $css_class; |
1123 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1124 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1123 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1124 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1125 | 1125 | : ''; |
1126 | 1126 | |
1127 | 1127 | //do we have a validation error? if we do then let's use that value instead |
@@ -1132,32 +1132,32 @@ discard block |
||
1132 | 1132 | |
1133 | 1133 | //shortcode selector |
1134 | 1134 | $field_name_to_use = $extra_field == 'main' ? 'content' : $extra_field; |
1135 | - $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $field_name_to_use, $field_id ); |
|
1135 | + $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($field_name_to_use, $field_id); |
|
1136 | 1136 | |
1137 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1137 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1138 | 1138 | //we want to decode the entities |
1139 | - $template_form_fields[$field_id]['value'] = stripslashes( html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") ); |
|
1139 | + $template_form_fields[$field_id]['value'] = stripslashes(html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")); |
|
1140 | 1140 | |
1141 | 1141 | }/**/ |
1142 | 1142 | } |
1143 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1144 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1143 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1144 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1145 | 1145 | |
1146 | 1146 | $template_form_fields[$templatefield_MTP_id] = array( |
1147 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1147 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1148 | 1148 | 'label' => null, |
1149 | 1149 | 'input' => 'hidden', |
1150 | 1150 | 'type' => 'int', |
1151 | 1151 | 'required' => false, |
1152 | 1152 | 'validation' => false, |
1153 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1153 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1154 | 1154 | 'css_class' => '', |
1155 | 1155 | 'format' => '%d', |
1156 | 1156 | 'db-col' => 'MTP_ID' |
1157 | 1157 | ); |
1158 | 1158 | |
1159 | 1159 | $template_form_fields[$templatefield_templatename_id] = array( |
1160 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1160 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1161 | 1161 | 'label' => null, |
1162 | 1162 | 'input' => 'hidden', |
1163 | 1163 | 'type' => 'string', |
@@ -1171,11 +1171,11 @@ discard block |
||
1171 | 1171 | } |
1172 | 1172 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1173 | 1173 | } else { |
1174 | - $field_id = $template_field . '-content'; |
|
1174 | + $field_id = $template_field.'-content'; |
|
1175 | 1175 | $template_form_fields[$field_id] = $field_setup_array; |
1176 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1177 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1178 | - ? isset( $message_templates[ $context ][ $template_field ] ) |
|
1176 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1177 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1178 | + ? isset($message_templates[$context][$template_field]) |
|
1179 | 1179 | : null; |
1180 | 1180 | $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
1181 | 1181 | && is_array($message_templates[$context]) |
@@ -1189,10 +1189,10 @@ discard block |
||
1189 | 1189 | |
1190 | 1190 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1191 | 1191 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1192 | - $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; |
|
1192 | + $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; |
|
1193 | 1193 | |
1194 | 1194 | //shortcode selector |
1195 | - $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $template_field, $field_id ); |
|
1195 | + $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($template_field, $field_id); |
|
1196 | 1196 | |
1197 | 1197 | //if ( isset( $field_setup_array['input'] ) && $field_setup_array['input'] == 'wp_editor' ) { |
1198 | 1198 | // //we want to decode the entities |
@@ -1202,12 +1202,12 @@ discard block |
||
1202 | 1202 | |
1203 | 1203 | //k took care of content field(s) now let's take care of others. |
1204 | 1204 | |
1205 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1206 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1205 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1206 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1207 | 1207 | |
1208 | 1208 | //foreach template field there are actually two form fields created |
1209 | 1209 | $template_form_fields[$templatefield_MTP_id] = array( |
1210 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1210 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1211 | 1211 | 'label' => null, |
1212 | 1212 | 'input' => 'hidden', |
1213 | 1213 | 'type' => 'int', |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | ); |
1221 | 1221 | |
1222 | 1222 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1223 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1223 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1224 | 1224 | 'label' => null, |
1225 | 1225 | 'input' => 'hidden', |
1226 | 1226 | 'type' => 'string', |
@@ -1364,15 +1364,15 @@ discard block |
||
1364 | 1364 | 'value' => $GRP_ID |
1365 | 1365 | ); |
1366 | 1366 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1367 | - 'name' => $action . '_nonce', |
|
1367 | + 'name' => $action.'_nonce', |
|
1368 | 1368 | 'input' => 'hidden', |
1369 | 1369 | 'type' => 'string', |
1370 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1370 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1371 | 1371 | ); |
1372 | 1372 | |
1373 | 1373 | //$sidebar_array = array('ee-msg-is-global', 'ee-msg-is-override', 'ee-msg-deleted', 'ee-msg-is-active'); |
1374 | 1374 | |
1375 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1375 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1376 | 1376 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1377 | 1377 | 'name' => 'template_switch', |
1378 | 1378 | 'input' => 'hidden', |
@@ -1382,8 +1382,8 @@ discard block |
||
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | |
1385 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1386 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1385 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1386 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1387 | 1387 | |
1388 | 1388 | |
1389 | 1389 | } //end if ( !empty($template_field_structure) ) |
@@ -1395,14 +1395,14 @@ discard block |
||
1395 | 1395 | $GRP_ID, |
1396 | 1396 | false, |
1397 | 1397 | add_query_arg( |
1398 | - array( 'action' => 'global_mtps' ), |
|
1398 | + array('action' => 'global_mtps'), |
|
1399 | 1399 | $this->_admin_base_url |
1400 | 1400 | ) |
1401 | 1401 | ); |
1402 | 1402 | |
1403 | 1403 | //add preview button |
1404 | - $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 ); |
|
1405 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1404 | + $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); |
|
1405 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1406 | 1406 | |
1407 | 1407 | |
1408 | 1408 | //setup context switcher |
@@ -1430,17 +1430,17 @@ discard block |
||
1430 | 1430 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1431 | 1431 | |
1432 | 1432 | $this->_template_path = $this->_template_args['GRP_ID'] |
1433 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1434 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1433 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1434 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1435 | 1435 | |
1436 | 1436 | //send along EE_Message_Template_Group object for further template use. |
1437 | 1437 | $this->_template_args['MTP'] = $message_template_group; |
1438 | 1438 | |
1439 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1439 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1440 | 1440 | |
1441 | 1441 | |
1442 | 1442 | //finally, let's set the admin_page title |
1443 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1443 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1444 | 1444 | |
1445 | 1445 | |
1446 | 1446 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | |
1456 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1456 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1457 | 1457 | return $mceInit; |
1458 | 1458 | } |
1459 | 1459 | |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | public function _add_form_element_before() { |
1467 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1467 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | public function _add_form_element_after() { |
@@ -1482,33 +1482,33 @@ discard block |
||
1482 | 1482 | * @return string json object |
1483 | 1483 | */ |
1484 | 1484 | public function switch_template_pack() { |
1485 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1486 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1485 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1486 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1487 | 1487 | |
1488 | 1488 | //verify we have needed values. |
1489 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1489 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1490 | 1490 | $this->_template_args['error'] = true; |
1491 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1491 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1492 | 1492 | } else { |
1493 | 1493 | //get template, set the new template_pack and then reset to default |
1494 | 1494 | /** @type EE_Message_Template_Group $message_template_group */ |
1495 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1495 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1496 | 1496 | |
1497 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1497 | + $message_template_group->set_template_pack_name($template_pack); |
|
1498 | 1498 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1499 | 1499 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1500 | 1500 | |
1501 | 1501 | $query_args = $this->_reset_to_default_template(); |
1502 | 1502 | |
1503 | - if ( empty( $query_args['id'] ) ) { |
|
1504 | - EE_Error::add_error( __('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1503 | + if (empty($query_args['id'])) { |
|
1504 | + EE_Error::add_error(__('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1505 | 1505 | $this->_template_args['error'] = true; |
1506 | 1506 | } else { |
1507 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1507 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1508 | 1508 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1509 | - 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 ) ); |
|
1509 | + 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)); |
|
1510 | 1510 | //generate the redirect url for js. |
1511 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1511 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1512 | 1512 | $this->_template_args['data']['redirect_url'] = $url; |
1513 | 1513 | $this->_template_args['success'] = true; |
1514 | 1514 | } |
@@ -1530,16 +1530,16 @@ discard block |
||
1530 | 1530 | protected function _reset_to_default_template() { |
1531 | 1531 | |
1532 | 1532 | $templates = array(); |
1533 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1533 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1534 | 1534 | //we need to make sure we've got the info we need. |
1535 | - if ( !isset( $this->_req_data['msgr'] ) && !isset( $this->_req_data['mt'] ) && !isset( $this->_req_data['GRP_ID'] ) ) { |
|
1536 | - 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__ ); |
|
1535 | + if ( ! isset($this->_req_data['msgr']) && ! isset($this->_req_data['mt']) && ! isset($this->_req_data['GRP_ID'])) { |
|
1536 | + 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__); |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | //all templates will be reset to whatever the defaults are for the global template matching the messenger and message type. |
1540 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1540 | + $success = ! empty($GRP_ID) ? true : false; |
|
1541 | 1541 | |
1542 | - if ( $success ) { |
|
1542 | + if ($success) { |
|
1543 | 1543 | |
1544 | 1544 | //let's first determine if the incoming template is a global template, |
1545 | 1545 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1547,39 +1547,39 @@ discard block |
||
1547 | 1547 | |
1548 | 1548 | |
1549 | 1549 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1550 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1550 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1551 | 1551 | |
1552 | - if ( $success ) { |
|
1552 | + if ($success) { |
|
1553 | 1553 | //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. |
1554 | - $templates = $this->_generate_new_templates( $this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true ); |
|
1554 | + $templates = $this->_generate_new_templates($this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true); |
|
1555 | 1555 | } |
1556 | 1556 | |
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | //any error messages? |
1560 | - if ( !$success ) { |
|
1561 | - EE_Error::add_error( __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1560 | + if ( ! $success) { |
|
1561 | + EE_Error::add_error(__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1562 | 1562 | } |
1563 | 1563 | |
1564 | 1564 | //all good, let's add a success message! |
1565 | - if ( $success && ! empty( $templates ) ) { |
|
1565 | + if ($success && ! empty($templates)) { |
|
1566 | 1566 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1567 | 1567 | EE_Error::overwrite_success(); |
1568 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1568 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | |
1572 | 1572 | $query_args = array( |
1573 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1574 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1575 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1573 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1574 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1575 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1576 | 1576 | ); |
1577 | 1577 | |
1578 | 1578 | //if called via ajax then we return query args otherwise redirect |
1579 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1579 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1580 | 1580 | return $query_args; |
1581 | 1581 | } else { |
1582 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1582 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1583 | 1583 | return null; |
1584 | 1584 | } |
1585 | 1585 | } |
@@ -1592,19 +1592,19 @@ discard block |
||
1592 | 1592 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1593 | 1593 | * @return string |
1594 | 1594 | */ |
1595 | - public function _preview_message( $send = false ) { |
|
1595 | + public function _preview_message($send = false) { |
|
1596 | 1596 | //first make sure we've got the necessary parameters |
1597 | - if ( !isset( $this->_req_data['message_type'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['GRP_ID'] ) ) { |
|
1598 | - EE_Error::add_error( __('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1597 | + if ( ! isset($this->_req_data['message_type']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['GRP_ID'])) { |
|
1598 | + EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1599 | 1599 | } |
1600 | 1600 | |
1601 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1601 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1602 | 1602 | |
1603 | 1603 | |
1604 | 1604 | //get the preview! |
1605 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1605 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1606 | 1606 | |
1607 | - if ( $send ) { |
|
1607 | + if ($send) { |
|
1608 | 1608 | return $preview; |
1609 | 1609 | } |
1610 | 1610 | |
@@ -1614,16 +1614,16 @@ discard block |
||
1614 | 1614 | 'context' => $this->_req_data['context'], |
1615 | 1615 | 'action' => 'edit_message_template' |
1616 | 1616 | ); |
1617 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1618 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1617 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1618 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1619 | 1619 | |
1620 | 1620 | //let's provide a helpful title for context |
1621 | - $preview_title = sprintf( __('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']) ); |
|
1621 | + $preview_title = sprintf(__('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular'])); |
|
1622 | 1622 | |
1623 | 1623 | |
1624 | 1624 | //setup display of preview. |
1625 | 1625 | $this->_admin_page_title = $preview_title; |
1626 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1626 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1627 | 1627 | $this->_template_args['data']['force_json'] = true; |
1628 | 1628 | return ''; |
1629 | 1629 | } |
@@ -1653,9 +1653,9 @@ discard block |
||
1653 | 1653 | * @return void |
1654 | 1654 | */ |
1655 | 1655 | protected function _register_edit_meta_boxes() { |
1656 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1657 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1658 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1656 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1657 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1658 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1659 | 1659 | } |
1660 | 1660 | |
1661 | 1661 | |
@@ -1674,10 +1674,10 @@ discard block |
||
1674 | 1674 | |
1675 | 1675 | $tp_select_values = array(); |
1676 | 1676 | |
1677 | - foreach ( $tp_collection as $tp ) { |
|
1677 | + foreach ($tp_collection as $tp) { |
|
1678 | 1678 | //only include template packs that support this messenger and message type! |
1679 | 1679 | $supports = $tp->get_supports(); |
1680 | - if ( ! isset( $supports[$this->_message_template_group->messenger()] ) || ! in_array( $this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()] ) ) { |
|
1680 | + if ( ! isset($supports[$this->_message_template_group->messenger()]) || ! in_array($this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()])) { |
|
1681 | 1681 | //not supported |
1682 | 1682 | continue; |
1683 | 1683 | } |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | //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. |
1692 | - if ( empty( $tp_select_values ) ) { |
|
1692 | + if (empty($tp_select_values)) { |
|
1693 | 1693 | $tp_select_values[] = array( |
1694 | 1694 | 'text' => __('Default', 'event_espresso'), |
1695 | 1695 | 'id' => 'default' |
@@ -1697,27 +1697,27 @@ discard block |
||
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | //setup variation select values for the currently selected template. |
1700 | - $variations = $this->_message_template_group->get_template_pack()->get_variations( $this->_message_template_group->messenger(), $this->_message_template_group->message_type() ); |
|
1700 | + $variations = $this->_message_template_group->get_template_pack()->get_variations($this->_message_template_group->messenger(), $this->_message_template_group->message_type()); |
|
1701 | 1701 | $variations_select_values = array(); |
1702 | - foreach ( $variations as $variation => $label ) { |
|
1702 | + foreach ($variations as $variation => $label) { |
|
1703 | 1703 | $variations_select_values[] = array( |
1704 | 1704 | 'text' => $label, |
1705 | 1705 | 'id' => $variation |
1706 | 1706 | ); |
1707 | 1707 | } |
1708 | 1708 | |
1709 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1709 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1710 | 1710 | |
1711 | - $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( 'MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name() ); |
|
1712 | - $template_args['variations_selector'] = EEH_Form_Fields::select_input( 'MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation() ); |
|
1711 | + $template_args['template_packs_selector'] = EEH_Form_Fields::select_input('MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name()); |
|
1712 | + $template_args['variations_selector'] = EEH_Form_Fields::select_input('MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation()); |
|
1713 | 1713 | $template_args['template_pack_label'] = $template_pack_labels->template_pack; |
1714 | 1714 | $template_args['template_variation_label'] = $template_pack_labels->template_variation; |
1715 | 1715 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1716 | 1716 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1717 | 1717 | |
1718 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1718 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1719 | 1719 | |
1720 | - EEH_Template::display_template( $template, $template_args ); |
|
1720 | + EEH_Template::display_template($template, $template_args); |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | |
@@ -1738,52 +1738,52 @@ discard block |
||
1738 | 1738 | 'GRP_ID' => $this->_message_template_group->GRP_ID() |
1739 | 1739 | ); |
1740 | 1740 | |
1741 | - $button = $this->get_action_link_or_button( 'reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button' ); |
|
1741 | + $button = $this->get_action_link_or_button('reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button'); |
|
1742 | 1742 | |
1743 | 1743 | |
1744 | 1744 | //test button |
1745 | 1745 | //first we need to see if there are any fields |
1746 | 1746 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1747 | 1747 | |
1748 | - if ( !empty( $fields ) ) { |
|
1748 | + if ( ! empty($fields)) { |
|
1749 | 1749 | //yup there be fields |
1750 | - foreach ( $fields as $field => $config ) { |
|
1751 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1750 | + foreach ($fields as $field => $config) { |
|
1751 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1752 | 1752 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1753 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1754 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1753 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1754 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1755 | 1755 | |
1756 | 1756 | //if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults |
1757 | 1757 | $fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : ''; |
1758 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix; |
|
1758 | + $existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix; |
|
1759 | 1759 | |
1760 | 1760 | $template_form_fields[$field_id] = array( |
1761 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1761 | + 'name' => 'test_settings_fld['.$field.']', |
|
1762 | 1762 | 'label' => $config['label'], |
1763 | 1763 | 'input' => $config['input'], |
1764 | 1764 | 'type' => $config['type'], |
1765 | 1765 | 'required' => $config['required'], |
1766 | 1766 | 'validation' => $config['validation'], |
1767 | - 'value' => isset( $existing[$field] ) ? $existing[$field] : $default, |
|
1767 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1768 | 1768 | 'css_class' => $config['css_class'], |
1769 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1769 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1770 | 1770 | 'default' => $default, |
1771 | 1771 | 'format' => $config['format'] |
1772 | 1772 | ); |
1773 | 1773 | } |
1774 | 1774 | } |
1775 | 1775 | |
1776 | - $test_settings_fields = !empty( $template_form_fields) ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) : ''; |
|
1776 | + $test_settings_fields = ! empty($template_form_fields) ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') : ''; |
|
1777 | 1777 | |
1778 | 1778 | $test_settings_html = ''; |
1779 | 1779 | //print out $test_settings_fields |
1780 | - if ( !empty( $test_settings_fields ) ) { |
|
1780 | + if ( ! empty($test_settings_fields)) { |
|
1781 | 1781 | echo $test_settings_fields; |
1782 | - $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>'; |
|
1782 | + $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>'; |
|
1783 | 1783 | } |
1784 | 1784 | |
1785 | 1785 | //and button |
1786 | - 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>'; |
|
1786 | + 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>'; |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | |
@@ -1798,13 +1798,13 @@ discard block |
||
1798 | 1798 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
1799 | 1799 | * @return string |
1800 | 1800 | */ |
1801 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
1801 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
1802 | 1802 | $template_args = array( |
1803 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
1803 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
1804 | 1804 | 'fieldname' => $field, |
1805 | 1805 | 'linked_input_id' => $linked_input_id |
1806 | 1806 | ); |
1807 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
1807 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
1808 | 1808 | } |
1809 | 1809 | |
1810 | 1810 | |
@@ -1819,13 +1819,13 @@ discard block |
||
1819 | 1819 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
1820 | 1820 | //$messenger = $this->_message_template_group->messenger_obj(); |
1821 | 1821 | //now let's set the content depending on the status of the shortcodes array |
1822 | - if ( empty( $shortcodes ) ) { |
|
1823 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
1822 | + if (empty($shortcodes)) { |
|
1823 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
1824 | 1824 | echo $content; |
1825 | 1825 | } else { |
1826 | 1826 | //$alt = 0; |
1827 | 1827 | ?> |
1828 | - <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> |
|
1828 | + <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> |
|
1829 | 1829 | <?php |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1842,7 +1842,7 @@ discard block |
||
1842 | 1842 | protected function _set_shortcodes() { |
1843 | 1843 | |
1844 | 1844 | //no need to run this if the property is already set |
1845 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
1845 | + if ( ! empty($this->_shortcodes)) {return; } |
|
1846 | 1846 | |
1847 | 1847 | $this->_shortcodes = $this->_get_shortcodes(); |
1848 | 1848 | } |
@@ -1864,14 +1864,14 @@ discard block |
||
1864 | 1864 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
1865 | 1865 | * just an array of shortcode/label pairs. |
1866 | 1866 | */ |
1867 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
1867 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
1868 | 1868 | $this->_set_message_template_group(); |
1869 | 1869 | |
1870 | 1870 | //we need the messenger and message template to retrieve the valid shortcodes array. |
1871 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1872 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
1871 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1872 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
1873 | 1873 | |
1874 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
1874 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
1875 | 1875 | } |
1876 | 1876 | |
1877 | 1877 | |
@@ -1884,19 +1884,19 @@ discard block |
||
1884 | 1884 | */ |
1885 | 1885 | protected function _set_message_template_group() { |
1886 | 1886 | |
1887 | - if ( !empty( $this->_message_template_group ) ) |
|
1888 | - {return;} //get out if this is already set. |
|
1887 | + if ( ! empty($this->_message_template_group)) |
|
1888 | + {return; } //get out if this is already set. |
|
1889 | 1889 | |
1890 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
1891 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
1890 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
1891 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
1892 | 1892 | |
1893 | 1893 | //let's get the message templates |
1894 | 1894 | $MTP = EEM_Message_Template_Group::instance(); |
1895 | 1895 | |
1896 | - if ( empty($GRP_ID) ) |
|
1897 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
1896 | + if (empty($GRP_ID)) |
|
1897 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
1898 | 1898 | else |
1899 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
1899 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
1900 | 1900 | |
1901 | 1901 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
1902 | 1902 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -1915,7 +1915,7 @@ discard block |
||
1915 | 1915 | * @param array $args various things the context switcher needs. |
1916 | 1916 | * |
1917 | 1917 | */ |
1918 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
1918 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
1919 | 1919 | $context_details = $template_group_object->contexts_config(); |
1920 | 1920 | $context_label = $template_group_object->context_label(); |
1921 | 1921 | ob_start(); |
@@ -1923,26 +1923,26 @@ discard block |
||
1923 | 1923 | <div class="ee-msg-switcher-container"> |
1924 | 1924 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
1925 | 1925 | <?php |
1926 | - foreach ( $args as $name => $value ) { |
|
1927 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
1926 | + foreach ($args as $name => $value) { |
|
1927 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
1928 | 1928 | ?> |
1929 | 1929 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
1930 | 1930 | <?php |
1931 | 1931 | } |
1932 | 1932 | //setup nonce_url |
1933 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
1933 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
1934 | 1934 | ?> |
1935 | 1935 | <select name="context"> |
1936 | 1936 | <?php |
1937 | 1937 | $context_templates = $template_group_object->context_templates(); |
1938 | - if ( is_array($context_templates) ) : |
|
1939 | - foreach ( $context_templates as $context => $template_fields ) : |
|
1938 | + if (is_array($context_templates)) : |
|
1939 | + foreach ($context_templates as $context => $template_fields) : |
|
1940 | 1940 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
1941 | 1941 | ?> |
1942 | 1942 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>><?php echo $context_details[$context]['label']; ?></option> |
1943 | 1943 | <?php endforeach; endif; ?> |
1944 | 1944 | </select> |
1945 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
1945 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
1946 | 1946 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
1947 | 1947 | </form> |
1948 | 1948 | <?php echo $args['extra']; ?> |
@@ -1969,8 +1969,8 @@ discard block |
||
1969 | 1969 | * @return array |
1970 | 1970 | */ |
1971 | 1971 | protected function _set_message_template_column_values($index) { |
1972 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
1973 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
1972 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
1973 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
1974 | 1974 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
1975 | 1975 | } |
1976 | 1976 | } /*else { |
@@ -1979,22 +1979,22 @@ discard block |
||
1979 | 1979 | |
1980 | 1980 | |
1981 | 1981 | $set_column_values = array( |
1982 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
1983 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
1984 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
1985 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
1986 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
1987 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
1988 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
1989 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
1990 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
1991 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
1982 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
1983 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
1984 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
1985 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
1986 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
1987 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
1988 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
1989 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
1990 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
1991 | + ? absint($this->_req_data['MTP_is_global']) |
|
1992 | 1992 | : 0, |
1993 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
1994 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
1993 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
1994 | + ? absint($this->_req_data['MTP_is_override']) |
|
1995 | 1995 | : 0, |
1996 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
1997 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
1996 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
1997 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
1998 | 1998 | ); |
1999 | 1999 | |
2000 | 2000 | |
@@ -2006,28 +2006,28 @@ discard block |
||
2006 | 2006 | |
2007 | 2007 | |
2008 | 2008 | |
2009 | - protected function _insert_or_update_message_template($new = false ) { |
|
2009 | + protected function _insert_or_update_message_template($new = false) { |
|
2010 | 2010 | |
2011 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2011 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2012 | 2012 | $success = 0; |
2013 | 2013 | $override = false; |
2014 | 2014 | |
2015 | 2015 | //setup notices description |
2016 | - $messenger = !empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'] ) ) : false; |
|
2017 | - $message_type = !empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'] ) ) : false; |
|
2018 | - $context = !empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'] ) ) : false; |
|
2016 | + $messenger = ! empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) : false; |
|
2017 | + $message_type = ! empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) : false; |
|
2018 | + $context = ! empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) : false; |
|
2019 | 2019 | |
2020 | - $item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : ''; |
|
2020 | + $item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : ''; |
|
2021 | 2021 | $item_desc .= 'Message Template'; |
2022 | 2022 | $query_args = array(); |
2023 | 2023 | $edit_array = array(); |
2024 | 2024 | $action_desc = ''; |
2025 | 2025 | |
2026 | 2026 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2027 | - if ( $new ) { |
|
2028 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2029 | - if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) { |
|
2030 | - if ( empty($edit_array) ) { |
|
2027 | + if ($new) { |
|
2028 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2029 | + if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) { |
|
2030 | + if (empty($edit_array)) { |
|
2031 | 2031 | $success = 0; |
2032 | 2032 | } else { |
2033 | 2033 | $success = 1; |
@@ -2046,33 +2046,33 @@ discard block |
||
2046 | 2046 | |
2047 | 2047 | |
2048 | 2048 | //run update for each template field in displayed context |
2049 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2050 | - 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__ ); |
|
2049 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2050 | + 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__); |
|
2051 | 2051 | $success = 0; |
2052 | 2052 | |
2053 | 2053 | } else { |
2054 | 2054 | //first validate all fields! |
2055 | - $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']); |
|
2055 | + $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']); |
|
2056 | 2056 | |
2057 | 2057 | //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. |
2058 | - if ( is_array($validates) && !empty($validates) ) { |
|
2058 | + if (is_array($validates) && ! empty($validates)) { |
|
2059 | 2059 | //add the transient so when the form loads we know which fields to highlight |
2060 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2060 | + $this->_add_transient('edit_message_template', $validates); |
|
2061 | 2061 | |
2062 | 2062 | $success = 0; |
2063 | 2063 | |
2064 | 2064 | //setup notices |
2065 | - foreach ( $validates as $field => $error ) { |
|
2066 | - if ( isset($error['msg'] ) ) |
|
2067 | - {EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );} |
|
2065 | + foreach ($validates as $field => $error) { |
|
2066 | + if (isset($error['msg'])) |
|
2067 | + {EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); } |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | } else { |
2071 | 2071 | $set_column_values = array(); |
2072 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2072 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2073 | 2073 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2074 | 2074 | |
2075 | - $where_cols_n_values = array( 'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']); |
|
2075 | + $where_cols_n_values = array('MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']); |
|
2076 | 2076 | |
2077 | 2077 | $message_template_fields = array( |
2078 | 2078 | 'GRP_ID' => $set_column_values['GRP_ID'], |
@@ -2080,10 +2080,10 @@ discard block |
||
2080 | 2080 | 'MTP_context' => $set_column_values['MTP_context'], |
2081 | 2081 | 'MTP_content' => $set_column_values['MTP_content'] |
2082 | 2082 | ); |
2083 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2084 | - if ( $updated === false ) { |
|
2085 | - $msg = sprintf( __('%s field was NOT updated for some reason', 'event_espresso'), $template_field ); |
|
2086 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2083 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2084 | + if ($updated === false) { |
|
2085 | + $msg = sprintf(__('%s field was NOT updated for some reason', 'event_espresso'), $template_field); |
|
2086 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2087 | 2087 | } else { |
2088 | 2088 | $success = 1; |
2089 | 2089 | } |
@@ -2093,40 +2093,40 @@ discard block |
||
2093 | 2093 | |
2094 | 2094 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2095 | 2095 | $mtpg_fields = array( |
2096 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2097 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2098 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2099 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2100 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2101 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2102 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2103 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2104 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2096 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2097 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2098 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2099 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2100 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2101 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2102 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2103 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2104 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2105 | 2105 | : '', |
2106 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2107 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2106 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2107 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2108 | 2108 | : '' |
2109 | 2109 | ); |
2110 | 2110 | |
2111 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2112 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2111 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2112 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2113 | 2113 | |
2114 | - if ( $updated === false ) { |
|
2114 | + if ($updated === false) { |
|
2115 | 2115 | EE_Error::add_error( |
2116 | 2116 | sprintf( |
2117 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2118 | - $set_column_values[ 'GRP_ID' ] |
|
2117 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2118 | + $set_column_values['GRP_ID'] |
|
2119 | 2119 | ), |
2120 | 2120 | __FILE__, __FUNCTION__, __LINE__ |
2121 | 2121 | ); |
2122 | 2122 | } else { |
2123 | 2123 | //k now we need to ensure the template_pack and template_variation fields are set. |
2124 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) ? $this->_req_data['MTP_template_pack'] : 'default'; |
|
2125 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) ? $this->_req_data['MTP_template_variation'] : 'default'; |
|
2126 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2127 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2128 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2129 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2124 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) ? $this->_req_data['MTP_template_pack'] : 'default'; |
|
2125 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) ? $this->_req_data['MTP_template_variation'] : 'default'; |
|
2126 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2127 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2128 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2129 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2130 | 2130 | } |
2131 | 2131 | $success = 1; |
2132 | 2132 | } |
@@ -2136,7 +2136,7 @@ discard block |
||
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | //we return things differently if doing ajax |
2139 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2139 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2140 | 2140 | $this->_template_args['success'] = $success; |
2141 | 2141 | $this->_template_args['error'] = ! $success ? true : false; |
2142 | 2142 | $this->_template_args['content'] = ''; |
@@ -2144,9 +2144,9 @@ discard block |
||
2144 | 2144 | 'grpID' => $edit_array['GRP_ID'], |
2145 | 2145 | 'templateName' => $edit_array['template_name'] |
2146 | 2146 | ); |
2147 | - if ( $success ) { |
|
2147 | + if ($success) { |
|
2148 | 2148 | EE_Error::overwrite_success(); |
2149 | - 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') ); |
|
2149 | + 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')); |
|
2150 | 2150 | } |
2151 | 2151 | |
2152 | 2152 | $this->_return_json(); |
@@ -2154,13 +2154,13 @@ discard block |
||
2154 | 2154 | |
2155 | 2155 | |
2156 | 2156 | //was a test send triggered? |
2157 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2157 | + if (isset($this->_req_data['test_button'])) { |
|
2158 | 2158 | EE_Error::overwrite_success(); |
2159 | - $this->_do_test_send( $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] ); |
|
2159 | + $this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2160 | 2160 | $override = true; |
2161 | 2161 | } |
2162 | 2162 | |
2163 | - if ( empty( $query_args ) ) { |
|
2163 | + if (empty($query_args)) { |
|
2164 | 2164 | $query_args = array( |
2165 | 2165 | 'id' => $this->_req_data['GRP_ID'], |
2166 | 2166 | 'context' => $this->_req_data['MTP_context'], |
@@ -2168,7 +2168,7 @@ discard block |
||
2168 | 2168 | ); |
2169 | 2169 | } |
2170 | 2170 | |
2171 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2171 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2172 | 2172 | } |
2173 | 2173 | |
2174 | 2174 | |
@@ -2182,28 +2182,28 @@ discard block |
||
2182 | 2182 | * @param string $message_type message type being tested |
2183 | 2183 | * |
2184 | 2184 | */ |
2185 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2185 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2186 | 2186 | //set things up for preview |
2187 | 2187 | $this->_req_data['messenger'] = $messenger; |
2188 | 2188 | $this->_req_data['message_type'] = $message_type; |
2189 | 2189 | $this->_req_data['context'] = $context; |
2190 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2191 | - $active_messenger = $this->_active_messengers[ $messenger ][ 'obj' ]; |
|
2190 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2191 | + $active_messenger = $this->_active_messengers[$messenger]['obj']; |
|
2192 | 2192 | |
2193 | 2193 | //let's save any existing fields that might be required by the messenger |
2194 | 2194 | if ( |
2195 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2195 | + isset($this->_req_data['test_settings_fld']) |
|
2196 | 2196 | && $active_messenger instanceof EE_Messenger |
2197 | 2197 | ) { |
2198 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2198 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2199 | 2199 | } |
2200 | 2200 | |
2201 | 2201 | $success = $this->_preview_message(true); |
2202 | 2202 | |
2203 | - if ( $success ) { |
|
2204 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2203 | + if ($success) { |
|
2204 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2205 | 2205 | } else { |
2206 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2206 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2207 | 2207 | } |
2208 | 2208 | } |
2209 | 2209 | |
@@ -2229,12 +2229,12 @@ discard block |
||
2229 | 2229 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2230 | 2230 | |
2231 | 2231 | //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. |
2232 | - if ( empty( $message_types ) ) |
|
2233 | - {return true;} |
|
2232 | + if (empty($message_types)) |
|
2233 | + {return true; } |
|
2234 | 2234 | |
2235 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
2235 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
2236 | 2236 | |
2237 | - return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2237 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2238 | 2238 | |
2239 | 2239 | } |
2240 | 2240 | |
@@ -2251,33 +2251,33 @@ discard block |
||
2251 | 2251 | * |
2252 | 2252 | * @return void |
2253 | 2253 | */ |
2254 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2255 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2254 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2255 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2256 | 2256 | $MTP = EEM_Message_Template_Group::instance(); |
2257 | 2257 | |
2258 | 2258 | $success = 1; |
2259 | 2259 | |
2260 | 2260 | //incoming GRP_IDs |
2261 | - if ( $all ) { |
|
2261 | + if ($all) { |
|
2262 | 2262 | //Checkboxes |
2263 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2263 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2264 | 2264 | //if array has more than one element then success message should be plural. |
2265 | 2265 | //todo: what about nonce? |
2266 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2266 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2267 | 2267 | |
2268 | 2268 | //cycle through checkboxes |
2269 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2270 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2271 | - if ( ! $trashed_or_restored ) { |
|
2269 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2270 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2271 | + if ( ! $trashed_or_restored) { |
|
2272 | 2272 | $success = 0; |
2273 | 2273 | } |
2274 | 2274 | } |
2275 | 2275 | } else { |
2276 | 2276 | //grab single GRP_ID and handle |
2277 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2278 | - if ( ! empty( $GRP_ID ) ) { |
|
2279 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2280 | - if ( ! $trashed_or_restored ) { |
|
2277 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2278 | + if ( ! empty($GRP_ID)) { |
|
2279 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2280 | + if ( ! $trashed_or_restored) { |
|
2281 | 2281 | $success = 0; |
2282 | 2282 | } |
2283 | 2283 | } else { |
@@ -2289,13 +2289,13 @@ discard block |
||
2289 | 2289 | |
2290 | 2290 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2291 | 2291 | |
2292 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2292 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2293 | 2293 | |
2294 | 2294 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2295 | 2295 | |
2296 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2296 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2297 | 2297 | |
2298 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2298 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2299 | 2299 | |
2300 | 2300 | } |
2301 | 2301 | |
@@ -2311,24 +2311,24 @@ discard block |
||
2311 | 2311 | * @return void |
2312 | 2312 | */ |
2313 | 2313 | protected function _delete_message_template() { |
2314 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2314 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2315 | 2315 | |
2316 | 2316 | //checkboxes |
2317 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2317 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2318 | 2318 | //if array has more than one element then success message should be plural |
2319 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2319 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2320 | 2320 | |
2321 | 2321 | //cycle through bulk action checkboxes |
2322 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2323 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2322 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2323 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2324 | 2324 | } |
2325 | 2325 | } else { |
2326 | 2326 | //grab single grp_id and delete |
2327 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2328 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2327 | + $GRP_ID = absint($this->_req_data['id']); |
|
2328 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2329 | 2329 | } |
2330 | 2330 | |
2331 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2331 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2332 | 2332 | |
2333 | 2333 | } |
2334 | 2334 | |
@@ -2343,20 +2343,20 @@ discard block |
||
2343 | 2343 | * |
2344 | 2344 | * @return bool boolean to indicate the success of the deletes or not. |
2345 | 2345 | */ |
2346 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2346 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2347 | 2347 | $success = 1; |
2348 | 2348 | $MTPG = EEM_Message_Template_Group::instance(); |
2349 | 2349 | //first let's GET this group |
2350 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2350 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2351 | 2351 | //then delete permanently all the related Message Templates |
2352 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2352 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2353 | 2353 | |
2354 | - if ( $deleted === 0 ) |
|
2355 | - {$success = 0;} |
|
2354 | + if ($deleted === 0) |
|
2355 | + {$success = 0; } |
|
2356 | 2356 | |
2357 | 2357 | //now delete permanently this particular group |
2358 | 2358 | |
2359 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2359 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2360 | 2360 | $success = 0; |
2361 | 2361 | } |
2362 | 2362 | return $success; |
@@ -2374,7 +2374,7 @@ discard block |
||
2374 | 2374 | * @return string |
2375 | 2375 | */ |
2376 | 2376 | protected function _learn_more_about_message_templates_link() { |
2377 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2377 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2378 | 2378 | } |
2379 | 2379 | |
2380 | 2380 | |
@@ -2389,14 +2389,14 @@ discard block |
||
2389 | 2389 | */ |
2390 | 2390 | protected function _settings() { |
2391 | 2391 | |
2392 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
2392 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
2393 | 2393 | |
2394 | 2394 | $this->_set_m_mt_settings(); |
2395 | 2395 | |
2396 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2396 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2397 | 2397 | |
2398 | 2398 | //let's setup the messenger tabs |
2399 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2399 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2400 | 2400 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2401 | 2401 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2402 | 2402 | |
@@ -2415,8 +2415,8 @@ discard block |
||
2415 | 2415 | */ |
2416 | 2416 | protected function _set_m_mt_settings() { |
2417 | 2417 | //first if this is already set then lets get out no need to regenerate data. |
2418 | - if ( !empty($this->_m_mt_settings) ) |
|
2419 | - {return;} |
|
2418 | + if ( ! empty($this->_m_mt_settings)) |
|
2419 | + {return; } |
|
2420 | 2420 | |
2421 | 2421 | //$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
2422 | 2422 | |
@@ -2428,10 +2428,10 @@ discard block |
||
2428 | 2428 | |
2429 | 2429 | //assemble the array for the _tab_text_links helper |
2430 | 2430 | |
2431 | - foreach ( $messengers as $messenger ) { |
|
2431 | + foreach ($messengers as $messenger) { |
|
2432 | 2432 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2433 | 2433 | 'label' => ucwords($messenger->label['singular']), |
2434 | - 'class' => isset( $this->_active_messengers[$messenger->name] ) ? 'messenger-active' : '', |
|
2434 | + 'class' => isset($this->_active_messengers[$messenger->name]) ? 'messenger-active' : '', |
|
2435 | 2435 | 'href' => $messenger->name, |
2436 | 2436 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2437 | 2437 | 'slug' => $messenger->name, |
@@ -2441,27 +2441,27 @@ discard block |
||
2441 | 2441 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2442 | 2442 | |
2443 | 2443 | //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. |
2444 | - $selected_settings = isset( $this->_active_messengers[$messenger->name]['settings'] ) ? $this->_active_messengers[$messenger->name]['settings'] : array(); |
|
2445 | - foreach ( $message_types as $message_type ) { |
|
2444 | + $selected_settings = isset($this->_active_messengers[$messenger->name]['settings']) ? $this->_active_messengers[$messenger->name]['settings'] : array(); |
|
2445 | + foreach ($message_types as $message_type) { |
|
2446 | 2446 | //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. |
2447 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2447 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2448 | 2448 | continue; |
2449 | 2449 | } |
2450 | 2450 | |
2451 | - $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 | + $a_or_i = isset($selected_settings[$messenger->name.'-message_types'][$message_type->name]) && $selected_settings[$messenger->name.'-message_types'][$message_type->name] ? 'active' : 'inactive'; |
|
2452 | 2452 | |
2453 | 2453 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2454 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2455 | - 'class' => 'message-type-' . $a_or_i, |
|
2456 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2457 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2458 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2454 | + 'label' => ucwords($message_type->label['singular']), |
|
2455 | + 'class' => 'message-type-'.$a_or_i, |
|
2456 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2457 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2458 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2459 | 2459 | 'title' => $a_or_i == 'active' |
2460 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2461 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2460 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2461 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2462 | 2462 | 'content' => $a_or_i == 'active' |
2463 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2464 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2463 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2464 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2465 | 2465 | 'slug' => $message_type->name, |
2466 | 2466 | 'active' => $a_or_i == 'active' ? true : false, |
2467 | 2467 | 'obj' => $message_type |
@@ -2480,34 +2480,34 @@ discard block |
||
2480 | 2480 | * |
2481 | 2481 | * @return string html output for the content |
2482 | 2482 | */ |
2483 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2483 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2484 | 2484 | //get message type fields |
2485 | 2485 | $fields = $message_type->get_admin_settings_fields(); |
2486 | - $settings_template_args['template_form_fields']= ''; |
|
2486 | + $settings_template_args['template_form_fields'] = ''; |
|
2487 | 2487 | |
2488 | - if ( !empty( $fields ) && $active ) { |
|
2488 | + if ( ! empty($fields) && $active) { |
|
2489 | 2489 | |
2490 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2490 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2491 | 2491 | |
2492 | - foreach( $fields as $fldname => $fldprops ) { |
|
2493 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2492 | + foreach ($fields as $fldname => $fldprops) { |
|
2493 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2494 | 2494 | $template_form_field[$field_id] = array( |
2495 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2495 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2496 | 2496 | 'label' => $fldprops['label'], |
2497 | 2497 | 'input' => $fldprops['field_type'], |
2498 | 2498 | 'type' => $fldprops['value_type'], |
2499 | 2499 | 'required' => $fldprops['required'], |
2500 | 2500 | 'validation' => $fldprops['validation'], |
2501 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2502 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2503 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2501 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2502 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2503 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2504 | 2504 | 'css_class' => 'no-drag', |
2505 | 2505 | 'format' => $fldprops['format'] |
2506 | 2506 | ); |
2507 | 2507 | } |
2508 | 2508 | |
2509 | 2509 | |
2510 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2510 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2511 | 2511 | } |
2512 | 2512 | |
2513 | 2513 | $settings_template_args['description'] = $message_type->description; |
@@ -2527,13 +2527,13 @@ discard block |
||
2527 | 2527 | ) |
2528 | 2528 | ); |
2529 | 2529 | |
2530 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2531 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2530 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2531 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2532 | 2532 | |
2533 | 2533 | |
2534 | 2534 | |
2535 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2536 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2535 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2536 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2537 | 2537 | return $content; |
2538 | 2538 | } |
2539 | 2539 | |
@@ -2550,21 +2550,21 @@ discard block |
||
2550 | 2550 | $m_boxes = $mt_boxes = array(); |
2551 | 2551 | $m_template_args = $mt_template_args = array(); |
2552 | 2552 | |
2553 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2553 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2554 | 2554 | |
2555 | - foreach ( $this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array ) { |
|
2555 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2556 | 2556 | |
2557 | - $hide_on_message = isset( $this->_active_messengers[$messenger] ) ? '' : 'hidden'; |
|
2558 | - $hide_off_message = isset( $this->_active_messengers[$messenger] ) ? 'hidden' : ''; |
|
2557 | + $hide_on_message = isset($this->_active_messengers[$messenger]) ? '' : 'hidden'; |
|
2558 | + $hide_off_message = isset($this->_active_messengers[$messenger]) ? 'hidden' : ''; |
|
2559 | 2559 | |
2560 | 2560 | //messenger meta boxes |
2561 | 2561 | $active = $selected_messenger == $messenger ? true : false; |
2562 | - $active_mt_tabs = isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] ) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : ''; |
|
2563 | - $m_boxes[$messenger . '_a_box'] = sprintf( __('%s Settings', 'event_espresso'), $tab_array['label'] ); |
|
2564 | - $m_template_args[$messenger . '_a_box'] = array( |
|
2565 | - 'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2566 | - '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'] ) : '', |
|
2567 | - 'content' => $this->_get_messenger_box_content( $tab_array['obj'] ), |
|
2562 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : ''; |
|
2563 | + $m_boxes[$messenger.'_a_box'] = sprintf(__('%s Settings', 'event_espresso'), $tab_array['label']); |
|
2564 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2565 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2566 | + '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']) : '', |
|
2567 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2568 | 2568 | 'hidden' => $active ? '' : ' hidden', |
2569 | 2569 | 'hide_on_message' => $hide_on_message, |
2570 | 2570 | 'messenger' => $messenger, |
@@ -2573,10 +2573,10 @@ discard block |
||
2573 | 2573 | |
2574 | 2574 | |
2575 | 2575 | //message type meta boxes (which is really just the inactive container for each messenger showing inactive message types for that messenger) |
2576 | - $mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2577 | - $mt_template_args[$messenger . '_i_box'] = array( |
|
2578 | - 'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2579 | - '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'] ) : '', |
|
2576 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2577 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2578 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2579 | + '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']) : '', |
|
2580 | 2580 | 'hidden' => $active ? '' : ' hidden', |
2581 | 2581 | 'hide_on_message' => $hide_on_message, |
2582 | 2582 | 'hide_off_message' => $hide_off_message, |
@@ -2586,19 +2586,19 @@ discard block |
||
2586 | 2586 | } |
2587 | 2587 | |
2588 | 2588 | //register messenger metaboxes |
2589 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2590 | - foreach ( $m_boxes as $box => $label ) { |
|
2591 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2592 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2593 | - 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 ); |
|
2589 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2590 | + foreach ($m_boxes as $box => $label) { |
|
2591 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2592 | + $msgr = str_replace('_a_box', '', $box); |
|
2593 | + 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); |
|
2594 | 2594 | } |
2595 | 2595 | |
2596 | 2596 | //register message type metaboxes |
2597 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2598 | - foreach ( $mt_boxes as $box => $label ) { |
|
2599 | - $callback_args = array( 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] ); |
|
2600 | - $mt = str_replace( '_i_box', '', $box ); |
|
2601 | - 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 ); |
|
2597 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2598 | + foreach ($mt_boxes as $box => $label) { |
|
2599 | + $callback_args = array('template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]); |
|
2600 | + $mt = str_replace('_i_box', '', $box); |
|
2601 | + 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); |
|
2602 | 2602 | } |
2603 | 2603 | |
2604 | 2604 | } |
@@ -2611,13 +2611,13 @@ discard block |
||
2611 | 2611 | * |
2612 | 2612 | * @return string html formatted tabs |
2613 | 2613 | */ |
2614 | - protected function _get_mt_tabs( $tab_array ) { |
|
2614 | + protected function _get_mt_tabs($tab_array) { |
|
2615 | 2615 | $tab_array = (array) $tab_array; |
2616 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2616 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2617 | 2617 | $tabs = ''; |
2618 | 2618 | |
2619 | - foreach ( $tab_array as $tab ) { |
|
2620 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
2619 | + foreach ($tab_array as $tab) { |
|
2620 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
2621 | 2621 | } |
2622 | 2622 | |
2623 | 2623 | return $tabs; |
@@ -2633,7 +2633,7 @@ discard block |
||
2633 | 2633 | * |
2634 | 2634 | * @return string html formatted content |
2635 | 2635 | */ |
2636 | - protected function _get_messenger_box_content( $messenger ) { |
|
2636 | + protected function _get_messenger_box_content($messenger) { |
|
2637 | 2637 | |
2638 | 2638 | $fields = $messenger->get_admin_settings_fields(); |
2639 | 2639 | $settings_template_args['template_form_fields'] = ''; |
@@ -2642,27 +2642,27 @@ discard block |
||
2642 | 2642 | $settings_template_args['active'] = isset($this->_active_messengers[$messenger->name]) ? true : false; |
2643 | 2643 | |
2644 | 2644 | |
2645 | - if ( !empty( $fields ) ) { |
|
2645 | + if ( ! empty($fields)) { |
|
2646 | 2646 | |
2647 | 2647 | $existing_settings = $messenger->get_existing_admin_settings(); |
2648 | 2648 | |
2649 | - foreach( $fields as $fldname => $fldprops ) { |
|
2650 | - $field_id = $messenger->name . '-' . $fldname; |
|
2649 | + foreach ($fields as $fldname => $fldprops) { |
|
2650 | + $field_id = $messenger->name.'-'.$fldname; |
|
2651 | 2651 | $template_form_field[$field_id] = array( |
2652 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
2652 | + 'name' => 'messenger_settings['.$field_id.']', |
|
2653 | 2653 | 'label' => $fldprops['label'], |
2654 | 2654 | 'input' => $fldprops['field_type'], |
2655 | 2655 | 'type' => $fldprops['value_type'], |
2656 | 2656 | 'required' => $fldprops['required'], |
2657 | 2657 | 'validation' => $fldprops['validation'], |
2658 | - 'value' => isset( $existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'], |
|
2658 | + 'value' => isset($existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'], |
|
2659 | 2659 | 'css_class' => '', |
2660 | 2660 | 'format' => $fldprops['format'] |
2661 | 2661 | ); |
2662 | 2662 | } |
2663 | 2663 | |
2664 | 2664 | |
2665 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) : ''; |
|
2665 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') : ''; |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | //we also need some hidden fields |
@@ -2678,8 +2678,8 @@ discard block |
||
2678 | 2678 | ); |
2679 | 2679 | |
2680 | 2680 | //make sure any active message types that are existing are included in the hidden fields |
2681 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
2682 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
2681 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
2682 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
2683 | 2683 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
2684 | 2684 | 'type' => 'hidden', |
2685 | 2685 | 'value' => $mt |
@@ -2687,25 +2687,25 @@ discard block |
||
2687 | 2687 | } |
2688 | 2688 | } |
2689 | 2689 | |
2690 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2690 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2691 | 2691 | |
2692 | - $active = isset( $this->_active_messengers[$messenger->name] ) ? true : false; |
|
2692 | + $active = isset($this->_active_messengers[$messenger->name]) ? true : false; |
|
2693 | 2693 | |
2694 | 2694 | $settings_template_args['messenger'] = $messenger->name; |
2695 | 2695 | $settings_template_args['description'] = $messenger->description; |
2696 | 2696 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
2697 | 2697 | |
2698 | 2698 | |
2699 | - $settings_template_args['show_hide_edit_form'] = isset( $this->_active_messengers[$messenger->name] ) ? $settings_template_args['show_hide_edit_form'] : ' hidden'; |
|
2699 | + $settings_template_args['show_hide_edit_form'] = isset($this->_active_messengers[$messenger->name]) ? $settings_template_args['show_hide_edit_form'] : ' hidden'; |
|
2700 | 2700 | |
2701 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : $settings_template_args['show_hide_edit_form']; |
|
2701 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : $settings_template_args['show_hide_edit_form']; |
|
2702 | 2702 | |
2703 | 2703 | |
2704 | 2704 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
2705 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
2705 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
2706 | 2706 | $settings_template_args['on_off_status'] = $active ? true : false; |
2707 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
2708 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
2707 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
2708 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2709 | 2709 | return $content; |
2710 | 2710 | } |
2711 | 2711 | |
@@ -2719,39 +2719,39 @@ discard block |
||
2719 | 2719 | public function activate_messenger_toggle() { |
2720 | 2720 | $success = true; |
2721 | 2721 | //let's check that we have required data |
2722 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2723 | - EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2722 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2723 | + EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2724 | 2724 | $success = false; |
2725 | 2725 | } |
2726 | 2726 | |
2727 | 2727 | //do a nonce check here since we're not arriving via a normal route |
2728 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
2729 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
2728 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
2729 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
2730 | 2730 | |
2731 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2731 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2732 | 2732 | |
2733 | 2733 | |
2734 | 2734 | |
2735 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2736 | - EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2735 | + if ( ! isset($this->_req_data['status'])) { |
|
2736 | + EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2737 | 2737 | $success = false; |
2738 | 2738 | } |
2739 | 2739 | |
2740 | 2740 | //do check to verify we have a valid status. |
2741 | 2741 | $status = $this->_req_data['status']; |
2742 | 2742 | |
2743 | - if ( $status != 'off' && $status != 'on' ) { |
|
2744 | - 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__ ); |
|
2743 | + if ($status != 'off' && $status != 'on') { |
|
2744 | + 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__); |
|
2745 | 2745 | $success = false; |
2746 | 2746 | } |
2747 | 2747 | |
2748 | - if ( $success ) { |
|
2748 | + if ($success) { |
|
2749 | 2749 | //made it here? Stop dawdling then!! |
2750 | - if ( $status == 'off' ) { |
|
2750 | + if ($status == 'off') { |
|
2751 | 2751 | //off = deactivate. get it? |
2752 | - $success = $this->_activate_messenger( $this->_req_data['messenger'], true ); |
|
2752 | + $success = $this->_activate_messenger($this->_req_data['messenger'], true); |
|
2753 | 2753 | } else { |
2754 | - $success = $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
2754 | + $success = $this->_activate_messenger($this->_req_data['messenger']); |
|
2755 | 2755 | } |
2756 | 2756 | } |
2757 | 2757 | |
@@ -2777,26 +2777,26 @@ discard block |
||
2777 | 2777 | |
2778 | 2778 | |
2779 | 2779 | //let's make sure we have the necessary data |
2780 | - if ( !isset( $this->_req_data[ 'message_type' ] ) ) { |
|
2781 | - EE_Error::add_error( __('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2780 | + if ( ! isset($this->_req_data['message_type'])) { |
|
2781 | + EE_Error::add_error(__('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2782 | 2782 | $success = false; |
2783 | 2783 | } |
2784 | 2784 | |
2785 | 2785 | |
2786 | 2786 | //do a nonce check here since we're not arriving via a normal route |
2787 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
2788 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
2787 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
2788 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
2789 | 2789 | |
2790 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2790 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2791 | 2791 | |
2792 | 2792 | |
2793 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2794 | - EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2793 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2794 | + EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2795 | 2795 | $success = false; |
2796 | 2796 | } |
2797 | 2797 | |
2798 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2799 | - EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2798 | + if ( ! isset($this->_req_data['status'])) { |
|
2799 | + EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2800 | 2800 | $success = false; |
2801 | 2801 | } |
2802 | 2802 | |
@@ -2804,16 +2804,16 @@ discard block |
||
2804 | 2804 | //do check to verify we have a valid status. |
2805 | 2805 | $status = $this->_req_data['status']; |
2806 | 2806 | |
2807 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
2808 | - 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__ ); |
|
2807 | + if ($status != 'activate' && $status != 'deactivate') { |
|
2808 | + 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__); |
|
2809 | 2809 | $success = false; |
2810 | 2810 | } |
2811 | 2811 | |
2812 | 2812 | |
2813 | - if ( $success ) { |
|
2813 | + if ($success) { |
|
2814 | 2814 | //made it here? um, what are you waiting for then? |
2815 | 2815 | $deactivate = $status == 'deactivate' ? true : false; |
2816 | - $success = $this->_activate_messenger( $this->_req_data['messenger'], $deactivate, $this->_req_data['message_type'] ); |
|
2816 | + $success = $this->_activate_messenger($this->_req_data['messenger'], $deactivate, $this->_req_data['message_type']); |
|
2817 | 2817 | } |
2818 | 2818 | |
2819 | 2819 | $this->_template_args['success'] = $success; |
@@ -2843,19 +2843,19 @@ discard block |
||
2843 | 2843 | |
2844 | 2844 | $this->_set_m_mt_settings(); |
2845 | 2845 | |
2846 | - if ( !$deactivate ) { |
|
2846 | + if ( ! $deactivate) { |
|
2847 | 2847 | |
2848 | 2848 | |
2849 | 2849 | //we are activating. we can use $this->_m_mt_settings to get all the installed messengers |
2850 | - $this->_active_messengers[$messenger]['settings'] = !isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings']; |
|
2850 | + $this->_active_messengers[$messenger]['settings'] = ! isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings']; |
|
2851 | 2851 | $this->_active_messengers[$messenger]['obj'] = $this->_m_mt_settings['messenger_tabs'][$messenger]['obj']; |
2852 | 2852 | /** @type EE_Messenger $active_messenger */ |
2853 | - $active_messenger = $this->_active_messengers[ $messenger ][ 'obj' ]; |
|
2853 | + $active_messenger = $this->_active_messengers[$messenger]['obj']; |
|
2854 | 2854 | |
2855 | 2855 | //get has_active so we can sure its kept up to date. |
2856 | - $has_activated = get_option( 'ee_has_activated_messages' ); |
|
2856 | + $has_activated = get_option('ee_has_activated_messages'); |
|
2857 | 2857 | |
2858 | - if ( empty( $has_activated[$messenger] ) ) { |
|
2858 | + if (empty($has_activated[$messenger])) { |
|
2859 | 2859 | $has_activated[$messenger] = array(); |
2860 | 2860 | } |
2861 | 2861 | |
@@ -2864,22 +2864,22 @@ discard block |
||
2864 | 2864 | ? (array) $message_type |
2865 | 2865 | : $active_messenger->get_default_message_types(); |
2866 | 2866 | |
2867 | - foreach ( $default_types as $type ) { |
|
2867 | + foreach ($default_types as $type) { |
|
2868 | 2868 | /** @type EE_Message_Type $active_message_type */ |
2869 | - $active_message_type = $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ][ $type ][ 'obj' ]; |
|
2869 | + $active_message_type = $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$type]['obj']; |
|
2870 | 2870 | $settings_fields = $active_message_type->get_admin_settings_fields(); |
2871 | 2871 | $settings = array(); |
2872 | - if ( !empty( $settings_fields ) ) { |
|
2872 | + if ( ! empty($settings_fields)) { |
|
2873 | 2873 | //we have fields for this message type so let's get the defaults for saving. |
2874 | - foreach ( $settings_fields as $field => $values ) { |
|
2874 | + foreach ($settings_fields as $field => $values) { |
|
2875 | 2875 | $settings[$field] = $values['default']; |
2876 | 2876 | } |
2877 | 2877 | //let's set the data for reloading this message type form in ajax |
2878 | 2878 | $this->_template_args['data']['mt_reload'][] = $type; |
2879 | 2879 | } |
2880 | - $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$type]['settings'] = $settings; |
|
2880 | + $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$type]['settings'] = $settings; |
|
2881 | 2881 | |
2882 | - if ( ! in_array( $type, $has_activated[$messenger] ) ) { |
|
2882 | + if ( ! in_array($type, $has_activated[$messenger])) { |
|
2883 | 2883 | $has_activated[$messenger][] = $type; |
2884 | 2884 | } |
2885 | 2885 | } |
@@ -2887,41 +2887,41 @@ discard block |
||
2887 | 2887 | //any default settings for the messenger? |
2888 | 2888 | $msgr_settings = $active_messenger->get_admin_settings_fields(); |
2889 | 2889 | |
2890 | - if ( !empty( $msgr_settings ) ) { |
|
2891 | - foreach ( $msgr_settings as $field => $value ) { |
|
2890 | + if ( ! empty($msgr_settings)) { |
|
2891 | + foreach ($msgr_settings as $field => $value) { |
|
2892 | 2892 | $this->_active_messengers[$messenger]['settings'][$field] = $value; |
2893 | 2893 | } |
2894 | 2894 | } |
2895 | 2895 | |
2896 | 2896 | //update settings in database |
2897 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
2898 | - update_option( 'ee_has_activated_messages', $has_activated ); |
|
2897 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
2898 | + update_option('ee_has_activated_messages', $has_activated); |
|
2899 | 2899 | |
2900 | 2900 | |
2901 | 2901 | //generate new templates (if necessary) |
2902 | - $templates = $this->_generate_new_templates( $messenger, $default_types, 0, true ); |
|
2902 | + $templates = $this->_generate_new_templates($messenger, $default_types, 0, true); |
|
2903 | 2903 | |
2904 | 2904 | EE_Error::overwrite_success(); |
2905 | 2905 | |
2906 | 2906 | //if generation failed then we need to remove the active messenger. |
2907 | - if ( !$templates ) { |
|
2907 | + if ( ! $templates) { |
|
2908 | 2908 | unset($this->_active_messengers[$messenger]); |
2909 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
2909 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
2910 | 2910 | } else { |
2911 | 2911 | //all is good let's do a success message |
2912 | - if ( $message_type ) { |
|
2913 | - 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]['obj']->label['singular'] ) ) ); |
|
2912 | + if ($message_type) { |
|
2913 | + 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]['obj']->label['singular']))); |
|
2914 | 2914 | |
2915 | 2915 | //if message type was invoice then let's make sure we activate the invoice payment method. |
2916 | - if ( $message_type == 'invoice' ) { |
|
2917 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
2918 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
2919 | - if ( $pm instanceof EE_Payment_Method ) { |
|
2920 | - 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' ) ); |
|
2916 | + if ($message_type == 'invoice') { |
|
2917 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
2918 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
2919 | + if ($pm instanceof EE_Payment_Method) { |
|
2920 | + 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')); |
|
2921 | 2921 | } |
2922 | 2922 | } |
2923 | 2923 | } else { |
2924 | - EE_Error::add_success( sprintf( __('%s messenger has been successfully activated', 'event_espresso'), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) ); |
|
2924 | + EE_Error::add_success(sprintf(__('%s messenger has been successfully activated', 'event_espresso'), ucwords($this->_active_messengers[$messenger]['obj']->label['singular']))); |
|
2925 | 2925 | } |
2926 | 2926 | } |
2927 | 2927 | |
@@ -2934,37 +2934,37 @@ discard block |
||
2934 | 2934 | $update_array = array( |
2935 | 2935 | 'MTP_messenger' => $messenger); |
2936 | 2936 | |
2937 | - if ( $message_type ) { |
|
2937 | + if ($message_type) { |
|
2938 | 2938 | $update_array['MTP_message_type'] = $message_type; |
2939 | 2939 | } |
2940 | - EEM_Message_Template_Group::instance()->update( array( 'MTP_is_active' => 0 ), array($update_array) ); |
|
2940 | + EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => 0), array($update_array)); |
|
2941 | 2941 | |
2942 | 2942 | $messenger_obj = $this->_active_messengers[$messenger]['obj']; |
2943 | 2943 | |
2944 | 2944 | //if this is a message type deactivation then we're only unsetting the message type otherwise unset the messenger |
2945 | - if ( $message_type ) { |
|
2946 | - unset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] ); |
|
2945 | + if ($message_type) { |
|
2946 | + unset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type]); |
|
2947 | 2947 | } else { |
2948 | - unset( $this->_active_messengers[$messenger] ); |
|
2948 | + unset($this->_active_messengers[$messenger]); |
|
2949 | 2949 | } |
2950 | 2950 | |
2951 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
2951 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
2952 | 2952 | EE_Error::overwrite_success(); |
2953 | - if ( $message_type ) { |
|
2954 | - 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']) ) ); |
|
2953 | + if ($message_type) { |
|
2954 | + 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']))); |
|
2955 | 2955 | } else { |
2956 | - EE_Error::add_success( sprintf( __('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'] ) ) ); |
|
2956 | + EE_Error::add_success(sprintf(__('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular']))); |
|
2957 | 2957 | } |
2958 | 2958 | |
2959 | 2959 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
2960 | - if ( $messenger == 'html' || $message_type == 'invoice') { |
|
2961 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
2962 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
2963 | - if ( $count_updated > 0 ) { |
|
2960 | + if ($messenger == 'html' || $message_type == 'invoice') { |
|
2961 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
2962 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
2963 | + if ($count_updated > 0) { |
|
2964 | 2964 | $msg = $message_type == 'invoice' |
2965 | - ? __('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' ) |
|
2966 | - : __('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' ); |
|
2967 | - EE_Error::add_attention( $msg ); |
|
2965 | + ? __('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') |
|
2966 | + : __('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'); |
|
2967 | + EE_Error::add_attention($msg); |
|
2968 | 2968 | } |
2969 | 2969 | } |
2970 | 2970 | |
@@ -2981,8 +2981,8 @@ discard block |
||
2981 | 2981 | * @return string html data |
2982 | 2982 | */ |
2983 | 2983 | public function update_mt_form() { |
2984 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
2985 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2984 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
2985 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
2986 | 2986 | return $this->_return_json(); |
2987 | 2987 | } |
2988 | 2988 | |
@@ -2991,7 +2991,7 @@ discard block |
||
2991 | 2991 | $message_type = $message_types[$this->_req_data['message_type']]['obj']; |
2992 | 2992 | $messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj']; |
2993 | 2993 | |
2994 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
2994 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
2995 | 2995 | $this->_template_args['success'] = true; |
2996 | 2996 | $this->_template_args['content'] = $content; |
2997 | 2997 | return $this->_return_json(); |
@@ -3006,36 +3006,36 @@ discard block |
||
3006 | 3006 | * @return string json success or fail message |
3007 | 3007 | */ |
3008 | 3008 | public function save_settings() { |
3009 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3010 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3009 | + if ( ! isset($this->_req_data['type'])) { |
|
3010 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3011 | 3011 | $this->_template_args['error'] = true; |
3012 | 3012 | $this->_return_json(); |
3013 | 3013 | } |
3014 | 3014 | |
3015 | 3015 | |
3016 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3016 | + if ($this->_req_data['type'] == 'messenger') { |
|
3017 | 3017 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3018 | 3018 | $messenger = $settings['messenger']; |
3019 | 3019 | //let's setup the settings data |
3020 | - foreach ( $settings as $key => $value ) { |
|
3021 | - switch ( $key ) { |
|
3020 | + foreach ($settings as $key => $value) { |
|
3021 | + switch ($key) { |
|
3022 | 3022 | case 'messenger' : |
3023 | - unset( $settings['messenger'] ); |
|
3023 | + unset($settings['messenger']); |
|
3024 | 3024 | break; |
3025 | 3025 | case 'message_types' : |
3026 | - if ( isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] ) ) { |
|
3027 | - foreach ( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v ) { |
|
3028 | - if ( isset( $settings['message_types'][$mt] ) ) |
|
3029 | - {$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();} |
|
3026 | + if (isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'])) { |
|
3027 | + foreach ($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'] as $mt => $v) { |
|
3028 | + if (isset($settings['message_types'][$mt])) |
|
3029 | + {$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(); } |
|
3030 | 3030 | } |
3031 | 3031 | } else { |
3032 | - foreach ( $value as $mt => $v ) { |
|
3032 | + foreach ($value as $mt => $v) { |
|
3033 | 3033 | //let's see if this message type is already present and has settings. |
3034 | - $settings[$messenger . '-message_types'][$mt]['settings'] = array(); |
|
3034 | + $settings[$messenger.'-message_types'][$mt]['settings'] = array(); |
|
3035 | 3035 | } |
3036 | 3036 | } |
3037 | 3037 | //k settings are set let's get rid of the message types index |
3038 | - unset( $settings['message_types'] ); |
|
3038 | + unset($settings['message_types']); |
|
3039 | 3039 | break; |
3040 | 3040 | default : |
3041 | 3041 | $settings[$key] = $value; |
@@ -3045,36 +3045,36 @@ discard block |
||
3045 | 3045 | $this->_active_messengers[$messenger]['settings'] = $settings; |
3046 | 3046 | } |
3047 | 3047 | |
3048 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3048 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3049 | 3049 | $settings = $this->_req_data['message_type_settings']; |
3050 | 3050 | $messenger = $settings['messenger']; |
3051 | 3051 | $message_type = $settings['message_type']; |
3052 | 3052 | |
3053 | - foreach ( $settings as $key => $value ) { |
|
3054 | - switch ( $key ) { |
|
3053 | + foreach ($settings as $key => $value) { |
|
3054 | + switch ($key) { |
|
3055 | 3055 | case 'messenger' : |
3056 | - unset( $settings['messenger'] ); |
|
3056 | + unset($settings['messenger']); |
|
3057 | 3057 | break; |
3058 | 3058 | case 'message_type' : |
3059 | - unset( $settings['message_type'] ); |
|
3059 | + unset($settings['message_type']); |
|
3060 | 3060 | break; |
3061 | 3061 | default : |
3062 | 3062 | $settings['settings'][$key] = $value; |
3063 | - unset( $settings[$key] ); |
|
3063 | + unset($settings[$key]); |
|
3064 | 3064 | break; |
3065 | 3065 | } |
3066 | 3066 | } |
3067 | 3067 | |
3068 | - $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings; |
|
3068 | + $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type] = $settings; |
|
3069 | 3069 | } |
3070 | 3070 | |
3071 | 3071 | //okay we should have the data all setup. Now we just update! |
3072 | - $success = EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers ); |
|
3072 | + $success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers); |
|
3073 | 3073 | |
3074 | - if ( $success ) { |
|
3075 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3074 | + if ($success) { |
|
3075 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3076 | 3076 | } else { |
3077 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3077 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3078 | 3078 | } |
3079 | 3079 | |
3080 | 3080 | $this->_template_args['success'] = $success; |
@@ -3096,8 +3096,8 @@ discard block |
||
3096 | 3096 | */ |
3097 | 3097 | protected function _generate_now() { |
3098 | 3098 | $msg_ids = $this->_get_msg_ids_from_request(); |
3099 | - EED_Messages::generate_now( $msg_ids ); |
|
3100 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3099 | + EED_Messages::generate_now($msg_ids); |
|
3100 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3101 | 3101 | } |
3102 | 3102 | |
3103 | 3103 | |
@@ -3112,7 +3112,7 @@ discard block |
||
3112 | 3112 | protected function _generate_and_send_now() { |
3113 | 3113 | $this->_generate_now(); |
3114 | 3114 | $this->_send_now(); |
3115 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3115 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3116 | 3116 | } |
3117 | 3117 | |
3118 | 3118 | |
@@ -3126,8 +3126,8 @@ discard block |
||
3126 | 3126 | */ |
3127 | 3127 | protected function _queue_for_resending() { |
3128 | 3128 | $msg_ids = $this->_get_msg_ids_from_request(); |
3129 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3130 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3129 | + EED_Messages::queue_for_resending($msg_ids); |
|
3130 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3131 | 3131 | } |
3132 | 3132 | |
3133 | 3133 | |
@@ -3140,8 +3140,8 @@ discard block |
||
3140 | 3140 | */ |
3141 | 3141 | protected function _send_now() { |
3142 | 3142 | $msg_ids = $this->_get_msg_ids_from_request(); |
3143 | - EED_Messages::send_now( $msg_ids ); |
|
3144 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3143 | + EED_Messages::send_now($msg_ids); |
|
3144 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3145 | 3145 | } |
3146 | 3146 | |
3147 | 3147 | |
@@ -3155,23 +3155,23 @@ discard block |
||
3155 | 3155 | protected function _delete_ee_messages() { |
3156 | 3156 | $msg_ids = $this->_get_msg_ids_from_request(); |
3157 | 3157 | $deleted_count = 0; |
3158 | - foreach ( $msg_ids as $msg_id ) { |
|
3159 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3158 | + foreach ($msg_ids as $msg_id) { |
|
3159 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3160 | 3160 | $deleted_count++; |
3161 | 3161 | } |
3162 | 3162 | } |
3163 | - if ( $deleted_count ) { |
|
3163 | + if ($deleted_count) { |
|
3164 | 3164 | $this->_redirect_after_action( |
3165 | 3165 | true, |
3166 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3166 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3167 | 3167 | __('deleted', 'event_espresso') |
3168 | 3168 | ); |
3169 | 3169 | } else { |
3170 | 3170 | EE_Error::add_error( |
3171 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3171 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3172 | 3172 | __FILE__, __FUNCTION__, __LINE__ |
3173 | 3173 | ); |
3174 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3174 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3175 | 3175 | } |
3176 | 3176 | } |
3177 | 3177 | |
@@ -3184,10 +3184,10 @@ discard block |
||
3184 | 3184 | * @return array |
3185 | 3185 | */ |
3186 | 3186 | protected function _get_msg_ids_from_request() { |
3187 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3187 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3188 | 3188 | return array(); |
3189 | 3189 | } |
3190 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3190 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3191 | 3191 | } |
3192 | 3192 | |
3193 | 3193 |
@@ -416,6 +416,7 @@ discard block |
||
416 | 416 | * @param EE_Registration | null $registration The registration object must be included if this |
417 | 417 | * is going to be a registration trigger url. |
418 | 418 | * @param string $sending_messenger The (optional) sending messenger for the url. |
419 | + * @param EE_Registration $registration |
|
419 | 420 | * |
420 | 421 | * @return string |
421 | 422 | * @throws EE_Error |
@@ -830,7 +831,7 @@ discard block |
||
830 | 831 | * an empty string is returned |
831 | 832 | * |
832 | 833 | * @since 4.9.0 |
833 | - * @param $payment_status |
|
834 | + * @param boolean|string $payment_status |
|
834 | 835 | * @return string |
835 | 836 | */ |
836 | 837 | public static function convert_payment_status_to_message_type( $payment_status ) { |
@@ -967,8 +968,8 @@ discard block |
||
967 | 968 | /** |
968 | 969 | * @param \EE_Messenger $messenger |
969 | 970 | * @param \EE_message_type $message_type |
970 | - * @param $GRP_ID |
|
971 | - * @param $global |
|
971 | + * @param integer $GRP_ID |
|
972 | + * @param boolean $global |
|
972 | 973 | * @return array|mixed |
973 | 974 | */ |
974 | 975 | protected function _create_new_templates( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
@@ -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,44 +55,44 @@ 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 | 63 | |
64 | - if ( empty($messenger) ) { |
|
65 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
64 | + if (empty($messenger)) { |
|
65 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | //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. |
69 | - if ( empty($message_types) ) { |
|
70 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
69 | + if (empty($message_types)) { |
|
70 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | self::_set_autoloader(); |
74 | 74 | /** @type EE_Messages $messages_controller */ |
75 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
75 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
76 | 76 | |
77 | - foreach ( $message_types as $message_type ) { |
|
77 | + foreach ($message_types as $message_type) { |
|
78 | 78 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
79 | - if ( $global && empty( $GRP_ID ) ) { |
|
80 | - $GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) ); |
|
79 | + if ($global && empty($GRP_ID)) { |
|
80 | + $GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE))); |
|
81 | 81 | $GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0; |
82 | 82 | } |
83 | 83 | //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!! |
84 | - if ( $global && self::already_generated($messenger, $message_type, $GRP_ID ) ) { |
|
84 | + if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) { |
|
85 | 85 | $templates = TRUE; |
86 | 86 | continue; //get out we've already got generated templates for this. |
87 | 87 | } |
88 | 88 | |
89 | 89 | $new_message_template_group = $messages_controller->create_new_templates($messenger, $message_type, $GRP_ID, $global); |
90 | 90 | |
91 | - if ( !$new_message_template_group ) { |
|
91 | + if ( ! $new_message_template_group) { |
|
92 | 92 | $success = FALSE; |
93 | 93 | continue; |
94 | 94 | } |
95 | - if ( $templates === TRUE ) $templates = array(); |
|
95 | + if ($templates === TRUE) $templates = array(); |
|
96 | 96 | $templates[] = $new_message_template_group; |
97 | 97 | } |
98 | 98 | |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | * @param bool $update_to_active if true then we also toggle the template to active. |
109 | 109 | * @return bool true = generated, false = hasn't been generated. |
110 | 110 | */ |
111 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) { |
|
111 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) { |
|
112 | 112 | self::_set_autoloader(); |
113 | 113 | $MTP = EEM_Message_Template::instance(); |
114 | 114 | |
115 | 115 | //what method we use depends on whether we have an GRP_ID or not |
116 | - $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 ) ) ); |
|
116 | + $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))); |
|
117 | 117 | |
118 | - if ( $update_to_active ) { |
|
119 | - self::update_to_active( $messenger, $message_type ); |
|
118 | + if ($update_to_active) { |
|
119 | + self::update_to_active($messenger, $message_type); |
|
120 | 120 | } |
121 | 121 | |
122 | - return ( $count > 0 ) ? TRUE : FALSE; |
|
122 | + return ($count > 0) ? TRUE : FALSE; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | * @static |
134 | 134 | * @return int count of updated records. |
135 | 135 | */ |
136 | - public static function update_to_active( $messenger, $message_type ) { |
|
136 | + public static function update_to_active($messenger, $message_type) { |
|
137 | 137 | return EEM_Message_Template_Group::instance()->update( |
138 | - array( 'MTP_is_active' => 1 ), |
|
138 | + array('MTP_is_active' => 1), |
|
139 | 139 | array( |
140 | 140 | array( |
141 | 141 | 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return int count of updated records. |
160 | 160 | */ |
161 | - public static function update_to_inactive( $messenger = '', $message_type = '' ) { |
|
161 | + public static function update_to_inactive($messenger = '', $message_type = '') { |
|
162 | 162 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
163 | 163 | $messenger, |
164 | 164 | $message_type |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @param string $type |
174 | 174 | * @return array array consisting of installed messenger objects and installed message type objects. |
175 | 175 | */ |
176 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
176 | + public static function get_installed_message_objects($type = 'all') { |
|
177 | 177 | self::_set_autoloader(); |
178 | 178 | //get all installed messengers and message_types |
179 | 179 | /** @type EE_Messages $messages_controller */ |
180 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
180 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
181 | 181 | return $messages_controller->get_installed($type); |
182 | 182 | } |
183 | 183 | |
@@ -210,38 +210,38 @@ discard block |
||
210 | 210 | $context = 'admin', |
211 | 211 | $merged = false |
212 | 212 | ) { |
213 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
214 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
213 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
214 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
215 | 215 | |
216 | 216 | //convert slug to object |
217 | - $messenger = self::messenger_obj( $messenger ); |
|
217 | + $messenger = self::messenger_obj($messenger); |
|
218 | 218 | |
219 | 219 | //validate class for getting our list of shortcodes |
220 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
221 | - if ( !class_exists( $classname ) ) { |
|
222 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
220 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
221 | + if ( ! class_exists($classname)) { |
|
222 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
223 | 223 | $msg[] = sprintf( |
224 | 224 | __('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'), |
225 | 225 | $classname |
226 | 226 | ); |
227 | - throw new EE_Error( implode( '||', $msg ) ); |
|
227 | + throw new EE_Error(implode('||', $msg)); |
|
228 | 228 | } |
229 | 229 | /** @type EE_Messages_Validator $_VLD */ |
230 | - $_VLD = new $classname( array(), $context ); |
|
230 | + $_VLD = new $classname(array(), $context); |
|
231 | 231 | $valid_shortcodes = $_VLD->get_validators(); |
232 | 232 | |
233 | 233 | //let's make sure we're only getting the shortcode part of the validators |
234 | 234 | $shortcodes = array(); |
235 | - foreach( $valid_shortcodes as $field => $validators ) { |
|
235 | + foreach ($valid_shortcodes as $field => $validators) { |
|
236 | 236 | $shortcodes[$field] = $validators['shortcodes']; |
237 | 237 | } |
238 | 238 | $valid_shortcodes = $shortcodes; |
239 | 239 | |
240 | 240 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
241 | - if ( ! empty( $fields ) ) { |
|
241 | + if ( ! empty($fields)) { |
|
242 | 242 | $specified_shortcodes = array(); |
243 | - foreach ( $fields as $field ) { |
|
244 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
243 | + foreach ($fields as $field) { |
|
244 | + if (isset($valid_shortcodes[$field])) |
|
245 | 245 | $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
246 | 246 | } |
247 | 247 | $valid_shortcodes = $specified_shortcodes; |
@@ -249,16 +249,16 @@ discard block |
||
249 | 249 | |
250 | 250 | |
251 | 251 | //if not merged then let's replace the fields with the localized fields |
252 | - if ( ! $merged ) { |
|
252 | + if ( ! $merged) { |
|
253 | 253 | //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. |
254 | 254 | $field_settings = $messenger->get_template_fields(); |
255 | 255 | $localized = array(); |
256 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
256 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
257 | 257 | //get localized field label |
258 | - if ( isset( $field_settings[$field] ) ) { |
|
258 | + if (isset($field_settings[$field])) { |
|
259 | 259 | //possible that this is used as a main field. |
260 | - if ( empty( $field_settings[$field] ) ) { |
|
261 | - if ( isset( $field_settings['extra'][$field] ) ) { |
|
260 | + if (empty($field_settings[$field])) { |
|
261 | + if (isset($field_settings['extra'][$field])) { |
|
262 | 262 | $_field = $field_settings['extra'][$field]['main']['label']; |
263 | 263 | } else { |
264 | 264 | $_field = $field; |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | } else { |
267 | 267 | $_field = $field_settings[$field]['label']; |
268 | 268 | } |
269 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
269 | + } else if (isset($field_settings['extra'])) { |
|
270 | 270 | //loop through extra "main fields" and see if any of their children have our field |
271 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
272 | - if ( isset( $fields[$field] ) ) |
|
271 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
272 | + if (isset($fields[$field])) |
|
273 | 273 | $_field = $fields[$field]['label']; |
274 | 274 | else |
275 | 275 | $_field = $field; |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | } else { |
278 | 278 | $_field = $field; |
279 | 279 | } |
280 | - if ( isset( $_field )) { |
|
281 | - $localized[ $_field ] = $shortcodes; |
|
280 | + if (isset($_field)) { |
|
281 | + $localized[$_field] = $shortcodes; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | $valid_shortcodes = $localized; |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | |
287 | 287 | |
288 | 288 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
289 | - if ( $merged ) { |
|
289 | + if ($merged) { |
|
290 | 290 | $merged_codes = array(); |
291 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
292 | - foreach ( $shortcode as $code => $label ) { |
|
293 | - if ( isset( $merged_codes[$code] ) ) |
|
291 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
292 | + foreach ($shortcode as $code => $label) { |
|
293 | + if (isset($merged_codes[$code])) |
|
294 | 294 | continue; |
295 | 295 | else |
296 | 296 | $merged_codes[$code] = $label; |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | * @throws \EE_Error |
313 | 313 | * @return EE_Messenger |
314 | 314 | */ |
315 | - public static function messenger_obj( $messenger ) { |
|
315 | + public static function messenger_obj($messenger) { |
|
316 | 316 | /** @type EE_Messages $messages_controller */ |
317 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
317 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
318 | 318 | $installed_messengers = $messages_controller->get_installed_messengers(); |
319 | - return isset( $installed_messengers[ $messenger ] ) ? $installed_messengers[ $messenger ] : null; |
|
319 | + return isset($installed_messengers[$messenger]) ? $installed_messengers[$messenger] : null; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @throws \EE_Error |
330 | 330 | * @return EE_message_type |
331 | 331 | */ |
332 | - public static function message_type_obj( $message_type ) { |
|
332 | + public static function message_type_obj($message_type) { |
|
333 | 333 | /** @type EE_Messages $messages_controller */ |
334 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
334 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
335 | 335 | $installed_message_types = $messages_controller->get_installed_message_types(); |
336 | - return isset( $installed_message_types[ $message_type ] ) ? $installed_message_types[ $message_type ] : null; |
|
336 | + return isset($installed_message_types[$message_type]) ? $installed_message_types[$message_type] : null; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @param string $message_type message type to check for. |
348 | 348 | * @return boolean |
349 | 349 | */ |
350 | - public static function is_mt_active( $message_type ) { |
|
350 | + public static function is_mt_active($message_type) { |
|
351 | 351 | self::_set_autoloader(); |
352 | 352 | /** @type EE_Messages $messages_controller */ |
353 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
353 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
354 | 354 | $active_mts = $messages_controller->get_active_message_types(); |
355 | - return in_array( $message_type, $active_mts ); |
|
355 | + return in_array($message_type, $active_mts); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | * @param string $messenger slug for messenger to check. |
366 | 366 | * @return boolean |
367 | 367 | */ |
368 | - public static function is_messenger_active( $messenger ) { |
|
368 | + public static function is_messenger_active($messenger) { |
|
369 | 369 | self::_set_autoloader(); |
370 | 370 | /** @type EE_Messages $messages_controller */ |
371 | - $messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
|
371 | + $messages_controller = EE_Registry::instance()->load_lib('messages'); |
|
372 | 372 | $active_messengers = $messages_controller->get_active_messengers(); |
373 | - return isset( $active_messengers[ $messenger ] ); |
|
373 | + return isset($active_messengers[$messenger]); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | public static function get_active_messengers_in_db() { |
387 | 387 | return apply_filters( |
388 | 388 | 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', |
389 | - get_option( 'ee_active_messengers', array() ) |
|
389 | + get_option('ee_active_messengers', array()) |
|
390 | 390 | ); |
391 | 391 | } |
392 | 392 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return bool FALSE if not updated, TRUE if updated. |
404 | 404 | */ |
405 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
406 | - return update_option( 'ee_active_messengers', $data_to_save ); |
|
405 | + public static function update_active_messengers_in_db($data_to_save) { |
|
406 | + return update_option('ee_active_messengers', $data_to_save); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -427,34 +427,34 @@ discard block |
||
427 | 427 | $sending_messenger = '' |
428 | 428 | ) { |
429 | 429 | //first determine if the url can be to the EE_Message object. |
430 | - if ( ! $message_type->always_generate() ) { |
|
431 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
430 | + if ( ! $message_type->always_generate()) { |
|
431 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
435 | - if ( ! $registration instanceof EE_Registration ) { |
|
435 | + if ( ! $registration instanceof EE_Registration) { |
|
436 | 436 | throw new EE_Error( |
437 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
437 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
438 | 438 | ); |
439 | 439 | } |
440 | 440 | |
441 | 441 | //validate given context |
442 | 442 | $contexts = $message_type->get_contexts(); |
443 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
443 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
444 | 444 | throw new EE_Error( |
445 | 445 | sprintf( |
446 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
446 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
447 | 447 | $message->context(), |
448 | - get_class( $message_type ) |
|
448 | + get_class($message_type) |
|
449 | 449 | ) |
450 | 450 | ); |
451 | 451 | } |
452 | 452 | |
453 | 453 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
454 | - if ( ! empty( $sending_messenger ) ) { |
|
454 | + if ( ! empty($sending_messenger)) { |
|
455 | 455 | $with_messengers = $message_type->with_messengers(); |
456 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
457 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
456 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
457 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
458 | 458 | throw new EE_Error( |
459 | 459 | sprintf( |
460 | 460 | __( |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | 'event_espresso' |
463 | 463 | ), |
464 | 464 | $sending_messenger, |
465 | - get_class( $message_type ) |
|
465 | + get_class($message_type) |
|
466 | 466 | ) |
467 | 467 | ); |
468 | 468 | } |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | * @param EE_Message $message |
486 | 486 | * @return string. |
487 | 487 | */ |
488 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
488 | + public static function generate_browser_trigger(EE_Message $message) { |
|
489 | 489 | $query_args = array( |
490 | 490 | 'ee' => 'msg_browser_trigger', |
491 | 491 | 'token' => $message->MSG_token() |
492 | 492 | ); |
493 | 493 | return apply_filters( |
494 | 494 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
495 | - add_query_arg( $query_args, site_url() ), |
|
495 | + add_query_arg($query_args, site_url()), |
|
496 | 496 | $message |
497 | 497 | ); |
498 | 498 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param EE_Message $message |
508 | 508 | * @return string |
509 | 509 | */ |
510 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
510 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
511 | 511 | return apply_filters( |
512 | 512 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
513 | 513 | add_query_arg( |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | 'GRP_ID' => $message_template_group, |
558 | 558 | 'id' => $data_id |
559 | 559 | ); |
560 | - $url = add_query_arg( $query_args, get_site_url() ); |
|
560 | + $url = add_query_arg($query_args, get_site_url()); |
|
561 | 561 | |
562 | 562 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
563 | 563 | $url = apply_filters( |
@@ -585,9 +585,9 @@ discard block |
||
585 | 585 | * @param string $type What action to return. |
586 | 586 | * @return string |
587 | 587 | */ |
588 | - public static function get_message_action_icon( $type ) { |
|
588 | + public static function get_message_action_icon($type) { |
|
589 | 589 | $action_icons = self::get_message_action_icons(); |
590 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
590 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -599,34 +599,34 @@ discard block |
||
599 | 599 | * @return array |
600 | 600 | */ |
601 | 601 | public static function get_message_action_icons() { |
602 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
602 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
603 | 603 | array( |
604 | 604 | 'view' => array( |
605 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
605 | + 'label' => __('View Message', 'event_espresso'), |
|
606 | 606 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
607 | 607 | ), |
608 | 608 | 'error' => array( |
609 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
609 | + 'label' => __('View Error Message', 'event_espresso'), |
|
610 | 610 | 'css_class' => 'dashicons dashicons-info', |
611 | 611 | ), |
612 | 612 | 'see_notifications_for' => array( |
613 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
613 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
614 | 614 | 'css_class' => 'dashicons dashicons-images-alt', |
615 | 615 | ), |
616 | 616 | 'generate_now' => array( |
617 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
617 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
618 | 618 | 'css_class' => 'dashicons dashicons-admin-tools', |
619 | 619 | ), |
620 | 620 | 'send_now' => array( |
621 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
621 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
622 | 622 | 'css_class' => 'dashicons dashicons-controls-forward', |
623 | 623 | ), |
624 | 624 | 'queue_for_resending' => array( |
625 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
625 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
626 | 626 | 'css_class' => 'dashicons dashicons-controls-repeat', |
627 | 627 | ), |
628 | 628 | 'view_transaction' => array( |
629 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
629 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
630 | 630 | 'css_class' => 'dashicons dashicons-cart', |
631 | 631 | ) |
632 | 632 | ) |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @return string |
647 | 647 | */ |
648 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
649 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
650 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
648 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
649 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
650 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | |
@@ -661,15 +661,15 @@ discard block |
||
661 | 661 | * |
662 | 662 | * @return array |
663 | 663 | */ |
664 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
665 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
664 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
665 | + EE_Registry::instance()->load_helper('URL'); |
|
666 | 666 | //if $message is not an instance of EE_Message then let's just do a dummy. |
667 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
668 | - $action_urls = apply_filters( |
|
667 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
668 | + $action_urls = apply_filters( |
|
669 | 669 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
670 | 670 | array( |
671 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
672 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
671 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
672 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
673 | 673 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
674 | 674 | array_merge( |
675 | 675 | array( |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | ), |
680 | 680 | $query_params |
681 | 681 | ), |
682 | - admin_url( 'admin.php' ) |
|
682 | + admin_url('admin.php') |
|
683 | 683 | ), |
684 | 684 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
685 | 685 | array( |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | 'action' => 'generate_now', |
688 | 688 | 'MSG_ID' => $message->ID() |
689 | 689 | ), |
690 | - admin_url( 'admin.php' ) |
|
690 | + admin_url('admin.php') |
|
691 | 691 | ), |
692 | 692 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
693 | 693 | array( |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | 'action' => 'send_now', |
696 | 696 | 'MSG_ID' => $message->ID() |
697 | 697 | ), |
698 | - admin_url( 'admin.php' ) |
|
698 | + admin_url('admin.php') |
|
699 | 699 | ), |
700 | 700 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
701 | 701 | array( |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | 'action' => 'queue_for_resending', |
704 | 704 | 'MSG_ID' => $message->ID() |
705 | 705 | ), |
706 | - admin_url( 'admin.php' ) |
|
706 | + admin_url('admin.php') |
|
707 | 707 | ), |
708 | 708 | ) |
709 | 709 | ); |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | 'action' => 'view_transaction', |
722 | 722 | 'TXN_ID' => $message->TXN_ID() |
723 | 723 | ), |
724 | - admin_url( 'admin.php' ) |
|
724 | + admin_url('admin.php') |
|
725 | 725 | ); |
726 | 726 | } else { |
727 | 727 | $action_urls['view_transaction'] = ''; |
@@ -742,24 +742,24 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @return string |
744 | 744 | */ |
745 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
746 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
747 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
748 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
745 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
746 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
747 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
748 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
749 | 749 | return ''; |
750 | 750 | } |
751 | 751 | |
752 | 752 | $icon_css['css_class'] .= esc_attr( |
753 | 753 | apply_filters( |
754 | 754 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
755 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
755 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
756 | 756 | $type, |
757 | 757 | $message, |
758 | 758 | $query_params |
759 | 759 | ) |
760 | 760 | ); |
761 | 761 | |
762 | - return '<a href="' . $url . '"><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
762 | + return '<a href="'.$url.'"><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
763 | 763 | |
764 | 764 | } |
765 | 765 | |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | * @param $reg_status |
798 | 798 | * @return string |
799 | 799 | */ |
800 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
800 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
801 | 801 | $reg_status_array = self::reg_status_to_message_type_array(); |
802 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
802 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -833,9 +833,9 @@ discard block |
||
833 | 833 | * @param $payment_status |
834 | 834 | * @return string |
835 | 835 | */ |
836 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
836 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
837 | 837 | $payment_status_array = self::payment_status_to_message_type_array(); |
838 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
838 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -846,32 +846,32 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return EE_Messages_Template_Pack |
848 | 848 | */ |
849 | - public static function get_template_pack( $template_pack_name ) { |
|
850 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
849 | + public static function get_template_pack($template_pack_name) { |
|
850 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
851 | 851 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
852 | 852 | } |
853 | 853 | |
854 | 854 | //first see if in collection already |
855 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
855 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
856 | 856 | |
857 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
857 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
858 | 858 | return $template_pack; |
859 | 859 | } |
860 | 860 | |
861 | 861 | //nope...let's get it. |
862 | 862 | //not set yet so let's attempt to get it. |
863 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
863 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
864 | 864 | ' ', |
865 | 865 | '_', |
866 | 866 | ucwords( |
867 | - str_replace( '_', ' ', $template_pack_name ) |
|
867 | + str_replace('_', ' ', $template_pack_name) |
|
868 | 868 | ) |
869 | 869 | ); |
870 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
871 | - return self::get_template_pack( 'default' ); |
|
870 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
871 | + return self::get_template_pack('default'); |
|
872 | 872 | } else { |
873 | 873 | $template_pack = new $pack_class_name; |
874 | - self::$_template_pack_collection->add( $template_pack ); |
|
874 | + self::$_template_pack_collection->add($template_pack); |
|
875 | 875 | return $template_pack; |
876 | 876 | } |
877 | 877 | } |
@@ -889,26 +889,26 @@ discard block |
||
889 | 889 | */ |
890 | 890 | public static function get_template_pack_collection() { |
891 | 891 | $new_collection = false; |
892 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
892 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
893 | 893 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
894 | 894 | $new_collection = true; |
895 | 895 | } |
896 | 896 | |
897 | 897 | //glob the defaults directory for messages |
898 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
899 | - foreach( $templates as $template_path ) { |
|
898 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
899 | + foreach ($templates as $template_path) { |
|
900 | 900 | //grab folder name |
901 | - $template = basename( $template_path ); |
|
901 | + $template = basename($template_path); |
|
902 | 902 | |
903 | - if ( ! $new_collection ) { |
|
903 | + if ( ! $new_collection) { |
|
904 | 904 | //already have it? |
905 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
905 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
906 | 906 | continue; |
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
910 | 910 | //setup classname. |
911 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
911 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
912 | 912 | ' ', |
913 | 913 | '_', |
914 | 914 | ucwords( |
@@ -919,20 +919,20 @@ discard block |
||
919 | 919 | ) |
920 | 920 | ) |
921 | 921 | ); |
922 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
922 | + if ( ! class_exists($template_pack_class_name)) { |
|
923 | 923 | continue; |
924 | 924 | } |
925 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
925 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | /** |
929 | 929 | * Filter for plugins to add in any additional template packs |
930 | 930 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
931 | 931 | */ |
932 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
933 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
934 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
935 | - self::$_template_pack_collection->add( $template_pack ); |
|
932 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
933 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
934 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
935 | + self::$_template_pack_collection->add($template_pack); |
|
936 | 936 | } |
937 | 937 | } |
938 | 938 | return self::$_template_pack_collection; |
@@ -950,16 +950,16 @@ discard block |
||
950 | 950 | * @return array |
951 | 951 | * @throws \EE_Error |
952 | 952 | */ |
953 | - public function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
953 | + public function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
954 | 954 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
955 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
956 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
957 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
958 | - if ( ! $this->message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
955 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
956 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
957 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
958 | + if ( ! $this->message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
959 | 959 | return array(); |
960 | 960 | } |
961 | 961 | //whew made it this far! Okay, let's go ahead and create the templates then |
962 | - return $this->_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
962 | + return $this->_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | |
@@ -971,13 +971,13 @@ discard block |
||
971 | 971 | * @param $global |
972 | 972 | * @return array|mixed |
973 | 973 | */ |
974 | - protected function _create_new_templates( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
974 | + protected function _create_new_templates(EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
975 | 975 | //if we're creating a custom template then we don't need to use the defaults class |
976 | - if ( ! $global ) { |
|
977 | - return $this->_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
976 | + if ( ! $global) { |
|
977 | + return $this->_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
978 | 978 | } |
979 | 979 | $Message_Template_Defaults = new EE_Message_Template_Defaults( |
980 | - EE_Registry::instance()->load_lib( 'messages' ), |
|
980 | + EE_Registry::instance()->load_lib('messages'), |
|
981 | 981 | $messenger->name, |
982 | 982 | $message_type->name, |
983 | 983 | $GRP_ID |
@@ -1009,11 +1009,11 @@ discard block |
||
1009 | 1009 | * ) |
1010 | 1010 | * @access private |
1011 | 1011 | */ |
1012 | - private function _create_custom_template_group( EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1012 | + private function _create_custom_template_group(EE_Messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1013 | 1013 | //defaults |
1014 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1014 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1015 | 1015 | //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. |
1016 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1016 | + $Message_Template_Group = empty($GRP_ID) |
|
1017 | 1017 | ? EEM_Message_Template_Group::instance()->get_one( |
1018 | 1018 | array( |
1019 | 1019 | array( |
@@ -1023,9 +1023,9 @@ discard block |
||
1023 | 1023 | ) |
1024 | 1024 | ) |
1025 | 1025 | ) |
1026 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1026 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1027 | 1027 | //if we don't have a mtg at this point then we need to bail. |
1028 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1028 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1029 | 1029 | EE_Error::add_error( |
1030 | 1030 | sprintf( |
1031 | 1031 | __( |
@@ -1044,42 +1044,42 @@ discard block |
||
1044 | 1044 | $mtts = $Message_Template_Group->message_templates(); |
1045 | 1045 | //now we have what we need to setup the new template |
1046 | 1046 | $new_mtg = clone $Message_Template_Group; |
1047 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1048 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1049 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1050 | - ? $_POST[ 'templateName' ] |
|
1047 | + $new_mtg->set('GRP_ID', 0); |
|
1048 | + $new_mtg->set('MTP_is_global', false); |
|
1049 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1050 | + ? $_POST['templateName'] |
|
1051 | 1051 | : __( |
1052 | 1052 | 'New Custom Template', |
1053 | 1053 | 'event_espresso' |
1054 | 1054 | ); |
1055 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1056 | - ? $_POST[ 'templateDescription' ] |
|
1055 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1056 | + ? $_POST['templateDescription'] |
|
1057 | 1057 | : sprintf( |
1058 | 1058 | __( |
1059 | 1059 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1060 | 1060 | 'event_espresso' |
1061 | 1061 | ), |
1062 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1063 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1062 | + $new_mtg->messenger_obj()->label['singular'], |
|
1063 | + $new_mtg->message_type_obj()->label['singular'] |
|
1064 | 1064 | ); |
1065 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1066 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1065 | + $new_mtg->set('MTP_name', $template_name); |
|
1066 | + $new_mtg->set('MTP_description', $template_description); |
|
1067 | 1067 | //remove ALL relations on this template group so they don't get saved! |
1068 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1068 | + $new_mtg->_remove_relations('Message_Template'); |
|
1069 | 1069 | $new_mtg->save(); |
1070 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1071 | - $success[ 'template_name' ] = $template_name; |
|
1070 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1071 | + $success['template_name'] = $template_name; |
|
1072 | 1072 | //add new message templates and add relation to. |
1073 | - foreach ( $mtts as $mtt ) { |
|
1074 | - if ( ! $mtt instanceof EE_Message_Template ) { |
|
1073 | + foreach ($mtts as $mtt) { |
|
1074 | + if ( ! $mtt instanceof EE_Message_Template) { |
|
1075 | 1075 | continue; |
1076 | 1076 | } |
1077 | 1077 | $nmtt = clone $mtt; |
1078 | - $nmtt->set( 'MTP_ID', 0 ); |
|
1079 | - $nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1078 | + $nmtt->set('MTP_ID', 0); |
|
1079 | + $nmtt->set('GRP_ID', $new_mtg->ID()); //relation |
|
1080 | 1080 | $nmtt->save(); |
1081 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1082 | - $success[ 'MTP_context' ] = $nmtt->get( 'MTP_context' ); |
|
1081 | + if (empty($success['MTP_context'])) { |
|
1082 | + $success['MTP_context'] = $nmtt->get('MTP_context'); |
|
1083 | 1083 | } |
1084 | 1084 | } |
1085 | 1085 | return $success; |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | $global = false |
1102 | 1102 | ) { |
1103 | 1103 | //is given message_type valid for given messenger (if this is not a global save) |
1104 | - if ( $global ) { |
|
1104 | + if ($global) { |
|
1105 | 1105 | return true; |
1106 | 1106 | } |
1107 | 1107 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | ) |
1114 | 1114 | ) |
1115 | 1115 | ); |
1116 | - if ( $active_templates > 0 ) { |
|
1116 | + if ($active_templates > 0) { |
|
1117 | 1117 | return true; |
1118 | 1118 | } |
1119 | 1119 | EE_Error::add_error( |
@@ -1142,24 +1142,24 @@ discard block |
||
1142 | 1142 | * @param string $message_type_name name of EE_message_type |
1143 | 1143 | * @return array |
1144 | 1144 | */ |
1145 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
1145 | + public function get_fields($messenger_name, $message_type_name) { |
|
1146 | 1146 | $template_fields = array(); |
1147 | 1147 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1148 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1149 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1150 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1151 | - if ( ! $this->message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1148 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1149 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1150 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1151 | + if ( ! $this->message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1152 | 1152 | return array(); |
1153 | 1153 | } |
1154 | 1154 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1155 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1156 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1157 | - $template_fields[ $context ][ $field ] = $value; |
|
1155 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1156 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1157 | + $template_fields[$context][$field] = $value; |
|
1158 | 1158 | } |
1159 | 1159 | } |
1160 | - if ( empty( $template_fields ) ) { |
|
1160 | + if (empty($template_fields)) { |
|
1161 | 1161 | EE_Error::add_error( |
1162 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1162 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1163 | 1163 | __FILE__, |
1164 | 1164 | __FUNCTION__, |
1165 | 1165 | __LINE__ |