@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | final class EE_Admin { |
25 | 25 | |
26 | 26 | /** |
27 | - * EE_Admin Object |
|
28 | - * @private _instance |
|
29 | - * @private protected |
|
30 | - */ |
|
27 | + * EE_Admin Object |
|
28 | + * @private _instance |
|
29 | + * @private protected |
|
30 | + */ |
|
31 | 31 | private static $_instance = NULL; |
32 | 32 | |
33 | 33 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
59 | - * class constructor |
|
60 | - */ |
|
59 | + * class constructor |
|
60 | + */ |
|
61 | 61 | protected function __construct() { |
62 | 62 | // define global EE_Admin constants |
63 | 63 | $this->_define_all_constants(); |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | |
169 | 169 | |
170 | 170 | /** |
171 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even EE_Front_Controller's init phases have run |
|
172 | - * |
|
173 | - * @access public |
|
174 | - * @return void |
|
175 | - */ |
|
171 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even EE_Front_Controller's init phases have run |
|
172 | + * |
|
173 | + * @access public |
|
174 | + * @return void |
|
175 | + */ |
|
176 | 176 | public function init() { |
177 | 177 | |
178 | 178 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | |
464 | 464 | |
465 | 465 | /** |
466 | - * admin_init |
|
467 | - * |
|
468 | - * @access public |
|
469 | - * @return void |
|
470 | - */ |
|
466 | + * admin_init |
|
467 | + * |
|
468 | + * @access public |
|
469 | + * @return void |
|
470 | + */ |
|
471 | 471 | public function admin_init() { |
472 | 472 | |
473 | 473 | /** |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | |
625 | 625 | |
626 | 626 | /** |
627 | - * dismiss_persistent_admin_notice |
|
628 | - * |
|
629 | - * @access public |
|
630 | - * @return void |
|
631 | - */ |
|
627 | + * dismiss_persistent_admin_notice |
|
628 | + * |
|
629 | + * @access public |
|
630 | + * @return void |
|
631 | + */ |
|
632 | 632 | public function dismiss_ee_nag_notice_callback() { |
633 | 633 | EE_Error::dismiss_persistent_admin_notice(); |
634 | 634 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -220,8 +222,9 @@ discard block |
||
220 | 222 | */ |
221 | 223 | public function remove_pages_from_nav_menu( $post_type ) { |
222 | 224 | //if this isn't the "pages" post type let's get out |
223 | - if ( $post_type->name !== 'page' ) |
|
224 | - return $post_type; |
|
225 | + if ( $post_type->name !== 'page' ) { |
|
226 | + return $post_type; |
|
227 | + } |
|
225 | 228 | |
226 | 229 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
227 | 230 | |
@@ -296,8 +299,9 @@ discard block |
||
296 | 299 | * @return string the (maybe) modified link |
297 | 300 | */ |
298 | 301 | public function modify_edit_post_link( $link, $id, $context ) { |
299 | - if ( ! $post = get_post( $id ) ) |
|
300 | - return $link; |
|
302 | + if ( ! $post = get_post( $id ) ) { |
|
303 | + return $link; |
|
304 | + } |
|
301 | 305 | |
302 | 306 | if ( $post->post_type == 'espresso_attendees' ) { |
303 | 307 | $query_args = array( |
@@ -337,7 +341,10 @@ discard block |
||
337 | 341 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
338 | 342 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
339 | 343 | <li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>> |
340 | - <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"> |
|
344 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) { |
|
345 | + echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); |
|
346 | +} |
|
347 | +?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
341 | 348 | <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
342 | 349 | </a> |
343 | 350 | </li> |
@@ -870,8 +877,9 @@ discard block |
||
870 | 877 | */ |
871 | 878 | public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
872 | 879 | 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' ); |
873 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) |
|
874 | - $config['page_path'] = $page_path; |
|
880 | + if ( class_exists( 'EE_Register_Admin_Page' ) ) { |
|
881 | + $config['page_path'] = $page_path; |
|
882 | + } |
|
875 | 883 | EE_Register_Admin_Page::register( $page_basename, $config ); |
876 | 884 | } |
877 | 885 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public static function instance() { |
49 | 49 | // check if class object is instantiated |
50 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
50 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
51 | 51 | self::$_instance = new self(); |
52 | 52 | } |
53 | 53 | return self::$_instance; |
@@ -62,25 +62,25 @@ discard block |
||
62 | 62 | // define global EE_Admin constants |
63 | 63 | $this->_define_all_constants(); |
64 | 64 | // set autoloaders for our admin page classes based on included path information |
65 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
65 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
66 | 66 | // admin hooks |
67 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
67 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
68 | 68 | // load EE_Request_Handler early |
69 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
70 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
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' )); |
|
69 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
70 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
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,12 +95,12 @@ 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' )); |
|
103 | - define( 'JQPLOT_URL', EE_GLOBAL_ASSETS_URL . 'scripts/jqplot/' ); |
|
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 | + define('JQPLOT_URL', EE_GLOBAL_ASSETS_URL.'scripts/jqplot/'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,23 +113,23 @@ discard block |
||
113 | 113 | * @param string $plugin |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function filter_plugin_actions( $links, $plugin ) { |
|
116 | + public function filter_plugin_actions($links, $plugin) { |
|
117 | 117 | // set $main_file in stone |
118 | 118 | static $main_file; |
119 | 119 | // if $main_file is not set yet |
120 | - if ( ! $main_file ) { |
|
121 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
120 | + if ( ! $main_file) { |
|
121 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
122 | 122 | } |
123 | - if ( $plugin == $main_file ) { |
|
123 | + if ($plugin == $main_file) { |
|
124 | 124 | // compare current plugin to this one |
125 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
126 | - $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>'; |
|
127 | - array_unshift( $links, $maintenance_link ); |
|
125 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
126 | + $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>'; |
|
127 | + array_unshift($links, $maintenance_link); |
|
128 | 128 | } else { |
129 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
130 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
129 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
130 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
131 | 131 | // add before other links |
132 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
132 | + array_unshift($links, $org_settings_link, $events_link); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | return $links; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @return void |
145 | 145 | */ |
146 | 146 | public function get_request() { |
147 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
148 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
147 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
148 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * @param array $admin_page_folder_names |
158 | 158 | * @return array |
159 | 159 | */ |
160 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
160 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
161 | 161 | return array( |
162 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
163 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
164 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
162 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
163 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
164 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
165 | 165 | ); |
166 | 166 | } |
167 | 167 | |
@@ -176,36 +176,36 @@ discard block |
||
176 | 176 | public function init() { |
177 | 177 | |
178 | 178 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
179 | - if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
179 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
180 | 180 | //ok so we want to enable the entire admin |
181 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
182 | - add_action( 'save_post', array( 'EE_Admin', 'parse_post_content_on_save' ), 100, 2 ); |
|
183 | - add_action( 'update_option', array( $this, 'reset_page_for_posts_on_change' ), 100, 3 ); |
|
184 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
185 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
186 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
181 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
182 | + add_action('save_post', array('EE_Admin', 'parse_post_content_on_save'), 100, 2); |
|
183 | + add_action('update_option', array($this, 'reset_page_for_posts_on_change'), 100, 3); |
|
184 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
185 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
186 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
187 | 187 | //at a glance dashboard widget |
188 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items'), 10 ); |
|
188 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
189 | 189 | //filter for get_edit_post_link used on comments for custom post types |
190 | - add_filter('get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 3 ); |
|
190 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
194 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
194 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
195 | 195 | try { |
196 | 196 | //this loads the controller for the admin pages which will setup routing etc |
197 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
198 | - } catch ( EE_Error $e ) { |
|
197 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
198 | + } catch (EE_Error $e) { |
|
199 | 199 | $e->get_error(); |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
204 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
205 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
204 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
205 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
206 | 206 | |
207 | 207 | //exclude EE critical pages from all nav menus and wp_list_pages |
208 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
208 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * @param object $post_type WP post type object |
219 | 219 | * @return object WP post type object |
220 | 220 | */ |
221 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
221 | + public function remove_pages_from_nav_menu($post_type) { |
|
222 | 222 | //if this isn't the "pages" post type let's get out |
223 | - if ( $post_type->name !== 'page' ) |
|
223 | + if ($post_type->name !== 'page') |
|
224 | 224 | return $post_type; |
225 | 225 | |
226 | 226 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -240,28 +240,28 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function enable_hidden_ee_nav_menu_metaboxes() { |
242 | 242 | global $wp_meta_boxes, $pagenow; |
243 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
243 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | $user = wp_get_current_user(); |
247 | 247 | //has this been done yet? |
248 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
248 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
249 | 249 | return; |
250 | 250 | } |
251 | 251 | |
252 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
253 | - $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' ) ); |
|
252 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
253 | + $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')); |
|
254 | 254 | |
255 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
256 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
257 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
258 | - unset( $hidden_meta_boxes[ $key ] ); |
|
255 | + if (is_array($hidden_meta_boxes)) { |
|
256 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
257 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
258 | + unset($hidden_meta_boxes[$key]); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
264 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
263 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
264 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @return void |
281 | 281 | */ |
282 | 282 | public function register_custom_nav_menu_boxes() { |
283 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
283 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -297,17 +297,17 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return string the (maybe) modified link |
299 | 299 | */ |
300 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
301 | - if ( ! $post = get_post( $id ) ) |
|
300 | + public function modify_edit_post_link($link, $id, $context) { |
|
301 | + if ( ! $post = get_post($id)) |
|
302 | 302 | return $link; |
303 | 303 | |
304 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
304 | + if ($post->post_type == 'espresso_attendees') { |
|
305 | 305 | $query_args = array( |
306 | 306 | 'action' => 'edit_attendee', |
307 | 307 | 'post' => $id |
308 | 308 | ); |
309 | 309 | EE_Registry::instance()->load_helper('URL'); |
310 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
310 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
311 | 311 | } |
312 | 312 | return $link; |
313 | 313 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | global $nav_menu_selected_id; |
320 | 320 | |
321 | 321 | $db_fields = false; |
322 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
322 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
323 | 323 | $current_tab = 'event-archives'; |
324 | 324 | |
325 | 325 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | ?> |
339 | 339 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
340 | 340 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
341 | - <li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
342 | - <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"> |
|
343 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
341 | + <li <?php echo ('event-archives' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
342 | + <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"> |
|
343 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
344 | 344 | </a> |
345 | 345 | </li> |
346 | 346 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | <?php */ ?> |
359 | 359 | |
360 | 360 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
361 | - echo ( 'event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
361 | + echo ('event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
362 | 362 | ?>"> |
363 | 363 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
364 | 364 | <?php |
365 | 365 | $pages = $this->_get_extra_nav_menu_pages_items(); |
366 | 366 | $args['walker'] = $walker; |
367 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
367 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
368 | 368 | ?> |
369 | 369 | </ul> |
370 | 370 | </div><!-- /.tabs-panel --> |
@@ -372,18 +372,18 @@ discard block |
||
372 | 372 | <p class="button-controls"> |
373 | 373 | <span class="list-controls"> |
374 | 374 | <a href="<?php |
375 | - echo esc_url( add_query_arg( |
|
375 | + echo esc_url(add_query_arg( |
|
376 | 376 | array( |
377 | 377 | 'extra-nav-menu-pages-tab' => 'event-archives', |
378 | 378 | 'selectall' => 1, |
379 | 379 | ), |
380 | - remove_query_arg( $removed_args ) |
|
380 | + remove_query_arg($removed_args) |
|
381 | 381 | )); |
382 | 382 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
383 | 383 | </span> |
384 | 384 | |
385 | 385 | <span class="add-to-menu"> |
386 | - <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' ); ?>" /> |
|
386 | + <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'); ?>" /> |
|
387 | 387 | <span class="spinner"></span> |
388 | 388 | </span> |
389 | 389 | </p> |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | private function _get_extra_nav_menu_pages_items() { |
405 | 405 | $menuitems[] = array( |
406 | 406 | 'title' => __('Event List', 'event_espresso'), |
407 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
407 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
408 | 408 | 'description' => __('Archive page for all events.', 'event_espresso') |
409 | 409 | ); |
410 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
410 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * @param $menuitem |
420 | 420 | * @return stdClass |
421 | 421 | */ |
422 | - private function _setup_extra_nav_menu_pages_items( $menuitem ) { |
|
422 | + private function _setup_extra_nav_menu_pages_items($menuitem) { |
|
423 | 423 | $menu_item = new stdClass(); |
424 | 424 | $keys = array( |
425 | 425 | 'ID' => 0, |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | 'xfn' => '' |
440 | 440 | ); |
441 | 441 | |
442 | - foreach ( $keys as $key => $value) { |
|
442 | + foreach ($keys as $key => $value) { |
|
443 | 443 | $menu_item->$key = isset($menuitem[$key]) ? $menuitem[$key] : $value; |
444 | 444 | } |
445 | 445 | return $menu_item; |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | * - check if doing post processing of one of EE CPTs |
480 | 480 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
481 | 481 | */ |
482 | - if ( isset( $_POST['action'] ) && $_POST['action'] == 'editpost' ) { |
|
483 | - if ( isset( $_POST['post_type'] ) ) { |
|
484 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
485 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
482 | + if (isset($_POST['action']) && $_POST['action'] == 'editpost') { |
|
483 | + if (isset($_POST['post_type'])) { |
|
484 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
485 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
493 | 493 | */ |
494 | 494 | global $pagenow; |
495 | - if ( $pagenow == 'options-reading.php' ) { |
|
496 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
495 | + if ($pagenow == 'options-reading.php') { |
|
496 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | } |
@@ -505,25 +505,25 @@ discard block |
||
505 | 505 | * @param string $output Current output. |
506 | 506 | * @return string |
507 | 507 | */ |
508 | - public function modify_dropdown_pages( $output ) { |
|
508 | + public function modify_dropdown_pages($output) { |
|
509 | 509 | //get critical pages |
510 | 510 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
511 | 511 | |
512 | 512 | //split current output by line break for easier parsing. |
513 | - $split_output = explode( "\n", $output ); |
|
513 | + $split_output = explode("\n", $output); |
|
514 | 514 | |
515 | 515 | //loop through to remove any critical pages from the array. |
516 | - foreach ( $critical_pages as $page_id ) { |
|
517 | - $needle = 'value="' . $page_id . '"'; |
|
518 | - foreach( $split_output as $key => $haystack ) { |
|
519 | - if( strpos( $haystack, $needle ) !== false ) { |
|
520 | - unset( $split_output[$key] ); |
|
516 | + foreach ($critical_pages as $page_id) { |
|
517 | + $needle = 'value="'.$page_id.'"'; |
|
518 | + foreach ($split_output as $key => $haystack) { |
|
519 | + if (strpos($haystack, $needle) !== false) { |
|
520 | + unset($split_output[$key]); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | 525 | //replace output with the new contents |
526 | - $output = implode( "\n", $split_output ); |
|
526 | + $output = implode("\n", $split_output); |
|
527 | 527 | |
528 | 528 | return $output; |
529 | 529 | } |
@@ -539,37 +539,37 @@ discard block |
||
539 | 539 | public function enqueue_admin_scripts() { |
540 | 540 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
541 | 541 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
542 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
542 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
543 | 543 | // register cookie script for future dependencies |
544 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
544 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
545 | 545 | // 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' ); |
546 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
546 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
547 | 547 | // register jQuery Validate |
548 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
548 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
549 | 549 | } |
550 | 550 | //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' ); |
551 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
551 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
552 | 552 | //joyride style |
553 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
554 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
555 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
553 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
554 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
555 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
556 | 556 | //joyride JS |
557 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
557 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
558 | 558 | // wanna go for a joyride? |
559 | 559 | wp_enqueue_style('ee-joyride-css'); |
560 | 560 | wp_enqueue_script('jquery-joyride'); |
561 | 561 | } |
562 | 562 | //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' ); |
563 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
563 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
564 | 564 | EE_Registry::instance()->load_helper('Qtip_Loader'); |
565 | 565 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
566 | 566 | } |
567 | 567 | //accounting.js library |
568 | 568 | // @link http://josscrowcroft.github.io/accounting.js/ |
569 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
570 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
571 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
572 | - wp_enqueue_script( 'ee-accounting' ); |
|
569 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
570 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
571 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
572 | + wp_enqueue_script('ee-accounting'); |
|
573 | 573 | // array of settings to get converted to JSON array via wp_localize_script |
574 | 574 | $currency_config = array( |
575 | 575 | 'currency' => array( |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | public function get_persistent_admin_notices() { |
617 | 617 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
618 | 618 | $args = array( |
619 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
620 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
619 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
620 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
621 | 621 | ); |
622 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
623 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
622 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
623 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -641,26 +641,26 @@ discard block |
||
641 | 641 | * @param $elements |
642 | 642 | * @return array |
643 | 643 | */ |
644 | - public function dashboard_glance_items( $elements ) { |
|
644 | + public function dashboard_glance_items($elements) { |
|
645 | 645 | $events = EEM_Event::instance()->count(); |
646 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
647 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
646 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
647 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
648 | 648 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
649 | 649 | $registrations = EEM_Registration::instance()->count( |
650 | 650 | array( |
651 | 651 | array( |
652 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
652 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
653 | 653 | ) |
654 | 654 | ) |
655 | 655 | ); |
656 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
657 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
656 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
657 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
658 | 658 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
659 | 659 | |
660 | - $items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
660 | + $items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
661 | 661 | |
662 | - foreach ( $items as $type => $item_properties ) { |
|
663 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
662 | + foreach ($items as $type => $item_properties) { |
|
663 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
664 | 664 | } |
665 | 665 | return $elements; |
666 | 666 | } |
@@ -679,63 +679,63 @@ discard block |
||
679 | 679 | * @param $post |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
682 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
683 | 683 | // default post types |
684 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
684 | + $post_types = array('post' => 0, 'page' => 1); |
|
685 | 685 | // add CPTs |
686 | 686 | $CPTs = EE_Register_CPTs::get_CPTs(); |
687 | - $post_types = array_merge( $post_types, $CPTs ); |
|
687 | + $post_types = array_merge($post_types, $CPTs); |
|
688 | 688 | // for default or CPT posts... |
689 | - if ( isset( $post_types[ $post->post_type ] )) { |
|
689 | + if (isset($post_types[$post->post_type])) { |
|
690 | 690 | // post on frontpage ? |
691 | 691 | $page_for_posts = EE_Config::get_page_for_posts(); |
692 | 692 | $maybe_remove_from_posts = array(); |
693 | 693 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
694 | 694 | $critical_shortcodes = EE_Registry::instance()->CFG->core->get_critical_pages_shortcodes_array(); |
695 | 695 | // array of shortcodes indexed by post name |
696 | - EE_Registry::instance()->CFG->core->post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
696 | + EE_Registry::instance()->CFG->core->post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
697 | 697 | // whether to proceed with update, if an entry already exists for this post, then we want to update |
698 | - $update_post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] ) ? true : false; |
|
698 | + $update_post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name]) ? true : false; |
|
699 | 699 | // empty both arrays |
700 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] = array(); |
|
700 | + EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name] = array(); |
|
701 | 701 | // check that posts page is already being tracked |
702 | - if ( ! isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
702 | + if ( ! isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts])) { |
|
703 | 703 | // if not, then ensure that it is properly added |
704 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] = array(); |
|
704 | + EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts] = array(); |
|
705 | 705 | } |
706 | 706 | // loop thru shortcodes |
707 | - foreach ( EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
707 | + foreach (EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
708 | 708 | // convert to UPPERCASE to get actual shortcode |
709 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
709 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
710 | 710 | // is the shortcode in the post_content ? |
711 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== FALSE ) { |
|
711 | + if (strpos($post->post_content, $EES_Shortcode) !== FALSE) { |
|
712 | 712 | // map shortcode to post names and post IDs |
713 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
713 | + EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
714 | 714 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
715 | - if ( ! in_array( $EES_Shortcode, $critical_shortcodes )) { |
|
715 | + if ( ! in_array($EES_Shortcode, $critical_shortcodes)) { |
|
716 | 716 | // add shortcode to "Posts page" tracking |
717 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = $post_ID; |
|
717 | + EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = $post_ID; |
|
718 | 718 | } |
719 | 719 | $update_post_shortcodes = TRUE; |
720 | - unset( $maybe_remove_from_posts[ $EES_Shortcode ] ); |
|
720 | + unset($maybe_remove_from_posts[$EES_Shortcode]); |
|
721 | 721 | } else { |
722 | - $maybe_remove_from_posts[ $EES_Shortcode ] = $post_ID; |
|
722 | + $maybe_remove_from_posts[$EES_Shortcode] = $post_ID; |
|
723 | 723 | } |
724 | 724 | } |
725 | - if ( $update_post_shortcodes ) { |
|
725 | + if ($update_post_shortcodes) { |
|
726 | 726 | // remove shortcodes from $maybe_remove_from_posts that are still being used |
727 | - foreach ( EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes ) { |
|
728 | - if ( $post_name == $page_for_posts ) { |
|
727 | + foreach (EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes) { |
|
728 | + if ($post_name == $page_for_posts) { |
|
729 | 729 | continue; |
730 | 730 | } |
731 | 731 | // compute difference between active post_shortcodes array and $maybe_remove_from_posts array |
732 | - $maybe_remove_from_posts = array_diff_key( $maybe_remove_from_posts, $shortcodes ); |
|
732 | + $maybe_remove_from_posts = array_diff_key($maybe_remove_from_posts, $shortcodes); |
|
733 | 733 | } |
734 | 734 | // now unset unused shortcodes from the $page_for_posts post_shortcodes |
735 | - foreach ( $maybe_remove_from_posts as $shortcode => $post_ID ) { |
|
736 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode ] ); |
|
735 | + foreach ($maybe_remove_from_posts as $shortcode => $post_ID) { |
|
736 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$shortcode]); |
|
737 | 737 | } |
738 | - EE_Registry::instance()->CFG->update_post_shortcodes( $page_for_posts ); |
|
738 | + EE_Registry::instance()->CFG->update_post_shortcodes($page_for_posts); |
|
739 | 739 | } |
740 | 740 | } |
741 | 741 | } |
@@ -753,32 +753,32 @@ discard block |
||
753 | 753 | * @throws EE_Error |
754 | 754 | * @return string |
755 | 755 | */ |
756 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
757 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
756 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
757 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
758 | 758 | // check for date_format or time_format |
759 | - switch ( $option ) { |
|
759 | + switch ($option) { |
|
760 | 760 | case 'date_format' : |
761 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
761 | + $date_time_format = $value.' '.get_option('time_format'); |
|
762 | 762 | break; |
763 | 763 | case 'time_format' : |
764 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
764 | + $date_time_format = get_option('date_format').' '.$value; |
|
765 | 765 | break; |
766 | 766 | default : |
767 | 767 | $date_time_format = FALSE; |
768 | 768 | } |
769 | 769 | // do we have a date_time format to check ? |
770 | - if ( $date_time_format ) { |
|
771 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
770 | + if ($date_time_format) { |
|
771 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
772 | 772 | |
773 | - if ( is_array( $error_msg ) ) { |
|
774 | - $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>'; |
|
773 | + if (is_array($error_msg)) { |
|
774 | + $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>'; |
|
775 | 775 | |
776 | 776 | |
777 | - foreach ( $error_msg as $error ) { |
|
778 | - $msg .= '<li>' . $error . '</li>'; |
|
777 | + foreach ($error_msg as $error) { |
|
778 | + $msg .= '<li>'.$error.'</li>'; |
|
779 | 779 | } |
780 | 780 | |
781 | - $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>'; |
|
781 | + $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>'; |
|
782 | 782 | |
783 | 783 | // trigger WP settings error |
784 | 784 | add_settings_error( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | ); |
789 | 789 | |
790 | 790 | // set format to something valid |
791 | - switch ( $option ) { |
|
791 | + switch ($option) { |
|
792 | 792 | case 'date_format' : |
793 | 793 | $value = 'F j, Y'; |
794 | 794 | break; |
@@ -814,14 +814,14 @@ discard block |
||
814 | 814 | * @param $value |
815 | 815 | * @return void |
816 | 816 | */ |
817 | - public function reset_page_for_posts_on_change( $option, $old_value, $value ) { |
|
818 | - if ( $option == 'page_for_posts' ) { |
|
817 | + public function reset_page_for_posts_on_change($option, $old_value, $value) { |
|
818 | + if ($option == 'page_for_posts') { |
|
819 | 819 | global $wpdb; |
820 | - $SQL = 'SELECT post_name from ' . $wpdb->posts . ' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s'; |
|
821 | - $old_page_for_posts = $old_value ? $wpdb->get_var( $wpdb->prepare( $SQL, $old_value )) : 'posts'; |
|
822 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value )) : 'posts'; |
|
823 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $new_page_for_posts ] = EE_Registry::instance()->CFG->core->post_shortcodes[ $old_page_for_posts ]; |
|
824 | - EE_Registry::instance()->CFG->update_post_shortcodes( $new_page_for_posts ); |
|
820 | + $SQL = 'SELECT post_name from '.$wpdb->posts.' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s'; |
|
821 | + $old_page_for_posts = $old_value ? $wpdb->get_var($wpdb->prepare($SQL, $old_value)) : 'posts'; |
|
822 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
823 | + EE_Registry::instance()->CFG->core->post_shortcodes[$new_page_for_posts] = EE_Registry::instance()->CFG->core->post_shortcodes[$old_page_for_posts]; |
|
824 | + EE_Registry::instance()->CFG->update_post_shortcodes($new_page_for_posts); |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | * @param $content |
835 | 835 | * @return string |
836 | 836 | */ |
837 | - public function its_eSpresso( $content ) { |
|
838 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
837 | + public function its_eSpresso($content) { |
|
838 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -848,9 +848,9 @@ discard block |
||
848 | 848 | */ |
849 | 849 | public function espresso_admin_footer() { |
850 | 850 | return sprintf( |
851 | - __( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ), |
|
851 | + __('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'), |
|
852 | 852 | '<a href="http://eventespresso.com/" title="', |
853 | - '">' . EVENT_ESPRESSO_POWERED_BY . '</a>' |
|
853 | + '">'.EVENT_ESPRESSO_POWERED_BY.'</a>' |
|
854 | 854 | ); |
855 | 855 | } |
856 | 856 | |
@@ -870,11 +870,11 @@ discard block |
||
870 | 870 | * @param array $config |
871 | 871 | * @return void |
872 | 872 | */ |
873 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
874 | - 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' ); |
|
875 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) |
|
873 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
874 | + 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'); |
|
875 | + if (class_exists('EE_Register_Admin_Page')) |
|
876 | 876 | $config['page_path'] = $page_path; |
877 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
877 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
106 | - * @return null |
|
106 | + * @return EE_Line_Item_Display |
|
107 | 107 | */ |
108 | 108 | public function line_item_display() { |
109 | 109 | return $this->line_item_display; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | |
114 | 114 | /** |
115 | - * @param null $line_item_display |
|
115 | + * @param EE_Line_Item_Display $line_item_display |
|
116 | 116 | */ |
117 | 117 | public function set_line_item_display( $line_item_display ) { |
118 | 118 | $this->line_item_display = $line_item_display; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | /** |
183 | - * @return bool |
|
183 | + * @return EE_Form_Section_Proper |
|
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | 186 | EE_Registry::instance()->load_helper( 'HTML' ); |
@@ -537,6 +537,7 @@ discard block |
||
537 | 537 | * _apply_registration_payments_to_amount_owing |
538 | 538 | * |
539 | 539 | * @access protected |
540 | + * @param EE_Base_Class[] $registrations |
|
540 | 541 | * @return void |
541 | 542 | */ |
542 | 543 | protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
@@ -754,7 +755,7 @@ discard block |
||
754 | 755 | * get_billing_form_html_for_payment_method |
755 | 756 | * |
756 | 757 | * @access public |
757 | - * @return string |
|
758 | + * @return boolean |
|
758 | 759 | */ |
759 | 760 | public function get_billing_form_html_for_payment_method() { |
760 | 761 | // how have they chosen to pay? |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | * switch_payment_method |
875 | 876 | * |
876 | 877 | * @access public |
877 | - * @return string |
|
878 | + * @return boolean |
|
878 | 879 | */ |
879 | 880 | public function switch_payment_method() { |
880 | 881 | if ( ! $this->_verify_payment_method_is_set() ) { |
@@ -1041,7 +1042,7 @@ discard block |
||
1041 | 1042 | |
1042 | 1043 | /** |
1043 | 1044 | * process_reg_step |
1044 | - * @return boolean |
|
1045 | + * @return null|boolean |
|
1045 | 1046 | */ |
1046 | 1047 | public function process_reg_step() { |
1047 | 1048 | // how have they chosen to pay? |
@@ -1117,7 +1118,7 @@ discard block |
||
1117 | 1118 | * update_reg_step |
1118 | 1119 | * this is the final step after a user revisits the site to retry a payment |
1119 | 1120 | * |
1120 | - * @return boolean |
|
1121 | + * @return null|boolean |
|
1121 | 1122 | */ |
1122 | 1123 | public function update_reg_step() { |
1123 | 1124 | $success = TRUE; |
@@ -1399,7 +1400,7 @@ discard block |
||
1399 | 1400 | * |
1400 | 1401 | * @access private |
1401 | 1402 | * @type EE_Payment_Method $payment_method |
1402 | - * @return mixed EE_Payment | boolean |
|
1403 | + * @return EE_Payment|null EE_Payment | boolean |
|
1403 | 1404 | */ |
1404 | 1405 | private function _attempt_payment( EE_Payment_Method $payment_method ) { |
1405 | 1406 | $payment =NULL; |
@@ -1602,6 +1603,7 @@ discard block |
||
1602 | 1603 | * @access private |
1603 | 1604 | * @type EE_Payment $payment |
1604 | 1605 | * @param string $payment_occurs |
1606 | + * @param EE_Payment|null $payment |
|
1605 | 1607 | * @return bool |
1606 | 1608 | * @throws \EE_Error |
1607 | 1609 | */ |
@@ -1708,7 +1710,7 @@ discard block |
||
1708 | 1710 | * or present the payment options again |
1709 | 1711 | * |
1710 | 1712 | * @access private |
1711 | - * @return EE_Payment | FALSE |
|
1713 | + * @return boolean | FALSE |
|
1712 | 1714 | */ |
1713 | 1715 | public function process_gateway_response() { |
1714 | 1716 | $payment = null; |
@@ -1769,7 +1771,7 @@ discard block |
||
1769 | 1771 | * _validate_return |
1770 | 1772 | * |
1771 | 1773 | * @access private |
1772 | - * @return bool |
|
1774 | + * @return boolean|null |
|
1773 | 1775 | */ |
1774 | 1776 | private function _validate_offsite_return() { |
1775 | 1777 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
@@ -1836,7 +1838,7 @@ discard block |
||
1836 | 1838 | * |
1837 | 1839 | * @access private |
1838 | 1840 | * @param \EE_Registration $primary_registrant |
1839 | - * @return bool |
|
1841 | + * @return false|null |
|
1840 | 1842 | */ |
1841 | 1843 | private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
1842 | 1844 | if ( ! $primary_registrant instanceof EE_Registration ) { |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public static function set_hooks() { |
31 | - add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) ); |
|
32 | - add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
33 | - add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
34 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
35 | - add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
36 | - add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) ); |
|
37 | - add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
31 | + add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')); |
|
32 | + add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
33 | + add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
34 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
35 | + add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
36 | + add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')); |
|
37 | + add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
38 | 38 | ); |
39 | - add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 ); |
|
39 | + add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * ajax switch_spco_billing_form |
46 | 46 | */ |
47 | 47 | public static function switch_spco_billing_form() { |
48 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
48 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * ajax save_payer_details |
55 | 55 | */ |
56 | 56 | public static function save_payer_details() { |
57 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
57 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * ajax get_transaction_details |
64 | 64 | */ |
65 | 65 | public static function get_transaction_details() { |
66 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
66 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @param EE_Checkout $checkout |
92 | 92 | * @return \EE_SPCO_Reg_Step_Payment_Options |
93 | 93 | */ |
94 | - public function __construct( EE_Checkout $checkout ) { |
|
94 | + public function __construct(EE_Checkout $checkout) { |
|
95 | 95 | $this->_slug = 'payment_options'; |
96 | 96 | $this->_name = __('Payment Options', 'event_espresso'); |
97 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
97 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
98 | 98 | $this->checkout = $checkout; |
99 | 99 | $this->_reset_success_message(); |
100 | - $this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
100 | + $this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param null $line_item_display |
116 | 116 | */ |
117 | - public function set_line_item_display( $line_item_display ) { |
|
117 | + public function set_line_item_display($line_item_display) { |
|
118 | 118 | $this->line_item_display = $line_item_display; |
119 | 119 | } |
120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | public function translate_js_strings() { |
128 | - EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' ); |
|
129 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' ); |
|
130 | - EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' ); |
|
128 | + EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso'); |
|
129 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso'); |
|
130 | + EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | // $ 0.00 transactions (no payment required) |
157 | 157 | ! $this->checkout->payment_required() |
158 | 158 | // but do NOT remove if current action being called belongs to this reg step |
159 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
159 | + && ! is_callable(array($this, $this->checkout->action)) |
|
160 | 160 | && ! $this->completed() |
161 | 161 | ) { |
162 | 162 | // and if so, then we no longer need the Payment Options step |
163 | - if ( $this->is_current_step() ) { |
|
163 | + if ($this->is_current_step()) { |
|
164 | 164 | $this->checkout->generate_reg_form = false; |
165 | 165 | } |
166 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
166 | + $this->checkout->remove_reg_step($this->_slug); |
|
167 | 167 | // DEBUG LOG |
168 | 168 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | // load EEM_Payment_Method |
172 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
172 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
173 | 173 | // get all active payment methods |
174 | 174 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
175 | 175 | $this->checkout->transaction, EEM_Payment_Method::scope_cart |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return bool |
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
186 | + EE_Registry::instance()->load_helper('HTML'); |
|
187 | 187 | // reset in case someone changes their mind |
188 | 188 | $this->_reset_selected_method_of_payment(); |
189 | 189 | // set some defaults |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | $reg_count = 0; |
196 | 196 | $no_payment_required = true; |
197 | 197 | // loop thru registrations to gather info |
198 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
199 | - foreach ( $registrations as $registration ) { |
|
198 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
199 | + foreach ($registrations as $registration) { |
|
200 | 200 | /** @var $registration EE_Registration */ |
201 | 201 | $reg_count++; |
202 | 202 | // registrant is NOT Approved |
203 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
203 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
204 | 204 | // add event to list of events with pre-approval reg status |
205 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
205 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
206 | 206 | do_action( |
207 | 207 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
208 | 208 | $registration->event(), |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | && $registration->event()->is_sold_out() |
220 | 220 | ) { |
221 | 221 | // add event to list of events that are sold out |
222 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
222 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
223 | 223 | do_action( |
224 | 224 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
225 | 225 | $registration->event(), |
@@ -228,29 +228,29 @@ discard block |
||
228 | 228 | continue; |
229 | 229 | } |
230 | 230 | // are they allowed to pay now and is there monies owing? |
231 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
232 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
231 | + if ($registration->owes_monies_and_can_pay()) { |
|
232 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
233 | 233 | do_action( |
234 | 234 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
235 | 235 | $registration->event(), |
236 | 236 | $this |
237 | 237 | ); |
238 | - } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free() ) { |
|
239 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
238 | + } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) { |
|
239 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | $subsections = array(); |
243 | 243 | // now decide which template to load |
244 | - if ( ! empty( $sold_out_events )) { |
|
245 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
244 | + if ( ! empty($sold_out_events)) { |
|
245 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
246 | 246 | } |
247 | - if ( ! empty( $registrations_requiring_pre_approval )) { |
|
248 | - $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval ); |
|
247 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
248 | + $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval); |
|
249 | 249 | } |
250 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
251 | - $subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events ); |
|
250 | + if ( ! empty($registrations_for_free_events)) { |
|
251 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
252 | 252 | } |
253 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
253 | + if ( ! empty($registrations_requiring_payment)) { |
|
254 | 254 | // autoload Line_Item_Display classes |
255 | 255 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
256 | 256 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -261,17 +261,17 @@ discard block |
||
261 | 261 | $this->checkout->cart->get_grand_total() |
262 | 262 | ); |
263 | 263 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
264 | - if ( $this->checkout->amount_owing > 0 ) { |
|
264 | + if ($this->checkout->amount_owing > 0) { |
|
265 | 265 | EEH_Autoloader::register_line_item_display_autoloaders(); |
266 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
267 | - $subsections[ 'payment_options' ] = $this->_display_payment_options( |
|
266 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
267 | + $subsections['payment_options'] = $this->_display_payment_options( |
|
268 | 268 | $this->line_item_display->display_line_item( |
269 | 269 | $filtered_line_item_tree, |
270 | - array( 'registrations' => $registrations ) |
|
270 | + array('registrations' => $registrations) |
|
271 | 271 | ) |
272 | 272 | ); |
273 | 273 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
274 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
274 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
275 | 275 | } |
276 | 276 | $no_payment_required = false; |
277 | 277 | } else { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $this->_save_selected_method_of_payment(); |
281 | 281 | |
282 | 282 | $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
283 | - $subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required ); |
|
283 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
284 | 284 | |
285 | 285 | return new EE_Form_Section_Proper( |
286 | 286 | array( |
@@ -308,21 +308,21 @@ discard block |
||
308 | 308 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
309 | 309 | * @return \EE_Line_Item_Filter_Collection |
310 | 310 | */ |
311 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
312 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
311 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
312 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
313 | 313 | return $line_item_filter_collection; |
314 | 314 | } |
315 | - if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) { |
|
315 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
316 | 316 | return $line_item_filter_collection; |
317 | 317 | } |
318 | - if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) { |
|
318 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
319 | 319 | return $line_item_filter_collection; |
320 | 320 | } |
321 | 321 | $registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
322 | 322 | EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
323 | 323 | ); |
324 | - $line_item_filter_collection->add( new EE_Billable_Line_Item_Filter( $registrations ) ); |
|
325 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
324 | + $line_item_filter_collection->add(new EE_Billable_Line_Item_Filter($registrations)); |
|
325 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
326 | 326 | return $line_item_filter_collection; |
327 | 327 | } |
328 | 328 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @return void |
337 | 337 | */ |
338 | 338 | protected function _hide_reg_step_submit_button_if_revisit() { |
339 | - if ( $this->checkout->revisit ) { |
|
340 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
339 | + if ($this->checkout->revisit) { |
|
340 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -348,25 +348,25 @@ discard block |
||
348 | 348 | * @param \EE_Event[] $sold_out_events_array |
349 | 349 | * @return \EE_Form_Section_Proper |
350 | 350 | */ |
351 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
351 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
352 | 352 | // set some defaults |
353 | 353 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
354 | 354 | $sold_out_events = ''; |
355 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
356 | - $sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )); |
|
355 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
356 | + $sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')); |
|
357 | 357 | } |
358 | 358 | return new EE_Form_Section_Proper( |
359 | 359 | array( |
360 | 360 | 'layout_strategy' => new EE_Template_Layout( |
361 | 361 | array( |
362 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template |
|
362 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template |
|
363 | 363 | 'template_args' => apply_filters( |
364 | 364 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
365 | 365 | array( |
366 | 366 | 'sold_out_events' => $sold_out_events, |
367 | 367 | 'sold_out_events_msg' => apply_filters( |
368 | 368 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
369 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ) |
|
369 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso') |
|
370 | 370 | ) |
371 | 371 | ) |
372 | 372 | ) |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | * @param array $registrations_requiring_pre_approval |
384 | 384 | * @return \EE_Form_Section_Proper |
385 | 385 | */ |
386 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) { |
|
386 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
387 | 387 | $events_requiring_pre_approval = ''; |
388 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
389 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
390 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
391 | - EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
388 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
389 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
390 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
391 | + EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
392 | 392 | ) |
393 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
393 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
394 | 394 | ); |
395 | 395 | } |
396 | 396 | } |
@@ -398,14 +398,14 @@ discard block |
||
398 | 398 | array( |
399 | 399 | 'layout_strategy' => new EE_Template_Layout( |
400 | 400 | array( |
401 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template |
|
401 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template |
|
402 | 402 | 'template_args' => apply_filters( |
403 | 403 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
404 | 404 | array( |
405 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
405 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
406 | 406 | 'events_requiring_pre_approval_msg' => apply_filters( |
407 | 407 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
408 | - __( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' ) |
|
408 | + __('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso') |
|
409 | 409 | ) |
410 | 410 | ) |
411 | 411 | ), |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @param \EE_Event[] $registrations_for_free_events |
424 | 424 | * @return \EE_Form_Section_Proper |
425 | 425 | */ |
426 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
426 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
427 | 427 | // set some defaults |
428 | 428 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
429 | 429 | // generate no_payment_required form |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | array( |
432 | 432 | 'layout_strategy' => new EE_Template_Layout( |
433 | 433 | array( |
434 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template |
|
434 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template |
|
435 | 435 | 'template_args' => apply_filters( |
436 | 436 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
437 | 437 | array( |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | 'registrations' => array(), |
440 | 440 | 'ticket_count' => array(), |
441 | 441 | 'registrations_for_free_events' => $registrations_for_free_events, |
442 | - 'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' )) |
|
442 | + 'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso')) |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ) |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * @param string $transaction_details |
457 | 457 | * @return \EE_Form_Section_Proper |
458 | 458 | */ |
459 | - private function _display_payment_options( $transaction_details = '' ) { |
|
459 | + private function _display_payment_options($transaction_details = '') { |
|
460 | 460 | // has method_of_payment been set by no-js user? |
461 | 461 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
462 | 462 | // build payment options form |
@@ -468,18 +468,18 @@ discard block |
||
468 | 468 | 'before_payment_options' => apply_filters( |
469 | 469 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
470 | 470 | new EE_Form_Section_Proper( |
471 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
471 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
472 | 472 | ) |
473 | 473 | ), |
474 | 474 | 'payment_options' => $this->_setup_payment_options(), |
475 | 475 | 'after_payment_options' => apply_filters( |
476 | 476 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
477 | 477 | new EE_Form_Section_Proper( |
478 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
478 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
479 | 479 | ) |
480 | 480 | ), |
481 | 481 | ), |
482 | - 'layout_strategy' => new EE_Template_Layout( array( |
|
482 | + 'layout_strategy' => new EE_Template_Layout(array( |
|
483 | 483 | 'layout_template_file' => $this->_template, |
484 | 484 | 'template_args' => apply_filters( |
485 | 485 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | * @param bool $no_payment_required |
504 | 504 | * @return \EE_Form_Section_Proper |
505 | 505 | */ |
506 | - private function _extra_hidden_inputs( $no_payment_required = TRUE ) { |
|
506 | + private function _extra_hidden_inputs($no_payment_required = TRUE) { |
|
507 | 507 | |
508 | 508 | return new EE_Form_Section_Proper( |
509 | 509 | array( |
510 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
510 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
511 | 511 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
512 | 512 | 'subsections' => array( |
513 | 513 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -540,16 +540,16 @@ discard block |
||
540 | 540 | * @access protected |
541 | 541 | * @return void |
542 | 542 | */ |
543 | - protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
|
543 | + protected function _apply_registration_payments_to_amount_owing($registrations) { |
|
544 | 544 | $payments = array(); |
545 | - foreach ( $registrations as $registration ) { |
|
546 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
545 | + foreach ($registrations as $registration) { |
|
546 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
547 | 547 | $payments = $payments + $registration->registration_payments(); |
548 | 548 | } |
549 | 549 | } |
550 | - if ( ! empty( $payments ) ) { |
|
551 | - foreach ( $payments as $payment ) { |
|
552 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
550 | + if ( ! empty($payments)) { |
|
551 | + foreach ($payments as $payment) { |
|
552 | + if ($payment instanceof EE_Registration_Payment) { |
|
553 | 553 | $this->checkout->amount_owing -= $payment->amount(); |
554 | 554 | } |
555 | 555 | } |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | * @param bool $force_reset |
565 | 565 | * @return void |
566 | 566 | */ |
567 | - private function _reset_selected_method_of_payment( $force_reset = FALSE ) { |
|
568 | - $reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE )); |
|
569 | - if ( $reset_payment_method ) { |
|
567 | + private function _reset_selected_method_of_payment($force_reset = FALSE) { |
|
568 | + $reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE)); |
|
569 | + if ($reset_payment_method) { |
|
570 | 570 | $this->checkout->selected_method_of_payment = NULL; |
571 | 571 | $this->checkout->payment_method = NULL; |
572 | 572 | $this->checkout->billing_form = NULL; |
@@ -585,9 +585,9 @@ discard block |
||
585 | 585 | * @param string $selected_method_of_payment |
586 | 586 | * @return EE_Billing_Info_Form |
587 | 587 | */ |
588 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
589 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
590 | - EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment )); |
|
588 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
589 | + $selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
590 | + EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment)); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -600,40 +600,40 @@ discard block |
||
600 | 600 | // load payment method classes |
601 | 601 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
602 | 602 | // switch up header depending on number of available payment methods |
603 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
604 | - ? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' )) |
|
605 | - : apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' )); |
|
603 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
604 | + ? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso')) |
|
605 | + : apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso')); |
|
606 | 606 | $available_payment_methods = array( |
607 | 607 | // display the "Payment Method" header |
608 | 608 | 'payment_method_header' => new EE_Form_Section_HTML( |
609 | - EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' ) |
|
609 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
610 | 610 | ) |
611 | 611 | ); |
612 | 612 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
613 | 613 | $available_payment_method_options = array(); |
614 | 614 | $default_payment_method_option = array(); |
615 | 615 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
616 | - $payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' ))); |
|
616 | + $payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;'))); |
|
617 | 617 | // loop through payment methods |
618 | - foreach( $this->checkout->available_payment_methods as $payment_method ) { |
|
619 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
620 | - $payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' ); |
|
618 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
619 | + if ($payment_method instanceof EE_Payment_Method) { |
|
620 | + $payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img'); |
|
621 | 621 | // check if any payment methods are set as default |
622 | 622 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
623 | - if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) { |
|
623 | + if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) { |
|
624 | 624 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
625 | 625 | $this->_save_selected_method_of_payment(); |
626 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
626 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
627 | 627 | } else { |
628 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
628 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
629 | 629 | } |
630 | - $payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method ); |
|
630 | + $payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method); |
|
631 | 631 | } |
632 | 632 | } |
633 | 633 | // prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs |
634 | 634 | $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
635 | 635 | // now generate the actual form inputs |
636 | - $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options ); |
|
636 | + $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options); |
|
637 | 637 | $available_payment_methods = $available_payment_methods + $payment_methods_billing_info; |
638 | 638 | |
639 | 639 | // build the available payment methods form |
@@ -653,19 +653,19 @@ discard block |
||
653 | 653 | * @return EE_Payment_Method[] |
654 | 654 | */ |
655 | 655 | protected function _get_available_payment_methods() { |
656 | - if ( ! empty( $this->checkout->available_payment_methods )) { |
|
656 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
657 | 657 | return $this->checkout->available_payment_methods; |
658 | 658 | } |
659 | 659 | $available_payment_methods = array(); |
660 | 660 | // load EEM_Payment_Method |
661 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
661 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
662 | 662 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
663 | 663 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
664 | 664 | // get all active payment methods |
665 | - $payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart ); |
|
666 | - foreach ( $payment_methods as $payment_method ) { |
|
667 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
668 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
665 | + $payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart); |
|
666 | + foreach ($payment_methods as $payment_method) { |
|
667 | + if ($payment_method instanceof EE_Payment_Method) { |
|
668 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | return $available_payment_methods; |
@@ -681,14 +681,14 @@ discard block |
||
681 | 681 | * @param array $available_payment_method_options |
682 | 682 | * @return \EE_Form_Section_Proper |
683 | 683 | */ |
684 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
684 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
685 | 685 | // generate inputs |
686 | 686 | return new EE_Form_Section_Proper( |
687 | 687 | array( |
688 | 688 | 'html_id' => 'ee-available-payment-method-inputs', |
689 | 689 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
690 | 690 | 'subsections' => array( |
691 | - '' => new EE_Radio_Button_Input ( |
|
691 | + '' => new EE_Radio_Button_Input( |
|
692 | 692 | $available_payment_method_options, |
693 | 693 | array( |
694 | 694 | 'html_name' => 'selected_method_of_payment', |
@@ -712,36 +712,36 @@ discard block |
||
712 | 712 | * @param EE_Payment_Method $payment_method |
713 | 713 | * @return \EE_Form_Section_Proper |
714 | 714 | */ |
715 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
715 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
716 | 716 | $currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE; |
717 | 717 | // generate the billing form for payment method |
718 | - $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML(); |
|
718 | + $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML(); |
|
719 | 719 | $this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form; |
720 | 720 | // it's all in the details |
721 | - $info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' ); |
|
721 | + $info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr'); |
|
722 | 722 | // add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not |
723 | - if ( $payment_method->description() ) { |
|
723 | + if ($payment_method->description()) { |
|
724 | 724 | $payment_method_info = $payment_method->description(); |
725 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
726 | - $payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
725 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
726 | + $payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
727 | 727 | } else { |
728 | - $payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
728 | + $payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
729 | 729 | } |
730 | - $info_html .= EEH_HTML::p ( |
|
731 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ), |
|
730 | + $info_html .= EEH_HTML::p( |
|
731 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info), |
|
732 | 732 | '', |
733 | 733 | 'spco-payment-method-desc ee-attention' |
734 | 734 | ); |
735 | 735 | |
736 | 736 | return new EE_Form_Section_Proper( |
737 | 737 | array( |
738 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
738 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
739 | 739 | 'html_class' => 'spco-payment-method-info-dv', |
740 | 740 | // only display the selected or default PM |
741 | 741 | 'html_style' => $currently_selected ? '' : 'display:none;', |
742 | 742 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
743 | 743 | 'subsections' => array( |
744 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
744 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
745 | 745 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
746 | 746 | ) |
747 | 747 | ) |
@@ -759,12 +759,12 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public function get_billing_form_html_for_payment_method() { |
761 | 761 | // how have they chosen to pay? |
762 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
762 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
763 | 763 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
764 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
764 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
765 | 765 | return FALSE; |
766 | 766 | } |
767 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
767 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
768 | 768 | EE_Error::add_success( |
769 | 769 | apply_filters( |
770 | 770 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -773,20 +773,20 @@ discard block |
||
773 | 773 | ); |
774 | 774 | } |
775 | 775 | // now generate billing form for selected method of payment |
776 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
776 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
777 | 777 | // fill form with attendee info if applicable |
778 | - if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
779 | - $payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
778 | + if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
779 | + $payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
780 | 780 | } |
781 | 781 | // and debug content |
782 | - if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
783 | - $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form ); |
|
782 | + if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
783 | + $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form); |
|
784 | 784 | } |
785 | 785 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : ''; |
786 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info )); |
|
786 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
787 | 787 | // localize validation rules for main form |
788 | 788 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
789 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
789 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
790 | 790 | return TRUE; |
791 | 791 | } |
792 | 792 | |
@@ -799,15 +799,15 @@ discard block |
||
799 | 799 | * @param EE_Payment_Method $payment_method |
800 | 800 | * @return \EE_Billing_Info_Form |
801 | 801 | */ |
802 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
803 | - $billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) ); |
|
804 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
805 | - if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) { |
|
806 | - if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) { |
|
802 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
803 | + $billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing)); |
|
804 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
805 | + if (EE_Registry::instance()->REQ->is_set('payment_method')) { |
|
806 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
807 | 807 | EE_Error::add_success( |
808 | 808 | apply_filters( |
809 | 809 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
810 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() ) |
|
810 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name()) |
|
811 | 811 | ) |
812 | 812 | ); |
813 | 813 | } |
@@ -832,27 +832,27 @@ discard block |
||
832 | 832 | * @param string $request_param |
833 | 833 | * @return NULL|string |
834 | 834 | */ |
835 | - private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) { |
|
835 | + private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') { |
|
836 | 836 | // is selected_method_of_payment set in the request ? |
837 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE ); |
|
838 | - if ( $selected_method_of_payment ) { |
|
837 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE); |
|
838 | + if ($selected_method_of_payment) { |
|
839 | 839 | // sanitize it |
840 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment; |
|
841 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
840 | + $selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment; |
|
841 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
842 | 842 | // store it in the session so that it's available for all subsequent requests including AJAX |
843 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
843 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
844 | 844 | } else { |
845 | 845 | // or is is set in the session ? |
846 | - $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' ); |
|
846 | + $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment'); |
|
847 | 847 | } |
848 | 848 | // do ya really really gotta have it? |
849 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
849 | + if (empty($selected_method_of_payment) && $required) { |
|
850 | 850 | EE_Error::add_error( |
851 | 851 | sprintf( |
852 | - __( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ), |
|
852 | + __('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'), |
|
853 | 853 | '<br/>', |
854 | 854 | '<br/>', |
855 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
855 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
856 | 856 | ), |
857 | 857 | __FILE__, __FUNCTION__, __LINE__ |
858 | 858 | ); |
@@ -878,37 +878,37 @@ discard block |
||
878 | 878 | * @return string |
879 | 879 | */ |
880 | 880 | public function switch_payment_method() { |
881 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
881 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
882 | 882 | return false; |
883 | 883 | } |
884 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
884 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
885 | 885 | EE_Error::add_success( |
886 | 886 | apply_filters( |
887 | 887 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
888 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() ) |
|
888 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name()) |
|
889 | 889 | ) |
890 | 890 | ); |
891 | 891 | } |
892 | 892 | // generate billing form for selected method of payment if it hasn't been done already |
893 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
894 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
893 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
894 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
895 | 895 | } |
896 | 896 | // fill form with attendee info if applicable |
897 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
898 | - $this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
897 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
898 | + $this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
899 | 899 | } |
900 | 900 | // and debug content |
901 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
902 | - $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form ); |
|
901 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
902 | + $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form); |
|
903 | 903 | } |
904 | 904 | // get html and validation rules for form |
905 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
906 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() )); |
|
905 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
906 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html())); |
|
907 | 907 | // localize validation rules for main form |
908 | - $this->checkout->billing_form->localize_validation_rules( TRUE ); |
|
909 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
908 | + $this->checkout->billing_form->localize_validation_rules(TRUE); |
|
909 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
910 | 910 | } else { |
911 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' )); |
|
911 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
912 | 912 | } |
913 | 913 | //prevents advancement to next step |
914 | 914 | $this->checkout->continue_reg = FALSE; |
@@ -923,18 +923,18 @@ discard block |
||
923 | 923 | */ |
924 | 924 | protected function _verify_payment_method_is_set() { |
925 | 925 | // generate billing form for selected method of payment if it hasn't been done already |
926 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
926 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
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 | } else { |
930 | 930 | // choose your own adventure based on method_of_payment |
931 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
931 | + switch ($this->checkout->selected_method_of_payment) { |
|
932 | 932 | case 'events_sold_out' : |
933 | 933 | EE_Error::add_attention( |
934 | 934 | apply_filters( |
935 | 935 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
936 | - __( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
937 | - 'event_espresso' ) |
|
936 | + __('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
937 | + 'event_espresso') |
|
938 | 938 | ), |
939 | 939 | __FILE__, __FUNCTION__, __LINE__ |
940 | 940 | ); |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | EE_Error::add_attention( |
945 | 945 | apply_filters( |
946 | 946 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
947 | - __( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
947 | + __('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
948 | 948 | ), |
949 | 949 | __FILE__, __FUNCTION__, __LINE__ |
950 | 950 | ); |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | EE_Error::add_attention( |
955 | 955 | apply_filters( |
956 | 956 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
957 | - __( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
957 | + __('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
958 | 958 | ), |
959 | 959 | __FILE__, __FUNCTION__, __LINE__ |
960 | 960 | ); |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | } |
965 | 965 | } |
966 | 966 | // verify payment method |
967 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
967 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
968 | 968 | // get payment method for selected method of payment |
969 | 969 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
970 | 970 | } |
@@ -984,23 +984,23 @@ discard block |
||
984 | 984 | * @return void |
985 | 985 | */ |
986 | 986 | public function save_payer_details_via_ajax() { |
987 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
987 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
988 | 988 | return; |
989 | 989 | } |
990 | 990 | // generate billing form for selected method of payment if it hasn't been done already |
991 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
992 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
991 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
992 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
993 | 993 | } |
994 | 994 | // generate primary attendee from payer info if applicable |
995 | 995 | if ( ! $this->checkout->transaction_has_primary_registrant()) { |
996 | 996 | $attendee = $this->_create_attendee_from_request_data(); |
997 | - if ( $attendee instanceof EE_Attendee ) { |
|
998 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
999 | - if ( $registration->is_primary_registrant() ) { |
|
997 | + if ($attendee instanceof EE_Attendee) { |
|
998 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
999 | + if ($registration->is_primary_registrant()) { |
|
1000 | 1000 | $this->checkout->primary_attendee_obj = $attendee; |
1001 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1002 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1003 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1001 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1002 | + $registration->set_attendee_id($attendee->ID()); |
|
1003 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1013,56 +1013,56 @@ discard block |
||
1013 | 1013 | * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
1014 | 1014 | * @return \EE_Attendee |
1015 | 1015 | */ |
1016 | - protected function _create_attendee_from_request_data(){ |
|
1016 | + protected function _create_attendee_from_request_data() { |
|
1017 | 1017 | // get State ID |
1018 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1019 | - if ( ! empty( $STA_ID )) { |
|
1018 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1019 | + if ( ! empty($STA_ID)) { |
|
1020 | 1020 | // can we get state object from name ? |
1021 | - EE_Registry::instance()->load_model( 'State' ); |
|
1022 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' ); |
|
1023 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1021 | + EE_Registry::instance()->load_model('State'); |
|
1022 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1023 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1024 | 1024 | } |
1025 | 1025 | // get Country ISO |
1026 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1027 | - if ( ! empty( $CNT_ISO )) { |
|
1026 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1027 | + if ( ! empty($CNT_ISO)) { |
|
1028 | 1028 | // can we get country object from name ? |
1029 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1030 | - $country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' ); |
|
1031 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1029 | + EE_Registry::instance()->load_model('Country'); |
|
1030 | + $country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO'); |
|
1031 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1032 | 1032 | } |
1033 | 1033 | // grab attendee data |
1034 | 1034 | $attendee_data = array( |
1035 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1036 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1037 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1038 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1039 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1040 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1035 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1036 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1037 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1038 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1039 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1040 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1041 | 1041 | 'STA_ID' => $STA_ID, |
1042 | 1042 | 'CNT_ISO' => $CNT_ISO, |
1043 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1044 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1043 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1044 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1045 | 1045 | ); |
1046 | 1046 | // validate the email address since it is the most important piece of info |
1047 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) { |
|
1048 | - EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1047 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) { |
|
1048 | + EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1049 | 1049 | } |
1050 | 1050 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1051 | - if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) { |
|
1052 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1051 | + if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) { |
|
1052 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1053 | 1053 | 'ATT_fname' => $attendee_data['ATT_fname'], |
1054 | 1054 | 'ATT_lname' => $attendee_data['ATT_lname'], |
1055 | 1055 | 'ATT_email' => $attendee_data['ATT_email'] |
1056 | 1056 | )); |
1057 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1057 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1058 | 1058 | return $existing_attendee; |
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | // no existing attendee? kk let's create a new one |
1062 | 1062 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1063 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1064 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1065 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1063 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1064 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1065 | + return EE_Attendee::new_instance($attendee_data); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1082,22 +1082,22 @@ discard block |
||
1082 | 1082 | */ |
1083 | 1083 | public function process_reg_step() { |
1084 | 1084 | // how have they chosen to pay? |
1085 | - $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE ); |
|
1085 | + $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE); |
|
1086 | 1086 | // choose your own adventure based on method_of_payment |
1087 | - switch( $this->checkout->selected_method_of_payment ) { |
|
1087 | + switch ($this->checkout->selected_method_of_payment) { |
|
1088 | 1088 | |
1089 | 1089 | case 'events_sold_out' : |
1090 | 1090 | $this->checkout->redirect = TRUE; |
1091 | 1091 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1092 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1092 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1093 | 1093 | // mark this reg step as completed |
1094 | 1094 | $this->set_completed(); |
1095 | 1095 | return FALSE; |
1096 | 1096 | break; |
1097 | 1097 | |
1098 | 1098 | case 'payments_closed' : |
1099 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) { |
|
1100 | - EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1099 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) { |
|
1100 | + EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1101 | 1101 | } |
1102 | 1102 | // mark this reg step as completed |
1103 | 1103 | $this->set_completed(); |
@@ -1105,8 +1105,8 @@ discard block |
||
1105 | 1105 | break; |
1106 | 1106 | |
1107 | 1107 | case 'no_payment_required' : |
1108 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) { |
|
1109 | - EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1108 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) { |
|
1109 | + EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1110 | 1110 | } |
1111 | 1111 | // mark this reg step as completed |
1112 | 1112 | $this->set_completed(); |
@@ -1115,9 +1115,9 @@ discard block |
||
1115 | 1115 | |
1116 | 1116 | default: |
1117 | 1117 | $payment_successful = $this->_process_payment(); |
1118 | - if ( $payment_successful ) { |
|
1118 | + if ($payment_successful) { |
|
1119 | 1119 | $this->checkout->continue_reg = true; |
1120 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1120 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1121 | 1121 | } else { |
1122 | 1122 | $this->checkout->continue_reg = false; |
1123 | 1123 | } |
@@ -1135,8 +1135,8 @@ discard block |
||
1135 | 1135 | * @param \EE_Payment_Method $payment_method |
1136 | 1136 | * @return void |
1137 | 1137 | */ |
1138 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1139 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1138 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1139 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1140 | 1140 | case EE_PMT_Base::offsite : |
1141 | 1141 | break; |
1142 | 1142 | case EE_PMT_Base::onsite : |
@@ -1159,15 +1159,15 @@ discard block |
||
1159 | 1159 | public function update_reg_step() { |
1160 | 1160 | $success = TRUE; |
1161 | 1161 | // if payment required |
1162 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1163 | - do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction ); |
|
1162 | + if ($this->checkout->transaction->total() > 0) { |
|
1163 | + do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction); |
|
1164 | 1164 | // attempt payment via payment method |
1165 | 1165 | $success = $this->process_reg_step(); |
1166 | 1166 | } |
1167 | - if ( $success && ! $this->checkout->redirect ) { |
|
1168 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() ); |
|
1167 | + if ($success && ! $this->checkout->redirect) { |
|
1168 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID()); |
|
1169 | 1169 | // set return URL |
1170 | - $this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url ); |
|
1170 | + $this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url); |
|
1171 | 1171 | } |
1172 | 1172 | return $success; |
1173 | 1173 | } |
@@ -1185,32 +1185,32 @@ discard block |
||
1185 | 1185 | */ |
1186 | 1186 | private function _process_payment() { |
1187 | 1187 | // basically confirm that the event hasn't sold out since they hit the page |
1188 | - if ( ! $this->_last_second_ticket_verifications() ) { |
|
1188 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
1189 | 1189 | return false; |
1190 | 1190 | } |
1191 | 1191 | // ya gotta make a choice man |
1192 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
1193 | - $this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' )); |
|
1192 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1193 | + $this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso')); |
|
1194 | 1194 | return FALSE; |
1195 | 1195 | } |
1196 | 1196 | // get EE_Payment_Method object |
1197 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1197 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1198 | 1198 | return FALSE; |
1199 | 1199 | } |
1200 | 1200 | // setup billing form |
1201 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1202 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1201 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1202 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1203 | 1203 | // bad billing form ? |
1204 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1204 | + if ( ! $this->_billing_form_is_valid()) { |
|
1205 | 1205 | return FALSE; |
1206 | 1206 | } |
1207 | 1207 | } |
1208 | 1208 | // ensure primary registrant has been fully processed |
1209 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1209 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1210 | 1210 | return FALSE; |
1211 | 1211 | } |
1212 | 1212 | // if session is close to expiring (under 10 minutes by default) |
1213 | - if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) { |
|
1213 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
1214 | 1214 | // add some time to session expiration so that payment can be completed |
1215 | 1215 | EE_Registry::instance()->SSN->extend_expiration(); |
1216 | 1216 | } |
@@ -1219,24 +1219,24 @@ discard block |
||
1219 | 1219 | // 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 |
1220 | 1220 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1221 | 1221 | // attempt payment |
1222 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1222 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1223 | 1223 | // process results |
1224 | - $payment = $this->_validate_payment( $payment ); |
|
1225 | - $payment = $this->_post_payment_processing( $payment ); |
|
1224 | + $payment = $this->_validate_payment($payment); |
|
1225 | + $payment = $this->_post_payment_processing($payment); |
|
1226 | 1226 | // verify payment |
1227 | - if ( $payment instanceof EE_Payment ) { |
|
1227 | + if ($payment instanceof EE_Payment) { |
|
1228 | 1228 | // store that for later |
1229 | 1229 | $this->checkout->payment = $payment; |
1230 | 1230 | /** @type EE_Transaction_Processor $transaction_processor */ |
1231 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1231 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1232 | 1232 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1233 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1234 | - if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) { |
|
1233 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1234 | + if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) { |
|
1235 | 1235 | return true; |
1236 | 1236 | } else { |
1237 | 1237 | return false; |
1238 | 1238 | } |
1239 | - } else if ( $payment === true ) { |
|
1239 | + } else if ($payment === true) { |
|
1240 | 1240 | // please note that offline payment methods will NOT make a payment, |
1241 | 1241 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1242 | 1242 | $this->checkout->payment = $payment; |
@@ -1256,22 +1256,22 @@ discard block |
||
1256 | 1256 | */ |
1257 | 1257 | protected function _last_second_ticket_verifications() { |
1258 | 1258 | // don't bother re-validating if not a return visit |
1259 | - if ( ! $this->checkout->revisit ) { |
|
1259 | + if ( ! $this->checkout->revisit) { |
|
1260 | 1260 | return true; |
1261 | 1261 | } |
1262 | 1262 | $registrations = $this->checkout->transaction->registrations(); |
1263 | - if ( empty( $registrations ) ) { |
|
1263 | + if (empty($registrations)) { |
|
1264 | 1264 | return false; |
1265 | 1265 | } |
1266 | - foreach ( $registrations as $registration ) { |
|
1267 | - if ( $registration instanceof EE_Registration ) { |
|
1266 | + foreach ($registrations as $registration) { |
|
1267 | + if ($registration instanceof EE_Registration) { |
|
1268 | 1268 | $event = $registration->event_obj(); |
1269 | - if ( ! ( $event instanceof EE_Event && $event->is_sold_out( true ) ) ) { |
|
1269 | + if ( ! ($event instanceof EE_Event && $event->is_sold_out(true))) { |
|
1270 | 1270 | EE_Error::add_error( |
1271 | 1271 | apply_filters( |
1272 | 1272 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
1273 | 1273 | sprintf( |
1274 | - __( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ), |
|
1274 | + __('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'), |
|
1275 | 1275 | $event->name() |
1276 | 1276 | ) |
1277 | 1277 | ), |
@@ -1295,10 +1295,10 @@ discard block |
||
1295 | 1295 | * @return bool |
1296 | 1296 | */ |
1297 | 1297 | public function redirect_form() { |
1298 | - $payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() ); |
|
1298 | + $payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment()); |
|
1299 | 1299 | $html = $payment_method_billing_info->get_html_and_js(); |
1300 | 1300 | $html .= $this->checkout->redirect_form; |
1301 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1301 | + EE_Registry::instance()->REQ->add_output($html); |
|
1302 | 1302 | return TRUE; |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1311,33 +1311,33 @@ discard block |
||
1311 | 1311 | * @return bool |
1312 | 1312 | */ |
1313 | 1313 | private function _billing_form_is_valid() { |
1314 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1315 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1314 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1315 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1316 | 1316 | $this->checkout->billing_form->receive_form_submission(); |
1317 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1317 | + if ($this->checkout->billing_form->is_valid()) { |
|
1318 | 1318 | return TRUE; |
1319 | 1319 | } |
1320 | 1320 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1321 | 1321 | $error_strings = array(); |
1322 | - foreach( $validation_errors as $validation_error ){ |
|
1323 | - if( $validation_error instanceof EE_Validation_Error ){ |
|
1322 | + foreach ($validation_errors as $validation_error) { |
|
1323 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1324 | 1324 | $form_section = $validation_error->get_form_section(); |
1325 | - if( $form_section instanceof EE_Form_Input_Base ){ |
|
1325 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1326 | 1326 | $label = $form_section->html_label_text(); |
1327 | - }elseif( $form_section instanceof EE_Form_Section_Base ){ |
|
1327 | + }elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1328 | 1328 | $label = $form_section->name(); |
1329 | - }else{ |
|
1330 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1329 | + } else { |
|
1330 | + $label = __('Validation Error', 'event_espresso'); |
|
1331 | 1331 | } |
1332 | - $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1332 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1333 | 1333 | } |
1334 | 1334 | } |
1335 | - EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings ) ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1335 | + EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__); |
|
1336 | 1336 | } else { |
1337 | - EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1337 | + EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1338 | 1338 | } |
1339 | 1339 | } else { |
1340 | - EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1340 | + EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1341 | 1341 | } |
1342 | 1342 | return FALSE; |
1343 | 1343 | } |
@@ -1355,9 +1355,9 @@ discard block |
||
1355 | 1355 | */ |
1356 | 1356 | private function _setup_primary_registrant_prior_to_payment() { |
1357 | 1357 | // check if transaction has a primary registrant and that it has a related Attendee object |
1358 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1358 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1359 | 1359 | // need to at least gather some primary registrant data before attempting payment |
1360 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) { |
|
1360 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) { |
|
1361 | 1361 | return FALSE; |
1362 | 1362 | } |
1363 | 1363 | } |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | // grab the primary_registration object |
1366 | 1366 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1367 | 1367 | /** @type EE_Transaction_Processor $transaction_processor */ |
1368 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1368 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1369 | 1369 | // at this point we'll consider a TXN to not have been failed |
1370 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1370 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1371 | 1371 | // save the TXN ( which clears cached copy of primary_registration) |
1372 | 1372 | $this->checkout->transaction->save(); |
1373 | 1373 | // grab TXN ID and save it to the primary_registration |
1374 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1374 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1375 | 1375 | // save what we have so far |
1376 | 1376 | $primary_registration->save(); |
1377 | 1377 | return TRUE; |
@@ -1388,41 +1388,41 @@ discard block |
||
1388 | 1388 | private function _capture_primary_registration_data_from_billing_form() { |
1389 | 1389 | // convert billing form data into an attendee |
1390 | 1390 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1391 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1391 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1392 | 1392 | EE_Error::add_error( |
1393 | 1393 | sprintf( |
1394 | - __( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1394 | + __('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1395 | 1395 | '<br/>', |
1396 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1396 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1397 | 1397 | ), __FILE__, __FUNCTION__, __LINE__ |
1398 | 1398 | ); |
1399 | 1399 | return FALSE; |
1400 | 1400 | } |
1401 | 1401 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1402 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1402 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1403 | 1403 | EE_Error::add_error( |
1404 | 1404 | sprintf( |
1405 | - __( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1405 | + __('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1406 | 1406 | '<br/>', |
1407 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1407 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1408 | 1408 | ), __FILE__, __FUNCTION__, __LINE__ |
1409 | 1409 | ); |
1410 | 1410 | return FALSE; |
1411 | 1411 | } |
1412 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) { |
|
1412 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) { |
|
1413 | 1413 | EE_Error::add_error( |
1414 | 1414 | sprintf( |
1415 | - __( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1415 | + __('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1416 | 1416 | '<br/>', |
1417 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1417 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1418 | 1418 | ), __FILE__, __FUNCTION__, __LINE__ |
1419 | 1419 | ); |
1420 | 1420 | return FALSE; |
1421 | 1421 | } |
1422 | 1422 | /** @type EE_Registration_Processor $registration_processor */ |
1423 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1423 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1424 | 1424 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1425 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1425 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1426 | 1426 | |
1427 | 1427 | return TRUE; |
1428 | 1428 | } |
@@ -1438,35 +1438,35 @@ discard block |
||
1438 | 1438 | */ |
1439 | 1439 | private function _get_payment_method_for_selected_method_of_payment() { |
1440 | 1440 | // get EE_Payment_Method object |
1441 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) { |
|
1442 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1441 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1442 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1443 | 1443 | } else { |
1444 | 1444 | // load EEM_Payment_Method |
1445 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1445 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1446 | 1446 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1447 | 1447 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1448 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1448 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1449 | 1449 | } |
1450 | 1450 | // verify $payment_method |
1451 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1451 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1452 | 1452 | // not a payment |
1453 | 1453 | EE_Error::add_error( |
1454 | 1454 | sprintf( |
1455 | - __( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1455 | + __('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1456 | 1456 | '<br/>', |
1457 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1457 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1458 | 1458 | ), __FILE__, __FUNCTION__, __LINE__ |
1459 | 1459 | ); |
1460 | 1460 | return NULL; |
1461 | 1461 | } |
1462 | 1462 | // and verify it has a valid Payment_Method Type object |
1463 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1463 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1464 | 1464 | // not a payment |
1465 | 1465 | EE_Error::add_error( |
1466 | 1466 | sprintf( |
1467 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1467 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1468 | 1468 | '<br/>', |
1469 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1469 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1470 | 1470 | ), __FILE__, __FUNCTION__, __LINE__ |
1471 | 1471 | ); |
1472 | 1472 | return NULL; |
@@ -1485,30 +1485,30 @@ discard block |
||
1485 | 1485 | * @type EE_Payment_Method $payment_method |
1486 | 1486 | * @return mixed EE_Payment | boolean |
1487 | 1487 | */ |
1488 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1489 | - $payment =NULL; |
|
1488 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1489 | + $payment = NULL; |
|
1490 | 1490 | $this->checkout->transaction->save(); |
1491 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1492 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1491 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1492 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1493 | 1493 | return FALSE; |
1494 | 1494 | } |
1495 | 1495 | try { |
1496 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1496 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1497 | 1497 | // generate payment object |
1498 | 1498 | $payment = $payment_processor->process_payment( |
1499 | 1499 | $payment_method, |
1500 | 1500 | $this->checkout->transaction, |
1501 | 1501 | $this->checkout->amount_owing, |
1502 | 1502 | $this->checkout->billing_form, |
1503 | - $this->_get_return_url( $payment_method ), |
|
1503 | + $this->_get_return_url($payment_method), |
|
1504 | 1504 | 'CART', |
1505 | 1505 | $this->checkout->admin_request, |
1506 | 1506 | TRUE, |
1507 | 1507 | $this->reg_step_url() |
1508 | 1508 | ); |
1509 | 1509 | |
1510 | - } catch( Exception $e ) { |
|
1511 | - $this->_handle_payment_processor_exception( $e ); |
|
1510 | + } catch (Exception $e) { |
|
1511 | + $this->_handle_payment_processor_exception($e); |
|
1512 | 1512 | } |
1513 | 1513 | return $payment; |
1514 | 1514 | } |
@@ -1522,12 +1522,12 @@ discard block |
||
1522 | 1522 | * @param \Exception $e |
1523 | 1523 | * @return void |
1524 | 1524 | */ |
1525 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1525 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1526 | 1526 | EE_Error::add_error( |
1527 | 1527 | sprintf( |
1528 | - __( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ), |
|
1528 | + __('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'), |
|
1529 | 1529 | '<br/>', |
1530 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1530 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1531 | 1531 | $e->getMessage(), |
1532 | 1532 | $e->getFile(), |
1533 | 1533 | $e->getLine() |
@@ -1544,9 +1544,9 @@ discard block |
||
1544 | 1544 | * @param \EE_Payment_Method $payment_method |
1545 | 1545 | * @return string |
1546 | 1546 | */ |
1547 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1547 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1548 | 1548 | $return_url = ''; |
1549 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1549 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1550 | 1550 | |
1551 | 1551 | case EE_PMT_Base::offsite : |
1552 | 1552 | $return_url = add_query_arg( |
@@ -1577,27 +1577,27 @@ discard block |
||
1577 | 1577 | * @param EE_Payment $payment |
1578 | 1578 | * @return EE_Payment | FALSE |
1579 | 1579 | */ |
1580 | - private function _validate_payment( $payment = NULL ) { |
|
1581 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1580 | + private function _validate_payment($payment = NULL) { |
|
1581 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1582 | 1582 | return TRUE; |
1583 | 1583 | } |
1584 | 1584 | // verify payment object |
1585 | - if ( $payment instanceof EE_Payment ) { |
|
1585 | + if ($payment instanceof EE_Payment) { |
|
1586 | 1586 | if ( |
1587 | 1587 | $payment->status() != EEM_Payment::status_id_approved |
1588 | 1588 | && $payment->status() != EEM_Payment::status_id_pending |
1589 | 1589 | && $payment->status() != EEM_Payment::status_id_cancelled |
1590 | 1590 | && $payment->gateway_response() != '' |
1591 | 1591 | ) { |
1592 | - EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1592 | + EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__); |
|
1593 | 1593 | } |
1594 | 1594 | } else { |
1595 | 1595 | // not a payment |
1596 | 1596 | EE_Error::add_error( |
1597 | 1597 | sprintf( |
1598 | - __( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1598 | + __('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1599 | 1599 | '<br/>', |
1600 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1600 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1601 | 1601 | ), __FILE__, __FUNCTION__, __LINE__ |
1602 | 1602 | ); |
1603 | 1603 | return FALSE; |
@@ -1614,23 +1614,23 @@ discard block |
||
1614 | 1614 | * @param EE_Payment $payment |
1615 | 1615 | * @return bool |
1616 | 1616 | */ |
1617 | - private function _post_payment_processing( $payment = NULL ) { |
|
1617 | + private function _post_payment_processing($payment = NULL) { |
|
1618 | 1618 | // On-Site payment? |
1619 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1620 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) { |
|
1619 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1620 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1621 | 1621 | //$this->_setup_redirect_for_next_step(); |
1622 | 1622 | $this->checkout->continue_reg = false; |
1623 | 1623 | } |
1624 | 1624 | // Off-Site payment? |
1625 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1625 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1626 | 1626 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1627 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ){ |
|
1628 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1627 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1628 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1629 | 1629 | $this->checkout->redirect = TRUE; |
1630 | 1630 | $this->checkout->redirect_form = $payment->redirect_form(); |
1631 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1631 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1632 | 1632 | // set JSON response |
1633 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1633 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1634 | 1634 | // set cron job for finalizing the TXN |
1635 | 1635 | // in case the user does not return from the off-site gateway |
1636 | 1636 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1638,21 +1638,21 @@ discard block |
||
1638 | 1638 | $this->checkout->transaction->ID() |
1639 | 1639 | ); |
1640 | 1640 | // and lastly, let's bump the payment status to pending |
1641 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1641 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1642 | 1642 | $payment->save(); |
1643 | 1643 | } else { |
1644 | 1644 | // not a payment |
1645 | 1645 | $this->checkout->continue_reg = false; |
1646 | 1646 | EE_Error::add_error( |
1647 | 1647 | sprintf( |
1648 | - __( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1648 | + __('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1649 | 1649 | '<br/>', |
1650 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1650 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1651 | 1651 | ), __FILE__, __FUNCTION__, __LINE__ |
1652 | 1652 | ); |
1653 | 1653 | } |
1654 | 1654 | // Off-Line payment? |
1655 | - } else if ( $payment === TRUE ) { |
|
1655 | + } else if ($payment === TRUE) { |
|
1656 | 1656 | //$this->_setup_redirect_for_next_step(); |
1657 | 1657 | return TRUE; |
1658 | 1658 | } else { |
@@ -1688,65 +1688,65 @@ discard block |
||
1688 | 1688 | * @return bool |
1689 | 1689 | * @throws \EE_Error |
1690 | 1690 | */ |
1691 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1691 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1692 | 1692 | // off-line payment? carry on |
1693 | - if ( $payment_occurs == EE_PMT_Base::offline ) { |
|
1693 | + if ($payment_occurs == EE_PMT_Base::offline) { |
|
1694 | 1694 | return true; |
1695 | 1695 | } |
1696 | 1696 | // verify payment validity |
1697 | - if ( $payment instanceof EE_Payment ) { |
|
1698 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1697 | + if ($payment instanceof EE_Payment) { |
|
1698 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1699 | 1699 | $msg = $payment->gateway_response(); |
1700 | 1700 | // check results |
1701 | - switch ( $payment->status() ) { |
|
1701 | + switch ($payment->status()) { |
|
1702 | 1702 | |
1703 | 1703 | // good payment |
1704 | 1704 | case EEM_Payment::status_id_approved : |
1705 | - EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1705 | + EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1706 | 1706 | return TRUE; |
1707 | 1707 | break; |
1708 | 1708 | |
1709 | 1709 | // slow payment |
1710 | 1710 | case EEM_Payment::status_id_pending : |
1711 | - if ( empty( $msg )) { |
|
1712 | - $msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' ); |
|
1711 | + if (empty($msg)) { |
|
1712 | + $msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso'); |
|
1713 | 1713 | } |
1714 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1714 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1715 | 1715 | return TRUE; |
1716 | 1716 | break; |
1717 | 1717 | |
1718 | 1718 | // don't wanna payment |
1719 | 1719 | case EEM_Payment::status_id_cancelled : |
1720 | - if ( empty( $msg )) { |
|
1720 | + if (empty($msg)) { |
|
1721 | 1721 | $msg = _n( |
1722 | 1722 | 'Payment cancelled. Please try again.', |
1723 | 1723 | 'Payment cancelled. Please try again or select another method of payment.', |
1724 | - count( $this->checkout->available_payment_methods ), |
|
1724 | + count($this->checkout->available_payment_methods), |
|
1725 | 1725 | 'event_espresso' |
1726 | 1726 | ); |
1727 | 1727 | } |
1728 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1728 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1729 | 1729 | return FALSE; |
1730 | 1730 | break; |
1731 | 1731 | |
1732 | 1732 | // not enough payment |
1733 | 1733 | case EEM_Payment::status_id_declined : |
1734 | - if ( empty( $msg )) { |
|
1734 | + if (empty($msg)) { |
|
1735 | 1735 | $msg = _n( |
1736 | 1736 | 'We\'re sorry but your payment was declined. Please try again.', |
1737 | 1737 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
1738 | - count( $this->checkout->available_payment_methods ), |
|
1738 | + count($this->checkout->available_payment_methods), |
|
1739 | 1739 | 'event_espresso' |
1740 | 1740 | ); |
1741 | 1741 | } |
1742 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1742 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1743 | 1743 | return FALSE; |
1744 | 1744 | break; |
1745 | 1745 | |
1746 | 1746 | // bad payment |
1747 | 1747 | case EEM_Payment::status_id_failed : |
1748 | - if ( ! empty( $msg ) ) { |
|
1749 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1748 | + if ( ! empty($msg)) { |
|
1749 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1750 | 1750 | return false; |
1751 | 1751 | } |
1752 | 1752 | // default to error below |
@@ -1756,14 +1756,14 @@ discard block |
||
1756 | 1756 | } |
1757 | 1757 | // off-site payment gateway responses are too unreliable, so let's just assume that |
1758 | 1758 | // the payment processing is just running slower than the registrant's request |
1759 | - if ( $payment_occurs == EE_PMT_Base::offsite ) { |
|
1759 | + if ($payment_occurs == EE_PMT_Base::offsite) { |
|
1760 | 1760 | return true; |
1761 | 1761 | } |
1762 | 1762 | EE_Error::add_error( |
1763 | 1763 | sprintf( |
1764 | - __( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1764 | + __('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1765 | 1765 | '<br/>', |
1766 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1766 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1767 | 1767 | ), |
1768 | 1768 | __FILE__, __FUNCTION__, __LINE__ |
1769 | 1769 | ); |
@@ -1796,13 +1796,13 @@ discard block |
||
1796 | 1796 | public function process_gateway_response() { |
1797 | 1797 | $payment = null; |
1798 | 1798 | // how have they chosen to pay? |
1799 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1799 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1800 | 1800 | // get EE_Payment_Method object |
1801 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1801 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1802 | 1802 | $this->checkout->continue_reg = false; |
1803 | 1803 | return false; |
1804 | 1804 | } |
1805 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
1805 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
1806 | 1806 | return false; |
1807 | 1807 | } |
1808 | 1808 | $this->_validate_offsite_return(); |
@@ -1816,23 +1816,23 @@ discard block |
||
1816 | 1816 | // true |
1817 | 1817 | //); |
1818 | 1818 | // verify TXN |
1819 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1819 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1820 | 1820 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
1821 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
1821 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
1822 | 1822 | $this->checkout->continue_reg = false; |
1823 | 1823 | return false; |
1824 | 1824 | } |
1825 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
1826 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
1827 | - $payment = $this->_validate_payment( $payment ); |
|
1825 | + $payment = $this->_process_off_site_payment($gateway); |
|
1826 | + $payment = $this->_process_cancelled_payments($payment); |
|
1827 | + $payment = $this->_validate_payment($payment); |
|
1828 | 1828 | // if payment was not declined by the payment gateway or cancelled by the registrant |
1829 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
1829 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
1830 | 1830 | //$this->_setup_redirect_for_next_step(); |
1831 | 1831 | // store that for later |
1832 | 1832 | $this->checkout->payment = $payment; |
1833 | 1833 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
1834 | 1834 | // because we will complete this step during the IPN processing then |
1835 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) { |
|
1835 | + if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) { |
|
1836 | 1836 | $this->set_completed(); |
1837 | 1837 | } |
1838 | 1838 | return true; |
@@ -1855,19 +1855,19 @@ discard block |
||
1855 | 1855 | * @return bool |
1856 | 1856 | */ |
1857 | 1857 | private function _validate_offsite_return() { |
1858 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
1859 | - if ( $TXN_ID != $this->checkout->transaction->ID() ) { |
|
1858 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
1859 | + if ($TXN_ID != $this->checkout->transaction->ID()) { |
|
1860 | 1860 | // Houston... we might have a problem |
1861 | 1861 | $invalid_TXN = false; |
1862 | 1862 | // first gather some info |
1863 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1863 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1864 | 1864 | $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null; |
1865 | 1865 | // let's start by retrieving the cart for this TXN |
1866 | - $cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction ); |
|
1867 | - if ( $cart instanceof EE_Cart ) { |
|
1866 | + $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction); |
|
1867 | + if ($cart instanceof EE_Cart) { |
|
1868 | 1868 | // verify that the current cart has tickets |
1869 | 1869 | $tickets = $cart->get_tickets(); |
1870 | - if ( empty( $tickets ) ) { |
|
1870 | + if (empty($tickets)) { |
|
1871 | 1871 | $invalid_TXN = true; |
1872 | 1872 | } |
1873 | 1873 | } else { |
@@ -1875,39 +1875,39 @@ discard block |
||
1875 | 1875 | } |
1876 | 1876 | $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null; |
1877 | 1877 | // validate current Session ID and compare against valid TXN session ID |
1878 | - if ( EE_Session::instance()->id() === null ) { |
|
1878 | + if (EE_Session::instance()->id() === null) { |
|
1879 | 1879 | $invalid_TXN = true; |
1880 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
1880 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
1881 | 1881 | // WARNING !!! |
1882 | 1882 | // this could be PayPal sending back duplicate requests (ya they do that) |
1883 | 1883 | // or it **could** mean someone is simply registering AGAIN after having just done so |
1884 | 1884 | // so now we need to determine if this current TXN looks valid or not |
1885 | 1885 | /** @type EE_Transaction_Processor $transaction_processor */ |
1886 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1886 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1887 | 1887 | // has this step even been started ? |
1888 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
1888 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
1889 | 1889 | ) { |
1890 | 1890 | // really? you're half way through this reg step, but you never started it ? |
1891 | 1891 | $invalid_TXN = true; |
1892 | 1892 | } |
1893 | 1893 | } |
1894 | - if ( $invalid_TXN ) { |
|
1894 | + if ($invalid_TXN) { |
|
1895 | 1895 | // is the valid TXN completed ? |
1896 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
1896 | + if ($valid_TXN instanceof EE_Transaction) { |
|
1897 | 1897 | /** @type EE_Transaction_Processor $transaction_processor */ |
1898 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1898 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1899 | 1899 | // has this step even been started ? |
1900 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
1901 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
1900 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
1901 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
1902 | 1902 | // so it **looks** like this is a double request from PayPal |
1903 | 1903 | // so let's try to pick up where we left off |
1904 | 1904 | $this->checkout->transaction = $valid_TXN; |
1905 | - $this->checkout->refresh_all_entities( true ); |
|
1905 | + $this->checkout->refresh_all_entities(true); |
|
1906 | 1906 | return; |
1907 | 1907 | } |
1908 | 1908 | } |
1909 | 1909 | // you appear to be lost? |
1910 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
1910 | + $this->_redirect_wayward_request($primary_registrant); |
|
1911 | 1911 | } |
1912 | 1912 | } |
1913 | 1913 | } |
@@ -1921,16 +1921,16 @@ discard block |
||
1921 | 1921 | * @param \EE_Registration $primary_registrant |
1922 | 1922 | * @return bool |
1923 | 1923 | */ |
1924 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
1925 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1924 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
1925 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1926 | 1926 | // try redirecting based on the current TXN |
1927 | 1927 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null; |
1928 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1928 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1929 | 1929 | EE_Error::add_error( |
1930 | 1930 | sprintf( |
1931 | - __( 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1931 | + __('Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1932 | 1932 | '<br/>', |
1933 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1933 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1934 | 1934 | ), |
1935 | 1935 | __FILE__, __FUNCTION__, __LINE__ |
1936 | 1936 | ); |
@@ -1958,16 +1958,16 @@ discard block |
||
1958 | 1958 | * @param \EE_Offsite_Gateway $gateway |
1959 | 1959 | * @return \EE_Payment |
1960 | 1960 | */ |
1961 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
1961 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
1962 | 1962 | try { |
1963 | 1963 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
1964 | - if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) { |
|
1964 | + if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) { |
|
1965 | 1965 | $payment = $this->checkout->transaction->last_payment(); |
1966 | 1966 | //$payment_source = 'last_payment'; |
1967 | 1967 | } else { |
1968 | 1968 | // get payment details and process results |
1969 | 1969 | /** @type EE_Payment_Processor $payment_processor */ |
1970 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1970 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1971 | 1971 | $payment = $payment_processor->process_ipn( |
1972 | 1972 | $_REQUEST, |
1973 | 1973 | $this->checkout->transaction, |
@@ -1977,14 +1977,14 @@ discard block |
||
1977 | 1977 | ); |
1978 | 1978 | //$payment_source = 'process_ipn'; |
1979 | 1979 | } |
1980 | - } catch ( Exception $e ) { |
|
1980 | + } catch (Exception $e) { |
|
1981 | 1981 | // let's just eat the exception and try to move on using any previously set payment info |
1982 | 1982 | $payment = $this->checkout->transaction->last_payment(); |
1983 | 1983 | //$payment_source = 'last_payment after Exception'; |
1984 | 1984 | // but if we STILL don't have a payment object |
1985 | - if ( ! $payment instanceof EE_Payment ) { |
|
1985 | + if ( ! $payment instanceof EE_Payment) { |
|
1986 | 1986 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
1987 | - $this->_handle_payment_processor_exception( $e ); |
|
1987 | + $this->_handle_payment_processor_exception($e); |
|
1988 | 1988 | } |
1989 | 1989 | } |
1990 | 1990 | // DEBUG LOG |
@@ -2008,13 +2008,13 @@ discard block |
||
2008 | 2008 | * @param EE_Payment $payment |
2009 | 2009 | * @return EE_Payment | FALSE |
2010 | 2010 | */ |
2011 | - private function _process_cancelled_payments( $payment = NULL ) { |
|
2011 | + private function _process_cancelled_payments($payment = NULL) { |
|
2012 | 2012 | if ( |
2013 | - isset( $_REQUEST[ 'ee_cancel_payment' ] ) |
|
2013 | + isset($_REQUEST['ee_cancel_payment']) |
|
2014 | 2014 | && $payment instanceof EE_Payment |
2015 | 2015 | && $payment->status() == EEM_Payment::status_id_failed |
2016 | 2016 | ) { |
2017 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2017 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2018 | 2018 | } |
2019 | 2019 | return $payment; |
2020 | 2020 | } |
@@ -2031,23 +2031,23 @@ discard block |
||
2031 | 2031 | public function get_transaction_details_for_gateways() { |
2032 | 2032 | $txn_details = array(); |
2033 | 2033 | // ya gotta make a choice man |
2034 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2034 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2035 | 2035 | $txn_details = array( |
2036 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2036 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2037 | 2037 | ); |
2038 | 2038 | } |
2039 | 2039 | // get EE_Payment_Method object |
2040 | 2040 | if ( |
2041 | - empty( $txn_details ) && |
|
2041 | + empty($txn_details) && |
|
2042 | 2042 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2043 | 2043 | ) { |
2044 | 2044 | $txn_details = array( |
2045 | 2045 | 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
2046 | - 'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' ) |
|
2046 | + 'error' => __('A valid Payment Method could not be determined.', 'event_espresso') |
|
2047 | 2047 | ); |
2048 | 2048 | } |
2049 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2050 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2049 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2050 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2051 | 2051 | $txn_details = array( |
2052 | 2052 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2053 | 2053 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2059 | 2059 | 'payment_amount' => $this->checkout->amount_owing, |
2060 | 2060 | 'return_url' => $return_url, |
2061 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2061 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2062 | 2062 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2063 | 2063 | array( |
2064 | 2064 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2067,7 +2067,7 @@ discard block |
||
2067 | 2067 | ) |
2068 | 2068 | ); |
2069 | 2069 | } |
2070 | - echo json_encode( $txn_details ); |
|
2070 | + echo json_encode($txn_details); |
|
2071 | 2071 | exit(); |
2072 | 2072 | } |
2073 | 2073 |
@@ -69,104 +69,104 @@ discard block |
||
69 | 69 | * @param array $options |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
72 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
73 | 73 | |
74 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
75 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
74 | + EE_Registry::instance()->load_helper('Template'); |
|
75 | + EE_Registry::instance()->load_helper('HTML'); |
|
76 | 76 | |
77 | 77 | $html = ''; |
78 | 78 | // set some default options and merge with incoming |
79 | 79 | $default_options = array( |
80 | - 'show_desc' => true, // true false |
|
80 | + 'show_desc' => true, // true false |
|
81 | 81 | 'odd' => false |
82 | 82 | ); |
83 | - $options = array_merge( $default_options, (array)$options ); |
|
83 | + $options = array_merge($default_options, (array) $options); |
|
84 | 84 | |
85 | - switch( $line_item->type() ) { |
|
85 | + switch ($line_item->type()) { |
|
86 | 86 | |
87 | 87 | case EEM_Line_Item::type_line_item: |
88 | 88 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
89 | - if ( $line_item->OBJ_type() == 'Ticket' ) { |
|
89 | + if ($line_item->OBJ_type() == 'Ticket') { |
|
90 | 90 | // item row |
91 | - $html .= $this->_ticket_row( $line_item, $options ); |
|
91 | + $html .= $this->_ticket_row($line_item, $options); |
|
92 | 92 | // got any kids? |
93 | - foreach ( $line_item->children() as $child_line_item ) { |
|
94 | - $this->display_line_item( $child_line_item, $options ); |
|
93 | + foreach ($line_item->children() as $child_line_item) { |
|
94 | + $this->display_line_item($child_line_item, $options); |
|
95 | 95 | } |
96 | 96 | } else { |
97 | 97 | // item row |
98 | - $html .= $this->_item_row( $line_item, $options ); |
|
98 | + $html .= $this->_item_row($line_item, $options); |
|
99 | 99 | // got any kids? |
100 | - foreach ( $line_item->children() as $child_line_item ) { |
|
101 | - $this->display_line_item( $child_line_item, $options ); |
|
100 | + foreach ($line_item->children() as $child_line_item) { |
|
101 | + $this->display_line_item($child_line_item, $options); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | |
106 | 106 | case EEM_Line_Item::type_sub_line_item: |
107 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
107 | + $html .= $this->_sub_item_row($line_item, $options); |
|
108 | 108 | break; |
109 | 109 | |
110 | 110 | case EEM_Line_Item::type_sub_total: |
111 | 111 | static $sub_total = 0; |
112 | 112 | $event_sub_total = 0; |
113 | - $text = __( 'Sub-Total', 'event_espresso' ); |
|
114 | - if ( $line_item->OBJ_type() == 'Event' ) { |
|
115 | - $options[ 'event_id' ] = $event_id = $line_item->OBJ_ID(); |
|
116 | - if ( ! isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
117 | - $event = EEM_Event::instance()->get_one_by_ID( $options[ 'event_id' ] ); |
|
118 | - if ( $event instanceof EE_Event ) { |
|
119 | - if ( $event->default_registration_status() == EEM_Registration::status_id_not_approved ) { |
|
113 | + $text = __('Sub-Total', 'event_espresso'); |
|
114 | + if ($line_item->OBJ_type() == 'Event') { |
|
115 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
116 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
117 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
118 | + if ($event instanceof EE_Event) { |
|
119 | + if ($event->default_registration_status() == EEM_Registration::status_id_not_approved) { |
|
120 | 120 | return ''; |
121 | 121 | } |
122 | 122 | } |
123 | - $this->_events[ $options[ 'event_id' ] ] = 0; |
|
124 | - $html .= $this->_event_row( $line_item ); |
|
125 | - $text = __( 'Event Sub-Total', 'event_espresso' ); |
|
123 | + $this->_events[$options['event_id']] = 0; |
|
124 | + $html .= $this->_event_row($line_item); |
|
125 | + $text = __('Event Sub-Total', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | $child_line_items = $line_item->children(); |
129 | 129 | // loop thru children |
130 | - foreach( $child_line_items as $child_line_item ) { |
|
130 | + foreach ($child_line_items as $child_line_item) { |
|
131 | 131 | // recursively feed children back into this method |
132 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
132 | + $html .= $this->display_line_item($child_line_item, $options); |
|
133 | 133 | } |
134 | - $event_sub_total += isset( $options[ 'event_id' ] ) ? $this->_events[ $options[ 'event_id' ] ] : 0; |
|
134 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
135 | 135 | $sub_total += $event_sub_total; |
136 | 136 | if ( |
137 | 137 | ( |
138 | 138 | // event subtotals |
139 | 139 | $line_item->code() != 'pre-tax-subtotal' && |
140 | - count( $child_line_items ) > 1 |
|
140 | + count($child_line_items) > 1 |
|
141 | 141 | ) |
142 | 142 | || |
143 | 143 | ( |
144 | 144 | // pre-tax subtotals |
145 | 145 | $line_item->code() == 'pre-tax-subtotal' && |
146 | - count( $this->_events ) > 1 |
|
146 | + count($this->_events) > 1 |
|
147 | 147 | ) |
148 | 148 | ) { |
149 | 149 | $options['sub_total'] = $line_item->OBJ_type() == 'Event' ? $event_sub_total : $sub_total; |
150 | - $html .= $this->_sub_total_row( $line_item, $text, $options ); |
|
150 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
151 | 151 | } |
152 | 152 | break; |
153 | 153 | |
154 | 154 | case EEM_Line_Item::type_tax: |
155 | - if ( $this->_show_taxes ) { |
|
156 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
155 | + if ($this->_show_taxes) { |
|
156 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
157 | 157 | } |
158 | 158 | break; |
159 | 159 | |
160 | 160 | case EEM_Line_Item::type_tax_sub_total: |
161 | - if ( $this->_show_taxes ) { |
|
161 | + if ($this->_show_taxes) { |
|
162 | 162 | $child_line_items = $line_item->children(); |
163 | 163 | // loop thru children |
164 | - foreach( $child_line_items as $child_line_item ) { |
|
164 | + foreach ($child_line_items as $child_line_item) { |
|
165 | 165 | // recursively feed children back into this method |
166 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
166 | + $html .= $this->display_line_item($child_line_item, $options); |
|
167 | 167 | } |
168 | - if ( count( $child_line_items ) > 1 ) { |
|
169 | - $this->_taxes_html .= $this->_total_tax_row( $line_item, __( 'Tax Total', 'event_espresso' ) ); |
|
168 | + if (count($child_line_items) > 1) { |
|
169 | + $this->_taxes_html .= $this->_total_tax_row($line_item, __('Tax Total', 'event_espresso')); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | break; |
@@ -175,25 +175,25 @@ discard block |
||
175 | 175 | // get all child line items |
176 | 176 | $children = $line_item->children(); |
177 | 177 | // loop thru all non-tax child line items |
178 | - foreach( $children as $child_line_item ) { |
|
179 | - if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) { |
|
178 | + foreach ($children as $child_line_item) { |
|
179 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
180 | 180 | // recursively feed children back into this method |
181 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
181 | + $html .= $this->display_line_item($child_line_item, $options); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | 185 | // now loop thru tax child line items |
186 | - foreach( $children as $child_line_item ) { |
|
187 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) { |
|
186 | + foreach ($children as $child_line_item) { |
|
187 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
188 | 188 | // recursively feed children back into this method |
189 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
189 | + $html .= $this->display_line_item($child_line_item, $options); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | $html .= $this->_taxes_html; |
193 | - $html .= $this->_total_row( $line_item, __('Total', 'event_espresso') ); |
|
193 | + $html .= $this->_total_row($line_item, __('Total', 'event_espresso')); |
|
194 | 194 | |
195 | 195 | |
196 | - $html .= $this->_payments_and_amount_owing_rows( $line_item, $options ); |
|
196 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
197 | 197 | break; |
198 | 198 | |
199 | 199 | } |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | * @param EE_Line_Item $line_item |
209 | 209 | * @return mixed |
210 | 210 | */ |
211 | - private function _event_row( EE_Line_Item $line_item ) { |
|
211 | + private function _event_row(EE_Line_Item $line_item) { |
|
212 | 212 | // start of row |
213 | - $html = EEH_HTML::tr( '', 'event-cart-total-row', 'total_tr odd' ); |
|
213 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
214 | 214 | // event name td |
215 | - $html .= EEH_HTML::td( EEH_HTML::strong( $line_item->name() ), '', 'event-header', '', ' colspan="4"' ); |
|
215 | + $html .= EEH_HTML::td(EEH_HTML::strong($line_item->name()), '', 'event-header', '', ' colspan="4"'); |
|
216 | 216 | // end of row |
217 | 217 | $html .= EEH_HTML::trx(); |
218 | 218 | return $html; |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * @param array $options |
228 | 228 | * @return mixed |
229 | 229 | */ |
230 | - private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
|
230 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) { |
|
231 | 231 | // start of row |
232 | 232 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
233 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
233 | + $html = EEH_HTML::tr('', '', $row_class); |
|
234 | 234 | // name && desc |
235 | 235 | $name_and_desc = apply_filters( |
236 | 236 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
@@ -239,23 +239,23 @@ discard block |
||
239 | 239 | ); |
240 | 240 | $name_and_desc .= apply_filters( |
241 | 241 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
242 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
242 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
243 | 243 | $line_item, |
244 | 244 | $options |
245 | 245 | ); |
246 | 246 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
247 | 247 | // name td |
248 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
248 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
249 | 249 | // price td |
250 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
250 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
251 | 251 | // quantity td |
252 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
252 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
253 | 253 | $this->_total_items += $line_item->quantity(); |
254 | 254 | // determine total for line item |
255 | 255 | $total = $line_item->total(); |
256 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
256 | + $this->_events[$options['event_id']] += $total; |
|
257 | 257 | // total td |
258 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
258 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
259 | 259 | // end of row |
260 | 260 | $html .= EEH_HTML::trx(); |
261 | 261 | return $html; |
@@ -270,38 +270,38 @@ discard block |
||
270 | 270 | * @param array $options |
271 | 271 | * @return mixed |
272 | 272 | */ |
273 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
273 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
274 | 274 | // start of row |
275 | 275 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
276 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
276 | + $html = EEH_HTML::tr('', '', $row_class); |
|
277 | 277 | // name && desc |
278 | 278 | $name_and_desc = apply_filters( |
279 | 279 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
280 | - $line_item->OBJ_type() . ': ' . $line_item->name(), |
|
280 | + $line_item->OBJ_type().': '.$line_item->name(), |
|
281 | 281 | $line_item |
282 | 282 | ); |
283 | 283 | $name_and_desc .= apply_filters( |
284 | 284 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
285 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
285 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
286 | 286 | $line_item, |
287 | 287 | $options |
288 | 288 | ); |
289 | 289 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
290 | 290 | // name td |
291 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l' ); |
|
291 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
292 | 292 | // price td |
293 | - if ( $line_item->is_percent() ) { |
|
294 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' ); |
|
293 | + if ($line_item->is_percent()) { |
|
294 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
295 | 295 | } else { |
296 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
296 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
297 | 297 | } |
298 | 298 | // quantity td |
299 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
299 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
300 | 300 | //$total = $line_item->total() * $line_item->quantity(); |
301 | 301 | $total = $line_item->total(); |
302 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
302 | + $this->_events[$options['event_id']] += $total; |
|
303 | 303 | // total td |
304 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
304 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
305 | 305 | // end of row |
306 | 306 | $html .= EEH_HTML::trx(); |
307 | 307 | return $html; |
@@ -316,22 +316,22 @@ discard block |
||
316 | 316 | * @param array $options |
317 | 317 | * @return mixed |
318 | 318 | */ |
319 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
319 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
320 | 320 | // start of row |
321 | - $html = EEH_HTML::tr( '', 'item sub-item-row' ); |
|
321 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
322 | 322 | // name && desc |
323 | 323 | $name_and_desc = $line_item->name(); |
324 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
324 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
325 | 325 | // name td |
326 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
326 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
327 | 327 | // discount/surcharge td |
328 | - if ( $line_item->is_percent() ) { |
|
329 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c' ); |
|
328 | + if ($line_item->is_percent()) { |
|
329 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
330 | 330 | } else { |
331 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
331 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
332 | 332 | } |
333 | 333 | // total td |
334 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
334 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
335 | 335 | // end of row |
336 | 336 | $html .= EEH_HTML::trx(); |
337 | 337 | return $html; |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | * @param array $options |
347 | 347 | * @return mixed |
348 | 348 | */ |
349 | - private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
349 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
350 | 350 | // start of row |
351 | - $html = EEH_HTML::tr( '', 'item sub-item tax-total' ); |
|
351 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
352 | 352 | // name && desc |
353 | 353 | $name_and_desc = $line_item->name(); |
354 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>'; |
|
355 | - $name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : ''; |
|
354 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>'; |
|
355 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
356 | 356 | // name td |
357 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
357 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
358 | 358 | // percent td |
359 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', ' jst-rght', '' ); |
|
359 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
360 | 360 | // empty td (price) |
361 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
361 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
362 | 362 | // total td |
363 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
363 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
364 | 364 | // end of row |
365 | 365 | $html .= EEH_HTML::trx(); |
366 | 366 | return $html; |
@@ -375,17 +375,17 @@ discard block |
||
375 | 375 | * @param string $text |
376 | 376 | * @return mixed |
377 | 377 | */ |
378 | - private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) { |
|
378 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') { |
|
379 | 379 | $html = ''; |
380 | - if ( $line_item->total() ) { |
|
380 | + if ($line_item->total()) { |
|
381 | 381 | // start of row |
382 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
382 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
383 | 383 | // total td |
384 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' ); |
|
384 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"'); |
|
385 | 385 | // empty td (price) |
386 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
386 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
387 | 387 | // total td |
388 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
388 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
389 | 389 | // end of row |
390 | 390 | $html .= EEH_HTML::trx(); |
391 | 391 | } |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | * @param array $options |
403 | 403 | * @return mixed |
404 | 404 | */ |
405 | - private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
405 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
406 | 406 | $html = ''; |
407 | - if ( $line_item->total() ) { |
|
407 | + if ($line_item->total()) { |
|
408 | 408 | // start of row |
409 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
409 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
410 | 410 | // total td |
411 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
411 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
412 | 412 | // total td |
413 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' ); |
|
413 | + $html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght'); |
|
414 | 414 | // end of row |
415 | 415 | $html .= EEH_HTML::trx(); |
416 | 416 | } |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | * @param string $text |
428 | 428 | * @return mixed |
429 | 429 | */ |
430 | - private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
|
430 | + private function _total_row(EE_Line_Item $line_item, $text = '') { |
|
431 | 431 | // start of row |
432 | - $html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' ); |
|
432 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
433 | 433 | // total td |
434 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
434 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
435 | 435 | // total td |
436 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
436 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
437 | 437 | // end of row |
438 | 438 | $html .= EEH_HTML::trx(); |
439 | 439 | return $html; |
@@ -448,30 +448,30 @@ discard block |
||
448 | 448 | * @param array $options |
449 | 449 | * @return mixed |
450 | 450 | */ |
451 | - private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) { |
|
451 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) { |
|
452 | 452 | $html = ''; |
453 | 453 | $owing = $line_item->total(); |
454 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() ); |
|
455 | - if ( $transaction instanceof EE_Transaction ) { |
|
454 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
455 | + if ($transaction instanceof EE_Transaction) { |
|
456 | 456 | $registration_payments = array(); |
457 | - $registrations = ! empty( $options['registrations'] ) |
|
458 | - ? $options[ 'registrations' ] |
|
457 | + $registrations = ! empty($options['registrations']) |
|
458 | + ? $options['registrations'] |
|
459 | 459 | : $transaction->registrations(); |
460 | - foreach ( $registrations as $registration ) { |
|
461 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
460 | + foreach ($registrations as $registration) { |
|
461 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
462 | 462 | $registration_payments = $registration_payments + $registration->registration_payments(); |
463 | 463 | } |
464 | 464 | } |
465 | - if ( ! empty( $registration_payments )) { |
|
466 | - foreach ( $registration_payments as $registration_payment ) { |
|
467 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
465 | + if ( ! empty($registration_payments)) { |
|
466 | + foreach ($registration_payments as $registration_payment) { |
|
467 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
468 | 468 | $owing = $owing - $registration_payment->amount(); |
469 | 469 | $payment = $registration_payment->payment(); |
470 | - if ( $payment instanceof EE_Payment ) { |
|
470 | + if ($payment instanceof EE_Payment) { |
|
471 | 471 | $payment_desc = sprintf( |
472 | - __( 'Payment%1$s Received: %2$s', 'event_espresso' ), |
|
472 | + __('Payment%1$s Received: %2$s', 'event_espresso'), |
|
473 | 473 | $payment->txn_id_chq_nmbr() != '' |
474 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
474 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
475 | 475 | : '', |
476 | 476 | $payment->timestamp() |
477 | 477 | ); |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | $payment_desc = ''; |
480 | 480 | } |
481 | 481 | // start of row |
482 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
482 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
483 | 483 | // payment desc |
484 | - $html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' ); |
|
484 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
485 | 485 | // total td |
486 | 486 | $html .= EEH_HTML::td( |
487 | - EEH_Template::format_currency( $registration_payment->amount(), false, false ), |
|
487 | + EEH_Template::format_currency($registration_payment->amount(), false, false), |
|
488 | 488 | '', |
489 | 489 | 'total jst-rght' |
490 | 490 | ); |
@@ -492,17 +492,17 @@ discard block |
||
492 | 492 | $html .= EEH_HTML::trx(); |
493 | 493 | } |
494 | 494 | } |
495 | - if ( $line_item->total() ) { |
|
495 | + if ($line_item->total()) { |
|
496 | 496 | // start of row |
497 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
497 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
498 | 498 | // total td |
499 | 499 | $html .= EEH_HTML::td( |
500 | 500 | __('Amount Owing', 'event_espresso'), |
501 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
501 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
502 | 502 | ); |
503 | 503 | // total td |
504 | 504 | $html .= EEH_HTML::td( |
505 | - EEH_Template::format_currency( $owing, false, false ), '', 'total jst-rght' |
|
505 | + EEH_Template::format_currency($owing, false, false), '', 'total jst-rght' |
|
506 | 506 | ); |
507 | 507 | // end of row |
508 | 508 | $html .= EEH_HTML::trx(); |
@@ -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 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
45 | 45 | * @return \Payments_Admin_Page |
46 | 46 | */ |
47 | - public function __construct( $routing = TRUE ) { |
|
48 | - parent::__construct( $routing ); |
|
47 | + public function __construct($routing = TRUE) { |
|
48 | + parent::__construct($routing); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | protected function _set_page_config() { |
131 | 131 | $payment_method_list_config = array( |
132 | 132 | 'nav' => array( |
133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
134 | 134 | 'order' => 10 |
135 | 135 | ), |
136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
137 | 137 | 'help_tabs' => array_merge( |
138 | 138 | array( |
139 | 139 | 'payment_methods_overview_help_tab' => array( |
140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
141 | 141 | 'filename' => 'payment_methods_overview' |
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | $this->_add_payment_method_help_tabs() ), |
145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
146 | 146 | 'require_nonce' => false |
147 | 147 | ); |
148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ) |
161 | 161 | ), |
162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | 164 | 'require_nonce' => FALSE |
165 | 165 | ), |
166 | 166 | 'payment_log'=>array( |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _add_payment_method_help_tabs(){ |
|
182 | + protected function _add_payment_method_help_tabs() { |
|
183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
185 | 185 | $all_pmt_help_tabs_config = array(); |
186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
186 | + foreach ($payment_method_types as $payment_method_type) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | 191 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
192 | 192 | 'title'=>$config['title'], |
193 | - 'content'=>EEH_Template::display_template( $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true) |
|
193 | + 'content'=>EEH_Template::display_template($payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true) |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | public function load_scripts_styles() { |
214 | - wp_enqueue_script( 'ee_admin_js' ); |
|
215 | - wp_enqueue_script( 'ee-text-links' ); |
|
216 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
214 | + wp_enqueue_script('ee_admin_js'); |
|
215 | + wp_enqueue_script('ee-text-links'); |
|
216 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | |
223 | 223 | public function load_scripts_styles_default() { |
224 | 224 | //styles |
225 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
226 | - wp_enqueue_style( 'espresso_payments' ); |
|
227 | - wp_enqueue_style( 'ee-text-links' ); |
|
225 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
226 | + wp_enqueue_style('espresso_payments'); |
|
227 | + wp_enqueue_style('ee-text-links'); |
|
228 | 228 | //scripts |
229 | 229 | } |
230 | 230 | |
@@ -238,46 +238,46 @@ discard block |
||
238 | 238 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
239 | 239 | * recheck here. |
240 | 240 | */ |
241 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
241 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
242 | 242 | EEM_Payment_Method::instance()->verify_button_urls(); |
243 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
244 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
243 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
244 | + EE_Registry::instance()->load_helper('HTML'); |
|
245 | 245 | //setup tabs, one for each payment method type |
246 | 246 | $tabs = array(); |
247 | 247 | $payment_methods = array(); |
248 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
248 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
249 | 249 | // we don't want to show admin-only PMTs for now |
250 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
250 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | //check access |
254 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
254 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | //check for any active pms of that type |
258 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
259 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
258 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
259 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
260 | 260 | $payment_method = EE_Payment_Method::new_instance( |
261 | 261 | array( |
262 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
262 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
263 | 263 | 'PMD_type' =>$pmt_obj->system_name(), |
264 | 264 | 'PMD_name' =>$pmt_obj->pretty_name(), |
265 | 265 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
266 | 266 | ) |
267 | 267 | ); |
268 | 268 | } |
269 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
269 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
270 | 270 | } |
271 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
272 | - foreach( $payment_methods as $payment_method ) { |
|
273 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
271 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
272 | + foreach ($payment_methods as $payment_method) { |
|
273 | + if ($payment_method instanceof EE_Payment_Method) { |
|
274 | 274 | add_meta_box( |
275 | 275 | //html id |
276 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
276 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
277 | 277 | //title |
278 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
278 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
279 | 279 | //callback |
280 | - array( $this, 'payment_method_settings_meta_box' ), |
|
280 | + array($this, 'payment_method_settings_meta_box'), |
|
281 | 281 | //post type |
282 | 282 | null, |
283 | 283 | //context |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | //priority |
286 | 286 | 'default', |
287 | 287 | //callback args |
288 | - array( 'payment_method' => $payment_method ) |
|
288 | + array('payment_method' => $payment_method) |
|
289 | 289 | ); |
290 | 290 | //setup for tabbed content |
291 | - $tabs[ $payment_method->slug() ] = array( |
|
291 | + $tabs[$payment_method->slug()] = array( |
|
292 | 292 | 'label' => $payment_method->admin_name(), |
293 | 293 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
294 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
295 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
294 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
295 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
296 | 296 | 'slug' => $payment_method->slug() |
297 | 297 | ); |
298 | 298 | } |
299 | 299 | } |
300 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
300 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
301 | 301 | $this->display_admin_page_with_sidebar(); |
302 | 302 | |
303 | 303 | } |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | * _get_active_payment_method_slug |
309 | 309 | * @return string |
310 | 310 | */ |
311 | - protected function _get_active_payment_method_slug(){ |
|
311 | + protected function _get_active_payment_method_slug() { |
|
312 | 312 | $payment_method_slug = FALSE; |
313 | 313 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
314 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
314 | + if (isset($this->_req_data['payment_method'])) { |
|
315 | 315 | // if they provided the current payment method, use it |
316 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
316 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
317 | 317 | } |
318 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
318 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
319 | 319 | // if that didn't work or wasn't provided, find another way to select the current pm |
320 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
320 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
321 | 321 | // like, looking for an active one |
322 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
322 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
323 | 323 | // test that one as well |
324 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
324 | + if ($this->_verify_payment_method($payment_method)) { |
|
325 | 325 | $payment_method_slug = $payment_method->slug(); |
326 | 326 | } else { |
327 | 327 | $payment_method_slug = 'paypal_standard'; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @param \EE_Payment_Method $payment_method |
340 | 340 | * @return boolean |
341 | 341 | */ |
342 | - protected function _verify_payment_method( $payment_method ){ |
|
342 | + protected function _verify_payment_method($payment_method) { |
|
343 | 343 | if ( |
344 | 344 | $payment_method instanceof EE_Payment_Method && |
345 | 345 | $payment_method->type_obj() instanceof EE_PMT_Base && |
346 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
346 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
347 | 347 | ) { |
348 | 348 | return TRUE; |
349 | 349 | } |
@@ -360,21 +360,21 @@ discard block |
||
360 | 360 | * @return string |
361 | 361 | * @throws EE_Error |
362 | 362 | */ |
363 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
364 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
365 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
366 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
363 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
364 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
365 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
366 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
367 | 367 | } |
368 | 368 | $payment_method_scopes = $payment_method->active(); |
369 | 369 | // if the payment method really exists show its form, otherwise the activation template |
370 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
371 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
372 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
373 | - $form->receive_form_submission( $this->_req_data ); |
|
370 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
371 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
372 | + if ($form->form_data_present_in($this->_req_data)) { |
|
373 | + $form->receive_form_submission($this->_req_data); |
|
374 | 374 | } |
375 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
375 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
376 | 376 | } else { |
377 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
377 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | * @param \EE_Payment_Method $payment_method |
388 | 388 | * @return \EE_Form_Section_Proper |
389 | 389 | */ |
390 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
391 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
390 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
391 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
392 | 392 | return new EE_Form_Section_Proper(); |
393 | 393 | } |
394 | 394 | return new EE_Form_Section_Proper( |
395 | 395 | array( |
396 | - 'name' => $payment_method->slug() . '_settings_form', |
|
397 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
396 | + 'name' => $payment_method->slug().'_settings_form', |
|
397 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
398 | 398 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
399 | 399 | array( |
400 | 400 | 'action' => 'update_payment_method', |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | 'subsections' => apply_filters( |
407 | 407 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
408 | 408 | array( |
409 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
410 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
411 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
412 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
413 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
414 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
409 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
410 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
411 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
412 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
413 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
414 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
415 | 415 | ), |
416 | 416 | $payment_method |
417 | 417 | ) |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | * @param \EE_Payment_Method $payment_method |
429 | 429 | * @return \EE_Form_Section_Proper |
430 | 430 | */ |
431 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
432 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
431 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
432 | + if ($payment_method->type_obj()->requires_https()) { |
|
433 | 433 | return new EE_Form_Section_HTML( |
434 | 434 | EEH_HTML::tr( |
435 | 435 | EEH_HTML::th( |
436 | 436 | EEH_HTML::label( |
437 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
437 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
438 | 438 | ) |
439 | - ) . |
|
439 | + ). |
|
440 | 440 | EEH_HTML::td( |
441 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
442 | - EEH_HTML::br() . |
|
443 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
441 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
442 | + EEH_HTML::br(). |
|
443 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
444 | 444 | ) |
445 | 445 | ) |
446 | 446 | ); |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * @param \EE_Payment_Method $payment_method |
459 | 459 | * @return \EE_Form_Section_Proper |
460 | 460 | */ |
461 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
462 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
461 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
462 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
463 | 463 | return new EE_Form_Section_HTML( |
464 | 464 | EEH_HTML::tr( |
465 | 465 | EEH_HTML::th( |
466 | 466 | EEH_HTML::label( |
467 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
467 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
468 | 468 | ) |
469 | - ) . |
|
469 | + ). |
|
470 | 470 | EEH_HTML::td( |
471 | 471 | EEH_HTML::strong( |
472 | 472 | sprintf( |
473 | - __( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
473 | + __('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
474 | 474 | EE_Config::instance()->currency->code |
475 | 475 | ) |
476 | 476 | ) |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | * @param \EE_Payment_Method $payment_method |
491 | 491 | * @return \EE_Form_Section_HTML |
492 | 492 | */ |
493 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
493 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
494 | 494 | //modify the form so we only have/show fields that will be implemented for this version |
495 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
495 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @return \EE_Payment_Method_Form |
506 | 506 | * @throws \EE_Error |
507 | 507 | */ |
508 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
509 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
508 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
509 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
510 | 510 | $form_section->exclude( |
511 | 511 | array( |
512 | 512 | 'PMD_type', //dont want them changing the type |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | ); |
518 | 518 | return $form_section; |
519 | 519 | } else { |
520 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
520 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -530,18 +530,18 @@ discard block |
||
530 | 530 | * @param \EE_Payment_Method $payment_method |
531 | 531 | * @return \EE_Form_Section_HTML |
532 | 532 | */ |
533 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
533 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
534 | 534 | $update_button = new EE_Submit_Input( |
535 | 535 | array( |
536 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
537 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
536 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
537 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
538 | 538 | 'html_label' => EEH_HTML::nbsp() |
539 | 539 | ) |
540 | 540 | ); |
541 | 541 | return new EE_Form_Section_HTML( |
542 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
542 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
543 | 543 | EEH_HTML::tr( |
544 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
544 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
545 | 545 | EEH_HTML::td( |
546 | 546 | $update_button->get_html_for_input() |
547 | 547 | ) |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | * @param \EE_Payment_Method $payment_method |
559 | 559 | * @return \EE_Form_Section_Proper |
560 | 560 | */ |
561 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
562 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
561 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
562 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
563 | 563 | return new EE_Form_Section_HTML( |
564 | 564 | EEH_HTML::tr( |
565 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
565 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
566 | 566 | EEH_HTML::td( |
567 | 567 | EEH_HTML::link( |
568 | 568 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | ), |
575 | 575 | $link_text_and_title, |
576 | 576 | $link_text_and_title, |
577 | - 'deactivate_' . $payment_method->slug(), |
|
577 | + 'deactivate_'.$payment_method->slug(), |
|
578 | 578 | 'espresso-button button-secondary' |
579 | 579 | ) |
580 | 580 | ) |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | * @param \EE_Payment_Method $payment_method |
591 | 591 | * @return \EE_Form_Section_Proper |
592 | 592 | */ |
593 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
594 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
593 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
594 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
595 | 595 | return new EE_Form_Section_Proper( |
596 | 596 | array( |
597 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
598 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
597 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
598 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
599 | 599 | 'action' => '#', |
600 | 600 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
601 | 601 | 'subsections' => apply_filters( |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | new EE_Form_Section_HTML( |
605 | 605 | EEH_HTML::tr( |
606 | 606 | EEH_HTML::th( |
607 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
608 | - ) . |
|
607 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
608 | + ). |
|
609 | 609 | EEH_HTML::td( |
610 | 610 | EEH_HTML::link( |
611 | 611 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | ), |
618 | 618 | $link_text_and_title, |
619 | 619 | $link_text_and_title, |
620 | - 'activate_' . $payment_method->slug(), |
|
620 | + 'activate_'.$payment_method->slug(), |
|
621 | 621 | 'espresso-button-green button-primary' |
622 | 622 | ) |
623 | 623 | ) |
@@ -638,9 +638,9 @@ discard block |
||
638 | 638 | protected function _fine_print() { |
639 | 639 | return new EE_Form_Section_HTML( |
640 | 640 | EEH_HTML::tr( |
641 | - EEH_HTML::th() . |
|
641 | + EEH_HTML::th(). |
|
642 | 642 | EEH_HTML::td( |
643 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
643 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
644 | 644 | ) |
645 | 645 | ) |
646 | 646 | ); |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
653 | 653 | * @global WP_User $current_user |
654 | 654 | */ |
655 | - protected function _activate_payment_method(){ |
|
656 | - if(isset($this->_req_data['payment_method_type'])){ |
|
655 | + protected function _activate_payment_method() { |
|
656 | + if (isset($this->_req_data['payment_method_type'])) { |
|
657 | 657 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
658 | 658 | //see if one exists |
659 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
660 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
659 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
660 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
661 | 661 | |
662 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
663 | - }else{ |
|
662 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
663 | + } else { |
|
664 | 664 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
665 | 665 | } |
666 | 666 | } |
@@ -668,14 +668,14 @@ discard block |
||
668 | 668 | /** |
669 | 669 | * Deactivates the payment method with the specified slug, and redirects. |
670 | 670 | */ |
671 | - protected function _deactivate_payment_method(){ |
|
672 | - if(isset($this->_req_data['payment_method'])){ |
|
671 | + protected function _deactivate_payment_method() { |
|
672 | + if (isset($this->_req_data['payment_method'])) { |
|
673 | 673 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
674 | 674 | //deactivate it |
675 | 675 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
676 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
677 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
678 | - }else{ |
|
676 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
677 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
678 | + } else { |
|
679 | 679 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
680 | 680 | } |
681 | 681 | } |
@@ -689,39 +689,39 @@ discard block |
||
689 | 689 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - protected function _update_payment_method(){ |
|
693 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
692 | + protected function _update_payment_method() { |
|
693 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
694 | 694 | //ok let's find which gateway form to use based on the form input |
695 | 695 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
696 | 696 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
697 | 697 | $correct_pmt_form_to_use = NULL; |
698 | 698 | $pmt_obj = NULL; |
699 | - foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){ |
|
699 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
700 | 700 | /** @var $pmt_obj EE_PMT_Base */ |
701 | 701 | //get the form and simplify it, like what we do when we display it |
702 | 702 | $pmt_form = $pmt_obj->settings_form(); |
703 | 703 | $this->_simplify_form($pmt_form); |
704 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
704 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
705 | 705 | $correct_pmt_form_to_use = $pmt_form; |
706 | 706 | break; |
707 | 707 | } |
708 | 708 | } |
709 | 709 | //if we couldn't find the correct payment method type... |
710 | - if( ! $correct_pmt_form_to_use ){ |
|
710 | + if ( ! $correct_pmt_form_to_use) { |
|
711 | 711 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
712 | 712 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
713 | 713 | } |
714 | 714 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
715 | - if($correct_pmt_form_to_use->is_valid()){ |
|
715 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
716 | 716 | $correct_pmt_form_to_use->save(); |
717 | 717 | $pm = $correct_pmt_form_to_use->get_model_object(); |
718 | 718 | /** @var $pm EE_Payment_Method */ |
719 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug())); |
|
720 | - }else{ |
|
719 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug())); |
|
720 | + } else { |
|
721 | 721 | EE_Error::add_error( |
722 | 722 | sprintf( |
723 | 723 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
724 | - $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
724 | + $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
725 | 725 | ), |
726 | 726 | __FILE__, |
727 | 727 | __FUNCTION__, |
@@ -738,11 +738,11 @@ discard block |
||
738 | 738 | protected function _payment_settings() { |
739 | 739 | |
740 | 740 | $this->_template_args['values'] = $this->_yes_no_values; |
741 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
741 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
742 | 742 | |
743 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
744 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
745 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
743 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
744 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
745 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
746 | 746 | $this->display_admin_page_with_sidebar(); |
747 | 747 | |
748 | 748 | } |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | * @return array |
757 | 757 | */ |
758 | 758 | protected function _update_payment_settings() { |
759 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
760 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
759 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
760 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
761 | 761 | |
762 | 762 | |
763 | - $what = __('Payment Settings','event_espresso'); |
|
764 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
765 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
763 | + $what = __('Payment Settings', 'event_espresso'); |
|
764 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
765 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
766 | 766 | |
767 | 767 | } |
768 | 768 | protected function _payment_log_overview_list_table() { |
@@ -788,18 +788,18 @@ discard block |
||
788 | 788 | * @param bool $count |
789 | 789 | * @return array |
790 | 790 | */ |
791 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
792 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
791 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
792 | + EE_Registry::instance()->load_model('Change_Log'); |
|
793 | 793 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
794 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
794 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
795 | 795 | //check if they've selected a specific payment method |
796 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
796 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
797 | 797 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
798 | 798 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
799 | 799 | } |
800 | 800 | //take into account search |
801 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
802 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
801 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
802 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
803 | 803 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
804 | 804 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
805 | 805 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -814,48 +814,48 @@ discard block |
||
814 | 814 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
815 | 815 | |
816 | 816 | } |
817 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
817 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
818 | 818 | //add date |
819 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
820 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
819 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
820 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
821 | 821 | //make sure our timestamps start and end right at the boundaries for each day |
822 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
823 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
822 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
823 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
824 | 824 | |
825 | 825 | //convert to timestamps |
826 | - $start_date = strtotime( $start_date ); |
|
827 | - $end_date = strtotime( $end_date ); |
|
826 | + $start_date = strtotime($start_date); |
|
827 | + $end_date = strtotime($end_date); |
|
828 | 828 | |
829 | 829 | //makes sure start date is the lowest value and vice versa |
830 | - $start_date = min( $start_date, $end_date ); |
|
831 | - $end_date = max( $start_date, $end_date ); |
|
830 | + $start_date = min($start_date, $end_date); |
|
831 | + $end_date = max($start_date, $end_date); |
|
832 | 832 | |
833 | 833 | //convert for query |
834 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
835 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
834 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
835 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
836 | 836 | |
837 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
837 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
838 | 838 | |
839 | 839 | } |
840 | - if($count){ |
|
840 | + if ($count) { |
|
841 | 841 | return EEM_Change_Log::instance()->count($query_params); |
842 | 842 | } |
843 | - if(isset($this->_req_data['order'])){ |
|
844 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
843 | + if (isset($this->_req_data['order'])) { |
|
844 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
845 | 845 | $query_params['order_by'] = array('LOG_time' => $sort); |
846 | - }else{ |
|
846 | + } else { |
|
847 | 847 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
848 | 848 | } |
849 | - $offset = ($current_page-1)*$per_page; |
|
849 | + $offset = ($current_page - 1) * $per_page; |
|
850 | 850 | |
851 | - if( ! isset($this->_req_data['download_results'])){ |
|
852 | - $query_params['limit'] = array( $offset, $per_page ); |
|
851 | + if ( ! isset($this->_req_data['download_results'])) { |
|
852 | + $query_params['limit'] = array($offset, $per_page); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
856 | 856 | |
857 | 857 | //now they've requested to instead just download the file instead of viewing it. |
858 | - if(isset($this->_req_data['download_results'])){ |
|
858 | + if (isset($this->_req_data['download_results'])) { |
|
859 | 859 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
860 | 860 | header('Content-Disposition: attachment'); |
861 | 861 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -877,36 +877,36 @@ discard block |
||
877 | 877 | * @param EE_Change_Log $logB |
878 | 878 | * @return int |
879 | 879 | */ |
880 | - protected function _sort_logs_again($logA,$logB){ |
|
880 | + protected function _sort_logs_again($logA, $logB) { |
|
881 | 881 | $timeA = $logA->get_raw('LOG_time'); |
882 | 882 | $timeB = $logB->get_raw('LOG_time'); |
883 | - if($timeA == $timeB){ |
|
883 | + if ($timeA == $timeB) { |
|
884 | 884 | return 0; |
885 | 885 | } |
886 | 886 | $comparison = $timeA < $timeB ? -1 : 1; |
887 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
887 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
888 | 888 | return $comparison * -1; |
889 | - }else{ |
|
889 | + } else { |
|
890 | 890 | return $comparison; |
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | 894 | protected function _payment_log_details() { |
895 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
895 | + EE_Registry::instance()->load_model('Change_Log'); |
|
896 | 896 | /** @var $payment_log EE_Change_Log */ |
897 | 897 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
898 | 898 | $payment_method = NULL; |
899 | 899 | $transaction = NULL; |
900 | - if( $payment_log instanceof EE_Change_Log ){ |
|
901 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
900 | + if ($payment_log instanceof EE_Change_Log) { |
|
901 | + if ($payment_log->object() instanceof EE_Payment) { |
|
902 | 902 | $payment_method = $payment_log->object()->payment_method(); |
903 | 903 | $transaction = $payment_log->object()->transaction(); |
904 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
904 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
905 | 905 | $payment_method = $payment_log->object(); |
906 | 906 | } |
907 | 907 | } |
908 | 908 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
909 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
909 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
910 | 910 | array( |
911 | 911 | 'payment_log'=>$payment_log, |
912 | 912 | 'payment_method'=>$payment_method, |
@@ -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 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @return string the assembled html string containing the tabbed content for display. |
47 | 47 | * @throws \EE_Error |
48 | 48 | */ |
49 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
49 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
50 | 50 | |
51 | 51 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
52 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
53 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
52 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
53 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we've got incoming data setup properly |
57 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
58 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
57 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
58 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
59 | 59 | |
60 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
60 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
61 | 61 | $all_tabs_content = ''; |
62 | 62 | |
63 | 63 | $index = 0; |
64 | - foreach ( $tabs as $tab ) { |
|
64 | + foreach ($tabs as $tab) { |
|
65 | 65 | $active = $index === 0 ? true : false; |
66 | 66 | $all_tabs .= self::tab($tab, $active); |
67 | 67 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
80 | 80 | |
81 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
81 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @throws \EE_Error |
103 | 103 | */ |
104 | 104 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
105 | - if ( empty($nav_tabs) ) |
|
106 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
105 | + if (empty($nav_tabs)) |
|
106 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
107 | 107 | |
108 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
109 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
108 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
109 | + foreach ($nav_tabs as $slug => $tab) { |
|
110 | 110 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
111 | 111 | } |
112 | 112 | $all_tabs .= '</h2>'; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param bool|string $css If string given then the generated tab will include that as the class. |
123 | 123 | * @return string html for tab |
124 | 124 | */ |
125 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
125 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
126 | 126 | $name = str_replace(' ', '-', $name); |
127 | 127 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
128 | - $class = $css ? $class . ' ' . $css : $class; |
|
129 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
130 | - $url = $url ? $url : '#' . $name; |
|
131 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
128 | + $class = $css ? $class.' '.$css : $class; |
|
129 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
130 | + $url = $url ? $url : '#'.$name; |
|
131 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
132 | 132 | return $tab; |
133 | 133 | } |
134 | 134 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private static function tab_content($name, $tab_content, $active = false) { |
146 | 146 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
147 | - $name = str_replace( ' ', '-', $name); |
|
148 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
149 | - $content .= "\t" . $tab_content . "\n"; |
|
147 | + $name = str_replace(' ', '-', $name); |
|
148 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
149 | + $content .= "\t".$tab_content."\n"; |
|
150 | 150 | $content .= '<div style="clear:both"></div></div>'; |
151 | 151 | return $content; |
152 | 152 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
173 | 173 | * @return string a html snippet of of all the formatted link elements. |
174 | 174 | */ |
175 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
176 | - $item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class ); |
|
177 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
175 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
176 | + $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
177 | + if ( ! is_array($item_array) || empty($item_array)) |
|
178 | 178 | return false; //get out we don't have even the basic thing we need! |
179 | 179 | |
180 | 180 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
186 | 186 | 'slug' => 'item_slug' |
187 | 187 | ); |
188 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
189 | - $list = '<ul class="' . $container_class . '">'; |
|
188 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
189 | + $list = '<ul class="'.$container_class.'">'; |
|
190 | 190 | |
191 | 191 | $ci = 1; |
192 | - foreach ( $item_array as $item ) { |
|
193 | - $item = wp_parse_args( $item, $defaults ); |
|
194 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
192 | + foreach ($item_array as $item) { |
|
193 | + $item = wp_parse_args($item, $defaults); |
|
194 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
195 | 195 | $list .= self::_text_link_item($item); |
196 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
196 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
197 | 197 | $list .= self::_text_link_item($sep); |
198 | 198 | $ci++; |
199 | 199 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | |
207 | - private static function _text_link_item( $item ) { |
|
207 | + private static function _text_link_item($item) { |
|
208 | 208 | //if this isn't an array then we're doing a separator |
209 | - if ( !is_array( $item ) ) { |
|
209 | + if ( ! is_array($item)) { |
|
210 | 210 | $label = $item; |
211 | 211 | $class = 'ee-text-link-sep'; |
212 | 212 | $href = ''; |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | extract($item); |
216 | 216 | } |
217 | 217 | |
218 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
218 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
219 | 219 | |
220 | - $content = '<li ' . $class . '>'; |
|
221 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
220 | + $content = '<li '.$class.'>'; |
|
221 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
222 | 222 | $content .= $label; |
223 | - $content .= !empty($href) ? '</a>' : ''; |
|
223 | + $content .= ! empty($href) ? '</a>' : ''; |
|
224 | 224 | $content .= '</li>'; |
225 | 225 | return $content; |
226 | 226 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -513,7 +515,7 @@ discard block |
||
513 | 515 | |
514 | 516 | if($count){ |
515 | 517 | return EEM_Price::instance()->count_deleted_and_undeleted(array($_where)); |
516 | - }else{ |
|
518 | + } else{ |
|
517 | 519 | return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
518 | 520 | } |
519 | 521 | } |
@@ -943,7 +945,7 @@ discard block |
||
943 | 945 | 'limit'=>$limit); |
944 | 946 | if($count){ |
945 | 947 | return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params); |
946 | - }else{ |
|
948 | + } else{ |
|
947 | 949 | return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
948 | 950 | } |
949 | 951 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
140 | - if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
141 | - || $force_recheck ) { |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | + if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name]) |
|
141 | + || $force_recheck) { |
|
142 | 142 | $this->maybe_register_payment_methods($force_recheck); |
143 | 143 | } |
144 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
144 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
145 | 145 | require_once($this->_payment_method_types[$payment_method_name]); |
146 | 146 | return true; |
147 | - }else{ |
|
147 | + } else { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
158 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
159 | 159 | $this->maybe_register_payment_methods($force_recheck); |
160 | - if($with_prefixes){ |
|
160 | + if ($with_prefixes) { |
|
161 | 161 | $classnames = array_keys($this->_payment_method_types); |
162 | 162 | $payment_methods = array(); |
163 | - foreach($classnames as $classname){ |
|
163 | + foreach ($classnames as $classname) { |
|
164 | 164 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
165 | 165 | } |
166 | 166 | return $payment_methods; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | return array_keys($this->_payment_method_types); |
169 | 169 | } |
170 | 170 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
175 | 175 | * @return EE_PMT_Base[] |
176 | 176 | */ |
177 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
177 | + public function payment_method_types($force_recheck = FALSE) { |
|
178 | 178 | $this->maybe_register_payment_methods($force_recheck); |
179 | 179 | $pmt_objs = array(); |
180 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
180 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
181 | 181 | $pmt_objs[] = new $classname; |
182 | 182 | } |
183 | 183 | return $pmt_objs; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $classname |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public function payment_method_type_sans_class_prefix($classname){ |
|
193 | - $pmt_name = str_replace("EE_PMT_","",$classname); |
|
192 | + public function payment_method_type_sans_class_prefix($classname) { |
|
193 | + $pmt_name = str_replace("EE_PMT_", "", $classname); |
|
194 | 194 | return $pmt_name; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $type |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function payment_method_class_from_type($type){ |
|
202 | + public function payment_method_class_from_type($type) { |
|
203 | 203 | $this->maybe_register_payment_methods(); |
204 | 204 | return "EE_PMT_".$type; |
205 | 205 | } |
@@ -213,38 +213,38 @@ discard block |
||
213 | 213 | * @return \EE_Payment_Method |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
216 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
217 | 217 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
218 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
218 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
219 | 219 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
220 | - if(class_exists($pm_type_class)){ |
|
220 | + if (class_exists($pm_type_class)) { |
|
221 | 221 | /** @var $pm_type_obj EE_PMT_Base */ |
222 | 222 | $pm_type_obj = new $pm_type_class; |
223 | 223 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
224 | - if( ! $payment_method){ |
|
225 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
224 | + if ( ! $payment_method) { |
|
225 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
226 | 226 | } |
227 | - $payment_method->set_type( $payment_method_type ); |
|
228 | - $this->initialize_payment_method( $payment_method ); |
|
227 | + $payment_method->set_type($payment_method_type); |
|
228 | + $this->initialize_payment_method($payment_method); |
|
229 | 229 | } else { |
230 | 230 | throw new EE_Error( |
231 | 231 | sprintf( |
232 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
232 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
233 | 233 | $pm_type_class ) |
234 | 234 | ); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | $payment_method->set_active(); |
238 | 238 | $payment_method->save(); |
239 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
240 | - if( $payment_method->type() == 'Invoice' ){ |
|
241 | - $messages = EE_Registry::instance()->load_lib( 'messages' ); |
|
242 | - $messages->ensure_message_type_is_active( 'invoice', 'html' ); |
|
243 | - $messages->ensure_messenger_is_active( 'pdf' ); |
|
239 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
240 | + if ($payment_method->type() == 'Invoice') { |
|
241 | + $messages = EE_Registry::instance()->load_lib('messages'); |
|
242 | + $messages->ensure_message_type_is_active('invoice', 'html'); |
|
243 | + $messages->ensure_messenger_is_active('pdf'); |
|
244 | 244 | EE_Error::add_attention( |
245 | 245 | sprintf( |
246 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
247 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
246 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
247 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
248 | 248 | '</a>' |
249 | 249 | ) |
250 | 250 | ); |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | * @param EE_PMT_Base $pm_type_obj |
259 | 259 | * @return EE_Payment_Method |
260 | 260 | */ |
261 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
261 | + public function create_payment_method_of_type($pm_type_obj) { |
|
262 | 262 | global $current_user; |
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | 265 | 'PMD_type' => $pm_type_obj->system_name(), |
266 | 266 | 'PMD_name' => $pm_type_obj->pretty_name(), |
267 | 267 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
268 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
268 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
269 | 269 | 'PMD_wp_user' => $current_user->ID, |
270 | 270 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
271 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
271 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
272 | 272 | ) * 10, |
273 | 273 | ) |
274 | 274 | ); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | * @param EE_Payment_Method $payment_method |
281 | 281 | * @return EE_Payment_Method |
282 | 282 | */ |
283 | - public function initialize_payment_method( $payment_method ) { |
|
283 | + public function initialize_payment_method($payment_method) { |
|
284 | 284 | $pm_type_obj = $payment_method->type_obj(); |
285 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
286 | - if( ! $payment_method->button_url() ){ |
|
287 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
285 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
286 | + if ( ! $payment_method->button_url()) { |
|
287 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
288 | 288 | } |
289 | 289 | //now add setup its default extra meta properties |
290 | 290 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
291 | - foreach( $extra_metas as $meta_name => $input ){ |
|
292 | - $payment_method->update_extra_meta($meta_name, $input->raw_value() ); |
|
291 | + foreach ($extra_metas as $meta_name => $input) { |
|
292 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
293 | 293 | } |
294 | 294 | return $payment_method; |
295 | 295 | } |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * @param EE_Payment_Method $payment_method |
300 | 300 | * @return EE_Payment_Method |
301 | 301 | */ |
302 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
303 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
302 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
303 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
304 | 304 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
305 | 305 | } |
306 | 306 | return $payment_method; |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return int count of rows updated. |
320 | 320 | */ |
321 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
322 | - $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug))); |
|
321 | + public function deactivate_payment_method($payment_method_slug) { |
|
322 | + $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug))); |
|
323 | 323 | return $count_updated; |
324 | 324 | } |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $caps capabilities being filtered |
333 | 333 | * @return array |
334 | 334 | */ |
335 | - public function add_payment_method_caps( $caps ) { |
|
335 | + public function add_payment_method_caps($caps) { |
|
336 | 336 | /* add dynamic caps from payment methods |
337 | 337 | * at the time of writing, october 20 2014, these are the caps added: |
338 | 338 | * ee_payment_method_admin_only |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * their related capability automatically added too, so long as they are |
348 | 348 | * registered properly using EE_Register_Payment_Method::register() |
349 | 349 | */ |
350 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
350 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
351 | 351 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
352 | 352 | } |
353 | 353 | return $caps; |
@@ -715,7 +715,7 @@ |
||
715 | 715 | } |
716 | 716 | } |
717 | 717 | } |
718 | - } |
|
718 | + } |
|
719 | 719 | /** |
720 | 720 | * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
721 | 721 | * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * given two paths, this determines if there is a common base path between the two |
284 | 284 | * |
285 | - * @param array $paths |
|
285 | + * @param string[] $paths |
|
286 | 286 | * @return string |
287 | 287 | */ |
288 | 288 | protected static function _find_common_base_path( $paths ) { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
310 | 310 | * @param array $template_args an array of arguments to be extracted for use in the template |
311 | 311 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
312 | - * @return mixed string |
|
312 | + * @return string string |
|
313 | 313 | */ |
314 | 314 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
315 | 315 | //require the template validator for verifying variables are set according to how the template requires |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -171,26 +171,26 @@ discard block |
||
171 | 171 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
172 | 172 | * @return mixed |
173 | 173 | */ |
174 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
174 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
175 | 175 | // first use WP locate_template to check for template in the current theme folder |
176 | - $template_path = locate_template( $templates ); |
|
176 | + $template_path = locate_template($templates); |
|
177 | 177 | |
178 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
178 | + if ($check_if_custom && ! empty($template_path)) |
|
179 | 179 | return TRUE; |
180 | 180 | |
181 | 181 | // not in the theme |
182 | - if ( empty( $template_path )) { |
|
182 | + if (empty($template_path)) { |
|
183 | 183 | // not even a template to look for ? |
184 | - if ( empty( $templates )) { |
|
184 | + if (empty($templates)) { |
|
185 | 185 | // get post_type |
186 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
186 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
187 | 187 | // get array of EE Custom Post Types |
188 | 188 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
189 | 189 | // build template name based on request |
190 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
191 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
192 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
193 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
190 | + if (isset($EE_CPTs[$post_type])) { |
|
191 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
192 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
193 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | // currently active EE template theme |
@@ -199,80 +199,80 @@ discard block |
||
199 | 199 | // array of paths to folders that may contain templates |
200 | 200 | $template_folder_paths = array( |
201 | 201 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
202 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
202 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
203 | 203 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
204 | 204 | EVENT_ESPRESSO_TEMPLATE_DIR |
205 | 205 | ); |
206 | 206 | |
207 | 207 | //add core plugin folders for checking only if we're not $check_if_custom |
208 | - if ( ! $check_if_custom ) { |
|
208 | + if ( ! $check_if_custom) { |
|
209 | 209 | $core_paths = array( |
210 | 210 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
211 | - EE_PUBLIC . $current_theme, |
|
211 | + EE_PUBLIC.$current_theme, |
|
212 | 212 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
213 | - EE_TEMPLATES . $current_theme, |
|
213 | + EE_TEMPLATES.$current_theme, |
|
214 | 214 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
215 | 215 | EE_PLUGIN_DIR_PATH |
216 | 216 | ); |
217 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
217 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // now filter that array |
221 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
222 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
223 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
221 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
222 | + $templates = is_array($templates) ? $templates : array($templates); |
|
223 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
224 | 224 | // array to hold all possible template paths |
225 | 225 | $full_template_paths = array(); |
226 | 226 | |
227 | 227 | EE_Registry::instance()->load_helper('File'); |
228 | 228 | // loop through $templates |
229 | - foreach ( $templates as $template ) { |
|
229 | + foreach ($templates as $template) { |
|
230 | 230 | // normalize directory separators |
231 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
232 | - $file_name = basename( $template ); |
|
233 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
231 | + $template = EEH_File::standardise_directory_separators($template); |
|
232 | + $file_name = basename($template); |
|
233 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
234 | 234 | // while looping through all template folder paths |
235 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
235 | + foreach ($template_folder_paths as $template_folder_path) { |
|
236 | 236 | // normalize directory separators |
237 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
237 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
238 | 238 | // determine if any common base path exists between the two paths |
239 | 239 | $common_base_path = EEH_Template::_find_common_base_path( |
240 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
240 | + array($template_folder_path, $template_path_minus_file_name) |
|
241 | 241 | ); |
242 | - if ( $common_base_path !== '' ) { |
|
242 | + if ($common_base_path !== '') { |
|
243 | 243 | // both paths have a common base, so just tack the filename onto our search path |
244 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
244 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
245 | 245 | } else { |
246 | 246 | // no common base path, so let's just concatenate |
247 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
247 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
248 | 248 | } |
249 | 249 | // build up our template locations array by adding our resolved paths |
250 | 250 | $full_template_paths[] = $resolved_path; |
251 | 251 | } |
252 | 252 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
253 | - array_unshift( $full_template_paths, $template ); |
|
253 | + array_unshift($full_template_paths, $template); |
|
254 | 254 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
255 | - array_unshift( $full_template_paths, get_template_directory() . DS . $file_name ); |
|
255 | + array_unshift($full_template_paths, get_template_directory().DS.$file_name); |
|
256 | 256 | } |
257 | 257 | // filter final array of full template paths |
258 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths ); |
|
258 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths); |
|
259 | 259 | // now loop through our final array of template location paths and check each location |
260 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
261 | - if ( is_readable( $full_template_path )) { |
|
262 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
260 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
261 | + if (is_readable($full_template_path)) { |
|
262 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
263 | 263 | break; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
267 | 267 | // if we got it and you want to see it... |
268 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
269 | - if ( $return_string ) { |
|
270 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
268 | + if ($template_path && $load && ! $check_if_custom) { |
|
269 | + if ($return_string) { |
|
270 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
271 | 271 | } else { |
272 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
272 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
273 | 273 | } |
274 | 274 | } |
275 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
275 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | * @param array $paths |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - protected static function _find_common_base_path( $paths ) { |
|
288 | + protected static function _find_common_base_path($paths) { |
|
289 | 289 | $last_offset = 0; |
290 | 290 | $common_base_path = ''; |
291 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
291 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
292 | 292 | $dir_length = $index - $last_offset + 1; |
293 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
294 | - foreach ( $paths as $path ) { |
|
295 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
293 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
294 | + foreach ($paths as $path) { |
|
295 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
296 | 296 | return $common_base_path; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | $common_base_path .= $directory; |
300 | 300 | $last_offset = $index + 1; |
301 | 301 | } |
302 | - return substr( $common_base_path, 0, -1 ); |
|
302 | + return substr($common_base_path, 0, -1); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
312 | 312 | * @return mixed string |
313 | 313 | */ |
314 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
314 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
315 | 315 | //require the template validator for verifying variables are set according to how the template requires |
316 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
316 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -324,26 +324,26 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @since 4.6.0 |
326 | 326 | */ |
327 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
328 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
327 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
328 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
329 | 329 | |
330 | 330 | // you gimme nuttin - YOU GET NUTTIN !! |
331 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
331 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
332 | 332 | return ''; |
333 | 333 | } |
334 | 334 | // if $template_args are not in an array, then make it so |
335 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
336 | - $template_args = array( $template_args ); |
|
335 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
336 | + $template_args = array($template_args); |
|
337 | 337 | } |
338 | - extract( (array) $template_args); |
|
338 | + extract((array) $template_args); |
|
339 | 339 | |
340 | - if ( $return_string ) { |
|
340 | + if ($return_string) { |
|
341 | 341 | // because we want to return a string, we are going to capture the output |
342 | 342 | ob_start(); |
343 | - include( $template_path ); |
|
343 | + include($template_path); |
|
344 | 344 | return ob_get_clean(); |
345 | 345 | } else { |
346 | - include( $template_path ); |
|
346 | + include($template_path); |
|
347 | 347 | } |
348 | 348 | return ''; |
349 | 349 | } |
@@ -361,27 +361,27 @@ discard block |
||
361 | 361 | * @param string $suffix added to the end of the generated class |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
364 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
365 | 365 | // in the beginning... |
366 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
366 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
367 | 367 | // da muddle |
368 | 368 | $class = ''; |
369 | 369 | // the end |
370 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
370 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
371 | 371 | // is the passed object an EE object ? |
372 | - if ( $object instanceof EE_Base_Class ) { |
|
372 | + if ($object instanceof EE_Base_Class) { |
|
373 | 373 | // grab the exact type of object |
374 | - $obj_class = get_class( $object ); |
|
374 | + $obj_class = get_class($object); |
|
375 | 375 | // depending on the type of object... |
376 | - switch ( $obj_class ) { |
|
376 | + switch ($obj_class) { |
|
377 | 377 | // no specifics just yet... |
378 | 378 | default : |
379 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
380 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
379 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
380 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | } |
384 | - return $prefix . $class . $suffix; |
|
384 | + return $prefix.$class.$suffix; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -397,50 +397,50 @@ discard block |
||
397 | 397 | * @param string $cur_code_span_class |
398 | 398 | * @return string the html output for the formatted money value |
399 | 399 | */ |
400 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
400 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
401 | 401 | // ensure amount was received |
402 | - if ( is_null( $amount ) ) { |
|
403 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
404 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
402 | + if (is_null($amount)) { |
|
403 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
404 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
405 | 405 | return ''; |
406 | 406 | } |
407 | 407 | //ensure amount is float |
408 | 408 | $amount = (float) $amount; |
409 | 409 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
410 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
410 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
411 | 411 | // still a number or was amount converted to a string like "free" ? |
412 | - if ( is_float( $amount_formatted )) { |
|
412 | + if (is_float($amount_formatted)) { |
|
413 | 413 | // was a country ISO code passed ? if so generate currency config object for that country |
414 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
414 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
415 | 415 | // verify results |
416 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
416 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
417 | 417 | // set default config country currency settings |
418 | 418 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
419 | 419 | } |
420 | 420 | // format float |
421 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
421 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
422 | 422 | // add formatting ? |
423 | - if ( ! $return_raw ) { |
|
423 | + if ( ! $return_raw) { |
|
424 | 424 | // add currency sign |
425 | - if( $mny->sign_b4 ){ |
|
426 | - if( $amount >= 0 ){ |
|
427 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
428 | - }else{ |
|
429 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
425 | + if ($mny->sign_b4) { |
|
426 | + if ($amount >= 0) { |
|
427 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
428 | + } else { |
|
429 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
430 | 430 | } |
431 | 431 | |
432 | - }else{ |
|
433 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
432 | + } else { |
|
433 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | // add currency code ? |
437 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
437 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
438 | 438 | } |
439 | 439 | // filter results |
440 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
440 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
441 | 441 | } |
442 | 442 | // clean up vars |
443 | - unset( $mny ); |
|
443 | + unset($mny); |
|
444 | 444 | // return formatted currency amount |
445 | 445 | return $amount_formatted; |
446 | 446 | } |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
456 | 456 | * @return string The localized label for the status id. |
457 | 457 | */ |
458 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
458 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
459 | 459 | /** @type EEM_Status $EEM_Status */ |
460 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
461 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
462 | - return $status[ $status_id ]; |
|
460 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
461 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
462 | + return $status[$status_id]; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | * @param string $icon |
473 | 473 | * @return string the html output for the button |
474 | 474 | */ |
475 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
476 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
477 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
475 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
476 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
477 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
478 | 478 | return $button; |
479 | 479 | } |
480 | 480 | |
@@ -491,21 +491,21 @@ discard block |
||
491 | 491 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
492 | 492 | * @return string generated link |
493 | 493 | */ |
494 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
494 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
495 | 495 | |
496 | - if ( ! $page ) |
|
497 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
496 | + if ( ! $page) |
|
497 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
498 | 498 | |
499 | - if ( ! $action ) |
|
500 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
499 | + if ( ! $action) |
|
500 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
501 | 501 | |
502 | 502 | $action = empty($action) ? 'default' : $action; |
503 | 503 | |
504 | 504 | |
505 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
506 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
507 | - $help_text = !$help_text ? '' : $help_text; |
|
508 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
505 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
506 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
507 | + $help_text = ! $help_text ? '' : $help_text; |
|
508 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -517,31 +517,31 @@ discard block |
||
517 | 517 | * @param EE_Help_Tour |
518 | 518 | * @return string html |
519 | 519 | */ |
520 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
520 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
521 | 521 | $id = $tour->get_slug(); |
522 | 522 | $stops = $tour->get_stops(); |
523 | 523 | |
524 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
524 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
525 | 525 | |
526 | - foreach ( $stops as $stop ) { |
|
527 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
528 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
526 | + foreach ($stops as $stop) { |
|
527 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
528 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
529 | 529 | |
530 | 530 | //if container is set to modal then let's make sure we set the options accordingly |
531 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
531 | + if (empty($data_id) && empty($data_class)) { |
|
532 | 532 | $stop['options']['modal'] = true; |
533 | 533 | $stop['options']['expose'] = true; |
534 | 534 | } |
535 | 535 | |
536 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
537 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
536 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
537 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
538 | 538 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
539 | 539 | |
540 | 540 | //options |
541 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
541 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
542 | 542 | $options = ' data-options="'; |
543 | - foreach ( $stop['options'] as $option => $value ) { |
|
544 | - $options .= $option . ':' . $value . ';'; |
|
543 | + foreach ($stop['options'] as $option => $value) { |
|
544 | + $options .= $option.':'.$value.';'; |
|
545 | 545 | } |
546 | 546 | $options .= '"'; |
547 | 547 | } else { |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | //let's put all together |
552 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
552 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | $content .= '</ol>'; |
@@ -570,31 +570,31 @@ discard block |
||
570 | 570 | * @throws EE_Error |
571 | 571 | * @return string html structure for status. |
572 | 572 | */ |
573 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
574 | - if ( !is_array( $status_array ) ) |
|
575 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
573 | + public static function status_legend($status_array, $active_status = '') { |
|
574 | + if ( ! is_array($status_array)) |
|
575 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
576 | 576 | |
577 | 577 | $setup_array = array(); |
578 | - foreach ( $status_array as $item => $status ) { |
|
578 | + foreach ($status_array as $item => $status) { |
|
579 | 579 | $setup_array[$item] = array( |
580 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
581 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
580 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
581 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
582 | 582 | 'status' => $status |
583 | 583 | ); |
584 | 584 | } |
585 | 585 | |
586 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
587 | - $content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
588 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
589 | - foreach ( $setup_array as $item => $details ) { |
|
586 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
587 | + $content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
588 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
589 | + foreach ($setup_array as $item => $details) { |
|
590 | 590 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
591 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
592 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
593 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
594 | - $content .= '</dt>' . "\n"; |
|
591 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
592 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
593 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
594 | + $content .= '</dt>'."\n"; |
|
595 | 595 | } |
596 | - $content .= '</dl>' . "\n"; |
|
597 | - $content .= '</div>' . "\n"; |
|
596 | + $content .= '</dl>'."\n"; |
|
597 | + $content .= '</div>'."\n"; |
|
598 | 598 | return $content; |
599 | 599 | } |
600 | 600 | |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @return string |
608 | 608 | */ |
609 | 609 | public static function layout_array_as_table($data) { |
610 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
611 | - $data = (array)$data; |
|
610 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
611 | + $data = (array) $data; |
|
612 | 612 | } |
613 | 613 | EE_Registry::instance()->load_helper('Array'); |
614 | 614 | ob_start(); |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | ?> |
623 | 623 | <tr> |
624 | 624 | <td> |
625 | - <?php echo $data_key;?> |
|
625 | + <?php echo $data_key; ?> |
|
626 | 626 | </td> |
627 | 627 | <td> |
628 | - <?php echo self::layout_array_as_table($data_values);?> |
|
628 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
629 | 629 | </td> |
630 | 630 | </tr> |
631 | 631 | <?php |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | <ul> |
640 | 640 | <?php |
641 | 641 | foreach ($data as $datum) { |
642 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
642 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
643 | 643 | }?> |
644 | 644 | </ul> |
645 | 645 | <?php |
@@ -669,8 +669,8 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return string |
671 | 671 | */ |
672 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
673 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
672 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
673 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | * ) |
695 | 695 | * @return string |
696 | 696 | */ |
697 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
697 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
698 | 698 | $page_links = array(); |
699 | 699 | $disable_first = $disable_last = ''; |
700 | 700 | $total_items = (int) $total_items; |
701 | 701 | $per_page = (int) $per_page; |
702 | 702 | $current = (int) $current; |
703 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
703 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
704 | 704 | |
705 | 705 | //filter items_label |
706 | 706 | $items_label = apply_filters( |
@@ -708,68 +708,68 @@ discard block |
||
708 | 708 | $items_label |
709 | 709 | ); |
710 | 710 | |
711 | - if ( empty( $items_label ) |
|
712 | - || ! is_array( $items_label ) |
|
713 | - || ! isset( $items_label['single'] ) |
|
714 | - || ! isset( $items_label['plural'] ) ) { |
|
711 | + if (empty($items_label) |
|
712 | + || ! is_array($items_label) |
|
713 | + || ! isset($items_label['single']) |
|
714 | + || ! isset($items_label['plural'])) { |
|
715 | 715 | $items_label = array( |
716 | - 'single' => __( '1 item', 'event_espresso' ), |
|
717 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
716 | + 'single' => __('1 item', 'event_espresso'), |
|
717 | + 'plural' => __('%s items', 'event_espresso') |
|
718 | 718 | ); |
719 | 719 | } else { |
720 | 720 | $items_label = array( |
721 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
722 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
721 | + 'single' => '1 '.esc_html($items_label['single']), |
|
722 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
723 | 723 | ); |
724 | 724 | } |
725 | 725 | |
726 | - $total_pages = ceil( $total_items / $per_page ); |
|
726 | + $total_pages = ceil($total_items / $per_page); |
|
727 | 727 | |
728 | - if ( $total_pages <= 1 ) |
|
728 | + if ($total_pages <= 1) |
|
729 | 729 | return ''; |
730 | 730 | |
731 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
731 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
732 | 732 | |
733 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
733 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
734 | 734 | |
735 | - if ( $current === 1 ) { |
|
735 | + if ($current === 1) { |
|
736 | 736 | $disable_first = ' disabled'; |
737 | 737 | } |
738 | - if ( $current == $total_pages ) { |
|
738 | + if ($current == $total_pages) { |
|
739 | 739 | $disable_last = ' disabled'; |
740 | 740 | } |
741 | 741 | |
742 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
743 | - 'first-page' . $disable_first, |
|
744 | - esc_attr__( 'Go to the first page' ), |
|
745 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
742 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
743 | + 'first-page'.$disable_first, |
|
744 | + esc_attr__('Go to the first page'), |
|
745 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
746 | 746 | '«' |
747 | 747 | ); |
748 | 748 | |
749 | 749 | $page_links[] = sprintf( |
750 | 750 | '<a class="%s" title="%s" href="%s">%s</a>', |
751 | - 'prev-page' . $disable_first, |
|
752 | - esc_attr__( 'Go to the previous page' ), |
|
753 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
751 | + 'prev-page'.$disable_first, |
|
752 | + esc_attr__('Go to the previous page'), |
|
753 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
754 | 754 | '‹' |
755 | 755 | ); |
756 | 756 | |
757 | - if ( ! $show_num_field ) { |
|
757 | + if ( ! $show_num_field) { |
|
758 | 758 | $html_current_page = $current; |
759 | 759 | } else { |
760 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
761 | - esc_attr__( 'Current page' ), |
|
760 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
761 | + esc_attr__('Current page'), |
|
762 | 762 | $current, |
763 | - strlen( $total_pages ) |
|
763 | + strlen($total_pages) |
|
764 | 764 | ); |
765 | 765 | } |
766 | 766 | |
767 | 767 | $html_total_pages = sprintf( |
768 | 768 | '<span class="total-pages">%s</span>', |
769 | - number_format_i18n( $total_pages ) |
|
769 | + number_format_i18n($total_pages) |
|
770 | 770 | ); |
771 | 771 | $page_links[] = sprintf( |
772 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
772 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
773 | 773 | $html_current_page, |
774 | 774 | $html_total_pages, |
775 | 775 | '<span class="paging-input">', |
@@ -778,29 +778,29 @@ discard block |
||
778 | 778 | |
779 | 779 | $page_links[] = sprintf( |
780 | 780 | '<a class="%s" title="%s" href="%s">%s</a>', |
781 | - 'next-page' . $disable_last, |
|
782 | - esc_attr__( 'Go to the next page' ), |
|
783 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
781 | + 'next-page'.$disable_last, |
|
782 | + esc_attr__('Go to the next page'), |
|
783 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
784 | 784 | '›' |
785 | 785 | ); |
786 | 786 | |
787 | 787 | $page_links[] = sprintf( |
788 | 788 | '<a class="%s" title="%s" href="%s">%s</a>', |
789 | - 'last-page' . $disable_last, |
|
790 | - esc_attr__( 'Go to the last page' ), |
|
791 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
789 | + 'last-page'.$disable_last, |
|
790 | + esc_attr__('Go to the last page'), |
|
791 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
792 | 792 | '»' |
793 | 793 | ); |
794 | 794 | |
795 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
795 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
796 | 796 | // set page class |
797 | - if ( $total_pages ) { |
|
797 | + if ($total_pages) { |
|
798 | 798 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
799 | 799 | } else { |
800 | 800 | $page_class = ' no-pages'; |
801 | 801 | } |
802 | 802 | |
803 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
803 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
102 | - unset( $espresso_themes[ $key ] ); |
|
102 | + unset( $espresso_themes[ $key ] ); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | ); |
710 | 710 | |
711 | 711 | if ( empty( $items_label ) |
712 | - || ! is_array( $items_label ) |
|
713 | - || ! isset( $items_label['single'] ) |
|
714 | - || ! isset( $items_label['plural'] ) ) { |
|
712 | + || ! is_array( $items_label ) |
|
713 | + || ! isset( $items_label['single'] ) |
|
714 | + || ! isset( $items_label['plural'] ) ) { |
|
715 | 715 | $items_label = array( |
716 | 716 | 'single' => __( '1 item', 'event_espresso' ), |
717 | 717 | 'plural' => __( '%s items', 'event_espresso' ) |
@@ -32,7 +32,6 @@ |
||
32 | 32 | /** |
33 | 33 | * |
34 | 34 | * @param string $model_name |
35 | - * @param string $comparison_model_name |
|
36 | 35 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 36 | * @return EE_Model_Field_Base |
38 | 37 | */ |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Joins any two models together via a has-and-belongs-to-many relation, using |
|
4 | - * the esp_extra_join table. |
|
5 | - */ |
|
3 | + * Joins any two models together via a has-and-belongs-to-many relation, using |
|
4 | + * the esp_extra_join table. |
|
5 | + */ |
|
6 | 6 | class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
7 | 7 | /** |
8 | 8 | * |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Joins any two models together via a has-and-belongs-to-many relation, using |
4 | 4 | * the esp_extra_join table. |
5 | 5 | */ |
6 | -class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
|
6 | +class EE_HABTM_Any_Relation extends EE_HABTM_Relation { |
|
7 | 7 | /** |
8 | 8 | * |
9 | 9 | * @var string |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
18 | 18 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
19 | 19 | */ |
20 | - function __construct( $block_deletes = true, $blocking_delete_error_message =''){ |
|
21 | - parent::__construct( 'Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
20 | + function __construct($block_deletes = true, $blocking_delete_error_message = '') { |
|
21 | + parent::__construct('Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
22 | 22 | } |
23 | - function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
24 | - if( $this_model_name < $other_model_name ) { |
|
23 | + function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
24 | + if ($this_model_name < $other_model_name) { |
|
25 | 25 | $this->_alphabetically_first_model_name = $this_model_name; |
26 | - } else{ |
|
26 | + } else { |
|
27 | 27 | $this->_alphabetically_first_model_name = $other_model_name; |
28 | 28 | } |
29 | - return parent::_construct_finalize_set_models( $this_model_name, $other_model_name ); |
|
29 | + return parent::_construct_finalize_set_models($this_model_name, $other_model_name); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 37 | * @return EE_Model_Field_Base |
38 | 38 | */ |
39 | - function get_join_table_fk_field_to( $model_name, $id_or_name_field ) { |
|
39 | + function get_join_table_fk_field_to($model_name, $id_or_name_field) { |
|
40 | 40 | $order = null; |
41 | - if( $model_name === $this->_alphabetically_first_model_name ) { |
|
41 | + if ($model_name === $this->_alphabetically_first_model_name) { |
|
42 | 42 | $order = 'first'; |
43 | 43 | } else { |
44 | 44 | $order = 'second'; |
45 | 45 | } |
46 | - return $this->get_join_model()->field_settings_for( 'EXJ_' . $order . '_model_' . $id_or_name_field ); |
|
46 | + return $this->get_join_model()->field_settings_for('EXJ_'.$order.'_model_'.$id_or_name_field); |
|
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * Gets the SQL string for joining the main model's table containing the pk to the join table. Eg "LEFT JOIN real_join_table AS join_table_alias ON this_table_alias.pk = join_table_alias.fk_to_this_table" |
50 | 50 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
51 | 51 | * @return string of SQL |
52 | 52 | */ |
53 | - function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
53 | + function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
54 | 54 | //create sql like |
55 | 55 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
56 | 56 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $field_with_model_name = $this->get_join_table_fk_field_to( |
65 | 65 | $this->get_this_model()->get_this_model_name(), |
66 | 66 | 'name' ); |
67 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
68 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
67 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
68 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
69 | 69 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
70 | 70 | //phew! ok, we have all the info we need, now we can create the SQL join string |
71 | 71 | $SQL = $this->_left_join( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $join_table_fk_field_to_this_table->get_table_column(), |
75 | 75 | $this_table_alias, |
76 | 76 | $this_table_pk_field->get_table_column(), |
77 | - $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ) . |
|
77 | + $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ). |
|
78 | 78 | $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
79 | 79 | |
80 | 80 | return $SQL; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
88 | 88 | * @return string of SQL |
89 | 89 | */ |
90 | - function get_join_statement($model_relation_chain){ |
|
91 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
92 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
90 | + function get_join_statement($model_relation_chain) { |
|
91 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
92 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
93 | 93 | } |
94 | 94 | $join_table_fk_field_to_this_table = $this->get_join_table_fk_field_to( |
95 | 95 | $this->get_this_model()->get_this_model_name(), |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $this->get_other_model()->get_this_model_name(), |
102 | 102 | 'name' ); |
103 | 103 | |
104 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
104 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
105 | 105 | |
106 | 106 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
107 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
107 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
108 | 108 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
109 | 109 | |
110 | 110 | $SQL = $this->_left_join( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $join_table_alias, |
115 | 115 | $join_table_fk_field_to_other_table->get_table_column(), |
116 | 116 | $field_with_other_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'" |
117 | - ) . |
|
117 | + ). |
|
118 | 118 | $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
119 | 119 | return $SQL; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param array $extra_join_model_fields_n_values col=>val pairs that are used as extra conditions for checking existing values and for setting new rows if no exact matches. |
127 | 127 | * @return EE_Base_Class |
128 | 128 | */ |
129 | - function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
129 | + function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
130 | 130 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
131 | 131 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
132 | 132 | //check if such a relationship already exists |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | $this->get_other_model()->get_this_model_name(), |
144 | 144 | 'name' ); |
145 | 145 | |
146 | - $cols_n_values = array( |
|
146 | + $cols_n_values = array( |
|
147 | 147 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
148 | 148 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
149 | 149 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
150 | 150 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
151 | 151 | |
152 | 152 | //if $where_query exists lets add them to the query_params. |
153 | - if ( !empty( $extra_join_model_fields_n_values ) ) { |
|
153 | + if ( ! empty($extra_join_model_fields_n_values)) { |
|
154 | 154 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
155 | 155 | //make sure we strip THIS models name from the query param |
156 | - foreach ( $extra_join_model_fields_n_values as $query_param => $val ) { |
|
157 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
156 | + foreach ($extra_join_model_fields_n_values as $query_param => $val) { |
|
157 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
158 | 158 | $parsed_query[$query_param] = $val; |
159 | 159 | } |
160 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
160 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
161 | 161 | } |
162 | 162 | |
163 | - $query_params = array( $cols_n_values ); |
|
163 | + $query_params = array($cols_n_values); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
167 | 167 | //if there is already an entry in the join table, indicating a relationship, we're done |
168 | 168 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
169 | 169 | //the other tables, use the joining model directly! |
170 | - if( ! $existing_entry_in_join_table ){ |
|
170 | + if ( ! $existing_entry_in_join_table) { |
|
171 | 171 | $this->get_join_model()->insert($cols_n_values); |
172 | 172 | } |
173 | 173 | return $other_model_obj; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * * @param array $where_query col=>val pairs that are used as extra conditions for checking existing values and for removing existing rows if exact matches exist. |
180 | 180 | * @return EE_Base_Class |
181 | 181 | */ |
182 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
182 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
183 | 183 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
184 | 184 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
185 | 185 | //check if such a relationship already exists |
@@ -196,24 +196,24 @@ discard block |
||
196 | 196 | $this->get_other_model()->get_this_model_name(), |
197 | 197 | 'name' ); |
198 | 198 | |
199 | - $cols_n_values = array( |
|
199 | + $cols_n_values = array( |
|
200 | 200 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
201 | 201 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
202 | 202 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
203 | 203 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
204 | 204 | |
205 | 205 | //if $where_query exists lets add them to the query_params. |
206 | - if ( !empty( $where_query ) ) { |
|
206 | + if ( ! empty($where_query)) { |
|
207 | 207 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
208 | 208 | //make sure we strip THIS models name from the query param |
209 | - foreach ( $where_query as $query_param => $val ) { |
|
210 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
209 | + foreach ($where_query as $query_param => $val) { |
|
210 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
211 | 211 | $parsed_query[$query_param] = $val; |
212 | 212 | } |
213 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
213 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
214 | 214 | } |
215 | 215 | |
216 | - $existing_entry_in_join_table = $this->get_join_model()->delete( array($cols_n_values) ); |
|
216 | + $existing_entry_in_join_table = $this->get_join_model()->delete(array($cols_n_values)); |
|
217 | 217 | return $other_model_obj; |
218 | 218 | } |
219 | 219 | } |