@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * ------------------------------------------------------------------------ |
26 | 26 | */ |
27 | -abstract class EE_Offsite_Gateway extends EE_Gateway{ |
|
27 | +abstract class EE_Offsite_Gateway extends EE_Gateway { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * whether or not the gateway uses an IPN |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment provider's website |
62 | 62 | * @return EE_Payment |
63 | 63 | */ |
64 | - public abstract function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL); |
|
64 | + public abstract function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL); |
|
65 | 65 | |
66 | 66 | |
67 | 67 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param EEI_Transaction $transaction |
75 | 75 | * @return EEI_Payment updated |
76 | 76 | */ |
77 | - public abstract function handle_payment_update($update_info,$transaction); |
|
77 | + public abstract function handle_payment_update($update_info, $transaction); |
|
78 | 78 | |
79 | 79 | |
80 | 80 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * @access protected |
102 | 102 | * @param boolean $uses_separate_IPN_request |
103 | 103 | */ |
104 | - protected function set_uses_separate_IPN_request( $uses_separate_IPN_request ) { |
|
105 | - $this->_uses_separate_IPN_request = filter_var( $uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN ); |
|
104 | + protected function set_uses_separate_IPN_request($uses_separate_IPN_request) { |
|
105 | + $this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @param boolean $separate_IPN_request |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public function handle_IPN_in_this_request( $request_data, $separate_IPN_request ) { |
|
120 | - if( $separate_IPN_request ) { |
|
119 | + public function handle_IPN_in_this_request($request_data, $separate_IPN_request) { |
|
120 | + if ($separate_IPN_request) { |
|
121 | 121 | return $this->_uses_separate_IPN_request; |
122 | 122 | } else { |
123 | 123 | //it's a request where the user returned from an offsite gateway |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | public static function set_hooks_admin() { |
29 | 29 | add_action( |
30 | 30 | 'save_post', |
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
31 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'), |
|
32 | 32 | 100, |
33 | 33 | 2 |
34 | 34 | ); |
35 | 35 | add_action( |
36 | 36 | 'delete_post', |
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
37 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'), |
|
38 | 38 | 100, |
39 | 39 | 1 |
40 | 40 | ); |
41 | 41 | add_action( |
42 | 42 | 'add_option_page_for_posts', |
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
43 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'), |
|
44 | 44 | 100, |
45 | 45 | 2 |
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'update_option', |
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
49 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'), |
|
50 | 50 | 100, |
51 | 51 | 3 |
52 | 52 | ); |
53 | 53 | add_action( |
54 | 54 | 'delete_option', |
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
55 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'), |
|
56 | 56 | 100, |
57 | 57 | 1 |
58 | 58 | ); |
@@ -72,61 +72,61 @@ discard block |
||
72 | 72 | * @param \WP_Post $post |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
75 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
76 | 76 | // if the post is trashed, then let's remove our post shortcode tracking |
77 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
78 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
77 | + if ($post instanceof \WP_Post && $post->post_status === 'trash') { |
|
78 | + PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | // default post types |
82 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
82 | + $post_types = array('post' => 0, 'page' => 1); |
|
83 | 83 | // add CPTs |
84 | 84 | $CPTs = \EE_Register_CPTs::get_CPTs(); |
85 | - $post_types = array_merge( $post_types, $CPTs ); |
|
85 | + $post_types = array_merge($post_types, $CPTs); |
|
86 | 86 | // for default or CPT posts... |
87 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
87 | + if (isset($post_types[$post->post_type])) { |
|
88 | 88 | // post on frontpage ? |
89 | 89 | $page_for_posts = \EE_Config::get_page_for_posts(); |
90 | - if ( $post->post_name === $page_for_posts ) { |
|
91 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
90 | + if ($post->post_name === $page_for_posts) { |
|
91 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | // array of shortcodes indexed by post name |
95 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
95 | + \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) |
|
96 | 96 | ? \EE_Registry::CFG()->core->post_shortcodes |
97 | 97 | : array(); |
98 | 98 | // whether to proceed with update |
99 | 99 | $update_post_shortcodes = false; |
100 | 100 | // empty both arrays |
101 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
101 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); |
|
102 | 102 | // check that posts page is already being tracked |
103 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
103 | + if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { |
|
104 | 104 | // if not, then ensure that it is properly added |
105 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
105 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
106 | 106 | } |
107 | 107 | // loop thru shortcodes |
108 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
108 | + foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
109 | 109 | // convert to UPPERCASE to get actual shortcode |
110 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
110 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
111 | 111 | // is the shortcode in the post_content ? |
112 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
112 | + if (strpos($post->post_content, $EES_Shortcode) !== false) { |
|
113 | 113 | // map shortcode to post names and post IDs |
114 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
114 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
115 | 115 | // and add this shortcode to the tracking for the blog page |
116 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
116 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
117 | 117 | $update_post_shortcodes = true; |
118 | 118 | } else { |
119 | 119 | // shortcode is not present in post content, so check if we were tracking it previously |
120 | 120 | // stop tracking if shortcode is not used in this specific post |
121 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
122 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
121 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { |
|
122 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); |
|
123 | 123 | $update_post_shortcodes = true; |
124 | 124 | } |
125 | 125 | // make sure that something is set for the shortcode posts (even though we may remove this) |
126 | 126 | $shortcode_posts = isset( |
127 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
127 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
128 | 128 | ) |
129 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
129 | + ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
130 | 130 | : array(); |
131 | 131 | // and stop tracking for this shortcode on the blog page if it is not used |
132 | 132 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | : $update_post_shortcodes; |
141 | 141 | } |
142 | 142 | } |
143 | - if ( $update_post_shortcodes ) { |
|
144 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
143 | + if ($update_post_shortcodes) { |
|
144 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | * @param string $page_for_posts |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) { |
|
162 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
161 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) { |
|
162 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
163 | 163 | // loop thru shortcodes |
164 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
165 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
166 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
164 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
165 | + foreach ($post_shortcodes as $EES_Shortcode => $post_ID) { |
|
166 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
167 | 167 | } |
168 | 168 | } |
169 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
169 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | * @param $EES_Shortcode |
182 | 182 | * @param $post_ID |
183 | 183 | */ |
184 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) { |
|
184 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) { |
|
185 | 185 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
186 | 186 | $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
187 | 187 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
188 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
188 | + if (in_array($EES_Shortcode, $critical_shortcodes)) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | // add shortcode to "Posts page" tracking |
192 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
192 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
193 | 193 | // make sure tracking is in form of an array |
194 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
196 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true |
|
194 | + if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
195 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array( |
|
196 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true |
|
197 | 197 | ); |
198 | 198 | } |
199 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
199 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true); |
|
200 | 200 | } else { |
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | * @param int $ID |
212 | 212 | * @return void |
213 | 213 | */ |
214 | - public static function unset_post_shortcodes_on_delete( $ID ) { |
|
214 | + public static function unset_post_shortcodes_on_delete($ID) { |
|
215 | 215 | $update_post_shortcodes = false; |
216 | 216 | // post on frontpage ? |
217 | 217 | $page_for_posts = \EE_Config::get_page_for_posts(); |
218 | 218 | // looking for any references to this post |
219 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
219 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
220 | 220 | // is this the "Posts Page" (blog) ? |
221 | - if ( $post_name === $page_for_posts ) { |
|
221 | + if ($post_name === $page_for_posts) { |
|
222 | 222 | // loop thru shortcodes registered for the posts page |
223 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
223 | + foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) { |
|
224 | 224 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
225 | 225 | $ID, |
226 | 226 | $shortcode_class, |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | } |
234 | 234 | } else { |
235 | 235 | // loop thru shortcodes registered for each page |
236 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
236 | + foreach ($post_shortcodes as $shortcode_class => $post_ID) { |
|
237 | 237 | // if this is page is being deleted, then don't track any post shortcodes for it |
238 | - if ( $post_ID === $ID ) { |
|
239 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
238 | + if ($post_ID === $ID) { |
|
239 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]); |
|
240 | 240 | $update_post_shortcodes = true; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | - if ( $update_post_shortcodes ) { |
|
246 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
245 | + if ($update_post_shortcodes) { |
|
246 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -268,20 +268,20 @@ discard block |
||
268 | 268 | $update_post_shortcodes = false |
269 | 269 | ) { |
270 | 270 | // make sure that an array of post IDs is being tracked for each shortcode |
271 | - if ( ! is_array( $shortcode_posts ) ) { |
|
272 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
271 | + if ( ! is_array($shortcode_posts)) { |
|
272 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array( |
|
273 | 273 | $shortcode_posts => true |
274 | 274 | ); |
275 | 275 | $update_post_shortcodes = true; |
276 | 276 | } |
277 | 277 | // now if the ID of the post being deleted is in the $shortcode_posts array |
278 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
279 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
278 | + if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) { |
|
279 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]); |
|
280 | 280 | $update_post_shortcodes = true; |
281 | 281 | } |
282 | 282 | // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
283 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
284 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
283 | + if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
284 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]); |
|
285 | 285 | $update_post_shortcodes = true; |
286 | 286 | } |
287 | 287 | return $update_post_shortcodes; |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @param $page_for_posts |
297 | 297 | * @return void |
298 | 298 | */ |
299 | - public static function update_post_shortcodes( $page_for_posts = '' ) { |
|
299 | + public static function update_post_shortcodes($page_for_posts = '') { |
|
300 | 300 | // make sure page_for_posts is set |
301 | - $page_for_posts = ! empty( $page_for_posts ) |
|
301 | + $page_for_posts = ! empty($page_for_posts) |
|
302 | 302 | ? $page_for_posts |
303 | 303 | : \EE_Config::get_page_for_posts(); |
304 | 304 | // allow others to mess stuff up :D |
@@ -314,45 +314,45 @@ discard block |
||
314 | 314 | $page_for_posts |
315 | 315 | ); |
316 | 316 | // verify that post_shortcodes is set |
317 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
318 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
317 | + \EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes) |
|
318 | + && is_array(\EE_Config::instance()->core->post_shortcodes) |
|
319 | 319 | ? \EE_Config::instance()->core->post_shortcodes |
320 | 320 | : array(); |
321 | 321 | // cycle thru post_shortcodes |
322 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
322 | + foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) { |
|
323 | 323 | // are there any shortcodes to track ? |
324 | - if ( ! empty( $shortcodes ) ) { |
|
324 | + if ( ! empty($shortcodes)) { |
|
325 | 325 | // loop thru list of tracked shortcodes |
326 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
326 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
327 | 327 | // if shortcode is for a critical page, |
328 | 328 | // BUT this is NOT the corresponding critical page for that shortcode |
329 | - if ( $post_name === $page_for_posts ) { |
|
329 | + if ($post_name === $page_for_posts) { |
|
330 | 330 | continue; |
331 | 331 | } |
332 | 332 | // skip the posts page, because we want all shortcodes registered for it |
333 | - if ( $post_name === $page_for_posts ) { |
|
333 | + if ($post_name === $page_for_posts) { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | 336 | // make sure post still exists |
337 | - $post = get_post( $post_id ); |
|
337 | + $post = get_post($post_id); |
|
338 | 338 | // check that the post name matches what we have saved |
339 | - if ( $post && $post->post_name === $post_name ) { |
|
339 | + if ($post && $post->post_name === $post_name) { |
|
340 | 340 | // if so, then break before hitting the unset below |
341 | 341 | continue; |
342 | 342 | } |
343 | 343 | // we don't like missing posts around here >:( |
344 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
345 | 345 | } |
346 | 346 | } else { |
347 | 347 | // you got no shortcodes to keep track of ! |
348 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
352 | 352 | $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
353 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
354 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
355 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
353 | + $critical_shortcodes = array_flip($critical_shortcodes); |
|
354 | + foreach ($critical_shortcodes as $critical_shortcode) { |
|
355 | + unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]); |
|
356 | 356 | } |
357 | 357 | //only show errors |
358 | 358 | \EE_Config::instance()->update_espresso_config(); |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * @param string $value |
373 | 373 | * @return void |
374 | 374 | */ |
375 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) { |
|
376 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
375 | + public static function reset_page_for_posts_on_initial_set($option, $value) { |
|
376 | + PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | * @param string $value |
391 | 391 | * @return void |
392 | 392 | */ |
393 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) { |
|
394 | - if ( $option === 'page_for_posts' ) { |
|
393 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') { |
|
394 | + if ($option === 'page_for_posts') { |
|
395 | 395 | global $wpdb; |
396 | 396 | $table = $wpdb->posts; |
397 | 397 | $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
398 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
399 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
398 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
399 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @param string $option |
413 | 413 | * @return void |
414 | 414 | */ |
415 | - public static function reset_page_for_posts_on_delete( $option ) { |
|
416 | - if ( $option === 'page_for_posts' ) { |
|
417 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
415 | + public static function reset_page_for_posts_on_delete($option) { |
|
416 | + if ($option === 'page_for_posts') { |
|
417 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts'); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EE_Admin_Page_CPT class |
4 | 6 | * |
@@ -236,8 +238,9 @@ discard block |
||
236 | 238 | |
237 | 239 | $containers = array(); |
238 | 240 | |
239 | - if ( empty( $wp_meta_boxes ) ) |
|
240 | - return; |
|
241 | + if ( empty( $wp_meta_boxes ) ) { |
|
242 | + return; |
|
243 | + } |
|
241 | 244 | |
242 | 245 | $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
243 | 246 | |
@@ -341,8 +344,9 @@ discard block |
||
341 | 344 | |
342 | 345 | |
343 | 346 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
345 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
347 | + if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) { |
|
348 | + add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
349 | + } |
|
346 | 350 | |
347 | 351 | //add preview button |
348 | 352 | add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
@@ -352,12 +356,14 @@ discard block |
||
352 | 356 | add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
353 | 357 | |
354 | 358 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
355 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
356 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
359 | + if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) { |
|
360 | + add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
361 | + } |
|
357 | 362 | |
358 | 363 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
360 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
364 | + if ( method_exists( $this, 'edit_form_after_title' ) ) { |
|
365 | + add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
366 | + } |
|
361 | 367 | |
362 | 368 | |
363 | 369 | /** |
@@ -548,7 +554,9 @@ discard block |
||
548 | 554 | |
549 | 555 | |
550 | 556 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
557 | + if ( !defined('DOING_AUTOSAVE') ) { |
|
558 | + define('DOING_AUTOSAVE', true); |
|
559 | + } |
|
552 | 560 | |
553 | 561 | //if we made it here then the nonce checked out. Let's run our methods and actions |
554 | 562 | if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
@@ -578,8 +586,9 @@ discard block |
||
578 | 586 | protected function _extend_page_config_for_cpt() { |
579 | 587 | |
580 | 588 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
582 | - return; |
|
589 | + if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) { |
|
590 | + return; |
|
591 | + } |
|
583 | 592 | |
584 | 593 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585 | 594 | if ( !empty( $this->_cpt_object ) ) { |
@@ -611,8 +620,9 @@ discard block |
||
611 | 620 | } |
612 | 621 | |
613 | 622 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
614 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
615 | - return; |
|
623 | + if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) { |
|
624 | + return; |
|
625 | + } |
|
616 | 626 | |
617 | 627 | |
618 | 628 | $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
@@ -896,8 +906,10 @@ discard block |
||
896 | 906 | } |
897 | 907 | } |
898 | 908 | |
899 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
900 | - return; //TODO we'll remove this after reimplementing autosave in 4.2 |
|
909 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
910 | + return; |
|
911 | + } |
|
912 | + //TODO we'll remove this after reimplementing autosave in 4.2 |
|
901 | 913 | $this->_insert_update_cpt_item( $post_id, $post ); |
902 | 914 | } |
903 | 915 | |
@@ -974,7 +986,9 @@ discard block |
||
974 | 986 | */ |
975 | 987 | public function modify_current_screen() { |
976 | 988 | //ONLY do this if the current page_route IS a cpt route |
977 | - if ( !$this->_cpt_route ) return; |
|
989 | + if ( !$this->_cpt_route ) { |
|
990 | + return; |
|
991 | + } |
|
978 | 992 | //routing things REALLY early b/c this is a cpt admin page |
979 | 993 | set_current_screen( $this->_cpt_routes[$this->_req_action]); |
980 | 994 | $this->_current_screen = get_current_screen(); |
@@ -1014,8 +1028,9 @@ discard block |
||
1014 | 1028 | public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
1015 | 1029 | if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
1016 | 1030 | $post = get_post( $id ); |
1017 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
1018 | - $shortlink = home_url('?p=' . $post->ID); |
|
1031 | + if ( isset($post->post_type) && $this->page_slug == $post->post_type ) { |
|
1032 | + $shortlink = home_url('?p=' . $post->ID); |
|
1033 | + } |
|
1019 | 1034 | } |
1020 | 1035 | return $shortlink; |
1021 | 1036 | } |
@@ -1028,7 +1043,9 @@ discard block |
||
1028 | 1043 | * @return void |
1029 | 1044 | */ |
1030 | 1045 | public function route_admin_request() { |
1031 | - if ( $this->_cpt_route ) return; |
|
1046 | + if ( $this->_cpt_route ) { |
|
1047 | + return; |
|
1048 | + } |
|
1032 | 1049 | try { |
1033 | 1050 | $this->_route_admin_request(); |
1034 | 1051 | } catch ( EE_Error $e ) { |
@@ -1067,8 +1084,9 @@ discard block |
||
1067 | 1084 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
1068 | 1085 | |
1069 | 1086 | //can't do anything without revision so let's get out if not present |
1070 | - if ( empty( $rev_id ) ) |
|
1071 | - return $location; |
|
1087 | + if ( empty( $rev_id ) ) { |
|
1088 | + return $location; |
|
1089 | + } |
|
1072 | 1090 | |
1073 | 1091 | //get rev_post_data |
1074 | 1092 | $rev = get_post($rev_id); |
@@ -1097,8 +1115,9 @@ discard block |
||
1097 | 1115 | */ |
1098 | 1116 | public function modify_edit_post_link( $link, $id, $context ) { |
1099 | 1117 | $post = get_post( $id ); |
1100 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1101 | - return $link; |
|
1118 | + if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) { |
|
1119 | + return $link; |
|
1120 | + } |
|
1102 | 1121 | $query_args = array( |
1103 | 1122 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1104 | 1123 | 'post' => $id |
@@ -1118,8 +1137,9 @@ discard block |
||
1118 | 1137 | */ |
1119 | 1138 | public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
1120 | 1139 | $post = get_post($post_id); |
1121 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1122 | - return $delete_link; |
|
1140 | + if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) { |
|
1141 | + return $delete_link; |
|
1142 | + } |
|
1123 | 1143 | |
1124 | 1144 | return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
1125 | 1145 | } |
@@ -1133,8 +1153,9 @@ discard block |
||
1133 | 1153 | * @return string url to redirect to |
1134 | 1154 | */ |
1135 | 1155 | public function cpt_trash_post_location_redirect( $location, $status ) { |
1136 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1137 | - return $location; |
|
1156 | + if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) { |
|
1157 | + return $location; |
|
1158 | + } |
|
1138 | 1159 | |
1139 | 1160 | $post = get_post( $this->_req_data['post'] ); |
1140 | 1161 | $query_args = array( 'action' => 'default' ); |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | /** |
81 | - * @var EE_CPT_Base |
|
82 | - */ |
|
81 | + * @var EE_CPT_Base |
|
82 | + */ |
|
83 | 83 | protected $_cpt_model_obj = FALSE; |
84 | 84 | |
85 | 85 | |
@@ -659,12 +659,12 @@ discard block |
||
659 | 659 | $model = null; |
660 | 660 | if ( |
661 | 661 | empty( $this->_cpt_model_names ) |
662 | - || ( |
|
663 | - ! $ignore_route_check |
|
664 | - && ! isset( $this->_cpt_routes[ $this->_req_action ] ) |
|
665 | - ) || ( |
|
666 | - $this->_cpt_model_obj instanceof EE_CPT_Base |
|
667 | - && $this->_cpt_model_obj->ID() === $id |
|
662 | + || ( |
|
663 | + ! $ignore_route_check |
|
664 | + && ! isset( $this->_cpt_routes[ $this->_req_action ] ) |
|
665 | + ) || ( |
|
666 | + $this->_cpt_model_obj instanceof EE_CPT_Base |
|
667 | + && $this->_cpt_model_obj->ID() === $id |
|
668 | 668 | ) |
669 | 669 | ) { |
670 | 670 | EE_Admin::debug_log( __METHOD__, array( '**RETURN**' => true ) ); |
@@ -906,9 +906,9 @@ discard block |
||
906 | 906 | //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit. |
907 | 907 | if ( $update |
908 | 908 | && ( |
909 | - ! $this->_cpt_model_obj instanceof EE_CPT_Base |
|
910 | - || $this->_cpt_model_obj->ID() !== $post_id |
|
911 | - ) |
|
909 | + ! $this->_cpt_model_obj instanceof EE_CPT_Base |
|
910 | + || $this->_cpt_model_obj->ID() !== $post_id |
|
911 | + ) |
|
912 | 912 | ) { |
913 | 913 | return; |
914 | 914 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param object $post The post object of the cpt that was saved. |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - abstract protected function _insert_update_cpt_item( $post_id, $post ); |
|
116 | + abstract protected function _insert_update_cpt_item($post_id, $post); |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $post_id The ID of the cpt that was trashed |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - abstract public function trash_cpt_item( $post_id ); |
|
129 | + abstract public function trash_cpt_item($post_id); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $post_id theID of the cpt that was untrashed |
138 | 138 | * @return void |
139 | 139 | */ |
140 | - abstract public function restore_cpt_item( $post_id ); |
|
140 | + abstract public function restore_cpt_item($post_id); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $post_id the ID of the cpt that was deleted |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - abstract public function delete_cpt_item( $post_id ); |
|
151 | + abstract public function delete_cpt_item($post_id); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | |
@@ -161,32 +161,32 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function _before_page_setup() { |
163 | 163 | |
164 | - $page = isset( $this->_req_data['page'] ) ? $this->_req_data['page'] : $this->page_slug; |
|
164 | + $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
|
165 | 165 | |
166 | - $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes ); |
|
166 | + $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes); |
|
167 | 167 | |
168 | 168 | //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
169 | - $this->_cpt_object = isset($this->_req_data['action']) && isset( $this->_cpt_routes[$this->_req_data['action']] ) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object( $page ); |
|
169 | + $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object($page); |
|
170 | 170 | |
171 | 171 | //tweak pagenow for page loading. |
172 | - if( ! $this->_pagenow_map ) { |
|
172 | + if ( ! $this->_pagenow_map) { |
|
173 | 173 | $this->_pagenow_map = array( |
174 | 174 | 'create_new' => 'post-new.php', |
175 | 175 | 'edit' => 'post.php', |
176 | 176 | 'trash' => 'post.php' |
177 | 177 | ); |
178 | 178 | } |
179 | - add_action( 'current_screen', array( $this, 'modify_pagenow') ); |
|
179 | + add_action('current_screen', array($this, 'modify_pagenow')); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
183 | 183 | //get current page from autosave |
184 | - $current_page = isset( $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] ) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | - $this->_current_page = isset( $this->_req_data['current_page'] ) ? $this->_req_data['current_page'] : $current_page; |
|
184 | + $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | + $this->_current_page = isset($this->_req_data['current_page']) ? $this->_req_data['current_page'] : $current_page; |
|
186 | 186 | |
187 | 187 | |
188 | 188 | //autosave... make sure its only for the correct page |
189 | - if ( !empty($this->_current_page ) && $this->_current_page == $this->page_slug ) { |
|
189 | + if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
|
190 | 190 | //setup autosave ajax hook |
191 | 191 | //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
192 | 192 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - public function modify_pagenow( $current_screen ) { |
|
205 | + public function modify_pagenow($current_screen) { |
|
206 | 206 | global $pagenow; |
207 | 207 | //possibly reset pagenow. |
208 | - if ( ! empty( $this->_req_data['page'] ) && $this->_req_data['page'] == $this->page_slug && !empty( $this->_req_data['action'] ) && isset( $this->_pagenow_map[$this->_req_data['action'] ] ) ) { |
|
208 | + if ( ! empty($this->_req_data['page']) && $this->_req_data['page'] == $this->page_slug && ! empty($this->_req_data['action']) && isset($this->_pagenow_map[$this->_req_data['action']])) { |
|
209 | 209 | $pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
210 | 210 | } |
211 | 211 | } |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically you would send along the id of a metabox container. |
221 | 221 | * @return void |
222 | 222 | */ |
223 | - protected function _register_autosave_containers( $ids ) { |
|
224 | - $this->_autosave_containers = array_merge( $this->_autosave_fields, (array) $ids ); |
|
223 | + protected function _register_autosave_containers($ids) { |
|
224 | + $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | |
237 | 237 | $containers = array(); |
238 | 238 | |
239 | - if ( empty( $wp_meta_boxes ) ) |
|
239 | + if (empty($wp_meta_boxes)) |
|
240 | 240 | return; |
241 | 241 | |
242 | - $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
242 | + $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
243 | 243 | |
244 | - foreach ( $current_metaboxes as $box_context ) { |
|
245 | - foreach ( $box_context as $box_details ) { |
|
246 | - foreach ( $box_details as $box ) { |
|
247 | - if ( is_array( $box['callback'] ) && ( $box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks ) ){ |
|
244 | + foreach ($current_metaboxes as $box_context) { |
|
245 | + foreach ($box_context as $box_details) { |
|
246 | + foreach ($box_details as $box) { |
|
247 | + if (is_array($box['callback']) && ($box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks)) { |
|
248 | 248 | $containers[] = $box['id']; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - $this->_autosave_containers = array_merge( $this->_autosave_containers, $containers ); |
|
254 | + $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
|
255 | 255 | |
256 | 256 | //add hidden inputs container |
257 | 257 | $this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2 |
269 | 269 | |
270 | 270 | //filter _autosave_containers |
271 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this ); |
|
272 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', $containers, $this ); |
|
271 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this); |
|
272 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers', $containers, $this); |
|
273 | 273 | |
274 | - wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers ); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
274 | + wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
275 | 275 | |
276 | 276 | $unsaved_data_msg = array( |
277 | - 'eventmsg' => sprintf( __("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
277 | + 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
278 | 278 | 'inputChanged' => 0 |
279 | 279 | ); |
280 | 280 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function load_page_dependencies() { |
287 | 287 | try { |
288 | 288 | $this->_load_page_dependencies(); |
289 | - } catch ( EE_Error $e ) { |
|
289 | + } catch (EE_Error $e) { |
|
290 | 290 | $e->get_error(); |
291 | 291 | } |
292 | 292 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | protected function _load_page_dependencies() { |
303 | 303 | |
304 | 304 | //we only add stuff if this is a cpt_route! |
305 | - if ( !$this->_cpt_route ) { |
|
305 | + if ( ! $this->_cpt_route) { |
|
306 | 306 | parent::_load_page_dependencies(); |
307 | 307 | return; |
308 | 308 | } |
@@ -312,72 +312,72 @@ discard block |
||
312 | 312 | |
313 | 313 | //the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
314 | 314 | //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
315 | - add_action('edit_form_after_title', array( $this, 'cpt_post_form_hidden_input') ); |
|
315 | + add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
|
316 | 316 | |
317 | 317 | //inject our Admin page nav tabs... |
318 | 318 | //let's make sure the nav tabs are set if they aren't already |
319 | 319 | //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
320 | - add_action('post_edit_form_tag', array( $this, 'inject_nav_tabs' ) ); |
|
320 | + add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
|
321 | 321 | |
322 | 322 | //modify the post_updated messages array |
323 | - add_action('post_updated_messages', array( $this, 'post_update_messages' ), 10 ); |
|
323 | + add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
|
324 | 324 | |
325 | 325 | //add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
326 | - add_filter( 'pre_get_shortlink', array( $this, 'add_shortlink_button_to_editor' ), 10, 4 ); |
|
326 | + add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
|
327 | 327 | |
328 | 328 | //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
329 | - if ( !empty($this->_labels['publishbox'] ) ) { |
|
329 | + if ( ! empty($this->_labels['publishbox'])) { |
|
330 | 330 | |
331 | - $box_label = is_array( $this->_labels['publishbox'] ) && isset( $this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
331 | + $box_label = is_array($this->_labels['publishbox']) && isset($this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
332 | 332 | |
333 | - remove_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
334 | - add_meta_box( 'submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
333 | + remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
334 | + add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | //let's add page_templates metabox if this cpt added support for it. |
338 | - if ( $this->_supports_page_templates($this->_cpt_object->name) ) { |
|
339 | - add_meta_box( 'page_templates', __('Page Template', 'event_espresso' ), array( $this, 'page_template_meta_box' ), $this->_cpt_routes[$this->_req_action], 'side', 'default' ); |
|
338 | + if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
339 | + add_meta_box('page_templates', __('Page Template', 'event_espresso'), array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
|
340 | 340 | }/**/ |
341 | 341 | |
342 | 342 | |
343 | 343 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
345 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
344 | + if (method_exists($this, 'extra_permalink_field_buttons')) |
|
345 | + add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
|
346 | 346 | |
347 | 347 | //add preview button |
348 | - add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
|
348 | + add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
|
349 | 349 | |
350 | 350 | |
351 | 351 | //insert our own post_stati dropdown |
352 | - add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
|
352 | + add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
|
353 | 353 | |
354 | 354 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
355 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
356 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
355 | + if (method_exists($this, 'extra_misc_actions_publish_box')) |
|
356 | + add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
|
357 | 357 | |
358 | 358 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
360 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
359 | + if (method_exists($this, 'edit_form_after_title')) |
|
360 | + add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
|
361 | 361 | |
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
365 | 365 | */ |
366 | - add_filter( 'clean_url', array( $this, 'switch_core_wp_urls_with_ours' ), 10, 3 ); |
|
366 | + add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | parent::_load_page_dependencies(); |
370 | 370 | |
371 | 371 | //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
372 | 372 | global $pagenow; |
373 | - do_action( 'load-' . $pagenow ); |
|
373 | + do_action('load-'.$pagenow); |
|
374 | 374 | |
375 | 375 | $this->modify_current_screen(); |
376 | - add_action( 'admin_enqueue_scripts', array( $this, 'setup_autosave_hooks'), 30 ); |
|
376 | + add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
|
377 | 377 | //we route REALLY early. |
378 | 378 | try { |
379 | 379 | $this->_route_admin_request(); |
380 | - } catch ( EE_Error $e ) { |
|
380 | + } catch (EE_Error $e) { |
|
381 | 381 | $e->get_error(); |
382 | 382 | } |
383 | 383 | } |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string possibly a new url for our route. |
398 | 398 | */ |
399 | - public function switch_core_wp_urls_with_ours( $good_protocol_url, $original_url, $_context ) { |
|
399 | + public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) { |
|
400 | 400 | $routes_to_match = array( |
401 | 401 | 0 => array( |
402 | 402 | 'edit.php?post_type=espresso_attendees', |
403 | 403 | 'admin.php?page=espresso_registrations&action=contact_list' |
404 | 404 | ), |
405 | 405 | 1 => array( |
406 | - 'edit.php?post_type=' . $this->_cpt_object->name, |
|
407 | - 'admin.php?page=' . $this->_cpt_object->name |
|
406 | + 'edit.php?post_type='.$this->_cpt_object->name, |
|
407 | + 'admin.php?page='.$this->_cpt_object->name |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | |
411 | - foreach( $routes_to_match as $route_matches ) { |
|
412 | - if ( strpos( $good_protocol_url, $route_matches[0] ) !== false ) { |
|
413 | - return str_replace( $route_matches[0], $route_matches[1], $good_protocol_url ); |
|
411 | + foreach ($routes_to_match as $route_matches) { |
|
412 | + if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
413 | + return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | } |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | * @param string $cpt_name The cpt slug we're checking on. |
427 | 427 | * @return bool True supported, false not. |
428 | 428 | */ |
429 | - private function _supports_page_templates( $cpt_name ) { |
|
429 | + private function _supports_page_templates($cpt_name) { |
|
430 | 430 | $cpt_args = EE_Register_CPTs::get_CPTs(); |
431 | - $cpt_args = isset( $cpt_args[$cpt_name] ) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | - return ! empty( $cpt_args['page_templates'] ) ? TRUE : FALSE; |
|
431 | + $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | + return ! empty($cpt_args['page_templates']) ? TRUE : FALSE; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | public function page_template_meta_box() { |
445 | 445 | global $post; |
446 | 446 | $template = ''; |
447 | - if ( count( get_page_templates( $post ) ) != 0 ) { |
|
448 | - $page_template = get_post_meta( $post->ID, '_wp_page_template', TRUE ); |
|
449 | - $template = !empty( $page_template ) ? $page_template : ''; |
|
447 | + if (count(get_page_templates($post)) != 0) { |
|
448 | + $page_template = get_post_meta($post->ID, '_wp_page_template', TRUE); |
|
449 | + $template = ! empty($page_template) ? $page_template : ''; |
|
450 | 450 | } |
451 | 451 | ?> |
452 | 452 | <p><strong><?php _e('Template') ?></strong></p> |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | * @param string $new_slug what the slug is |
471 | 471 | * @return string The new html string for the permalink area |
472 | 472 | */ |
473 | - public function preview_button_html( $return, $id, $new_title, $new_slug ) { |
|
474 | - $post = get_post( $id ); |
|
475 | - if ( 'publish' != get_post_status( $post ) ) { |
|
476 | - $return .= '<span_id="view-post-btn"><a href="' . wp_get_shortlink($id, 'post') . '" class="button button-small">' . __('Preview', 'event_espresso') . '</a></span>' . "\n"; |
|
473 | + public function preview_button_html($return, $id, $new_title, $new_slug) { |
|
474 | + $post = get_post($id); |
|
475 | + if ('publish' != get_post_status($post)) { |
|
476 | + $return .= '<span_id="view-post-btn"><a href="'.wp_get_shortlink($id, 'post').'" class="button button-small">'.__('Preview', 'event_espresso').'</a></span>'."\n"; |
|
477 | 477 | } |
478 | 478 | return $return; |
479 | 479 | } |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | 'cur_status' => $this->_cpt_model_obj->status(), |
494 | 494 | 'statuses' => $statuses, |
495 | 495 | 'cur_status_label' => $cur_status_label, |
496 | - 'localized_status_save' => sprintf( __('Save %s', 'event_espresso'), $cur_status_label ) |
|
496 | + 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label) |
|
497 | 497 | ); |
498 | 498 | |
499 | 499 | //we'll add a trash post status (WP doesn't add one for some reason) |
500 | - if ( $this->_cpt_model_obj->status() == 'trash' ) { |
|
500 | + if ($this->_cpt_model_obj->status() == 'trash') { |
|
501 | 501 | $template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
502 | 502 | $statuses['trash'] = __('Trashed', 'event_espresso'); |
503 | 503 | $template_args['statuses'] = $statuses; |
504 | 504 | } |
505 | 505 | |
506 | - $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
507 | - EEH_Template::display_template( $template, $template_args ); |
|
506 | + $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php'; |
|
507 | + EEH_Template::display_template($template, $template_args); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -543,22 +543,22 @@ discard block |
||
543 | 543 | public function do_extra_autosave_stuff() { |
544 | 544 | |
545 | 545 | //next let's check for the autosave nonce (we'll use _verify_nonce ) |
546 | - $nonce = isset( $this->_req_data['autosavenonce'] ) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | - $this->_verify_nonce( $nonce, 'autosave' ); |
|
546 | + $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | + $this->_verify_nonce($nonce, 'autosave'); |
|
548 | 548 | |
549 | 549 | |
550 | 550 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
551 | + if ( ! defined('DOING_AUTOSAVE')) define('DOING_AUTOSAVE', true); |
|
552 | 552 | |
553 | 553 | //if we made it here then the nonce checked out. Let's run our methods and actions |
554 | - if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
|
555 | - call_user_func( array( $this, '_ee_autosave_' . $this->_current_view ) ); |
|
554 | + if (method_exists($this, '_ee_autosave_'.$this->_current_view)) { |
|
555 | + call_user_func(array($this, '_ee_autosave_'.$this->_current_view)); |
|
556 | 556 | } else { |
557 | 557 | $this->_template_args['success'] = TRUE; |
558 | 558 | } |
559 | 559 | |
560 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this ); |
|
561 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class( $this ), $this ); |
|
560 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
561 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this); |
|
562 | 562 | |
563 | 563 | //now let's return json |
564 | 564 | $this->_return_json(); |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | protected function _extend_page_config_for_cpt() { |
579 | 579 | |
580 | 580 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
581 | + if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) |
|
582 | 582 | return; |
583 | 583 | |
584 | 584 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585 | - if ( !empty( $this->_cpt_object ) ) { |
|
586 | - $this->_page_routes = array_merge( array( |
|
585 | + if ( ! empty($this->_cpt_object)) { |
|
586 | + $this->_page_routes = array_merge(array( |
|
587 | 587 | 'create_new' => '_create_new_cpt_item', |
588 | 588 | 'edit' => '_edit_cpt_item' |
589 | - ), $this->_page_routes ); |
|
589 | + ), $this->_page_routes); |
|
590 | 590 | |
591 | 591 | |
592 | - $this->_page_config = array_merge( array( |
|
592 | + $this->_page_config = array_merge(array( |
|
593 | 593 | 'create_new' => array( |
594 | 594 | 'nav' => array( |
595 | 595 | 'label' => $this->_cpt_object->labels->add_new_item, |
@@ -611,23 +611,23 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
614 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
614 | + if ( ! isset($this->_cpt_routes[$this->_req_action])) |
|
615 | 615 | return; |
616 | 616 | |
617 | 617 | |
618 | - $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
|
618 | + $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? TRUE : FALSE; |
|
619 | 619 | //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
620 | 620 | |
621 | 621 | |
622 | - if ( empty( $this->_cpt_object ) ) { |
|
623 | - $msg = sprintf( __('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this) ); |
|
624 | - throw new EE_Error( $msg ); |
|
622 | + if (empty($this->_cpt_object)) { |
|
623 | + $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this)); |
|
624 | + throw new EE_Error($msg); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
628 | - if ( $this->_cpt_route ) { |
|
629 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
630 | - $this->_set_model_object( $id ); |
|
628 | + if ($this->_cpt_route) { |
|
629 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
630 | + $this->_set_model_object($id); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | } |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | * @param int $id The id to retrieve the model object for. If empty we set a default object. |
642 | 642 | * @param bool $ignore_route_check |
643 | 643 | */ |
644 | - protected function _set_model_object( $id = NULL, $ignore_route_check = false ) { |
|
644 | + protected function _set_model_object($id = NULL, $ignore_route_check = false) { |
|
645 | 645 | $model = null; |
646 | 646 | if ( |
647 | - empty( $this->_cpt_model_names ) |
|
647 | + empty($this->_cpt_model_names) |
|
648 | 648 | || ( |
649 | 649 | ! $ignore_route_check |
650 | - && ! isset( $this->_cpt_routes[ $this->_req_action ] ) |
|
650 | + && ! isset($this->_cpt_routes[$this->_req_action]) |
|
651 | 651 | ) || ( |
652 | 652 | $this->_cpt_model_obj instanceof EE_CPT_Base |
653 | 653 | && $this->_cpt_model_obj->ID() === $id |
@@ -657,21 +657,21 @@ discard block |
||
657 | 657 | return; |
658 | 658 | } |
659 | 659 | //if ignore_route_check is true, then get the model name via EE_Register_CPTs |
660 | - if ( $ignore_route_check ) { |
|
660 | + if ($ignore_route_check) { |
|
661 | 661 | $model_names = EE_Register_CPTs::get_cpt_model_names(); |
662 | - $post_type = get_post_type( $id ); |
|
663 | - if ( isset( $model_names[ $post_type ] ) ) { |
|
664 | - $model = EE_Registry::instance()->load_model( $model_names[ $post_type ] ); |
|
662 | + $post_type = get_post_type($id); |
|
663 | + if (isset($model_names[$post_type])) { |
|
664 | + $model = EE_Registry::instance()->load_model($model_names[$post_type]); |
|
665 | 665 | } |
666 | 666 | } else { |
667 | - $model = EE_Registry::instance()->load_model( $this->_cpt_model_names[$this->_req_action] ); |
|
667 | + $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
|
668 | 668 | } |
669 | 669 | |
670 | - if ( $model instanceof EEM_Base ) { |
|
671 | - $this->_cpt_model_obj = ! empty( $id ) ? $model->get_one_by_ID( $id ) : $model->create_default_object(); |
|
670 | + if ($model instanceof EEM_Base) { |
|
671 | + $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
|
672 | 672 | } |
673 | 673 | |
674 | - do_action( 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object' ); |
|
674 | + do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -685,47 +685,47 @@ discard block |
||
685 | 685 | */ |
686 | 686 | public function admin_init_global() { |
687 | 687 | |
688 | - $post = isset( $this->_req_data['post'] ) ? get_post( $this->_req_data['post'] ) : NULL; |
|
688 | + $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : NULL; |
|
689 | 689 | |
690 | 690 | //its possible this is a new save so let's catch that instead |
691 | - $post = isset( $this->_req_data['post_ID'] ) ? get_post( $this->_req_data['post_ID'] ) : $post; |
|
691 | + $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
|
692 | 692 | $post_type = $post ? $post->post_type : false; |
693 | 693 | |
694 | 694 | $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
695 | 695 | |
696 | - $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
696 | + $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
697 | 697 | |
698 | - add_filter( 'get_delete_post_link', array( $this, 'modify_delete_post_link'), 10, 3 ); |
|
699 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link'), 10, 3 ); |
|
698 | + add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
699 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
700 | 700 | |
701 | 701 | |
702 | - if ( $post_type === $route_to_check ) { |
|
703 | - add_filter('redirect_post_location', array( $this, 'cpt_post_location_redirect'), 10, 2 ); |
|
702 | + if ($post_type === $route_to_check) { |
|
703 | + add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
|
704 | 704 | //catch trashed wp redirect |
705 | - add_filter('wp_redirect', array( $this, 'cpt_trash_post_location_redirect' ), 10, 2 ); |
|
705 | + add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | //now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
709 | - $revision = isset( $this->_req_data['revision'] ) ? $this->_req_data['revision'] : NULL; |
|
709 | + $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
|
710 | 710 | |
711 | 711 | /**var_dump($this->_req_data); |
712 | 712 | exit();/**/ |
713 | 713 | |
714 | - if ( !empty( $revision ) ) { |
|
715 | - $action = isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : NULL; |
|
714 | + if ( ! empty($revision)) { |
|
715 | + $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : NULL; |
|
716 | 716 | |
717 | 717 | //doing a restore? |
718 | - if ( !empty( $action ) && $action == 'restore' ) { |
|
718 | + if ( ! empty($action) && $action == 'restore') { |
|
719 | 719 | |
720 | 720 | //get post for revision |
721 | - $rev_post = get_post( $revision ); |
|
722 | - $rev_parent = get_post( $rev_post->post_parent ); |
|
721 | + $rev_post = get_post($revision); |
|
722 | + $rev_parent = get_post($rev_post->post_parent); |
|
723 | 723 | |
724 | 724 | //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
725 | - if ( $rev_parent && $rev_parent->post_type == $this->page_slug ) { |
|
726 | - add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2 ); |
|
725 | + if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
726 | + add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
|
727 | 727 | //restores of revisions |
728 | - add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2 ); |
|
728 | + add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | |
@@ -734,15 +734,15 @@ discard block |
||
734 | 734 | //NOTE we ONLY want to run these hooks if we're on the right class for the given post type. Otherwise we could see some really freaky things happen! |
735 | 735 | |
736 | 736 | |
737 | - if ( $post_type && $post_type === $route_to_check ) { |
|
737 | + if ($post_type && $post_type === $route_to_check) { |
|
738 | 738 | //$post_id, $post |
739 | - add_action('save_post', array( $this, 'insert_update'), 10, 3 ); |
|
739 | + add_action('save_post', array($this, 'insert_update'), 10, 3); |
|
740 | 740 | |
741 | 741 | //$post_id |
742 | - add_action('trashed_post', array( $this, 'before_trash_cpt_item' ), 10 ); |
|
743 | - add_action('trashed_post', array( $this, 'dont_permanently_delete_ee_cpts'), 10 ); |
|
744 | - add_action('untrashed_post', array( $this, 'before_restore_cpt_item'), 10 ); |
|
745 | - add_action('after_delete_post', array( $this, 'before_delete_cpt_item'), 10 ); |
|
742 | + add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10); |
|
743 | + add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
744 | + add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10); |
|
745 | + add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | } |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @param int $post_id |
758 | 758 | */ |
759 | - public function before_trash_cpt_item( $post_id ) { |
|
760 | - $this->_set_model_object( $post_id, true ); |
|
759 | + public function before_trash_cpt_item($post_id) { |
|
760 | + $this->_set_model_object($post_id, true); |
|
761 | 761 | //if our cpt object isn't existent then get out immediately. |
762 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
762 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
763 | 763 | return; |
764 | 764 | } |
765 | - $this->trash_cpt_item( $post_id ); |
|
765 | + $this->trash_cpt_item($post_id); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | |
@@ -772,13 +772,13 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @param $post_id |
774 | 774 | */ |
775 | - public function before_restore_cpt_item( $post_id ) { |
|
776 | - $this->_set_model_object( $post_id, true ); |
|
775 | + public function before_restore_cpt_item($post_id) { |
|
776 | + $this->_set_model_object($post_id, true); |
|
777 | 777 | //if our cpt object isn't existent then get out immediately. |
778 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
778 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
779 | 779 | return; |
780 | 780 | } |
781 | - $this->restore_cpt_item( $post_id ); |
|
781 | + $this->restore_cpt_item($post_id); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -787,13 +787,13 @@ discard block |
||
787 | 787 | * Execute some basic checks before calling the delete_cpt_item method in the child class. |
788 | 788 | * @param $post_id |
789 | 789 | */ |
790 | - public function before_delete_cpt_item( $post_id ) { |
|
791 | - $this->_set_model_object( $post_id, true ); |
|
790 | + public function before_delete_cpt_item($post_id) { |
|
791 | + $this->_set_model_object($post_id, true); |
|
792 | 792 | //if our cpt object isn't existent then get out immediately. |
793 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
793 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
794 | 794 | return; |
795 | 795 | } |
796 | - $this->delete_cpt_item( $post_id ); |
|
796 | + $this->delete_cpt_item($post_id); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | |
@@ -805,15 +805,15 @@ discard block |
||
805 | 805 | * @return void |
806 | 806 | */ |
807 | 807 | public function verify_cpt_object() { |
808 | - $label = !empty( $this->_cpt_object ) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
808 | + $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
809 | 809 | // verify event object |
810 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
811 | - throw new EE_Error( sprintf( __('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso' ), $label ) ); |
|
810 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
811 | + throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso'), $label)); |
|
812 | 812 | } |
813 | 813 | //if auto-draft then throw an error |
814 | - if ( $this->_cpt_model_obj->get('status') == 'auto-draft' ) { |
|
814 | + if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
|
815 | 815 | EE_Error::overwrite_errors(); |
816 | - EE_Error::add_error( sprintf( __('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label ), __FILE__, __FUNCTION__, __LINE__ ); |
|
816 | + EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label), __FILE__, __FUNCTION__, __LINE__); |
|
817 | 817 | } |
818 | 818 | } |
819 | 819 | |
@@ -842,22 +842,22 @@ discard block |
||
842 | 842 | public function load_global_scripts_styles() { |
843 | 843 | parent::load_global_scripts_styles(); |
844 | 844 | |
845 | - if ( $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
845 | + if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
846 | 846 | //setup custom post status object for localize script but only if we've got a cpt object |
847 | 847 | $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
848 | 848 | |
849 | - if ( !empty($statuses) ) { |
|
849 | + if ( ! empty($statuses)) { |
|
850 | 850 | //get ALL statuses! |
851 | 851 | $statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
852 | 852 | //setup object |
853 | 853 | $ee_cpt_statuses = array(); |
854 | - foreach ( $statuses as $status => $label ) { |
|
854 | + foreach ($statuses as $status => $label) { |
|
855 | 855 | $ee_cpt_statuses[$status] = array( |
856 | 856 | 'label' => $label, |
857 | - 'save_label' => sprintf( __('Save as %s', 'event_espresso'), $label ) |
|
857 | + 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label) |
|
858 | 858 | ); |
859 | 859 | } |
860 | - wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses ); |
|
860 | + wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | } |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | * @param bool $update Whether this is an update or a new save. |
873 | 873 | * @return void |
874 | 874 | */ |
875 | - public function insert_update( $post_id, $post, $update ) { |
|
875 | + public function insert_update($post_id, $post, $update) { |
|
876 | 876 | |
877 | 877 | //make sure that if this is a revision OR trash action that we don't do any updates! |
878 | 878 | if ( |
879 | - isset( $this->_req_data['action'] ) |
|
879 | + isset($this->_req_data['action']) |
|
880 | 880 | && ( |
881 | 881 | $this->_req_data['action'] == 'restore' |
882 | 882 | || $this->_req_data['action'] == 'trash' |
@@ -885,10 +885,10 @@ discard block |
||
885 | 885 | return; |
886 | 886 | } |
887 | 887 | |
888 | - $this->_set_model_object( $post_id, true ); |
|
888 | + $this->_set_model_object($post_id, true); |
|
889 | 889 | |
890 | 890 | //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit. |
891 | - if ( $update |
|
891 | + if ($update |
|
892 | 892 | && ( |
893 | 893 | ! $this->_cpt_model_obj instanceof EE_CPT_Base |
894 | 894 | || $this->_cpt_model_obj->ID() !== $post_id |
@@ -909,19 +909,19 @@ discard block |
||
909 | 909 | }/**/ //TODO reactivate after autosave is implemented in 4.2 |
910 | 910 | |
911 | 911 | //take care of updating any selected page_template IF this cpt supports it. |
912 | - if ( $this->_supports_page_templates($post->post_type ) && !empty( $this->_req_data['page_template'] ) ) { |
|
912 | + if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
|
913 | 913 | $post->page_template = $this->_req_data['page_template']; |
914 | - $page_templates = wp_get_theme()->get_page_templates( $post ); |
|
915 | - if ( 'default' != $this->_req_data['page_template'] && ! isset( $page_templates[ $this->_req_data['page_template'] ] ) ) { |
|
916 | - EE_Error::add_error( __('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
914 | + $page_templates = wp_get_theme()->get_page_templates($post); |
|
915 | + if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
916 | + EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
917 | 917 | } else { |
918 | - update_post_meta( $post_id, '_wp_page_template', $this->_req_data['page_template'] ); |
|
918 | + update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | |
922 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
922 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
923 | 923 | return; //TODO we'll remove this after reimplementing autosave in 4.2 |
924 | - $this->_insert_update_cpt_item( $post_id, $post ); |
|
924 | + $this->_insert_update_cpt_item($post_id, $post); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | |
@@ -934,15 +934,15 @@ discard block |
||
934 | 934 | * @param int $post_id ID of the post |
935 | 935 | * @return void |
936 | 936 | */ |
937 | - public function dont_permanently_delete_ee_cpts( $post_id ) { |
|
937 | + public function dont_permanently_delete_ee_cpts($post_id) { |
|
938 | 938 | //only do this if we're actually processing one of our CPTs |
939 | 939 | //if our cpt object isn't existent then get out immediately. |
940 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
940 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
941 | 941 | return; |
942 | 942 | } |
943 | 943 | |
944 | - delete_post_meta( $post_id, '_wp_trash_meta_status' ); |
|
945 | - delete_post_meta( $post_id, '_wp_trash_meta_time'); |
|
944 | + delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
945 | + delete_post_meta($post_id, '_wp_trash_meta_time'); |
|
946 | 946 | |
947 | 947 | //our cpts may have comments so let's take care of that too |
948 | 948 | delete_post_meta($post_id, '_wp_trash_meta_comments_status'); |
@@ -960,14 +960,14 @@ discard block |
||
960 | 960 | * @param int $revision_id ID of revision being restored |
961 | 961 | * @return void |
962 | 962 | */ |
963 | - public function restore_revision( $post_id, $revision_id ) { |
|
964 | - $this->_restore_cpt_item( $post_id, $revision_id ); |
|
963 | + public function restore_revision($post_id, $revision_id) { |
|
964 | + $this->_restore_cpt_item($post_id, $revision_id); |
|
965 | 965 | |
966 | 966 | //global action |
967 | - do_action( 'AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
967 | + do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
968 | 968 | |
969 | 969 | //class specific action so you can limit hooking into a specific page. |
970 | - do_action( 'AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id ); |
|
970 | + do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @param int $revision_id ID of revision for item |
979 | 979 | * @return void |
980 | 980 | */ |
981 | - abstract protected function _restore_cpt_item( $post_id, $revision_id ); |
|
981 | + abstract protected function _restore_cpt_item($post_id, $revision_id); |
|
982 | 982 | |
983 | 983 | |
984 | 984 | |
@@ -997,9 +997,9 @@ discard block |
||
997 | 997 | */ |
998 | 998 | public function modify_current_screen() { |
999 | 999 | //ONLY do this if the current page_route IS a cpt route |
1000 | - if ( !$this->_cpt_route ) return; |
|
1000 | + if ( ! $this->_cpt_route) return; |
|
1001 | 1001 | //routing things REALLY early b/c this is a cpt admin page |
1002 | - set_current_screen( $this->_cpt_routes[$this->_req_action]); |
|
1002 | + set_current_screen($this->_cpt_routes[$this->_req_action]); |
|
1003 | 1003 | $this->_current_screen = get_current_screen(); |
1004 | 1004 | $this->_current_screen->base = 'event-espresso'; |
1005 | 1005 | $this->_add_help_tabs(); //we make sure we add any help tabs back in! |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | * @param string $title The new title (or existing if there is no editor_title defined) |
1021 | 1021 | * @return string |
1022 | 1022 | */ |
1023 | - public function add_custom_editor_default_title( $title ) { |
|
1024 | - return isset( $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] ) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
1023 | + public function add_custom_editor_default_title($title) { |
|
1024 | + return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
@@ -1034,11 +1034,11 @@ discard block |
||
1034 | 1034 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
1035 | 1035 | * @return string |
1036 | 1036 | */ |
1037 | - public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
|
1038 | - if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
|
1039 | - $post = get_post( $id ); |
|
1040 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
1041 | - $shortlink = home_url('?p=' . $post->ID); |
|
1037 | + public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) { |
|
1038 | + if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
1039 | + $post = get_post($id); |
|
1040 | + if (isset($post->post_type) && $this->page_slug == $post->post_type) |
|
1041 | + $shortlink = home_url('?p='.$post->ID); |
|
1042 | 1042 | } |
1043 | 1043 | return $shortlink; |
1044 | 1044 | } |
@@ -1051,10 +1051,10 @@ discard block |
||
1051 | 1051 | * @return void |
1052 | 1052 | */ |
1053 | 1053 | public function route_admin_request() { |
1054 | - if ( $this->_cpt_route ) return; |
|
1054 | + if ($this->_cpt_route) return; |
|
1055 | 1055 | try { |
1056 | 1056 | $this->_route_admin_request(); |
1057 | - } catch ( EE_Error $e ) { |
|
1057 | + } catch (EE_Error $e) { |
|
1058 | 1058 | $e->get_error(); |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1067,12 +1067,12 @@ discard block |
||
1067 | 1067 | * @return string html |
1068 | 1068 | */ |
1069 | 1069 | public function cpt_post_form_hidden_input() { |
1070 | - echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
1070 | + echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />'; |
|
1071 | 1071 | |
1072 | 1072 | //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
1073 | 1073 | echo '<div id="ee-cpt-hidden-inputs">'; |
1074 | - echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
1075 | - echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
1074 | + echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />'; |
|
1075 | + echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />'; |
|
1076 | 1076 | echo '</div>'; |
1077 | 1077 | } |
1078 | 1078 | |
@@ -1085,12 +1085,12 @@ discard block |
||
1085 | 1085 | * @param int $status Status for http header |
1086 | 1086 | * @return string new (or original) url to redirect to. |
1087 | 1087 | */ |
1088 | - public function revision_redirect( $location, $status ) { |
|
1088 | + public function revision_redirect($location, $status) { |
|
1089 | 1089 | //get revision |
1090 | 1090 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
1091 | 1091 | |
1092 | 1092 | //can't do anything without revision so let's get out if not present |
1093 | - if ( empty( $rev_id ) ) |
|
1093 | + if (empty($rev_id)) |
|
1094 | 1094 | return $location; |
1095 | 1095 | |
1096 | 1096 | //get rev_post_data |
@@ -1104,8 +1104,8 @@ discard block |
||
1104 | 1104 | 'message' => 5 |
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - $this->_process_notices( $query_args, TRUE ); |
|
1108 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1107 | + $this->_process_notices($query_args, TRUE); |
|
1108 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | |
@@ -1118,16 +1118,16 @@ discard block |
||
1118 | 1118 | * @param string $context optional, defaults to display. How to write the '&' |
1119 | 1119 | * @return string the link |
1120 | 1120 | */ |
1121 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
1122 | - $post = get_post( $id ); |
|
1123 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1121 | + public function modify_edit_post_link($link, $id, $context) { |
|
1122 | + $post = get_post($id); |
|
1123 | + if ( ! isset($this->_req_data['action']) || ! isset($this->_cpt_routes[$this->_req_data['action']]) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
|
1124 | 1124 | return $link; |
1125 | 1125 | $query_args = array( |
1126 | 1126 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1127 | 1127 | 'post' => $id |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1130 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1139,12 +1139,12 @@ discard block |
||
1139 | 1139 | * @param bool $force_delete whether this is forcing a hard delete instead of trash |
1140 | 1140 | * @return string new delete link |
1141 | 1141 | */ |
1142 | - public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
|
1142 | + public function modify_delete_post_link($delete_link, $post_id, $force_delete) { |
|
1143 | 1143 | $post = get_post($post_id); |
1144 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1144 | + if ( ! isset($this->_req_data['action']) || (isset($this->_cpt_routes[$this->_req_data['action']]) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])) |
|
1145 | 1145 | return $delete_link; |
1146 | 1146 | |
1147 | - return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
|
1147 | + return add_query_arg(array('current_route' => 'trash'), $delete_link); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | |
@@ -1155,16 +1155,16 @@ discard block |
||
1155 | 1155 | * @param string $status status |
1156 | 1156 | * @return string url to redirect to |
1157 | 1157 | */ |
1158 | - public function cpt_trash_post_location_redirect( $location, $status ) { |
|
1159 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1158 | + public function cpt_trash_post_location_redirect($location, $status) { |
|
1159 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) |
|
1160 | 1160 | return $location; |
1161 | 1161 | |
1162 | - $post = get_post( $this->_req_data['post'] ); |
|
1163 | - $query_args = array( 'action' => 'default' ); |
|
1162 | + $post = get_post($this->_req_data['post']); |
|
1163 | + $query_args = array('action' => 'default'); |
|
1164 | 1164 | $this->_cpt_object = get_post_type_object($post->post_type); |
1165 | - EE_Error::add_success( sprintf( __('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name) ); |
|
1166 | - $this->_process_notices( $query_args, TRUE ); |
|
1167 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1165 | + EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name)); |
|
1166 | + $this->_process_notices($query_args, TRUE); |
|
1167 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | |
@@ -1179,21 +1179,21 @@ discard block |
||
1179 | 1179 | * @param string $post_id This is the 'ID' value of the wp_posts table |
1180 | 1180 | * @return string the new location to redirect to |
1181 | 1181 | */ |
1182 | - public function cpt_post_location_redirect( $location, $post_id ) { |
|
1182 | + public function cpt_post_location_redirect($location, $post_id) { |
|
1183 | 1183 | //we DO have a match so let's setup the url |
1184 | 1184 | //we have to get the post to determine our route |
1185 | 1185 | $post = get_post($post_id); |
1186 | 1186 | $edit_route = $this->_cpt_edit_routes[$post->post_type]; |
1187 | 1187 | |
1188 | 1188 | //shared query_args |
1189 | - $query_args = array( 'action' => $edit_route, 'post' => $post_id ); |
|
1189 | + $query_args = array('action' => $edit_route, 'post' => $post_id); |
|
1190 | 1190 | $admin_url = $this->_admin_base_url; |
1191 | 1191 | // $append = ''; |
1192 | 1192 | |
1193 | - if ( isset( $this->_req_data['save'] ) || isset( $this->_req_data['publish'] ) ) { |
|
1194 | - $status = get_post_status( $post_id ); |
|
1195 | - if ( isset( $this->_req_data['publish'] ) ) { |
|
1196 | - switch ( $status ) { |
|
1193 | + if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
1194 | + $status = get_post_status($post_id); |
|
1195 | + if (isset($this->_req_data['publish'])) { |
|
1196 | + switch ($status) { |
|
1197 | 1197 | case 'pending': |
1198 | 1198 | $message = 8; |
1199 | 1199 | break; |
@@ -1206,13 +1206,13 @@ discard block |
||
1206 | 1206 | } else { |
1207 | 1207 | $message = 'draft' == $status ? 10 : 1; |
1208 | 1208 | } |
1209 | - } else if ( isset( $this->_req_data['addmeta']) && $this->_req_data['addmeta'] ) { |
|
1209 | + } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
|
1210 | 1210 | $message = 2; |
1211 | 1211 | // $append = '#postcustom'; |
1212 | - } else if ( isset( $this->_req_data['deletemeta']) && $this->_req_data['deletemeta'] ) { |
|
1212 | + } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
|
1213 | 1213 | $message = 3; |
1214 | 1214 | // $append = '#postcustom'; |
1215 | - } elseif ( $this->_req_data['action'] == 'post-quickpress-save-cont' ) { |
|
1215 | + } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
|
1216 | 1216 | $message = 7; |
1217 | 1217 | } else { |
1218 | 1218 | $message = 4; |
@@ -1220,11 +1220,11 @@ discard block |
||
1220 | 1220 | |
1221 | 1221 | //change the message if the post type is not viewable on the frontend |
1222 | 1222 | $this->_cpt_object = get_post_type_object($post->post_type); |
1223 | - $message = $message === 1 && !$this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1223 | + $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1224 | 1224 | |
1225 | - $query_args = array_merge( array( 'message' => $message ), $query_args ); |
|
1226 | - $this->_process_notices( $query_args, TRUE ); |
|
1227 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1225 | + $query_args = array_merge(array('message' => $message), $query_args); |
|
1226 | + $this->_process_notices($query_args, TRUE); |
|
1227 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | |
@@ -1256,10 +1256,10 @@ discard block |
||
1256 | 1256 | * @param array $messages the original messages array |
1257 | 1257 | * @return array the new messages array |
1258 | 1258 | */ |
1259 | - public function post_update_messages( $messages ) { |
|
1259 | + public function post_update_messages($messages) { |
|
1260 | 1260 | global $post; |
1261 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1262 | - $id = empty( $id ) && is_object( $post ) ? $post->ID : NULL; |
|
1261 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1262 | + $id = empty($id) && is_object($post) ? $post->ID : NULL; |
|
1263 | 1263 | |
1264 | 1264 | // $post_type = $post ? $post->post_type : false; |
1265 | 1265 | |
@@ -1272,9 +1272,9 @@ discard block |
||
1272 | 1272 | 0 => '', //Unused. Messages start at index 1. |
1273 | 1273 | |
1274 | 1274 | 1 => sprintf( |
1275 | - __( '%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1275 | + __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1276 | 1276 | $this->_cpt_object->labels->singular_name, |
1277 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1277 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1278 | 1278 | '</a>' |
1279 | 1279 | ), |
1280 | 1280 | |
@@ -1282,38 +1282,38 @@ discard block |
||
1282 | 1282 | |
1283 | 1283 | 3 => __('Custom field deleted.'), |
1284 | 1284 | |
1285 | - 4 => sprintf( __( '%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1285 | + 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1286 | 1286 | |
1287 | - 5 => isset( $_GET['revision'] ) ? sprintf( __('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title( (int) $_GET['revision'], FALSE ) ) : FALSE, |
|
1287 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], FALSE)) : FALSE, |
|
1288 | 1288 | |
1289 | 1289 | 6 => sprintf( |
1290 | - __( '%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1290 | + __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1291 | 1291 | $this->_cpt_object->labels->singular_name, |
1292 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1292 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1293 | 1293 | '</a>' |
1294 | 1294 | ), |
1295 | 1295 | |
1296 | - 7 => sprintf( __( '%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1296 | + 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1297 | 1297 | |
1298 | 1298 | 8 => sprintf( |
1299 | 1299 | __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
1300 | 1300 | $this->_cpt_object->labels->singular_name, |
1301 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) . '">', |
|
1301 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">', |
|
1302 | 1302 | '</a>' |
1303 | 1303 | ), |
1304 | 1304 | |
1305 | 1305 | 9 => sprintf( |
1306 | - __( '%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1306 | + __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1307 | 1307 | $this->_cpt_object->labels->singular_name, |
1308 | - '<strong>' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date )) . '</strong>', |
|
1309 | - '<a target="_blank" href="' . esc_url( get_permalink( $id )), |
|
1308 | + '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>', |
|
1309 | + '<a target="_blank" href="'.esc_url(get_permalink($id)), |
|
1310 | 1310 | '</a>' |
1311 | 1311 | ), |
1312 | 1312 | |
1313 | 1313 | 10 => sprintf( |
1314 | 1314 | __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
1315 | 1315 | $this->_cpt_object->labels->singular_name, |
1316 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) , |
|
1316 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
1317 | 1317 | '</a>' |
1318 | 1318 | ) |
1319 | 1319 | ); |
@@ -1340,24 +1340,24 @@ discard block |
||
1340 | 1340 | $post_type_object = $this->_cpt_object; |
1341 | 1341 | $title = $post_type_object->labels->add_new_item; |
1342 | 1342 | $editing = TRUE; |
1343 | - wp_enqueue_script( 'autosave' ); |
|
1344 | - $post = $post = get_default_post_to_edit( $this->_cpt_routes[$this->_req_action], TRUE ); |
|
1343 | + wp_enqueue_script('autosave'); |
|
1344 | + $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], TRUE); |
|
1345 | 1345 | $post_ID = $post->ID; |
1346 | 1346 | $is_IE = $is_IE; |
1347 | 1347 | |
1348 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1348 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1349 | 1349 | |
1350 | 1350 | //modify the default editor title field with default title. |
1351 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1351 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1352 | 1352 | |
1353 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1353 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | |
1357 | 1357 | |
1358 | 1358 | |
1359 | 1359 | public function add_new_admin_page_global() { |
1360 | - $admin_page = !empty( $this->_req_data['post'] ) ? 'post-php' : 'post-new-php'; |
|
1360 | + $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
|
1361 | 1361 | ?> |
1362 | 1362 | <script type="text/javascript"> |
1363 | 1363 | adminpage = '<?php echo $admin_page; ?>'; |
@@ -1379,16 +1379,16 @@ discard block |
||
1379 | 1379 | */ |
1380 | 1380 | protected function _edit_cpt_item() { |
1381 | 1381 | global $post, $title, $is_IE, $post_type, $post_type_object; |
1382 | - $post_id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1383 | - $post = !empty( $post_id ) ? get_post( $post_id, OBJECT, 'edit' ) : NULL; |
|
1382 | + $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1383 | + $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : NULL; |
|
1384 | 1384 | |
1385 | - if ( empty ( $post ) ) { |
|
1386 | - wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); |
|
1385 | + if (empty ($post)) { |
|
1386 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | - if ( ! empty( $_GET['get-post-lock'] ) ) { |
|
1390 | - wp_set_post_lock( $post_id ); |
|
1391 | - wp_redirect( get_edit_post_link( $post_id, 'url' ) ); |
|
1389 | + if ( ! empty($_GET['get-post-lock'])) { |
|
1390 | + wp_set_post_lock($post_id); |
|
1391 | + wp_redirect(get_edit_post_link($post_id, 'url')); |
|
1392 | 1392 | exit(); |
1393 | 1393 | } |
1394 | 1394 | |
@@ -1398,32 +1398,32 @@ discard block |
||
1398 | 1398 | $post_type = $this->_cpt_routes[$this->_req_action]; |
1399 | 1399 | $post_type_object = $this->_cpt_object; |
1400 | 1400 | |
1401 | - if ( ! wp_check_post_lock( $post->ID ) ) { |
|
1402 | - $active_post_lock = wp_set_post_lock( $post->ID ); |
|
1401 | + if ( ! wp_check_post_lock($post->ID)) { |
|
1402 | + $active_post_lock = wp_set_post_lock($post->ID); |
|
1403 | 1403 | //wp_enqueue_script('autosave'); |
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | $title = $this->_cpt_object->labels->edit_item; |
1407 | 1407 | |
1408 | - add_action('admin_footer', '_admin_notice_post_locked' ); |
|
1408 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
1409 | 1409 | |
1410 | - if ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && !isset( $this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']] ) ) { |
|
1411 | - $create_new_action = apply_filters( 'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this ); |
|
1410 | + if (isset($this->_cpt_routes[$this->_req_data['action']]) && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])) { |
|
1411 | + $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this); |
|
1412 | 1412 | |
1413 | - $post_new_file = EE_Admin_Page::add_query_args_and_nonce( array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php' ); |
|
1413 | + $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php'); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | - if ( post_type_supports($this->_cpt_routes[$this->_req_action], 'comments') ) { |
|
1416 | + if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
|
1417 | 1417 | wp_enqueue_script('admin-comments'); |
1418 | 1418 | enqueue_comment_hotkeys_js(); |
1419 | 1419 | } |
1420 | 1420 | |
1421 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1421 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1422 | 1422 | |
1423 | 1423 | //modify the default editor title field with default title. |
1424 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1424 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1425 | 1425 | |
1426 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1426 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1427 | 1427 | |
1428 | 1428 | } |
1429 | 1429 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | $gateway = $payment_method->type_obj()->get_gateway(); |
97 | 97 | if ( |
98 | 98 | $gateway instanceof EE_Offsite_Gateway |
99 | - && $gateway->handle_IPN_in_this_request( |
|
99 | + && $gateway->handle_IPN_in_this_request( |
|
100 | 100 | \EE_Registry::instance()->REQ->params(), |
101 | 101 | true |
102 | 102 | ) |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * EES_Espresso_Txn_Page |
4 | 4 | * |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return void |
28 | 28 | */ |
29 | 29 | public static function set_hooks() { |
30 | - add_action( 'wp_loaded', array( 'EES_Espresso_Txn_Page', 'set_definitions' ), 2 ); |
|
30 | + add_action('wp_loaded', array('EES_Espresso_Txn_Page', 'set_definitions'), 2); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @return void |
49 | 49 | */ |
50 | 50 | public static function set_definitions() { |
51 | - define( 'TXN_PAGE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
52 | - define( 'TXN_PAGE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
51 | + define('TXN_PAGE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
52 | + define('TXN_PAGE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -66,21 +66,21 @@ discard block |
||
66 | 66 | * @throws \Exception |
67 | 67 | * @throws \EE_Error |
68 | 68 | */ |
69 | - public function run( WP $WP ) { |
|
69 | + public function run(WP $WP) { |
|
70 | 70 | $this->_current_txn = null; |
71 | - if ( EE_Registry::instance()->REQ->is_set('e_reg_url_link' )){ |
|
71 | + if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
72 | 72 | /** @var EEM_Transaction $EEM_Transaction */ |
73 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
73 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
74 | 74 | $this->_current_txn = $EEM_Transaction->get_transaction_from_reg_url_link(); |
75 | 75 | } |
76 | - if ( $this->_current_txn instanceof EE_Transaction ) { |
|
76 | + if ($this->_current_txn instanceof EE_Transaction) { |
|
77 | 77 | $payment_method = null; |
78 | - $payment_method_slug = EE_Registry::instance()->REQ->get( 'ee_payment_method', null ); |
|
79 | - if( $payment_method_slug ) { |
|
80 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug( $payment_method_slug ); |
|
78 | + $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
79 | + if ($payment_method_slug) { |
|
80 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
81 | 81 | } |
82 | 82 | |
83 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->is_off_site() ) { |
|
83 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
84 | 84 | $gateway = $payment_method->type_obj()->get_gateway(); |
85 | 85 | if ( |
86 | 86 | $gateway instanceof EE_Offsite_Gateway |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | ) |
91 | 91 | ) { |
92 | 92 | /** @type EE_Payment_Processor $payment_processor */ |
93 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
94 | - $payment_processor->process_ipn( $_REQUEST, $this->_current_txn, $payment_method ); |
|
93 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
94 | + $payment_processor->process_ipn($_REQUEST, $this->_current_txn, $payment_method); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | //allow gateways to add a filter to stop rendering the page |
98 | - if( apply_filters( 'FHEE__EES_Espresso_Txn_Page__run__exit', FALSE ) ){ |
|
98 | + if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', FALSE)) { |
|
99 | 99 | exit; |
100 | 100 | } |
101 | 101 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param array $attributes |
113 | 113 | * @return string |
114 | 114 | */ |
115 | - public function process_shortcode( $attributes = array() ) { |
|
116 | - return __( 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso' ); |
|
115 | + public function process_shortcode($attributes = array()) { |
|
116 | + return __('This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | |
184 | 184 | |
185 | 185 | /** |
186 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even EE_Front_Controller's init phases have run |
|
187 | - * |
|
188 | - * @access public |
|
189 | - * @return void |
|
190 | - */ |
|
186 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even EE_Front_Controller's init phases have run |
|
187 | + * |
|
188 | + * @access public |
|
189 | + * @return void |
|
190 | + */ |
|
191 | 191 | public function init() { |
192 | 192 | EE_Admin::debug_log( __METHOD__ ); |
193 | 193 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | |
475 | 475 | |
476 | 476 | /** |
477 | - * admin_init |
|
478 | - * |
|
479 | - * @access public |
|
480 | - * @return void |
|
481 | - */ |
|
477 | + * admin_init |
|
478 | + * |
|
479 | + * @access public |
|
480 | + * @return void |
|
481 | + */ |
|
482 | 482 | public function admin_init() { |
483 | 483 | |
484 | 484 | /** |
@@ -631,11 +631,11 @@ discard block |
||
631 | 631 | |
632 | 632 | |
633 | 633 | /** |
634 | - * dismiss_persistent_admin_notice |
|
635 | - * |
|
636 | - * @access public |
|
637 | - * @return void |
|
638 | - */ |
|
634 | + * dismiss_persistent_admin_notice |
|
635 | + * |
|
636 | + * @access public |
|
637 | + * @return void |
|
638 | + */ |
|
639 | 639 | public function dismiss_ee_nag_notice_callback() { |
640 | 640 | EE_Error::dismiss_persistent_admin_notice(); |
641 | 641 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function instance() { |
42 | 42 | // check if class object is instantiated |
43 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
43 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
44 | 44 | self::$_instance = new self(); |
45 | 45 | } |
46 | 46 | return self::$_instance; |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | // define global EE_Admin constants |
58 | 58 | $this->_define_all_constants(); |
59 | 59 | // set autoloaders for our admin page classes based on included path information |
60 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
60 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
61 | 61 | // admin hooks |
62 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
62 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
63 | 63 | // load EE_Request_Handler early |
64 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
65 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
64 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
65 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
66 | 66 | // post shortcode tracking |
67 | 67 | add_action( |
68 | 68 | 'AHEE__EE_System__initialize_last', |
69 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin' ) |
|
69 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin') |
|
70 | 70 | ); |
71 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
72 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
73 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
74 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
75 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
76 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
77 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
78 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
71 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
72 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
73 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
74 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
75 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
76 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
77 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
78 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
79 | 79 | |
80 | 80 | //reset Environment config (we only do this on admin page loads); |
81 | 81 | EE_Registry::instance()->CFG->environment->recheck_values(); |
82 | 82 | |
83 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
83 | + do_action('AHEE__EE_Admin__loaded'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | private function _define_all_constants() { |
98 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
99 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
100 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
101 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
102 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' )); |
|
98 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
99 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
100 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
101 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
102 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | * @param string $plugin |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function filter_plugin_actions( $links, $plugin ) { |
|
115 | + public function filter_plugin_actions($links, $plugin) { |
|
116 | 116 | // set $main_file in stone |
117 | 117 | static $main_file; |
118 | 118 | // if $main_file is not set yet |
119 | - if ( ! $main_file ) { |
|
120 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
119 | + if ( ! $main_file) { |
|
120 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
121 | 121 | } |
122 | - if ( $plugin === $main_file ) { |
|
122 | + if ($plugin === $main_file) { |
|
123 | 123 | // compare current plugin to this one |
124 | - if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
125 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>'; |
|
126 | - array_unshift( $links, $maintenance_link ); |
|
124 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
125 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>'; |
|
126 | + array_unshift($links, $maintenance_link); |
|
127 | 127 | } else { |
128 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
129 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
128 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
129 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
130 | 130 | // add before other links |
131 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
131 | + array_unshift($links, $org_settings_link, $events_link); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | return $links; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function get_request() { |
146 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
147 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
146 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
147 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param array $admin_page_folder_names |
157 | 157 | * @return array |
158 | 158 | */ |
159 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
159 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
160 | 160 | return array( |
161 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
162 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
163 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
161 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
162 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
163 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -174,31 +174,31 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function init() { |
176 | 176 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
177 | - if ( EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
177 | + if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
178 | 178 | //ok so we want to enable the entire admin |
179 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
180 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
181 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
179 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
180 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
181 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
182 | 182 | //at a glance dashboard widget |
183 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 ); |
|
183 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
184 | 184 | //filter for get_edit_post_link used on comments for custom post types |
185 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 ); |
|
185 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
186 | 186 | } |
187 | 187 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
188 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
188 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
189 | 189 | try { |
190 | 190 | //this loads the controller for the admin pages which will setup routing etc |
191 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
192 | - } catch ( EE_Error $e ) { |
|
191 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
192 | + } catch (EE_Error $e) { |
|
193 | 193 | $e->get_error(); |
194 | 194 | } |
195 | 195 | } |
196 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
196 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
197 | 197 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
198 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
199 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
198 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
199 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
200 | 200 | //exclude EE critical pages from all nav menus and wp_list_pages |
201 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
201 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | * @param object $post_type WP post type object |
212 | 212 | * @return object WP post type object |
213 | 213 | */ |
214 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
214 | + public function remove_pages_from_nav_menu($post_type) { |
|
215 | 215 | //if this isn't the "pages" post type let's get out |
216 | - if ( $post_type->name !== 'page' ) { |
|
216 | + if ($post_type->name !== 'page') { |
|
217 | 217 | return $post_type; |
218 | 218 | } |
219 | 219 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -233,28 +233,28 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function enable_hidden_ee_nav_menu_metaboxes() { |
235 | 235 | global $wp_meta_boxes, $pagenow; |
236 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
236 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | $user = wp_get_current_user(); |
240 | 240 | //has this been done yet? |
241 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
241 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
246 | - $initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) ); |
|
245 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
246 | + $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page')); |
|
247 | 247 | |
248 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
249 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
250 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
251 | - unset( $hidden_meta_boxes[ $key ] ); |
|
248 | + if (is_array($hidden_meta_boxes)) { |
|
249 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
250 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
251 | + unset($hidden_meta_boxes[$key]); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
257 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
256 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
257 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return void |
274 | 274 | */ |
275 | 275 | public function register_custom_nav_menu_boxes() { |
276 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
276 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return string the (maybe) modified link |
291 | 291 | */ |
292 | - public function modify_edit_post_link( $link, $id ) { |
|
293 | - if ( ! $post = get_post( $id ) ){ |
|
292 | + public function modify_edit_post_link($link, $id) { |
|
293 | + if ( ! $post = get_post($id)) { |
|
294 | 294 | return $link; |
295 | 295 | } |
296 | - if ( $post->post_type === 'espresso_attendees' ) { |
|
296 | + if ($post->post_type === 'espresso_attendees') { |
|
297 | 297 | $query_args = array( |
298 | 298 | 'action' => 'edit_attendee', |
299 | 299 | 'post' => $id |
300 | 300 | ); |
301 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
301 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
302 | 302 | } |
303 | 303 | return $link; |
304 | 304 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | global $nav_menu_selected_id; |
311 | 311 | |
312 | 312 | $db_fields = false; |
313 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
313 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
314 | 314 | $current_tab = 'event-archives'; |
315 | 315 | |
316 | 316 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | ?> |
330 | 330 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
331 | 331 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
332 | - <li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
333 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
334 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
332 | + <li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
333 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
334 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
335 | 335 | </a> |
336 | 336 | </li> |
337 | 337 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | <?php */ ?> |
350 | 350 | |
351 | 351 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
352 | - echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
352 | + echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
353 | 353 | ?>"> |
354 | 354 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
355 | 355 | <?php |
356 | 356 | $pages = $this->_get_extra_nav_menu_pages_items(); |
357 | 357 | $args['walker'] = $walker; |
358 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
358 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
359 | 359 | ?> |
360 | 360 | </ul> |
361 | 361 | </div><!-- /.tabs-panel --> |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | <p class="button-controls"> |
364 | 364 | <span class="list-controls"> |
365 | 365 | <a href="<?php |
366 | - echo esc_url( add_query_arg( |
|
366 | + echo esc_url(add_query_arg( |
|
367 | 367 | array( |
368 | 368 | 'extra-nav-menu-pages-tab' => 'event-archives', |
369 | 369 | 'selectall' => 1, |
370 | 370 | ), |
371 | - remove_query_arg( $removed_args ) |
|
371 | + remove_query_arg($removed_args) |
|
372 | 372 | )); |
373 | 373 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
374 | 374 | </span> |
375 | 375 | |
376 | 376 | <span class="add-to-menu"> |
377 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" /> |
|
377 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" /> |
|
378 | 378 | <span class="spinner"></span> |
379 | 379 | </span> |
380 | 380 | </p> |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | private function _get_extra_nav_menu_pages_items() { |
396 | 396 | $menuitems[] = array( |
397 | 397 | 'title' => __('Event List', 'event_espresso'), |
398 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
398 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
399 | 399 | 'description' => __('Archive page for all events.', 'event_espresso') |
400 | 400 | ); |
401 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
401 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param $menu_item_values |
411 | 411 | * @return stdClass |
412 | 412 | */ |
413 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
413 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
414 | 414 | $menu_item = new stdClass(); |
415 | 415 | $keys = array( |
416 | 416 | 'ID' => 0, |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | 'xfn' => '' |
431 | 431 | ); |
432 | 432 | |
433 | - foreach ( $keys as $key => $value) { |
|
434 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
433 | + foreach ($keys as $key => $value) { |
|
434 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
435 | 435 | } |
436 | 436 | return $menu_item; |
437 | 437 | } |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * - check if doing post processing of one of EE CPTs |
471 | 471 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
472 | 472 | */ |
473 | - if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) { |
|
474 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
475 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
473 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
474 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
475 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
482 | 482 | */ |
483 | 483 | global $pagenow; |
484 | - if ( $pagenow === 'options-reading.php' ) { |
|
485 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
484 | + if ($pagenow === 'options-reading.php') { |
|
485 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | } |
@@ -494,25 +494,25 @@ discard block |
||
494 | 494 | * @param string $output Current output. |
495 | 495 | * @return string |
496 | 496 | */ |
497 | - public function modify_dropdown_pages( $output ) { |
|
497 | + public function modify_dropdown_pages($output) { |
|
498 | 498 | //get critical pages |
499 | 499 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
500 | 500 | |
501 | 501 | //split current output by line break for easier parsing. |
502 | - $split_output = explode( "\n", $output ); |
|
502 | + $split_output = explode("\n", $output); |
|
503 | 503 | |
504 | 504 | //loop through to remove any critical pages from the array. |
505 | - foreach ( $critical_pages as $page_id ) { |
|
506 | - $needle = 'value="' . $page_id . '"'; |
|
507 | - foreach( $split_output as $key => $haystack ) { |
|
508 | - if( strpos( $haystack, $needle ) !== false ) { |
|
509 | - unset( $split_output[$key] ); |
|
505 | + foreach ($critical_pages as $page_id) { |
|
506 | + $needle = 'value="'.$page_id.'"'; |
|
507 | + foreach ($split_output as $key => $haystack) { |
|
508 | + if (strpos($haystack, $needle) !== false) { |
|
509 | + unset($split_output[$key]); |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | 514 | //replace output with the new contents |
515 | - return implode( "\n", $split_output ); |
|
515 | + return implode("\n", $split_output); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -526,36 +526,36 @@ discard block |
||
526 | 526 | public function enqueue_admin_scripts() { |
527 | 527 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
528 | 528 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
529 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
529 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
530 | 530 | // register cookie script for future dependencies |
531 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
531 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
532 | 532 | // jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
533 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
533 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
534 | 534 | // register jQuery Validate |
535 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
535 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
536 | 536 | } |
537 | 537 | //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' ); |
538 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
538 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
539 | 539 | //joyride style |
540 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
541 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
542 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
540 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
541 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
542 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
543 | 543 | //joyride JS |
544 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
544 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
545 | 545 | // wanna go for a joyride? |
546 | 546 | wp_enqueue_style('ee-joyride-css'); |
547 | 547 | wp_enqueue_script('jquery-joyride'); |
548 | 548 | } |
549 | 549 | //qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' ); |
550 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
550 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
551 | 551 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
552 | 552 | } |
553 | 553 | //accounting.js library |
554 | 554 | // @link http://josscrowcroft.github.io/accounting.js/ |
555 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
556 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
557 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
558 | - wp_enqueue_script( 'ee-accounting' ); |
|
555 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
556 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
557 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
558 | + wp_enqueue_script('ee-accounting'); |
|
559 | 559 | // array of settings to get converted to JSON array via wp_localize_script |
560 | 560 | $currency_config = array( |
561 | 561 | 'currency' => array( |
@@ -602,11 +602,11 @@ discard block |
||
602 | 602 | public function get_persistent_admin_notices() { |
603 | 603 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
604 | 604 | $args = array( |
605 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
606 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
605 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
606 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
607 | 607 | ); |
608 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
609 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
608 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
609 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -627,26 +627,26 @@ discard block |
||
627 | 627 | * @param $elements |
628 | 628 | * @return array |
629 | 629 | */ |
630 | - public function dashboard_glance_items( $elements ) { |
|
630 | + public function dashboard_glance_items($elements) { |
|
631 | 631 | $events = EEM_Event::instance()->count(); |
632 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
633 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
632 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
633 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
634 | 634 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
635 | 635 | $registrations = EEM_Registration::instance()->count( |
636 | 636 | array( |
637 | 637 | array( |
638 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
638 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
639 | 639 | ) |
640 | 640 | ) |
641 | 641 | ); |
642 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
643 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
642 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
643 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
644 | 644 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
645 | 645 | |
646 | - $items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
646 | + $items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
647 | 647 | |
648 | - foreach ( $items as $type => $item_properties ) { |
|
649 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
648 | + foreach ($items as $type => $item_properties) { |
|
649 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
650 | 650 | } |
651 | 651 | return $elements; |
652 | 652 | } |
@@ -663,31 +663,31 @@ discard block |
||
663 | 663 | * @throws EE_Error |
664 | 664 | * @return string |
665 | 665 | */ |
666 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
666 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
667 | 667 | // check for date_format or time_format |
668 | - switch ( $option ) { |
|
668 | + switch ($option) { |
|
669 | 669 | case 'date_format' : |
670 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
670 | + $date_time_format = $value.' '.get_option('time_format'); |
|
671 | 671 | break; |
672 | 672 | case 'time_format' : |
673 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
673 | + $date_time_format = get_option('date_format').' '.$value; |
|
674 | 674 | break; |
675 | 675 | default : |
676 | 676 | $date_time_format = FALSE; |
677 | 677 | } |
678 | 678 | // do we have a date_time format to check ? |
679 | - if ( $date_time_format ) { |
|
680 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
679 | + if ($date_time_format) { |
|
680 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
681 | 681 | |
682 | - if ( is_array( $error_msg ) ) { |
|
683 | - $msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format ) . '</p><p><ul>'; |
|
682 | + if (is_array($error_msg)) { |
|
683 | + $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>'; |
|
684 | 684 | |
685 | 685 | |
686 | - foreach ( $error_msg as $error ) { |
|
687 | - $msg .= '<li>' . $error . '</li>'; |
|
686 | + foreach ($error_msg as $error) { |
|
687 | + $msg .= '<li>'.$error.'</li>'; |
|
688 | 688 | } |
689 | 689 | |
690 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
690 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
691 | 691 | |
692 | 692 | // trigger WP settings error |
693 | 693 | add_settings_error( |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | ); |
698 | 698 | |
699 | 699 | // set format to something valid |
700 | - switch ( $option ) { |
|
700 | + switch ($option) { |
|
701 | 701 | case 'date_format' : |
702 | 702 | $value = 'F j, Y'; |
703 | 703 | break; |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | * @param $content |
720 | 720 | * @return string |
721 | 721 | */ |
722 | - public function its_eSpresso( $content ) { |
|
723 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
722 | + public function its_eSpresso($content) { |
|
723 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -733,9 +733,9 @@ discard block |
||
733 | 733 | */ |
734 | 734 | public function espresso_admin_footer() { |
735 | 735 | return sprintf( |
736 | - __( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ), |
|
736 | + __('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'), |
|
737 | 737 | '<a href="https://eventespresso.com/" title="', |
738 | - '">' . EVENT_ESPRESSO_POWERED_BY . '</a>' |
|
738 | + '">'.EVENT_ESPRESSO_POWERED_BY.'</a>' |
|
739 | 739 | ); |
740 | 740 | } |
741 | 741 | |
@@ -755,12 +755,12 @@ discard block |
||
755 | 755 | * @param array $config |
756 | 756 | * @return void |
757 | 757 | */ |
758 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
759 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' ); |
|
760 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) { |
|
758 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
759 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3'); |
|
760 | + if (class_exists('EE_Register_Admin_Page')) { |
|
761 | 761 | $config['page_path'] = $page_path; |
762 | 762 | } |
763 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
763 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
764 | 764 | |
765 | 765 | } |
766 | 766 |
@@ -606,9 +606,9 @@ |
||
606 | 606 | // first check if event is active. |
607 | 607 | if ( |
608 | 608 | $orig_status === EEM_Event::cancelled |
609 | - || $orig_status === EEM_Event::postponed |
|
610 | - || $event->is_expired() |
|
611 | - || $event->is_inactive() |
|
609 | + || $orig_status === EEM_Event::postponed |
|
610 | + || $event->is_expired() |
|
611 | + || $event->is_inactive() |
|
612 | 612 | ) { |
613 | 613 | return; |
614 | 614 | } |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -1484,10 +1485,11 @@ discard block |
||
1484 | 1485 | //get the earliest datetime (if present); |
1485 | 1486 | $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
1486 | 1487 | |
1487 | - if ( !empty( $earliest_dtt ) ) |
|
1488 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1489 | - else |
|
1490 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1488 | + if ( !empty( $earliest_dtt ) ) { |
|
1489 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1490 | + } else { |
|
1491 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1492 | + } |
|
1491 | 1493 | } |
1492 | 1494 | |
1493 | 1495 | $template_args = array_merge( $template_args, $price_args ); |
@@ -1725,8 +1727,9 @@ discard block |
||
1725 | 1727 | } |
1726 | 1728 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1727 | 1729 | |
1728 | - if ( $redirect_after ) |
|
1729 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1730 | + if ( $redirect_after ) { |
|
1731 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1732 | + } |
|
1730 | 1733 | } |
1731 | 1734 | |
1732 | 1735 | /** |
@@ -1853,8 +1856,9 @@ discard block |
||
1853 | 1856 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1854 | 1857 | } |
1855 | 1858 | |
1856 | - if ( $redirect_after ) |
|
1857 | - $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
|
1859 | + if ( $redirect_after ) { |
|
1860 | + $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
|
1861 | + } |
|
1858 | 1862 | } |
1859 | 1863 | |
1860 | 1864 | /** |
@@ -2091,8 +2095,10 @@ discard block |
||
2091 | 2095 | * @return void |
2092 | 2096 | */ |
2093 | 2097 | private function _set_category_object() { |
2094 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2095 | - return; //already have the category object so get out. |
|
2098 | + if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) { |
|
2099 | + return; |
|
2100 | + } |
|
2101 | + //already have the category object so get out. |
|
2096 | 2102 | |
2097 | 2103 | //set default category object |
2098 | 2104 | $this->_set_empty_category_object(); |
@@ -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 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->_cpt_edit_routes = array( |
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
69 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function _ajax_hooks() { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | 'edit' => __('Update Event', 'event_espresso'), |
93 | 93 | 'add_category' => __('Save New Category', 'event_espresso'), |
94 | 94 | 'edit_category' => __('Update Category', 'event_espresso'), |
95 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
95 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | //load field generator helper |
103 | 103 | |
104 | 104 | //is there a evt_id in the request? |
105 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
106 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
105 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
106 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
107 | 107 | |
108 | 108 | |
109 | 109 | $this->_page_routes = array( |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | 'help_tour' => array( |
318 | 318 | 'Event_Editor_Help_Tour' |
319 | 319 | ), |
320 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
320 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
321 | 321 | 'require_nonce' => FALSE |
322 | 322 | ), |
323 | 323 | 'edit' => array( |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | /*'help_tour' => array( |
374 | 374 | 'Event_Edit_Help_Tour' |
375 | 375 | ),*/ |
376 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
376 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
377 | 377 | 'require_nonce' => FALSE |
378 | 378 | ), |
379 | 379 | 'default_event_settings' => array( |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | 'filename' => 'events_default_settings_status' |
396 | 396 | ) |
397 | 397 | ), |
398 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
398 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
399 | 399 | 'require_nonce' => FALSE |
400 | 400 | ), |
401 | 401 | //template settings |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | 'filename' => 'general_settings_templates' |
412 | 412 | ) |
413 | 413 | ), |
414 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
414 | + 'help_tour' => array('Templates_Help_Tour'), |
|
415 | 415 | 'require_nonce' => FALSE |
416 | 416 | ), |
417 | 417 | //event category stuff |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'label' => __('Edit Category', 'event_espresso'), |
436 | 436 | 'order' => 15, |
437 | 437 | 'persistent' => FALSE, |
438 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
438 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
439 | 439 | ), |
440 | 440 | 'help_tabs' => array( |
441 | 441 | 'edit_category_help_tab' => array( |
@@ -505,14 +505,14 @@ discard block |
||
505 | 505 | |
506 | 506 | public function load_scripts_styles() { |
507 | 507 | |
508 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
509 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
508 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
509 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
510 | 510 | wp_enqueue_style('events-admin-css'); |
511 | 511 | wp_enqueue_style('ee-cat-admin'); |
512 | 512 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
513 | 513 | //registers for all views |
514 | 514 | //scripts |
515 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
515 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | public function load_scripts_styles_edit() { |
531 | 531 | //styles |
532 | 532 | wp_enqueue_style('espresso-ui-theme'); |
533 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
533 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
534 | 534 | wp_enqueue_style('event-editor-css'); |
535 | 535 | |
536 | 536 | //scripts |
537 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
537 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
538 | 538 | wp_enqueue_script('event-datetime-metabox'); |
539 | 539 | |
540 | 540 | } |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | |
571 | 571 | public function admin_init() { |
572 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
572 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function verify_event_edit($event = NULL) { |
592 | 592 | // no event? |
593 | - if ( empty( $event )) { |
|
593 | + if (empty($event)) { |
|
594 | 594 | // set event |
595 | 595 | $event = $this->_cpt_model_obj; |
596 | 596 | } |
597 | 597 | // STILL no event? |
598 | - if ( empty ( $event )) { |
|
598 | + if (empty ($event)) { |
|
599 | 599 | return; |
600 | 600 | } |
601 | 601 | $orig_status = $event->status(); |
@@ -609,27 +609,27 @@ discard block |
||
609 | 609 | return; |
610 | 610 | } |
611 | 611 | //made it here so it IS active... next check that any of the tickets are sold. |
612 | - if ( $event->is_sold_out( true ) ) { |
|
613 | - if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) { |
|
612 | + if ($event->is_sold_out(true)) { |
|
613 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
614 | 614 | EE_Error::add_attention( |
615 | 615 | sprintf( |
616 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
617 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
616 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
617 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
618 | 618 | ) |
619 | 619 | ); |
620 | 620 | } |
621 | 621 | return; |
622 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
622 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
623 | 623 | EE_Error::add_attention( |
624 | 624 | sprintf( |
625 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
626 | - 'event_espresso' ), |
|
627 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
625 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
626 | + 'event_espresso'), |
|
627 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
628 | 628 | ) |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
632 | - if ( ! $event->tickets_on_sale() ) { |
|
632 | + if ( ! $event->tickets_on_sale()) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | //made it here so show warning |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | */ |
649 | 649 | protected function _edit_event_warning() { |
650 | 650 | // we don't want to add warnings during these requests |
651 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) { |
|
651 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
652 | 652 | return; |
653 | 653 | } |
654 | 654 | EE_Error::add_attention( |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | ), |
680 | 680 | ); |
681 | 681 | |
682 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
682 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
683 | 683 | $this->_views['trash'] = array( |
684 | 684 | 'slug' => 'trash', |
685 | 685 | 'label' => __('Trash', 'event_espresso'), |
@@ -709,39 +709,39 @@ discard block |
||
709 | 709 | 'desc' => __('View Registrations for Event', 'event_espresso') |
710 | 710 | ) |
711 | 711 | ); |
712 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
712 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
713 | 713 | $statuses = array( |
714 | 714 | 'sold_out_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'active_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'upcoming_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'postponed_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'cancelled_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
733 | 733 | ), |
734 | 734 | 'expired_status' => array( |
735 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
736 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
735 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
736 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
737 | 737 | ), |
738 | 738 | 'inactive_status' => array( |
739 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
740 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
739 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
740 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
741 | 741 | ) |
742 | 742 | ); |
743 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
744 | - return array_merge( $items, $statuses ); |
|
743 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
744 | + return array_merge($items, $statuses); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * @return EEM_Event |
754 | 754 | */ |
755 | 755 | private function _event_model() { |
756 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
757 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
756 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
757 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
758 | 758 | } |
759 | 759 | return $this->_event_model; |
760 | 760 | } |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | * @param string $new_slug what the slug is |
774 | 774 | * @return string The new html string for the permalink area |
775 | 775 | */ |
776 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
776 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
777 | 777 | //make sure this is only when editing |
778 | - if ( !empty( $id ) ) { |
|
779 | - $post = get_post( $id ); |
|
780 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
781 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">'; |
|
778 | + if ( ! empty($id)) { |
|
779 | + $post = get_post($id); |
|
780 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
781 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">'; |
|
782 | 782 | } |
783 | 783 | return $return; |
784 | 784 | } |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | * @return string html for generated table |
795 | 795 | */ |
796 | 796 | protected function _events_overview_list_table() { |
797 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
798 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
797 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
798 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
799 | 799 | $this->_display_legend($this->_event_legend_items()); |
800 | 800 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
801 | 801 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -813,51 +813,51 @@ discard block |
||
813 | 813 | |
814 | 814 | |
815 | 815 | |
816 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
816 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
817 | 817 | |
818 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
818 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
819 | 819 | //getout we're not processing an event save. |
820 | 820 | return; |
821 | 821 | } |
822 | 822 | |
823 | 823 | $event_values = array( |
824 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
825 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
824 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
825 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
826 | 826 | 'EVT_additional_limit' => min( |
827 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
828 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
829 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
830 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
831 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
832 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
833 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
834 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
827 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
828 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
829 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
830 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
831 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
832 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
833 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
834 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | //update event |
838 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
838 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
839 | 839 | |
840 | 840 | |
841 | 841 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
842 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
843 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
842 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
843 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
844 | 844 | |
845 | 845 | |
846 | 846 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
847 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
847 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
848 | 848 | |
849 | 849 | $att_success = TRUE; |
850 | 850 | |
851 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
852 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
853 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
851 | + foreach ($event_update_callbacks as $e_callback) { |
|
852 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
853 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | //any errors? |
857 | - if ( $success && FALSE === $att_success ) { |
|
858 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
859 | - } else if ( $success === FALSE ) { |
|
860 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
857 | + if ($success && FALSE === $att_success) { |
|
858 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
859 | + } else if ($success === FALSE) { |
|
860 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
@@ -867,14 +867,14 @@ discard block |
||
867 | 867 | /** |
868 | 868 | * @see parent::restore_item() |
869 | 869 | */ |
870 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
870 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
871 | 871 | //copy existing event meta to new post |
872 | 872 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
873 | - if ( $post_evt instanceof EE_Event ) { |
|
873 | + if ($post_evt instanceof EE_Event) { |
|
874 | 874 | //meta revision restore |
875 | - $post_evt->restore_revision( $revision_id ); |
|
875 | + $post_evt->restore_revision($revision_id); |
|
876 | 876 | //related objs restore |
877 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
877 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -887,52 +887,52 @@ discard block |
||
887 | 887 | * @param array $data The request data from the form |
888 | 888 | * @return bool Success or fail. |
889 | 889 | */ |
890 | - protected function _default_venue_update( $evtobj, $data ) { |
|
891 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
890 | + protected function _default_venue_update($evtobj, $data) { |
|
891 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
892 | 892 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
893 | 893 | $rows_affected = NULL; |
894 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
894 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
895 | 895 | |
896 | 896 | // very important. If we don't have a venue name... |
897 | 897 | // then we'll get out because not necessary to create empty venue |
898 | - if ( empty( $data['venue_title'] ) ) { |
|
898 | + if (empty($data['venue_title'])) { |
|
899 | 899 | return false; |
900 | 900 | } |
901 | 901 | |
902 | 902 | $venue_array = array( |
903 | 903 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
904 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
905 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
906 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
907 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
908 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
909 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
910 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
911 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
912 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
913 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
914 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
915 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
916 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
917 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
918 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
919 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
904 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
905 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
906 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
907 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
908 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
909 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
910 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
911 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
912 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
913 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
914 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
915 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
916 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
917 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
918 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
919 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
920 | 920 | 'status' => 'publish' |
921 | 921 | ); |
922 | 922 | |
923 | 923 | |
924 | 924 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
925 | - if ( !empty( $venue_id ) ) { |
|
926 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
927 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
925 | + if ( ! empty($venue_id)) { |
|
926 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
927 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
928 | 928 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
929 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
929 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
930 | 930 | return $rows_affected > 0 ? TRUE : FALSE; |
931 | 931 | } else { |
932 | 932 | //we insert the venue |
933 | - $venue_id = $venue_model->insert( $venue_array ); |
|
934 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
935 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
933 | + $venue_id = $venue_model->insert($venue_array); |
|
934 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
935 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
936 | 936 | } |
937 | 937 | //when we have the ancestor come in it's already been handled by the revision save. |
938 | 938 | } |
@@ -946,54 +946,54 @@ discard block |
||
946 | 946 | * @param array $data The request data from the form |
947 | 947 | * @return bool success or fail |
948 | 948 | */ |
949 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
949 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
950 | 950 | $success = true; |
951 | 951 | $saved_dtt = null; |
952 | 952 | $saved_tickets = array(); |
953 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
953 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
954 | 954 | |
955 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
955 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
956 | 956 | //trim all values to ensure any excess whitespace is removed. |
957 | - $dtt = array_map( 'trim', $dtt ); |
|
958 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
957 | + $dtt = array_map('trim', $dtt); |
|
958 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
959 | 959 | $datetime_values = array( |
960 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
960 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
961 | 961 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
962 | 962 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
963 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
963 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
964 | 964 | 'DTT_order' => $row, |
965 | 965 | ); |
966 | 966 | |
967 | 967 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
968 | 968 | |
969 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
970 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
971 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
972 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
973 | - foreach ( $datetime_values as $field => $value ) { |
|
974 | - $DTM->set( $field, $value ); |
|
969 | + if ( ! empty($dtt['DTT_ID'])) { |
|
970 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
971 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
972 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
973 | + foreach ($datetime_values as $field => $value) { |
|
974 | + $DTM->set($field, $value); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
978 | 978 | $saved_dtts[$DTM->ID()] = $DTM; |
979 | 979 | } else { |
980 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
981 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
982 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
983 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
984 | - foreach ( $datetime_values as $field => $value ) { |
|
985 | - $DTM->set( $field, $value ); |
|
980 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
981 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
982 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
983 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
984 | + foreach ($datetime_values as $field => $value) { |
|
985 | + $DTM->set($field, $value); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | $DTM->save(); |
989 | 989 | |
990 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
990 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
991 | 991 | |
992 | 992 | //load DTT helper |
993 | 993 | |
994 | 994 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
995 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
996 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
995 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
996 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
997 | 997 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
998 | 998 | $DTT->save(); |
999 | 999 | } |
@@ -1001,45 +1001,45 @@ discard block |
||
1001 | 1001 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
1002 | 1002 | $saved_dtt = $DTT; |
1003 | 1003 | |
1004 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
1004 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | //no dtts get deleted so we don't do any of that logic here. |
1008 | 1008 | //update tickets next |
1009 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1010 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1011 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1009 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1010 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1011 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1012 | 1012 | $update_prices = false; |
1013 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1013 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1014 | 1014 | |
1015 | 1015 | // trim inputs to ensure any excess whitespace is removed. |
1016 | - $tkt = array_map( 'trim', $tkt ); |
|
1016 | + $tkt = array_map('trim', $tkt); |
|
1017 | 1017 | |
1018 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1018 | + if (empty($tkt['TKT_start_date'])) { |
|
1019 | 1019 | //let's use now in the set timezone. |
1020 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1021 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1020 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1021 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1024 | + if (empty($tkt['TKT_end_date'])) { |
|
1025 | 1025 | //use the start date of the first datetime |
1026 | 1026 | $dtt = $evtobj->first_datetime(); |
1027 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1027 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $TKT_values = array( |
1031 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1032 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1033 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1034 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1031 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1032 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1033 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1034 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1035 | 1035 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1036 | 1036 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1037 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1038 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1039 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1040 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1037 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1038 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1039 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1040 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1041 | 1041 | 'TKT_row' => $row, |
1042 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1042 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1043 | 1043 | 'TKT_price' => $ticket_price |
1044 | 1044 | ); |
1045 | 1045 | |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | |
1049 | 1049 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1050 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1050 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1051 | 1051 | $TKT_values['TKT_ID'] = 0; |
1052 | 1052 | $TKT_values['TKT_is_default'] = 0; |
1053 | 1053 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1058,58 +1058,58 @@ discard block |
||
1058 | 1058 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1059 | 1059 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1060 | 1060 | |
1061 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1062 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1063 | - if ( $TKT instanceof EE_Ticket ) { |
|
1064 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1061 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1062 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1063 | + if ($TKT instanceof EE_Ticket) { |
|
1064 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1065 | 1065 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1066 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1067 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1068 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1066 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1067 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1068 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1069 | 1069 | //set new values |
1070 | - foreach ( $TKT_values as $field => $value ) { |
|
1071 | - if ( $field == 'TKT_qty' ) { |
|
1072 | - $TKT->set_qty( $value ); |
|
1070 | + foreach ($TKT_values as $field => $value) { |
|
1071 | + if ($field == 'TKT_qty') { |
|
1072 | + $TKT->set_qty($value); |
|
1073 | 1073 | } else { |
1074 | - $TKT->set( $field, $value ); |
|
1074 | + $TKT->set($field, $value); |
|
1075 | 1075 | } |
1076 | 1076 | } |
1077 | 1077 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1078 | - if ( $create_new_TKT ) { |
|
1078 | + if ($create_new_TKT) { |
|
1079 | 1079 | //archive the old ticket first |
1080 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1080 | + $TKT->set('TKT_deleted', 1); |
|
1081 | 1081 | $TKT->save(); |
1082 | 1082 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1083 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1083 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1084 | 1084 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1085 | 1085 | $TKT = clone $TKT; |
1086 | - $TKT->set( 'TKT_ID', 0 ); |
|
1087 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1088 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1089 | - $TKT->set( 'TKT_sold', 0 ); |
|
1086 | + $TKT->set('TKT_ID', 0); |
|
1087 | + $TKT->set('TKT_deleted', 0); |
|
1088 | + $TKT->set('TKT_price', $ticket_price); |
|
1089 | + $TKT->set('TKT_sold', 0); |
|
1090 | 1090 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1091 | 1091 | $update_prices = true; |
1092 | 1092 | } |
1093 | 1093 | //make sure price is set if it hasn't been already |
1094 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1094 | + $TKT->set('TKT_price', $ticket_price); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | } else { |
1098 | 1098 | //no TKT_id so a new TKT |
1099 | 1099 | $TKT_values['TKT_price'] = $ticket_price; |
1100 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1101 | - if ( $TKT instanceof EE_Ticket ) { |
|
1100 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1101 | + if ($TKT instanceof EE_Ticket) { |
|
1102 | 1102 | //need to reset values to properly account for the date formats |
1103 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1104 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1105 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1103 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1104 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1105 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1106 | 1106 | |
1107 | 1107 | //set new values |
1108 | - foreach ( $TKT_values as $field => $value ) { |
|
1109 | - if ( $field == 'TKT_qty' ) { |
|
1110 | - $TKT->set_qty( $value ); |
|
1108 | + foreach ($TKT_values as $field => $value) { |
|
1109 | + if ($field == 'TKT_qty') { |
|
1110 | + $TKT->set_qty($value); |
|
1111 | 1111 | } else { |
1112 | - $TKT->set( $field, $value ); |
|
1112 | + $TKT->set($field, $value); |
|
1113 | 1113 | } |
1114 | 1114 | } |
1115 | 1115 | |
@@ -1117,31 +1117,31 @@ discard block |
||
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | // cap ticket qty by datetime reg limits |
1120 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1120 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1121 | 1121 | //update ticket. |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | |
1124 | 1124 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1125 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1126 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1125 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1126 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1127 | 1127 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1128 | 1128 | $TKT->save(); |
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | //initially let's add the ticket to the dtt |
1132 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1132 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1133 | 1133 | |
1134 | 1134 | $saved_tickets[$TKT->ID()] = $TKT; |
1135 | 1135 | |
1136 | 1136 | //add prices to ticket |
1137 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1137 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1138 | 1138 | } |
1139 | 1139 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1140 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1141 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1140 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1141 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1142 | 1142 | |
1143 | - foreach ( $tickets_removed as $id ) { |
|
1144 | - $id = absint( $id ); |
|
1143 | + foreach ($tickets_removed as $id) { |
|
1144 | + $id = absint($id); |
|
1145 | 1145 | |
1146 | 1146 | //get the ticket for this id |
1147 | 1147 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1150 | 1150 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1151 | 1151 | |
1152 | - foreach( $dtts as $dtt ) { |
|
1152 | + foreach ($dtts as $dtt) { |
|
1153 | 1153 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1154 | 1154 | } |
1155 | 1155 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1161 | 1161 | $tkt_to_remove->delete_permanently(); |
1162 | 1162 | } |
1163 | - return array( $saved_dtt, $saved_tickets ); |
|
1163 | + return array($saved_dtt, $saved_tickets); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1175,31 +1175,31 @@ discard block |
||
1175 | 1175 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1176 | 1176 | * @return void |
1177 | 1177 | */ |
1178 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1179 | - foreach ( $prices as $row => $prc ) { |
|
1178 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1179 | + foreach ($prices as $row => $prc) { |
|
1180 | 1180 | $PRC_values = array( |
1181 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1182 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1183 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1184 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1185 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1181 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1182 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1183 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1184 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1185 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1186 | 1186 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1187 | 1187 | 'PRC_order' => $row |
1188 | 1188 | ); |
1189 | 1189 | |
1190 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1190 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1191 | 1191 | $PRC_values['PRC_ID'] = 0; |
1192 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1192 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1193 | 1193 | } else { |
1194 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1194 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1195 | 1195 | //update this price with new values |
1196 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1197 | - $PRC->set( $field, $newprc ); |
|
1196 | + foreach ($PRC_values as $field => $newprc) { |
|
1197 | + $PRC->set($field, $newprc); |
|
1198 | 1198 | } |
1199 | 1199 | $PRC->save(); |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1202 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1203 | 1203 | } |
1204 | 1204 | } |
1205 | 1205 | |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | //load formatter helper |
1238 | 1238 | |
1239 | 1239 | //args for getting related registrations |
1240 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1241 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1242 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1240 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1241 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1242 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1243 | 1243 | |
1244 | 1244 | |
1245 | 1245 | // publish box |
@@ -1268,9 +1268,9 @@ discard block |
||
1268 | 1268 | ), |
1269 | 1269 | REG_ADMIN_URL |
1270 | 1270 | ), |
1271 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1272 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1273 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1271 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1272 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1273 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1274 | 1274 | 'misc_pub_section_class' => apply_filters( |
1275 | 1275 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1276 | 1276 | 'misc-pub-section' |
@@ -1289,9 +1289,9 @@ discard block |
||
1289 | 1289 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1290 | 1290 | $this->_cpt_model_obj |
1291 | 1291 | ); |
1292 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1292 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1293 | 1293 | // load template |
1294 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1294 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | |
@@ -1323,16 +1323,16 @@ discard block |
||
1323 | 1323 | $this->verify_cpt_object(); |
1324 | 1324 | add_meta_box( |
1325 | 1325 | 'espresso_event_editor_tickets', |
1326 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1327 | - array( $this, 'ticket_metabox' ), |
|
1326 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1327 | + array($this, 'ticket_metabox'), |
|
1328 | 1328 | $this->page_slug, |
1329 | 1329 | 'normal', |
1330 | 1330 | 'high' |
1331 | 1331 | ); |
1332 | 1332 | add_meta_box( |
1333 | 1333 | 'espresso_event_editor_event_options', |
1334 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1335 | - array( $this, 'registration_options_meta_box' ), |
|
1334 | + __('Event Registration Options', 'event_espresso'), |
|
1335 | + array($this, 'registration_options_meta_box'), |
|
1336 | 1336 | $this->page_slug, |
1337 | 1337 | 'side', |
1338 | 1338 | 'default' |
@@ -1362,36 +1362,36 @@ discard block |
||
1362 | 1362 | 'disabled' => '' |
1363 | 1363 | ); |
1364 | 1364 | |
1365 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1365 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1366 | 1366 | |
1367 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1367 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1368 | 1368 | |
1369 | 1369 | /** |
1370 | 1370 | * 1. Start with retrieving Datetimes |
1371 | 1371 | * 2. Fore each datetime get related tickets |
1372 | 1372 | * 3. For each ticket get related prices |
1373 | 1373 | */ |
1374 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1374 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1375 | 1375 | /** @type EE_Datetime $first_datetime */ |
1376 | - $first_datetime = reset( $times ); |
|
1376 | + $first_datetime = reset($times); |
|
1377 | 1377 | //do we get related tickets? |
1378 | - if ( $first_datetime instanceof EE_Datetime |
|
1379 | - && $first_datetime->ID() !== 0 ) { |
|
1378 | + if ($first_datetime instanceof EE_Datetime |
|
1379 | + && $first_datetime->ID() !== 0) { |
|
1380 | 1380 | $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
1381 | 1381 | $template_args['time'] = $first_datetime; |
1382 | 1382 | $related_tickets = $first_datetime->tickets( |
1383 | 1383 | array( |
1384 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1384 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1385 | 1385 | 'default_where_conditions' => 'none' |
1386 | 1386 | ) |
1387 | 1387 | ); |
1388 | 1388 | |
1389 | - if ( !empty($related_tickets) ) { |
|
1389 | + if ( ! empty($related_tickets)) { |
|
1390 | 1390 | $template_args['total_ticket_rows'] = count($related_tickets); |
1391 | 1391 | $row = 0; |
1392 | - foreach ( $related_tickets as $ticket ) { |
|
1392 | + foreach ($related_tickets as $ticket) { |
|
1393 | 1393 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1394 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1394 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1395 | 1395 | |
1396 | 1396 | $row++; |
1397 | 1397 | } |
@@ -1399,13 +1399,13 @@ discard block |
||
1399 | 1399 | $template_args['total_ticket_rows'] = 1; |
1400 | 1400 | /** @type EE_Ticket $ticket */ |
1401 | 1401 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1402 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1402 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1403 | 1403 | } |
1404 | 1404 | } else { |
1405 | 1405 | $template_args['time'] = $times[0]; |
1406 | 1406 | /** @type EE_Ticket $ticket */ |
1407 | 1407 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1408 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1408 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1409 | 1409 | // NOTE: we're just sending the first default row |
1410 | 1410 | // (decaf can't manage default tickets so this should be sufficient); |
1411 | 1411 | } |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1415 | 1415 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1416 | 1416 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1417 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1418 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1417 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1418 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1419 | 1419 | EEH_Template::display_template($template, $template_args); |
1420 | 1420 | } |
1421 | 1421 | |
@@ -1430,21 +1430,21 @@ discard block |
||
1430 | 1430 | * @param int $row |
1431 | 1431 | * @return string generated html for the ticket row. |
1432 | 1432 | */ |
1433 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1433 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1434 | 1434 | $template_args = array( |
1435 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1436 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1435 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1436 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1437 | 1437 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1438 | 1438 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1439 | 1439 | 'TKT_name' => $ticket->get('TKT_name'), |
1440 | 1440 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1441 | 1441 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1442 | 1442 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1443 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1443 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1444 | 1444 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1445 | 1445 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1446 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1447 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1446 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1447 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1448 | 1448 | ); |
1449 | 1449 | |
1450 | 1450 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1460,23 +1460,23 @@ discard block |
||
1460 | 1460 | |
1461 | 1461 | //make sure we have default start and end dates if skeleton |
1462 | 1462 | //handle rows that should NOT be empty |
1463 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1463 | + if (empty($template_args['TKT_start_date'])) { |
|
1464 | 1464 | //if empty then the start date will be now. |
1465 | 1465 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1466 | 1466 | } |
1467 | 1467 | |
1468 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1468 | + if (empty($template_args['TKT_end_date'])) { |
|
1469 | 1469 | //get the earliest datetime (if present); |
1470 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1470 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1471 | 1471 | |
1472 | - if ( !empty( $earliest_dtt ) ) |
|
1472 | + if ( ! empty($earliest_dtt)) |
|
1473 | 1473 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1474 | 1474 | else |
1475 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1475 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | - $template_args = array_merge( $template_args, $price_args ); |
|
1479 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1478 | + $template_args = array_merge($template_args, $price_args); |
|
1479 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1480 | 1480 | return EEH_Template::display_template($template, $template_args, TRUE); |
1481 | 1481 | } |
1482 | 1482 | |
@@ -1505,8 +1505,8 @@ discard block |
||
1505 | 1505 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1506 | 1506 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1507 | 1507 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1508 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1509 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1508 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1509 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1510 | 1510 | EEH_Template::display_template($templatepath, $template_args); |
1511 | 1511 | } |
1512 | 1512 | |
@@ -1534,21 +1534,21 @@ discard block |
||
1534 | 1534 | $EEME = $this->_event_model(); |
1535 | 1535 | |
1536 | 1536 | $offset = ($current_page - 1) * $per_page; |
1537 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1537 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1538 | 1538 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1539 | 1539 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1540 | 1540 | |
1541 | 1541 | if (isset($this->_req_data['month_range'])) { |
1542 | 1542 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1543 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1544 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1543 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1544 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | $where = array(); |
1548 | 1548 | |
1549 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1549 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1550 | 1550 | //determine what post_status our condition will have for the query. |
1551 | - switch ( $status ) { |
|
1551 | + switch ($status) { |
|
1552 | 1552 | case 'month' : |
1553 | 1553 | case 'today' : |
1554 | 1554 | case NULL : |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | break; |
1557 | 1557 | |
1558 | 1558 | case 'draft' : |
1559 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1559 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1560 | 1560 | break; |
1561 | 1561 | |
1562 | 1562 | default : |
@@ -1564,43 +1564,43 @@ discard block |
||
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | //categories? |
1567 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1567 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1568 | 1568 | |
1569 | - if ( !empty ( $category ) ) { |
|
1569 | + if ( ! empty ($category)) { |
|
1570 | 1570 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1571 | 1571 | $where['Term_Taxonomy.term_id'] = $category; |
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | //date where conditions |
1575 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1575 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1576 | 1576 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1577 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1578 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1579 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1580 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1577 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1578 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1579 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1580 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1581 | 1581 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1582 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1583 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1584 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1585 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1586 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1587 | - $now = date( 'Y-m-01' ); |
|
1588 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1589 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1590 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1591 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1582 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1583 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1584 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1585 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1586 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1587 | + $now = date('Y-m-01'); |
|
1588 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1589 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1590 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1591 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | |
1595 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1596 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1595 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1596 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1597 | 1597 | } else { |
1598 | - if ( ! isset( $where['status'] ) ) { |
|
1599 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1598 | + if ( ! isset($where['status'])) { |
|
1599 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1600 | 1600 | $where['OR'] = array( |
1601 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1601 | + 'status*restrict_private' => array('!=', 'private'), |
|
1602 | 1602 | 'AND' => array( |
1603 | - 'status*inclusive' => array( '=', 'private' ), |
|
1603 | + 'status*inclusive' => array('=', 'private'), |
|
1604 | 1604 | 'EVT_wp_user' => get_current_user_id() |
1605 | 1605 | ) |
1606 | 1606 | ); |
@@ -1608,16 +1608,16 @@ discard block |
||
1608 | 1608 | } |
1609 | 1609 | } |
1610 | 1610 | |
1611 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1612 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1611 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1612 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1613 | 1613 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1614 | 1614 | } |
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | |
1618 | 1618 | //search query handling |
1619 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1620 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1619 | + if (isset($this->_req_data['s'])) { |
|
1620 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1621 | 1621 | $where['OR'] = array( |
1622 | 1622 | 'EVT_name' => array('LIKE', $search_string), |
1623 | 1623 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1626,32 +1626,32 @@ discard block |
||
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | |
1629 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1630 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1629 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1630 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1631 | 1631 | |
1632 | 1632 | |
1633 | 1633 | //let's first check if we have special requests coming in. |
1634 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1635 | - switch ( $this->_req_data['active_status'] ) { |
|
1634 | + if (isset($this->_req_data['active_status'])) { |
|
1635 | + switch ($this->_req_data['active_status']) { |
|
1636 | 1636 | case 'upcoming' : |
1637 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1637 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1638 | 1638 | break; |
1639 | 1639 | |
1640 | 1640 | case 'expired' : |
1641 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1641 | + return $EEME->get_expired_events($query_params, $count); |
|
1642 | 1642 | break; |
1643 | 1643 | |
1644 | 1644 | case 'active' : |
1645 | - return $EEME->get_active_events( $query_params, $count ); |
|
1645 | + return $EEME->get_active_events($query_params, $count); |
|
1646 | 1646 | break; |
1647 | 1647 | |
1648 | 1648 | case 'inactive' : |
1649 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1649 | + return $EEME->get_inactive_events($query_params, $count); |
|
1650 | 1650 | break; |
1651 | 1651 | } |
1652 | 1652 | } |
1653 | 1653 | |
1654 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1654 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1655 | 1655 | |
1656 | 1656 | return $events; |
1657 | 1657 | } |
@@ -1660,23 +1660,23 @@ discard block |
||
1660 | 1660 | |
1661 | 1661 | |
1662 | 1662 | //handling for WordPress CPT actions (trash, restore, delete) |
1663 | - public function trash_cpt_item( $post_id ) { |
|
1663 | + public function trash_cpt_item($post_id) { |
|
1664 | 1664 | $this->_req_data['EVT_ID'] = $post_id; |
1665 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1665 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | |
1669 | 1669 | |
1670 | 1670 | |
1671 | - public function restore_cpt_item( $post_id ) { |
|
1671 | + public function restore_cpt_item($post_id) { |
|
1672 | 1672 | $this->_req_data['EVT_ID'] = $post_id; |
1673 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1673 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1674 | 1674 | } |
1675 | 1675 | |
1676 | 1676 | |
1677 | - public function delete_cpt_item( $post_id ) { |
|
1677 | + public function delete_cpt_item($post_id) { |
|
1678 | 1678 | $this->_req_data['EVT_ID'] = $post_id; |
1679 | - $this->_delete_event( FALSE ); |
|
1679 | + $this->_delete_event(FALSE); |
|
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | |
@@ -1688,7 +1688,7 @@ discard block |
||
1688 | 1688 | * @param string $event_status |
1689 | 1689 | * @return void |
1690 | 1690 | */ |
1691 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1691 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1692 | 1692 | //determine the event id and set to array. |
1693 | 1693 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1694 | 1694 | // loop thru events |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | // clean status |
1697 | 1697 | $event_status = sanitize_key($event_status); |
1698 | 1698 | // grab status |
1699 | - if (!empty($event_status)) { |
|
1699 | + if ( ! empty($event_status)) { |
|
1700 | 1700 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1701 | 1701 | } else { |
1702 | 1702 | $success = FALSE; |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | } |
1711 | 1711 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1712 | 1712 | |
1713 | - if ( $redirect_after ) |
|
1713 | + if ($redirect_after) |
|
1714 | 1714 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1715 | 1715 | } |
1716 | 1716 | |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | // clean status |
1726 | 1726 | $event_status = sanitize_key($event_status); |
1727 | 1727 | // grab status |
1728 | - if (!empty($event_status)) { |
|
1728 | + if ( ! empty($event_status)) { |
|
1729 | 1729 | $success = TRUE; |
1730 | 1730 | //determine the event id and set to array. |
1731 | 1731 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1760,15 +1760,15 @@ discard block |
||
1760 | 1760 | * @param string $event_status |
1761 | 1761 | * @return bool |
1762 | 1762 | */ |
1763 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1763 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1764 | 1764 | // grab event id |
1765 | - if (!$EVT_ID) { |
|
1765 | + if ( ! $EVT_ID) { |
|
1766 | 1766 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1767 | 1767 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1768 | 1768 | return FALSE; |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1771 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1772 | 1772 | |
1773 | 1773 | // clean status |
1774 | 1774 | $event_status = sanitize_key($event_status); |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | $hook = FALSE; |
1795 | 1795 | } |
1796 | 1796 | //use class to change status |
1797 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1797 | + $this->_cpt_model_obj->set_status($event_status); |
|
1798 | 1798 | $success = $this->_cpt_model_obj->save(); |
1799 | 1799 | |
1800 | 1800 | if ($success === FALSE) { |
@@ -1816,15 +1816,15 @@ discard block |
||
1816 | 1816 | * @access protected |
1817 | 1817 | * @param bool $redirect_after |
1818 | 1818 | */ |
1819 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1819 | + protected function _delete_event($redirect_after = TRUE) { |
|
1820 | 1820 | //determine the event id and set to array. |
1821 | 1821 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1822 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1822 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1823 | 1823 | |
1824 | 1824 | |
1825 | 1825 | // loop thru events |
1826 | 1826 | if ($EVT_ID) { |
1827 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1827 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1828 | 1828 | // get list of events with no prices |
1829 | 1829 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1830 | 1830 | // remove this event from the list of events with no prices |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - if ( $redirect_after ) |
|
1841 | + if ($redirect_after) |
|
1842 | 1842 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1843 | 1843 | } |
1844 | 1844 | |
@@ -1856,12 +1856,12 @@ discard block |
||
1856 | 1856 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1857 | 1857 | // loop thru events |
1858 | 1858 | foreach ($EVT_IDs as $EVT_ID) { |
1859 | - $EVT_ID = absint( $EVT_ID ); |
|
1860 | - if ( $EVT_ID ) { |
|
1861 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1859 | + $EVT_ID = absint($EVT_ID); |
|
1860 | + if ($EVT_ID) { |
|
1861 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1862 | 1862 | $success = $results !== FALSE ? $success : FALSE; |
1863 | 1863 | // remove this event from the list of events with no prices |
1864 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1864 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1865 | 1865 | } else { |
1866 | 1866 | $success = FALSE; |
1867 | 1867 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1881,9 +1881,9 @@ discard block |
||
1881 | 1881 | * @param int $EVT_ID |
1882 | 1882 | * @return bool |
1883 | 1883 | */ |
1884 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1884 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1885 | 1885 | // grab event id |
1886 | - if ( ! $EVT_ID ) { |
|
1886 | + if ( ! $EVT_ID) { |
|
1887 | 1887 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1888 | 1888 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1889 | 1889 | return FALSE; |
@@ -1892,19 +1892,19 @@ discard block |
||
1892 | 1892 | ! $this->_cpt_model_obj instanceof EE_Event |
1893 | 1893 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
1894 | 1894 | ) { |
1895 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1895 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1896 | 1896 | } |
1897 | 1897 | |
1898 | - if ( ! $this->_cpt_model instanceof EE_Event ) { |
|
1898 | + if ( ! $this->_cpt_model instanceof EE_Event) { |
|
1899 | 1899 | return false; |
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | //need to delete related tickets and prices first. |
1903 | 1903 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1904 | - foreach ( $datetimes as $datetime ) { |
|
1904 | + foreach ($datetimes as $datetime) { |
|
1905 | 1905 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1906 | 1906 | $tickets = $datetime->get_many_related('Ticket'); |
1907 | - foreach ( $tickets as $ticket ) { |
|
1907 | + foreach ($tickets as $ticket) { |
|
1908 | 1908 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1909 | 1909 | $ticket->delete_related_permanently('Price'); |
1910 | 1910 | $ticket->delete_permanently(); |
@@ -1914,14 +1914,14 @@ discard block |
||
1914 | 1914 | |
1915 | 1915 | //what about related venues or terms? |
1916 | 1916 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1917 | - foreach ( $venues as $venue ) { |
|
1917 | + foreach ($venues as $venue) { |
|
1918 | 1918 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1919 | 1919 | } |
1920 | 1920 | |
1921 | 1921 | //any attached question groups? |
1922 | 1922 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1923 | - if ( !empty( $question_groups ) ) { |
|
1924 | - foreach ( $question_groups as $question_group ) { |
|
1923 | + if ( ! empty($question_groups)) { |
|
1924 | + foreach ($question_groups as $question_group) { |
|
1925 | 1925 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1926 | 1926 | } |
1927 | 1927 | } |
@@ -1930,12 +1930,12 @@ discard block |
||
1930 | 1930 | |
1931 | 1931 | |
1932 | 1932 | //Message Template Groups |
1933 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1933 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1934 | 1934 | |
1935 | 1935 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1936 | 1936 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1937 | 1937 | |
1938 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1938 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1939 | 1939 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1940 | 1940 | } |
1941 | 1941 | |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1950 | 1950 | return FALSE; |
1951 | 1951 | } |
1952 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
1952 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
1953 | 1953 | return TRUE; |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | */ |
1967 | 1967 | public function total_events() { |
1968 | 1968 | |
1969 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1969 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
1970 | 1970 | return $count; |
1971 | 1971 | } |
1972 | 1972 | |
@@ -1981,10 +1981,10 @@ discard block |
||
1981 | 1981 | */ |
1982 | 1982 | public function total_events_draft() { |
1983 | 1983 | $where = array( |
1984 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
1984 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
1985 | 1985 | ); |
1986 | 1986 | |
1987 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1987 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1988 | 1988 | return $count; |
1989 | 1989 | } |
1990 | 1990 | |
@@ -2003,7 +2003,7 @@ discard block |
||
2003 | 2003 | 'status' => 'trash' |
2004 | 2004 | ); |
2005 | 2005 | |
2006 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2006 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2007 | 2007 | return $count; |
2008 | 2008 | } |
2009 | 2009 | |
@@ -2031,11 +2031,11 @@ discard block |
||
2031 | 2031 | // translated |
2032 | 2032 | TRUE |
2033 | 2033 | ); |
2034 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2034 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2035 | 2035 | |
2036 | 2036 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2037 | 2037 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2038 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2038 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2039 | 2039 | $this->display_admin_page_with_sidebar(); |
2040 | 2040 | } |
2041 | 2041 | |
@@ -2061,9 +2061,9 @@ discard block |
||
2061 | 2061 | |
2062 | 2062 | protected function _template_settings() { |
2063 | 2063 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2064 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2065 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2066 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2064 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2065 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2066 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | |
@@ -2076,22 +2076,22 @@ discard block |
||
2076 | 2076 | * @return void |
2077 | 2077 | */ |
2078 | 2078 | private function _set_category_object() { |
2079 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2079 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2080 | 2080 | return; //already have the category object so get out. |
2081 | 2081 | |
2082 | 2082 | //set default category object |
2083 | 2083 | $this->_set_empty_category_object(); |
2084 | 2084 | |
2085 | 2085 | //only set if we've got an id |
2086 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2086 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2087 | 2087 | return; |
2088 | 2088 | } |
2089 | 2089 | |
2090 | 2090 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2091 | 2091 | |
2092 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2092 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2093 | 2093 | |
2094 | - if ( !empty( $term ) ) { |
|
2094 | + if ( ! empty($term)) { |
|
2095 | 2095 | $this->_category->category_name = $term->name; |
2096 | 2096 | $this->_category->category_identifier = $term->slug; |
2097 | 2097 | $this->_category->category_desc = $term->description; |
@@ -2105,13 +2105,13 @@ discard block |
||
2105 | 2105 | |
2106 | 2106 | private function _set_empty_category_object() { |
2107 | 2107 | $this->_category = new stdClass(); |
2108 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2108 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2109 | 2109 | $this->_category->id = $this->_category->parent = 0; |
2110 | 2110 | } |
2111 | 2111 | |
2112 | 2112 | |
2113 | 2113 | protected function _category_list_table() { |
2114 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2114 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2115 | 2115 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2116 | 2116 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2117 | 2117 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2127,14 +2127,14 @@ discard block |
||
2127 | 2127 | $this->_set_add_edit_form_tags($route); |
2128 | 2128 | |
2129 | 2129 | $this->_set_category_object(); |
2130 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2130 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2131 | 2131 | |
2132 | 2132 | $delete_action = 'delete_category'; |
2133 | 2133 | |
2134 | 2134 | //custom redirect |
2135 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2135 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2136 | 2136 | |
2137 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2137 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2138 | 2138 | |
2139 | 2139 | //take care of contents |
2140 | 2140 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2148,25 +2148,25 @@ discard block |
||
2148 | 2148 | 'type' => 'wp_editor', |
2149 | 2149 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2150 | 2150 | 'class' => 'my_editor_custom', |
2151 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2151 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2152 | 2152 | ); |
2153 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2153 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2154 | 2154 | |
2155 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2155 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2156 | 2156 | |
2157 | 2157 | //setup category select for term parents. |
2158 | 2158 | $category_select_values[] = array( |
2159 | 2159 | 'text' => __('No Parent', 'event_espresso'), |
2160 | 2160 | 'id' => 0 |
2161 | 2161 | ); |
2162 | - foreach ( $all_terms as $term ) { |
|
2162 | + foreach ($all_terms as $term) { |
|
2163 | 2163 | $category_select_values[] = array( |
2164 | 2164 | 'text' => $term->name, |
2165 | 2165 | 'id' => $term->term_id |
2166 | 2166 | ); |
2167 | 2167 | } |
2168 | 2168 | |
2169 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2169 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2170 | 2170 | |
2171 | 2171 | $template_args = array( |
2172 | 2172 | 'category' => $this->_category, |
@@ -2176,15 +2176,15 @@ discard block |
||
2176 | 2176 | 'disable' => '', |
2177 | 2177 | 'disabled_message' => FALSE |
2178 | 2178 | ); |
2179 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2180 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2179 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2180 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2181 | 2181 | } |
2182 | 2182 | |
2183 | 2183 | |
2184 | 2184 | protected function _delete_categories() { |
2185 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2185 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2186 | 2186 | |
2187 | - foreach ( $cat_ids as $cat_id ) { |
|
2187 | + foreach ($cat_ids as $cat_id) { |
|
2188 | 2188 | $this->_delete_category($cat_id); |
2189 | 2189 | } |
2190 | 2190 | |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | $query_args = array( |
2193 | 2193 | 'action' => 'category_list' |
2194 | 2194 | ); |
2195 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2195 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2196 | 2196 | |
2197 | 2197 | } |
2198 | 2198 | |
@@ -2202,61 +2202,61 @@ discard block |
||
2202 | 2202 | |
2203 | 2203 | protected function _delete_category($cat_id) { |
2204 | 2204 | global $wpdb; |
2205 | - $cat_id = absint( $cat_id ); |
|
2206 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2205 | + $cat_id = absint($cat_id); |
|
2206 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | |
2210 | 2210 | |
2211 | 2211 | protected function _insert_or_update_category($new_category) { |
2212 | 2212 | |
2213 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2213 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2214 | 2214 | $success = 0; //we already have a success message so lets not send another. |
2215 | 2215 | |
2216 | - if ( $cat_id ) { |
|
2216 | + if ($cat_id) { |
|
2217 | 2217 | $query_args = array( |
2218 | 2218 | 'action' => 'edit_category', |
2219 | 2219 | 'EVT_CAT_ID' => $cat_id |
2220 | 2220 | ); |
2221 | 2221 | } else { |
2222 | - $query_args = array( 'action' => 'add_category' ); |
|
2222 | + $query_args = array('action' => 'add_category'); |
|
2223 | 2223 | } |
2224 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2224 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2225 | 2225 | |
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | |
2229 | 2229 | |
2230 | - private function _insert_category( $update = FALSE ) { |
|
2230 | + private function _insert_category($update = FALSE) { |
|
2231 | 2231 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2232 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2233 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2234 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2232 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2233 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2234 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2235 | 2235 | |
2236 | - if ( empty( $category_name ) ) { |
|
2237 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2238 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2236 | + if (empty($category_name)) { |
|
2237 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2238 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2239 | 2239 | return false; |
2240 | 2240 | } |
2241 | 2241 | |
2242 | - $term_args=array( |
|
2242 | + $term_args = array( |
|
2243 | 2243 | 'name'=>$category_name, |
2244 | 2244 | 'description'=>$category_desc, |
2245 | 2245 | 'parent'=>$category_parent |
2246 | 2246 | ); |
2247 | 2247 | //was the category_identifier input disabled? |
2248 | - if(isset($this->_req_data['category_identifier'])){ |
|
2248 | + if (isset($this->_req_data['category_identifier'])) { |
|
2249 | 2249 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2250 | 2250 | } |
2251 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2251 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2252 | 2252 | |
2253 | - if ( !is_array( $insert_ids ) ) { |
|
2254 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2255 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2253 | + if ( ! is_array($insert_ids)) { |
|
2254 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2255 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2256 | 2256 | } else { |
2257 | 2257 | $cat_id = $insert_ids['term_id']; |
2258 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2259 | - EE_Error::add_success( $msg ); |
|
2258 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2259 | + EE_Error::add_success($msg); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | return $cat_id; |
@@ -2265,32 +2265,32 @@ discard block |
||
2265 | 2265 | |
2266 | 2266 | |
2267 | 2267 | |
2268 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2268 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2269 | 2269 | global $wpdb; |
2270 | 2270 | |
2271 | 2271 | //testing term stuff |
2272 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2273 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2274 | - $limit = ($current_page-1)*$per_page; |
|
2272 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2273 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2274 | + $limit = ($current_page - 1) * $per_page; |
|
2275 | 2275 | |
2276 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2276 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2277 | 2277 | |
2278 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2279 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2278 | + if (isset($this->_req_data['s'])) { |
|
2279 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2280 | 2280 | $where['OR'] = array( |
2281 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2282 | - 'description' => array( 'LIKE', $sstr ) |
|
2281 | + 'Term.name' => array('LIKE', $sstr), |
|
2282 | + 'description' => array('LIKE', $sstr) |
|
2283 | 2283 | ); |
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | $query_params = array( |
2287 | - $where , |
|
2288 | - 'order_by' => array( $orderby => $order ), |
|
2289 | - 'limit' => $limit . ',' . $per_page, |
|
2287 | + $where, |
|
2288 | + 'order_by' => array($orderby => $order), |
|
2289 | + 'limit' => $limit.','.$per_page, |
|
2290 | 2290 | 'force_join' => array('Term') |
2291 | 2291 | ); |
2292 | 2292 | |
2293 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2293 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2294 | 2294 | |
2295 | 2295 | return $categories; |
2296 | 2296 | } |
@@ -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 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | * @return \EE_SPCO_Reg_Step_Payment_Options |
129 | 129 | */ |
130 | - public function __construct( EE_Checkout $checkout ) { |
|
130 | + public function __construct(EE_Checkout $checkout) { |
|
131 | 131 | $this->_slug = 'payment_options'; |
132 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
133 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
132 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
133 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
134 | 134 | $this->checkout = $checkout; |
135 | 135 | $this->_reset_success_message(); |
136 | 136 | $this->set_instructions( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @param null $line_item_display |
157 | 157 | */ |
158 | - public function set_line_item_display( $line_item_display ) { |
|
158 | + public function set_line_item_display($line_item_display) { |
|
159 | 159 | $this->line_item_display = $line_item_display; |
160 | 160 | } |
161 | 161 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * @param boolean $handle_IPN_in_this_request |
175 | 175 | */ |
176 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
177 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
176 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
177 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -227,20 +227,20 @@ discard block |
||
227 | 227 | // $ 0.00 transactions (no payment required) |
228 | 228 | ! $this->checkout->payment_required() |
229 | 229 | // but do NOT remove if current action being called belongs to this reg step |
230 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
230 | + && ! is_callable(array($this, $this->checkout->action)) |
|
231 | 231 | && ! $this->completed() |
232 | 232 | ) { |
233 | 233 | // and if so, then we no longer need the Payment Options step |
234 | - if ( $this->is_current_step() ) { |
|
234 | + if ($this->is_current_step()) { |
|
235 | 235 | $this->checkout->generate_reg_form = false; |
236 | 236 | } |
237 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
237 | + $this->checkout->remove_reg_step($this->_slug); |
|
238 | 238 | // DEBUG LOG |
239 | 239 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | // load EEM_Payment_Method |
243 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
243 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
244 | 244 | // get all active payment methods |
245 | 245 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
246 | 246 | $this->checkout->transaction, |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | $sold_out_events = array(); |
267 | 267 | $reg_count = 0; |
268 | 268 | // loop thru registrations to gather info |
269 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
270 | - foreach ( $registrations as $registration ) { |
|
269 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
270 | + foreach ($registrations as $registration) { |
|
271 | 271 | /** @var $registration EE_Registration */ |
272 | 272 | $reg_count++; |
273 | 273 | // if returning registrant is Approved then do NOT do this |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | && $registration->status_ID() === EEM_Registration::status_id_approved |
278 | 278 | ) |
279 | 279 | ) { |
280 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) { |
|
280 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
281 | 281 | // add event to list of events that are sold out |
282 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
282 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
283 | 283 | do_action( |
284 | 284 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
285 | 285 | $registration->event(), |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | ); |
288 | 288 | } |
289 | 289 | // event requires admin approval |
290 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
290 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
291 | 291 | // add event to list of events with pre-approval reg status |
292 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
292 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
293 | 293 | do_action( |
294 | 294 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
295 | 295 | $registration->event(), |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | } |
299 | 299 | } |
300 | 300 | // are they allowed to pay now and is there monies owing? |
301 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
302 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
301 | + if ($registration->owes_monies_and_can_pay()) { |
|
302 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
303 | 303 | do_action( |
304 | 304 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
305 | 305 | $registration->event(), |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
311 | 311 | && $registration->ticket()->is_free() |
312 | 312 | ) { |
313 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
313 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | $subsections = array(); |
317 | 317 | // now decide which template to load |
318 | - if ( ! empty( $sold_out_events ) ) { |
|
319 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
318 | + if ( ! empty($sold_out_events)) { |
|
319 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
320 | 320 | } |
321 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
321 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
322 | 322 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
323 | 323 | $registrations_requiring_pre_approval |
324 | 324 | ); |
325 | 325 | } |
326 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
327 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
326 | + if ( ! empty($registrations_for_free_events)) { |
|
327 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
328 | 328 | } |
329 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
329 | + if ( ! empty($registrations_requiring_payment)) { |
|
330 | 330 | // autoload Line_Item_Display classes |
331 | 331 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
332 | 332 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | ); |
339 | 339 | /** @var EE_Line_Item $filtered_line_item_tree */ |
340 | 340 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
341 | - if ( $this->checkout->amount_owing > 0 ) { |
|
341 | + if ($this->checkout->amount_owing > 0) { |
|
342 | 342 | EEH_Autoloader::register_line_item_display_autoloaders(); |
343 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
343 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
344 | 344 | $subsections['payment_options'] = $this->_display_payment_options( |
345 | 345 | $this->line_item_display->display_line_item( |
346 | 346 | $filtered_line_item_tree, |
347 | - array( 'registrations' => $registrations ) |
|
347 | + array('registrations' => $registrations) |
|
348 | 348 | ) |
349 | 349 | ); |
350 | 350 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
351 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
351 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
352 | 352 | } |
353 | 353 | } else { |
354 | 354 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
379 | 379 | * @return \EE_Line_Item_Filter_Collection |
380 | 380 | */ |
381 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
381 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
382 | 382 | $line_item_filter_collection->add( |
383 | 383 | new EE_Billable_Line_Item_Filter( |
384 | 384 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | ) |
387 | 387 | ) |
388 | 388 | ); |
389 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
389 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
390 | 390 | return $line_item_filter_collection; |
391 | 391 | } |
392 | 392 | |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * @return void |
401 | 401 | */ |
402 | 402 | protected function _hide_reg_step_submit_button_if_revisit() { |
403 | - if ( $this->checkout->revisit ) { |
|
404 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
403 | + if ($this->checkout->revisit) { |
|
404 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | * @return \EE_Form_Section_Proper |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
417 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
418 | 418 | // set some defaults |
419 | 419 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
420 | 420 | $sold_out_events = ''; |
421 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
421 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
422 | 422 | $sold_out_events .= EEH_HTML::li( |
423 | - EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
423 | + EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
424 | 424 | ); |
425 | 425 | } |
426 | 426 | return new EE_Form_Section_Proper( |
@@ -465,17 +465,17 @@ discard block |
||
465 | 465 | * @return \EE_Form_Section_Proper |
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
468 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
468 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
469 | 469 | $events_requiring_pre_approval = ''; |
470 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
471 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
472 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
470 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
471 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
472 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
473 | 473 | EEH_HTML::span( |
474 | 474 | '', |
475 | 475 | '', |
476 | 476 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
477 | 477 | ) |
478 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
478 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
479 | 479 | ); |
480 | 480 | } |
481 | 481 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | 'template_args' => apply_filters( |
495 | 495 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
496 | 496 | array( |
497 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
497 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
498 | 498 | 'events_requiring_pre_approval_msg' => apply_filters( |
499 | 499 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
500 | 500 | __( |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * @return \EE_Form_Section_Proper |
520 | 520 | * @throws \EE_Error |
521 | 521 | */ |
522 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
522 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
523 | 523 | // set some defaults |
524 | 524 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
525 | 525 | // generate no_payment_required form |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | 'ticket_count' => array(), |
544 | 544 | 'registrations_for_free_events' => $registrations_for_free_events, |
545 | 545 | 'no_payment_required_msg' => EEH_HTML::p( |
546 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
546 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
547 | 547 | ) |
548 | 548 | ) |
549 | 549 | ), |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @return \EE_Form_Section_Proper |
563 | 563 | * @throws \EE_Error |
564 | 564 | */ |
565 | - private function _display_payment_options( $transaction_details = '' ) { |
|
565 | + private function _display_payment_options($transaction_details = '') { |
|
566 | 566 | // has method_of_payment been set by no-js user? |
567 | 567 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
568 | 568 | // build payment options form |
@@ -574,18 +574,18 @@ discard block |
||
574 | 574 | 'before_payment_options' => apply_filters( |
575 | 575 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
576 | 576 | new EE_Form_Section_Proper( |
577 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
577 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
578 | 578 | ) |
579 | 579 | ), |
580 | 580 | 'payment_options' => $this->_setup_payment_options(), |
581 | 581 | 'after_payment_options' => apply_filters( |
582 | 582 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
583 | 583 | new EE_Form_Section_Proper( |
584 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
584 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
585 | 585 | ) |
586 | 586 | ), |
587 | 587 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
588 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( false ) |
|
588 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(false) |
|
589 | 589 | ), |
590 | 590 | 'layout_strategy' => new EE_Template_Layout( |
591 | 591 | array( |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | * @return \EE_Form_Section_Proper |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
617 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
618 | 618 | return new EE_Form_Section_Proper( |
619 | 619 | array( |
620 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
620 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
621 | 621 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
622 | 622 | 'subsections' => array( |
623 | 623 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -649,16 +649,16 @@ discard block |
||
649 | 649 | * @access protected |
650 | 650 | * @param array $registrations |
651 | 651 | */ |
652 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
652 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
653 | 653 | $payments = array(); |
654 | - foreach ( $registrations as $registration ) { |
|
655 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
654 | + foreach ($registrations as $registration) { |
|
655 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
656 | 656 | $payments += $registration->registration_payments(); |
657 | 657 | } |
658 | 658 | } |
659 | - if ( ! empty( $payments ) ) { |
|
660 | - foreach ( $payments as $payment ) { |
|
661 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
659 | + if ( ! empty($payments)) { |
|
660 | + foreach ($payments as $payment) { |
|
661 | + if ($payment instanceof EE_Registration_Payment) { |
|
662 | 662 | $this->checkout->amount_owing -= $payment->amount(); |
663 | 663 | } |
664 | 664 | } |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | * @param bool $force_reset |
675 | 675 | * @return void |
676 | 676 | */ |
677 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
677 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
678 | 678 | $reset_payment_method = $force_reset |
679 | 679 | ? true |
680 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
681 | - if ( $reset_payment_method ) { |
|
680 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
681 | + if ($reset_payment_method) { |
|
682 | 682 | $this->checkout->selected_method_of_payment = null; |
683 | 683 | $this->checkout->payment_method = null; |
684 | 684 | $this->checkout->billing_form = null; |
@@ -697,12 +697,12 @@ discard block |
||
697 | 697 | * @param string $selected_method_of_payment |
698 | 698 | * @return EE_Billing_Info_Form |
699 | 699 | */ |
700 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
701 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
700 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
701 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
702 | 702 | ? $selected_method_of_payment |
703 | 703 | : $this->checkout->selected_method_of_payment; |
704 | 704 | EE_Registry::instance()->SSN->set_session_data( |
705 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
705 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
706 | 706 | ); |
707 | 707 | } |
708 | 708 | |
@@ -718,19 +718,19 @@ discard block |
||
718 | 718 | // load payment method classes |
719 | 719 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
720 | 720 | // switch up header depending on number of available payment methods |
721 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
721 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
722 | 722 | ? apply_filters( |
723 | 723 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
724 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
724 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
725 | 725 | ) |
726 | 726 | : apply_filters( |
727 | 727 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
728 | - __( 'Method of Payment', 'event_espresso' ) |
|
728 | + __('Method of Payment', 'event_espresso') |
|
729 | 729 | ); |
730 | 730 | $available_payment_methods = array( |
731 | 731 | // display the "Payment Method" header |
732 | 732 | 'payment_method_header' => new EE_Form_Section_HTML( |
733 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
733 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
734 | 734 | ) |
735 | 735 | ); |
736 | 736 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -739,32 +739,32 @@ discard block |
||
739 | 739 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
740 | 740 | $payment_methods_billing_info = array( |
741 | 741 | new EE_Form_Section_HTML( |
742 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
742 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
743 | 743 | ) |
744 | 744 | ); |
745 | 745 | // loop through payment methods |
746 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
747 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
746 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
747 | + if ($payment_method instanceof EE_Payment_Method) { |
|
748 | 748 | $payment_method_button = EEH_HTML::img( |
749 | 749 | $payment_method->button_url(), |
750 | 750 | $payment_method->name(), |
751 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
751 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
752 | 752 | 'spco-payment-method-btn-img' |
753 | 753 | ); |
754 | 754 | // check if any payment methods are set as default |
755 | 755 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
756 | 756 | if ( |
757 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
758 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
757 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
758 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
759 | 759 | ) { |
760 | 760 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
761 | 761 | $this->_save_selected_method_of_payment(); |
762 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
762 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
763 | 763 | } else { |
764 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
764 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
765 | 765 | } |
766 | - $payment_methods_billing_info[ $payment_method->slug() |
|
767 | - . '-info' ] = $this->_payment_method_billing_info( |
|
766 | + $payment_methods_billing_info[$payment_method->slug() |
|
767 | + . '-info'] = $this->_payment_method_billing_info( |
|
768 | 768 | $payment_method |
769 | 769 | ); |
770 | 770 | } |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | * @return EE_Payment_Method[] |
795 | 795 | */ |
796 | 796 | protected function _get_available_payment_methods() { |
797 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
797 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
798 | 798 | return $this->checkout->available_payment_methods; |
799 | 799 | } |
800 | 800 | $available_payment_methods = array(); |
801 | 801 | // load EEM_Payment_Method |
802 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
802 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
803 | 803 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
804 | 804 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
805 | 805 | // get all active payment methods |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | $this->checkout->transaction, |
808 | 808 | EEM_Payment_Method::scope_cart |
809 | 809 | ); |
810 | - foreach ( $payment_methods as $payment_method ) { |
|
811 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
812 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
810 | + foreach ($payment_methods as $payment_method) { |
|
811 | + if ($payment_method instanceof EE_Payment_Method) { |
|
812 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | return $available_payment_methods; |
@@ -824,14 +824,14 @@ discard block |
||
824 | 824 | * @param array $available_payment_method_options |
825 | 825 | * @return \EE_Form_Section_Proper |
826 | 826 | */ |
827 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
827 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
828 | 828 | // generate inputs |
829 | 829 | return new EE_Form_Section_Proper( |
830 | 830 | array( |
831 | 831 | 'html_id' => 'ee-available-payment-method-inputs', |
832 | 832 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
833 | 833 | 'subsections' => array( |
834 | - '' => new EE_Radio_Button_Input ( |
|
834 | + '' => new EE_Radio_Button_Input( |
|
835 | 835 | $available_payment_method_options, |
836 | 836 | array( |
837 | 837 | 'html_name' => 'selected_method_of_payment', |
@@ -856,28 +856,28 @@ discard block |
||
856 | 856 | * @return \EE_Form_Section_Proper |
857 | 857 | * @throws \EE_Error |
858 | 858 | */ |
859 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
859 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
860 | 860 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
861 | 861 | ? true |
862 | 862 | : false; |
863 | 863 | // generate the billing form for payment method |
864 | 864 | $billing_form = $currently_selected |
865 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
865 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
866 | 866 | : new EE_Form_Section_HTML(); |
867 | 867 | $this->checkout->billing_form = $currently_selected |
868 | 868 | ? $billing_form |
869 | 869 | : $this->checkout->billing_form; |
870 | 870 | // it's all in the details |
871 | 871 | $info_html = EEH_HTML::h3( |
872 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
872 | + __('Important information regarding your payment', 'event_espresso'), |
|
873 | 873 | '', |
874 | 874 | 'spco-payment-method-hdr' |
875 | 875 | ); |
876 | 876 | // add some info regarding the step, either from what's saved in the admin, |
877 | 877 | // or a default string depending on whether the PM has a billing form or not |
878 | - if ( $payment_method->description() ) { |
|
878 | + if ($payment_method->description()) { |
|
879 | 879 | $payment_method_info = $payment_method->description(); |
880 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
880 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
881 | 881 | $payment_method_info = sprintf( |
882 | 882 | __( |
883 | 883 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | ); |
888 | 888 | } else { |
889 | 889 | $payment_method_info = sprintf( |
890 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
890 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
891 | 891 | $this->submit_button_text() |
892 | 892 | ); |
893 | 893 | } |
@@ -901,13 +901,13 @@ discard block |
||
901 | 901 | ); |
902 | 902 | return new EE_Form_Section_Proper( |
903 | 903 | array( |
904 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
904 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
905 | 905 | 'html_class' => 'spco-payment-method-info-dv', |
906 | 906 | // only display the selected or default PM |
907 | 907 | 'html_style' => $currently_selected ? '' : 'display:none;', |
908 | 908 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
909 | 909 | 'subsections' => array( |
910 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
910 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
911 | 911 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
912 | 912 | ) |
913 | 913 | ) |
@@ -925,15 +925,15 @@ discard block |
||
925 | 925 | */ |
926 | 926 | public function get_billing_form_html_for_payment_method() { |
927 | 927 | // how have they chosen to pay? |
928 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
928 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
929 | 929 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
930 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
930 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
931 | 931 | return false; |
932 | 932 | } |
933 | - if ( apply_filters( |
|
933 | + if (apply_filters( |
|
934 | 934 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
935 | 935 | false |
936 | - ) ) { |
|
936 | + )) { |
|
937 | 937 | EE_Error::add_success( |
938 | 938 | apply_filters( |
939 | 939 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | ); |
949 | 949 | } |
950 | 950 | // now generate billing form for selected method of payment |
951 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
951 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
952 | 952 | // fill form with attendee info if applicable |
953 | 953 | if ( |
954 | 954 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -970,10 +970,10 @@ discard block |
||
970 | 970 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
971 | 971 | ? $payment_method_billing_form->get_html() |
972 | 972 | : ''; |
973 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
973 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
974 | 974 | // localize validation rules for main form |
975 | 975 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
976 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
976 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
977 | 977 | return true; |
978 | 978 | } |
979 | 979 | |
@@ -987,18 +987,18 @@ discard block |
||
987 | 987 | * @return \EE_Billing_Info_Form |
988 | 988 | * @throws \EE_Error |
989 | 989 | */ |
990 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
990 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
991 | 991 | $billing_form = $payment_method->type_obj()->billing_form( |
992 | 992 | $this->checkout->transaction, |
993 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
993 | + array('amount_owing' => $this->checkout->amount_owing) |
|
994 | 994 | ); |
995 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
995 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
996 | 996 | if ( |
997 | 997 | apply_filters( |
998 | 998 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
999 | 999 | false |
1000 | 1000 | ) |
1001 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1001 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1002 | 1002 | ) { |
1003 | 1003 | EE_Error::add_success( |
1004 | 1004 | apply_filters( |
@@ -1040,15 +1040,15 @@ discard block |
||
1040 | 1040 | $request_param = 'selected_method_of_payment' |
1041 | 1041 | ) { |
1042 | 1042 | // is selected_method_of_payment set in the request ? |
1043 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1044 | - if ( $selected_method_of_payment ) { |
|
1043 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1044 | + if ($selected_method_of_payment) { |
|
1045 | 1045 | // sanitize it |
1046 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1047 | - ? array_shift( $selected_method_of_payment ) |
|
1046 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1047 | + ? array_shift($selected_method_of_payment) |
|
1048 | 1048 | : $selected_method_of_payment; |
1049 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1049 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1050 | 1050 | // store it in the session so that it's available for all subsequent requests including AJAX |
1051 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1051 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1052 | 1052 | } else { |
1053 | 1053 | // or is is set in the session ? |
1054 | 1054 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | ); |
1057 | 1057 | } |
1058 | 1058 | // do ya really really gotta have it? |
1059 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1059 | + if (empty($selected_method_of_payment) && $required) { |
|
1060 | 1060 | EE_Error::add_error( |
1061 | 1061 | sprintf( |
1062 | 1062 | __( |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | ), |
1066 | 1066 | '<br/>', |
1067 | 1067 | '<br/>', |
1068 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1068 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1069 | 1069 | ), |
1070 | 1070 | __FILE__, |
1071 | 1071 | __FUNCTION__, |
@@ -1092,13 +1092,13 @@ discard block |
||
1092 | 1092 | * @throws \EE_Error |
1093 | 1093 | */ |
1094 | 1094 | public function switch_payment_method() { |
1095 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1095 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1096 | 1096 | return false; |
1097 | 1097 | } |
1098 | - if ( apply_filters( |
|
1098 | + if (apply_filters( |
|
1099 | 1099 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1100 | 1100 | false |
1101 | - ) ) { |
|
1101 | + )) { |
|
1102 | 1102 | EE_Error::add_success( |
1103 | 1103 | apply_filters( |
1104 | 1104 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1113,13 +1113,13 @@ discard block |
||
1113 | 1113 | ); |
1114 | 1114 | } |
1115 | 1115 | // generate billing form for selected method of payment if it hasn't been done already |
1116 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1116 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1117 | 1117 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1118 | 1118 | $this->checkout->payment_method |
1119 | 1119 | ); |
1120 | 1120 | } |
1121 | 1121 | // fill form with attendee info if applicable |
1122 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1122 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1123 | 1123 | && $this->checkout->transaction_has_primary_registrant() |
1124 | 1124 | ) { |
1125 | 1125 | $this->checkout->billing_form->populate_from_attendee( |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | ); |
1128 | 1128 | } |
1129 | 1129 | // and debug content |
1130 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1130 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1131 | 1131 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1132 | 1132 | ) { |
1133 | 1133 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1135,15 +1135,15 @@ discard block |
||
1135 | 1135 | ); |
1136 | 1136 | } |
1137 | 1137 | // get html and validation rules for form |
1138 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1138 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1139 | 1139 | $this->checkout->json_response->set_return_data( |
1140 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1140 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1141 | 1141 | ); |
1142 | 1142 | // localize validation rules for main form |
1143 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1144 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1143 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1144 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1145 | 1145 | } else { |
1146 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1146 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1147 | 1147 | } |
1148 | 1148 | //prevents advancement to next step |
1149 | 1149 | $this->checkout->continue_reg = false; |
@@ -1160,12 +1160,12 @@ discard block |
||
1160 | 1160 | */ |
1161 | 1161 | protected function _verify_payment_method_is_set() { |
1162 | 1162 | // generate billing form for selected method of payment if it hasn't been done already |
1163 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1163 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1164 | 1164 | // how have they chosen to pay? |
1165 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1165 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1166 | 1166 | } |
1167 | 1167 | // verify payment method |
1168 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1168 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1169 | 1169 | // get payment method for selected method of payment |
1170 | 1170 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1171 | 1171 | } |
@@ -1184,25 +1184,25 @@ discard block |
||
1184 | 1184 | * @throws \EE_Error |
1185 | 1185 | */ |
1186 | 1186 | public function save_payer_details_via_ajax() { |
1187 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1187 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1188 | 1188 | return; |
1189 | 1189 | } |
1190 | 1190 | // generate billing form for selected method of payment if it hasn't been done already |
1191 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1191 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1192 | 1192 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1193 | 1193 | $this->checkout->payment_method |
1194 | 1194 | ); |
1195 | 1195 | } |
1196 | 1196 | // generate primary attendee from payer info if applicable |
1197 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1197 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1198 | 1198 | $attendee = $this->_create_attendee_from_request_data(); |
1199 | - if ( $attendee instanceof EE_Attendee ) { |
|
1200 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1201 | - if ( $registration->is_primary_registrant() ) { |
|
1199 | + if ($attendee instanceof EE_Attendee) { |
|
1200 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1201 | + if ($registration->is_primary_registrant()) { |
|
1202 | 1202 | $this->checkout->primary_attendee_obj = $attendee; |
1203 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1204 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1205 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1203 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1204 | + $registration->set_attendee_id($attendee->ID()); |
|
1205 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1206 | 1206 | } |
1207 | 1207 | } |
1208 | 1208 | } |
@@ -1219,50 +1219,50 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | protected function _create_attendee_from_request_data() { |
1221 | 1221 | // get State ID |
1222 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1223 | - if ( ! empty( $STA_ID ) ) { |
|
1222 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1223 | + if ( ! empty($STA_ID)) { |
|
1224 | 1224 | // can we get state object from name ? |
1225 | - EE_Registry::instance()->load_model( 'State' ); |
|
1226 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1227 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1225 | + EE_Registry::instance()->load_model('State'); |
|
1226 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1227 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1228 | 1228 | } |
1229 | 1229 | // get Country ISO |
1230 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1231 | - if ( ! empty( $CNT_ISO ) ) { |
|
1230 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1231 | + if ( ! empty($CNT_ISO)) { |
|
1232 | 1232 | // can we get country object from name ? |
1233 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1233 | + EE_Registry::instance()->load_model('Country'); |
|
1234 | 1234 | $country = EEM_Country::instance()->get_col( |
1235 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1235 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1236 | 1236 | 'CNT_ISO' |
1237 | 1237 | ); |
1238 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1238 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1239 | 1239 | } |
1240 | 1240 | // grab attendee data |
1241 | 1241 | $attendee_data = array( |
1242 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1243 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1244 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1245 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1246 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1247 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1242 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1243 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1244 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1245 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1246 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1247 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1248 | 1248 | 'STA_ID' => $STA_ID, |
1249 | 1249 | 'CNT_ISO' => $CNT_ISO, |
1250 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1251 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1250 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1251 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1252 | 1252 | ); |
1253 | 1253 | // validate the email address since it is the most important piece of info |
1254 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1254 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1255 | 1255 | EE_Error::add_error( |
1256 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1256 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1257 | 1257 | __FILE__, |
1258 | 1258 | __FUNCTION__, |
1259 | 1259 | __LINE__ |
1260 | 1260 | ); |
1261 | 1261 | } |
1262 | 1262 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1263 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1264 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1265 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1263 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1264 | + && ! empty($attendee_data['ATT_lname']) |
|
1265 | + && ! empty($attendee_data['ATT_email']) |
|
1266 | 1266 | ) { |
1267 | 1267 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1268 | 1268 | array( |
@@ -1271,19 +1271,19 @@ discard block |
||
1271 | 1271 | 'ATT_email' => $attendee_data['ATT_email'] |
1272 | 1272 | ) |
1273 | 1273 | ); |
1274 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1274 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1275 | 1275 | return $existing_attendee; |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | 1278 | // no existing attendee? kk let's create a new one |
1279 | 1279 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1280 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1280 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1281 | 1281 | ? $attendee_data['ATT_fname'] |
1282 | 1282 | : $attendee_data['ATT_email']; |
1283 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1283 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1284 | 1284 | ? $attendee_data['ATT_lname'] |
1285 | 1285 | : $attendee_data['ATT_email']; |
1286 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1286 | + return EE_Attendee::new_instance($attendee_data); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | |
@@ -1301,26 +1301,26 @@ discard block |
||
1301 | 1301 | // how have they chosen to pay? |
1302 | 1302 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1303 | 1303 | ? 'no_payment_required' |
1304 | - : $this->_get_selected_method_of_payment( true ); |
|
1304 | + : $this->_get_selected_method_of_payment(true); |
|
1305 | 1305 | // choose your own adventure based on method_of_payment |
1306 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1306 | + switch ($this->checkout->selected_method_of_payment) { |
|
1307 | 1307 | |
1308 | 1308 | case 'events_sold_out' : |
1309 | 1309 | $this->checkout->redirect = true; |
1310 | 1310 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1311 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1311 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1312 | 1312 | // mark this reg step as completed |
1313 | 1313 | $this->set_completed(); |
1314 | 1314 | return false; |
1315 | 1315 | break; |
1316 | 1316 | |
1317 | 1317 | case 'payments_closed' : |
1318 | - if ( apply_filters( |
|
1318 | + if (apply_filters( |
|
1319 | 1319 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1320 | 1320 | false |
1321 | - ) ) { |
|
1321 | + )) { |
|
1322 | 1322 | EE_Error::add_success( |
1323 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1323 | + __('no payment required at this time.', 'event_espresso'), |
|
1324 | 1324 | __FILE__, |
1325 | 1325 | __FUNCTION__, |
1326 | 1326 | __LINE__ |
@@ -1332,12 +1332,12 @@ discard block |
||
1332 | 1332 | break; |
1333 | 1333 | |
1334 | 1334 | case 'no_payment_required' : |
1335 | - if ( apply_filters( |
|
1335 | + if (apply_filters( |
|
1336 | 1336 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1337 | 1337 | false |
1338 | - ) ) { |
|
1338 | + )) { |
|
1339 | 1339 | EE_Error::add_success( |
1340 | - __( 'no payment required.', 'event_espresso' ), |
|
1340 | + __('no payment required.', 'event_espresso'), |
|
1341 | 1341 | __FILE__, |
1342 | 1342 | __FUNCTION__, |
1343 | 1343 | __LINE__ |
@@ -1350,9 +1350,9 @@ discard block |
||
1350 | 1350 | |
1351 | 1351 | default: |
1352 | 1352 | $payment_successful = $this->_process_payment(); |
1353 | - if ( $payment_successful ) { |
|
1353 | + if ($payment_successful) { |
|
1354 | 1354 | $this->checkout->continue_reg = true; |
1355 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1355 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1356 | 1356 | } else { |
1357 | 1357 | $this->checkout->continue_reg = false; |
1358 | 1358 | } |
@@ -1371,8 +1371,8 @@ discard block |
||
1371 | 1371 | * @return void |
1372 | 1372 | * @throws \EE_Error |
1373 | 1373 | */ |
1374 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1375 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1374 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1375 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1376 | 1376 | case EE_PMT_Base::offsite : |
1377 | 1377 | break; |
1378 | 1378 | case EE_PMT_Base::onsite : |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | public function update_reg_step() { |
1396 | 1396 | $success = true; |
1397 | 1397 | // if payment required |
1398 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1398 | + if ($this->checkout->transaction->total() > 0) { |
|
1399 | 1399 | do_action( |
1400 | 1400 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1401 | 1401 | $this->checkout->transaction |
@@ -1403,13 +1403,13 @@ discard block |
||
1403 | 1403 | // attempt payment via payment method |
1404 | 1404 | $success = $this->process_reg_step(); |
1405 | 1405 | } |
1406 | - if ( $success && ! $this->checkout->redirect ) { |
|
1406 | + if ($success && ! $this->checkout->redirect) { |
|
1407 | 1407 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1408 | 1408 | $this->checkout->transaction->ID() |
1409 | 1409 | ); |
1410 | 1410 | // set return URL |
1411 | 1411 | $this->checkout->redirect_url = add_query_arg( |
1412 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1412 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1413 | 1413 | $this->checkout->thank_you_page_url |
1414 | 1414 | ); |
1415 | 1415 | } |
@@ -1429,28 +1429,28 @@ discard block |
||
1429 | 1429 | // clear any previous errors related to not selecting a payment method |
1430 | 1430 | // EE_Error::overwrite_errors(); |
1431 | 1431 | // ya gotta make a choice man |
1432 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1432 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1433 | 1433 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1434 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1434 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1435 | 1435 | ); |
1436 | 1436 | return false; |
1437 | 1437 | } |
1438 | 1438 | // get EE_Payment_Method object |
1439 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1439 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1440 | 1440 | return false; |
1441 | 1441 | } |
1442 | 1442 | // setup billing form |
1443 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1443 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1444 | 1444 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1445 | 1445 | $this->checkout->payment_method |
1446 | 1446 | ); |
1447 | 1447 | // bad billing form ? |
1448 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1448 | + if ( ! $this->_billing_form_is_valid()) { |
|
1449 | 1449 | return false; |
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | // ensure primary registrant has been fully processed |
1453 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1453 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1454 | 1454 | return false; |
1455 | 1455 | } |
1456 | 1456 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1458,18 +1458,18 @@ discard block |
||
1458 | 1458 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1459 | 1459 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1460 | 1460 | // attempt payment |
1461 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1461 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1462 | 1462 | // process results |
1463 | - $payment = $this->_validate_payment( $payment ); |
|
1464 | - $payment = $this->_post_payment_processing( $payment ); |
|
1463 | + $payment = $this->_validate_payment($payment); |
|
1464 | + $payment = $this->_post_payment_processing($payment); |
|
1465 | 1465 | // verify payment |
1466 | - if ( $payment instanceof EE_Payment ) { |
|
1466 | + if ($payment instanceof EE_Payment) { |
|
1467 | 1467 | // store that for later |
1468 | 1468 | $this->checkout->payment = $payment; |
1469 | 1469 | /** @type EE_Transaction_Processor $transaction_processor */ |
1470 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1470 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1471 | 1471 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1472 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1472 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1473 | 1473 | $payment_status = $payment->status(); |
1474 | 1474 | if ( |
1475 | 1475 | $payment_status === EEM_Payment::status_id_approved |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | } else { |
1480 | 1480 | return false; |
1481 | 1481 | } |
1482 | - } else if ( $payment === true ) { |
|
1482 | + } else if ($payment === true) { |
|
1483 | 1483 | // please note that offline payment methods will NOT make a payment, |
1484 | 1484 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1485 | 1485 | $this->checkout->payment = $payment; |
@@ -1504,7 +1504,7 @@ discard block |
||
1504 | 1504 | ); |
1505 | 1505 | $html = $payment_method_billing_info->get_html_and_js(); |
1506 | 1506 | $html .= $this->checkout->redirect_form; |
1507 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1507 | + EE_Registry::instance()->REQ->add_output($html); |
|
1508 | 1508 | return true; |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1518,28 +1518,28 @@ discard block |
||
1518 | 1518 | * @throws \EE_Error |
1519 | 1519 | */ |
1520 | 1520 | private function _billing_form_is_valid() { |
1521 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1521 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1522 | 1522 | return true; |
1523 | 1523 | } |
1524 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1525 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1524 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1525 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1526 | 1526 | $this->checkout->billing_form->receive_form_submission(); |
1527 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1527 | + if ($this->checkout->billing_form->is_valid()) { |
|
1528 | 1528 | return true; |
1529 | 1529 | } |
1530 | 1530 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1531 | 1531 | $error_strings = array(); |
1532 | - foreach ( $validation_errors as $validation_error ) { |
|
1533 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1532 | + foreach ($validation_errors as $validation_error) { |
|
1533 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1534 | 1534 | $form_section = $validation_error->get_form_section(); |
1535 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1535 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1536 | 1536 | $label = $form_section->html_label_text(); |
1537 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1537 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1538 | 1538 | $label = $form_section->name(); |
1539 | 1539 | } else { |
1540 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1540 | + $label = __('Validation Error', 'event_espresso'); |
|
1541 | 1541 | } |
1542 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1542 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | EE_Error::add_error( |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | 'event_espresso' |
1550 | 1550 | ), |
1551 | 1551 | '<br/>', |
1552 | - implode( '<br/>', $error_strings ) |
|
1552 | + implode('<br/>', $error_strings) |
|
1553 | 1553 | ), |
1554 | 1554 | __FILE__, |
1555 | 1555 | __FUNCTION__, |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | } else { |
1570 | 1570 | EE_Error::add_error( |
1571 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1571 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1572 | 1572 | __FILE__, |
1573 | 1573 | __FUNCTION__, |
1574 | 1574 | __LINE__ |
@@ -1603,13 +1603,13 @@ discard block |
||
1603 | 1603 | // grab the primary_registration object |
1604 | 1604 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1605 | 1605 | /** @type EE_Transaction_Processor $transaction_processor */ |
1606 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1606 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1607 | 1607 | // at this point we'll consider a TXN to not have been failed |
1608 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1608 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1609 | 1609 | // save the TXN ( which clears cached copy of primary_registration) |
1610 | 1610 | $this->checkout->transaction->save(); |
1611 | 1611 | // grab TXN ID and save it to the primary_registration |
1612 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1612 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1613 | 1613 | // save what we have so far |
1614 | 1614 | $primary_registration->save(); |
1615 | 1615 | return true; |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | private function _capture_primary_registration_data_from_billing_form() { |
1628 | 1628 | // convert billing form data into an attendee |
1629 | 1629 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1630 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1630 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1631 | 1631 | EE_Error::add_error( |
1632 | 1632 | sprintf( |
1633 | 1633 | __( |
@@ -1635,7 +1635,7 @@ discard block |
||
1635 | 1635 | 'event_espresso' |
1636 | 1636 | ), |
1637 | 1637 | '<br/>', |
1638 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1638 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1639 | 1639 | ), |
1640 | 1640 | __FILE__, |
1641 | 1641 | __FUNCTION__, |
@@ -1644,7 +1644,7 @@ discard block |
||
1644 | 1644 | return false; |
1645 | 1645 | } |
1646 | 1646 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1647 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1647 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1648 | 1648 | EE_Error::add_error( |
1649 | 1649 | sprintf( |
1650 | 1650 | __( |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | 'event_espresso' |
1653 | 1653 | ), |
1654 | 1654 | '<br/>', |
1655 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1655 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1656 | 1656 | ), |
1657 | 1657 | __FILE__, |
1658 | 1658 | __FUNCTION__, |
@@ -1660,7 +1660,7 @@ discard block |
||
1660 | 1660 | ); |
1661 | 1661 | return false; |
1662 | 1662 | } |
1663 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1663 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1664 | 1664 | instanceof |
1665 | 1665 | EE_Attendee |
1666 | 1666 | ) { |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | 'event_espresso' |
1672 | 1672 | ), |
1673 | 1673 | '<br/>', |
1674 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1674 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1675 | 1675 | ), |
1676 | 1676 | __FILE__, |
1677 | 1677 | __FUNCTION__, |
@@ -1680,9 +1680,9 @@ discard block |
||
1680 | 1680 | return false; |
1681 | 1681 | } |
1682 | 1682 | /** @type EE_Registration_Processor $registration_processor */ |
1683 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1683 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1684 | 1684 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1685 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1685 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1686 | 1686 | return true; |
1687 | 1687 | } |
1688 | 1688 | |
@@ -1698,17 +1698,17 @@ discard block |
||
1698 | 1698 | */ |
1699 | 1699 | private function _get_payment_method_for_selected_method_of_payment() { |
1700 | 1700 | // get EE_Payment_Method object |
1701 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
1702 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1701 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1702 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1703 | 1703 | } else { |
1704 | 1704 | // load EEM_Payment_Method |
1705 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1705 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1706 | 1706 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1707 | 1707 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1708 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1708 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1709 | 1709 | } |
1710 | 1710 | // verify $payment_method |
1711 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1711 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1712 | 1712 | // not a payment |
1713 | 1713 | EE_Error::add_error( |
1714 | 1714 | sprintf( |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | 'event_espresso' |
1718 | 1718 | ), |
1719 | 1719 | '<br/>', |
1720 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1720 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1721 | 1721 | ), |
1722 | 1722 | __FILE__, |
1723 | 1723 | __FUNCTION__, |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | return null; |
1727 | 1727 | } |
1728 | 1728 | // and verify it has a valid Payment_Method Type object |
1729 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1729 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1730 | 1730 | // not a payment |
1731 | 1731 | EE_Error::add_error( |
1732 | 1732 | sprintf( |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | 'event_espresso' |
1736 | 1736 | ), |
1737 | 1737 | '<br/>', |
1738 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1738 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1739 | 1739 | ), |
1740 | 1740 | __FILE__, |
1741 | 1741 | __FUNCTION__, |
@@ -1756,29 +1756,29 @@ discard block |
||
1756 | 1756 | * @return mixed EE_Payment | boolean |
1757 | 1757 | * @throws \EE_Error |
1758 | 1758 | */ |
1759 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1759 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1760 | 1760 | $payment = null; |
1761 | 1761 | $this->checkout->transaction->save(); |
1762 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1763 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1762 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1763 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1764 | 1764 | return false; |
1765 | 1765 | } |
1766 | 1766 | try { |
1767 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1767 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1768 | 1768 | // generate payment object |
1769 | 1769 | $payment = $payment_processor->process_payment( |
1770 | 1770 | $payment_method, |
1771 | 1771 | $this->checkout->transaction, |
1772 | 1772 | $this->checkout->amount_owing, |
1773 | 1773 | $this->checkout->billing_form, |
1774 | - $this->_get_return_url( $payment_method ), |
|
1774 | + $this->_get_return_url($payment_method), |
|
1775 | 1775 | 'CART', |
1776 | 1776 | $this->checkout->admin_request, |
1777 | 1777 | true, |
1778 | 1778 | $this->reg_step_url() |
1779 | 1779 | ); |
1780 | - } catch ( Exception $e ) { |
|
1781 | - $this->_handle_payment_processor_exception( $e ); |
|
1780 | + } catch (Exception $e) { |
|
1781 | + $this->_handle_payment_processor_exception($e); |
|
1782 | 1782 | } |
1783 | 1783 | return $payment; |
1784 | 1784 | } |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | * @return void |
1794 | 1794 | * @throws \EE_Error |
1795 | 1795 | */ |
1796 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1796 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1797 | 1797 | EE_Error::add_error( |
1798 | 1798 | sprintf( |
1799 | 1799 | __( |
@@ -1801,7 +1801,7 @@ discard block |
||
1801 | 1801 | 'event_espresso' |
1802 | 1802 | ), |
1803 | 1803 | '<br/>', |
1804 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1804 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1805 | 1805 | $e->getMessage(), |
1806 | 1806 | $e->getFile(), |
1807 | 1807 | $e->getLine() |
@@ -1822,9 +1822,9 @@ discard block |
||
1822 | 1822 | * @return string |
1823 | 1823 | * @throws \EE_Error |
1824 | 1824 | */ |
1825 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1825 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1826 | 1826 | $return_url = ''; |
1827 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1827 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1828 | 1828 | case EE_PMT_Base::offsite : |
1829 | 1829 | $return_url = add_query_arg( |
1830 | 1830 | array( |
@@ -1853,12 +1853,12 @@ discard block |
||
1853 | 1853 | * @return EE_Payment | FALSE |
1854 | 1854 | * @throws \EE_Error |
1855 | 1855 | */ |
1856 | - private function _validate_payment( $payment = null ) { |
|
1857 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1856 | + private function _validate_payment($payment = null) { |
|
1857 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1858 | 1858 | return true; |
1859 | 1859 | } |
1860 | 1860 | // verify payment object |
1861 | - if ( ! $payment instanceof EE_Payment ) { |
|
1861 | + if ( ! $payment instanceof EE_Payment) { |
|
1862 | 1862 | // not a payment |
1863 | 1863 | EE_Error::add_error( |
1864 | 1864 | sprintf( |
@@ -1867,7 +1867,7 @@ discard block |
||
1867 | 1867 | 'event_espresso' |
1868 | 1868 | ), |
1869 | 1869 | '<br/>', |
1870 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1870 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1871 | 1871 | ), |
1872 | 1872 | __FILE__, |
1873 | 1873 | __FUNCTION__, |
@@ -1888,27 +1888,27 @@ discard block |
||
1888 | 1888 | * @return bool |
1889 | 1889 | * @throws \EE_Error |
1890 | 1890 | */ |
1891 | - private function _post_payment_processing( $payment = null ) { |
|
1891 | + private function _post_payment_processing($payment = null) { |
|
1892 | 1892 | // Off-Line payment? |
1893 | - if ( $payment === true ) { |
|
1893 | + if ($payment === true) { |
|
1894 | 1894 | //$this->_setup_redirect_for_next_step(); |
1895 | 1895 | return true; |
1896 | 1896 | // On-Site payment? |
1897 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
1898 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
1897 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
1898 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1899 | 1899 | //$this->_setup_redirect_for_next_step(); |
1900 | 1900 | $this->checkout->continue_reg = false; |
1901 | 1901 | } |
1902 | 1902 | // Off-Site payment? |
1903 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1903 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1904 | 1904 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1905 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
1906 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1905 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1906 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1907 | 1907 | $this->checkout->redirect = true; |
1908 | 1908 | $this->checkout->redirect_form = $payment->redirect_form(); |
1909 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1909 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1910 | 1910 | // set JSON response |
1911 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1911 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1912 | 1912 | // set cron job for finalizing the TXN |
1913 | 1913 | // in case the user does not return from the off-site gateway |
1914 | 1914 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | $this->checkout->transaction->ID() |
1917 | 1917 | ); |
1918 | 1918 | // and lastly, let's bump the payment status to pending |
1919 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1919 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1920 | 1920 | $payment->save(); |
1921 | 1921 | } else { |
1922 | 1922 | // not a payment |
@@ -1928,7 +1928,7 @@ discard block |
||
1928 | 1928 | 'event_espresso' |
1929 | 1929 | ), |
1930 | 1930 | '<br/>', |
1931 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1931 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1932 | 1932 | ), |
1933 | 1933 | __FILE__, |
1934 | 1934 | __FUNCTION__, |
@@ -1966,21 +1966,21 @@ discard block |
||
1966 | 1966 | * @return bool |
1967 | 1967 | * @throws \EE_Error |
1968 | 1968 | */ |
1969 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1969 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1970 | 1970 | // off-line payment? carry on |
1971 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
1971 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
1972 | 1972 | return true; |
1973 | 1973 | } |
1974 | 1974 | // verify payment validity |
1975 | - if ( $payment instanceof EE_Payment ) { |
|
1976 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1975 | + if ($payment instanceof EE_Payment) { |
|
1976 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1977 | 1977 | $msg = $payment->gateway_response(); |
1978 | 1978 | // check results |
1979 | - switch ( $payment->status() ) { |
|
1979 | + switch ($payment->status()) { |
|
1980 | 1980 | // good payment |
1981 | 1981 | case EEM_Payment::status_id_approved : |
1982 | 1982 | EE_Error::add_success( |
1983 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
1983 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
1984 | 1984 | __FILE__, |
1985 | 1985 | __FUNCTION__, |
1986 | 1986 | __LINE__ |
@@ -1989,45 +1989,45 @@ discard block |
||
1989 | 1989 | break; |
1990 | 1990 | // slow payment |
1991 | 1991 | case EEM_Payment::status_id_pending : |
1992 | - if ( empty( $msg ) ) { |
|
1992 | + if (empty($msg)) { |
|
1993 | 1993 | $msg = __( |
1994 | 1994 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
1995 | 1995 | 'event_espresso' |
1996 | 1996 | ); |
1997 | 1997 | } |
1998 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1998 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1999 | 1999 | return true; |
2000 | 2000 | break; |
2001 | 2001 | // don't wanna payment |
2002 | 2002 | case EEM_Payment::status_id_cancelled : |
2003 | - if ( empty( $msg ) ) { |
|
2003 | + if (empty($msg)) { |
|
2004 | 2004 | $msg = _n( |
2005 | 2005 | 'Payment cancelled. Please try again.', |
2006 | 2006 | 'Payment cancelled. Please try again or select another method of payment.', |
2007 | - count( $this->checkout->available_payment_methods ), |
|
2007 | + count($this->checkout->available_payment_methods), |
|
2008 | 2008 | 'event_espresso' |
2009 | 2009 | ); |
2010 | 2010 | } |
2011 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2011 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2012 | 2012 | return false; |
2013 | 2013 | break; |
2014 | 2014 | // not enough payment |
2015 | 2015 | case EEM_Payment::status_id_declined : |
2016 | - if ( empty( $msg ) ) { |
|
2016 | + if (empty($msg)) { |
|
2017 | 2017 | $msg = _n( |
2018 | 2018 | 'We\'re sorry but your payment was declined. Please try again.', |
2019 | 2019 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2020 | - count( $this->checkout->available_payment_methods ), |
|
2020 | + count($this->checkout->available_payment_methods), |
|
2021 | 2021 | 'event_espresso' |
2022 | 2022 | ); |
2023 | 2023 | } |
2024 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2024 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2025 | 2025 | return false; |
2026 | 2026 | break; |
2027 | 2027 | // bad payment |
2028 | 2028 | case EEM_Payment::status_id_failed : |
2029 | - if ( ! empty( $msg ) ) { |
|
2030 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2029 | + if ( ! empty($msg)) { |
|
2030 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2031 | 2031 | return false; |
2032 | 2032 | } |
2033 | 2033 | // default to error below |
@@ -2036,7 +2036,7 @@ discard block |
||
2036 | 2036 | } |
2037 | 2037 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2038 | 2038 | // the payment processing is just running slower than the registrant's request |
2039 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2039 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2040 | 2040 | return true; |
2041 | 2041 | } |
2042 | 2042 | EE_Error::add_error( |
@@ -2046,7 +2046,7 @@ discard block |
||
2046 | 2046 | 'event_espresso' |
2047 | 2047 | ), |
2048 | 2048 | '<br/>', |
2049 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2049 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2050 | 2050 | ), |
2051 | 2051 | __FILE__, |
2052 | 2052 | __FUNCTION__, |
@@ -2079,13 +2079,13 @@ discard block |
||
2079 | 2079 | public function process_gateway_response() { |
2080 | 2080 | $payment = null; |
2081 | 2081 | // how have they chosen to pay? |
2082 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2082 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2083 | 2083 | // get EE_Payment_Method object |
2084 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2084 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2085 | 2085 | $this->checkout->continue_reg = false; |
2086 | 2086 | return false; |
2087 | 2087 | } |
2088 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2088 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2089 | 2089 | return false; |
2090 | 2090 | } |
2091 | 2091 | $this->_validate_offsite_return(); |
@@ -2099,23 +2099,23 @@ discard block |
||
2099 | 2099 | // true |
2100 | 2100 | //); |
2101 | 2101 | // verify TXN |
2102 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2102 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2103 | 2103 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2104 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2104 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2105 | 2105 | $this->checkout->continue_reg = false; |
2106 | 2106 | return false; |
2107 | 2107 | } |
2108 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2109 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2110 | - $payment = $this->_validate_payment( $payment ); |
|
2108 | + $payment = $this->_process_off_site_payment($gateway); |
|
2109 | + $payment = $this->_process_cancelled_payments($payment); |
|
2110 | + $payment = $this->_validate_payment($payment); |
|
2111 | 2111 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2112 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2112 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2113 | 2113 | //$this->_setup_redirect_for_next_step(); |
2114 | 2114 | // store that for later |
2115 | 2115 | $this->checkout->payment = $payment; |
2116 | 2116 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2117 | 2117 | // because we will complete this step during the IPN processing then |
2118 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2118 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2119 | 2119 | $this->set_completed(); |
2120 | 2120 | } |
2121 | 2121 | return true; |
@@ -2139,21 +2139,21 @@ discard block |
||
2139 | 2139 | * @throws \EE_Error |
2140 | 2140 | */ |
2141 | 2141 | private function _validate_offsite_return() { |
2142 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2143 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2142 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2143 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2144 | 2144 | // Houston... we might have a problem |
2145 | 2145 | $invalid_TXN = false; |
2146 | 2146 | // first gather some info |
2147 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2147 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2148 | 2148 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2149 | 2149 | ? $valid_TXN->primary_registration() |
2150 | 2150 | : null; |
2151 | 2151 | // let's start by retrieving the cart for this TXN |
2152 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2153 | - if ( $cart instanceof EE_Cart ) { |
|
2152 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2153 | + if ($cart instanceof EE_Cart) { |
|
2154 | 2154 | // verify that the current cart has tickets |
2155 | 2155 | $tickets = $cart->get_tickets(); |
2156 | - if ( empty( $tickets ) ) { |
|
2156 | + if (empty($tickets)) { |
|
2157 | 2157 | $invalid_TXN = true; |
2158 | 2158 | } |
2159 | 2159 | } else { |
@@ -2163,39 +2163,39 @@ discard block |
||
2163 | 2163 | ? $primary_registrant->session_ID() |
2164 | 2164 | : null; |
2165 | 2165 | // validate current Session ID and compare against valid TXN session ID |
2166 | - if ( EE_Session::instance()->id() === null ) { |
|
2166 | + if (EE_Session::instance()->id() === null) { |
|
2167 | 2167 | $invalid_TXN = true; |
2168 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
2168 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
2169 | 2169 | // WARNING !!! |
2170 | 2170 | // this could be PayPal sending back duplicate requests (ya they do that) |
2171 | 2171 | // or it **could** mean someone is simply registering AGAIN after having just done so |
2172 | 2172 | // so now we need to determine if this current TXN looks valid or not |
2173 | 2173 | /** @type EE_Transaction_Processor $transaction_processor */ |
2174 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
2174 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2175 | 2175 | // has this step even been started ? |
2176 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
2176 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
2177 | 2177 | ) { |
2178 | 2178 | // really? you're half way through this reg step, but you never started it ? |
2179 | 2179 | $invalid_TXN = true; |
2180 | 2180 | } |
2181 | 2181 | } |
2182 | - if ( $invalid_TXN ) { |
|
2182 | + if ($invalid_TXN) { |
|
2183 | 2183 | // is the valid TXN completed ? |
2184 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2184 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2185 | 2185 | /** @type EE_Transaction_Processor $transaction_processor */ |
2186 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
2186 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2187 | 2187 | // has this step even been started ? |
2188 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
2189 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2188 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
2189 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2190 | 2190 | // so it **looks** like this is a double request from PayPal |
2191 | 2191 | // so let's try to pick up where we left off |
2192 | 2192 | $this->checkout->transaction = $valid_TXN; |
2193 | - $this->checkout->refresh_all_entities( true ); |
|
2193 | + $this->checkout->refresh_all_entities(true); |
|
2194 | 2194 | return; |
2195 | 2195 | } |
2196 | 2196 | } |
2197 | 2197 | // you appear to be lost? |
2198 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2198 | + $this->_redirect_wayward_request($primary_registrant); |
|
2199 | 2199 | } |
2200 | 2200 | } |
2201 | 2201 | } |
@@ -2210,14 +2210,14 @@ discard block |
||
2210 | 2210 | * @return bool |
2211 | 2211 | * @throws \EE_Error |
2212 | 2212 | */ |
2213 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2214 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2213 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2214 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2215 | 2215 | // try redirecting based on the current TXN |
2216 | 2216 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2217 | 2217 | ? $this->checkout->transaction->primary_registration() |
2218 | 2218 | : null; |
2219 | 2219 | } |
2220 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2220 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2221 | 2221 | EE_Error::add_error( |
2222 | 2222 | sprintf( |
2223 | 2223 | __( |
@@ -2225,7 +2225,7 @@ discard block |
||
2225 | 2225 | 'event_espresso' |
2226 | 2226 | ), |
2227 | 2227 | '<br/>', |
2228 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2228 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2229 | 2229 | ), |
2230 | 2230 | __FILE__, |
2231 | 2231 | __FUNCTION__, |
@@ -2256,17 +2256,17 @@ discard block |
||
2256 | 2256 | * @return \EE_Payment |
2257 | 2257 | * @throws \EE_Error |
2258 | 2258 | */ |
2259 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2259 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2260 | 2260 | try { |
2261 | 2261 | $request_data = \EE_Registry::instance()->REQ->params(); |
2262 | 2262 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2263 | 2263 | $this->set_handle_IPN_in_this_request( |
2264 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2264 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2265 | 2265 | ); |
2266 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2266 | + if ($this->handle_IPN_in_this_request()) { |
|
2267 | 2267 | // get payment details and process results |
2268 | 2268 | /** @type EE_Payment_Processor $payment_processor */ |
2269 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2269 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2270 | 2270 | $payment = $payment_processor->process_ipn( |
2271 | 2271 | $request_data, |
2272 | 2272 | $this->checkout->transaction, |
@@ -2279,14 +2279,14 @@ discard block |
||
2279 | 2279 | $payment = $this->checkout->transaction->last_payment(); |
2280 | 2280 | //$payment_source = 'last_payment'; |
2281 | 2281 | } |
2282 | - } catch ( Exception $e ) { |
|
2282 | + } catch (Exception $e) { |
|
2283 | 2283 | // let's just eat the exception and try to move on using any previously set payment info |
2284 | 2284 | $payment = $this->checkout->transaction->last_payment(); |
2285 | 2285 | //$payment_source = 'last_payment after Exception'; |
2286 | 2286 | // but if we STILL don't have a payment object |
2287 | - if ( ! $payment instanceof EE_Payment ) { |
|
2287 | + if ( ! $payment instanceof EE_Payment) { |
|
2288 | 2288 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2289 | - $this->_handle_payment_processor_exception( $e ); |
|
2289 | + $this->_handle_payment_processor_exception($e); |
|
2290 | 2290 | } |
2291 | 2291 | } |
2292 | 2292 | // DEBUG LOG |
@@ -2311,13 +2311,13 @@ discard block |
||
2311 | 2311 | * @return EE_Payment | FALSE |
2312 | 2312 | * @throws \EE_Error |
2313 | 2313 | */ |
2314 | - private function _process_cancelled_payments( $payment = null ) { |
|
2314 | + private function _process_cancelled_payments($payment = null) { |
|
2315 | 2315 | if ( |
2316 | 2316 | $payment instanceof EE_Payment |
2317 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2317 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2318 | 2318 | && $payment->status() === EEM_Payment::status_id_failed |
2319 | 2319 | ) { |
2320 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2320 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2321 | 2321 | } |
2322 | 2322 | return $payment; |
2323 | 2323 | } |
@@ -2334,14 +2334,14 @@ discard block |
||
2334 | 2334 | public function get_transaction_details_for_gateways() { |
2335 | 2335 | $txn_details = array(); |
2336 | 2336 | // ya gotta make a choice man |
2337 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2337 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2338 | 2338 | $txn_details = array( |
2339 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2339 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2340 | 2340 | ); |
2341 | 2341 | } |
2342 | 2342 | // get EE_Payment_Method object |
2343 | 2343 | if ( |
2344 | - empty( $txn_details ) |
|
2344 | + empty($txn_details) |
|
2345 | 2345 | && |
2346 | 2346 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2347 | 2347 | ) { |
@@ -2353,8 +2353,8 @@ discard block |
||
2353 | 2353 | ) |
2354 | 2354 | ); |
2355 | 2355 | } |
2356 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2357 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2356 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2357 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2358 | 2358 | $txn_details = array( |
2359 | 2359 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2360 | 2360 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2365,7 +2365,7 @@ discard block |
||
2365 | 2365 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2366 | 2366 | 'payment_amount' => $this->checkout->amount_owing, |
2367 | 2367 | 'return_url' => $return_url, |
2368 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2368 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2369 | 2369 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2370 | 2370 | array( |
2371 | 2371 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2374,7 +2374,7 @@ discard block |
||
2374 | 2374 | ) |
2375 | 2375 | ); |
2376 | 2376 | } |
2377 | - echo json_encode( $txn_details ); |
|
2377 | + echo json_encode($txn_details); |
|
2378 | 2378 | exit(); |
2379 | 2379 | } |
2380 | 2380 |
@@ -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 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param EE_Checkout $checkout |
23 | 23 | * @return \EE_SPCO_Reg_Step_Finalize_Registration |
24 | 24 | */ |
25 | - public function __construct( EE_Checkout $checkout ) { |
|
25 | + public function __construct(EE_Checkout $checkout) { |
|
26 | 26 | $this->_slug = 'finalize_registration'; |
27 | - $this->_name = __( 'Finalize Registration', 'event_espresso' ); |
|
27 | + $this->_name = __('Finalize Registration', 'event_espresso'); |
|
28 | 28 | $this->_submit_button_text = $this->_name; |
29 | 29 | $this->_template = ''; |
30 | 30 | $this->checkout = $checkout; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function initialize_reg_step() { |
49 | 49 | // there's actually no reg form to process if this is the final step |
50 | - if ( $this->is_current_step() ) { |
|
50 | + if ($this->is_current_step()) { |
|
51 | 51 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
52 | 52 | $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
53 | 53 | $this->checkout->generate_reg_form = false; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function process_reg_step() { |
75 | 75 | // ensure all data gets refreshed from the db |
76 | - $this->checkout->refresh_all_entities( true ); |
|
76 | + $this->checkout->refresh_all_entities(true); |
|
77 | 77 | // ensures that all details and statuses for transaction, registration, and payments are updated |
78 | 78 | $txn_update_params = $this->_finalize_transaction(); |
79 | 79 | // DEBUG LOG |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | $txn_update_params |
103 | 103 | ); |
104 | 104 | // check if transaction has a primary registrant and that it has a related Attendee object |
105 | - if ( ! $this->_validate_primary_registrant() ) { |
|
105 | + if ( ! $this->_validate_primary_registrant()) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | // you don't have to go home but you can't stay here ! |
109 | 109 | $this->checkout->redirect = true; |
110 | 110 | $this->checkout->continue_reg = true; |
111 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
111 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function _finalize_transaction() { |
135 | 135 | /** @type EE_Transaction_Processor $transaction_processor */ |
136 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
136 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
137 | 137 | //set revisit flag in txn processor |
138 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
138 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
139 | 139 | // at this point we'll consider a TXN to not have been abandoned |
140 | - $transaction_processor->toggle_abandoned_transaction_status( $this->checkout->transaction ); |
|
141 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
140 | + $transaction_processor->toggle_abandoned_transaction_status($this->checkout->transaction); |
|
141 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
142 | 142 | // save TXN data to the cart |
143 | 143 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
144 | 144 | $this->checkout->transaction->ID() |
145 | 145 | ); |
146 | 146 | } |
147 | 147 | /** @type EE_Transaction_Payments $transaction_payments */ |
148 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
148 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
149 | 149 | // maybe update status, but don't save transaction just yet |
150 | - $transaction_payments->update_transaction_status_based_on_total_paid( $this->checkout->transaction, false ); |
|
150 | + $transaction_payments->update_transaction_status_based_on_total_paid($this->checkout->transaction, false); |
|
151 | 151 | // maybe send messages |
152 | 152 | $this->_trigger_notifications(); |
153 | 153 | // this will result in the base session properties getting saved to the TXN_Session_data field |
154 | 154 | $this->checkout->transaction->set_txn_session_data( |
155 | - EE_Registry::instance()->SSN->get_session_data( null, true ) |
|
155 | + EE_Registry::instance()->SSN->get_session_data(null, true) |
|
156 | 156 | ); |
157 | 157 | // update the TXN if payment conditions have changed |
158 | 158 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | 176 | protected function _trigger_notifications() { |
177 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
178 | - $is_revisit = filter_var( $this->checkout->revisit, FILTER_VALIDATE_BOOLEAN ); |
|
179 | - if ( $this->checkout->payment_method->is_off_site() ) { |
|
180 | - $gateway= $this->checkout->payment_method->type_obj()->get_gateway(); |
|
177 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
178 | + $is_revisit = filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN); |
|
179 | + if ($this->checkout->payment_method->is_off_site()) { |
|
180 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
181 | 181 | if ( |
182 | 182 | ! $is_revisit |
183 | 183 | && $gateway instanceof EE_Offsite_Gateway |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | ) |
188 | 188 | ) { |
189 | 189 | // first time through SPCO and we are processing the payment notification NOW |
190 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
190 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
191 | 191 | } else { |
192 | 192 | // do NOT trigger notifications because this is a revisit, OR it was already done during the IPN |
193 | - remove_all_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ); |
|
193 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
194 | 194 | add_filter( |
195 | 195 | 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
196 | 196 | '__return_false', |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | } |
200 | 200 | } else if ( |
201 | 201 | // if SPCO revisit and TXN status has changed due to a payment |
202 | - $is_revisit && ( $this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated() ) |
|
202 | + $is_revisit && ($this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated()) |
|
203 | 203 | ) { |
204 | 204 | // send out notifications |
205 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
206 | - } else if ( ! $is_revisit ) { |
|
207 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
205 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | + } else if ( ! $is_revisit) { |
|
207 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * @throws \EE_Error |
219 | 219 | */ |
220 | 220 | protected function _validate_primary_registrant() { |
221 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
221 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
222 | 222 | EE_Error::add_error( |
223 | - __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), |
|
223 | + __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), |
|
224 | 224 | __FILE__, |
225 | 225 | __FUNCTION__, |
226 | 226 | __LINE__ |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | } |
232 | 232 | // setup URL for redirect |
233 | 233 | $this->checkout->redirect_url = add_query_arg( |
234 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
234 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
235 | 235 | $this->checkout->thank_you_page_url |
236 | 236 | ); |
237 | 237 | return true; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function update_reg_step() { |
246 | 246 | EE_Error::doing_it_wrong( |
247 | - __CLASS__ . '::' . __FILE__, |
|
247 | + __CLASS__.'::'.__FILE__, |
|
248 | 248 | __( |
249 | 249 | 'Can not call update_reg_step() on the Finalize Registration reg step.', |
250 | 250 | 'event_espresso' |
@@ -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 | * |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @param bool $routing |
74 | 74 | */ |
75 | - public function __construct( $routing = true ) { |
|
75 | + public function __construct($routing = true) { |
|
76 | 76 | //make sure messages autoloader is running |
77 | 77 | EED_Messages::set_autoloaders(); |
78 | - parent::__construct( $routing ); |
|
78 | + parent::__construct($routing); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
91 | 91 | |
92 | - $this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null; |
|
92 | + $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
|
93 | 93 | $this->_load_message_resource_manager(); |
94 | 94 | } |
95 | 95 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @throws EE_Error |
104 | 104 | */ |
105 | 105 | protected function _load_message_resource_manager() { |
106 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
106 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | $messengers = $this->_message_resource_manager->active_messengers(); |
120 | 120 | //setup messengers for selects |
121 | 121 | $i = 1; |
122 | - foreach ( $messengers as $messenger_name => $messenger ) { |
|
123 | - if ( $messenger instanceof EE_messenger ) { |
|
124 | - $m_values[ $i ][ 'id' ] = $messenger_name; |
|
125 | - $m_values[ $i ][ 'text' ] = ucwords( $messenger->label[ 'singular' ] ); |
|
122 | + foreach ($messengers as $messenger_name => $messenger) { |
|
123 | + if ($messenger instanceof EE_messenger) { |
|
124 | + $m_values[$i]['id'] = $messenger_name; |
|
125 | + $m_values[$i]['text'] = ucwords($messenger->label['singular']); |
|
126 | 126 | $i++; |
127 | 127 | } |
128 | 128 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | $mt_values = array(); |
142 | 142 | $message_types = $this->_message_resource_manager->installed_message_types(); |
143 | 143 | $i = 1; |
144 | - foreach ( $message_types as $message_type_name => $message_type ) { |
|
145 | - if ( $message_type instanceof EE_message_type ) { |
|
146 | - $mt_values[ $i ][ 'id' ] = $message_type_name; |
|
147 | - $mt_values[ $i ][ 'text' ] = ucwords( $message_type->label[ 'singular' ] ); |
|
144 | + foreach ($message_types as $message_type_name => $message_type) { |
|
145 | + if ($message_type instanceof EE_message_type) { |
|
146 | + $mt_values[$i]['id'] = $message_type_name; |
|
147 | + $mt_values[$i]['text'] = ucwords($message_type->label['singular']); |
|
148 | 148 | $i++; |
149 | 149 | } |
150 | 150 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | |
155 | 155 | |
156 | 156 | protected function _ajax_hooks() { |
157 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
158 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
159 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
160 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
161 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
157 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
158 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
159 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
160 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
161 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | * @return void |
191 | 191 | */ |
192 | 192 | protected function _set_page_routes() { |
193 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
193 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
194 | 194 | ? $this->_req_data['GRP_ID'] |
195 | 195 | : 0; |
196 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
196 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
197 | 197 | ? $this->_req_data['id'] |
198 | 198 | : $grp_id; |
199 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
199 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
200 | 200 | ? $this->_req_data['MSG_ID'] |
201 | 201 | : 0; |
202 | 202 | |
@@ -238,35 +238,35 @@ discard block |
||
238 | 238 | 'insert_message_template' => array( |
239 | 239 | 'func' => '_insert_or_update_message_template', |
240 | 240 | 'capability' => 'ee_edit_messages', |
241 | - 'args' => array( 'new_template' => true ), |
|
241 | + 'args' => array('new_template' => true), |
|
242 | 242 | 'noheader' => true |
243 | 243 | ), |
244 | 244 | 'update_message_template' => array( |
245 | 245 | 'func' => '_insert_or_update_message_template', |
246 | 246 | 'capability' => 'ee_edit_message', |
247 | 247 | 'obj_id' => $grp_id, |
248 | - 'args' => array( 'new_template' => false ), |
|
248 | + 'args' => array('new_template' => false), |
|
249 | 249 | 'noheader' => true |
250 | 250 | ), |
251 | 251 | 'trash_message_template' => array( |
252 | 252 | 'func' => '_trash_or_restore_message_template', |
253 | 253 | 'capability' => 'ee_delete_message', |
254 | 254 | 'obj_id' => $grp_id, |
255 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
255 | + 'args' => array('trash' => true, 'all' => true), |
|
256 | 256 | 'noheader' => true |
257 | 257 | ), |
258 | 258 | 'trash_message_template_context' => array( |
259 | 259 | 'func' => '_trash_or_restore_message_template', |
260 | 260 | 'capability' => 'ee_delete_message', |
261 | 261 | 'obj_id' => $grp_id, |
262 | - 'args' => array( 'trash' => true ), |
|
262 | + 'args' => array('trash' => true), |
|
263 | 263 | 'noheader' => true |
264 | 264 | ), |
265 | 265 | 'restore_message_template' => array( |
266 | 266 | 'func' => '_trash_or_restore_message_template', |
267 | 267 | 'capability' => 'ee_delete_message', |
268 | 268 | 'obj_id' => $grp_id, |
269 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
269 | + 'args' => array('trash' => false, 'all' => true), |
|
270 | 270 | 'noheader' => true |
271 | 271 | ), |
272 | 272 | 'restore_message_template_context' => array( |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'filename' => 'messages_overview_other', |
381 | 381 | ), |
382 | 382 | ), |
383 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
383 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
384 | 384 | 'require_nonce' => false |
385 | 385 | ), |
386 | 386 | 'custom_mtps' => array( |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | ), |
416 | 416 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
417 | 417 | 'has_metaboxes' => true, |
418 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
418 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
419 | 419 | 'help_tabs' => array( |
420 | 420 | 'edit_message_template' => array( |
421 | 421 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | 'filename' => 'messages_settings_messengers' |
472 | 472 | ), |
473 | 473 | ), |
474 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
474 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
475 | 475 | 'require_nonce' => false |
476 | 476 | ) |
477 | 477 | ); |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | |
506 | 506 | protected function _add_screen_options_default() { |
507 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
507 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
508 | 508 | $this->_per_page_screen_option(); |
509 | 509 | } |
510 | 510 | |
@@ -526,37 +526,37 @@ discard block |
||
526 | 526 | |
527 | 527 | |
528 | 528 | public function messages_help_tab() { |
529 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
529 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | |
533 | 533 | public function messengers_help_tab() { |
534 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
534 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
538 | 538 | public function message_types_help_tab() { |
539 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
539 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
543 | 543 | public function messages_overview_help_tab() { |
544 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
544 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | |
548 | 548 | public function message_templates_help_tab() { |
549 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
549 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | |
553 | 553 | public function edit_message_template_help_tab() { |
554 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
555 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
556 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
557 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
558 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
559 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
554 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
555 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
556 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
557 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
558 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
559 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | |
@@ -564,22 +564,22 @@ discard block |
||
564 | 564 | public function message_template_shortcodes_help_tab() { |
565 | 565 | $this->_set_shortcodes(); |
566 | 566 | $args['shortcodes'] = $this->_shortcodes; |
567 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
567 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
571 | 571 | |
572 | 572 | public function preview_message_help_tab() { |
573 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
573 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | |
577 | 577 | public function settings_help_tab() { |
578 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
579 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
578 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
579 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
580 | 580 | $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>'; |
581 | 581 | $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>'; |
582 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
582 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | |
@@ -587,31 +587,31 @@ discard block |
||
587 | 587 | |
588 | 588 | |
589 | 589 | public function load_scripts_styles() { |
590 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
590 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
591 | 591 | wp_enqueue_style('espresso_ee_msg'); |
592 | 592 | |
593 | - 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 ); |
|
594 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
593 | + 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); |
|
594 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | |
598 | 598 | |
599 | 599 | public function load_scripts_styles_default() { |
600 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
600 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
604 | 604 | |
605 | 605 | |
606 | 606 | |
607 | - public function wp_editor_css( $mce_css ) { |
|
607 | + public function wp_editor_css($mce_css) { |
|
608 | 608 | //if we're on the edit_message_template route |
609 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger ) { |
|
609 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) { |
|
610 | 610 | $message_type_name = $this->_active_message_type_name; |
611 | 611 | |
612 | 612 | //we're going to REPLACE the existing mce css |
613 | 613 | //we need to get the css file location from the active messenger |
614 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
614 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | return $mce_css; |
@@ -629,15 +629,15 @@ discard block |
||
629 | 629 | $this->_message_template_group->messenger_obj()->label['singular'], |
630 | 630 | $this->_message_template_group->message_type_obj()->label['singular'] |
631 | 631 | ); |
632 | - 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' ); |
|
632 | + 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'); |
|
633 | 633 | |
634 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
634 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
635 | 635 | |
636 | 636 | wp_enqueue_script('ee_admin_js'); |
637 | 637 | wp_enqueue_script('ee_msgs_edit_js'); |
638 | 638 | |
639 | 639 | //add in special css for tiny_mce |
640 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
640 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -646,22 +646,22 @@ discard block |
||
646 | 646 | |
647 | 647 | $this->_set_message_template_group(); |
648 | 648 | |
649 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
650 | - $this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
649 | + if (isset($this->_req_data['messenger'])) { |
|
650 | + $this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
651 | 651 | } |
652 | 652 | |
653 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
653 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
654 | 654 | |
655 | 655 | |
656 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
656 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
660 | 660 | |
661 | 661 | public function load_scripts_styles_settings() { |
662 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
663 | - wp_enqueue_style( 'ee-text-links' ); |
|
664 | - wp_enqueue_style( 'ee-message-settings' ); |
|
662 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
663 | + wp_enqueue_style('ee-text-links'); |
|
664 | + wp_enqueue_style('ee-message-settings'); |
|
665 | 665 | |
666 | 666 | wp_enqueue_script('ee-messages-settings'); |
667 | 667 | } |
@@ -691,40 +691,40 @@ discard block |
||
691 | 691 | * set views array for message queue list table |
692 | 692 | */ |
693 | 693 | public function _set_list_table_views_default() { |
694 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
694 | + EE_Registry::instance()->load_helper('Template'); |
|
695 | 695 | |
696 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
696 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
697 | 697 | ? array( |
698 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
699 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
700 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
701 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
698 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
699 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
700 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
701 | + 'send_now' => __('Send Now', 'event_espresso') |
|
702 | 702 | ) |
703 | 703 | : array(); |
704 | 704 | |
705 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
706 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
705 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
706 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
707 | 707 | : array(); |
708 | 708 | |
709 | 709 | |
710 | 710 | $this->_views = array( |
711 | 711 | 'all' => array( |
712 | 712 | 'slug' => 'all', |
713 | - 'label' => __( 'All', 'event_espresso' ), |
|
713 | + 'label' => __('All', 'event_espresso'), |
|
714 | 714 | 'count' => 0, |
715 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
715 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
716 | 716 | ) |
717 | 717 | ); |
718 | 718 | |
719 | 719 | |
720 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
721 | - if ( $status === EEM_Message::status_debug_only && ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) ) { |
|
720 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
721 | + if ($status === EEM_Message::status_debug_only && ( ! defined('WP_DEBUG') || ! WP_DEBUG)) { |
|
722 | 722 | continue; |
723 | 723 | } |
724 | 724 | $status_bulk_actions = $common_bulk_actions; |
725 | 725 | //unset bulk actions not applying to status |
726 | - if ( ! empty( $status_bulk_actions ) ) { |
|
727 | - switch ( $status ) { |
|
726 | + if ( ! empty($status_bulk_actions)) { |
|
727 | + switch ($status) { |
|
728 | 728 | case EEM_Message::status_idle : |
729 | 729 | case EEM_Message::status_resend : |
730 | 730 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -736,21 +736,21 @@ discard block |
||
736 | 736 | break; |
737 | 737 | |
738 | 738 | case EEM_Message::status_incomplete : |
739 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
739 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
740 | 740 | break; |
741 | 741 | |
742 | 742 | case EEM_Message::status_retry : |
743 | 743 | case EEM_Message::status_sent : |
744 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
744 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
745 | 745 | break; |
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | - $this->_views[ strtolower( $status ) ] = array( |
|
750 | - 'slug' => strtolower( $status ), |
|
751 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
749 | + $this->_views[strtolower($status)] = array( |
|
750 | + 'slug' => strtolower($status), |
|
751 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
752 | 752 | 'count' => 0, |
753 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
753 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
754 | 754 | ); |
755 | 755 | } |
756 | 756 | } |
@@ -769,8 +769,8 @@ discard block |
||
769 | 769 | protected function _message_queue_list_table() { |
770 | 770 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
771 | 771 | $this->_template_args['per_column'] = 6; |
772 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
773 | - $this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>'; |
|
772 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
773 | + $this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>'; |
|
774 | 774 | $this->display_admin_list_table_page_with_no_sidebar(); |
775 | 775 | } |
776 | 776 | |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
784 | 784 | $action_items = array(); |
785 | 785 | |
786 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
787 | - if ( $action_item === 'see_notifications_for' ) { |
|
786 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
787 | + if ($action_item === 'see_notifications_for') { |
|
788 | 788 | continue; |
789 | 789 | } |
790 | 790 | $action_items[$action_item] = array( |
@@ -796,37 +796,37 @@ discard block |
||
796 | 796 | /** @type array $status_items status legend setup*/ |
797 | 797 | $status_items = array( |
798 | 798 | 'sent_status' => array( |
799 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
800 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' ) |
|
799 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
800 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence') |
|
801 | 801 | ), |
802 | 802 | 'idle_status' => array( |
803 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
804 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' ) |
|
803 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
804 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence') |
|
805 | 805 | ), |
806 | 806 | 'failed_status' => array( |
807 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
808 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' ) |
|
807 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
808 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence') |
|
809 | 809 | ), |
810 | 810 | 'resend_status' => array( |
811 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
812 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' ) |
|
811 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
812 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence') |
|
813 | 813 | ), |
814 | 814 | 'incomplete_status' => array( |
815 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
816 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' ) |
|
815 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
816 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence') |
|
817 | 817 | ), |
818 | 818 | 'retry_status' => array( |
819 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
820 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' ) |
|
819 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
820 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence') |
|
821 | 821 | ) |
822 | 822 | ); |
823 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
823 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
824 | 824 | $status_items['debug_only_status'] = array( |
825 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only, |
|
826 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' ) |
|
825 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only, |
|
826 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence') |
|
827 | 827 | ); |
828 | 828 | } |
829 | - return array_merge( $action_items, $status_items ); |
|
829 | + return array_merge($action_items, $status_items); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -836,9 +836,9 @@ discard block |
||
836 | 836 | |
837 | 837 | protected function _custom_mtps_preview() { |
838 | 838 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
839 | - $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' ) . '" />'; |
|
839 | + $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').'" />'; |
|
840 | 840 | $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>'; |
841 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
841 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | |
@@ -862,31 +862,31 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @return array |
864 | 864 | */ |
865 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
865 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
866 | 866 | |
867 | 867 | $MTP = EEM_Message_Template_Group::instance(); |
868 | 868 | |
869 | 869 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
870 | 870 | $orderby = $this->_req_data['orderby']; |
871 | 871 | |
872 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
872 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
873 | 873 | |
874 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
875 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
874 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
875 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
876 | 876 | |
877 | - $offset = ($current_page-1)*$per_page; |
|
878 | - $limit = $all ? null : array( $offset, $per_page ); |
|
877 | + $offset = ($current_page - 1) * $per_page; |
|
878 | + $limit = $all ? null : array($offset, $per_page); |
|
879 | 879 | |
880 | 880 | |
881 | 881 | //options will match what is in the _views array property |
882 | - switch( $type ) { |
|
882 | + switch ($type) { |
|
883 | 883 | |
884 | 884 | case 'in_use': |
885 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
885 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
886 | 886 | break; |
887 | 887 | |
888 | 888 | default: |
889 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
889 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
890 | 890 | |
891 | 891 | } |
892 | 892 | |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
906 | 906 | $installed = array(); |
907 | 907 | |
908 | - foreach ( $installed_message_types as $message_type ) { |
|
909 | - $installed[ $message_type->name ] = $message_type; |
|
908 | + foreach ($installed_message_types as $message_type) { |
|
909 | + $installed[$message_type->name] = $message_type; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | return $installed; |
@@ -925,24 +925,24 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @throws EE_error |
927 | 927 | */ |
928 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
928 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
929 | 929 | //set values override any request data |
930 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
931 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
930 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
931 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
932 | 932 | |
933 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
934 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
933 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
934 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
935 | 935 | |
936 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
937 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
936 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
937 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
938 | 938 | |
939 | 939 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
940 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
941 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
940 | + if (empty($message_type) || empty($messenger)) |
|
941 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
942 | 942 | |
943 | 943 | //we need the GRP_ID for the template being used as the base for the new template |
944 | - if ( empty( $GRP_ID ) ) |
|
945 | - {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' ) );} |
|
944 | + if (empty($GRP_ID)) |
|
945 | + {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')); } |
|
946 | 946 | |
947 | 947 | //let's just make sure the template gets generated! |
948 | 948 | |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
964 | 964 | * off of. |
965 | 965 | */ |
966 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
967 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
966 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
967 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @return void |
976 | 976 | */ |
977 | 977 | protected function _edit_message_template() { |
978 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
978 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
979 | 979 | $template_fields = ''; |
980 | 980 | $sidebar_fields = ''; |
981 | 981 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
982 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
982 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
983 | 983 | |
984 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) |
|
985 | - ? absint( $this->_req_data['id'] ) |
|
984 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) |
|
985 | + ? absint($this->_req_data['id']) |
|
986 | 986 | : false; |
987 | 987 | |
988 | 988 | $this->_set_shortcodes(); //this also sets the _message_template property. |
@@ -990,20 +990,20 @@ discard block |
||
990 | 990 | $c_label = $message_template_group->context_label(); |
991 | 991 | $c_config = $message_template_group->contexts_config(); |
992 | 992 | |
993 | - reset( $c_config ); |
|
994 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) |
|
993 | + reset($c_config); |
|
994 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) |
|
995 | 995 | ? strtolower($this->_req_data['context']) |
996 | 996 | : key($c_config); |
997 | 997 | |
998 | 998 | |
999 | - if ( empty($GRP_ID) ) { |
|
999 | + if (empty($GRP_ID)) { |
|
1000 | 1000 | $action = 'insert_message_template'; |
1001 | 1001 | //$button_both = false; |
1002 | 1002 | //$button_text = array( __( 'Save','event_espresso') ); |
1003 | 1003 | //$button_actions = array('something_different'); |
1004 | 1004 | //$referrer = false; |
1005 | 1005 | $edit_message_template_form_url = add_query_arg( |
1006 | - array( 'action' => $action, 'noheader' => true ), |
|
1006 | + array('action' => $action, 'noheader' => true), |
|
1007 | 1007 | EE_MSG_ADMIN_URL |
1008 | 1008 | ); |
1009 | 1009 | } else { |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | //$button_actions = array(); |
1014 | 1014 | //$referrer = $this->_admin_base_url; |
1015 | 1015 | $edit_message_template_form_url = add_query_arg( |
1016 | - array( 'action' => $action, 'noheader' => true ), |
|
1016 | + array('action' => $action, 'noheader' => true), |
|
1017 | 1017 | EE_MSG_ADMIN_URL |
1018 | 1018 | ); |
1019 | 1019 | } |
@@ -1027,14 +1027,14 @@ discard block |
||
1027 | 1027 | |
1028 | 1028 | //Do we have any validation errors? |
1029 | 1029 | $validators = $this->_get_transient(); |
1030 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1030 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1031 | 1031 | |
1032 | 1032 | |
1033 | 1033 | //we need to assemble the title from Various details |
1034 | 1034 | $context_label = sprintf( |
1035 | 1035 | __('(%s %s)', 'event_espresso'), |
1036 | 1036 | $c_config[$context]['label'], |
1037 | - ucwords($c_label['label'] ) |
|
1037 | + ucwords($c_label['label']) |
|
1038 | 1038 | ); |
1039 | 1039 | |
1040 | 1040 | $title = sprintf( |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | $message_template_group->message_type() |
1056 | 1056 | ); |
1057 | 1057 | |
1058 | - if ( !$template_field_structure ) { |
|
1058 | + if ( ! $template_field_structure) { |
|
1059 | 1059 | $template_field_structure = false; |
1060 | 1060 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1061 | 1061 | } |
@@ -1065,51 +1065,51 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | |
1067 | 1067 | //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. |
1068 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1069 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1070 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1068 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1069 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1070 | + unset($template_field_structure[$context][$reference_field]); |
|
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | //let's loop through the template_field_structure and actually assemble the input fields! |
1075 | - if ( !empty($template_field_structure) ) { |
|
1076 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1075 | + if ( ! empty($template_field_structure)) { |
|
1076 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1077 | 1077 | //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. |
1078 | - if ( $template_field == 'extra' ) { |
|
1078 | + if ($template_field == 'extra') { |
|
1079 | 1079 | $this->_template_args['is_extra_fields'] = true; |
1080 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1081 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1080 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1081 | + $message_template = $message_templates[$context][$reference_field]; |
|
1082 | 1082 | $content = $message_template instanceof EE_Message_Template |
1083 | - ? $message_template->get( 'MTP_content' ) |
|
1083 | + ? $message_template->get('MTP_content') |
|
1084 | 1084 | : ''; |
1085 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1085 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1086 | 1086 | //let's verify if we need this extra field via the shortcodes parameter. |
1087 | 1087 | $continue = false; |
1088 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1089 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1090 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1091 | - {$continue = true;} |
|
1088 | + if (isset($extra_array['shortcodes_required'])) { |
|
1089 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1090 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1091 | + {$continue = true; } |
|
1092 | 1092 | } |
1093 | - if ( $continue ) {continue;} |
|
1093 | + if ($continue) {continue; } |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1096 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1097 | 1097 | $template_form_fields[$field_id] = $extra_array; |
1098 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1099 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1098 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1099 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1100 | 1100 | |
1101 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1101 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1102 | 1102 | && in_array($extra_field, $v_fields) |
1103 | 1103 | && |
1104 | 1104 | ( |
1105 | - is_array($validators[$extra_field] ) |
|
1106 | - && isset( $validators[$extra_field]['msg'] ) |
|
1105 | + is_array($validators[$extra_field]) |
|
1106 | + && isset($validators[$extra_field]['msg']) |
|
1107 | 1107 | ) |
1108 | - ? 'validate-error ' . $css_class |
|
1108 | + ? 'validate-error '.$css_class |
|
1109 | 1109 | : $css_class; |
1110 | 1110 | |
1111 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1112 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1111 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1112 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1113 | 1113 | : ''; |
1114 | 1114 | |
1115 | 1115 | //do we have a validation error? if we do then let's use that value instead |
@@ -1125,32 +1125,32 @@ discard block |
||
1125 | 1125 | $field_id |
1126 | 1126 | ); |
1127 | 1127 | |
1128 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1128 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1129 | 1129 | //we want to decode the entities |
1130 | 1130 | $template_form_fields[$field_id]['value'] = stripslashes( |
1131 | - html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1131 | + html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1132 | 1132 | ); |
1133 | 1133 | |
1134 | 1134 | }/**/ |
1135 | 1135 | } |
1136 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1137 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1136 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1137 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1138 | 1138 | |
1139 | 1139 | $template_form_fields[$templatefield_MTP_id] = array( |
1140 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1140 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1141 | 1141 | 'label' => null, |
1142 | 1142 | 'input' => 'hidden', |
1143 | 1143 | 'type' => 'int', |
1144 | 1144 | 'required' => false, |
1145 | 1145 | 'validation' => false, |
1146 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1146 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1147 | 1147 | 'css_class' => '', |
1148 | 1148 | 'format' => '%d', |
1149 | 1149 | 'db-col' => 'MTP_ID' |
1150 | 1150 | ); |
1151 | 1151 | |
1152 | 1152 | $template_form_fields[$templatefield_templatename_id] = array( |
1153 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1153 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1154 | 1154 | 'label' => null, |
1155 | 1155 | 'input' => 'hidden', |
1156 | 1156 | 'type' => 'string', |
@@ -1164,14 +1164,14 @@ discard block |
||
1164 | 1164 | } |
1165 | 1165 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1166 | 1166 | } else { |
1167 | - $field_id = $template_field . '-content'; |
|
1167 | + $field_id = $template_field.'-content'; |
|
1168 | 1168 | $template_form_fields[$field_id] = $field_setup_array; |
1169 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1170 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1171 | - ? $message_templates[ $context ][ $template_field ] |
|
1169 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1170 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1171 | + ? $message_templates[$context][$template_field] |
|
1172 | 1172 | : null; |
1173 | - $template_form_fields[$field_id]['value'] = ! empty( $message_templates ) |
|
1174 | - && is_array( $message_templates[$context] ) |
|
1173 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
|
1174 | + && is_array($message_templates[$context]) |
|
1175 | 1175 | && $message_template instanceof EE_Message_Template |
1176 | 1176 | ? $message_template->get('MTP_content') |
1177 | 1177 | : ''; |
@@ -1184,10 +1184,10 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1186 | 1186 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1187 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1188 | - && in_array( $template_field, $v_fields ) |
|
1189 | - && isset( $validators[$template_field]['msg'] ) |
|
1190 | - ? 'validate-error ' . $css_class |
|
1187 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1188 | + && in_array($template_field, $v_fields) |
|
1189 | + && isset($validators[$template_field]['msg']) |
|
1190 | + ? 'validate-error '.$css_class |
|
1191 | 1191 | : $css_class; |
1192 | 1192 | |
1193 | 1193 | //shortcode selector |
@@ -1198,12 +1198,12 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | //k took care of content field(s) now let's take care of others. |
1200 | 1200 | |
1201 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1202 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1201 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1202 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1203 | 1203 | |
1204 | 1204 | //foreach template field there are actually two form fields created |
1205 | 1205 | $template_form_fields[$templatefield_MTP_id] = array( |
1206 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1206 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1207 | 1207 | 'label' => null, |
1208 | 1208 | 'input' => 'hidden', |
1209 | 1209 | 'type' => 'int', |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | ); |
1217 | 1217 | |
1218 | 1218 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1219 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1219 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1220 | 1220 | 'label' => null, |
1221 | 1221 | 'input' => 'hidden', |
1222 | 1222 | 'type' => 'string', |
@@ -1360,13 +1360,13 @@ discard block |
||
1360 | 1360 | 'value' => $GRP_ID |
1361 | 1361 | ); |
1362 | 1362 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1363 | - 'name' => $action . '_nonce', |
|
1363 | + 'name' => $action.'_nonce', |
|
1364 | 1364 | 'input' => 'hidden', |
1365 | 1365 | 'type' => 'string', |
1366 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1366 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1367 | 1367 | ); |
1368 | 1368 | |
1369 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1369 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1370 | 1370 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1371 | 1371 | 'name' => 'template_switch', |
1372 | 1372 | 'input' => 'hidden', |
@@ -1376,8 +1376,8 @@ discard block |
||
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | |
1379 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1380 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1379 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1380 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1381 | 1381 | |
1382 | 1382 | |
1383 | 1383 | } //end if ( !empty($template_field_structure) ) |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | $GRP_ID, |
1390 | 1390 | false, |
1391 | 1391 | add_query_arg( |
1392 | - array( 'action' => 'global_mtps' ), |
|
1392 | + array('action' => 'global_mtps'), |
|
1393 | 1393 | $this->_admin_base_url |
1394 | 1394 | ) |
1395 | 1395 | ); |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | ), |
1406 | 1406 | $this->_admin_base_url |
1407 | 1407 | ); |
1408 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1408 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1409 | 1409 | |
1410 | 1410 | |
1411 | 1411 | //setup context switcher |
@@ -1433,17 +1433,17 @@ discard block |
||
1433 | 1433 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1434 | 1434 | |
1435 | 1435 | $this->_template_path = $this->_template_args['GRP_ID'] |
1436 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1437 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1436 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1437 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1438 | 1438 | |
1439 | 1439 | //send along EE_Message_Template_Group object for further template use. |
1440 | 1440 | $this->_template_args['MTP'] = $message_template_group; |
1441 | 1441 | |
1442 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1442 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1443 | 1443 | |
1444 | 1444 | |
1445 | 1445 | //finally, let's set the admin_page title |
1446 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1446 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1447 | 1447 | |
1448 | 1448 | |
1449 | 1449 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | |
1459 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1459 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1460 | 1460 | return $mceInit; |
1461 | 1461 | } |
1462 | 1462 | |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | public function _add_form_element_before() { |
1470 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1470 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | public function _add_form_element_after() { |
@@ -1484,25 +1484,25 @@ discard block |
||
1484 | 1484 | * |
1485 | 1485 | */ |
1486 | 1486 | public function switch_template_pack() { |
1487 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1488 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1487 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1488 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1489 | 1489 | |
1490 | 1490 | //verify we have needed values. |
1491 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1491 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1492 | 1492 | $this->_template_args['error'] = true; |
1493 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1493 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1494 | 1494 | } else { |
1495 | 1495 | //get template, set the new template_pack and then reset to default |
1496 | 1496 | /** @type EE_Message_Template_Group $message_template_group */ |
1497 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1497 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1498 | 1498 | |
1499 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1499 | + $message_template_group->set_template_pack_name($template_pack); |
|
1500 | 1500 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1501 | 1501 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1502 | 1502 | |
1503 | 1503 | $query_args = $this->_reset_to_default_template(); |
1504 | 1504 | |
1505 | - if ( empty( $query_args['id'] ) ) { |
|
1505 | + if (empty($query_args['id'])) { |
|
1506 | 1506 | EE_Error::add_error( |
1507 | 1507 | __( |
1508 | 1508 | 'Something went wrong with switching the template pack. Please try again or contact EE support', |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | ); |
1513 | 1513 | $this->_template_args['error'] = true; |
1514 | 1514 | } else { |
1515 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1515 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1516 | 1516 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1517 | 1517 | EE_Error::add_success( |
1518 | 1518 | sprintf( |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | ) |
1526 | 1526 | ); |
1527 | 1527 | //generate the redirect url for js. |
1528 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1528 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1529 | 1529 | $this->_template_args['data']['redirect_url'] = $url; |
1530 | 1530 | $this->_template_args['success'] = true; |
1531 | 1531 | } |
@@ -1547,9 +1547,9 @@ discard block |
||
1547 | 1547 | protected function _reset_to_default_template() { |
1548 | 1548 | |
1549 | 1549 | $templates = array(); |
1550 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1550 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1551 | 1551 | //we need to make sure we've got the info we need. |
1552 | - if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) { |
|
1552 | + if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) { |
|
1553 | 1553 | EE_Error::add_error( |
1554 | 1554 | __( |
1555 | 1555 | '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.', |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | |
1562 | 1562 | // all templates will be reset to whatever the defaults are |
1563 | 1563 | // for the global template matching the messenger and message type. |
1564 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1564 | + $success = ! empty($GRP_ID) ? true : false; |
|
1565 | 1565 | |
1566 | - if ( $success ) { |
|
1566 | + if ($success) { |
|
1567 | 1567 | |
1568 | 1568 | //let's first determine if the incoming template is a global template, |
1569 | 1569 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1571,9 +1571,9 @@ discard block |
||
1571 | 1571 | |
1572 | 1572 | |
1573 | 1573 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1574 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1574 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1575 | 1575 | |
1576 | - if ( $success ) { |
|
1576 | + if ($success) { |
|
1577 | 1577 | // if successfully deleted, lets generate the new ones. |
1578 | 1578 | // Note. We set GLOBAL to true, because resets on ANY template |
1579 | 1579 | // will use the related global template defaults for regeneration. |
@@ -1591,32 +1591,32 @@ discard block |
||
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | //any error messages? |
1594 | - if ( !$success ) { |
|
1594 | + if ( ! $success) { |
|
1595 | 1595 | EE_Error::add_error( |
1596 | - __( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ), |
|
1596 | + __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), |
|
1597 | 1597 | __FILE__, __FUNCTION__, __LINE__ |
1598 | 1598 | ); |
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | //all good, let's add a success message! |
1602 | - if ( $success && ! empty( $templates ) ) { |
|
1602 | + if ($success && ! empty($templates)) { |
|
1603 | 1603 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1604 | 1604 | EE_Error::overwrite_success(); |
1605 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1605 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1606 | 1606 | } |
1607 | 1607 | |
1608 | 1608 | |
1609 | 1609 | $query_args = array( |
1610 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1611 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1612 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1610 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1611 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1612 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1613 | 1613 | ); |
1614 | 1614 | |
1615 | 1615 | //if called via ajax then we return query args otherwise redirect |
1616 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1616 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1617 | 1617 | return $query_args; |
1618 | 1618 | } else { |
1619 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1619 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1620 | 1620 | return null; |
1621 | 1621 | } |
1622 | 1622 | } |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1630 | 1630 | * @return string |
1631 | 1631 | */ |
1632 | - public function _preview_message( $send = false ) { |
|
1632 | + public function _preview_message($send = false) { |
|
1633 | 1633 | //first make sure we've got the necessary parameters |
1634 | 1634 | if ( |
1635 | 1635 | ! isset( |
@@ -1645,13 +1645,13 @@ discard block |
||
1645 | 1645 | ); |
1646 | 1646 | } |
1647 | 1647 | |
1648 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1648 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1649 | 1649 | |
1650 | 1650 | |
1651 | 1651 | //get the preview! |
1652 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1652 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1653 | 1653 | |
1654 | - if ( $send ) { |
|
1654 | + if ($send) { |
|
1655 | 1655 | return $preview; |
1656 | 1656 | } |
1657 | 1657 | |
@@ -1661,22 +1661,22 @@ discard block |
||
1661 | 1661 | 'context' => $this->_req_data['context'], |
1662 | 1662 | 'action' => 'edit_message_template' |
1663 | 1663 | ); |
1664 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1665 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1664 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1665 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1666 | 1666 | $message_types = $this->get_installed_message_types(); |
1667 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
1667 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
1668 | 1668 | $active_messenger_label = $active_messenger instanceof EE_messenger |
1669 | - ? ucwords( $active_messenger->label['singular'] ) |
|
1670 | - : esc_html__( 'Unknown Messenger', 'event_espresso' ); |
|
1669 | + ? ucwords($active_messenger->label['singular']) |
|
1670 | + : esc_html__('Unknown Messenger', 'event_espresso'); |
|
1671 | 1671 | //let's provide a helpful title for context |
1672 | 1672 | $preview_title = sprintf( |
1673 | - __( 'Viewing Preview for %s %s Message Template', 'event_espresso' ), |
|
1673 | + __('Viewing Preview for %s %s Message Template', 'event_espresso'), |
|
1674 | 1674 | $active_messenger_label, |
1675 | - ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] ) |
|
1675 | + ucwords($message_types[$this->_req_data['message_type']]->label['singular']) |
|
1676 | 1676 | ); |
1677 | 1677 | //setup display of preview. |
1678 | 1678 | $this->_admin_page_title = $preview_title; |
1679 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1679 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1680 | 1680 | $this->_template_args['data']['force_json'] = true; |
1681 | 1681 | return ''; |
1682 | 1682 | } |
@@ -1706,9 +1706,9 @@ discard block |
||
1706 | 1706 | * @return void |
1707 | 1707 | */ |
1708 | 1708 | protected function _register_edit_meta_boxes() { |
1709 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1710 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1711 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1709 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1710 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1711 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | |
@@ -1727,14 +1727,14 @@ discard block |
||
1727 | 1727 | |
1728 | 1728 | $tp_select_values = array(); |
1729 | 1729 | |
1730 | - foreach ( $tp_collection as $tp ) { |
|
1730 | + foreach ($tp_collection as $tp) { |
|
1731 | 1731 | //only include template packs that support this messenger and message type! |
1732 | 1732 | $supports = $tp->get_supports(); |
1733 | 1733 | if ( |
1734 | - ! isset( $supports[ $this->_message_template_group->messenger() ] ) |
|
1734 | + ! isset($supports[$this->_message_template_group->messenger()]) |
|
1735 | 1735 | || ! in_array( |
1736 | 1736 | $this->_message_template_group->message_type(), |
1737 | - $supports[ $this->_message_template_group->messenger() ] |
|
1737 | + $supports[$this->_message_template_group->messenger()] |
|
1738 | 1738 | ) |
1739 | 1739 | ) { |
1740 | 1740 | //not supported |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | //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. |
1751 | - if ( empty( $tp_select_values ) ) { |
|
1751 | + if (empty($tp_select_values)) { |
|
1752 | 1752 | $tp_select_values[] = array( |
1753 | 1753 | 'text' => __('Default', 'event_espresso'), |
1754 | 1754 | 'id' => 'default' |
@@ -1761,14 +1761,14 @@ discard block |
||
1761 | 1761 | $this->_message_template_group->message_type() |
1762 | 1762 | ); |
1763 | 1763 | $variations_select_values = array(); |
1764 | - foreach ( $variations as $variation => $label ) { |
|
1764 | + foreach ($variations as $variation => $label) { |
|
1765 | 1765 | $variations_select_values[] = array( |
1766 | 1766 | 'text' => $label, |
1767 | 1767 | 'id' => $variation |
1768 | 1768 | ); |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1771 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1772 | 1772 | |
1773 | 1773 | $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( |
1774 | 1774 | 'MTP_template_pack', |
@@ -1785,9 +1785,9 @@ discard block |
||
1785 | 1785 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1786 | 1786 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1787 | 1787 | |
1788 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1788 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1789 | 1789 | |
1790 | - EEH_Template::display_template( $template, $template_args ); |
|
1790 | + EEH_Template::display_template($template, $template_args); |
|
1791 | 1791 | } |
1792 | 1792 | |
1793 | 1793 | |
@@ -1818,47 +1818,47 @@ discard block |
||
1818 | 1818 | //first we need to see if there are any fields |
1819 | 1819 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1820 | 1820 | |
1821 | - if ( !empty( $fields ) ) { |
|
1821 | + if ( ! empty($fields)) { |
|
1822 | 1822 | //yup there be fields |
1823 | - foreach ( $fields as $field => $config ) { |
|
1824 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1823 | + foreach ($fields as $field => $config) { |
|
1824 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1825 | 1825 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1826 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1827 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1826 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1827 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1828 | 1828 | |
1829 | 1829 | //if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults |
1830 | 1830 | $fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : ''; |
1831 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix; |
|
1831 | + $existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix; |
|
1832 | 1832 | |
1833 | 1833 | $template_form_fields[$field_id] = array( |
1834 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1834 | + 'name' => 'test_settings_fld['.$field.']', |
|
1835 | 1835 | 'label' => $config['label'], |
1836 | 1836 | 'input' => $config['input'], |
1837 | 1837 | 'type' => $config['type'], |
1838 | 1838 | 'required' => $config['required'], |
1839 | 1839 | 'validation' => $config['validation'], |
1840 | - 'value' => isset( $existing[$field] ) ? $existing[$field] : $default, |
|
1840 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1841 | 1841 | 'css_class' => $config['css_class'], |
1842 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1842 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1843 | 1843 | 'default' => $default, |
1844 | 1844 | 'format' => $config['format'] |
1845 | 1845 | ); |
1846 | 1846 | } |
1847 | 1847 | } |
1848 | 1848 | |
1849 | - $test_settings_fields = !empty( $template_form_fields) |
|
1850 | - ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) |
|
1849 | + $test_settings_fields = ! empty($template_form_fields) |
|
1850 | + ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') |
|
1851 | 1851 | : ''; |
1852 | 1852 | |
1853 | 1853 | $test_settings_html = ''; |
1854 | 1854 | //print out $test_settings_fields |
1855 | - if ( !empty( $test_settings_fields ) ) { |
|
1855 | + if ( ! empty($test_settings_fields)) { |
|
1856 | 1856 | echo $test_settings_fields; |
1857 | - $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>'; |
|
1857 | + $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>'; |
|
1858 | 1858 | } |
1859 | 1859 | |
1860 | 1860 | //and button |
1861 | - 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>'; |
|
1861 | + 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>'; |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | |
@@ -1873,13 +1873,13 @@ discard block |
||
1873 | 1873 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
1874 | 1874 | * @return string |
1875 | 1875 | */ |
1876 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
1876 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
1877 | 1877 | $template_args = array( |
1878 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
1878 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
1879 | 1879 | 'fieldname' => $field, |
1880 | 1880 | 'linked_input_id' => $linked_input_id |
1881 | 1881 | ); |
1882 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
1882 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
1883 | 1883 | } |
1884 | 1884 | |
1885 | 1885 | |
@@ -1894,13 +1894,13 @@ discard block |
||
1894 | 1894 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
1895 | 1895 | //$messenger = $this->_message_template_group->messenger_obj(); |
1896 | 1896 | //now let's set the content depending on the status of the shortcodes array |
1897 | - if ( empty( $shortcodes ) ) { |
|
1898 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
1897 | + if (empty($shortcodes)) { |
|
1898 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
1899 | 1899 | echo $content; |
1900 | 1900 | } else { |
1901 | 1901 | //$alt = 0; |
1902 | 1902 | ?> |
1903 | - <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> |
|
1903 | + <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> |
|
1904 | 1904 | <?php |
1905 | 1905 | } |
1906 | 1906 | |
@@ -1917,7 +1917,7 @@ discard block |
||
1917 | 1917 | protected function _set_shortcodes() { |
1918 | 1918 | |
1919 | 1919 | //no need to run this if the property is already set |
1920 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
1920 | + if ( ! empty($this->_shortcodes)) {return; } |
|
1921 | 1921 | |
1922 | 1922 | $this->_shortcodes = $this->_get_shortcodes(); |
1923 | 1923 | } |
@@ -1939,14 +1939,14 @@ discard block |
||
1939 | 1939 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
1940 | 1940 | * just an array of shortcode/label pairs. |
1941 | 1941 | */ |
1942 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
1942 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
1943 | 1943 | $this->_set_message_template_group(); |
1944 | 1944 | |
1945 | 1945 | //we need the messenger and message template to retrieve the valid shortcodes array. |
1946 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1947 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
1946 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1947 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
1948 | 1948 | |
1949 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
1949 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
1950 | 1950 | } |
1951 | 1951 | |
1952 | 1952 | |
@@ -1959,19 +1959,19 @@ discard block |
||
1959 | 1959 | */ |
1960 | 1960 | protected function _set_message_template_group() { |
1961 | 1961 | |
1962 | - if ( !empty( $this->_message_template_group ) ) |
|
1963 | - {return;} //get out if this is already set. |
|
1962 | + if ( ! empty($this->_message_template_group)) |
|
1963 | + {return; } //get out if this is already set. |
|
1964 | 1964 | |
1965 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
1966 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
1965 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
1966 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
1967 | 1967 | |
1968 | 1968 | //let's get the message templates |
1969 | 1969 | $MTP = EEM_Message_Template_Group::instance(); |
1970 | 1970 | |
1971 | - if ( empty($GRP_ID) ) |
|
1972 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
1971 | + if (empty($GRP_ID)) |
|
1972 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
1973 | 1973 | else |
1974 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
1974 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
1975 | 1975 | |
1976 | 1976 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
1977 | 1977 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | * @param array $args various things the context switcher needs. |
1991 | 1991 | * |
1992 | 1992 | */ |
1993 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
1993 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
1994 | 1994 | $context_details = $template_group_object->contexts_config(); |
1995 | 1995 | $context_label = $template_group_object->context_label(); |
1996 | 1996 | ob_start(); |
@@ -1998,20 +1998,20 @@ discard block |
||
1998 | 1998 | <div class="ee-msg-switcher-container"> |
1999 | 1999 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
2000 | 2000 | <?php |
2001 | - foreach ( $args as $name => $value ) { |
|
2002 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
2001 | + foreach ($args as $name => $value) { |
|
2002 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
2003 | 2003 | ?> |
2004 | 2004 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
2005 | 2005 | <?php |
2006 | 2006 | } |
2007 | 2007 | //setup nonce_url |
2008 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
2008 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
2009 | 2009 | ?> |
2010 | 2010 | <select name="context"> |
2011 | 2011 | <?php |
2012 | 2012 | $context_templates = $template_group_object->context_templates(); |
2013 | - if ( is_array($context_templates) ) : |
|
2014 | - foreach ( $context_templates as $context => $template_fields ) : |
|
2013 | + if (is_array($context_templates)) : |
|
2014 | + foreach ($context_templates as $context => $template_fields) : |
|
2015 | 2015 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
2016 | 2016 | ?> |
2017 | 2017 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>> |
@@ -2019,7 +2019,7 @@ discard block |
||
2019 | 2019 | </option> |
2020 | 2020 | <?php endforeach; endif; ?> |
2021 | 2021 | </select> |
2022 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
2022 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
2023 | 2023 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
2024 | 2024 | </form> |
2025 | 2025 | <?php echo $args['extra']; ?> |
@@ -2046,8 +2046,8 @@ discard block |
||
2046 | 2046 | * @return array |
2047 | 2047 | */ |
2048 | 2048 | protected function _set_message_template_column_values($index) { |
2049 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
2050 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
2049 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
2050 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
2051 | 2051 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
2052 | 2052 | } |
2053 | 2053 | } /*else { |
@@ -2056,22 +2056,22 @@ discard block |
||
2056 | 2056 | |
2057 | 2057 | |
2058 | 2058 | $set_column_values = array( |
2059 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
2060 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
2061 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
2062 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
2063 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
2064 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
2065 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
2066 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
2067 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
2068 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
2059 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
2060 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
2061 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
2062 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
2063 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
2064 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
2065 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
2066 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
2067 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
2068 | + ? absint($this->_req_data['MTP_is_global']) |
|
2069 | 2069 | : 0, |
2070 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
2071 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
2070 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
2071 | + ? absint($this->_req_data['MTP_is_override']) |
|
2072 | 2072 | : 0, |
2073 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
2074 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
2073 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
2074 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
2075 | 2075 | ); |
2076 | 2076 | |
2077 | 2077 | |
@@ -2083,36 +2083,36 @@ discard block |
||
2083 | 2083 | |
2084 | 2084 | |
2085 | 2085 | |
2086 | - protected function _insert_or_update_message_template($new = false ) { |
|
2086 | + protected function _insert_or_update_message_template($new = false) { |
|
2087 | 2087 | |
2088 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2088 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2089 | 2089 | $success = 0; |
2090 | 2090 | $override = false; |
2091 | 2091 | |
2092 | 2092 | //setup notices description |
2093 | - $messenger = ! empty( $this->_req_data['MTP_messenger'] ) |
|
2094 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_messenger'] ) ) |
|
2093 | + $messenger = ! empty($this->_req_data['MTP_messenger']) |
|
2094 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) |
|
2095 | 2095 | : false; |
2096 | 2096 | |
2097 | - $message_type = ! empty( $this->_req_data['MTP_message_type'] ) |
|
2098 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_message_type'] ) ) |
|
2097 | + $message_type = ! empty($this->_req_data['MTP_message_type']) |
|
2098 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) |
|
2099 | 2099 | : false; |
2100 | 2100 | |
2101 | - $context = ! empty( $this->_req_data['MTP_context'] ) |
|
2102 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_context'] ) ) |
|
2101 | + $context = ! empty($this->_req_data['MTP_context']) |
|
2102 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) |
|
2103 | 2103 | : false; |
2104 | 2104 | |
2105 | - $item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : ''; |
|
2105 | + $item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : ''; |
|
2106 | 2106 | $item_desc .= 'Message Template'; |
2107 | 2107 | $query_args = array(); |
2108 | 2108 | $edit_array = array(); |
2109 | 2109 | $action_desc = ''; |
2110 | 2110 | |
2111 | 2111 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2112 | - if ( $new ) { |
|
2113 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2114 | - if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) { |
|
2115 | - if ( empty($edit_array) ) { |
|
2112 | + if ($new) { |
|
2113 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2114 | + if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) { |
|
2115 | + if (empty($edit_array)) { |
|
2116 | 2116 | $success = 0; |
2117 | 2117 | } else { |
2118 | 2118 | $success = 1; |
@@ -2131,7 +2131,7 @@ discard block |
||
2131 | 2131 | |
2132 | 2132 | |
2133 | 2133 | //run update for each template field in displayed context |
2134 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2134 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2135 | 2135 | EE_Error::add_error( |
2136 | 2136 | __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), |
2137 | 2137 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2140,25 +2140,25 @@ discard block |
||
2140 | 2140 | |
2141 | 2141 | } else { |
2142 | 2142 | //first validate all fields! |
2143 | - $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']); |
|
2143 | + $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']); |
|
2144 | 2144 | |
2145 | 2145 | //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. |
2146 | - if ( is_array($validates) && !empty($validates) ) { |
|
2146 | + if (is_array($validates) && ! empty($validates)) { |
|
2147 | 2147 | //add the transient so when the form loads we know which fields to highlight |
2148 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2148 | + $this->_add_transient('edit_message_template', $validates); |
|
2149 | 2149 | |
2150 | 2150 | $success = 0; |
2151 | 2151 | |
2152 | 2152 | //setup notices |
2153 | - foreach ( $validates as $field => $error ) { |
|
2154 | - if ( isset($error['msg'] ) ) { |
|
2155 | - EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ ); |
|
2153 | + foreach ($validates as $field => $error) { |
|
2154 | + if (isset($error['msg'])) { |
|
2155 | + EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); |
|
2156 | 2156 | } |
2157 | 2157 | } |
2158 | 2158 | |
2159 | 2159 | } else { |
2160 | 2160 | $set_column_values = array(); |
2161 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2161 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2162 | 2162 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2163 | 2163 | |
2164 | 2164 | $where_cols_n_values = array( |
@@ -2171,11 +2171,11 @@ discard block |
||
2171 | 2171 | 'MTP_context' => $set_column_values['MTP_context'], |
2172 | 2172 | 'MTP_content' => $set_column_values['MTP_content'] |
2173 | 2173 | ); |
2174 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2175 | - if ( $updated === false ) { |
|
2174 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2175 | + if ($updated === false) { |
|
2176 | 2176 | EE_Error::add_error( |
2177 | 2177 | sprintf( |
2178 | - __( '%s field was NOT updated for some reason', 'event_espresso' ), |
|
2178 | + __('%s field was NOT updated for some reason', 'event_espresso'), |
|
2179 | 2179 | $template_field |
2180 | 2180 | ), |
2181 | 2181 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2189,46 +2189,46 @@ discard block |
||
2189 | 2189 | |
2190 | 2190 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2191 | 2191 | $mtpg_fields = array( |
2192 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2193 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2194 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2195 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2196 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2197 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2198 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2199 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2200 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2192 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2193 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2194 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2195 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2196 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2197 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2198 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2199 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2200 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2201 | 2201 | : '', |
2202 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2203 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2202 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2203 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2204 | 2204 | : '' |
2205 | 2205 | ); |
2206 | 2206 | |
2207 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2208 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2207 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2208 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2209 | 2209 | |
2210 | - if ( $updated === false ) { |
|
2210 | + if ($updated === false) { |
|
2211 | 2211 | EE_Error::add_error( |
2212 | 2212 | sprintf( |
2213 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2214 | - $set_column_values[ 'GRP_ID' ] |
|
2213 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2214 | + $set_column_values['GRP_ID'] |
|
2215 | 2215 | ), |
2216 | 2216 | __FILE__, __FUNCTION__, __LINE__ |
2217 | 2217 | ); |
2218 | 2218 | } else { |
2219 | 2219 | //k now we need to ensure the template_pack and template_variation fields are set. |
2220 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) |
|
2220 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) |
|
2221 | 2221 | ? $this->_req_data['MTP_template_pack'] |
2222 | 2222 | : 'default'; |
2223 | 2223 | |
2224 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) |
|
2224 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) |
|
2225 | 2225 | ? $this->_req_data['MTP_template_variation'] |
2226 | 2226 | : 'default'; |
2227 | 2227 | |
2228 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2229 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2230 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2231 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2228 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2229 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2230 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2231 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2232 | 2232 | } |
2233 | 2233 | $success = 1; |
2234 | 2234 | } |
@@ -2238,7 +2238,7 @@ discard block |
||
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | //we return things differently if doing ajax |
2241 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2241 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2242 | 2242 | $this->_template_args['success'] = $success; |
2243 | 2243 | $this->_template_args['error'] = ! $success ? true : false; |
2244 | 2244 | $this->_template_args['content'] = ''; |
@@ -2246,9 +2246,9 @@ discard block |
||
2246 | 2246 | 'grpID' => $edit_array['GRP_ID'], |
2247 | 2247 | 'templateName' => $edit_array['template_name'] |
2248 | 2248 | ); |
2249 | - if ( $success ) { |
|
2249 | + if ($success) { |
|
2250 | 2250 | EE_Error::overwrite_success(); |
2251 | - 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') ); |
|
2251 | + 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')); |
|
2252 | 2252 | } |
2253 | 2253 | |
2254 | 2254 | $this->_return_json(); |
@@ -2256,13 +2256,13 @@ discard block |
||
2256 | 2256 | |
2257 | 2257 | |
2258 | 2258 | //was a test send triggered? |
2259 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2259 | + if (isset($this->_req_data['test_button'])) { |
|
2260 | 2260 | EE_Error::overwrite_success(); |
2261 | - $this->_do_test_send( $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] ); |
|
2261 | + $this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2262 | 2262 | $override = true; |
2263 | 2263 | } |
2264 | 2264 | |
2265 | - if ( empty( $query_args ) ) { |
|
2265 | + if (empty($query_args)) { |
|
2266 | 2266 | $query_args = array( |
2267 | 2267 | 'id' => $this->_req_data['GRP_ID'], |
2268 | 2268 | 'context' => $this->_req_data['MTP_context'], |
@@ -2270,7 +2270,7 @@ discard block |
||
2270 | 2270 | ); |
2271 | 2271 | } |
2272 | 2272 | |
2273 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2273 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2274 | 2274 | } |
2275 | 2275 | |
2276 | 2276 | |
@@ -2284,28 +2284,28 @@ discard block |
||
2284 | 2284 | * @param string $message_type message type being tested |
2285 | 2285 | * |
2286 | 2286 | */ |
2287 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2287 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2288 | 2288 | //set things up for preview |
2289 | 2289 | $this->_req_data['messenger'] = $messenger; |
2290 | 2290 | $this->_req_data['message_type'] = $message_type; |
2291 | 2291 | $this->_req_data['context'] = $context; |
2292 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2293 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
2292 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2293 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($messenger); |
|
2294 | 2294 | |
2295 | 2295 | //let's save any existing fields that might be required by the messenger |
2296 | 2296 | if ( |
2297 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2297 | + isset($this->_req_data['test_settings_fld']) |
|
2298 | 2298 | && $active_messenger instanceof EE_messenger |
2299 | 2299 | ) { |
2300 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2300 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2301 | 2301 | } |
2302 | 2302 | |
2303 | 2303 | $success = $this->_preview_message(true); |
2304 | 2304 | |
2305 | - if ( $success ) { |
|
2306 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2305 | + if ($success) { |
|
2306 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2307 | 2307 | } else { |
2308 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2308 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2309 | 2309 | } |
2310 | 2310 | } |
2311 | 2311 | |
@@ -2331,11 +2331,11 @@ discard block |
||
2331 | 2331 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2332 | 2332 | |
2333 | 2333 | //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. |
2334 | - if ( empty( $message_types ) ) { |
|
2334 | + if (empty($message_types)) { |
|
2335 | 2335 | return true; |
2336 | 2336 | } |
2337 | 2337 | |
2338 | - return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global ); |
|
2338 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | |
@@ -2351,33 +2351,33 @@ discard block |
||
2351 | 2351 | * |
2352 | 2352 | * @return void |
2353 | 2353 | */ |
2354 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2355 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2354 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2355 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2356 | 2356 | $MTP = EEM_Message_Template_Group::instance(); |
2357 | 2357 | |
2358 | 2358 | $success = 1; |
2359 | 2359 | |
2360 | 2360 | //incoming GRP_IDs |
2361 | - if ( $all ) { |
|
2361 | + if ($all) { |
|
2362 | 2362 | //Checkboxes |
2363 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2363 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2364 | 2364 | //if array has more than one element then success message should be plural. |
2365 | 2365 | //todo: what about nonce? |
2366 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2366 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2367 | 2367 | |
2368 | 2368 | //cycle through checkboxes |
2369 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2370 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2371 | - if ( ! $trashed_or_restored ) { |
|
2369 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2370 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2371 | + if ( ! $trashed_or_restored) { |
|
2372 | 2372 | $success = 0; |
2373 | 2373 | } |
2374 | 2374 | } |
2375 | 2375 | } else { |
2376 | 2376 | //grab single GRP_ID and handle |
2377 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2378 | - if ( ! empty( $GRP_ID ) ) { |
|
2379 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2380 | - if ( ! $trashed_or_restored ) { |
|
2377 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2378 | + if ( ! empty($GRP_ID)) { |
|
2379 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2380 | + if ( ! $trashed_or_restored) { |
|
2381 | 2381 | $success = 0; |
2382 | 2382 | } |
2383 | 2383 | } else { |
@@ -2389,13 +2389,13 @@ discard block |
||
2389 | 2389 | |
2390 | 2390 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2391 | 2391 | |
2392 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2392 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2393 | 2393 | |
2394 | 2394 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2395 | 2395 | |
2396 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2396 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2397 | 2397 | |
2398 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2398 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2399 | 2399 | |
2400 | 2400 | } |
2401 | 2401 | |
@@ -2411,24 +2411,24 @@ discard block |
||
2411 | 2411 | * @return void |
2412 | 2412 | */ |
2413 | 2413 | protected function _delete_message_template() { |
2414 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2414 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2415 | 2415 | |
2416 | 2416 | //checkboxes |
2417 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2417 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2418 | 2418 | //if array has more than one element then success message should be plural |
2419 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2419 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2420 | 2420 | |
2421 | 2421 | //cycle through bulk action checkboxes |
2422 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2423 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2422 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2423 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2424 | 2424 | } |
2425 | 2425 | } else { |
2426 | 2426 | //grab single grp_id and delete |
2427 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2428 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2427 | + $GRP_ID = absint($this->_req_data['id']); |
|
2428 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2429 | 2429 | } |
2430 | 2430 | |
2431 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2431 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2432 | 2432 | |
2433 | 2433 | } |
2434 | 2434 | |
@@ -2443,20 +2443,20 @@ discard block |
||
2443 | 2443 | * |
2444 | 2444 | * @return bool boolean to indicate the success of the deletes or not. |
2445 | 2445 | */ |
2446 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2446 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2447 | 2447 | $success = 1; |
2448 | 2448 | $MTPG = EEM_Message_Template_Group::instance(); |
2449 | 2449 | //first let's GET this group |
2450 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2450 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2451 | 2451 | //then delete permanently all the related Message Templates |
2452 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2452 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2453 | 2453 | |
2454 | - if ( $deleted === 0 ) |
|
2455 | - {$success = 0;} |
|
2454 | + if ($deleted === 0) |
|
2455 | + {$success = 0; } |
|
2456 | 2456 | |
2457 | 2457 | //now delete permanently this particular group |
2458 | 2458 | |
2459 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2459 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2460 | 2460 | $success = 0; |
2461 | 2461 | } |
2462 | 2462 | return $success; |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | * @return string |
2475 | 2475 | */ |
2476 | 2476 | protected function _learn_more_about_message_templates_link() { |
2477 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2477 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2478 | 2478 | } |
2479 | 2479 | |
2480 | 2480 | |
@@ -2492,10 +2492,10 @@ discard block |
||
2492 | 2492 | |
2493 | 2493 | $this->_set_m_mt_settings(); |
2494 | 2494 | |
2495 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2495 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2496 | 2496 | |
2497 | 2497 | //let's setup the messenger tabs |
2498 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2498 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2499 | 2499 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2500 | 2500 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2501 | 2501 | |
@@ -2514,7 +2514,7 @@ discard block |
||
2514 | 2514 | */ |
2515 | 2515 | protected function _set_m_mt_settings() { |
2516 | 2516 | //first if this is already set then lets get out no need to regenerate data. |
2517 | - if ( !empty($this->_m_mt_settings) ) { |
|
2517 | + if ( ! empty($this->_m_mt_settings)) { |
|
2518 | 2518 | return; |
2519 | 2519 | } |
2520 | 2520 | |
@@ -2529,10 +2529,10 @@ discard block |
||
2529 | 2529 | |
2530 | 2530 | //assemble the array for the _tab_text_links helper |
2531 | 2531 | |
2532 | - foreach ( $messengers as $messenger ) { |
|
2532 | + foreach ($messengers as $messenger) { |
|
2533 | 2533 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2534 | 2534 | 'label' => ucwords($messenger->label['singular']), |
2535 | - 'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '', |
|
2535 | + 'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '', |
|
2536 | 2536 | 'href' => $messenger->name, |
2537 | 2537 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2538 | 2538 | 'slug' => $messenger->name, |
@@ -2542,26 +2542,26 @@ discard block |
||
2542 | 2542 | |
2543 | 2543 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2544 | 2544 | |
2545 | - foreach ( $message_types as $message_type ) { |
|
2545 | + foreach ($message_types as $message_type) { |
|
2546 | 2546 | //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. |
2547 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2547 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2548 | 2548 | continue; |
2549 | 2549 | } |
2550 | 2550 | |
2551 | - $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive'; |
|
2551 | + $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive'; |
|
2552 | 2552 | |
2553 | 2553 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2554 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2555 | - 'class' => 'message-type-' . $a_or_i, |
|
2556 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2557 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2558 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2554 | + 'label' => ucwords($message_type->label['singular']), |
|
2555 | + 'class' => 'message-type-'.$a_or_i, |
|
2556 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2557 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2558 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2559 | 2559 | 'title' => $a_or_i == 'active' |
2560 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2561 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2560 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2561 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2562 | 2562 | 'content' => $a_or_i == 'active' |
2563 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2564 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2563 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2564 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2565 | 2565 | 'slug' => $message_type->name, |
2566 | 2566 | 'active' => $a_or_i == 'active' ? true : false, |
2567 | 2567 | 'obj' => $message_type |
@@ -2580,34 +2580,34 @@ discard block |
||
2580 | 2580 | * |
2581 | 2581 | * @return string html output for the content |
2582 | 2582 | */ |
2583 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2583 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2584 | 2584 | //get message type fields |
2585 | 2585 | $fields = $message_type->get_admin_settings_fields(); |
2586 | - $settings_template_args['template_form_fields']= ''; |
|
2586 | + $settings_template_args['template_form_fields'] = ''; |
|
2587 | 2587 | |
2588 | - if ( !empty( $fields ) && $active ) { |
|
2588 | + if ( ! empty($fields) && $active) { |
|
2589 | 2589 | |
2590 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2590 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2591 | 2591 | |
2592 | - foreach( $fields as $fldname => $fldprops ) { |
|
2593 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2592 | + foreach ($fields as $fldname => $fldprops) { |
|
2593 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2594 | 2594 | $template_form_field[$field_id] = array( |
2595 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2595 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2596 | 2596 | 'label' => $fldprops['label'], |
2597 | 2597 | 'input' => $fldprops['field_type'], |
2598 | 2598 | 'type' => $fldprops['value_type'], |
2599 | 2599 | 'required' => $fldprops['required'], |
2600 | 2600 | 'validation' => $fldprops['validation'], |
2601 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2602 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2603 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2601 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2602 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2603 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2604 | 2604 | 'css_class' => 'no-drag', |
2605 | 2605 | 'format' => $fldprops['format'] |
2606 | 2606 | ); |
2607 | 2607 | } |
2608 | 2608 | |
2609 | 2609 | |
2610 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2610 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2611 | 2611 | } |
2612 | 2612 | |
2613 | 2613 | $settings_template_args['description'] = $message_type->description; |
@@ -2627,13 +2627,13 @@ discard block |
||
2627 | 2627 | ) |
2628 | 2628 | ); |
2629 | 2629 | |
2630 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2631 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2630 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2631 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2632 | 2632 | |
2633 | 2633 | |
2634 | 2634 | |
2635 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2636 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2635 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2636 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2637 | 2637 | return $content; |
2638 | 2638 | } |
2639 | 2639 | |
@@ -2650,27 +2650,27 @@ discard block |
||
2650 | 2650 | $m_boxes = $mt_boxes = array(); |
2651 | 2651 | $m_template_args = $mt_template_args = array(); |
2652 | 2652 | |
2653 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2653 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2654 | 2654 | |
2655 | - if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) { |
|
2656 | - foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) { |
|
2657 | - $hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden'; |
|
2658 | - $hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : ''; |
|
2655 | + if (isset($this->_m_mt_settings['messenger_tabs'])) { |
|
2656 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2657 | + $hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden'; |
|
2658 | + $hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : ''; |
|
2659 | 2659 | //messenger meta boxes |
2660 | 2660 | $active = $selected_messenger == $messenger ? true : false; |
2661 | - $active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] ) |
|
2662 | - ? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] |
|
2661 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) |
|
2662 | + ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] |
|
2663 | 2663 | : ''; |
2664 | - $m_boxes[ $messenger . '_a_box' ] = sprintf( |
|
2665 | - __( '%s Settings', 'event_espresso' ), |
|
2666 | - $tab_array[ 'label' ] |
|
2664 | + $m_boxes[$messenger.'_a_box'] = sprintf( |
|
2665 | + __('%s Settings', 'event_espresso'), |
|
2666 | + $tab_array['label'] |
|
2667 | 2667 | ); |
2668 | - $m_template_args[ $messenger . '_a_box' ] = array( |
|
2669 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2670 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2671 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2668 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2669 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2670 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2671 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2672 | 2672 | : '', |
2673 | - 'content' => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ), |
|
2673 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2674 | 2674 | 'hidden' => $active ? '' : ' hidden', |
2675 | 2675 | 'hide_on_message' => $hide_on_message, |
2676 | 2676 | 'messenger' => $messenger, |
@@ -2679,11 +2679,11 @@ discard block |
||
2679 | 2679 | // message type meta boxes |
2680 | 2680 | // (which is really just the inactive container for each messenger |
2681 | 2681 | // showing inactive message types for that messenger) |
2682 | - $mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' ); |
|
2683 | - $mt_template_args[ $messenger . '_i_box' ] = array( |
|
2684 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2685 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2686 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2682 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2683 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2684 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2685 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2686 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2687 | 2687 | : '', |
2688 | 2688 | 'hidden' => $active ? '' : ' hidden', |
2689 | 2689 | 'hide_on_message' => $hide_on_message, |
@@ -2696,12 +2696,12 @@ discard block |
||
2696 | 2696 | |
2697 | 2697 | |
2698 | 2698 | //register messenger metaboxes |
2699 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2700 | - foreach ( $m_boxes as $box => $label ) { |
|
2701 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2702 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2699 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2700 | + foreach ($m_boxes as $box => $label) { |
|
2701 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2702 | + $msgr = str_replace('_a_box', '', $box); |
|
2703 | 2703 | add_meta_box( |
2704 | - 'espresso_' . $msgr . '_settings', |
|
2704 | + 'espresso_'.$msgr.'_settings', |
|
2705 | 2705 | $label, |
2706 | 2706 | create_function( |
2707 | 2707 | '$post, $metabox', |
@@ -2715,14 +2715,14 @@ discard block |
||
2715 | 2715 | } |
2716 | 2716 | |
2717 | 2717 | //register message type metaboxes |
2718 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2719 | - foreach ( $mt_boxes as $box => $label ) { |
|
2718 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2719 | + foreach ($mt_boxes as $box => $label) { |
|
2720 | 2720 | $callback_args = array( |
2721 | - 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ] |
|
2721 | + 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] |
|
2722 | 2722 | ); |
2723 | - $mt = str_replace( '_i_box', '', $box ); |
|
2723 | + $mt = str_replace('_i_box', '', $box); |
|
2724 | 2724 | add_meta_box( |
2725 | - 'espresso_' . $mt . '_inactive_mts', |
|
2725 | + 'espresso_'.$mt.'_inactive_mts', |
|
2726 | 2726 | $label, |
2727 | 2727 | create_function( |
2728 | 2728 | '$post, $metabox', |
@@ -2745,13 +2745,13 @@ discard block |
||
2745 | 2745 | * |
2746 | 2746 | * @return string html formatted tabs |
2747 | 2747 | */ |
2748 | - protected function _get_mt_tabs( $tab_array ) { |
|
2748 | + protected function _get_mt_tabs($tab_array) { |
|
2749 | 2749 | $tab_array = (array) $tab_array; |
2750 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2750 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2751 | 2751 | $tabs = ''; |
2752 | 2752 | |
2753 | - foreach ( $tab_array as $tab ) { |
|
2754 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
2753 | + foreach ($tab_array as $tab) { |
|
2754 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
2755 | 2755 | } |
2756 | 2756 | |
2757 | 2757 | return $tabs; |
@@ -2767,29 +2767,29 @@ discard block |
||
2767 | 2767 | * |
2768 | 2768 | * @return string html formatted content |
2769 | 2769 | */ |
2770 | - protected function _get_messenger_box_content( EE_messenger $messenger ) { |
|
2770 | + protected function _get_messenger_box_content(EE_messenger $messenger) { |
|
2771 | 2771 | |
2772 | 2772 | $fields = $messenger->get_admin_settings_fields(); |
2773 | 2773 | $settings_template_args['template_form_fields'] = ''; |
2774 | 2774 | |
2775 | 2775 | //is $messenger active? |
2776 | - $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
2776 | + $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
2777 | 2777 | |
2778 | 2778 | |
2779 | - if ( ! empty( $fields ) ) { |
|
2779 | + if ( ! empty($fields)) { |
|
2780 | 2780 | |
2781 | 2781 | $existing_settings = $messenger->get_existing_admin_settings(); |
2782 | 2782 | |
2783 | - foreach( $fields as $fldname => $fldprops ) { |
|
2784 | - $field_id = $messenger->name . '-' . $fldname; |
|
2783 | + foreach ($fields as $fldname => $fldprops) { |
|
2784 | + $field_id = $messenger->name.'-'.$fldname; |
|
2785 | 2785 | $template_form_field[$field_id] = array( |
2786 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
2786 | + 'name' => 'messenger_settings['.$field_id.']', |
|
2787 | 2787 | 'label' => $fldprops['label'], |
2788 | 2788 | 'input' => $fldprops['field_type'], |
2789 | 2789 | 'type' => $fldprops['value_type'], |
2790 | 2790 | 'required' => $fldprops['required'], |
2791 | 2791 | 'validation' => $fldprops['validation'], |
2792 | - 'value' => isset( $existing_settings[$field_id]) |
|
2792 | + 'value' => isset($existing_settings[$field_id]) |
|
2793 | 2793 | ? $existing_settings[$field_id] |
2794 | 2794 | : $fldprops['default'], |
2795 | 2795 | 'css_class' => '', |
@@ -2798,8 +2798,8 @@ discard block |
||
2798 | 2798 | } |
2799 | 2799 | |
2800 | 2800 | |
2801 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) |
|
2802 | - ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) |
|
2801 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) |
|
2802 | + ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') |
|
2803 | 2803 | : ''; |
2804 | 2804 | } |
2805 | 2805 | |
@@ -2816,39 +2816,39 @@ discard block |
||
2816 | 2816 | ); |
2817 | 2817 | |
2818 | 2818 | //make sure any active message types that are existing are included in the hidden fields |
2819 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
2820 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
2819 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
2820 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
2821 | 2821 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
2822 | 2822 | 'type' => 'hidden', |
2823 | 2823 | 'value' => $mt |
2824 | 2824 | ); |
2825 | 2825 | } |
2826 | 2826 | } |
2827 | - $settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields( |
|
2828 | - $settings_template_args[ 'hidden_fields' ], |
|
2827 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( |
|
2828 | + $settings_template_args['hidden_fields'], |
|
2829 | 2829 | 'array' |
2830 | 2830 | ); |
2831 | - $active = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
2831 | + $active = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
2832 | 2832 | |
2833 | 2833 | $settings_template_args['messenger'] = $messenger->name; |
2834 | 2834 | $settings_template_args['description'] = $messenger->description; |
2835 | 2835 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
2836 | 2836 | |
2837 | 2837 | |
2838 | - $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ) |
|
2838 | + $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name) |
|
2839 | 2839 | ? $settings_template_args['show_hide_edit_form'] |
2840 | 2840 | : ' hidden'; |
2841 | 2841 | |
2842 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) |
|
2842 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) |
|
2843 | 2843 | ? ' hidden' |
2844 | 2844 | : $settings_template_args['show_hide_edit_form']; |
2845 | 2845 | |
2846 | 2846 | |
2847 | 2847 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
2848 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
2848 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
2849 | 2849 | $settings_template_args['on_off_status'] = $active ? true : false; |
2850 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
2851 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
2850 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
2851 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2852 | 2852 | return $content; |
2853 | 2853 | } |
2854 | 2854 | |
@@ -2862,9 +2862,9 @@ discard block |
||
2862 | 2862 | $success = true; |
2863 | 2863 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
2864 | 2864 | //let's check that we have required data |
2865 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2865 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2866 | 2866 | EE_Error::add_error( |
2867 | - __( 'Messenger name needed to toggle activation. None given', 'event_espresso' ), |
|
2867 | + __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
|
2868 | 2868 | __FILE__, |
2869 | 2869 | __FUNCTION__, |
2870 | 2870 | __LINE__ |
@@ -2873,14 +2873,14 @@ discard block |
||
2873 | 2873 | } |
2874 | 2874 | |
2875 | 2875 | //do a nonce check here since we're not arriving via a normal route |
2876 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
2877 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
2876 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
2877 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
2878 | 2878 | |
2879 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2879 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2880 | 2880 | |
2881 | 2881 | |
2882 | 2882 | |
2883 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2883 | + if ( ! isset($this->_req_data['status'])) { |
|
2884 | 2884 | EE_Error::add_error( |
2885 | 2885 | __( |
2886 | 2886 | 'Messenger status needed to know whether activation or deactivation is happening. No status is given', |
@@ -2896,11 +2896,11 @@ discard block |
||
2896 | 2896 | //do check to verify we have a valid status. |
2897 | 2897 | $status = $this->_req_data['status']; |
2898 | 2898 | |
2899 | - if ( $status != 'off' && $status != 'on' ) { |
|
2899 | + if ($status != 'off' && $status != 'on') { |
|
2900 | 2900 | EE_Error::add_error( |
2901 | 2901 | sprintf( |
2902 | - __( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ), |
|
2903 | - $this->_req_data[ 'status' ] |
|
2902 | + __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), |
|
2903 | + $this->_req_data['status'] |
|
2904 | 2904 | ), |
2905 | 2905 | __FILE__, |
2906 | 2906 | __FUNCTION__, |
@@ -2909,11 +2909,11 @@ discard block |
||
2909 | 2909 | $success = false; |
2910 | 2910 | } |
2911 | 2911 | |
2912 | - if ( $success ) { |
|
2912 | + if ($success) { |
|
2913 | 2913 | //made it here? Stop dawdling then!! |
2914 | 2914 | $success = $status == 'off' |
2915 | - ? $this->_deactivate_messenger( $this->_req_data['messenger'] ) |
|
2916 | - : $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
2915 | + ? $this->_deactivate_messenger($this->_req_data['messenger']) |
|
2916 | + : $this->_activate_messenger($this->_req_data['messenger']); |
|
2917 | 2917 | } |
2918 | 2918 | |
2919 | 2919 | $this->_template_args['success'] = $success; |
@@ -2936,7 +2936,7 @@ discard block |
||
2936 | 2936 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
2937 | 2937 | |
2938 | 2938 | //let's make sure we have the necessary data |
2939 | - if ( ! isset( $this->_req_data[ 'message_type' ] ) ) { |
|
2939 | + if ( ! isset($this->_req_data['message_type'])) { |
|
2940 | 2940 | EE_Error::add_error( |
2941 | 2941 | __('Message Type name needed to toggle activation. None given', 'event_espresso'), |
2942 | 2942 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2944,7 +2944,7 @@ discard block |
||
2944 | 2944 | $success = false; |
2945 | 2945 | } |
2946 | 2946 | |
2947 | - if ( ! isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2947 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2948 | 2948 | EE_Error::add_error( |
2949 | 2949 | __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
2950 | 2950 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2952,7 +2952,7 @@ discard block |
||
2952 | 2952 | $success = false; |
2953 | 2953 | } |
2954 | 2954 | |
2955 | - if ( ! isset( $this->_req_data[ 'status' ])) { |
|
2955 | + if ( ! isset($this->_req_data['status'])) { |
|
2956 | 2956 | EE_Error::add_error( |
2957 | 2957 | __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), |
2958 | 2958 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2964,7 +2964,7 @@ discard block |
||
2964 | 2964 | //do check to verify we have a valid status. |
2965 | 2965 | $status = $this->_req_data['status']; |
2966 | 2966 | |
2967 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
2967 | + if ($status != 'activate' && $status != 'deactivate') { |
|
2968 | 2968 | EE_Error::add_error( |
2969 | 2969 | sprintf( |
2970 | 2970 | __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), |
@@ -2977,16 +2977,16 @@ discard block |
||
2977 | 2977 | |
2978 | 2978 | |
2979 | 2979 | //do a nonce check here since we're not arriving via a normal route |
2980 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
2981 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
2980 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
2981 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
2982 | 2982 | |
2983 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2983 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2984 | 2984 | |
2985 | - if ( $success ) { |
|
2985 | + if ($success) { |
|
2986 | 2986 | //made it here? um, what are you waiting for then? |
2987 | 2987 | $success = $status == 'deactivate' |
2988 | - ? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ) |
|
2989 | - : $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ); |
|
2988 | + ? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']) |
|
2989 | + : $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']); |
|
2990 | 2990 | } |
2991 | 2991 | |
2992 | 2992 | $this->_template_args['success'] = $success; |
@@ -3000,30 +3000,30 @@ discard block |
||
3000 | 3000 | * @param string $messenger_name The name of the messenger being activated |
3001 | 3001 | * @return bool |
3002 | 3002 | */ |
3003 | - protected function _activate_messenger( $messenger_name ) { |
|
3003 | + protected function _activate_messenger($messenger_name) { |
|
3004 | 3004 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3005 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3005 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3006 | 3006 | $message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array(); |
3007 | 3007 | |
3008 | 3008 | //ensure is active |
3009 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate ); |
|
3009 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate); |
|
3010 | 3010 | |
3011 | 3011 | //set response_data for reload |
3012 | - foreach( $message_types_to_activate as $message_type_name ) { |
|
3012 | + foreach ($message_types_to_activate as $message_type_name) { |
|
3013 | 3013 | /** @var EE_message_type $message_type */ |
3014 | - $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3015 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
3014 | + $message_type = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3015 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
3016 | 3016 | && $message_type instanceof EE_message_type |
3017 | 3017 | ) { |
3018 | 3018 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3019 | - if ( $message_type->get_admin_settings_fields() ) { |
|
3019 | + if ($message_type->get_admin_settings_fields()) { |
|
3020 | 3020 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3021 | 3021 | } |
3022 | 3022 | } |
3023 | 3023 | } |
3024 | 3024 | |
3025 | 3025 | //add success message for activating messenger |
3026 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger ); |
|
3026 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger); |
|
3027 | 3027 | |
3028 | 3028 | } |
3029 | 3029 | |
@@ -3034,11 +3034,11 @@ discard block |
||
3034 | 3034 | * @param string $messenger_name The name of the messenger being activated |
3035 | 3035 | * @return bool |
3036 | 3036 | */ |
3037 | - protected function _deactivate_messenger( $messenger_name ) { |
|
3037 | + protected function _deactivate_messenger($messenger_name) { |
|
3038 | 3038 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3039 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3040 | - $this->_message_resource_manager->deactivate_messenger( $messenger_name ); |
|
3041 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger ); |
|
3039 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3040 | + $this->_message_resource_manager->deactivate_messenger($messenger_name); |
|
3041 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger); |
|
3042 | 3042 | } |
3043 | 3043 | |
3044 | 3044 | |
@@ -3049,23 +3049,23 @@ discard block |
||
3049 | 3049 | * @param string $message_type_name The name of the message type being activated for the messenger |
3050 | 3050 | * @return bool |
3051 | 3051 | */ |
3052 | - protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3052 | + protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3053 | 3053 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3054 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3054 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3055 | 3055 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3056 | - $message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3056 | + $message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3057 | 3057 | |
3058 | 3058 | //ensure is active |
3059 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name ); |
|
3059 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name); |
|
3060 | 3060 | |
3061 | 3061 | //set response for load |
3062 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
3062 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
3063 | 3063 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3064 | - if ( $message_type_to_activate->get_admin_settings_fields() ) { |
|
3064 | + if ($message_type_to_activate->get_admin_settings_fields()) { |
|
3065 | 3065 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3066 | 3066 | } |
3067 | 3067 | } |
3068 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate ); |
|
3068 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate); |
|
3069 | 3069 | } |
3070 | 3070 | |
3071 | 3071 | |
@@ -3077,13 +3077,13 @@ discard block |
||
3077 | 3077 | * @param string $message_type_name The name of the message type being deactivated for the messenger |
3078 | 3078 | * @return bool |
3079 | 3079 | */ |
3080 | - protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3080 | + protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3081 | 3081 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3082 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3082 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3083 | 3083 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3084 | - $message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3085 | - $this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name ); |
|
3086 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate ); |
|
3084 | + $message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3085 | + $this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name); |
|
3086 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate); |
|
3087 | 3087 | } |
3088 | 3088 | |
3089 | 3089 | |
@@ -3114,9 +3114,9 @@ discard block |
||
3114 | 3114 | EE_Message_Type $message_type = null |
3115 | 3115 | ) { |
3116 | 3116 | //if $messenger isn't a valid messenger object then get out. |
3117 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3117 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3118 | 3118 | EE_Error::add_error( |
3119 | - __( 'The messenger being activated is not a valid messenger', 'event_espresso' ), |
|
3119 | + __('The messenger being activated is not a valid messenger', 'event_espresso'), |
|
3120 | 3120 | __FILE__, |
3121 | 3121 | __FUNCTION__, |
3122 | 3122 | __LINE__ |
@@ -3124,32 +3124,32 @@ discard block |
||
3124 | 3124 | return false; |
3125 | 3125 | } |
3126 | 3126 | //activated |
3127 | - if ( $this->_template_args['data']['active_mts'] ) { |
|
3127 | + if ($this->_template_args['data']['active_mts']) { |
|
3128 | 3128 | EE_Error::overwrite_success(); |
3129 | 3129 | //activated a message type with the messenger |
3130 | - if ( $message_type instanceof EE_message_type ) { |
|
3130 | + if ($message_type instanceof EE_message_type) { |
|
3131 | 3131 | EE_Error::add_success( |
3132 | 3132 | sprintf( |
3133 | 3133 | __('%s message type has been successfully activated with the %s messenger', 'event_espresso'), |
3134 | - ucwords( $message_type->label['singular'] ), |
|
3135 | - ucwords( $messenger->label['singular'] ) |
|
3134 | + ucwords($message_type->label['singular']), |
|
3135 | + ucwords($messenger->label['singular']) |
|
3136 | 3136 | ) |
3137 | 3137 | ); |
3138 | 3138 | |
3139 | 3139 | //if message type was invoice then let's make sure we activate the invoice payment method. |
3140 | - if ( $message_type->name == 'invoice' ) { |
|
3141 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3142 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
3143 | - if ( $pm instanceof EE_Payment_Method ) { |
|
3144 | - 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' ) ); |
|
3140 | + if ($message_type->name == 'invoice') { |
|
3141 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3142 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
3143 | + if ($pm instanceof EE_Payment_Method) { |
|
3144 | + 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')); |
|
3145 | 3145 | } |
3146 | 3146 | } |
3147 | 3147 | //just toggles the entire messenger |
3148 | 3148 | } else { |
3149 | 3149 | EE_Error::add_success( |
3150 | 3150 | sprintf( |
3151 | - __( '%s messenger has been successfully activated', 'event_espresso' ), |
|
3152 | - ucwords( $messenger->label[ 'singular' ] ) |
|
3151 | + __('%s messenger has been successfully activated', 'event_espresso'), |
|
3152 | + ucwords($messenger->label['singular']) |
|
3153 | 3153 | ) |
3154 | 3154 | ); |
3155 | 3155 | } |
@@ -3159,12 +3159,12 @@ discard block |
||
3159 | 3159 | //message types after the activation process. However its possible some messengers don't HAVE any default_message_types |
3160 | 3160 | //in which case we just give a success message for the messenger being successfully activated. |
3161 | 3161 | } else { |
3162 | - if ( ! $messenger->get_default_message_types() ) { |
|
3162 | + if ( ! $messenger->get_default_message_types()) { |
|
3163 | 3163 | //messenger doesn't have any default message types so still a success. |
3164 | 3164 | EE_Error::add_success( |
3165 | 3165 | sprintf( |
3166 | - __('%s messenger was successfully activated.', 'event_espresso' ), |
|
3167 | - ucwords( $messenger->label['singular'] ) |
|
3166 | + __('%s messenger was successfully activated.', 'event_espresso'), |
|
3167 | + ucwords($messenger->label['singular']) |
|
3168 | 3168 | ) |
3169 | 3169 | ); |
3170 | 3170 | return true; |
@@ -3172,13 +3172,13 @@ discard block |
||
3172 | 3172 | EE_Error::add_error( |
3173 | 3173 | $message_type instanceof EE_message_type |
3174 | 3174 | ? sprintf( |
3175 | - __( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ), |
|
3176 | - ucwords( $message_type->label['singular'] ), |
|
3177 | - ucwords( $messenger->label['singular'] ) |
|
3175 | + __('%s message type was not successfully activated with the %s messenger', 'event_espresso'), |
|
3176 | + ucwords($message_type->label['singular']), |
|
3177 | + ucwords($messenger->label['singular']) |
|
3178 | 3178 | ) |
3179 | 3179 | : sprintf( |
3180 | - __( '%s messenger was not successfully activated', 'event_espresso' ), |
|
3181 | - ucwords( $messenger->label['singular'] ) |
|
3180 | + __('%s messenger was not successfully activated', 'event_espresso'), |
|
3181 | + ucwords($messenger->label['singular']) |
|
3182 | 3182 | ), |
3183 | 3183 | __FILE__, |
3184 | 3184 | __FUNCTION__, |
@@ -3206,9 +3206,9 @@ discard block |
||
3206 | 3206 | EE_Error::overwrite_success(); |
3207 | 3207 | |
3208 | 3208 | //if $messenger isn't a valid messenger object then get out. |
3209 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3209 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3210 | 3210 | EE_Error::add_error( |
3211 | - __( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ), |
|
3211 | + __('The messenger being deactivated is not a valid messenger', 'event_espresso'), |
|
3212 | 3212 | __FILE__, |
3213 | 3213 | __FUNCTION__, |
3214 | 3214 | __LINE__ |
@@ -3216,13 +3216,13 @@ discard block |
||
3216 | 3216 | return false; |
3217 | 3217 | } |
3218 | 3218 | |
3219 | - if ( $message_type instanceof EE_message_type ) { |
|
3219 | + if ($message_type instanceof EE_message_type) { |
|
3220 | 3220 | $message_type_name = $message_type->name; |
3221 | 3221 | EE_Error::add_success( |
3222 | 3222 | sprintf( |
3223 | 3223 | __('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'), |
3224 | - ucwords( $message_type->label['singular'] ), |
|
3225 | - ucwords ( $messenger->label['singular'] ) |
|
3224 | + ucwords($message_type->label['singular']), |
|
3225 | + ucwords($messenger->label['singular']) |
|
3226 | 3226 | ) |
3227 | 3227 | ); |
3228 | 3228 | } else { |
@@ -3230,20 +3230,20 @@ discard block |
||
3230 | 3230 | EE_Error::add_success( |
3231 | 3231 | sprintf( |
3232 | 3232 | __('%s messenger has been successfully deactivated.', 'event_espresso'), |
3233 | - ucwords( $messenger->label['singular'] ) |
|
3233 | + ucwords($messenger->label['singular']) |
|
3234 | 3234 | ) |
3235 | 3235 | ); |
3236 | 3236 | } |
3237 | 3237 | |
3238 | 3238 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
3239 | - if ( $messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3240 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3241 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
3242 | - if ( $count_updated > 0 ) { |
|
3239 | + if ($messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3240 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3241 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
3242 | + if ($count_updated > 0) { |
|
3243 | 3243 | $msg = $message_type_name == 'invoice' |
3244 | - ? __('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' ) |
|
3245 | - : __('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' ); |
|
3246 | - EE_Error::add_attention( $msg ); |
|
3244 | + ? __('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') |
|
3245 | + : __('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'); |
|
3246 | + EE_Error::add_attention($msg); |
|
3247 | 3247 | } |
3248 | 3248 | } |
3249 | 3249 | return true; |
@@ -3254,17 +3254,17 @@ discard block |
||
3254 | 3254 | * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax) |
3255 | 3255 | */ |
3256 | 3256 | public function update_mt_form() { |
3257 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
3258 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3257 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
3258 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
3259 | 3259 | $this->_return_json(); |
3260 | 3260 | } |
3261 | 3261 | |
3262 | 3262 | $message_types = $this->get_installed_message_types(); |
3263 | 3263 | |
3264 | - $message_type = $message_types[ $this->_req_data['message_type'] ]; |
|
3265 | - $messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
3264 | + $message_type = $message_types[$this->_req_data['message_type']]; |
|
3265 | + $messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
3266 | 3266 | |
3267 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
3267 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
3268 | 3268 | $this->_template_args['success'] = true; |
3269 | 3269 | $this->_template_args['content'] = $content; |
3270 | 3270 | $this->_return_json(); |
@@ -3278,45 +3278,45 @@ discard block |
||
3278 | 3278 | * |
3279 | 3279 | */ |
3280 | 3280 | public function save_settings() { |
3281 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3282 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3281 | + if ( ! isset($this->_req_data['type'])) { |
|
3282 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3283 | 3283 | $this->_template_args['error'] = true; |
3284 | 3284 | $this->_return_json(); |
3285 | 3285 | } |
3286 | 3286 | |
3287 | 3287 | |
3288 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3288 | + if ($this->_req_data['type'] == 'messenger') { |
|
3289 | 3289 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3290 | 3290 | $messenger = $settings['messenger']; |
3291 | 3291 | //let's setup the settings data |
3292 | - foreach ( $settings as $key => $value ) { |
|
3293 | - switch ( $key ) { |
|
3292 | + foreach ($settings as $key => $value) { |
|
3293 | + switch ($key) { |
|
3294 | 3294 | case 'messenger' : |
3295 | - unset( $settings['messenger'] ); |
|
3295 | + unset($settings['messenger']); |
|
3296 | 3296 | break; |
3297 | 3297 | case 'message_types' : |
3298 | - unset( $settings['message_types'] ); |
|
3298 | + unset($settings['message_types']); |
|
3299 | 3299 | break; |
3300 | 3300 | default : |
3301 | 3301 | $settings[$key] = $value; |
3302 | 3302 | break; |
3303 | 3303 | } |
3304 | 3304 | } |
3305 | - $this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings ); |
|
3305 | + $this->_message_resource_manager->add_settings_for_messenger($messenger, $settings); |
|
3306 | 3306 | } |
3307 | 3307 | |
3308 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3308 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3309 | 3309 | $settings = $this->_req_data['message_type_settings']; |
3310 | 3310 | $messenger = $settings['messenger']; |
3311 | 3311 | $message_type = $settings['message_type']; |
3312 | 3312 | |
3313 | - foreach ( $settings as $key => $value ) { |
|
3314 | - switch ( $key ) { |
|
3313 | + foreach ($settings as $key => $value) { |
|
3314 | + switch ($key) { |
|
3315 | 3315 | case 'messenger' : |
3316 | - unset( $settings['messenger'] ); |
|
3316 | + unset($settings['messenger']); |
|
3317 | 3317 | break; |
3318 | 3318 | case 'message_type' : |
3319 | - unset( $settings['message_type'] ); |
|
3319 | + unset($settings['message_type']); |
|
3320 | 3320 | break; |
3321 | 3321 | default : |
3322 | 3322 | $settings[$key] = $value; |
@@ -3324,16 +3324,16 @@ discard block |
||
3324 | 3324 | } |
3325 | 3325 | } |
3326 | 3326 | |
3327 | - $this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings ); |
|
3327 | + $this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings); |
|
3328 | 3328 | } |
3329 | 3329 | |
3330 | 3330 | //okay we should have the data all setup. Now we just update! |
3331 | 3331 | $success = $this->_message_resource_manager->update_active_messengers_option(); |
3332 | 3332 | |
3333 | - if ( $success ) { |
|
3334 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3333 | + if ($success) { |
|
3334 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3335 | 3335 | } else { |
3336 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3336 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3337 | 3337 | } |
3338 | 3338 | |
3339 | 3339 | $this->_template_args['success'] = $success; |
@@ -3355,8 +3355,8 @@ discard block |
||
3355 | 3355 | */ |
3356 | 3356 | protected function _generate_now() { |
3357 | 3357 | $msg_ids = $this->_get_msg_ids_from_request(); |
3358 | - EED_Messages::generate_now( $msg_ids ); |
|
3359 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3358 | + EED_Messages::generate_now($msg_ids); |
|
3359 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3360 | 3360 | } |
3361 | 3361 | |
3362 | 3362 | |
@@ -3371,7 +3371,7 @@ discard block |
||
3371 | 3371 | protected function _generate_and_send_now() { |
3372 | 3372 | $this->_generate_now(); |
3373 | 3373 | $this->_send_now(); |
3374 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3374 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3375 | 3375 | } |
3376 | 3376 | |
3377 | 3377 | |
@@ -3385,8 +3385,8 @@ discard block |
||
3385 | 3385 | */ |
3386 | 3386 | protected function _queue_for_resending() { |
3387 | 3387 | $msg_ids = $this->_get_msg_ids_from_request(); |
3388 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3389 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3388 | + EED_Messages::queue_for_resending($msg_ids); |
|
3389 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3390 | 3390 | } |
3391 | 3391 | |
3392 | 3392 | |
@@ -3399,8 +3399,8 @@ discard block |
||
3399 | 3399 | */ |
3400 | 3400 | protected function _send_now() { |
3401 | 3401 | $msg_ids = $this->_get_msg_ids_from_request(); |
3402 | - EED_Messages::send_now( $msg_ids ); |
|
3403 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3402 | + EED_Messages::send_now($msg_ids); |
|
3403 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3404 | 3404 | } |
3405 | 3405 | |
3406 | 3406 | |
@@ -3414,23 +3414,23 @@ discard block |
||
3414 | 3414 | protected function _delete_ee_messages() { |
3415 | 3415 | $msg_ids = $this->_get_msg_ids_from_request(); |
3416 | 3416 | $deleted_count = 0; |
3417 | - foreach ( $msg_ids as $msg_id ) { |
|
3418 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3417 | + foreach ($msg_ids as $msg_id) { |
|
3418 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3419 | 3419 | $deleted_count++; |
3420 | 3420 | } |
3421 | 3421 | } |
3422 | - if ( $deleted_count ) { |
|
3422 | + if ($deleted_count) { |
|
3423 | 3423 | $this->_redirect_after_action( |
3424 | 3424 | true, |
3425 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3425 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3426 | 3426 | __('deleted', 'event_espresso') |
3427 | 3427 | ); |
3428 | 3428 | } else { |
3429 | 3429 | EE_Error::add_error( |
3430 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3430 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3431 | 3431 | __FILE__, __FUNCTION__, __LINE__ |
3432 | 3432 | ); |
3433 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3433 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3434 | 3434 | } |
3435 | 3435 | } |
3436 | 3436 | |
@@ -3443,10 +3443,10 @@ discard block |
||
3443 | 3443 | * @return array |
3444 | 3444 | */ |
3445 | 3445 | protected function _get_msg_ids_from_request() { |
3446 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3446 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3447 | 3447 | return array(); |
3448 | 3448 | } |
3449 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3449 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3450 | 3450 | } |
3451 | 3451 | |
3452 | 3452 |