@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Log |
|
5 | - * |
|
6 | - * Singleton logging class. Can be called from anywhere in the plugin to log data to a log file. |
|
7 | - * Defaults to wp-content/uploads/espresso/logs/espresso_log.txt |
|
8 | - * Usage: |
|
9 | - * do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'logging message' ); |
|
10 | - * |
|
11 | - * @package Event Espresso |
|
12 | - * @subpackage core |
|
13 | - * @author Sidney Harrel, Brent Christensen |
|
14 | - * |
|
15 | - */ |
|
3 | + * |
|
4 | + * Class EE_Log |
|
5 | + * |
|
6 | + * Singleton logging class. Can be called from anywhere in the plugin to log data to a log file. |
|
7 | + * Defaults to wp-content/uploads/espresso/logs/espresso_log.txt |
|
8 | + * Usage: |
|
9 | + * do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'logging message' ); |
|
10 | + * |
|
11 | + * @package Event Espresso |
|
12 | + * @subpackage core |
|
13 | + * @author Sidney Harrel, Brent Christensen |
|
14 | + * |
|
15 | + */ |
|
16 | 16 | class EE_Log { |
17 | 17 | |
18 | 18 | /** |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Class EE_Log |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @return EE_Log |
63 | 63 | */ |
64 | 64 | public static function instance() { |
65 | - if ( ! self::$_instance instanceof EE_Log ) { |
|
65 | + if ( ! self::$_instance instanceof EE_Log) { |
|
66 | 66 | self::$_instance = new self(); |
67 | 67 | } |
68 | 68 | return self::$_instance; |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function __construct() { |
76 | 76 | |
77 | - if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging ) { |
|
77 | + if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - $this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS; |
|
81 | + $this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS; |
|
82 | 82 | $this->_log_file = EE_Registry::instance()->CFG->admin->log_file_name(); |
83 | 83 | $this->_log = ''; |
84 | 84 | $this->_debug_file = EE_Registry::instance()->CFG->admin->debug_file_name(); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
87 | 87 | $this->_remote_log = ''; |
88 | 88 | |
89 | - add_action( 'admin_init', array( $this, 'verify_filesystem' ), -10 ); |
|
90 | - add_action( 'AHEE_log', array( $this, 'log' ), 10, 4 ); |
|
91 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
92 | - add_action( 'shutdown', array( $this, 'write_log' ), 9999 ); |
|
89 | + add_action('admin_init', array($this, 'verify_filesystem'), -10); |
|
90 | + add_action('AHEE_log', array($this, 'log'), 10, 4); |
|
91 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
92 | + add_action('shutdown', array($this, 'write_log'), 9999); |
|
93 | 93 | // if WP_DEBUG |
94 | - add_action( 'shutdown', array( $this, 'write_debug' ), 9999 ); |
|
94 | + add_action('shutdown', array($this, 'write_debug'), 9999); |
|
95 | 95 | } |
96 | - if ( EE_Registry::instance()->CFG->admin->use_remote_logging ) { |
|
97 | - add_action( 'shutdown', array( $this, 'send_log' ), 9999 ); |
|
96 | + if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
97 | + add_action('shutdown', array($this, 'send_log'), 9999); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function verify_filesystem() { |
110 | 110 | try { |
111 | - EE_Registry::instance()->load_helper( 'File' ); |
|
112 | - EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_log_file ); |
|
113 | - EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_debug_file ); |
|
114 | - EEH_File::add_htaccess_deny_from_all( $this->_logs_folder ); |
|
115 | - } catch( EE_Error $e ){ |
|
116 | - EE_Error::add_error( sprintf( __( 'Event Espresso logging could not be setup because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + EE_Registry::instance()->load_helper('File'); |
|
112 | + EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_log_file); |
|
113 | + EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_debug_file); |
|
114 | + EEH_File::add_htaccess_deny_from_all($this->_logs_folder); |
|
115 | + } catch (EE_Error $e) { |
|
116 | + EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return; |
118 | 118 | } |
119 | 119 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @param string $type |
131 | 131 | * @return string |
132 | 132 | */ |
133 | - private function _format_message( $file = '', $function = '', $message = '', $type = '' ) { |
|
134 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
135 | - $msg .= '[' . current_time( 'mysql' ) . '] '; |
|
136 | - $msg .= ! empty( $file ) ? basename( $file ) : ''; |
|
137 | - $msg .= ! empty( $file ) && ! empty( $function ) ? ' -> ' : ''; |
|
138 | - $msg .= ! empty( $function ) ? $function . '()' : ''; |
|
133 | + private function _format_message($file = '', $function = '', $message = '', $type = '') { |
|
134 | + $msg = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
135 | + $msg .= '['.current_time('mysql').'] '; |
|
136 | + $msg .= ! empty($file) ? basename($file) : ''; |
|
137 | + $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
138 | + $msg .= ! empty($function) ? $function.'()' : ''; |
|
139 | 139 | $msg .= PHP_EOL; |
140 | - $type = ! empty( $type ) ? $type : 'log message'; |
|
141 | - $msg .= ! empty( $message ) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
140 | + $type = ! empty($type) ? $type : 'log message'; |
|
141 | + $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : ''; |
|
142 | 142 | return $msg; |
143 | 143 | } |
144 | 144 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $message |
154 | 154 | * @param string $type |
155 | 155 | */ |
156 | - public function log( $file = '', $function = '', $message = '', $type = '' ) { |
|
157 | - $this->_log .= $this->_format_message( $file, $function, $message, $type ); |
|
156 | + public function log($file = '', $function = '', $message = '', $type = '') { |
|
157 | + $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | public function write_log() { |
167 | 167 | try { |
168 | 168 | //get existing log file and append new log info |
169 | - $this->_log = EEH_File::get_file_contents( $this->_logs_folder . $this->_log_file ) . $this->_log; |
|
170 | - EEH_File::write_to_file( $this->_logs_folder . $this->_log_file, $this->_log, 'Event Espresso Log' ); |
|
171 | - } catch( EE_Error $e ){ |
|
172 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
169 | + $this->_log = EEH_File::get_file_contents($this->_logs_folder.$this->_log_file).$this->_log; |
|
170 | + EEH_File::write_to_file($this->_logs_folder.$this->_log_file, $this->_log, 'Event Espresso Log'); |
|
171 | + } catch (EE_Error $e) { |
|
172 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | } |
@@ -182,31 +182,31 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function send_log() { |
184 | 184 | |
185 | - if ( empty( $this->_remote_logging_url )) { |
|
185 | + if (empty($this->_remote_logging_url)) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
189 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
190 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
191 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
192 | - $data .= '&time=' . time(); |
|
193 | - $data .= '&remote_log=' . $this->_log; |
|
194 | - $data .= '&request_array=' . json_encode( $_REQUEST ); |
|
189 | + $data = 'domain='.$_SERVER['HTTP_HOST']; |
|
190 | + $data .= '&ip='.$_SERVER['SERVER_ADDR']; |
|
191 | + $data .= '&server_type='.$_SERVER['SERVER_SOFTWARE']; |
|
192 | + $data .= '&time='.time(); |
|
193 | + $data .= '&remote_log='.$this->_log; |
|
194 | + $data .= '&request_array='.json_encode($_REQUEST); |
|
195 | 195 | $data .= '&action=save'; |
196 | 196 | |
197 | - if ( defined( 'EELOGGING_PASS' )) { |
|
198 | - $data .= '&pass=' . EELOGGING_PASS; |
|
197 | + if (defined('EELOGGING_PASS')) { |
|
198 | + $data .= '&pass='.EELOGGING_PASS; |
|
199 | 199 | } |
200 | - if ( defined( 'EELOGGING_KEY' )) { |
|
201 | - $data .= '&key=' . EELOGGING_KEY; |
|
200 | + if (defined('EELOGGING_KEY')) { |
|
201 | + $data .= '&key='.EELOGGING_KEY; |
|
202 | 202 | } |
203 | 203 | |
204 | - $c = curl_init( $this->_remote_logging_url ); |
|
205 | - curl_setopt( $c, CURLOPT_POST, TRUE ); |
|
206 | - curl_setopt( $c, CURLOPT_POSTFIELDS, $data ); |
|
207 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, TRUE ); |
|
208 | - curl_exec( $c ); |
|
209 | - curl_close( $c ); |
|
204 | + $c = curl_init($this->_remote_logging_url); |
|
205 | + curl_setopt($c, CURLOPT_POST, TRUE); |
|
206 | + curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
207 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); |
|
208 | + curl_exec($c); |
|
209 | + curl_close($c); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | * previous entries are overwritten |
218 | 218 | */ |
219 | 219 | public function write_debug() { |
220 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
220 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
221 | 221 | $this->_debug_log = ''; |
222 | - foreach ( $_GET as $key => $value ) { |
|
223 | - $this->_debug_log .= '$_GET["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
222 | + foreach ($_GET as $key => $value) { |
|
223 | + $this->_debug_log .= '$_GET["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
224 | 224 | } |
225 | - foreach ( $_POST as $key => $value ) { |
|
226 | - $this->_debug_log .= '$_POST["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
225 | + foreach ($_POST as $key => $value) { |
|
226 | + $this->_debug_log .= '$_POST["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
227 | 227 | } |
228 | 228 | try { |
229 | - EEH_File::write_to_file( $this->_logs_folder . $this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log' ); |
|
230 | - } catch( EE_Error $e ){ |
|
231 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso debug log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
229 | + EEH_File::write_to_file($this->_logs_folder.$this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log'); |
|
230 | + } catch (EE_Error $e) { |
|
231 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso debug log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * __clone |
241 | 241 | */ |
242 | 242 | public function __clone() { |
243 | - trigger_error( __( 'Clone is not allowed.', 'event_espresso' ), E_USER_ERROR ); |
|
243 | + trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 |
@@ -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 |
@@ -555,10 +555,10 @@ |
||
555 | 555 | $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) ); |
556 | 556 | $status_array = array(); |
557 | 557 | foreach ( $stati as $status ) { |
558 | - $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
559 | - } |
|
560 | - return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
|
561 | - } |
|
558 | + $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
559 | + } |
|
560 | + return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
|
561 | + } |
|
562 | 562 | |
563 | 563 | |
564 | 564 |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | * Returns the name of the field's name that points to the WP_User table |
742 | 742 | * on this model (or follows the _model_chain_to_wp_user and uses that model's |
743 | 743 | * foreign key to the WP_User table) |
744 | - * @return string|boolean string on success, boolean false when there is no |
|
744 | + * @return string|false string on success, boolean false when there is no |
|
745 | 745 | * foreign key to the WP_User table |
746 | 746 | */ |
747 | 747 | function wp_user_field_name() { |
@@ -837,6 +837,7 @@ discard block |
||
837 | 837 | * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array. |
838 | 838 | * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection |
839 | 839 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
840 | + * @param string $columns_to_select |
|
840 | 841 | * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
841 | 842 | */ |
842 | 843 | public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
@@ -1139,7 +1140,7 @@ discard block |
||
1139 | 1140 | * @param bool $pretty Whether to return the pretty formats (true) or not (false). |
1140 | 1141 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
1141 | 1142 | * |
1142 | - * @return array formats in an array with the date format first, and the time format last. |
|
1143 | + * @return string[] formats in an array with the date format first, and the time format last. |
|
1143 | 1144 | */ |
1144 | 1145 | public function get_formats_for( $field_name, $pretty = false ) { |
1145 | 1146 | $field_settings = $this->field_settings_for( $field_name ); |
@@ -1174,7 +1175,7 @@ discard block |
||
1174 | 1175 | * |
1175 | 1176 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
1176 | 1177 | * |
1177 | - * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
1178 | + * @return string|null If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
1178 | 1179 | * exception is triggered. |
1179 | 1180 | */ |
1180 | 1181 | public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
@@ -1474,7 +1475,7 @@ discard block |
||
1474 | 1475 | * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value). |
1475 | 1476 | * Wrapper for EEM_Base::delete() |
1476 | 1477 | * @param mixed $id |
1477 | - * @return boolean whether the row got deleted or not |
|
1478 | + * @return integer whether the row got deleted or not |
|
1478 | 1479 | */ |
1479 | 1480 | public function delete_by_ID( $id ){ |
1480 | 1481 | return $this->delete( array( |
@@ -1834,7 +1835,7 @@ discard block |
||
1834 | 1835 | /** |
1835 | 1836 | * Verifies the EE addons' database is up-to-date and records that we've done it on |
1836 | 1837 | * EEM_Base::$_db_verification_level |
1837 | - * @param $wpdb_method |
|
1838 | + * @param string $wpdb_method |
|
1838 | 1839 | * @param $arguments_to_provide |
1839 | 1840 | * @return string |
1840 | 1841 | */ |
@@ -1902,7 +1903,6 @@ discard block |
||
1902 | 1903 | * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one. |
1903 | 1904 | * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table |
1904 | 1905 | * |
1905 | - * @param EE_Base_Class/int $thisModelObject |
|
1906 | 1906 | * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object |
1907 | 1907 | * @param string $relationName, key in EEM_Base::_relations |
1908 | 1908 | * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id') |
@@ -1924,8 +1924,8 @@ discard block |
||
1924 | 1924 | * |
1925 | 1925 | * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models. |
1926 | 1926 | * |
1927 | - * @param EE_Base_Class/int $id_or_obj |
|
1928 | - * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object |
|
1927 | + * @param EE_CPT_Base $id_or_obj |
|
1928 | + * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object |
|
1929 | 1929 | * @param string $relationName key in EEM_Base::_relations |
1930 | 1930 | * @return boolean of success |
1931 | 1931 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
@@ -2001,7 +2001,7 @@ discard block |
||
2001 | 2001 | /** |
2002 | 2002 | * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default, |
2003 | 2003 | * unless otherwise specified in the $query_params |
2004 | - * @param int/EE_Base_Class $id_or_obj |
|
2004 | + * @param EE_Event $id_or_obj |
|
2005 | 2005 | * @param string $model_name like 'Event', or 'Registration' |
2006 | 2006 | * @param array $query_params like EEM_Base::get_all's |
2007 | 2007 | * @param string $field_to_count name of field to count by. By default, uses primary key |
@@ -2390,7 +2390,7 @@ discard block |
||
2390 | 2390 | /** |
2391 | 2391 | * Finds all the fields that correspond to the given table |
2392 | 2392 | * @param string $table_alias, array key in EEM_Base::_tables |
2393 | - * @return EE_Model_Field_Base[] |
|
2393 | + * @return EE_Model_Field_Base |
|
2394 | 2394 | */ |
2395 | 2395 | function _get_fields_for_table($table_alias){ |
2396 | 2396 | return $this->_fields[$table_alias]; |
@@ -3454,8 +3454,8 @@ discard block |
||
3454 | 3454 | /** |
3455 | 3455 | * gets the field object of type 'primary_key' from the fieldsSettings attribute. |
3456 | 3456 | * Eg, on EE_Answer that would be ANS_ID field object |
3457 | - * @param $field_obj |
|
3458 | - * @return EE_Model_Field_Base |
|
3457 | + * @param EE_Model_Field_Base $field_obj |
|
3458 | + * @return boolean |
|
3459 | 3459 | */ |
3460 | 3460 | public function is_primary_key_field( $field_obj ){ |
3461 | 3461 | return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE; |
@@ -3549,7 +3549,7 @@ discard block |
||
3549 | 3549 | * Gets the actual table for the table alias |
3550 | 3550 | * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe |
3551 | 3551 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
3552 | - * @return EE_Table_Base |
|
3552 | + * @return string |
|
3553 | 3553 | */ |
3554 | 3554 | function get_table_for_alias($table_alias){ |
3555 | 3555 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
@@ -3676,7 +3676,7 @@ discard block |
||
3676 | 3676 | * The purpose of this method is to allow us to create a model object that is not in the db that holds default values. |
3677 | 3677 | * A typical example of where this is used is when creating a new item and the initial load of a form. We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!). |
3678 | 3678 | * |
3679 | - * @return EE_Base_Class single EE_Base_Class object with default values for the properties. |
|
3679 | + * @return boolean single EE_Base_Class object with default values for the properties. |
|
3680 | 3680 | */ |
3681 | 3681 | public function create_default_object() { |
3682 | 3682 | |
@@ -4066,7 +4066,7 @@ discard block |
||
4066 | 4066 | } |
4067 | 4067 | /** |
4068 | 4068 | * Read comments for assume_values_already_prepared_by_model_object() |
4069 | - * @return int |
|
4069 | + * @return boolean |
|
4070 | 4070 | */ |
4071 | 4071 | public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
4072 | 4072 | return $this->_values_already_prepared_by_model_object; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @since EE4 |
24 | 24 | * |
25 | 25 | */ |
26 | -abstract class EEM_Base extends EE_Base{ |
|
26 | +abstract class EEM_Base extends EE_Base { |
|
27 | 27 | |
28 | 28 | //admin posty |
29 | 29 | //basic -> grants access to mine -> if they don't have it, select none |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * Flag indicating whether this model has a primary key or not |
229 | 229 | * @var boolean |
230 | 230 | */ |
231 | - protected $_has_primary_key_field=null; |
|
231 | + protected $_has_primary_key_field = null; |
|
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Whether or not this model is based off a table in WP core only (CPTs should set |
@@ -283,19 +283,19 @@ discard block |
||
283 | 283 | * operators that work like 'BETWEEN'. Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'" |
284 | 284 | * @var array |
285 | 285 | */ |
286 | - protected $_between_style_operators = array( 'BETWEEN' ); |
|
286 | + protected $_between_style_operators = array('BETWEEN'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * operators that are used for handling NUll and !NULL queries. Typically used for when checking if a row exists on a join table. |
290 | 290 | * @var array |
291 | 291 | */ |
292 | - protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL'); |
|
292 | + protected $_null_style_operators = array('IS NOT NULL', 'IS NULL'); |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * Allowed values for $query_params['order'] for ordering in queries |
296 | 296 | * @var array |
297 | 297 | */ |
298 | - protected $_allowed_order_values = array('asc','desc','ASC','DESC'); |
|
298 | + protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC'); |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * When these are keys in a WHERE or HAVING clause, they are handled much differently |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | * 'where', but 'where' clauses are so common that we thought we'd omit it |
310 | 310 | * @var array |
311 | 311 | */ |
312 | - private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps'); |
|
312 | + private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps'); |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * All the data types that can be used in $wpdb->prepare statements. |
316 | 316 | * @var array |
317 | 317 | */ |
318 | - private $_valid_wpdb_data_types = array('%d','%s','%f'); |
|
318 | + private $_valid_wpdb_data_types = array('%d', '%s', '%f'); |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * EE_Registry Object |
@@ -348,17 +348,17 @@ discard block |
||
348 | 348 | /** |
349 | 349 | * constant used to show EEM_Base has not yet verified the db on this http request |
350 | 350 | */ |
351 | - const db_verified_none = 0; |
|
351 | + const db_verified_none = 0; |
|
352 | 352 | /** |
353 | 353 | * constant used to show EEM_Base has verified the EE core db on this http request, |
354 | 354 | * but not the addons' dbs |
355 | 355 | */ |
356 | - const db_verified_core = 1; |
|
356 | + const db_verified_core = 1; |
|
357 | 357 | /** |
358 | 358 | * constant used to show EEM_Base has verified the addons' dbs (and implicitly |
359 | 359 | * the EE core db too) |
360 | 360 | */ |
361 | - const db_verified_addons = 2; |
|
361 | + const db_verified_addons = 2; |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * indicates whether an EEM_Base child has already re-verified the DB |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | * @param null $timezone |
390 | 390 | * @throws \EE_Error |
391 | 391 | */ |
392 | - protected function __construct( $timezone = NULL ){ |
|
392 | + protected function __construct($timezone = NULL) { |
|
393 | 393 | // check that the model has not been loaded too soon |
394 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) { |
|
395 | - throw new EE_Error ( |
|
394 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons')) { |
|
395 | + throw new EE_Error( |
|
396 | 396 | sprintf( |
397 | - __( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ), |
|
398 | - get_class( $this ) |
|
397 | + __('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'), |
|
398 | + get_class($this) |
|
399 | 399 | ) |
400 | 400 | ); |
401 | 401 | } |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | * just use EE_Register_Model_Extension |
406 | 406 | * @var EE_Table_Base[] $_tables |
407 | 407 | */ |
408 | - $this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables ); |
|
409 | - foreach($this->_tables as $table_alias => $table_obj){ |
|
408 | + $this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables); |
|
409 | + foreach ($this->_tables as $table_alias => $table_obj) { |
|
410 | 410 | /** @var $table_obj EE_Table_Base */ |
411 | 411 | $table_obj->_construct_finalize_with_alias($table_alias); |
412 | - if( $table_obj instanceof EE_Secondary_Table ){ |
|
412 | + if ($table_obj instanceof EE_Secondary_Table) { |
|
413 | 413 | /** @var $table_obj EE_Secondary_Table */ |
414 | 414 | $table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table()); |
415 | 415 | } |
@@ -419,48 +419,48 @@ discard block |
||
419 | 419 | * EE_Register_Model_Extension |
420 | 420 | * @param EE_Model_Field_Base[] $_fields |
421 | 421 | */ |
422 | - $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields); |
|
423 | - foreach($this->_fields as $table_alias => $fields_for_table){ |
|
424 | - if ( ! array_key_exists( $table_alias, $this->_tables )){ |
|
425 | - throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields))); |
|
422 | + $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields); |
|
423 | + foreach ($this->_fields as $table_alias => $fields_for_table) { |
|
424 | + if ( ! array_key_exists($table_alias, $this->_tables)) { |
|
425 | + throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields))); |
|
426 | 426 | } |
427 | - foreach($fields_for_table as $field_name => $field_obj){ |
|
427 | + foreach ($fields_for_table as $field_name => $field_obj) { |
|
428 | 428 | /** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */ |
429 | 429 | //primary key field base has a slightly different _construct_finalize |
430 | 430 | /** @var $field_obj EE_Model_Field_Base */ |
431 | - $field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() ); |
|
431 | + $field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name()); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | // everything is related to Extra_Meta |
436 | - if( get_class($this) != 'EEM_Extra_Meta'){ |
|
436 | + if (get_class($this) != 'EEM_Extra_Meta') { |
|
437 | 437 | //make extra meta related to everything, but don't block deleting things just |
438 | 438 | //because they have related extra meta info. For now just orphan those extra meta |
439 | 439 | //in the future we should automatically delete them |
440 | - $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE ); |
|
440 | + $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE); |
|
441 | 441 | } |
442 | 442 | //and change logs |
443 | - if( get_class( $this) != 'EEM_Change_Log' ) { |
|
444 | - $this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE ); |
|
443 | + if (get_class($this) != 'EEM_Change_Log') { |
|
444 | + $this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE); |
|
445 | 445 | } |
446 | 446 | /** |
447 | 447 | * Filters the list of relations on a model. It is best to NOT use this directly and instead just use |
448 | 448 | * EE_Register_Model_Extension |
449 | 449 | * @param EE_Model_Relation_Base[] $_model_relations |
450 | 450 | */ |
451 | - $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations); |
|
452 | - foreach($this->_model_relations as $model_name => $relation_obj){ |
|
451 | + $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations); |
|
452 | + foreach ($this->_model_relations as $model_name => $relation_obj) { |
|
453 | 453 | /** @var $relation_obj EE_Model_Relation_Base */ |
454 | 454 | $relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name); |
455 | 455 | } |
456 | - foreach($this->_indexes as $index_name => $index_obj){ |
|
456 | + foreach ($this->_indexes as $index_name => $index_obj) { |
|
457 | 457 | /** @var $index_obj EE_Index */ |
458 | 458 | $index_obj->_construct_finalize($index_name, $this->get_this_model_name()); |
459 | 459 | } |
460 | 460 | |
461 | 461 | $this->set_timezone($timezone); |
462 | 462 | //finalize default where condition strategy, or set default |
463 | - if( ! $this->_default_where_conditions_strategy){ |
|
463 | + if ( ! $this->_default_where_conditions_strategy) { |
|
464 | 464 | //nothing was set during child constructor, so set default |
465 | 465 | $this->_default_where_conditions_strategy = new EE_Default_Where_Conditions(); |
466 | 466 | } |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | |
469 | 469 | //if the cap slug hasn't been set, and we haven't set it to false on purpose |
470 | 470 | //to indicate to NOT set it, set it to the logical default |
471 | - if( $this->_caps_slug === null ) { |
|
472 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
473 | - $this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() ); |
|
471 | + if ($this->_caps_slug === null) { |
|
472 | + EE_Registry::instance()->load_helper('Inflector'); |
|
473 | + $this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name()); |
|
474 | 474 | } |
475 | 475 | //initialize the standard cap restriction generators if none were specified by the child constructor |
476 | - if( $this->_cap_restriction_generators !== false ){ |
|
477 | - foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){ |
|
478 | - if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) { |
|
479 | - $this->_cap_restriction_generators[ $cap_context ] = apply_filters( |
|
476 | + if ($this->_cap_restriction_generators !== false) { |
|
477 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
478 | + if ( ! isset($this->_cap_restriction_generators[$cap_context])) { |
|
479 | + $this->_cap_restriction_generators[$cap_context] = apply_filters( |
|
480 | 480 | 'FHEE__EEM_Base___construct__standard_cap_restriction_generator', |
481 | 481 | new EE_Restriction_Generator_Protected(), |
482 | 482 | $cap_context, |
@@ -486,23 +486,23 @@ discard block |
||
486 | 486 | } |
487 | 487 | } |
488 | 488 | //if there are cap restriction generators, use them to make the default cap restrictions |
489 | - if( $this->_cap_restriction_generators !== false ){ |
|
490 | - foreach( $this->_cap_restriction_generators as $context => $generator_object ) { |
|
491 | - if( ! $generator_object ){ |
|
489 | + if ($this->_cap_restriction_generators !== false) { |
|
490 | + foreach ($this->_cap_restriction_generators as $context => $generator_object) { |
|
491 | + if ( ! $generator_object) { |
|
492 | 492 | continue; |
493 | 493 | } |
494 | - if( ! $generator_object instanceof EE_Restriction_Generator_Base ){ |
|
494 | + if ( ! $generator_object instanceof EE_Restriction_Generator_Base) { |
|
495 | 495 | throw new EE_Error( |
496 | 496 | sprintf( |
497 | - __( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ), |
|
497 | + __('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'), |
|
498 | 498 | $context, |
499 | 499 | $this->get_this_model_name() |
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | } |
503 | - $action = $this->cap_action_for_context( $context ); |
|
504 | - if( ! $generator_object->construction_finalized() ){ |
|
505 | - $generator_object->_construct_finalize( $this, $action ); |
|
503 | + $action = $this->cap_action_for_context($context); |
|
504 | + if ( ! $generator_object->construction_finalized()) { |
|
505 | + $generator_object->_construct_finalize($this, $action); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | } |
@@ -516,11 +516,11 @@ discard block |
||
516 | 516 | * @param string $context one of EEM_Base::valid_cap_contexts() |
517 | 517 | * @return EE_Default_Where_Conditions[] |
518 | 518 | */ |
519 | - protected function _generate_cap_restrictions( $context ){ |
|
520 | - if( isset( $this->_cap_restriction_generators[ $context ] ) && |
|
521 | - $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
|
522 | - return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
|
523 | - }else{ |
|
519 | + protected function _generate_cap_restrictions($context) { |
|
520 | + if (isset($this->_cap_restriction_generators[$context]) && |
|
521 | + $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) { |
|
522 | + return $this->_cap_restriction_generators[$context]->generate_restrictions(); |
|
523 | + } else { |
|
524 | 524 | return array(); |
525 | 525 | } |
526 | 526 | } |
@@ -533,16 +533,16 @@ discard block |
||
533 | 533 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
534 | 534 | * @return static (as in the concrete child class) |
535 | 535 | */ |
536 | - public static function instance( $timezone = NULL ){ |
|
536 | + public static function instance($timezone = NULL) { |
|
537 | 537 | |
538 | 538 | // check if instance of Espresso_model already exists |
539 | 539 | if ( ! static::$_instance instanceof static) { |
540 | 540 | // instantiate Espresso_model |
541 | - static::$_instance = new static( $timezone ); |
|
541 | + static::$_instance = new static($timezone); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | //we might have a timezone set, let set_timezone decide what to do with it |
545 | - static::$_instance->set_timezone( $timezone ); |
|
545 | + static::$_instance->set_timezone($timezone); |
|
546 | 546 | |
547 | 547 | // Espresso_model object |
548 | 548 | return static::$_instance; |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | * @param null | string $timezone |
556 | 556 | * @return static |
557 | 557 | */ |
558 | - public static function reset( $timezone = NULL ){ |
|
559 | - if ( ! is_null( static::$_instance ) ) { |
|
558 | + public static function reset($timezone = NULL) { |
|
559 | + if ( ! is_null(static::$_instance)) { |
|
560 | 560 | static::$_instance = null; |
561 | 561 | |
562 | - return self::instance( $timezone ); |
|
562 | + return self::instance($timezone); |
|
563 | 563 | } |
564 | 564 | return null; |
565 | 565 | } |
@@ -570,15 +570,15 @@ discard block |
||
570 | 570 | * @param boolean $translated return localized strings or JUST the array. |
571 | 571 | * @return array |
572 | 572 | */ |
573 | - public function status_array( $translated = FALSE ) { |
|
574 | - if ( !array_key_exists('Status', $this->_model_relations ) ) |
|
573 | + public function status_array($translated = FALSE) { |
|
574 | + if ( ! array_key_exists('Status', $this->_model_relations)) |
|
575 | 575 | return array(); |
576 | 576 | $model_name = $this->get_this_model_name(); |
577 | - $status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) ); |
|
578 | - $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) ); |
|
577 | + $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name))); |
|
578 | + $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type))); |
|
579 | 579 | $status_array = array(); |
580 | - foreach ( $stati as $status ) { |
|
581 | - $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
580 | + foreach ($stati as $status) { |
|
581 | + $status_array[$status->ID()] = $status->get('STS_code'); |
|
582 | 582 | } |
583 | 583 | return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
584 | 584 | } |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | * 'order_by'=>array('ANS_value'=>'ASC') |
720 | 720 | * )); |
721 | 721 | */ |
722 | - function get_all($query_params = array()){ |
|
722 | + function get_all($query_params = array()) { |
|
723 | 723 | return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL)); |
724 | 724 | } |
725 | 725 | |
@@ -729,10 +729,10 @@ discard block |
||
729 | 729 | * @param array $query_params @see EEM_Base::get_all() |
730 | 730 | * @return array like EEM_Base::get_all |
731 | 731 | */ |
732 | - function alter_query_params_to_only_include_mine( $query_params = array() ) { |
|
732 | + function alter_query_params_to_only_include_mine($query_params = array()) { |
|
733 | 733 | $wp_user_field_name = $this->wp_user_field_name(); |
734 | - if( $wp_user_field_name ){ |
|
735 | - $query_params[0][ $wp_user_field_name ] = get_current_user_id(); |
|
734 | + if ($wp_user_field_name) { |
|
735 | + $query_params[0][$wp_user_field_name] = get_current_user_id(); |
|
736 | 736 | } |
737 | 737 | return $query_params; |
738 | 738 | } |
@@ -745,19 +745,19 @@ discard block |
||
745 | 745 | * foreign key to the WP_User table |
746 | 746 | */ |
747 | 747 | function wp_user_field_name() { |
748 | - try{ |
|
749 | - if( ! empty( $this->_model_chain_to_wp_user ) ) { |
|
750 | - $models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user ); |
|
751 | - $last_model_name = end( $models_to_follow_to_wp_users ); |
|
752 | - $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
|
753 | - $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
|
754 | - }else{ |
|
748 | + try { |
|
749 | + if ( ! empty($this->_model_chain_to_wp_user)) { |
|
750 | + $models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user); |
|
751 | + $last_model_name = end($models_to_follow_to_wp_users); |
|
752 | + $model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name); |
|
753 | + $model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.'; |
|
754 | + } else { |
|
755 | 755 | $model_with_fk_to_wp_users = $this; |
756 | 756 | $model_chain_to_wp_user = ''; |
757 | 757 | } |
758 | - $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
|
759 | - return $model_chain_to_wp_user . $wp_user_field->get_name(); |
|
760 | - }catch( EE_Error $e ) { |
|
758 | + $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User'); |
|
759 | + return $model_chain_to_wp_user.$wp_user_field->get_name(); |
|
760 | + } catch (EE_Error $e) { |
|
761 | 761 | return false; |
762 | 762 | } |
763 | 763 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * (or transietly-related model) |
772 | 772 | * @return string |
773 | 773 | */ |
774 | - public function model_chain_to_wp_user(){ |
|
774 | + public function model_chain_to_wp_user() { |
|
775 | 775 | return $this->_model_chain_to_wp_user; |
776 | 776 | } |
777 | 777 | |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | * @return boolean |
784 | 784 | */ |
785 | 785 | public function is_owned() { |
786 | - if( $this->model_chain_to_wp_user() ){ |
|
786 | + if ($this->model_chain_to_wp_user()) { |
|
787 | 787 | return true; |
788 | - }else{ |
|
789 | - try{ |
|
790 | - $this->get_foreign_key_to( 'WP_User' ); |
|
788 | + } else { |
|
789 | + try { |
|
790 | + $this->get_foreign_key_to('WP_User'); |
|
791 | 791 | return true; |
792 | - }catch( EE_Error $e ){ |
|
792 | + } catch (EE_Error $e) { |
|
793 | 793 | return false; |
794 | 794 | } |
795 | 795 | } |
@@ -808,21 +808,21 @@ discard block |
||
808 | 808 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
809 | 809 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
810 | 810 | */ |
811 | - protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
811 | + protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
812 | 812 | //remember the custom selections, if any |
813 | - if(is_array($columns_to_select)){ |
|
813 | + if (is_array($columns_to_select)) { |
|
814 | 814 | $this->_custom_selections = $columns_to_select; |
815 | - }elseif(is_string($columns_to_select)){ |
|
815 | + }elseif (is_string($columns_to_select)) { |
|
816 | 816 | $this->_custom_selections = array($this->_custom_selections); |
817 | - }else{ |
|
817 | + } else { |
|
818 | 818 | $this->_custom_selections = array(); |
819 | 819 | } |
820 | 820 | |
821 | 821 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
822 | 822 | $select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info); |
823 | - $SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
823 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
824 | 824 | // echo "sql:$SQL"; |
825 | - $results = $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output); |
|
825 | + $results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output); |
|
826 | 826 | return $results; |
827 | 827 | } |
828 | 828 | |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
840 | 840 | * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
841 | 841 | */ |
842 | - public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
842 | + public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
843 | 843 | return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select); |
844 | 844 | } |
845 | 845 | |
@@ -851,21 +851,21 @@ discard block |
||
851 | 851 | * @throws EE_Error |
852 | 852 | * @return string |
853 | 853 | */ |
854 | - private function _construct_select_from_input($columns_to_select){ |
|
855 | - if(is_array($columns_to_select)){ |
|
854 | + private function _construct_select_from_input($columns_to_select) { |
|
855 | + if (is_array($columns_to_select)) { |
|
856 | 856 | $select_sql_array = array(); |
857 | 857 | |
858 | - foreach($columns_to_select as $alias => $selection_and_datatype){ |
|
859 | - if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){ |
|
860 | - throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"),$selection_and_datatype,$alias)); |
|
858 | + foreach ($columns_to_select as $alias => $selection_and_datatype) { |
|
859 | + if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) { |
|
860 | + throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"), $selection_and_datatype, $alias)); |
|
861 | 861 | } |
862 | - if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){ |
|
863 | - throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"),$selection_and_datatype[1],$selection_and_datatype[0],$alias,implode(",",$this->_valid_wpdb_data_types))); |
|
862 | + if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) { |
|
863 | + throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"), $selection_and_datatype[1], $selection_and_datatype[0], $alias, implode(",", $this->_valid_wpdb_data_types))); |
|
864 | 864 | } |
865 | 865 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
866 | 866 | } |
867 | - $columns_to_select_string = implode(", ",$select_sql_array); |
|
868 | - }else{ |
|
867 | + $columns_to_select_string = implode(", ", $select_sql_array); |
|
868 | + } else { |
|
869 | 869 | $columns_to_select_string = $columns_to_select; |
870 | 870 | } |
871 | 871 | return $columns_to_select_string; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID' |
879 | 879 | * @return string |
880 | 880 | */ |
881 | - function primary_key_name(){ |
|
881 | + function primary_key_name() { |
|
882 | 882 | return $this->get_primary_key_field()->get_name(); |
883 | 883 | } |
884 | 884 | |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | * @param mixed $id int or string, depending on the type of the model's primary key |
891 | 891 | * @return EE_Base_Class |
892 | 892 | */ |
893 | - function get_one_by_ID($id){ |
|
894 | - if( $this->get_from_entity_map( $id ) ){ |
|
895 | - return $this->get_from_entity_map( $id ); |
|
896 | - }elseif( $this->has_primary_key_field ( ) ) { |
|
893 | + function get_one_by_ID($id) { |
|
894 | + if ($this->get_from_entity_map($id)) { |
|
895 | + return $this->get_from_entity_map($id); |
|
896 | + }elseif ($this->has_primary_key_field( )) { |
|
897 | 897 | $primary_key_name = $this->get_primary_key_field()->get_name(); |
898 | 898 | return $this->get_one(array(array($primary_key_name => $id))); |
899 | - }else{ |
|
899 | + } else { |
|
900 | 900 | //no primary key, so the $id must be from the get_index_primary_key_string() |
901 | - return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) ); |
|
901 | + return $this->get_one(array($this->parse_index_primary_key_string($id))); |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | |
@@ -909,16 +909,16 @@ discard block |
||
909 | 909 | * @param array $query_params like EEM_Base's $query_params variable. |
910 | 910 | * @return EE_Base_Class | NULL |
911 | 911 | */ |
912 | - function get_one($query_params = array()){ |
|
913 | - if( ! is_array( $query_params ) ){ |
|
914 | - EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
912 | + function get_one($query_params = array()) { |
|
913 | + if ( ! is_array($query_params)) { |
|
914 | + EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
915 | 915 | $query_params = array(); |
916 | 916 | } |
917 | 917 | $query_params['limit'] = 1; |
918 | 918 | $items = $this->get_all($query_params); |
919 | - if(empty($items)){ |
|
919 | + if (empty($items)) { |
|
920 | 920 | return null; |
921 | - }else{ |
|
921 | + } else { |
|
922 | 922 | return array_shift($items); |
923 | 923 | } |
924 | 924 | } |
@@ -942,8 +942,8 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @return EE_Base_Class[]|array |
944 | 944 | */ |
945 | - public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
946 | - return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
945 | + public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
946 | + return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | |
@@ -966,8 +966,8 @@ discard block |
||
966 | 966 | * |
967 | 967 | * @return EE_Base_Class[]|array |
968 | 968 | */ |
969 | - public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
970 | - return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
969 | + public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
970 | + return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
@@ -989,9 +989,9 @@ discard block |
||
989 | 989 | * |
990 | 990 | * @return EE_Base_Class|null|array() |
991 | 991 | */ |
992 | - public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
993 | - $results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
994 | - return empty( $results ) ? null : reset( $results ); |
|
992 | + public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
993 | + $results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
994 | + return empty($results) ? null : reset($results); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | |
@@ -1013,9 +1013,9 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @return EE_Base_Class|null|array() |
1015 | 1015 | */ |
1016 | - public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
1017 | - $results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
1018 | - return empty( $results ) ? null : reset( $results ); |
|
1016 | + public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
1017 | + $results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
1018 | + return empty($results) ? null : reset($results); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | |
@@ -1041,40 +1041,40 @@ discard block |
||
1041 | 1041 | * @return EE_Base_Class[]|array |
1042 | 1042 | * @throws EE_Error |
1043 | 1043 | */ |
1044 | - protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1044 | + protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1045 | 1045 | //if $field_to_order_by is empty then let's assume we're ordering by the primary key. |
1046 | - if ( empty( $field_to_order_by ) ) { |
|
1047 | - if ( $this->has_primary_key_field() ) { |
|
1046 | + if (empty($field_to_order_by)) { |
|
1047 | + if ($this->has_primary_key_field()) { |
|
1048 | 1048 | $field_to_order_by = $this->get_primary_key_field()->get_name(); |
1049 | 1049 | } else { |
1050 | 1050 | |
1051 | - if ( WP_DEBUG ) { |
|
1052 | - throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) ); |
|
1051 | + if (WP_DEBUG) { |
|
1052 | + throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso')); |
|
1053 | 1053 | } |
1054 | - EE_Error::add_error( __('There was an error with the query.', 'event_espresso') ); |
|
1054 | + EE_Error::add_error(__('There was an error with the query.', 'event_espresso')); |
|
1055 | 1055 | return array(); |
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | |
1059 | - if( ! is_array( $query_params ) ){ |
|
1060 | - EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1059 | + if ( ! is_array($query_params)) { |
|
1060 | + EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1061 | 1061 | $query_params = array(); |
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | //let's add the where query param for consecutive look up. |
1065 | - $query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value ); |
|
1065 | + $query_params[0][$field_to_order_by] = array($operand, $current_field_value); |
|
1066 | 1066 | $query_params['limit'] = $limit; |
1067 | 1067 | |
1068 | 1068 | //set direction |
1069 | - $incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array(); |
|
1070 | - $query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby; |
|
1069 | + $incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array(); |
|
1070 | + $query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby; |
|
1071 | 1071 | |
1072 | 1072 | //if $columns_to_select is empty then that means we're returning EE_Base_Class objects |
1073 | - if ( empty( $columns_to_select ) ) { |
|
1074 | - return $this->get_all( $query_params ); |
|
1073 | + if (empty($columns_to_select)) { |
|
1074 | + return $this->get_all($query_params); |
|
1075 | 1075 | } else { |
1076 | 1076 | //getting just the fields |
1077 | - return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select ); |
|
1077 | + return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select); |
|
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | |
@@ -1085,18 +1085,18 @@ discard block |
||
1085 | 1085 | * This sets the _timezone property after model object has been instantiated. |
1086 | 1086 | * @param null | string $timezone valid PHP DateTimeZone timezone string |
1087 | 1087 | */ |
1088 | - public function set_timezone( $timezone ) { |
|
1089 | - if ( $timezone !== null ) { |
|
1088 | + public function set_timezone($timezone) { |
|
1089 | + if ($timezone !== null) { |
|
1090 | 1090 | $this->_timezone = $timezone; |
1091 | 1091 | } |
1092 | 1092 | //note we need to loop through relations and set the timezone on those objects as well. |
1093 | - foreach ( $this->_model_relations as $relation ) { |
|
1094 | - $relation->set_timezone( $timezone ); |
|
1093 | + foreach ($this->_model_relations as $relation) { |
|
1094 | + $relation->set_timezone($timezone); |
|
1095 | 1095 | } |
1096 | 1096 | //and finally we do the same for any datetime fields |
1097 | - foreach ( $this->_fields as $field ) { |
|
1098 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1099 | - $field->set_timezone( $timezone ); |
|
1097 | + foreach ($this->_fields as $field) { |
|
1098 | + if ($field instanceof EE_Datetime_Field) { |
|
1099 | + $field->set_timezone($timezone); |
|
1100 | 1100 | } |
1101 | 1101 | } |
1102 | 1102 | } |
@@ -1111,9 +1111,9 @@ discard block |
||
1111 | 1111 | */ |
1112 | 1112 | public function get_timezone() { |
1113 | 1113 | //first validate if timezone is set. If not, then let's set it be whatever is set on the model fields. |
1114 | - if ( empty( $this->_timezone ) ) { |
|
1115 | - foreach( $this->_fields as $field ) { |
|
1116 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1114 | + if (empty($this->_timezone)) { |
|
1115 | + foreach ($this->_fields as $field) { |
|
1116 | + if ($field instanceof EE_Datetime_Field) { |
|
1117 | 1117 | $this->set_timezone($field->get_timezone()); |
1118 | 1118 | break; |
1119 | 1119 | } |
@@ -1121,9 +1121,9 @@ discard block |
||
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | //if timezone STILL empty then return the default timezone for the site. |
1124 | - if ( empty( $this->_timezone ) ) { |
|
1125 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
1126 | - $this->set_timezone( EEH_DTT_Helper::get_timezone() ); |
|
1124 | + if (empty($this->_timezone)) { |
|
1125 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1126 | + $this->set_timezone(EEH_DTT_Helper::get_timezone()); |
|
1127 | 1127 | } |
1128 | 1128 | return $this->_timezone; |
1129 | 1129 | } |
@@ -1141,19 +1141,19 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return array formats in an array with the date format first, and the time format last. |
1143 | 1143 | */ |
1144 | - public function get_formats_for( $field_name, $pretty = false ) { |
|
1145 | - $field_settings = $this->field_settings_for( $field_name ); |
|
1144 | + public function get_formats_for($field_name, $pretty = false) { |
|
1145 | + $field_settings = $this->field_settings_for($field_name); |
|
1146 | 1146 | |
1147 | 1147 | //if not a valid EE_Datetime_Field then throw error |
1148 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
1149 | - throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) ); |
|
1148 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
1149 | + throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name)); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | //while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on |
1153 | 1153 | //the field. |
1154 | 1154 | $this->_timezone = $field_settings->get_timezone(); |
1155 | 1155 | |
1156 | - return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) ); |
|
1156 | + return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty)); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | |
@@ -1177,25 +1177,25 @@ discard block |
||
1177 | 1177 | * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
1178 | 1178 | * exception is triggered. |
1179 | 1179 | */ |
1180 | - public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
|
1181 | - $formats = $this->get_formats_for( $field_name ); |
|
1180 | + public function current_time_for_query($field_name, $timestamp = false, $what = 'both') { |
|
1181 | + $formats = $this->get_formats_for($field_name); |
|
1182 | 1182 | |
1183 | - $DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) ); |
|
1183 | + $DateTime = new DateTime("now", new DateTimeZone($this->_timezone)); |
|
1184 | 1184 | |
1185 | - if ( $timestamp ) { |
|
1186 | - return $DateTime->format( 'U' ); |
|
1185 | + if ($timestamp) { |
|
1186 | + return $DateTime->format('U'); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | //not returning timestamp, so return formatted string in timezone. |
1190 | - switch( $what ) { |
|
1190 | + switch ($what) { |
|
1191 | 1191 | case 'time' : |
1192 | - return $DateTime->format( $formats[1] ); |
|
1192 | + return $DateTime->format($formats[1]); |
|
1193 | 1193 | break; |
1194 | 1194 | case 'date' : |
1195 | - return $DateTime->format( $formats[0] ); |
|
1195 | + return $DateTime->format($formats[0]); |
|
1196 | 1196 | break; |
1197 | 1197 | default : |
1198 | - return $DateTime->format( implode( ' ', $formats ) ); |
|
1198 | + return $DateTime->format(implode(' ', $formats)); |
|
1199 | 1199 | break; |
1200 | 1200 | } |
1201 | 1201 | } |
@@ -1219,18 +1219,18 @@ discard block |
||
1219 | 1219 | * 'U', this is ignored. |
1220 | 1220 | * @return DateTime |
1221 | 1221 | */ |
1222 | - public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) { |
|
1222 | + public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') { |
|
1223 | 1223 | |
1224 | 1224 | //just using this to ensure the timezone is set correctly internally |
1225 | - $this->get_formats_for( $field_name ); |
|
1225 | + $this->get_formats_for($field_name); |
|
1226 | 1226 | |
1227 | 1227 | //load EEH_DTT_Helper |
1228 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
1229 | - $set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
1228 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1229 | + $set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
1230 | 1230 | |
1231 | - $incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) ); |
|
1231 | + $incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone)); |
|
1232 | 1232 | |
1233 | - return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) ); |
|
1233 | + return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone)); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects |
1241 | 1241 | * @return EE_Table_Base[] |
1242 | 1242 | */ |
1243 | - function get_tables(){ |
|
1243 | + function get_tables() { |
|
1244 | 1244 | return $this->_tables; |
1245 | 1245 | } |
1246 | 1246 | |
@@ -1274,9 +1274,9 @@ discard block |
||
1274 | 1274 | * be aware that model objects being used could get out-of-sync with the database |
1275 | 1275 | * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad) |
1276 | 1276 | */ |
1277 | - function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){ |
|
1278 | - if( ! is_array( $query_params ) ){ |
|
1279 | - EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1277 | + function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
1278 | + if ( ! is_array($query_params)) { |
|
1279 | + EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1280 | 1280 | $query_params = array(); |
1281 | 1281 | } |
1282 | 1282 | /** |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | * @param array $fields_n_values the updated fields and their new values |
1287 | 1287 | * @param array $query_params @see EEM_Base::get_all() |
1288 | 1288 | */ |
1289 | - do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params ); |
|
1289 | + do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params); |
|
1290 | 1290 | /** |
1291 | 1291 | * Filters the fields about to be updated given the query parameters. You can provide the |
1292 | 1292 | * $query_params to $this->get_all() to find exactly which records will be updated |
@@ -1294,10 +1294,10 @@ discard block |
||
1294 | 1294 | * @param EEM_Base $model the model being queried |
1295 | 1295 | * @param array $query_params see EEM_Base::get_all() |
1296 | 1296 | */ |
1297 | - $fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params ); |
|
1297 | + $fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params); |
|
1298 | 1298 | //need to verify that, for any entry we want to update, there are entries in each secondary table. |
1299 | 1299 | //to do that, for each table, verify that it's PK isn't null. |
1300 | - $tables= $this->get_tables(); |
|
1300 | + $tables = $this->get_tables(); |
|
1301 | 1301 | |
1302 | 1302 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
1303 | 1303 | //NOTE: we should make this code more efficient by NOT querying twice |
@@ -1307,29 +1307,29 @@ discard block |
||
1307 | 1307 | //we want to make sure the default_where strategy is ignored |
1308 | 1308 | $this->_ignore_where_strategy = TRUE; |
1309 | 1309 | $wpdb_select_results = $this->_get_all_wpdb_results($query_params); |
1310 | - foreach( $wpdb_select_results as $wpdb_result ){ |
|
1310 | + foreach ($wpdb_select_results as $wpdb_result) { |
|
1311 | 1311 | // type cast stdClass as array |
1312 | - $wpdb_result = (array)$wpdb_result; |
|
1312 | + $wpdb_result = (array) $wpdb_result; |
|
1313 | 1313 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
1314 | - if( $this->has_primary_key_field() ){ |
|
1315 | - $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
1316 | - }else{ |
|
1314 | + if ($this->has_primary_key_field()) { |
|
1315 | + $main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()]; |
|
1316 | + } else { |
|
1317 | 1317 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it woudl be lots of work) |
1318 | 1318 | $main_table_pk_value = null; |
1319 | 1319 | } |
1320 | 1320 | //if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables |
1321 | 1321 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
1322 | - if(count($tables) > 1){ |
|
1322 | + if (count($tables) > 1) { |
|
1323 | 1323 | //foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry |
1324 | 1324 | //in that table, and so we'll want to insert one |
1325 | - foreach($tables as $table_obj){ |
|
1325 | + foreach ($tables as $table_obj) { |
|
1326 | 1326 | $this_table_pk_column = $table_obj->get_fully_qualified_pk_column(); |
1327 | 1327 | //if there is no private key for this table on the results, it means there's no entry |
1328 | 1328 | //in this table, right? so insert a row in the current table, using any fields available |
1329 | - if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){ |
|
1329 | + if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) { |
|
1330 | 1330 | $success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value); |
1331 | 1331 | //if we died here, report the error |
1332 | - if( ! $success ) { |
|
1332 | + if ( ! $success) { |
|
1333 | 1333 | return false; |
1334 | 1334 | } |
1335 | 1335 | } |
@@ -1349,44 +1349,44 @@ discard block |
||
1349 | 1349 | //if this wasn't called from a model object (to update itself) |
1350 | 1350 | //then we want to make sure we keep all the existing |
1351 | 1351 | //model objects in sync with the db |
1352 | - if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
|
1353 | - if( $this->has_primary_key_field() ){ |
|
1354 | - $model_objs_affected_ids = $this->get_col( $query_params ); |
|
1355 | - }else{ |
|
1352 | + if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) { |
|
1353 | + if ($this->has_primary_key_field()) { |
|
1354 | + $model_objs_affected_ids = $this->get_col($query_params); |
|
1355 | + } else { |
|
1356 | 1356 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
1357 | - $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
|
1357 | + $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A); |
|
1358 | 1358 | $model_objs_affected_ids = array(); |
1359 | - foreach( $models_affected_key_columns as $row ){ |
|
1360 | - $combined_index_key = $this->get_index_primary_key_string( $row ); |
|
1361 | - $model_objs_affected_ids[ $combined_index_key ] = $combined_index_key; |
|
1359 | + foreach ($models_affected_key_columns as $row) { |
|
1360 | + $combined_index_key = $this->get_index_primary_key_string($row); |
|
1361 | + $model_objs_affected_ids[$combined_index_key] = $combined_index_key; |
|
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - if( ! $model_objs_affected_ids ){ |
|
1366 | + if ( ! $model_objs_affected_ids) { |
|
1367 | 1367 | //wait wait wait- if nothing was affected let's stop here |
1368 | 1368 | return 0; |
1369 | 1369 | } |
1370 | - foreach( $model_objs_affected_ids as $id ){ |
|
1371 | - $model_obj_in_entity_map = $this->get_from_entity_map( $id ); |
|
1372 | - if( $model_obj_in_entity_map ){ |
|
1373 | - foreach( $fields_n_values as $field => $new_value ){ |
|
1374 | - $model_obj_in_entity_map->set( $field, $new_value ); |
|
1370 | + foreach ($model_objs_affected_ids as $id) { |
|
1371 | + $model_obj_in_entity_map = $this->get_from_entity_map($id); |
|
1372 | + if ($model_obj_in_entity_map) { |
|
1373 | + foreach ($fields_n_values as $field => $new_value) { |
|
1374 | + $model_obj_in_entity_map->set($field, $new_value); |
|
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | } |
1378 | 1378 | //if there is a primary key on this model, we can now do a slight optimization |
1379 | - if( $this->has_primary_key_field() ){ |
|
1379 | + if ($this->has_primary_key_field()) { |
|
1380 | 1380 | //we already know what we want to update. So let's make the query simpler so it's a little more efficient |
1381 | 1381 | $query_params = array( |
1382 | - array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ), |
|
1383 | - 'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' ); |
|
1382 | + array($this->primary_key_name() => array('IN', $model_objs_affected_ids)), |
|
1383 | + 'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' ); |
|
1384 | 1384 | } |
1385 | 1385 | } |
1386 | 1386 | |
1387 | - $model_query_info = $this->_create_model_query_info_carrier( $query_params ); |
|
1388 | - $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
1389 | - $rows_affected = $this->_do_wpdb_query('query', array( $SQL ) ); |
|
1387 | + $model_query_info = $this->_create_model_query_info_carrier($query_params); |
|
1388 | + $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
1389 | + $rows_affected = $this->_do_wpdb_query('query', array($SQL)); |
|
1390 | 1390 | /** |
1391 | 1391 | * Action called after a model update call has been made. |
1392 | 1392 | * |
@@ -1395,8 +1395,8 @@ discard block |
||
1395 | 1395 | * @param array $query_params @see EEM_Base::get_all() |
1396 | 1396 | * @param int $rows_affected |
1397 | 1397 | */ |
1398 | - do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected ); |
|
1399 | - return $rows_affected;//how many supposedly got updated |
|
1398 | + do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected); |
|
1399 | + return $rows_affected; //how many supposedly got updated |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | /** |
@@ -1408,22 +1408,22 @@ discard block |
||
1408 | 1408 | * @param string $field_to_select |
1409 | 1409 | * @return array just like $wpdb->get_col() |
1410 | 1410 | */ |
1411 | - public function get_col( $query_params = array(), $field_to_select = NULL ){ |
|
1411 | + public function get_col($query_params = array(), $field_to_select = NULL) { |
|
1412 | 1412 | |
1413 | - if( $field_to_select ){ |
|
1414 | - $field = $this->field_settings_for( $field_to_select ); |
|
1415 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
1413 | + if ($field_to_select) { |
|
1414 | + $field = $this->field_settings_for($field_to_select); |
|
1415 | + }elseif ($this->has_primary_key_field( )) { |
|
1416 | 1416 | $field = $this->get_primary_key_field(); |
1417 | - }else{ |
|
1417 | + } else { |
|
1418 | 1418 | //no primary key, just grab the first column |
1419 | - $field = reset( $this->field_settings()); |
|
1419 | + $field = reset($this->field_settings()); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | |
1423 | 1423 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1424 | 1424 | $select_expressions = $field->get_qualified_column(); |
1425 | - $SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1426 | - $results = $this->_do_wpdb_query('get_col', array( $SQL ) ); |
|
1425 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1426 | + $results = $this->_do_wpdb_query('get_col', array($SQL)); |
|
1427 | 1427 | return $results; |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1433,12 +1433,12 @@ discard block |
||
1433 | 1433 | * @param string $field_to_select @see EEM_Base::get_col() |
1434 | 1434 | * @return string |
1435 | 1435 | */ |
1436 | - public function get_var( $query_params = array(), $field_to_select = NULL ) { |
|
1437 | - $query_params[ 'limit' ] = 1; |
|
1438 | - $col = $this->get_col( $query_params, $field_to_select ); |
|
1439 | - if( ! empty( $col ) ) { |
|
1440 | - return reset( $col ); |
|
1441 | - }else{ |
|
1436 | + public function get_var($query_params = array(), $field_to_select = NULL) { |
|
1437 | + $query_params['limit'] = 1; |
|
1438 | + $col = $this->get_col($query_params, $field_to_select); |
|
1439 | + if ( ! empty($col)) { |
|
1440 | + return reset($col); |
|
1441 | + } else { |
|
1442 | 1442 | return NULL; |
1443 | 1443 | } |
1444 | 1444 | } |
@@ -1452,19 +1452,19 @@ discard block |
||
1452 | 1452 | * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB |
1453 | 1453 | * @return string of SQL |
1454 | 1454 | */ |
1455 | - function _construct_update_sql($fields_n_values){ |
|
1455 | + function _construct_update_sql($fields_n_values) { |
|
1456 | 1456 | /** @type WPDB $wpdb */ |
1457 | 1457 | global $wpdb; |
1458 | 1458 | $cols_n_values = array(); |
1459 | - foreach($fields_n_values as $field_name => $value){ |
|
1459 | + foreach ($fields_n_values as $field_name => $value) { |
|
1460 | 1460 | $field_obj = $this->field_settings_for($field_name); |
1461 | 1461 | //if the value is NULL, we want to assign the value to that. |
1462 | 1462 | //wpdb->prepare doesn't really handle that properly |
1463 | - $prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values ); |
|
1464 | - $value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value ); |
|
1463 | + $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
|
1464 | + $value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value); |
|
1465 | 1465 | $cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql; |
1466 | 1466 | } |
1467 | - return implode(",",$cols_n_values); |
|
1467 | + return implode(",", $cols_n_values); |
|
1468 | 1468 | |
1469 | 1469 | } |
1470 | 1470 | |
@@ -1476,11 +1476,11 @@ discard block |
||
1476 | 1476 | * @param mixed $id |
1477 | 1477 | * @return boolean whether the row got deleted or not |
1478 | 1478 | */ |
1479 | - public function delete_by_ID( $id ){ |
|
1480 | - return $this->delete( array( |
|
1481 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
1479 | + public function delete_by_ID($id) { |
|
1480 | + return $this->delete(array( |
|
1481 | + array($this->get_primary_key_field()->get_name() => $id), |
|
1482 | 1482 | 'limit' => 1 |
1483 | - ) ); |
|
1483 | + )); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | |
@@ -1495,7 +1495,7 @@ discard block |
||
1495 | 1495 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
1496 | 1496 | * @return int how many rows got deleted |
1497 | 1497 | */ |
1498 | - function delete($query_params,$allow_blocking = true){ |
|
1498 | + function delete($query_params, $allow_blocking = true) { |
|
1499 | 1499 | /** |
1500 | 1500 | * Action called just before performing a real deletion query. You can use the |
1501 | 1501 | * model and its $query_params to find exactly which items will be deleted |
@@ -1504,34 +1504,34 @@ discard block |
||
1504 | 1504 | * @param boolean $allow_blocking whether or not to allow related model objects |
1505 | 1505 | * to block (prevent) this deletion |
1506 | 1506 | */ |
1507 | - do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking ); |
|
1507 | + do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking); |
|
1508 | 1508 | //some MySQL databases may be running safe mode, which may restrict |
1509 | 1509 | //deletion if there is no KEY column used in the WHERE statement of a deletion. |
1510 | 1510 | //to get around this, we first do a SELECT, get all the IDs, and then run another query |
1511 | 1511 | //to delete them |
1512 | 1512 | $items_for_deletion = $this->_get_all_wpdb_results($query_params); |
1513 | - $deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking); |
|
1514 | - if($deletion_where){ |
|
1513 | + $deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking); |
|
1514 | + if ($deletion_where) { |
|
1515 | 1515 | //echo "objects for deletion:";var_dump($objects_for_deletion); |
1516 | 1516 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1517 | 1517 | $table_aliases = array(); |
1518 | - foreach(array_keys($this->_tables) as $table_alias){ |
|
1518 | + foreach (array_keys($this->_tables) as $table_alias) { |
|
1519 | 1519 | $table_aliases[] = $table_alias; |
1520 | 1520 | } |
1521 | - $SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
1521 | + $SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
1522 | 1522 | |
1523 | 1523 | // /echo "delete sql:$SQL"; |
1524 | - $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
|
1525 | - }else{ |
|
1524 | + $rows_deleted = $this->_do_wpdb_query('query', array($SQL)); |
|
1525 | + } else { |
|
1526 | 1526 | $rows_deleted = 0; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | //and lastly make sure those items are removed from the entity map; if they could be put into it at all |
1530 | - if( $this->has_primary_key_field() ){ |
|
1531 | - foreach($items_for_deletion as $item_for_deletion_row ){ |
|
1532 | - $pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
1533 | - if( isset( $this->_entity_map[ $pk_value ] ) ){ |
|
1534 | - unset( $this->_entity_map[ $pk_value ] ); |
|
1530 | + if ($this->has_primary_key_field()) { |
|
1531 | + foreach ($items_for_deletion as $item_for_deletion_row) { |
|
1532 | + $pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()]; |
|
1533 | + if (isset($this->_entity_map[$pk_value])) { |
|
1534 | + unset($this->_entity_map[$pk_value]); |
|
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | } |
@@ -1543,8 +1543,8 @@ discard block |
||
1543 | 1543 | * @param array $query_params @see EEM_Base::get_all() |
1544 | 1544 | * @param int $rows_deleted |
1545 | 1545 | */ |
1546 | - do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted ); |
|
1547 | - return $rows_deleted;//how many supposedly got deleted |
|
1546 | + do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted); |
|
1547 | + return $rows_deleted; //how many supposedly got deleted |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | |
@@ -1560,28 +1560,28 @@ discard block |
||
1560 | 1560 | * blocking its deletion before removing the relation between A and B |
1561 | 1561 | * @return boolean |
1562 | 1562 | */ |
1563 | - public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){ |
|
1563 | + public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) { |
|
1564 | 1564 | //first, if $ignore_this_model_obj was supplied, get its model |
1565 | - if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
|
1565 | + if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) { |
|
1566 | 1566 | $ignored_model = $ignore_this_model_obj->get_model(); |
1567 | - }else{ |
|
1567 | + } else { |
|
1568 | 1568 | $ignored_model = null; |
1569 | 1569 | } |
1570 | 1570 | //now check all the relations of $this_model_obj_or_id and see if there |
1571 | 1571 | //are any related model objects blocking it? |
1572 | 1572 | $is_blocked = false; |
1573 | - foreach($this->_model_relations as $relation_name => $relation_obj){ |
|
1574 | - if( $relation_obj->block_delete_if_related_models_exist()){ |
|
1573 | + foreach ($this->_model_relations as $relation_name => $relation_obj) { |
|
1574 | + if ($relation_obj->block_delete_if_related_models_exist()) { |
|
1575 | 1575 | //if $ignore_this_model_obj was supplied, then for the query |
1576 | 1576 | //on that model needs to be told to ignore $ignore_this_model_obj |
1577 | - if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){ |
|
1578 | - $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
|
1579 | - array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
|
1580 | - }else{ |
|
1577 | + if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) { |
|
1578 | + $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array( |
|
1579 | + array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID())))); |
|
1580 | + } else { |
|
1581 | 1581 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
1582 | 1582 | } |
1583 | 1583 | |
1584 | - if($related_model_objects){ |
|
1584 | + if ($related_model_objects) { |
|
1585 | 1585 | EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__); |
1586 | 1586 | $is_blocked = true; |
1587 | 1587 | } |
@@ -1601,65 +1601,65 @@ discard block |
||
1601 | 1601 | * @throws EE_Error |
1602 | 1602 | * @return string everything that comes after the WHERE statement. |
1603 | 1603 | */ |
1604 | - protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) { |
|
1605 | - if($this->has_primary_key_field()){ |
|
1604 | + protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) { |
|
1605 | + if ($this->has_primary_key_field()) { |
|
1606 | 1606 | $primary_table = $this->_get_main_table(); |
1607 | 1607 | $other_tables = $this->_get_other_tables(); |
1608 | 1608 | $deletes = $query = array(); |
1609 | - foreach ( $objects_for_deletion as $delete_object ) { |
|
1609 | + foreach ($objects_for_deletion as $delete_object) { |
|
1610 | 1610 | //before we mark this object for deletion, |
1611 | 1611 | //make sure there's no related objects blocking its deletion (if we're checking) |
1612 | - if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){ |
|
1612 | + if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) { |
|
1613 | 1613 | continue; |
1614 | 1614 | } |
1615 | 1615 | |
1616 | 1616 | //primary table deletes |
1617 | - if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) |
|
1617 | + if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) |
|
1618 | 1618 | $deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()]; |
1619 | 1619 | |
1620 | 1620 | //other tables |
1621 | - if ( !empty( $other_tables ) ) { |
|
1622 | - foreach ( $other_tables as $ot ) { |
|
1621 | + if ( ! empty($other_tables)) { |
|
1622 | + foreach ($other_tables as $ot) { |
|
1623 | 1623 | |
1624 | 1624 | //first check if we've got the foreign key column here. |
1625 | - if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) |
|
1625 | + if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) |
|
1626 | 1626 | $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()]; |
1627 | 1627 | |
1628 | 1628 | //wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables |
1629 | - if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) |
|
1629 | + if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) |
|
1630 | 1630 | $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
1631 | 1631 | |
1632 | 1632 | //finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there! |
1633 | - if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) |
|
1633 | + if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) |
|
1634 | 1634 | $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
1635 | 1635 | } |
1636 | 1636 | } |
1637 | 1637 | } |
1638 | 1638 | |
1639 | 1639 | //we should have deletes now, so let's just go through and setup the where statement |
1640 | - foreach ( $deletes as $column => $values ) { |
|
1640 | + foreach ($deletes as $column => $values) { |
|
1641 | 1641 | //make sure we have unique $values; |
1642 | 1642 | $values = array_unique($values); |
1643 | - $query[] = $column . ' IN(' . implode(",",$values) . ')'; |
|
1643 | + $query[] = $column.' IN('.implode(",", $values).')'; |
|
1644 | 1644 | } |
1645 | 1645 | |
1646 | - return !empty($query) ? implode(' AND ', $query ) : ''; |
|
1647 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1646 | + return ! empty($query) ? implode(' AND ', $query) : ''; |
|
1647 | + }elseif (count($this->get_combined_primary_key_fields()) > 1) { |
|
1648 | 1648 | $ways_to_identify_a_row = array(); |
1649 | 1649 | $fields = $this->get_combined_primary_key_fields(); |
1650 | 1650 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
1651 | - foreach($objects_for_deletion as $delete_object){ |
|
1651 | + foreach ($objects_for_deletion as $delete_object) { |
|
1652 | 1652 | $values_for_each_cpk_for_a_row = array(); |
1653 | - foreach($fields as $cpk_field){ |
|
1653 | + foreach ($fields as $cpk_field) { |
|
1654 | 1654 | $values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()]; |
1655 | 1655 | } |
1656 | - $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
|
1656 | + $ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")"; |
|
1657 | 1657 | } |
1658 | - return implode(" OR ",$ways_to_identify_a_row); |
|
1659 | - }else{ |
|
1658 | + return implode(" OR ", $ways_to_identify_a_row); |
|
1659 | + } else { |
|
1660 | 1660 | //so there's no primary key and no combined key... |
1661 | 1661 | //sorry, can't help you |
1662 | - throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
|
1662 | + throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this))); |
|
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | |
@@ -1673,21 +1673,21 @@ discard block |
||
1673 | 1673 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
1674 | 1674 | * @return int |
1675 | 1675 | */ |
1676 | - function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1676 | + function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1677 | 1677 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1678 | - if($field_to_count){ |
|
1678 | + if ($field_to_count) { |
|
1679 | 1679 | $field_obj = $this->field_settings_for($field_to_count); |
1680 | 1680 | $column_to_count = $field_obj->get_qualified_column(); |
1681 | - }elseif($this->has_primary_key_field ()){ |
|
1681 | + }elseif ($this->has_primary_key_field()) { |
|
1682 | 1682 | $pk_field_obj = $this->get_primary_key_field(); |
1683 | 1683 | $column_to_count = $pk_field_obj->get_qualified_column(); |
1684 | - }else{//there's no primary key |
|
1684 | + } else {//there's no primary key |
|
1685 | 1685 | $column_to_count = '*'; |
1686 | 1686 | } |
1687 | 1687 | |
1688 | - $column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count; |
|
1689 | - $SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
1690 | - return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) ); |
|
1688 | + $column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count; |
|
1689 | + $SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1690 | + return (int) $this->_do_wpdb_query('get_var', array($SQL)); |
|
1691 | 1691 | } |
1692 | 1692 | |
1693 | 1693 | /** |
@@ -1697,23 +1697,23 @@ discard block |
||
1697 | 1697 | * @param string $field_to_sum name of field (array key in $_fields array) |
1698 | 1698 | * @return float |
1699 | 1699 | */ |
1700 | - function sum($query_params, $field_to_sum = NULL){ |
|
1700 | + function sum($query_params, $field_to_sum = NULL) { |
|
1701 | 1701 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1702 | 1702 | |
1703 | - if($field_to_sum){ |
|
1703 | + if ($field_to_sum) { |
|
1704 | 1704 | $field_obj = $this->field_settings_for($field_to_sum); |
1705 | 1705 | |
1706 | - }else{ |
|
1706 | + } else { |
|
1707 | 1707 | $field_obj = $this->get_primary_key_field(); |
1708 | 1708 | } |
1709 | 1709 | $column_to_count = $field_obj->get_qualified_column(); |
1710 | 1710 | |
1711 | - $SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
1712 | - $return_value = $this->_do_wpdb_query('get_var',array( $SQL ) ); |
|
1713 | - if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){ |
|
1714 | - return (float)$return_value; |
|
1715 | - }else{//must be %f |
|
1716 | - return (float)$return_value; |
|
1711 | + $SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1712 | + $return_value = $this->_do_wpdb_query('get_var', array($SQL)); |
|
1713 | + if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') { |
|
1714 | + return (float) $return_value; |
|
1715 | + } else {//must be %f |
|
1716 | + return (float) $return_value; |
|
1717 | 1717 | } |
1718 | 1718 | } |
1719 | 1719 | |
@@ -1728,33 +1728,33 @@ discard block |
||
1728 | 1728 | * @global wpdb $wpdb |
1729 | 1729 | * @return mixed |
1730 | 1730 | */ |
1731 | - protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){ |
|
1731 | + protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
1732 | 1732 | //if we're in maintenance mode level 2, DON'T run any queries |
1733 | 1733 | //because level 2 indicates the database needs updating and |
1734 | 1734 | //is probably out of sync with the code |
1735 | - if( ! EE_Maintenance_Mode::instance()->models_can_query()){ |
|
1735 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
1736 | 1736 | throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso"))); |
1737 | 1737 | } |
1738 | 1738 | /** @type WPDB $wpdb */ |
1739 | 1739 | global $wpdb; |
1740 | - if( ! method_exists( $wpdb, $wpdb_method ) ){ |
|
1741 | - throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) ); |
|
1740 | + if ( ! method_exists($wpdb, $wpdb_method)) { |
|
1741 | + throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method)); |
|
1742 | 1742 | } |
1743 | - if( WP_DEBUG ){ |
|
1743 | + if (WP_DEBUG) { |
|
1744 | 1744 | $old_show_errors_value = $wpdb->show_errors; |
1745 | - $wpdb->show_errors( FALSE ); |
|
1746 | - } |
|
1747 | - $result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
1748 | - $this->show_db_query_if_previously_requested( $wpdb->last_query ); |
|
1749 | - if( WP_DEBUG ){ |
|
1750 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1751 | - if( ! empty( $wpdb->last_error ) ){ |
|
1752 | - throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
|
1753 | - }elseif( $result === false ){ |
|
1754 | - throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
|
1745 | + $wpdb->show_errors(FALSE); |
|
1746 | + } |
|
1747 | + $result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
1748 | + $this->show_db_query_if_previously_requested($wpdb->last_query); |
|
1749 | + if (WP_DEBUG) { |
|
1750 | + $wpdb->show_errors($old_show_errors_value); |
|
1751 | + if ( ! empty($wpdb->last_error)) { |
|
1752 | + throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error)); |
|
1753 | + }elseif ($result === false) { |
|
1754 | + throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true))); |
|
1755 | 1755 | } |
1756 | - }elseif( $result === false ) { |
|
1757 | - EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__); |
|
1756 | + }elseif ($result === false) { |
|
1757 | + EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__); |
|
1758 | 1758 | } |
1759 | 1759 | return $result; |
1760 | 1760 | } |
@@ -1770,23 +1770,23 @@ discard block |
||
1770 | 1770 | * @param array $arguments_to_provide |
1771 | 1771 | * @return mixed |
1772 | 1772 | */ |
1773 | - private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) { |
|
1773 | + private function _process_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
1774 | 1774 | /** @type WPDB $wpdb */ |
1775 | 1775 | global $wpdb; |
1776 | 1776 | $wpdb->last_error = null; |
1777 | - $result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide ); |
|
1777 | + $result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide); |
|
1778 | 1778 | // was there an error running the query? |
1779 | - if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) { |
|
1780 | - switch ( EEM_Base::$_db_verification_level ) { |
|
1779 | + if (($result === false || ! empty($wpdb->last_error))) { |
|
1780 | + switch (EEM_Base::$_db_verification_level) { |
|
1781 | 1781 | |
1782 | 1782 | case EEM_Base::db_verified_none : |
1783 | 1783 | // let's double-check core's DB |
1784 | - $error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide ); |
|
1784 | + $error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide); |
|
1785 | 1785 | break; |
1786 | 1786 | |
1787 | 1787 | case EEM_Base::db_verified_core : |
1788 | 1788 | // STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed |
1789 | - $error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide ); |
|
1789 | + $error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide); |
|
1790 | 1790 | break; |
1791 | 1791 | |
1792 | 1792 | case EEM_Base::db_verified_addons : |
@@ -1794,11 +1794,11 @@ discard block |
||
1794 | 1794 | return $result; |
1795 | 1795 | break; |
1796 | 1796 | } |
1797 | - if ( ! empty( $error_message ) ) { |
|
1798 | - EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' ); |
|
1799 | - trigger_error( $error_message ); |
|
1797 | + if ( ! empty($error_message)) { |
|
1798 | + EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error'); |
|
1799 | + trigger_error($error_message); |
|
1800 | 1800 | } |
1801 | - return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
1801 | + return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
1802 | 1802 | |
1803 | 1803 | } |
1804 | 1804 | |
@@ -1814,18 +1814,18 @@ discard block |
||
1814 | 1814 | * @param array $arguments_to_provide |
1815 | 1815 | * @return string |
1816 | 1816 | */ |
1817 | - private function _verify_core_db( $wpdb_method, $arguments_to_provide ){ |
|
1817 | + private function _verify_core_db($wpdb_method, $arguments_to_provide) { |
|
1818 | 1818 | /** @type WPDB $wpdb */ |
1819 | 1819 | global $wpdb; |
1820 | 1820 | //ok remember that we've already attempted fixing the core db, in case the problem persists |
1821 | 1821 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_core; |
1822 | 1822 | $error_message = sprintf( |
1823 | - __( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ), |
|
1823 | + __('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'), |
|
1824 | 1824 | $wpdb->last_error, |
1825 | 1825 | $wpdb_method, |
1826 | - json_encode( $arguments_to_provide ) |
|
1826 | + json_encode($arguments_to_provide) |
|
1827 | 1827 | ); |
1828 | - EE_System::instance()->initialize_db_if_no_migrations_required( false, true ); |
|
1828 | + EE_System::instance()->initialize_db_if_no_migrations_required(false, true); |
|
1829 | 1829 | return $error_message; |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1838,16 +1838,16 @@ discard block |
||
1838 | 1838 | * @param $arguments_to_provide |
1839 | 1839 | * @return string |
1840 | 1840 | */ |
1841 | - private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) { |
|
1841 | + private function _verify_addons_db($wpdb_method, $arguments_to_provide) { |
|
1842 | 1842 | /** @type WPDB $wpdb */ |
1843 | 1843 | global $wpdb; |
1844 | 1844 | //ok remember that we've already attempted fixing the addons dbs, in case the problem persists |
1845 | 1845 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons; |
1846 | 1846 | $error_message = sprintf( |
1847 | - __( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ), |
|
1847 | + __('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'), |
|
1848 | 1848 | $wpdb->last_error, |
1849 | 1849 | $wpdb_method, |
1850 | - json_encode( $arguments_to_provide ) |
|
1850 | + json_encode($arguments_to_provide) |
|
1851 | 1851 | ); |
1852 | 1852 | EE_System::instance()->initialize_addons(); |
1853 | 1853 | return $error_message; |
@@ -1862,7 +1862,7 @@ discard block |
||
1862 | 1862 | * @param EE_Model_Query_Info_Carrier $model_query_info |
1863 | 1863 | * @return string |
1864 | 1864 | */ |
1865 | - private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){ |
|
1865 | + private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) { |
|
1866 | 1866 | return " FROM ".$model_query_info->get_full_join_sql(). |
1867 | 1867 | $model_query_info->get_where_sql(). |
1868 | 1868 | $model_query_info->get_group_by_sql(). |
@@ -1875,7 +1875,7 @@ discard block |
||
1875 | 1875 | * Set to easily debug the next X queries ran from this model. |
1876 | 1876 | * @param int $count |
1877 | 1877 | */ |
1878 | - function show_next_x_db_queries($count = 1){ |
|
1878 | + function show_next_x_db_queries($count = 1) { |
|
1879 | 1879 | $this->_show_next_x_db_queries = $count; |
1880 | 1880 | } |
1881 | 1881 | |
@@ -1884,8 +1884,8 @@ discard block |
||
1884 | 1884 | /** |
1885 | 1885 | * @param $sql_query |
1886 | 1886 | */ |
1887 | - function show_db_query_if_previously_requested($sql_query){ |
|
1888 | - if($this->_show_next_x_db_queries > 0){ |
|
1887 | + function show_db_query_if_previously_requested($sql_query) { |
|
1888 | + if ($this->_show_next_x_db_queries > 0) { |
|
1889 | 1889 | echo $sql_query; |
1890 | 1890 | $this->_show_next_x_db_queries--; |
1891 | 1891 | } |
@@ -1909,7 +1909,7 @@ discard block |
||
1909 | 1909 | * @param array $extra_join_model_fields_n_values This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
1910 | 1910 | * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj |
1911 | 1911 | */ |
1912 | - public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){ |
|
1912 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) { |
|
1913 | 1913 | $relation_obj = $this->related_settings_for($relationName); |
1914 | 1914 | return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
1915 | 1915 | } |
@@ -1930,9 +1930,9 @@ discard block |
||
1930 | 1930 | * @return boolean of success |
1931 | 1931 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
1932 | 1932 | */ |
1933 | - public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query= array() ){ |
|
1933 | + public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) { |
|
1934 | 1934 | $relation_obj = $this->related_settings_for($relationName); |
1935 | - return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query ); |
|
1935 | + return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query); |
|
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | |
@@ -1945,9 +1945,9 @@ discard block |
||
1945 | 1945 | * @param EE_Base_Class[] objects to which relations were removed |
1946 | 1946 | * @return \EE_Base_Class[] |
1947 | 1947 | */ |
1948 | - public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){ |
|
1948 | + public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) { |
|
1949 | 1949 | $relation_obj = $this->related_settings_for($relationName); |
1950 | - return $relation_obj->remove_relations($id_or_obj, $where_query_params ); |
|
1950 | + return $relation_obj->remove_relations($id_or_obj, $where_query_params); |
|
1951 | 1951 | } |
1952 | 1952 | |
1953 | 1953 | |
@@ -1960,10 +1960,10 @@ discard block |
||
1960 | 1960 | * @param array $query_params like EEM_Base::get_all |
1961 | 1961 | * @return EE_Base_Class[] |
1962 | 1962 | */ |
1963 | - function get_all_related($id_or_obj, $model_name, $query_params = null){ |
|
1963 | + function get_all_related($id_or_obj, $model_name, $query_params = null) { |
|
1964 | 1964 | $model_obj = $this->ensure_is_obj($id_or_obj); |
1965 | 1965 | $relation_settings = $this->related_settings_for($model_name); |
1966 | - return $relation_settings->get_all_related($model_obj,$query_params); |
|
1966 | + return $relation_settings->get_all_related($model_obj, $query_params); |
|
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | /** |
@@ -1976,10 +1976,10 @@ discard block |
||
1976 | 1976 | * @param array $query_params |
1977 | 1977 | * @return int how many deleted |
1978 | 1978 | */ |
1979 | - public function delete_related($id_or_obj,$model_name, $query_params = array()){ |
|
1979 | + public function delete_related($id_or_obj, $model_name, $query_params = array()) { |
|
1980 | 1980 | $model_obj = $this->ensure_is_obj($id_or_obj); |
1981 | 1981 | $relation_settings = $this->related_settings_for($model_name); |
1982 | - return $relation_settings->delete_all_related($model_obj,$query_params); |
|
1982 | + return $relation_settings->delete_all_related($model_obj, $query_params); |
|
1983 | 1983 | } |
1984 | 1984 | |
1985 | 1985 | /** |
@@ -1992,10 +1992,10 @@ discard block |
||
1992 | 1992 | * @param array $query_params |
1993 | 1993 | * @return int how many deleted |
1994 | 1994 | */ |
1995 | - public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){ |
|
1995 | + public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) { |
|
1996 | 1996 | $model_obj = $this->ensure_is_obj($id_or_obj); |
1997 | 1997 | $relation_settings = $this->related_settings_for($model_name); |
1998 | - return $relation_settings->delete_related_permanently($model_obj,$query_params); |
|
1998 | + return $relation_settings->delete_related_permanently($model_obj, $query_params); |
|
1999 | 1999 | } |
2000 | 2000 | |
2001 | 2001 | /** |
@@ -2008,17 +2008,17 @@ discard block |
||
2008 | 2008 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
2009 | 2009 | * @return int |
2010 | 2010 | */ |
2011 | - function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){ |
|
2011 | + function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) { |
|
2012 | 2012 | $related_model = $this->get_related_model_obj($model_name); |
2013 | 2013 | //we're just going to use the query params on the related model's normal get_all query, |
2014 | 2014 | //except add a condition to say to match the current mod |
2015 | - if( ! isset($query_params['default_where_conditions'])){ |
|
2016 | - $query_params['default_where_conditions']='none'; |
|
2015 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
2016 | + $query_params['default_where_conditions'] = 'none'; |
|
2017 | 2017 | } |
2018 | 2018 | $this_model_name = $this->get_this_model_name(); |
2019 | 2019 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
2020 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
2021 | - return $related_model->count($query_params,$field_to_count,$distinct); |
|
2020 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
2021 | + return $related_model->count($query_params, $field_to_count, $distinct); |
|
2022 | 2022 | } |
2023 | 2023 | |
2024 | 2024 | |
@@ -2032,21 +2032,21 @@ discard block |
||
2032 | 2032 | * @param string $field_to_sum name of field to count by. By default, uses primary key |
2033 | 2033 | * @return float |
2034 | 2034 | */ |
2035 | - function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){ |
|
2035 | + function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) { |
|
2036 | 2036 | $related_model = $this->get_related_model_obj($model_name); |
2037 | - if( ! is_array( $query_params ) ){ |
|
2038 | - EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
2037 | + if ( ! is_array($query_params)) { |
|
2038 | + EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
2039 | 2039 | $query_params = array(); |
2040 | 2040 | } |
2041 | 2041 | //we're just going to use the query params on the related model's normal get_all query, |
2042 | 2042 | //except add a condition to say to match the current mod |
2043 | - if( ! isset($query_params['default_where_conditions'])){ |
|
2044 | - $query_params['default_where_conditions']='none'; |
|
2043 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
2044 | + $query_params['default_where_conditions'] = 'none'; |
|
2045 | 2045 | } |
2046 | 2046 | $this_model_name = $this->get_this_model_name(); |
2047 | 2047 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
2048 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
2049 | - return $related_model->sum($query_params,$field_to_sum); |
|
2048 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
2049 | + return $related_model->sum($query_params, $field_to_sum); |
|
2050 | 2050 | } |
2051 | 2051 | |
2052 | 2052 | |
@@ -2058,12 +2058,12 @@ discard block |
||
2058 | 2058 | * @param array $query_params like EEM_Base::get_all's |
2059 | 2059 | * @return EE_Base_Class |
2060 | 2060 | */ |
2061 | - public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){ |
|
2062 | - $query_params['limit']=1; |
|
2063 | - $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
|
2064 | - if( $results ){ |
|
2061 | + public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) { |
|
2062 | + $query_params['limit'] = 1; |
|
2063 | + $results = $this->get_all_related($id_or_obj, $other_model_name, $query_params); |
|
2064 | + if ($results) { |
|
2065 | 2065 | return array_shift($results); |
2066 | - }else{ |
|
2066 | + } else { |
|
2067 | 2067 | return null; |
2068 | 2068 | } |
2069 | 2069 | |
@@ -2073,8 +2073,8 @@ discard block |
||
2073 | 2073 | * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event |
2074 | 2074 | * @return string |
2075 | 2075 | */ |
2076 | - function get_this_model_name(){ |
|
2077 | - return str_replace("EEM_","",get_class($this)); |
|
2076 | + function get_this_model_name() { |
|
2077 | + return str_replace("EEM_", "", get_class($this)); |
|
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | /** |
@@ -2082,14 +2082,14 @@ discard block |
||
2082 | 2082 | * @return EE_Any_Foreign_Model_Name_Field |
2083 | 2083 | * @throws EE_Error |
2084 | 2084 | */ |
2085 | - public function get_field_containing_related_model_name(){ |
|
2086 | - foreach($this->field_settings(true) as $field){ |
|
2087 | - if($field instanceof EE_Any_Foreign_Model_Name_Field){ |
|
2085 | + public function get_field_containing_related_model_name() { |
|
2086 | + foreach ($this->field_settings(true) as $field) { |
|
2087 | + if ($field instanceof EE_Any_Foreign_Model_Name_Field) { |
|
2088 | 2088 | $field_with_model_name = $field; |
2089 | 2089 | } |
2090 | 2090 | } |
2091 | - if( !isset($field_with_model_name) || !$field_with_model_name ){ |
|
2092 | - throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() )); |
|
2091 | + if ( ! isset($field_with_model_name) || ! $field_with_model_name) { |
|
2092 | + throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name())); |
|
2093 | 2093 | } |
2094 | 2094 | return $field_with_model_name; |
2095 | 2095 | } |
@@ -2110,19 +2110,19 @@ discard block |
||
2110 | 2110 | * @return int new primary key on main table that got inserted |
2111 | 2111 | * @throws EE_Error |
2112 | 2112 | */ |
2113 | - function insert($field_n_values){ |
|
2113 | + function insert($field_n_values) { |
|
2114 | 2114 | /** |
2115 | 2115 | * Filters the fields and their values before inserting an item using the models |
2116 | 2116 | * @param array $fields_n_values keys are the fields and values are their new values |
2117 | 2117 | * @param EEM_Base $model the model used |
2118 | 2118 | */ |
2119 | - $field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this ); |
|
2120 | - if($this->_satisfies_unique_indexes($field_n_values)){ |
|
2119 | + $field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this); |
|
2120 | + if ($this->_satisfies_unique_indexes($field_n_values)) { |
|
2121 | 2121 | $main_table = $this->_get_main_table(); |
2122 | 2122 | $new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false); |
2123 | - if( $new_id !== false ) { |
|
2124 | - foreach($this->_get_other_tables() as $other_table){ |
|
2125 | - $this->_insert_into_specific_table($other_table, $field_n_values,$new_id); |
|
2123 | + if ($new_id !== false) { |
|
2124 | + foreach ($this->_get_other_tables() as $other_table) { |
|
2125 | + $this->_insert_into_specific_table($other_table, $field_n_values, $new_id); |
|
2126 | 2126 | } |
2127 | 2127 | } |
2128 | 2128 | /** |
@@ -2132,9 +2132,9 @@ discard block |
||
2132 | 2132 | * @param array $fields_n_values fields and their values |
2133 | 2133 | * @param int|string the ID of the newly-inserted model object |
2134 | 2134 | */ |
2135 | - do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
|
2135 | + do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id); |
|
2136 | 2136 | return $new_id; |
2137 | - }else{ |
|
2137 | + } else { |
|
2138 | 2138 | return FALSE; |
2139 | 2139 | } |
2140 | 2140 | } |
@@ -2147,11 +2147,11 @@ discard block |
||
2147 | 2147 | * @param string $action |
2148 | 2148 | * @return boolean |
2149 | 2149 | */ |
2150 | - protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){ |
|
2151 | - foreach($this->unique_indexes() as $index_name => $index){ |
|
2150 | + protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') { |
|
2151 | + foreach ($this->unique_indexes() as $index_name => $index) { |
|
2152 | 2152 | $uniqueness_where_params = array_intersect_key($field_n_values, $index->fields()); |
2153 | - if($this->exists(array($uniqueness_where_params))){ |
|
2154 | - EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ ); |
|
2153 | + if ($this->exists(array($uniqueness_where_params))) { |
|
2154 | + EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__); |
|
2155 | 2155 | return false; |
2156 | 2156 | } |
2157 | 2157 | } |
@@ -2172,28 +2172,28 @@ discard block |
||
2172 | 2172 | * @throws EE_Error |
2173 | 2173 | * @return EE_Base_Class |
2174 | 2174 | */ |
2175 | - public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
|
2176 | - if($obj_or_fields_array instanceof EE_Base_Class){ |
|
2175 | + public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) { |
|
2176 | + if ($obj_or_fields_array instanceof EE_Base_Class) { |
|
2177 | 2177 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
2178 | - }elseif( is_array($obj_or_fields_array)){ |
|
2178 | + }elseif (is_array($obj_or_fields_array)) { |
|
2179 | 2179 | $fields_n_values = $obj_or_fields_array; |
2180 | - }else{ |
|
2181 | - throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array)); |
|
2180 | + } else { |
|
2181 | + throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array)); |
|
2182 | 2182 | } |
2183 | 2183 | $query_params = array(); |
2184 | - if( $this->has_primary_key_field() && |
|
2185 | - ( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
2186 | - isset($fields_n_values[$this->primary_key_name()])){ |
|
2184 | + if ($this->has_primary_key_field() && |
|
2185 | + ($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
2186 | + isset($fields_n_values[$this->primary_key_name()])) { |
|
2187 | 2187 | $query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()]; |
2188 | 2188 | } |
2189 | - foreach($this->unique_indexes() as $unique_index_name=>$unique_index){ |
|
2189 | + foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) { |
|
2190 | 2190 | $uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields()); |
2191 | 2191 | $query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params; |
2192 | 2192 | } |
2193 | 2193 | //if there is nothing to base this search on, then we shouldn't find anything |
2194 | - if( empty( $query_params ) ){ |
|
2194 | + if (empty($query_params)) { |
|
2195 | 2195 | return array(); |
2196 | - }else{ |
|
2196 | + } else { |
|
2197 | 2197 | return $this->get_one($query_params); |
2198 | 2198 | } |
2199 | 2199 | } |
@@ -2203,7 +2203,7 @@ discard block |
||
2203 | 2203 | * @param array $query_params |
2204 | 2204 | * @return boolean |
2205 | 2205 | */ |
2206 | - function exists($query_params){ |
|
2206 | + function exists($query_params) { |
|
2207 | 2207 | $query_params['limit'] = 1; |
2208 | 2208 | return $this->count($query_params) > 0; |
2209 | 2209 | } |
@@ -2213,7 +2213,7 @@ discard block |
||
2213 | 2213 | * @param int|string $id |
2214 | 2214 | * @return boolean |
2215 | 2215 | */ |
2216 | - function exists_by_ID($id){ |
|
2216 | + function exists_by_ID($id) { |
|
2217 | 2217 | return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id))); |
2218 | 2218 | } |
2219 | 2219 | |
@@ -2233,45 +2233,45 @@ discard block |
||
2233 | 2233 | * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert |
2234 | 2234 | * @return int ID of new row inserted, or FALSE on failure |
2235 | 2235 | */ |
2236 | - protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){ |
|
2236 | + protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) { |
|
2237 | 2237 | global $wpdb; |
2238 | 2238 | $insertion_col_n_values = array(); |
2239 | 2239 | $format_for_insertion = array(); |
2240 | 2240 | $fields_on_table = $this->_get_fields_for_table($table->get_table_alias()); |
2241 | - foreach($fields_on_table as $field_name => $field_obj){ |
|
2241 | + foreach ($fields_on_table as $field_name => $field_obj) { |
|
2242 | 2242 | //check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing |
2243 | - if($field_obj->is_auto_increment()){ |
|
2243 | + if ($field_obj->is_auto_increment()) { |
|
2244 | 2244 | continue; |
2245 | 2245 | } |
2246 | 2246 | $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
2247 | 2247 | //if the value we want to assign it to is NULL, just don't mention it for the insertion |
2248 | - if( $prepared_value !== NULL ){ |
|
2249 | - $insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value; |
|
2248 | + if ($prepared_value !== NULL) { |
|
2249 | + $insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value; |
|
2250 | 2250 | $format_for_insertion[] = $field_obj->get_wpdb_data_type(); |
2251 | 2251 | } |
2252 | 2252 | } |
2253 | 2253 | |
2254 | - if($table instanceof EE_Secondary_Table && $new_id){ |
|
2254 | + if ($table instanceof EE_Secondary_Table && $new_id) { |
|
2255 | 2255 | //its not the main table, so we should have already saved the main table's PK which we just inserted |
2256 | 2256 | //so add the fk to the main table as a column |
2257 | 2257 | $insertion_col_n_values[$table->get_fk_on_table()] = $new_id; |
2258 | - $format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs |
|
2258 | + $format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs |
|
2259 | 2259 | } |
2260 | 2260 | //insert the new entry |
2261 | - $result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) ); |
|
2262 | - if( $result === false ) { |
|
2261 | + $result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion)); |
|
2262 | + if ($result === false) { |
|
2263 | 2263 | return false; |
2264 | 2264 | } |
2265 | 2265 | //ok, now what do we return for the ID of the newly-inserted thing? |
2266 | - if($this->has_primary_key_field()){ |
|
2267 | - if($this->get_primary_key_field()->is_auto_increment()){ |
|
2266 | + if ($this->has_primary_key_field()) { |
|
2267 | + if ($this->get_primary_key_field()->is_auto_increment()) { |
|
2268 | 2268 | return $wpdb->insert_id; |
2269 | - }else{ |
|
2269 | + } else { |
|
2270 | 2270 | //it's not an auto-increment primary key, so |
2271 | 2271 | //it must have been supplied |
2272 | 2272 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
2273 | 2273 | } |
2274 | - }else{ |
|
2274 | + } else { |
|
2275 | 2275 | //we can't return a primary key because there is none. instead return |
2276 | 2276 | //a unique string indicating this model |
2277 | 2277 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2286,15 +2286,15 @@ discard block |
||
2286 | 2286 | * @param array $fields_n_values |
2287 | 2287 | * @return mixed string|int|float depending on what the table column will be expecting |
2288 | 2288 | */ |
2289 | - protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){ |
|
2289 | + protected function _prepare_value_or_use_default($field_obj, $fields_n_values) { |
|
2290 | 2290 | //if this field doesn't allow nullable, don't allow it |
2291 | - if( ! $field_obj->is_nullable() && ( |
|
2292 | - ! isset( $fields_n_values[ $field_obj->get_name() ] ) || |
|
2293 | - $fields_n_values[ $field_obj->get_name() ] === NULL ) ){ |
|
2294 | - $fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value(); |
|
2291 | + if ( ! $field_obj->is_nullable() && ( |
|
2292 | + ! isset($fields_n_values[$field_obj->get_name()]) || |
|
2293 | + $fields_n_values[$field_obj->get_name()] === NULL )) { |
|
2294 | + $fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value(); |
|
2295 | 2295 | } |
2296 | - $unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL; |
|
2297 | - return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj); |
|
2296 | + $unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL; |
|
2297 | + return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj); |
|
2298 | 2298 | } |
2299 | 2299 | |
2300 | 2300 | |
@@ -2306,9 +2306,9 @@ discard block |
||
2306 | 2306 | * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection |
2307 | 2307 | * @return mixed a value ready for use in the database for insertions, updating, or in a where clause |
2308 | 2308 | */ |
2309 | - private function _prepare_value_for_use_in_db($value, $field){ |
|
2310 | - if($field && $field instanceof EE_Model_Field_Base){ |
|
2311 | - switch( $this->_values_already_prepared_by_model_object ){ |
|
2309 | + private function _prepare_value_for_use_in_db($value, $field) { |
|
2310 | + if ($field && $field instanceof EE_Model_Field_Base) { |
|
2311 | + switch ($this->_values_already_prepared_by_model_object) { |
|
2312 | 2312 | /** @noinspection PhpMissingBreakStatementInspection */ |
2313 | 2313 | case self::not_prepared_by_model_object: |
2314 | 2314 | $value = $field->prepare_for_set($value); |
@@ -2319,7 +2319,7 @@ discard block |
||
2319 | 2319 | //leave the value alone |
2320 | 2320 | } |
2321 | 2321 | return $value; |
2322 | - }else{ |
|
2322 | + } else { |
|
2323 | 2323 | return $value; |
2324 | 2324 | } |
2325 | 2325 | } |
@@ -2329,13 +2329,13 @@ discard block |
||
2329 | 2329 | * @return EE_Primary_Table |
2330 | 2330 | * @throws EE_Error |
2331 | 2331 | */ |
2332 | - protected function _get_main_table(){ |
|
2333 | - foreach($this->_tables as $table){ |
|
2334 | - if($table instanceof EE_Primary_Table){ |
|
2332 | + protected function _get_main_table() { |
|
2333 | + foreach ($this->_tables as $table) { |
|
2334 | + if ($table instanceof EE_Primary_Table) { |
|
2335 | 2335 | return $table; |
2336 | 2336 | } |
2337 | 2337 | } |
2338 | - throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this))); |
|
2338 | + throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this))); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | /** |
@@ -2354,7 +2354,7 @@ discard block |
||
2354 | 2354 | */ |
2355 | 2355 | public function second_table() { |
2356 | 2356 | // grab second table from tables array |
2357 | - $second_table = end( $this->_tables ); |
|
2357 | + $second_table = end($this->_tables); |
|
2358 | 2358 | return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL; |
2359 | 2359 | } |
2360 | 2360 | |
@@ -2367,8 +2367,8 @@ discard block |
||
2367 | 2367 | * @param string $table_alias |
2368 | 2368 | * @return EE_Primary_Table | EE_Secondary_Table |
2369 | 2369 | */ |
2370 | - public function get_table_obj_by_alias( $table_alias = '' ) { |
|
2371 | - return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL; |
|
2370 | + public function get_table_obj_by_alias($table_alias = '') { |
|
2371 | + return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL; |
|
2372 | 2372 | } |
2373 | 2373 | |
2374 | 2374 | |
@@ -2377,10 +2377,10 @@ discard block |
||
2377 | 2377 | * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables |
2378 | 2378 | * @return EE_Secondary_Table[] |
2379 | 2379 | */ |
2380 | - protected function _get_other_tables(){ |
|
2381 | - $other_tables =array(); |
|
2382 | - foreach($this->_tables as $table_alias => $table){ |
|
2383 | - if($table instanceof EE_Secondary_Table){ |
|
2380 | + protected function _get_other_tables() { |
|
2381 | + $other_tables = array(); |
|
2382 | + foreach ($this->_tables as $table_alias => $table) { |
|
2383 | + if ($table instanceof EE_Secondary_Table) { |
|
2384 | 2384 | $other_tables[$table_alias] = $table; |
2385 | 2385 | } |
2386 | 2386 | } |
@@ -2392,7 +2392,7 @@ discard block |
||
2392 | 2392 | * @param string $table_alias, array key in EEM_Base::_tables |
2393 | 2393 | * @return EE_Model_Field_Base[] |
2394 | 2394 | */ |
2395 | - function _get_fields_for_table($table_alias){ |
|
2395 | + function _get_fields_for_table($table_alias) { |
|
2396 | 2396 | return $this->_fields[$table_alias]; |
2397 | 2397 | } |
2398 | 2398 | |
@@ -2404,29 +2404,29 @@ discard block |
||
2404 | 2404 | * @param array $query_params like EEM_Base::get_all's $query_parameters['where'] |
2405 | 2405 | * @return EE_Model_Query_Info_Carrier |
2406 | 2406 | */ |
2407 | - function _extract_related_models_from_query($query_params){ |
|
2407 | + function _extract_related_models_from_query($query_params) { |
|
2408 | 2408 | $query_info_carrier = new EE_Model_Query_Info_Carrier(); |
2409 | - if(array_key_exists(0,$query_params)){ |
|
2410 | - $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0); |
|
2411 | - } |
|
2412 | - if(array_key_exists('group_by', $query_params)){ |
|
2413 | - if(is_array($query_params['group_by'])){ |
|
2414 | - $this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by'); |
|
2415 | - }elseif( ! empty ( $query_params['group_by'] )){ |
|
2416 | - $this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by'); |
|
2409 | + if (array_key_exists(0, $query_params)) { |
|
2410 | + $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0); |
|
2411 | + } |
|
2412 | + if (array_key_exists('group_by', $query_params)) { |
|
2413 | + if (is_array($query_params['group_by'])) { |
|
2414 | + $this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by'); |
|
2415 | + }elseif ( ! empty ($query_params['group_by'])) { |
|
2416 | + $this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by'); |
|
2417 | 2417 | } |
2418 | 2418 | } |
2419 | - if(array_key_exists('having',$query_params)){ |
|
2420 | - $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having'); |
|
2419 | + if (array_key_exists('having', $query_params)) { |
|
2420 | + $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having'); |
|
2421 | 2421 | } |
2422 | - if(array_key_exists('order_by', $query_params)){ |
|
2423 | - if ( is_array( $query_params['order_by'] ) ) |
|
2424 | - $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by'); |
|
2425 | - elseif( ! empty( $query_params['order_by'] )) |
|
2426 | - $this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by'); |
|
2422 | + if (array_key_exists('order_by', $query_params)) { |
|
2423 | + if (is_array($query_params['order_by'])) |
|
2424 | + $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by'); |
|
2425 | + elseif ( ! empty($query_params['order_by'])) |
|
2426 | + $this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by'); |
|
2427 | 2427 | } |
2428 | - if(array_key_exists('force_join', $query_params)){ |
|
2429 | - $this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join'); |
|
2428 | + if (array_key_exists('force_join', $query_params)) { |
|
2429 | + $this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join'); |
|
2430 | 2430 | } |
2431 | 2431 | return $query_info_carrier; |
2432 | 2432 | } |
@@ -2439,34 +2439,34 @@ discard block |
||
2439 | 2439 | * @throws EE_Error |
2440 | 2440 | * @return \EE_Model_Query_Info_Carrier |
2441 | 2441 | */ |
2442 | - private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
2443 | - if (!empty($sub_query_params)){ |
|
2442 | + private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
2443 | + if ( ! empty($sub_query_params)) { |
|
2444 | 2444 | $sub_query_params = (array) $sub_query_params; |
2445 | - foreach($sub_query_params as $param => $possibly_array_of_params){ |
|
2445 | + foreach ($sub_query_params as $param => $possibly_array_of_params) { |
|
2446 | 2446 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
2447 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type); |
|
2447 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
2448 | 2448 | |
2449 | 2449 | //if $possibly_array_of_params is an array, try recursing into it, searching for keys which |
2450 | 2450 | //indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried |
2451 | 2451 | //extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value |
2452 | 2452 | //of array('Registration.TXN_ID'=>23) |
2453 | 2453 | $query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param); |
2454 | - if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){ |
|
2455 | - if (! is_array($possibly_array_of_params)){ |
|
2454 | + if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) { |
|
2455 | + if ( ! is_array($possibly_array_of_params)) { |
|
2456 | 2456 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
2457 | - $param,$possibly_array_of_params)); |
|
2458 | - }else{ |
|
2459 | - $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
|
2457 | + $param, $possibly_array_of_params)); |
|
2458 | + } else { |
|
2459 | + $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type); |
|
2460 | 2460 | } |
2461 | - }elseif($query_param_type === 0 //ie WHERE |
|
2461 | + }elseif ($query_param_type === 0 //ie WHERE |
|
2462 | 2462 | && is_array($possibly_array_of_params) |
2463 | 2463 | && isset($possibly_array_of_params[2]) |
2464 | - && $possibly_array_of_params[2] == true){ |
|
2464 | + && $possibly_array_of_params[2] == true) { |
|
2465 | 2465 | //then $possible_array_of_params looks something like array('<','DTT_sold',true) |
2466 | 2466 | //indicating that $possible_array_of_params[1] is actually a field name, |
2467 | 2467 | //from which we should extract query parameters! |
2468 | - if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){ |
|
2469 | - throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params))); |
|
2468 | + if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) { |
|
2469 | + throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params))); |
|
2470 | 2470 | } |
2471 | 2471 | $this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type); |
2472 | 2472 | } |
@@ -2485,14 +2485,14 @@ discard block |
||
2485 | 2485 | * @throws EE_Error |
2486 | 2486 | * @return \EE_Model_Query_Info_Carrier |
2487 | 2487 | */ |
2488 | - private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
2489 | - if (!empty($sub_query_params)){ |
|
2490 | - if(!is_array($sub_query_params)){ |
|
2491 | - throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params)); |
|
2488 | + private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
2489 | + if ( ! empty($sub_query_params)) { |
|
2490 | + if ( ! is_array($sub_query_params)) { |
|
2491 | + throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params)); |
|
2492 | 2492 | } |
2493 | - foreach($sub_query_params as $param){ |
|
2493 | + foreach ($sub_query_params as $param) { |
|
2494 | 2494 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
2495 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type); |
|
2495 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
2496 | 2496 | } |
2497 | 2497 | } |
2498 | 2498 | return $model_query_info_carrier; |
@@ -2511,81 +2511,81 @@ discard block |
||
2511 | 2511 | * @throws EE_Error |
2512 | 2512 | * @return EE_Model_Query_Info_Carrier |
2513 | 2513 | */ |
2514 | - function _create_model_query_info_carrier($query_params){ |
|
2515 | - if( ! is_array( $query_params ) ){ |
|
2516 | - EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
2514 | + function _create_model_query_info_carrier($query_params) { |
|
2515 | + if ( ! is_array($query_params)) { |
|
2516 | + EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
2517 | 2517 | $query_params = array(); |
2518 | 2518 | } |
2519 | - if( isset( $query_params[0] ) ) { |
|
2519 | + if (isset($query_params[0])) { |
|
2520 | 2520 | $where_query_params = $query_params[0]; |
2521 | - }else{ |
|
2521 | + } else { |
|
2522 | 2522 | $where_query_params = array(); |
2523 | 2523 | } |
2524 | 2524 | //first check if we should alter the query to account for caps or not |
2525 | 2525 | //because the caps might require us to do extra joins |
2526 | - if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) { |
|
2527 | - $query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) ); |
|
2526 | + if (isset($query_params['caps']) && $query_params['caps'] != 'none') { |
|
2527 | + $query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps'])); |
|
2528 | 2528 | } |
2529 | 2529 | $query_object = $this->_extract_related_models_from_query($query_params); |
2530 | 2530 | |
2531 | 2531 | //verify where_query_params has NO numeric indexes.... that's simply not how you use it! |
2532 | - foreach($where_query_params as $key => $value){ |
|
2533 | - if(is_int($key)){ |
|
2534 | - throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this))); |
|
2532 | + foreach ($where_query_params as $key => $value) { |
|
2533 | + if (is_int($key)) { |
|
2534 | + throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this))); |
|
2535 | 2535 | } |
2536 | 2536 | } |
2537 | - if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){ |
|
2537 | + if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) { |
|
2538 | 2538 | $use_default_where_conditions = $query_params['default_where_conditions']; |
2539 | - }else{ |
|
2539 | + } else { |
|
2540 | 2540 | $use_default_where_conditions = 'all'; |
2541 | 2541 | } |
2542 | - $where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params ); |
|
2543 | - $query_object->set_where_sql( $this->_construct_where_clause($where_query_params)); |
|
2542 | + $where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params); |
|
2543 | + $query_object->set_where_sql($this->_construct_where_clause($where_query_params)); |
|
2544 | 2544 | |
2545 | 2545 | |
2546 | 2546 | //if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join. So we need to setup a subquery and use that for the main join. Note for now this only works on the primary table for the model. So for instance, you could set the limit array like this: |
2547 | 2547 | //array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) ) |
2548 | - if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) { |
|
2549 | - $query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) ); |
|
2548 | + if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) { |
|
2549 | + $query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1])); |
|
2550 | 2550 | } |
2551 | 2551 | |
2552 | 2552 | |
2553 | 2553 | //set limit |
2554 | - if(array_key_exists('limit',$query_params)){ |
|
2555 | - if(is_array($query_params['limit'])){ |
|
2556 | - if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){ |
|
2557 | - $e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit'])); |
|
2554 | + if (array_key_exists('limit', $query_params)) { |
|
2555 | + if (is_array($query_params['limit'])) { |
|
2556 | + if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) { |
|
2557 | + $e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit'])); |
|
2558 | 2558 | throw new EE_Error($e."|".$e); |
2559 | 2559 | } |
2560 | 2560 | //they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25 |
2561 | 2561 | $query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]); |
2562 | - }elseif( ! empty ( $query_params['limit'] )){ |
|
2562 | + }elseif ( ! empty ($query_params['limit'])) { |
|
2563 | 2563 | $query_object->set_limit_sql((" LIMIT ".$query_params['limit'])); |
2564 | 2564 | } |
2565 | 2565 | } |
2566 | 2566 | //set order by |
2567 | - if(array_key_exists('order_by',$query_params)){ |
|
2568 | - if(is_array($query_params['order_by'])){ |
|
2567 | + if (array_key_exists('order_by', $query_params)) { |
|
2568 | + if (is_array($query_params['order_by'])) { |
|
2569 | 2569 | //if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must |
2570 | 2570 | //specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So |
2571 | 2571 | //including 'order' wouldn't make any sense if 'order_by' has already specified which way to order! |
2572 | - if(array_key_exists('order', $query_params)){ |
|
2572 | + if (array_key_exists('order', $query_params)) { |
|
2573 | 2573 | throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"), |
2574 | - get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order'])); |
|
2574 | + get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order'])); |
|
2575 | 2575 | } |
2576 | - $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by'); |
|
2576 | + $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by'); |
|
2577 | 2577 | //assume it's an array of fields to order by |
2578 | 2578 | $order_array = array(); |
2579 | - foreach($query_params['order_by'] as $field_name_to_order_by => $order){ |
|
2579 | + foreach ($query_params['order_by'] as $field_name_to_order_by => $order) { |
|
2580 | 2580 | $order = $this->_extract_order($order); |
2581 | 2581 | $order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order; |
2582 | 2582 | } |
2583 | - $query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array)); |
|
2584 | - }elseif( ! empty ( $query_params['order_by'] )){ |
|
2585 | - $this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']); |
|
2586 | - if(isset($query_params['order'])){ |
|
2583 | + $query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array)); |
|
2584 | + }elseif ( ! empty ($query_params['order_by'])) { |
|
2585 | + $this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']); |
|
2586 | + if (isset($query_params['order'])) { |
|
2587 | 2587 | $order = $this->_extract_order($query_params['order']); |
2588 | - }else{ |
|
2588 | + } else { |
|
2589 | 2589 | $order = 'DESC'; |
2590 | 2590 | } |
2591 | 2591 | $query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order); |
@@ -2593,46 +2593,46 @@ discard block |
||
2593 | 2593 | } |
2594 | 2594 | |
2595 | 2595 | //if 'order_by' wasn't set, maybe they are just using 'order' on its own? |
2596 | - if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){ |
|
2596 | + if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) { |
|
2597 | 2597 | $pk_field = $this->get_primary_key_field(); |
2598 | 2598 | $order = $this->_extract_order($query_params['order']); |
2599 | 2599 | $query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order); |
2600 | 2600 | } |
2601 | 2601 | |
2602 | 2602 | //set group by |
2603 | - if(array_key_exists('group_by',$query_params)){ |
|
2604 | - if(is_array($query_params['group_by'])){ |
|
2603 | + if (array_key_exists('group_by', $query_params)) { |
|
2604 | + if (is_array($query_params['group_by'])) { |
|
2605 | 2605 | //it's an array, so assume we'll be grouping by a bunch of stuff |
2606 | 2606 | $group_by_array = array(); |
2607 | - foreach($query_params['group_by'] as $field_name_to_group_by){ |
|
2607 | + foreach ($query_params['group_by'] as $field_name_to_group_by) { |
|
2608 | 2608 | $group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by); |
2609 | 2609 | } |
2610 | - $query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array)); |
|
2611 | - }elseif( ! empty ( $query_params['group_by'] )){ |
|
2610 | + $query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array)); |
|
2611 | + }elseif ( ! empty ($query_params['group_by'])) { |
|
2612 | 2612 | $query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])); |
2613 | 2613 | } |
2614 | 2614 | } |
2615 | 2615 | //set having |
2616 | - if(array_key_exists('having',$query_params) && $query_params['having']){ |
|
2617 | - $query_object->set_having_sql( $this->_construct_having_clause($query_params['having'])); |
|
2616 | + if (array_key_exists('having', $query_params) && $query_params['having']) { |
|
2617 | + $query_object->set_having_sql($this->_construct_having_clause($query_params['having'])); |
|
2618 | 2618 | } |
2619 | 2619 | |
2620 | 2620 | //now, just verify they didn't pass anything wack |
2621 | - foreach($query_params as $query_key => $query_value){ |
|
2622 | - if( ! in_array($query_key,$this->_allowed_query_params,true)){ |
|
2621 | + foreach ($query_params as $query_key => $query_value) { |
|
2622 | + if ( ! in_array($query_key, $this->_allowed_query_params, true)) { |
|
2623 | 2623 | throw new EE_Error( |
2624 | 2624 | sprintf( |
2625 | - __("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'), |
|
2625 | + __("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'), |
|
2626 | 2626 | $query_key, |
2627 | 2627 | get_class($this), |
2628 | 2628 | // print_r( $this->_allowed_query_params, TRUE ) |
2629 | - implode( ',', $this->_allowed_query_params ) |
|
2629 | + implode(',', $this->_allowed_query_params) |
|
2630 | 2630 | ) |
2631 | 2631 | ); |
2632 | 2632 | } |
2633 | 2633 | } |
2634 | 2634 | $main_model_join_sql = $query_object->get_main_model_join_sql(); |
2635 | - if ( empty( $main_model_join_sql ) ) |
|
2635 | + if (empty($main_model_join_sql)) |
|
2636 | 2636 | $query_object->set_main_model_join_sql($this->_construct_internal_join()); |
2637 | 2637 | return $query_object; |
2638 | 2638 | } |
@@ -2643,17 +2643,17 @@ discard block |
||
2643 | 2643 | * @param string $context one of EEM_Base::valid_cap_contexts() |
2644 | 2644 | * @return array like EEM_Base::get_all() 's $query_params[0] |
2645 | 2645 | */ |
2646 | - public function caps_where_conditions( $context = self::caps_read ) { |
|
2647 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
2646 | + public function caps_where_conditions($context = self::caps_read) { |
|
2647 | + EEM_Base::verify_is_valid_cap_context($context); |
|
2648 | 2648 | $cap_where_conditions = array(); |
2649 | - $cap_restrictions = $this->caps_missing( $context ); |
|
2649 | + $cap_restrictions = $this->caps_missing($context); |
|
2650 | 2650 | /** |
2651 | 2651 | * @var $cap_restrictions EE_Default_Where_Conditions[] |
2652 | 2652 | */ |
2653 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
2654 | - $cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() ); |
|
2653 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
2654 | + $cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions()); |
|
2655 | 2655 | } |
2656 | - return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions ); |
|
2656 | + return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions); |
|
2657 | 2657 | } |
2658 | 2658 | |
2659 | 2659 | /** |
@@ -2663,11 +2663,11 @@ discard block |
||
2663 | 2663 | * @return string either ASC, asc, DESC or desc |
2664 | 2664 | * @throws EE_Error |
2665 | 2665 | */ |
2666 | - private function _extract_order($should_be_order_string){ |
|
2667 | - if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
|
2666 | + private function _extract_order($should_be_order_string) { |
|
2667 | + if (in_array($should_be_order_string, $this->_allowed_order_values)) { |
|
2668 | 2668 | return $should_be_order_string; |
2669 | - }else{ |
|
2670 | - throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
|
2669 | + } else { |
|
2670 | + throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string)); |
|
2671 | 2671 | } |
2672 | 2672 | } |
2673 | 2673 | |
@@ -2685,19 +2685,19 @@ discard block |
||
2685 | 2685 | * @throws EE_Error |
2686 | 2686 | * @return array like $query_params[0], see EEM_Base::get_all for documentation |
2687 | 2687 | */ |
2688 | - private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){ |
|
2689 | - $allowed_used_default_where_conditions_values = array('all','this_model_only', 'other_models_only','none'); |
|
2690 | - if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){ |
|
2691 | - throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values))); |
|
2688 | + private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) { |
|
2689 | + $allowed_used_default_where_conditions_values = array('all', 'this_model_only', 'other_models_only', 'none'); |
|
2690 | + if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) { |
|
2691 | + throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values))); |
|
2692 | 2692 | } |
2693 | - if( in_array($use_default_where_conditions, array('all','this_model_only')) ){ |
|
2693 | + if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) { |
|
2694 | 2694 | $universal_query_params = $this->_get_default_where_conditions(); |
2695 | - }else{ |
|
2695 | + } else { |
|
2696 | 2696 | $universal_query_params = array(); |
2697 | 2697 | } |
2698 | 2698 | |
2699 | - if(in_array($use_default_where_conditions,array('all','other_models_only'))){ |
|
2700 | - foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){ |
|
2699 | + if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) { |
|
2700 | + foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) { |
|
2701 | 2701 | $related_model = $this->get_related_model_obj($model_name); |
2702 | 2702 | $related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path); |
2703 | 2703 | |
@@ -2724,22 +2724,22 @@ discard block |
||
2724 | 2724 | * @param string $model_relation_path like 'Transaction.Payment.' |
2725 | 2725 | * @return array like EEM_Base::get_all's $query_params[0] |
2726 | 2726 | */ |
2727 | - private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){ |
|
2727 | + private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) { |
|
2728 | 2728 | $null_friendly_where_conditions = array(); |
2729 | 2729 | $none_overridden = true; |
2730 | 2730 | $or_condition_key_for_defaults = 'OR*'.get_class($model); |
2731 | 2731 | |
2732 | - foreach($default_where_conditions as $key => $val){ |
|
2733 | - if( isset($provided_where_conditions[$key])){ |
|
2732 | + foreach ($default_where_conditions as $key => $val) { |
|
2733 | + if (isset($provided_where_conditions[$key])) { |
|
2734 | 2734 | $none_overridden = false; |
2735 | - }else{ |
|
2735 | + } else { |
|
2736 | 2736 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
2737 | 2737 | } |
2738 | 2738 | } |
2739 | - if( $none_overridden && $default_where_conditions){ |
|
2740 | - if($model->has_primary_key_field()){ |
|
2739 | + if ($none_overridden && $default_where_conditions) { |
|
2740 | + if ($model->has_primary_key_field()) { |
|
2741 | 2741 | $null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL'); |
2742 | - }else{ |
|
2742 | + } else { |
|
2743 | 2743 | //@todo NO PK, use other defaults |
2744 | 2744 | } |
2745 | 2745 | } |
@@ -2754,8 +2754,8 @@ discard block |
||
2754 | 2754 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
2755 | 2755 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
2756 | 2756 | */ |
2757 | - private function _get_default_where_conditions($model_relation_path = null){ |
|
2758 | - if ( $this->_ignore_where_strategy ) |
|
2757 | + private function _get_default_where_conditions($model_relation_path = null) { |
|
2758 | + if ($this->_ignore_where_strategy) |
|
2759 | 2759 | return array(); |
2760 | 2760 | |
2761 | 2761 | return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -2766,13 +2766,13 @@ discard block |
||
2766 | 2766 | * @param EE_Model_Query_Info_Carrier $model_query_info |
2767 | 2767 | * @return string |
2768 | 2768 | */ |
2769 | - private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){ |
|
2769 | + private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) { |
|
2770 | 2770 | $selects = $this->_get_columns_to_select_for_this_model(); |
2771 | - foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){ |
|
2771 | + foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) { |
|
2772 | 2772 | $other_model_included = $this->get_related_model_obj($name_of_other_model_included); |
2773 | 2773 | $selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain)); |
2774 | 2774 | } |
2775 | - return implode(", ",$selects); |
|
2775 | + return implode(", ", $selects); |
|
2776 | 2776 | } |
2777 | 2777 | |
2778 | 2778 | /** |
@@ -2781,19 +2781,19 @@ discard block |
||
2781 | 2781 | * @param string $model_relation_chain like 'Question.Question_Group.Event' |
2782 | 2782 | * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'" |
2783 | 2783 | */ |
2784 | - public function _get_columns_to_select_for_this_model($model_relation_chain = ''){ |
|
2784 | + public function _get_columns_to_select_for_this_model($model_relation_chain = '') { |
|
2785 | 2785 | $fields = $this->field_settings(); |
2786 | 2786 | $selects = array(); |
2787 | 2787 | $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name()); |
2788 | - foreach($fields as $field_obj){ |
|
2789 | - $selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
2788 | + foreach ($fields as $field_obj) { |
|
2789 | + $selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
2790 | 2790 | } |
2791 | 2791 | //make sure we are also getting the PKs of each table |
2792 | 2792 | $tables = $this->get_tables(); |
2793 | - if(count($tables) > 1){ |
|
2794 | - foreach($tables as $table_obj){ |
|
2795 | - $qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column(); |
|
2796 | - if( ! in_array($qualified_pk_column,$selects)){ |
|
2793 | + if (count($tables) > 1) { |
|
2794 | + foreach ($tables as $table_obj) { |
|
2795 | + $qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column(); |
|
2796 | + if ( ! in_array($qualified_pk_column, $selects)) { |
|
2797 | 2797 | $selects[] = "$qualified_pk_column AS '$qualified_pk_column'"; |
2798 | 2798 | } |
2799 | 2799 | } |
@@ -2817,66 +2817,66 @@ discard block |
||
2817 | 2817 | * @throws EE_Error |
2818 | 2818 | * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it |
2819 | 2819 | */ |
2820 | - private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){ |
|
2821 | - if($original_query_param == NULL){ |
|
2820 | + private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) { |
|
2821 | + if ($original_query_param == NULL) { |
|
2822 | 2822 | $original_query_param = $query_param; |
2823 | 2823 | } |
2824 | 2824 | $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); |
2825 | 2825 | /** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */ |
2826 | - $allow_logic_query_params = in_array($query_param_type,array('where','having')); |
|
2827 | - $allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order')); |
|
2826 | + $allow_logic_query_params = in_array($query_param_type, array('where', 'having')); |
|
2827 | + $allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order')); |
|
2828 | 2828 | //check to see if we have a field on this model |
2829 | 2829 | $this_model_fields = $this->field_settings(true); |
2830 | - if(array_key_exists($query_param,$this_model_fields)){ |
|
2831 | - if($allow_fields){ |
|
2830 | + if (array_key_exists($query_param, $this_model_fields)) { |
|
2831 | + if ($allow_fields) { |
|
2832 | 2832 | return; |
2833 | - }else{ |
|
2833 | + } else { |
|
2834 | 2834 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
2835 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
2835 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
2836 | 2836 | } |
2837 | 2837 | } |
2838 | 2838 | //check if this is a special logic query param |
2839 | - elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
|
2840 | - if($allow_logic_query_params){ |
|
2839 | + elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) { |
|
2840 | + if ($allow_logic_query_params) { |
|
2841 | 2841 | return; |
2842 | - }else{ |
|
2842 | + } else { |
|
2843 | 2843 | throw new EE_Error( |
2844 | 2844 | sprintf( |
2845 | - __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
|
2846 | - implode( '", "', $this->_logic_query_param_keys ), |
|
2847 | - $query_param , |
|
2848 | - get_class( $this ), |
|
2845 | + __('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'), |
|
2846 | + implode('", "', $this->_logic_query_param_keys), |
|
2847 | + $query_param, |
|
2848 | + get_class($this), |
|
2849 | 2849 | '<br />', |
2850 | - "\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param |
|
2850 | + "\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param |
|
2851 | 2851 | ) |
2852 | 2852 | ); |
2853 | 2853 | } |
2854 | 2854 | } |
2855 | 2855 | |
2856 | 2856 | //check if it's a custom selection |
2857 | - elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
2857 | + elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
2858 | 2858 | return; |
2859 | 2859 | } |
2860 | 2860 | |
2861 | 2861 | //check if has a model name at the beginning |
2862 | 2862 | //and |
2863 | 2863 | //check if it's a field on a related model |
2864 | - foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){ |
|
2865 | - if(strpos($query_param, $valid_related_model_name.".") === 0){ |
|
2866 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
2864 | + foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) { |
|
2865 | + if (strpos($query_param, $valid_related_model_name.".") === 0) { |
|
2866 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
2867 | 2867 | $query_param = substr($query_param, strlen($valid_related_model_name.".")); |
2868 | - if($query_param == ''){ |
|
2868 | + if ($query_param == '') { |
|
2869 | 2869 | //nothing left to $query_param |
2870 | 2870 | //we should actually end in a field name, not a model like this! |
2871 | 2871 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
2872 | - $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
|
2873 | - }else{ |
|
2872 | + $query_param, $query_param_type, get_class($this), $valid_related_model_name)); |
|
2873 | + } else { |
|
2874 | 2874 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
2875 | 2875 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
2876 | 2876 | return; |
2877 | 2877 | } |
2878 | - }elseif($query_param == $valid_related_model_name){ |
|
2879 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
2878 | + }elseif ($query_param == $valid_related_model_name) { |
|
2879 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
2880 | 2880 | return; |
2881 | 2881 | } |
2882 | 2882 | } |
@@ -2886,7 +2886,7 @@ discard block |
||
2886 | 2886 | //and we previously confirmed it wasn't a logic query param or field on the current model |
2887 | 2887 | //it's wack, that's what it is |
2888 | 2888 | throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"), |
2889 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
2889 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
2890 | 2890 | |
2891 | 2891 | } |
2892 | 2892 | |
@@ -2903,26 +2903,26 @@ discard block |
||
2903 | 2903 | * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table) |
2904 | 2904 | * @return void |
2905 | 2905 | */ |
2906 | - private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){ |
|
2906 | + private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) { |
|
2907 | 2907 | $relation_obj = $this->related_settings_for($model_name); |
2908 | 2908 | |
2909 | 2909 | $model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param); |
2910 | 2910 | //check if the relation is HABTM, because then we're essentially doing two joins |
2911 | 2911 | //If so, join first to the JOIN table, and add its data types, and then continue as normal |
2912 | - if($relation_obj instanceof EE_HABTM_Relation){ |
|
2912 | + if ($relation_obj instanceof EE_HABTM_Relation) { |
|
2913 | 2913 | $join_model_obj = $relation_obj->get_join_model(); |
2914 | 2914 | //replace the model specified with the join model for this relation chain, whi |
2915 | 2915 | $relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain); |
2916 | 2916 | $new_query_info = new EE_Model_Query_Info_Carrier( |
2917 | 2917 | array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()), |
2918 | 2918 | $relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model)); |
2919 | - $passed_in_query_info->merge( $new_query_info ); |
|
2919 | + $passed_in_query_info->merge($new_query_info); |
|
2920 | 2920 | } |
2921 | 2921 | //now just join to the other table pointed to by the relation object, and add its data types |
2922 | 2922 | $new_query_info = new EE_Model_Query_Info_Carrier( |
2923 | 2923 | array($model_relation_chain=>$model_name), |
2924 | 2924 | $relation_obj->get_join_statement($model_relation_chain)); |
2925 | - $passed_in_query_info->merge( $new_query_info ); |
|
2925 | + $passed_in_query_info->merge($new_query_info); |
|
2926 | 2926 | } |
2927 | 2927 | |
2928 | 2928 | |
@@ -2931,11 +2931,11 @@ discard block |
||
2931 | 2931 | * @param array $where_params like EEM_Base::get_all |
2932 | 2932 | * @return string of SQL |
2933 | 2933 | */ |
2934 | - private function _construct_where_clause($where_params){ |
|
2934 | + private function _construct_where_clause($where_params) { |
|
2935 | 2935 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
2936 | - if($SQL){ |
|
2937 | - return " WHERE ". $SQL; |
|
2938 | - }else{ |
|
2936 | + if ($SQL) { |
|
2937 | + return " WHERE ".$SQL; |
|
2938 | + } else { |
|
2939 | 2939 | return ''; |
2940 | 2940 | } |
2941 | 2941 | } |
@@ -2946,11 +2946,11 @@ discard block |
||
2946 | 2946 | * @param array $having_params |
2947 | 2947 | * @return string |
2948 | 2948 | */ |
2949 | - private function _construct_having_clause($having_params){ |
|
2949 | + private function _construct_having_clause($having_params) { |
|
2950 | 2950 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
2951 | - if($SQL){ |
|
2952 | - return " HAVING ". $SQL; |
|
2953 | - }else{ |
|
2951 | + if ($SQL) { |
|
2952 | + return " HAVING ".$SQL; |
|
2953 | + } else { |
|
2954 | 2954 | return ''; |
2955 | 2955 | } |
2956 | 2956 | |
@@ -2964,17 +2964,17 @@ discard block |
||
2964 | 2964 | * @return EE_Model_Field_Base |
2965 | 2965 | * @throws EE_Error |
2966 | 2966 | */ |
2967 | - protected function _get_field_on_model($field_name,$model_name){ |
|
2967 | + protected function _get_field_on_model($field_name, $model_name) { |
|
2968 | 2968 | $model_class = 'EEM_'.$model_name; |
2969 | 2969 | $model_filepath = $model_class.".model.php"; |
2970 | - EE_Registry::instance()->load_helper( 'File' ); |
|
2971 | - if ( is_readable($model_filepath)){ |
|
2970 | + EE_Registry::instance()->load_helper('File'); |
|
2971 | + if (is_readable($model_filepath)) { |
|
2972 | 2972 | require_once($model_filepath); |
2973 | - $model_instance=call_user_func($model_name."::instance"); |
|
2973 | + $model_instance = call_user_func($model_name."::instance"); |
|
2974 | 2974 | /* @var $model_instance EEM_Base */ |
2975 | 2975 | return $model_instance->field_settings_for($field_name); |
2976 | - }else{ |
|
2977 | - throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
|
2976 | + } else { |
|
2977 | + throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath)); |
|
2978 | 2978 | } |
2979 | 2979 | } |
2980 | 2980 | |
@@ -2987,43 +2987,43 @@ discard block |
||
2987 | 2987 | * @throws EE_Error |
2988 | 2988 | * @return string of SQL |
2989 | 2989 | */ |
2990 | - private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){ |
|
2991 | - $where_clauses=array(); |
|
2992 | - foreach($where_params as $query_param => $op_and_value_or_sub_condition){ |
|
2993 | - $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param); |
|
2994 | - if(in_array($query_param,$this->_logic_query_param_keys)){ |
|
2995 | - switch($query_param){ |
|
2990 | + private function _construct_condition_clause_recursive($where_params, $glue = ' AND') { |
|
2991 | + $where_clauses = array(); |
|
2992 | + foreach ($where_params as $query_param => $op_and_value_or_sub_condition) { |
|
2993 | + $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param); |
|
2994 | + if (in_array($query_param, $this->_logic_query_param_keys)) { |
|
2995 | + switch ($query_param) { |
|
2996 | 2996 | case 'not': |
2997 | 2997 | case 'NOT': |
2998 | - $where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
2998 | + $where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
2999 | 2999 | break; |
3000 | 3000 | case 'and': |
3001 | 3001 | case 'AND': |
3002 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")"; |
|
3002 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")"; |
|
3003 | 3003 | break; |
3004 | 3004 | case 'or': |
3005 | 3005 | case 'OR': |
3006 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
|
3006 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")"; |
|
3007 | 3007 | break; |
3008 | 3008 | } |
3009 | - }else{ |
|
3009 | + } else { |
|
3010 | 3010 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
3011 | 3011 | |
3012 | 3012 | //if it's not a normal field, maybe it's a custom selection? |
3013 | - if( ! $field_obj){ |
|
3014 | - if(isset( $this->_custom_selections[$query_param][1])){ |
|
3013 | + if ( ! $field_obj) { |
|
3014 | + if (isset($this->_custom_selections[$query_param][1])) { |
|
3015 | 3015 | $field_obj = $this->_custom_selections[$query_param][1]; |
3016 | - }else{ |
|
3017 | - throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
|
3016 | + } else { |
|
3017 | + throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param)); |
|
3018 | 3018 | } |
3019 | 3019 | } |
3020 | 3020 | $op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj); |
3021 | - $where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
3021 | + $where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
3022 | 3022 | } |
3023 | 3023 | } |
3024 | - if($where_clauses){ |
|
3025 | - $SQL = implode($glue,$where_clauses); |
|
3026 | - }else{ |
|
3024 | + if ($where_clauses) { |
|
3025 | + $SQL = implode($glue, $where_clauses); |
|
3026 | + } else { |
|
3027 | 3027 | $SQL = ''; |
3028 | 3028 | } |
3029 | 3029 | return $SQL; |
@@ -3037,18 +3037,18 @@ discard block |
||
3037 | 3037 | * @throws EE_Error |
3038 | 3038 | * @return string table alias and column name for SQL, eg "Transaction.TXN_ID" |
3039 | 3039 | */ |
3040 | - private function _deduce_column_name_from_query_param($query_param){ |
|
3040 | + private function _deduce_column_name_from_query_param($query_param) { |
|
3041 | 3041 | $field = $this->_deduce_field_from_query_param($query_param); |
3042 | 3042 | |
3043 | - if( $field ){ |
|
3044 | - $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
|
3045 | - return $table_alias_prefix . $field->get_qualified_column(); |
|
3046 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3043 | + if ($field) { |
|
3044 | + $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param); |
|
3045 | + return $table_alias_prefix.$field->get_qualified_column(); |
|
3046 | + }elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
3047 | 3047 | //maybe it's custom selection item? |
3048 | 3048 | //if so, just use it as the "column name" |
3049 | 3049 | return $query_param; |
3050 | - }else{ |
|
3051 | - throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
|
3050 | + } else { |
|
3051 | + throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections))); |
|
3052 | 3052 | } |
3053 | 3053 | } |
3054 | 3054 | |
@@ -3060,11 +3060,11 @@ discard block |
||
3060 | 3060 | * @param string $condition_query_param_key |
3061 | 3061 | * @return string |
3062 | 3062 | */ |
3063 | - private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){ |
|
3063 | + private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
3064 | 3064 | $pos_of_star = strpos($condition_query_param_key, '*'); |
3065 | - if($pos_of_star === FALSE){ |
|
3065 | + if ($pos_of_star === FALSE) { |
|
3066 | 3066 | return $condition_query_param_key; |
3067 | - }else{ |
|
3067 | + } else { |
|
3068 | 3068 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
3069 | 3069 | return $condition_query_param_sans_star; |
3070 | 3070 | } |
@@ -3079,54 +3079,54 @@ discard block |
||
3079 | 3079 | * @throws EE_Error |
3080 | 3080 | * @return string |
3081 | 3081 | */ |
3082 | - private function _construct_op_and_value($op_and_value, $field_obj){ |
|
3083 | - if(is_array( $op_and_value )){ |
|
3082 | + private function _construct_op_and_value($op_and_value, $field_obj) { |
|
3083 | + if (is_array($op_and_value)) { |
|
3084 | 3084 | $operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null; |
3085 | - if( ! $operator){ |
|
3085 | + if ( ! $operator) { |
|
3086 | 3086 | $php_array_like_string = array(); |
3087 | - foreach($op_and_value as $key => $value){ |
|
3087 | + foreach ($op_and_value as $key => $value) { |
|
3088 | 3088 | $php_array_like_string[] = "$key=>$value"; |
3089 | 3089 | } |
3090 | - throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string))); |
|
3090 | + throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string))); |
|
3091 | 3091 | } |
3092 | 3092 | $value = isset($op_and_value[1]) ? $op_and_value[1] : null; |
3093 | - }else{ |
|
3093 | + } else { |
|
3094 | 3094 | $operator = '='; |
3095 | 3095 | $value = $op_and_value; |
3096 | 3096 | } |
3097 | 3097 | |
3098 | 3098 | //check to see if the value is actually another field |
3099 | - if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){ |
|
3099 | + if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) { |
|
3100 | 3100 | return $operator.SP.$this->_deduce_column_name_from_query_param($value); |
3101 | - }elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3101 | + }elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
3102 | 3102 | //in this case, the value should be an array, or at least a comma-separated list |
3103 | 3103 | //it will need to handle a little differently |
3104 | 3104 | $cleaned_value = $this->_construct_in_value($value, $field_obj); |
3105 | 3105 | //note: $cleaned_value has already been run through $wpdb->prepare() |
3106 | 3106 | return $operator.SP.$cleaned_value; |
3107 | - } elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) { |
|
3107 | + } elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) { |
|
3108 | 3108 | //the value should be an array with count of two. |
3109 | - if ( count($value) !== 2 ) |
|
3110 | - throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) ); |
|
3111 | - $cleaned_value = $this->_construct_between_value( $value, $field_obj ); |
|
3109 | + if (count($value) !== 2) |
|
3110 | + throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN")); |
|
3111 | + $cleaned_value = $this->_construct_between_value($value, $field_obj); |
|
3112 | 3112 | return $operator.SP.$cleaned_value; |
3113 | - } elseif( in_array( $operator, $this->_null_style_operators ) ) { |
|
3114 | - if($value != NULL){ |
|
3115 | - throw new EE_Error(sprintf(__("You attempted to give a value (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator)); |
|
3113 | + } elseif (in_array($operator, $this->_null_style_operators)) { |
|
3114 | + if ($value != NULL) { |
|
3115 | + throw new EE_Error(sprintf(__("You attempted to give a value (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator)); |
|
3116 | 3116 | } |
3117 | 3117 | return $operator; |
3118 | - }elseif( $operator == 'LIKE' && ! is_array($value)){ |
|
3118 | + }elseif ($operator == 'LIKE' && ! is_array($value)) { |
|
3119 | 3119 | //if the operator is 'LIKE', we want to allow percent signs (%) and not |
3120 | 3120 | //remove other junk. So just treat it as a string. |
3121 | 3121 | return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s'); |
3122 | - }elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3123 | - return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj); |
|
3124 | - }elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3125 | - throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator)); |
|
3126 | - }elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3127 | - throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator)); |
|
3128 | - }else{ |
|
3129 | - throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value))); |
|
3122 | + }elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
3123 | + return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj); |
|
3124 | + }elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
3125 | + throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator)); |
|
3126 | + }elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
3127 | + throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator)); |
|
3128 | + } else { |
|
3129 | + throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value))); |
|
3130 | 3130 | } |
3131 | 3131 | } |
3132 | 3132 | |
@@ -3138,12 +3138,12 @@ discard block |
||
3138 | 3138 | * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s' |
3139 | 3139 | * @return string |
3140 | 3140 | */ |
3141 | - function _construct_between_value( $values, $field_obj ) { |
|
3141 | + function _construct_between_value($values, $field_obj) { |
|
3142 | 3142 | $cleaned_values = array(); |
3143 | - foreach ( $values as $value ) { |
|
3144 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
3143 | + foreach ($values as $value) { |
|
3144 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
3145 | 3145 | } |
3146 | - return $cleaned_values[0] . " AND " . $cleaned_values[1]; |
|
3146 | + return $cleaned_values[0]." AND ".$cleaned_values[1]; |
|
3147 | 3147 | } |
3148 | 3148 | |
3149 | 3149 | |
@@ -3159,26 +3159,26 @@ discard block |
||
3159 | 3159 | * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d' |
3160 | 3160 | * @return string of SQL to follow an 'IN' or 'NOT IN' operator |
3161 | 3161 | */ |
3162 | - function _construct_in_value($values, $field_obj){ |
|
3162 | + function _construct_in_value($values, $field_obj) { |
|
3163 | 3163 | //check if the value is a CSV list |
3164 | - if(is_string($values)){ |
|
3164 | + if (is_string($values)) { |
|
3165 | 3165 | //in which case, turn it into an array |
3166 | - $values = explode(",",$values); |
|
3166 | + $values = explode(",", $values); |
|
3167 | 3167 | } |
3168 | 3168 | $cleaned_values = array(); |
3169 | - foreach($values as $value){ |
|
3170 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
3169 | + foreach ($values as $value) { |
|
3170 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
3171 | 3171 | } |
3172 | 3172 | //we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()", |
3173 | 3173 | //but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set |
3174 | 3174 | //which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns |
3175 | - if(empty($cleaned_values)){ |
|
3175 | + if (empty($cleaned_values)) { |
|
3176 | 3176 | $all_fields = $this->field_settings(); |
3177 | 3177 | $a_field = array_shift($all_fields); |
3178 | 3178 | $main_table = $this->_get_main_table(); |
3179 | 3179 | $cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE"; |
3180 | 3180 | } |
3181 | - return "(".implode(",",$cleaned_values).")"; |
|
3181 | + return "(".implode(",", $cleaned_values).")"; |
|
3182 | 3182 | } |
3183 | 3183 | |
3184 | 3184 | |
@@ -3190,16 +3190,16 @@ discard block |
||
3190 | 3190 | * @throws EE_Error |
3191 | 3191 | * @return false|null|string |
3192 | 3192 | */ |
3193 | - private function _wpdb_prepare_using_field($value,$field_obj){ |
|
3193 | + private function _wpdb_prepare_using_field($value, $field_obj) { |
|
3194 | 3194 | /** @type WPDB $wpdb */ |
3195 | 3195 | global $wpdb; |
3196 | - if($field_obj instanceof EE_Model_Field_Base){ |
|
3197 | - return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
3198 | - }else{//$field_obj should really just be a data type |
|
3199 | - if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
|
3200 | - throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
|
3196 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
3197 | + return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
3198 | + } else {//$field_obj should really just be a data type |
|
3199 | + if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) { |
|
3200 | + throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types))); |
|
3201 | 3201 | } |
3202 | - return $wpdb->prepare($field_obj,$value); |
|
3202 | + return $wpdb->prepare($field_obj, $value); |
|
3203 | 3203 | } |
3204 | 3204 | } |
3205 | 3205 | |
@@ -3211,27 +3211,27 @@ discard block |
||
3211 | 3211 | * @throws EE_Error |
3212 | 3212 | * @return EE_Model_Field_Base |
3213 | 3213 | */ |
3214 | - protected function _deduce_field_from_query_param($query_param_name){ |
|
3214 | + protected function _deduce_field_from_query_param($query_param_name) { |
|
3215 | 3215 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
3216 | 3216 | //which will help us find the database table and column |
3217 | 3217 | |
3218 | - $query_param_parts = explode(".",$query_param_name); |
|
3219 | - if(empty($query_param_parts)){ |
|
3220 | - throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
3218 | + $query_param_parts = explode(".", $query_param_name); |
|
3219 | + if (empty($query_param_parts)) { |
|
3220 | + throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
3221 | 3221 | } |
3222 | 3222 | $number_of_parts = count($query_param_parts); |
3223 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
3224 | - if($number_of_parts == 1){ |
|
3223 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
3224 | + if ($number_of_parts == 1) { |
|
3225 | 3225 | $field_name = $last_query_param_part; |
3226 | 3226 | $model_obj = $this; |
3227 | - }else{// $number_of_parts >= 2 |
|
3227 | + } else {// $number_of_parts >= 2 |
|
3228 | 3228 | //the last part is the column name, and there are only 2parts. therefore... |
3229 | 3229 | $field_name = $last_query_param_part; |
3230 | - $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
|
3230 | + $model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]); |
|
3231 | 3231 | } |
3232 | - try{ |
|
3232 | + try { |
|
3233 | 3233 | return $model_obj->field_settings_for($field_name); |
3234 | - }catch(EE_Error $e){ |
|
3234 | + } catch (EE_Error $e) { |
|
3235 | 3235 | return null; |
3236 | 3236 | } |
3237 | 3237 | } |
@@ -3245,13 +3245,13 @@ discard block |
||
3245 | 3245 | * @throws EE_Error |
3246 | 3246 | * @return string |
3247 | 3247 | */ |
3248 | - function _get_qualified_column_for_field($field_name){ |
|
3248 | + function _get_qualified_column_for_field($field_name) { |
|
3249 | 3249 | $all_fields = $this->field_settings(); |
3250 | 3250 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
3251 | - if($field){ |
|
3251 | + if ($field) { |
|
3252 | 3252 | return $field->get_qualified_column(); |
3253 | - }else{ |
|
3254 | - throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
|
3253 | + } else { |
|
3254 | + throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this))); |
|
3255 | 3255 | } |
3256 | 3256 | } |
3257 | 3257 | |
@@ -3265,14 +3265,14 @@ discard block |
||
3265 | 3265 | * @param mixed|string $limit The limit for this select |
3266 | 3266 | * @return string The final select join element for the query. |
3267 | 3267 | */ |
3268 | - function _construct_limit_join_select( $table_alias, $limit ) { |
|
3268 | + function _construct_limit_join_select($table_alias, $limit) { |
|
3269 | 3269 | $SQL = ''; |
3270 | 3270 | |
3271 | - foreach ( $this->_tables as $table_obj ) { |
|
3272 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
3273 | - $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP; |
|
3274 | - } elseif ( $table_obj instanceof EE_Secondary_Table ) { |
|
3275 | - $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP; |
|
3271 | + foreach ($this->_tables as $table_obj) { |
|
3272 | + if ($table_obj instanceof EE_Primary_Table) { |
|
3273 | + $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP; |
|
3274 | + } elseif ($table_obj instanceof EE_Secondary_Table) { |
|
3275 | + $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP; |
|
3276 | 3276 | } |
3277 | 3277 | } |
3278 | 3278 | return $SQL; |
@@ -3285,7 +3285,7 @@ discard block |
||
3285 | 3285 | * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id" |
3286 | 3286 | * @return string SQL |
3287 | 3287 | */ |
3288 | - function _construct_internal_join(){ |
|
3288 | + function _construct_internal_join() { |
|
3289 | 3289 | $SQL = $this->_get_main_table()->get_table_sql(); |
3290 | 3290 | $SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias()); |
3291 | 3291 | return $SQL; |
@@ -3306,17 +3306,17 @@ discard block |
||
3306 | 3306 | * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause) |
3307 | 3307 | * @return string |
3308 | 3308 | */ |
3309 | - function _construct_internal_join_to_table_with_alias($alias_prefixed){ |
|
3309 | + function _construct_internal_join_to_table_with_alias($alias_prefixed) { |
|
3310 | 3310 | $SQL = ''; |
3311 | 3311 | $alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed); |
3312 | - foreach($this->_tables as $table_obj){ |
|
3313 | - if($table_obj instanceof EE_Secondary_Table){//table is secondary table |
|
3314 | - if($alias_sans_prefix == $table_obj->get_table_alias()){ |
|
3312 | + foreach ($this->_tables as $table_obj) { |
|
3313 | + if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table |
|
3314 | + if ($alias_sans_prefix == $table_obj->get_table_alias()) { |
|
3315 | 3315 | //so we're joining to this table, meaning the table is already in |
3316 | 3316 | //the FROM statement, BUT the primary table isn't. So we want |
3317 | 3317 | //to add the inverse join sql |
3318 | 3318 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
3319 | - }else{ |
|
3319 | + } else { |
|
3320 | 3320 | //just add a regular JOIN to this table from the primary table |
3321 | 3321 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
3322 | 3322 | } |
@@ -3330,9 +3330,9 @@ discard block |
||
3330 | 3330 | * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc) |
3331 | 3331 | * @return array |
3332 | 3332 | */ |
3333 | - function _get_data_types(){ |
|
3333 | + function _get_data_types() { |
|
3334 | 3334 | $data_types = array(); |
3335 | - foreach(array_values($this->field_settings()) as $field_obj){ |
|
3335 | + foreach (array_values($this->field_settings()) as $field_obj) { |
|
3336 | 3336 | //$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type(); |
3337 | 3337 | /** @var $field_obj EE_Model_Field_Base */ |
3338 | 3338 | $data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type(); |
@@ -3348,11 +3348,11 @@ discard block |
||
3348 | 3348 | * @throws EE_Error |
3349 | 3349 | * @return EEM_Base |
3350 | 3350 | */ |
3351 | - function get_related_model_obj($model_name){ |
|
3351 | + function get_related_model_obj($model_name) { |
|
3352 | 3352 | |
3353 | 3353 | $model_classname = "EEM_".$model_name; |
3354 | - if(!class_exists($model_classname)){ |
|
3355 | - throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname)); |
|
3354 | + if ( ! class_exists($model_classname)) { |
|
3355 | + throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname)); |
|
3356 | 3356 | } |
3357 | 3357 | $model_obj = call_user_func($model_classname."::instance"); |
3358 | 3358 | return $model_obj; |
@@ -3363,7 +3363,7 @@ discard block |
||
3363 | 3363 | * Returns the array of EE_ModelRelations for this model. |
3364 | 3364 | * @return EE_Model_Relation_Base[] |
3365 | 3365 | */ |
3366 | - public function relation_settings(){ |
|
3366 | + public function relation_settings() { |
|
3367 | 3367 | return $this->_model_relations; |
3368 | 3368 | } |
3369 | 3369 | |
@@ -3373,10 +3373,10 @@ discard block |
||
3373 | 3373 | * (Eg, without an event, datetimes have little purpose.) |
3374 | 3374 | * @return EE_Belongs_To_Relation[] |
3375 | 3375 | */ |
3376 | - public function belongs_to_relations(){ |
|
3376 | + public function belongs_to_relations() { |
|
3377 | 3377 | $belongs_to_relations = array(); |
3378 | - foreach($this->relation_settings() as $model_name => $relation_obj){ |
|
3379 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
3378 | + foreach ($this->relation_settings() as $model_name => $relation_obj) { |
|
3379 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
3380 | 3380 | $belongs_to_relations[$model_name] = $relation_obj; |
3381 | 3381 | } |
3382 | 3382 | } |
@@ -3391,15 +3391,15 @@ discard block |
||
3391 | 3391 | * @throws EE_Error |
3392 | 3392 | * @return EE_Model_Relation_Base |
3393 | 3393 | */ |
3394 | - public function related_settings_for($relation_name){ |
|
3395 | - $relatedModels=$this->relation_settings(); |
|
3396 | - if(!array_key_exists($relation_name,$relatedModels)){ |
|
3394 | + public function related_settings_for($relation_name) { |
|
3395 | + $relatedModels = $this->relation_settings(); |
|
3396 | + if ( ! array_key_exists($relation_name, $relatedModels)) { |
|
3397 | 3397 | throw new EE_Error( |
3398 | 3398 | sprintf( |
3399 | - __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'), |
|
3399 | + __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'), |
|
3400 | 3400 | $relation_name, |
3401 | 3401 | $this->_get_class_name(), |
3402 | - implode( ', ', array_keys( $relatedModels )) |
|
3402 | + implode(', ', array_keys($relatedModels)) |
|
3403 | 3403 | ) |
3404 | 3404 | ); |
3405 | 3405 | } |
@@ -3414,10 +3414,10 @@ discard block |
||
3414 | 3414 | * @throws EE_Error |
3415 | 3415 | * @return EE_Model_Field_Base |
3416 | 3416 | */ |
3417 | - public function field_settings_for($fieldName){ |
|
3418 | - $fieldSettings=$this->field_settings(true); |
|
3419 | - if( ! array_key_exists($fieldName,$fieldSettings)){ |
|
3420 | - throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this))); |
|
3417 | + public function field_settings_for($fieldName) { |
|
3418 | + $fieldSettings = $this->field_settings(true); |
|
3419 | + if ( ! array_key_exists($fieldName, $fieldSettings)) { |
|
3420 | + throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this))); |
|
3421 | 3421 | } |
3422 | 3422 | return $fieldSettings[$fieldName]; |
3423 | 3423 | } |
@@ -3427,11 +3427,11 @@ discard block |
||
3427 | 3427 | * @param string $fieldName a key in the model's _field_settings array |
3428 | 3428 | * @return boolean |
3429 | 3429 | */ |
3430 | - public function has_field($fieldName){ |
|
3430 | + public function has_field($fieldName) { |
|
3431 | 3431 | $fieldSettings = $this->field_settings(true); |
3432 | - if( isset($fieldSettings[$fieldName])){ |
|
3432 | + if (isset($fieldSettings[$fieldName])) { |
|
3433 | 3433 | return true; |
3434 | - }else{ |
|
3434 | + } else { |
|
3435 | 3435 | return false; |
3436 | 3436 | } |
3437 | 3437 | } |
@@ -3441,11 +3441,11 @@ discard block |
||
3441 | 3441 | * @param string $relation_name possibly one of the keys in the relation_settings array |
3442 | 3442 | * @return boolean |
3443 | 3443 | */ |
3444 | - public function has_relation($relation_name){ |
|
3444 | + public function has_relation($relation_name) { |
|
3445 | 3445 | $relations = $this->relation_settings(); |
3446 | - if(isset($relations[$relation_name])){ |
|
3446 | + if (isset($relations[$relation_name])) { |
|
3447 | 3447 | return true; |
3448 | - }else{ |
|
3448 | + } else { |
|
3449 | 3449 | return false; |
3450 | 3450 | } |
3451 | 3451 | } |
@@ -3457,7 +3457,7 @@ discard block |
||
3457 | 3457 | * @param $field_obj |
3458 | 3458 | * @return EE_Model_Field_Base |
3459 | 3459 | */ |
3460 | - public function is_primary_key_field( $field_obj ){ |
|
3460 | + public function is_primary_key_field($field_obj) { |
|
3461 | 3461 | return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE; |
3462 | 3462 | } |
3463 | 3463 | |
@@ -3469,16 +3469,16 @@ discard block |
||
3469 | 3469 | * @return EE_Model_Field_Base |
3470 | 3470 | * @throws EE_Error |
3471 | 3471 | */ |
3472 | - public function get_primary_key_field(){ |
|
3473 | - if( $this->_primary_key_field === NULL ){ |
|
3474 | - foreach( $this->field_settings( TRUE ) as $field_obj ){ |
|
3475 | - if( $this->is_primary_key_field( $field_obj )){ |
|
3472 | + public function get_primary_key_field() { |
|
3473 | + if ($this->_primary_key_field === NULL) { |
|
3474 | + foreach ($this->field_settings(TRUE) as $field_obj) { |
|
3475 | + if ($this->is_primary_key_field($field_obj)) { |
|
3476 | 3476 | $this->_primary_key_field = $field_obj; |
3477 | 3477 | break; |
3478 | 3478 | } |
3479 | 3479 | } |
3480 | - if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){ |
|
3481 | - throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this))); |
|
3480 | + if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) { |
|
3481 | + throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this))); |
|
3482 | 3482 | } |
3483 | 3483 | } |
3484 | 3484 | return $this->_primary_key_field; |
@@ -3491,12 +3491,12 @@ discard block |
||
3491 | 3491 | * Internally does some caching. |
3492 | 3492 | * @return boolean |
3493 | 3493 | */ |
3494 | - public function has_primary_key_field(){ |
|
3495 | - if($this->_has_primary_key_field === null){ |
|
3496 | - try{ |
|
3494 | + public function has_primary_key_field() { |
|
3495 | + if ($this->_has_primary_key_field === null) { |
|
3496 | + try { |
|
3497 | 3497 | $this->get_primary_key_field(); |
3498 | 3498 | $this->_has_primary_key_field = true; |
3499 | - }catch(EE_Error $e){ |
|
3499 | + } catch (EE_Error $e) { |
|
3500 | 3500 | $this->_has_primary_key_field = false; |
3501 | 3501 | } |
3502 | 3502 | } |
@@ -3510,9 +3510,9 @@ discard block |
||
3510 | 3510 | * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc |
3511 | 3511 | * @return EE_Model_Field_Base or null if none is found |
3512 | 3512 | */ |
3513 | - public function get_a_field_of_type($field_class_name){ |
|
3514 | - foreach($this->field_settings() as $field){ |
|
3515 | - if( $field instanceof $field_class_name ){ |
|
3513 | + public function get_a_field_of_type($field_class_name) { |
|
3514 | + foreach ($this->field_settings() as $field) { |
|
3515 | + if ($field instanceof $field_class_name) { |
|
3516 | 3516 | return $field; |
3517 | 3517 | } |
3518 | 3518 | } |
@@ -3526,21 +3526,21 @@ discard block |
||
3526 | 3526 | * @return EE_Foreign_Key_Field_Base |
3527 | 3527 | * @throws EE_Error |
3528 | 3528 | */ |
3529 | - public function get_foreign_key_to($model_name){ |
|
3530 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
3531 | - foreach($this->field_settings() as $field){ |
|
3529 | + public function get_foreign_key_to($model_name) { |
|
3530 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
3531 | + foreach ($this->field_settings() as $field) { |
|
3532 | 3532 | // if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){ |
3533 | - if( $field instanceof EE_Foreign_Key_Field_Base ){ |
|
3534 | - if (in_array($model_name,$field->get_model_names_pointed_to() ) ) { |
|
3535 | - $this->_cache_foreign_key_to_fields[ $model_name ] = $field; |
|
3533 | + if ($field instanceof EE_Foreign_Key_Field_Base) { |
|
3534 | + if (in_array($model_name, $field->get_model_names_pointed_to())) { |
|
3535 | + $this->_cache_foreign_key_to_fields[$model_name] = $field; |
|
3536 | 3536 | } |
3537 | 3537 | } |
3538 | 3538 | } |
3539 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
3540 | - throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this))); |
|
3539 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
3540 | + throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this))); |
|
3541 | 3541 | } |
3542 | 3542 | } |
3543 | - return $this->_cache_foreign_key_to_fields[ $model_name ]; |
|
3543 | + return $this->_cache_foreign_key_to_fields[$model_name]; |
|
3544 | 3544 | } |
3545 | 3545 | |
3546 | 3546 | |
@@ -3551,7 +3551,7 @@ discard block |
||
3551 | 3551 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
3552 | 3552 | * @return EE_Table_Base |
3553 | 3553 | */ |
3554 | - function get_table_for_alias($table_alias){ |
|
3554 | + function get_table_for_alias($table_alias) { |
|
3555 | 3555 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
3556 | 3556 | return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name(); |
3557 | 3557 | } |
@@ -3564,25 +3564,25 @@ discard block |
||
3564 | 3564 | * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields |
3565 | 3565 | * @return EE_Model_Field_Base[] where the keys are the field's name |
3566 | 3566 | */ |
3567 | - public function field_settings($include_db_only_fields = false){ |
|
3568 | - if( $include_db_only_fields ){ |
|
3569 | - if( $this->_cached_fields === NULL ){ |
|
3567 | + public function field_settings($include_db_only_fields = false) { |
|
3568 | + if ($include_db_only_fields) { |
|
3569 | + if ($this->_cached_fields === NULL) { |
|
3570 | 3570 | $this->_cached_fields = array(); |
3571 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
3572 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
3573 | - $this->_cached_fields[$field_name]=$field_obj; |
|
3571 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
3572 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
3573 | + $this->_cached_fields[$field_name] = $field_obj; |
|
3574 | 3574 | } |
3575 | 3575 | } |
3576 | 3576 | } |
3577 | 3577 | return $this->_cached_fields; |
3578 | - }else{ |
|
3579 | - if( $this->_cached_fields_non_db_only === NULL ){ |
|
3578 | + } else { |
|
3579 | + if ($this->_cached_fields_non_db_only === NULL) { |
|
3580 | 3580 | $this->_cached_fields_non_db_only = array(); |
3581 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
3582 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
3581 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
3582 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
3583 | 3583 | /** @var $field_obj EE_Model_Field_Base */ |
3584 | - if( ! $field_obj->is_db_only_field() ){ |
|
3585 | - $this->_cached_fields_non_db_only[$field_name]=$field_obj; |
|
3584 | + if ( ! $field_obj->is_db_only_field()) { |
|
3585 | + $this->_cached_fields_non_db_only[$field_name] = $field_obj; |
|
3586 | 3586 | } |
3587 | 3587 | } |
3588 | 3588 | } |
@@ -3601,67 +3601,67 @@ discard block |
||
3601 | 3601 | * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed) |
3602 | 3602 | * @throws \EE_Error |
3603 | 3603 | */ |
3604 | - protected function _create_objects( $rows = array() ) { |
|
3605 | - $array_of_objects=array(); |
|
3606 | - if(empty($rows)){ |
|
3604 | + protected function _create_objects($rows = array()) { |
|
3605 | + $array_of_objects = array(); |
|
3606 | + if (empty($rows)) { |
|
3607 | 3607 | return array(); |
3608 | 3608 | } |
3609 | 3609 | $count_if_model_has_no_primary_key = 0; |
3610 | 3610 | $has_primary_key = $this->has_primary_key_field(); |
3611 | - if( $has_primary_key ) { |
|
3611 | + if ($has_primary_key) { |
|
3612 | 3612 | $primary_key_field = $this->get_primary_key_field(); |
3613 | 3613 | } else { |
3614 | 3614 | $primary_key_field = null; |
3615 | 3615 | } |
3616 | - foreach ( $rows as $row ) { |
|
3617 | - if(empty($row)){ |
|
3616 | + foreach ($rows as $row) { |
|
3617 | + if (empty($row)) { |
|
3618 | 3618 | //wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful... |
3619 | 3619 | return array(); |
3620 | 3620 | } |
3621 | 3621 | //check if we've already set this object in the results array, |
3622 | 3622 | //in which case there's no need to process it further (again) |
3623 | - if( $has_primary_key ) { |
|
3623 | + if ($has_primary_key) { |
|
3624 | 3624 | $table_pk_value = $this->_get_column_value_with_table_alias_or_not( |
3625 | 3625 | $row, |
3626 | 3626 | $primary_key_field->get_qualified_column(), |
3627 | 3627 | $primary_key_field->get_table_column() |
3628 | 3628 | ); |
3629 | - if( $table_pk_value && |
|
3630 | - isset( $array_of_objects[ $table_pk_value ] ) ) { |
|
3629 | + if ($table_pk_value && |
|
3630 | + isset($array_of_objects[$table_pk_value])) { |
|
3631 | 3631 | continue; |
3632 | 3632 | } |
3633 | 3633 | } |
3634 | - $classInstance=$this->instantiate_class_from_array_or_object($row); |
|
3635 | - if( ! $classInstance ) { |
|
3634 | + $classInstance = $this->instantiate_class_from_array_or_object($row); |
|
3635 | + if ( ! $classInstance) { |
|
3636 | 3636 | throw new EE_Error( |
3637 | 3637 | sprintf( |
3638 | - __( 'Could not create instance of class %s from row %s', 'event_espresso' ), |
|
3638 | + __('Could not create instance of class %s from row %s', 'event_espresso'), |
|
3639 | 3639 | $this->get_this_model_name(), |
3640 | - http_build_query( $row ) |
|
3640 | + http_build_query($row) |
|
3641 | 3641 | ) |
3642 | 3642 | ); |
3643 | 3643 | } |
3644 | 3644 | //set the timezone on the instantiated objects |
3645 | - $classInstance->set_timezone( $this->_timezone ); |
|
3645 | + $classInstance->set_timezone($this->_timezone); |
|
3646 | 3646 | //make sure if there is any timezone setting present that we set the timezone for the object |
3647 | 3647 | $key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++; |
3648 | - $array_of_objects[ $key ] = $classInstance; |
|
3648 | + $array_of_objects[$key] = $classInstance; |
|
3649 | 3649 | //also, for all the relations of type BelongsTo, see if we can cache |
3650 | 3650 | //those related models |
3651 | 3651 | //(we could do this for other relations too, but if there are conditions |
3652 | 3652 | //that filtered out some fo the results, then we'd be caching an incomplete set |
3653 | 3653 | //so it requires a little more thought than just caching them immediately...) |
3654 | - foreach($this->_model_relations as $modelName => $relation_obj){ |
|
3655 | - if( $relation_obj instanceof EE_Belongs_To_Relation){ |
|
3654 | + foreach ($this->_model_relations as $modelName => $relation_obj) { |
|
3655 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
3656 | 3656 | //check if this model's INFO is present. If so, cache it on the model |
3657 | 3657 | $other_model = $relation_obj->get_other_model(); |
3658 | 3658 | |
3659 | 3659 | $other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row); |
3660 | 3660 | |
3661 | 3661 | //if we managed to make a model object from the results, cache it on the main model object |
3662 | - if( $other_model_obj_maybe ){ |
|
3662 | + if ($other_model_obj_maybe) { |
|
3663 | 3663 | //set timezone on these other model objects if they are present |
3664 | - $other_model_obj_maybe->set_timezone( $this->_timezone ); |
|
3664 | + $other_model_obj_maybe->set_timezone($this->_timezone); |
|
3665 | 3665 | $classInstance->cache($modelName, $other_model_obj_maybe); |
3666 | 3666 | } |
3667 | 3667 | } |
@@ -3682,12 +3682,12 @@ discard block |
||
3682 | 3682 | |
3683 | 3683 | $this_model_fields_and_values = array(); |
3684 | 3684 | //setup the row using default values; |
3685 | - foreach ( $this->field_settings() as $field_name => $field_obj ) { |
|
3685 | + foreach ($this->field_settings() as $field_name => $field_obj) { |
|
3686 | 3686 | $this_model_fields_and_values[$field_name] = $field_obj->get_default_value(); |
3687 | 3687 | } |
3688 | 3688 | |
3689 | 3689 | $className = $this->_get_class_name(); |
3690 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE ); |
|
3690 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE); |
|
3691 | 3691 | |
3692 | 3692 | return $classInstance; |
3693 | 3693 | } |
@@ -3700,45 +3700,45 @@ discard block |
||
3700 | 3700 | * or an stdClass where each property is the name of a column, |
3701 | 3701 | * @return EE_Base_Class |
3702 | 3702 | */ |
3703 | - public function instantiate_class_from_array_or_object($cols_n_values){ |
|
3704 | - if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) { |
|
3705 | - $cols_n_values = get_object_vars( $cols_n_values ); |
|
3703 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
3704 | + if ( ! is_array($cols_n_values) && is_object($cols_n_values)) { |
|
3705 | + $cols_n_values = get_object_vars($cols_n_values); |
|
3706 | 3706 | } |
3707 | 3707 | $primary_key = NULL; |
3708 | 3708 | //make sure the array only has keys that are fields/columns on this model |
3709 | - $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
3710 | - if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){ |
|
3711 | - $primary_key = $this_model_fields_n_values[ $this->primary_key_name() ]; |
|
3709 | + $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
3710 | + if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) { |
|
3711 | + $primary_key = $this_model_fields_n_values[$this->primary_key_name()]; |
|
3712 | 3712 | } |
3713 | - $className=$this->_get_class_name(); |
|
3713 | + $className = $this->_get_class_name(); |
|
3714 | 3714 | |
3715 | 3715 | //check we actually found results that we can use to build our model object |
3716 | 3716 | //if not, return null |
3717 | - if( $this->has_primary_key_field()){ |
|
3718 | - if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
|
3717 | + if ($this->has_primary_key_field()) { |
|
3718 | + if (empty($this_model_fields_n_values[$this->primary_key_name()])) { |
|
3719 | 3719 | return NULL; |
3720 | 3720 | } |
3721 | - }else if($this->unique_indexes()){ |
|
3721 | + } else if ($this->unique_indexes()) { |
|
3722 | 3722 | $first_column = reset($this_model_fields_n_values); |
3723 | - if(empty($first_column)){ |
|
3723 | + if (empty($first_column)) { |
|
3724 | 3724 | return NULL; |
3725 | 3725 | } |
3726 | 3726 | } |
3727 | 3727 | |
3728 | 3728 | // if there is no primary key or the object doesn't already exist in the entity map, then create a new instance |
3729 | - if ( $primary_key){ |
|
3730 | - $classInstance = $this->get_from_entity_map( $primary_key ); |
|
3731 | - if( ! $classInstance) { |
|
3732 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
3729 | + if ($primary_key) { |
|
3730 | + $classInstance = $this->get_from_entity_map($primary_key); |
|
3731 | + if ( ! $classInstance) { |
|
3732 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
3733 | 3733 | // add this new object to the entity map |
3734 | - $classInstance = $this->add_to_entity_map( $classInstance ); |
|
3734 | + $classInstance = $this->add_to_entity_map($classInstance); |
|
3735 | 3735 | } |
3736 | - }else{ |
|
3737 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
3736 | + } else { |
|
3737 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
3738 | 3738 | } |
3739 | 3739 | |
3740 | 3740 | //it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example). In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property. |
3741 | - $this->set_timezone( $classInstance->get_timezone() ); |
|
3741 | + $this->set_timezone($classInstance->get_timezone()); |
|
3742 | 3742 | return $classInstance; |
3743 | 3743 | } |
3744 | 3744 | /** |
@@ -3746,8 +3746,8 @@ discard block |
||
3746 | 3746 | * @param int|string $id the ID of the model object |
3747 | 3747 | * @return EE_Base_Class |
3748 | 3748 | */ |
3749 | - public function get_from_entity_map( $id ){ |
|
3750 | - return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL; |
|
3749 | + public function get_from_entity_map($id) { |
|
3750 | + return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL; |
|
3751 | 3751 | } |
3752 | 3752 | |
3753 | 3753 | |
@@ -3766,21 +3766,21 @@ discard block |
||
3766 | 3766 | * @throws EE_Error |
3767 | 3767 | * @return \EE_Base_Class |
3768 | 3768 | */ |
3769 | - public function add_to_entity_map( EE_Base_Class $object) { |
|
3769 | + public function add_to_entity_map(EE_Base_Class $object) { |
|
3770 | 3770 | $className = $this->_get_class_name(); |
3771 | - if( ! $object instanceof $className ){ |
|
3772 | - throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) ); |
|
3771 | + if ( ! $object instanceof $className) { |
|
3772 | + throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className)); |
|
3773 | 3773 | } |
3774 | 3774 | /** @var $object EE_Base_Class */ |
3775 | - if ( ! $object->ID() ){ |
|
3776 | - throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this))); |
|
3775 | + if ( ! $object->ID()) { |
|
3776 | + throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this))); |
|
3777 | 3777 | } |
3778 | 3778 | // double check it's not already there |
3779 | - $classInstance = $this->get_from_entity_map( $object->ID() ); |
|
3780 | - if ( $classInstance ) { |
|
3779 | + $classInstance = $this->get_from_entity_map($object->ID()); |
|
3780 | + if ($classInstance) { |
|
3781 | 3781 | return $classInstance; |
3782 | 3782 | } else { |
3783 | - $this->_entity_map[ $object->ID() ] = $object; |
|
3783 | + $this->_entity_map[$object->ID()] = $object; |
|
3784 | 3784 | return $object; |
3785 | 3785 | } |
3786 | 3786 | } |
@@ -3793,8 +3793,8 @@ discard block |
||
3793 | 3793 | * @param array $cols_n_values |
3794 | 3794 | * @return array |
3795 | 3795 | */ |
3796 | - public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) { |
|
3797 | - return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
3796 | + public function deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
3797 | + return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
3798 | 3798 | } |
3799 | 3799 | |
3800 | 3800 | |
@@ -3807,40 +3807,40 @@ discard block |
||
3807 | 3807 | * @param string $cols_n_values |
3808 | 3808 | * @return array |
3809 | 3809 | */ |
3810 | - protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){ |
|
3810 | + protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
3811 | 3811 | $this_model_fields_n_values = array(); |
3812 | - foreach( $this->get_tables() as $table_alias => $table_obj ) { |
|
3813 | - $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() ); |
|
3812 | + foreach ($this->get_tables() as $table_alias => $table_obj) { |
|
3813 | + $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column()); |
|
3814 | 3814 | //there is a primary key on this table and its not set. Use defaults for all its columns |
3815 | - if( $table_obj->get_pk_column() && $table_pk_value === NULL ){ |
|
3816 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
3817 | - if( ! $field_obj->is_db_only_field() ){ |
|
3815 | + if ($table_obj->get_pk_column() && $table_pk_value === NULL) { |
|
3816 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
3817 | + if ( ! $field_obj->is_db_only_field()) { |
|
3818 | 3818 | //prepare field as if its coming from db |
3819 | - $prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() ); |
|
3820 | - $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
|
3819 | + $prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value()); |
|
3820 | + $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value); |
|
3821 | 3821 | } |
3822 | 3822 | } |
3823 | - }else{ |
|
3823 | + } else { |
|
3824 | 3824 | //the table's rows existed. Use their values |
3825 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
3826 | - if( ! $field_obj->is_db_only_field() ) |
|
3827 | - $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() ); |
|
3825 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
3826 | + if ( ! $field_obj->is_db_only_field()) |
|
3827 | + $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column()); |
|
3828 | 3828 | } |
3829 | 3829 | } |
3830 | 3830 | } |
3831 | 3831 | return $this_model_fields_n_values; |
3832 | 3832 | } |
3833 | 3833 | |
3834 | - protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){ |
|
3834 | + protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) { |
|
3835 | 3835 | //ask the field what it think it's table_name.column_name should be, and call it the "qualified column" |
3836 | 3836 | //does the field on the model relate to this column retrieved from the db? |
3837 | 3837 | //or is it a db-only field? (not relating to the model) |
3838 | - if( isset( $cols_n_values[ $qualified_column ] ) ){ |
|
3839 | - $value = $cols_n_values[ $qualified_column ]; |
|
3838 | + if (isset($cols_n_values[$qualified_column])) { |
|
3839 | + $value = $cols_n_values[$qualified_column]; |
|
3840 | 3840 | |
3841 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
3842 | - $value = $cols_n_values[ $regular_column ]; |
|
3843 | - }else{ |
|
3841 | + }elseif (isset($cols_n_values[$regular_column])) { |
|
3842 | + $value = $cols_n_values[$regular_column]; |
|
3843 | + } else { |
|
3844 | 3844 | $value = NULL; |
3845 | 3845 | } |
3846 | 3846 | |
@@ -3858,23 +3858,23 @@ discard block |
||
3858 | 3858 | * @param int|string $id |
3859 | 3859 | * @return EE_Base_Class |
3860 | 3860 | */ |
3861 | - public function refresh_entity_map_from_db( $id ){ |
|
3862 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
3863 | - if( $obj_in_map ){ |
|
3864 | - $wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) ); |
|
3865 | - if( $wpdb_results && is_array( $wpdb_results ) ){ |
|
3866 | - $one_row = reset( $wpdb_results ); |
|
3867 | - foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) { |
|
3868 | - $obj_in_map->set_from_db( $field_name, $db_value ); |
|
3861 | + public function refresh_entity_map_from_db($id) { |
|
3862 | + $obj_in_map = $this->get_from_entity_map($id); |
|
3863 | + if ($obj_in_map) { |
|
3864 | + $wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)); |
|
3865 | + if ($wpdb_results && is_array($wpdb_results)) { |
|
3866 | + $one_row = reset($wpdb_results); |
|
3867 | + foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) { |
|
3868 | + $obj_in_map->set_from_db($field_name, $db_value); |
|
3869 | 3869 | } |
3870 | 3870 | //clear the cache of related model objects |
3871 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
3872 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
3871 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
3872 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
3873 | 3873 | } |
3874 | 3874 | } |
3875 | 3875 | return $obj_in_map; |
3876 | - }else{ |
|
3877 | - return $this->get_one_by_ID( $id ); |
|
3876 | + } else { |
|
3877 | + return $this->get_one_by_ID($id); |
|
3878 | 3878 | } |
3879 | 3879 | } |
3880 | 3880 | |
@@ -3892,24 +3892,24 @@ discard block |
||
3892 | 3892 | * @param EE_Base_Class $replacing_model_obj |
3893 | 3893 | * @return \EE_Base_Class |
3894 | 3894 | */ |
3895 | - public function refresh_entity_map_with( $id, $replacing_model_obj ) { |
|
3896 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
3897 | - if( $obj_in_map ){ |
|
3898 | - if( $replacing_model_obj instanceof EE_Base_Class ){ |
|
3899 | - foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) { |
|
3900 | - $obj_in_map->set( $field_name, $value ); |
|
3895 | + public function refresh_entity_map_with($id, $replacing_model_obj) { |
|
3896 | + $obj_in_map = $this->get_from_entity_map($id); |
|
3897 | + if ($obj_in_map) { |
|
3898 | + if ($replacing_model_obj instanceof EE_Base_Class) { |
|
3899 | + foreach ($replacing_model_obj->model_field_array() as $field_name => $value) { |
|
3900 | + $obj_in_map->set($field_name, $value); |
|
3901 | 3901 | } |
3902 | 3902 | //make the model object in the entity map's cache match the $replacing_model_obj |
3903 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
3904 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
3905 | - foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) { |
|
3906 | - $obj_in_map->cache( $relation_name, $cached_obj, $cache_id ); |
|
3903 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
3904 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
3905 | + foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) { |
|
3906 | + $obj_in_map->cache($relation_name, $cached_obj, $cache_id); |
|
3907 | 3907 | } |
3908 | 3908 | } |
3909 | 3909 | } |
3910 | 3910 | return $obj_in_map; |
3911 | - }else{ |
|
3912 | - $this->add_to_entity_map( $replacing_model_obj ); |
|
3911 | + } else { |
|
3912 | + $this->add_to_entity_map($replacing_model_obj); |
|
3913 | 3913 | return $replacing_model_obj; |
3914 | 3914 | } |
3915 | 3915 | } |
@@ -3922,7 +3922,7 @@ discard block |
||
3922 | 3922 | * require_once($this->_getClassName().".class.php"); |
3923 | 3923 | * @return string |
3924 | 3924 | */ |
3925 | - private function _get_class_name(){ |
|
3925 | + private function _get_class_name() { |
|
3926 | 3926 | return "EE_".$this->get_this_model_name(); |
3927 | 3927 | } |
3928 | 3928 | |
@@ -3935,10 +3935,10 @@ discard block |
||
3935 | 3935 | * @param int $quantity |
3936 | 3936 | * @return string |
3937 | 3937 | */ |
3938 | - public function item_name($quantity = 1){ |
|
3939 | - if($quantity == 1){ |
|
3938 | + public function item_name($quantity = 1) { |
|
3939 | + if ($quantity == 1) { |
|
3940 | 3940 | return $this->singular_item; |
3941 | - }else{ |
|
3941 | + } else { |
|
3942 | 3942 | return $this->plural_item; |
3943 | 3943 | } |
3944 | 3944 | } |
@@ -3967,13 +3967,13 @@ discard block |
||
3967 | 3967 | * @throws EE_Error |
3968 | 3968 | * @return mixed whatever the plugin which calls add_filter decides |
3969 | 3969 | */ |
3970 | - public function __call($methodName,$args){ |
|
3971 | - $className=get_class($this); |
|
3972 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
3973 | - if(!has_filter($tagName)){ |
|
3970 | + public function __call($methodName, $args) { |
|
3971 | + $className = get_class($this); |
|
3972 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
3973 | + if ( ! has_filter($tagName)) { |
|
3974 | 3974 | throw new EE_Error( |
3975 | 3975 | sprintf( |
3976 | - __( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ), |
|
3976 | + __('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'), |
|
3977 | 3977 | $methodName, |
3978 | 3978 | $className, |
3979 | 3979 | $tagName, |
@@ -3982,7 +3982,7 @@ discard block |
||
3982 | 3982 | ); |
3983 | 3983 | } |
3984 | 3984 | |
3985 | - return apply_filters($tagName,null,$this,$args); |
|
3985 | + return apply_filters($tagName, null, $this, $args); |
|
3986 | 3986 | } |
3987 | 3987 | |
3988 | 3988 | |
@@ -3995,22 +3995,22 @@ discard block |
||
3995 | 3995 | * @throws EE_Error |
3996 | 3996 | * @return EE_Base_Class |
3997 | 3997 | */ |
3998 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){ |
|
3998 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
3999 | 3999 | $className = $this->_get_class_name(); |
4000 | 4000 | $primary_key_field = $this->get_primary_key_field(); |
4001 | - if( $base_class_obj_or_id instanceof $className ){ |
|
4001 | + if ($base_class_obj_or_id instanceof $className) { |
|
4002 | 4002 | $model_object = $base_class_obj_or_id; |
4003 | - }elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && ( |
|
4004 | - is_int( $base_class_obj_or_id ) || |
|
4005 | - is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101) |
|
4003 | + }elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && ( |
|
4004 | + is_int($base_class_obj_or_id) || |
|
4005 | + is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101) |
|
4006 | 4006 | $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
4007 | - }elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){ |
|
4007 | + }elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) { |
|
4008 | 4008 | //assume its a string representation of the object |
4009 | 4009 | $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
4010 | - }else{ |
|
4011 | - throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
|
4010 | + } else { |
|
4011 | + throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true))); |
|
4012 | 4012 | } |
4013 | - if( $model_object->ID() == NULL && $ensure_is_in_db){ |
|
4013 | + if ($model_object->ID() == NULL && $ensure_is_in_db) { |
|
4014 | 4014 | $model_object->save(); |
4015 | 4015 | } |
4016 | 4016 | return $model_object; |
@@ -4026,19 +4026,19 @@ discard block |
||
4026 | 4026 | * @return int|string depending on the type of this model object's ID |
4027 | 4027 | * @throws EE_Error |
4028 | 4028 | */ |
4029 | - public function ensure_is_ID($base_class_obj_or_id){ |
|
4029 | + public function ensure_is_ID($base_class_obj_or_id) { |
|
4030 | 4030 | $className = $this->_get_class_name(); |
4031 | - if( $base_class_obj_or_id instanceof $className ){ |
|
4031 | + if ($base_class_obj_or_id instanceof $className) { |
|
4032 | 4032 | /** @var $base_class_obj_or_id EE_Base_Class */ |
4033 | 4033 | $id = $base_class_obj_or_id->ID(); |
4034 | - }elseif(is_int($base_class_obj_or_id)){ |
|
4034 | + }elseif (is_int($base_class_obj_or_id)) { |
|
4035 | 4035 | //assume it's an ID |
4036 | 4036 | $id = $base_class_obj_or_id; |
4037 | - }elseif(is_string($base_class_obj_or_id)){ |
|
4037 | + }elseif (is_string($base_class_obj_or_id)) { |
|
4038 | 4038 | //assume its a string representation of the object |
4039 | 4039 | $id = $base_class_obj_or_id; |
4040 | - }else{ |
|
4041 | - throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
|
4040 | + } else { |
|
4041 | + throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true))); |
|
4042 | 4042 | } |
4043 | 4043 | return $id; |
4044 | 4044 | } |
@@ -4061,14 +4061,14 @@ discard block |
||
4061 | 4061 | * @param int $values_already_prepared like one of the constants on EEM_Base |
4062 | 4062 | * @return void |
4063 | 4063 | */ |
4064 | - public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){ |
|
4064 | + public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) { |
|
4065 | 4065 | $this->_values_already_prepared_by_model_object = $values_already_prepared; |
4066 | 4066 | } |
4067 | 4067 | /** |
4068 | 4068 | * Read comments for assume_values_already_prepared_by_model_object() |
4069 | 4069 | * @return int |
4070 | 4070 | */ |
4071 | - public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
|
4071 | + public function get_assumption_concerning_values_already_prepared_by_model_object() { |
|
4072 | 4072 | return $this->_values_already_prepared_by_model_object; |
4073 | 4073 | } |
4074 | 4074 | |
@@ -4076,17 +4076,17 @@ discard block |
||
4076 | 4076 | * Gets all the indexes on this model |
4077 | 4077 | * @return EE_Index[] |
4078 | 4078 | */ |
4079 | - public function indexes(){ |
|
4079 | + public function indexes() { |
|
4080 | 4080 | return $this->_indexes; |
4081 | 4081 | } |
4082 | 4082 | /** |
4083 | 4083 | * Gets all the Unique Indexes on this model |
4084 | 4084 | * @return EE_Unique_Index[] |
4085 | 4085 | */ |
4086 | - public function unique_indexes(){ |
|
4086 | + public function unique_indexes() { |
|
4087 | 4087 | $unique_indexes = array(); |
4088 | - foreach($this->_indexes as $name => $index){ |
|
4089 | - if($index instanceof EE_Unique_Index){ |
|
4088 | + foreach ($this->_indexes as $name => $index) { |
|
4089 | + if ($index instanceof EE_Unique_Index) { |
|
4090 | 4090 | $unique_indexes [$name] = $index; |
4091 | 4091 | } |
4092 | 4092 | } |
@@ -4099,9 +4099,9 @@ discard block |
||
4099 | 4099 | * on a primary index |
4100 | 4100 | * @return EE_Model_Field_Base[] |
4101 | 4101 | */ |
4102 | - public function get_combined_primary_key_fields(){ |
|
4103 | - foreach($this->indexes() as $index){ |
|
4104 | - if($index instanceof EE_Primary_Key_Index){ |
|
4102 | + public function get_combined_primary_key_fields() { |
|
4103 | + foreach ($this->indexes() as $index) { |
|
4104 | + if ($index instanceof EE_Primary_Key_Index) { |
|
4105 | 4105 | return $index->fields(); |
4106 | 4106 | } |
4107 | 4107 | } |
@@ -4114,7 +4114,7 @@ discard block |
||
4114 | 4114 | * @param array $cols_n_values keys are field names, values are their values |
4115 | 4115 | * @return string |
4116 | 4116 | */ |
4117 | - public function get_index_primary_key_string($cols_n_values){ |
|
4117 | + public function get_index_primary_key_string($cols_n_values) { |
|
4118 | 4118 | $cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields()); |
4119 | 4119 | return http_build_query($cols_n_values_for_primary_key_index); |
4120 | 4120 | } |
@@ -4126,13 +4126,13 @@ discard block |
||
4126 | 4126 | * @param string $index_primary_key_string |
4127 | 4127 | * @return null|array |
4128 | 4128 | */ |
4129 | - function parse_index_primary_key_string( $index_primary_key_string) { |
|
4129 | + function parse_index_primary_key_string($index_primary_key_string) { |
|
4130 | 4130 | $key_fields = $this->get_combined_primary_key_fields(); |
4131 | 4131 | //check all of them are in the $id |
4132 | 4132 | $key_vals_in_combined_pk = array(); |
4133 | - parse_str( $index_primary_key_string, $key_vals_in_combined_pk ); |
|
4134 | - foreach( $key_fields as $key_field_name => $field_obj ) { |
|
4135 | - if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){ |
|
4133 | + parse_str($index_primary_key_string, $key_vals_in_combined_pk); |
|
4134 | + foreach ($key_fields as $key_field_name => $field_obj) { |
|
4135 | + if ( ! isset($key_vals_in_combined_pk[$key_field_name])) { |
|
4136 | 4136 | return NULL; |
4137 | 4137 | } |
4138 | 4138 | } |
@@ -4145,10 +4145,10 @@ discard block |
||
4145 | 4145 | * @param array $key_vals |
4146 | 4146 | * @return boolean |
4147 | 4147 | */ |
4148 | - function has_all_combined_primary_key_fields( $key_vals ) { |
|
4149 | - $keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() ); |
|
4150 | - foreach( $keys_it_should_have as $key ){ |
|
4151 | - if( ! isset( $key_vals[ $key ] ) ){ |
|
4148 | + function has_all_combined_primary_key_fields($key_vals) { |
|
4149 | + $keys_it_should_have = array_keys($this->get_combined_primary_key_fields()); |
|
4150 | + foreach ($keys_it_should_have as $key) { |
|
4151 | + if ( ! isset($key_vals[$key])) { |
|
4152 | 4152 | return false; |
4153 | 4153 | } |
4154 | 4154 | } |
@@ -4164,23 +4164,23 @@ discard block |
||
4164 | 4164 | * @throws EE_Error |
4165 | 4165 | * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed) |
4166 | 4166 | */ |
4167 | - public function get_all_copies($model_object_or_attributes_array, $query_params = array()){ |
|
4167 | + public function get_all_copies($model_object_or_attributes_array, $query_params = array()) { |
|
4168 | 4168 | |
4169 | - if($model_object_or_attributes_array instanceof EE_Base_Class){ |
|
4169 | + if ($model_object_or_attributes_array instanceof EE_Base_Class) { |
|
4170 | 4170 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
4171 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
4171 | + }elseif (is_array($model_object_or_attributes_array)) { |
|
4172 | 4172 | $attributes_array = $model_object_or_attributes_array; |
4173 | - }else{ |
|
4174 | - throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
|
4173 | + } else { |
|
4174 | + throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array)); |
|
4175 | 4175 | } |
4176 | 4176 | //even copies obviously won't have the same ID, so remove the primary key |
4177 | 4177 | //from the WHERE conditions for finding copies (if there is a primary key, of course) |
4178 | - if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){ |
|
4178 | + if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) { |
|
4179 | 4179 | unset($attributes_array[$this->primary_key_name()]); |
4180 | 4180 | } |
4181 | - if(isset($query_params[0])){ |
|
4182 | - $query_params[0] = array_merge($attributes_array,$query_params); |
|
4183 | - }else{ |
|
4181 | + if (isset($query_params[0])) { |
|
4182 | + $query_params[0] = array_merge($attributes_array, $query_params); |
|
4183 | + } else { |
|
4184 | 4184 | $query_params[0] = $attributes_array; |
4185 | 4185 | } |
4186 | 4186 | return $this->get_all($query_params); |
@@ -4194,16 +4194,16 @@ discard block |
||
4194 | 4194 | * @param array $query_params |
4195 | 4195 | * @return EE_Base_Class |
4196 | 4196 | */ |
4197 | - function get_one_copy($model_object_or_attributes_array,$query_params = array()){ |
|
4198 | - if( ! is_array( $query_params ) ){ |
|
4199 | - EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
4197 | + function get_one_copy($model_object_or_attributes_array, $query_params = array()) { |
|
4198 | + if ( ! is_array($query_params)) { |
|
4199 | + EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
4200 | 4200 | $query_params = array(); |
4201 | 4201 | } |
4202 | 4202 | $query_params['limit'] = 1; |
4203 | - $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
|
4204 | - if(is_array($copies)){ |
|
4203 | + $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params); |
|
4204 | + if (is_array($copies)) { |
|
4205 | 4205 | return array_shift($copies); |
4206 | - }else{ |
|
4206 | + } else { |
|
4207 | 4207 | return null; |
4208 | 4208 | } |
4209 | 4209 | } |
@@ -4217,10 +4217,10 @@ discard block |
||
4217 | 4217 | * @param int|string $id the value of the primary key to update |
4218 | 4218 | * @return int number of rows updated |
4219 | 4219 | */ |
4220 | - public function update_by_ID($fields_n_values,$id){ |
|
4220 | + public function update_by_ID($fields_n_values, $id) { |
|
4221 | 4221 | $query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id), |
4222 | 4222 | 'default_where_conditions'=>'other_models_only',); |
4223 | - return $this->update($fields_n_values,$query_params); |
|
4223 | + return $this->update($fields_n_values, $query_params); |
|
4224 | 4224 | } |
4225 | 4225 | |
4226 | 4226 | |
@@ -4231,12 +4231,12 @@ discard block |
||
4231 | 4231 | * @return string an operator which can be used in SQL |
4232 | 4232 | * @throws EE_Error |
4233 | 4233 | */ |
4234 | - private function _prepare_operator_for_sql($operator_supplied){ |
|
4234 | + private function _prepare_operator_for_sql($operator_supplied) { |
|
4235 | 4235 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
4236 | - if($sql_operator){ |
|
4236 | + if ($sql_operator) { |
|
4237 | 4237 | return $sql_operator; |
4238 | - }else{ |
|
4239 | - throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
|
4238 | + } else { |
|
4239 | + throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators)))); |
|
4240 | 4240 | } |
4241 | 4241 | } |
4242 | 4242 | |
@@ -4246,10 +4246,10 @@ discard block |
||
4246 | 4246 | * @param array $query_params like get_all's |
4247 | 4247 | * @return string[] |
4248 | 4248 | */ |
4249 | - public function get_all_names($query_params = array()){ |
|
4249 | + public function get_all_names($query_params = array()) { |
|
4250 | 4250 | $objs = $this->get_all($query_params); |
4251 | 4251 | $names = array(); |
4252 | - foreach($objs as $obj){ |
|
4252 | + foreach ($objs as $obj) { |
|
4253 | 4253 | $names[$obj->ID()] = $obj->name(); |
4254 | 4254 | } |
4255 | 4255 | return $names; |
@@ -4264,22 +4264,22 @@ discard block |
||
4264 | 4264 | * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array |
4265 | 4265 | * @return array |
4266 | 4266 | */ |
4267 | - public function get_IDs( $model_objects, $filter_out_empty_ids = false) { |
|
4268 | - if( ! $this->has_primary_key_field() ) { |
|
4269 | - if( WP_DEBUG ) { |
|
4270 | - EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
4267 | + public function get_IDs($model_objects, $filter_out_empty_ids = false) { |
|
4268 | + if ( ! $this->has_primary_key_field()) { |
|
4269 | + if (WP_DEBUG) { |
|
4270 | + EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
4271 | 4271 | return array(); |
4272 | 4272 | } |
4273 | 4273 | } |
4274 | 4274 | $IDs = array(); |
4275 | - foreach( $model_objects as $model_object ) { |
|
4275 | + foreach ($model_objects as $model_object) { |
|
4276 | 4276 | $id = $model_object->ID(); |
4277 | - if( ! $id ) { |
|
4278 | - if( $filter_out_empty_ids ) { |
|
4277 | + if ( ! $id) { |
|
4278 | + if ($filter_out_empty_ids) { |
|
4279 | 4279 | continue; |
4280 | 4280 | } |
4281 | - if( WP_DEBUG ) { |
|
4282 | - EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
4281 | + if (WP_DEBUG) { |
|
4282 | + EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
4283 | 4283 | } |
4284 | 4284 | } |
4285 | 4285 | $IDs[] = $id; |
@@ -4292,8 +4292,8 @@ discard block |
||
4292 | 4292 | * are no capabilities that relate to this model returns false |
4293 | 4293 | * @return string|false |
4294 | 4294 | */ |
4295 | - public function cap_slug(){ |
|
4296 | - return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
4295 | + public function cap_slug() { |
|
4296 | + return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
4297 | 4297 | } |
4298 | 4298 | |
4299 | 4299 | /** |
@@ -4305,27 +4305,27 @@ discard block |
||
4305 | 4305 | * @param string $context |
4306 | 4306 | * @return EE_Default_Where_Conditions[] indexed by associated capability |
4307 | 4307 | */ |
4308 | - public function cap_restrictions( $context = EEM_Base::caps_read ) { |
|
4309 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
4308 | + public function cap_restrictions($context = EEM_Base::caps_read) { |
|
4309 | + EEM_Base::verify_is_valid_cap_context($context); |
|
4310 | 4310 | //check if we ought to run the restriction generator first |
4311 | - if( isset( $this->_cap_restriction_generators[ $context ] ) && |
|
4312 | - $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base && |
|
4313 | - ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) { |
|
4314 | - $this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ], $this->_cap_restriction_generators[ $context ]->generate_restrictions() ); |
|
4311 | + if (isset($this->_cap_restriction_generators[$context]) && |
|
4312 | + $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base && |
|
4313 | + ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) { |
|
4314 | + $this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions()); |
|
4315 | 4315 | } |
4316 | 4316 | //and make sure we've finalized the construction of each restriction |
4317 | - foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) { |
|
4318 | - $where_conditions_obj->_finalize_construct( $this ); |
|
4317 | + foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) { |
|
4318 | + $where_conditions_obj->_finalize_construct($this); |
|
4319 | 4319 | } |
4320 | 4320 | |
4321 | - return $this->_cap_restrictions[ $context ]; |
|
4321 | + return $this->_cap_restrictions[$context]; |
|
4322 | 4322 | } |
4323 | 4323 | |
4324 | 4324 | /** |
4325 | 4325 | * Indicating whether or not this model thinks its a wp core model |
4326 | 4326 | * @return boolean |
4327 | 4327 | */ |
4328 | - public function is_wp_core_model(){ |
|
4328 | + public function is_wp_core_model() { |
|
4329 | 4329 | return $this->_wp_core_model; |
4330 | 4330 | } |
4331 | 4331 | |
@@ -4335,12 +4335,12 @@ discard block |
||
4335 | 4335 | * @param string $context one of EEM_Base::caps_ constants |
4336 | 4336 | * @return EE_Default_Where_Conditions[] indexed by capability name |
4337 | 4337 | */ |
4338 | - public function caps_missing( $context = EEM_Base::caps_read ) { |
|
4338 | + public function caps_missing($context = EEM_Base::caps_read) { |
|
4339 | 4339 | $missing_caps = array(); |
4340 | - $cap_restrictions = $this->cap_restrictions( $context ); |
|
4341 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
4342 | - if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) { |
|
4343 | - $missing_caps[ $cap ] = $restriction_if_no_cap; |
|
4340 | + $cap_restrictions = $this->cap_restrictions($context); |
|
4341 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
4342 | + if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) { |
|
4343 | + $missing_caps[$cap] = $restriction_if_no_cap; |
|
4344 | 4344 | } |
4345 | 4345 | } |
4346 | 4346 | return $missing_caps; |
@@ -4352,7 +4352,7 @@ discard block |
||
4352 | 4352 | * one of 'read', 'edit', or 'delete' |
4353 | 4353 | */ |
4354 | 4354 | public function cap_contexts_to_cap_action_map() { |
4355 | - return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this ); |
|
4355 | + return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this); |
|
4356 | 4356 | } |
4357 | 4357 | |
4358 | 4358 | |
@@ -4363,19 +4363,19 @@ discard block |
||
4363 | 4363 | * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values |
4364 | 4364 | * @throws \EE_Error |
4365 | 4365 | */ |
4366 | - public function cap_action_for_context( $context ) { |
|
4366 | + public function cap_action_for_context($context) { |
|
4367 | 4367 | $mapping = $this->cap_contexts_to_cap_action_map(); |
4368 | - if( isset( $mapping[ $context ] ) ) { |
|
4369 | - return $mapping[ $context ]; |
|
4368 | + if (isset($mapping[$context])) { |
|
4369 | + return $mapping[$context]; |
|
4370 | 4370 | } |
4371 | - if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) { |
|
4371 | + if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) { |
|
4372 | 4372 | return $action; |
4373 | 4373 | } |
4374 | 4374 | throw new EE_Error( |
4375 | 4375 | sprintf( |
4376 | - __( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ), |
|
4376 | + __('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'), |
|
4377 | 4377 | $context, |
4378 | - implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) ) |
|
4378 | + implode(',', array_keys($this->cap_contexts_to_cap_action_map())) |
|
4379 | 4379 | ) |
4380 | 4380 | ); |
4381 | 4381 | |
@@ -4386,7 +4386,7 @@ discard block |
||
4386 | 4386 | * @return array |
4387 | 4387 | */ |
4388 | 4388 | static public function valid_cap_contexts() { |
4389 | - return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array( |
|
4389 | + return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array( |
|
4390 | 4390 | self::caps_read, |
4391 | 4391 | self::caps_read_admin, |
4392 | 4392 | self::caps_edit, |
@@ -4402,17 +4402,17 @@ discard block |
||
4402 | 4402 | * @return bool |
4403 | 4403 | * @throws \EE_Error |
4404 | 4404 | */ |
4405 | - static public function verify_is_valid_cap_context( $context ) { |
|
4405 | + static public function verify_is_valid_cap_context($context) { |
|
4406 | 4406 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
4407 | - if( in_array( $context, $valid_cap_contexts ) ) { |
|
4407 | + if (in_array($context, $valid_cap_contexts)) { |
|
4408 | 4408 | return true; |
4409 | - }else{ |
|
4409 | + } else { |
|
4410 | 4410 | throw new EE_Error( |
4411 | 4411 | sprintf( |
4412 | - __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
|
4412 | + __('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'), |
|
4413 | 4413 | $context, |
4414 | - 'EEM_Base' , |
|
4415 | - implode(',', $valid_cap_contexts ) |
|
4414 | + 'EEM_Base', |
|
4415 | + implode(',', $valid_cap_contexts) |
|
4416 | 4416 | ) |
4417 | 4417 | ); |
4418 | 4418 | } |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Ticketing Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Event Espresso |
|
9 | - * @ copyright (c) 2008-2014 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version $VID:$ |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Ticketing Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Event Espresso |
|
9 | + * @ copyright (c) 2008-2014 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version $VID:$ |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + */ |
|
16 | 16 | /** |
17 | - * Class EE_Register_Addon |
|
18 | - * |
|
19 | - * EEI_Plugin_API class for registering addons for use with EE core. |
|
20 | - * Receives an array of addon details and takes care of adding all of the necessary hooks and filters to setup things such as autoloaders, configuration settings, data migration scripts, admin pages, modules, shortcodes, and even widgets |
|
21 | - * |
|
22 | - * @package Event Espresso |
|
23 | - * @subpackage plugin api, addons |
|
24 | - * @since 4.3.0 |
|
25 | - * @author Brent Christensen |
|
26 | - */ |
|
17 | + * Class EE_Register_Addon |
|
18 | + * |
|
19 | + * EEI_Plugin_API class for registering addons for use with EE core. |
|
20 | + * Receives an array of addon details and takes care of adding all of the necessary hooks and filters to setup things such as autoloaders, configuration settings, data migration scripts, admin pages, modules, shortcodes, and even widgets |
|
21 | + * |
|
22 | + * @package Event Espresso |
|
23 | + * @subpackage plugin api, addons |
|
24 | + * @since 4.3.0 |
|
25 | + * @author Brent Christensen |
|
26 | + */ |
|
27 | 27 | class EE_Register_Addon implements EEI_Plugin_API { |
28 | 28 | |
29 | 29 | |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | * An array of message types with the key as the message type name and the values as below: |
139 | 139 | * @type string $mtfilename The filename of the message type being registered. This will be the main |
140 | 140 | * EE_{Messagetype_Name}_message_type class. (eg. EE_Declined_Registration_message_type.class.php). Required. |
141 | - * @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required. |
|
142 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
143 | - * type should activate with. Each value in the array should match the name property of a EE_messenger. Optional. |
|
144 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
141 | + * @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required. |
|
142 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
143 | + * type should activate with. Each value in the array should match the name property of a EE_messenger. Optional. |
|
144 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
145 | 145 | * type should validate with. Each value in the array should match the name property of an EE_messenger. Optional. |
146 | 146 | * } |
147 | 147 | * @type array $custom_post_types |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This file contains the EE_Register_Config class that implements EEI_Plugin_API. |
|
4 | - * @package Event Espresso |
|
5 | - * @subpackage helpers |
|
6 | - * @since 4.3.0 |
|
7 | - */ |
|
3 | + * This file contains the EE_Register_Config class that implements EEI_Plugin_API. |
|
4 | + * @package Event Espresso |
|
5 | + * @subpackage helpers |
|
6 | + * @since 4.3.0 |
|
7 | + */ |
|
8 | 8 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
9 | 9 | |
10 | 10 | /** |
@@ -112,6 +112,6 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function deregister( $config_class_name = NULL ) { |
114 | 114 | if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
115 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
115 | + unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
116 | 116 | } |
117 | 117 | } |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | * } |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public static function register( $config_class = NULL, $setup_args = array() ) { |
|
45 | + public static function register($config_class = NULL, $setup_args = array()) { |
|
46 | 46 | |
47 | - $setup_args['config_name'] = isset( $setup_args['config_name'] ) && ! empty( $setup_args['config_name'] ) ? $setup_args['config_name'] : $config_class; |
|
48 | - $setup_args['config_section'] = isset( $setup_args['config_section'] ) && ! empty( $setup_args['config_section'] ) ? $setup_args['config_section'] : 'addons'; |
|
47 | + $setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class; |
|
48 | + $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons'; |
|
49 | 49 | |
50 | 50 | //required fields MUST be present, so let's make sure they are. |
51 | - if ( empty( $config_class ) || ! is_array( $setup_args ) || empty( $setup_args['config_name'] )) { |
|
52 | - throw new EE_Error( __( 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso' )); |
|
51 | + if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) { |
|
52 | + throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //make sure we don't register twice |
56 | - if( isset( self::$_ee_config_registry[ $config_class ] ) ){ |
|
56 | + if (isset(self::$_ee_config_registry[$config_class])) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | //first find out if this happened too late. |
62 | - if ( did_action( 'AHEE__EE_System__load_core_configuration__begin' ) ) { |
|
62 | + if (did_action('AHEE__EE_System__load_core_configuration__begin')) { |
|
63 | 63 | EE_Error::doing_it_wrong( |
64 | 64 | __METHOD__, |
65 | 65 | sprintf( |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | ); |
71 | 71 | } |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_config_registry[ $config_class ] = array( |
|
73 | + self::$_ee_config_registry[$config_class] = array( |
|
74 | 74 | 'section' => $setup_args['config_section'], |
75 | 75 | 'name' => $setup_args['config_name'] |
76 | 76 | ); |
77 | 77 | |
78 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
79 | - add_action( 'AHEE__EE_Config__update_espresso_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
78 | + add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
79 | + add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * @param \EE_Config $EE_Config |
91 | 91 | * @return \StdClass |
92 | 92 | */ |
93 | - public static function set_config( EE_Config $EE_Config ) { |
|
94 | - foreach ( self::$_ee_config_registry as $config_class => $settings ) { |
|
93 | + public static function set_config(EE_Config $EE_Config) { |
|
94 | + foreach (self::$_ee_config_registry as $config_class => $settings) { |
|
95 | 95 | //first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
96 | - if ( ! class_exists( $config_class )) { |
|
96 | + if ( ! class_exists($config_class)) { |
|
97 | 97 | throw new EE_Error( |
98 | 98 | sprintf( |
99 | - __( 'The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso' ), |
|
99 | + __('The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso'), |
|
100 | 100 | $config_class |
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
104 | - $EE_Config->get_config( $settings['section'], $settings['name'], $config_class ); |
|
104 | + $EE_Config->get_config($settings['section'], $settings['name'], $config_class); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * @param mixed $config_class_name |
113 | 113 | */ |
114 | - public static function deregister( $config_class_name = NULL ) { |
|
115 | - if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
|
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
114 | + public static function deregister($config_class_name = NULL) { |
|
115 | + if ( ! empty(self::$_ee_config_registry[$config_class_name])) |
|
116 | + unset(self::$_ee_config_registry[$config_class_name]); |
|
117 | 117 | } |
118 | 118 | } |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | protected static $_event = NULL; |
36 | 36 | |
37 | 37 | /** |
38 | - * array of datetimes and the spaces available for them |
|
39 | - * |
|
40 | - * @access private |
|
41 | - * @var array |
|
42 | - */ |
|
38 | + * array of datetimes and the spaces available for them |
|
39 | + * |
|
40 | + * @access private |
|
41 | + * @var array |
|
42 | + */ |
|
43 | 43 | private static $_available_spaces = array(); |
44 | 44 | |
45 | 45 | |
@@ -855,11 +855,11 @@ discard block |
||
855 | 855 | |
856 | 856 | |
857 | 857 | /** |
858 | - * load js |
|
859 | - * |
|
860 | - * @access public |
|
861 | - * @return void |
|
862 | - */ |
|
858 | + * load js |
|
859 | + * |
|
860 | + * @access public |
|
861 | + * @return void |
|
862 | + */ |
|
863 | 863 | public static function load_tckt_slctr_assets() { |
864 | 864 | // add some style |
865 | 865 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | * @return EED_Ticket_Selector |
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | - return parent::get_instance( __CLASS__ ); |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function set_config(){ |
|
66 | - $this->set_config_section( 'template_settings' ); |
|
67 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
68 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
65 | + protected function set_config() { |
|
66 | + $this->set_config_section('template_settings'); |
|
67 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
68 | + $this->set_config_name('EED_Ticket_Selector'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function set_hooks() { |
82 | 82 | // routing |
83 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
84 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
85 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
83 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
84 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
85 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
86 | 86 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
87 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
87 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
88 | 88 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
89 | 89 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
90 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
90 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function set_hooks_admin() { |
102 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
102 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
103 | 103 | //add button for iframe code to event editor. |
104 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
105 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
104 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
105 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | */ |
116 | 116 | public static function set_definitions() { |
117 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
118 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
117 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
118 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
119 | 119 | |
120 | 120 | //if config is not set, initialize |
121 | 121 | //If config is not set, set it. |
122 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
122 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
123 | 123 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
124 | 124 | } |
125 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
125 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param object $WP |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function run( $WP ) {} |
|
136 | + public function run($WP) {} |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | public function ticket_selector_iframe() { |
146 | 146 | self::$_in_iframe = true; |
147 | 147 | /** @type EEM_Event $EEM_Event */ |
148 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
148 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
149 | 149 | $event = $EEM_Event->get_one_by_ID( |
150 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
150 | + EE_Registry::instance()->REQ->get('event', 0) |
|
151 | 151 | ); |
152 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
153 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
152 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
153 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
154 | 154 | $template_args['css'] = apply_filters( |
155 | 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
156 | 156 | array( |
157 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
158 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
159 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
160 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
157 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
158 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
159 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
160 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
161 | 161 | ) |
162 | 162 | ); |
163 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
164 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
163 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
164 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
165 | 165 | $template_args['eei18n'] = apply_filters( |
166 | 166 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
167 | 167 | EE_Registry::localize_i18n_js_strings() |
@@ -169,19 +169,19 @@ discard block |
||
169 | 169 | $template_args['js'] = apply_filters( |
170 | 170 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
171 | 171 | array( |
172 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
173 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
174 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
172 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
173 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
174 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | EE_Registry::instance()->load_helper('Template'); |
178 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
179 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
178 | + $template_args['notices'] = EEH_Template::display_template( |
|
179 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
180 | 180 | array(), |
181 | 181 | true |
182 | 182 | ); |
183 | 183 | EEH_Template::display_template( |
184 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
184 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
185 | 185 | $template_args |
186 | 186 | ); |
187 | 187 | exit; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string The new html string for the permalink area. |
202 | 202 | */ |
203 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
203 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
204 | 204 | //make sure this is ONLY when editing and the event id has been set. |
205 | - if ( ! empty( $id ) ) { |
|
206 | - $post = get_post( $id ); |
|
205 | + if ( ! empty($id)) { |
|
206 | + $post = get_post($id); |
|
207 | 207 | |
208 | 208 | //if NOT event then let's get out. |
209 | - if ( $post->post_type !== 'espresso_events' ) { |
|
209 | + if ($post->post_type !== 'espresso_events') { |
|
210 | 210 | return $permalink_string; |
211 | 211 | } |
212 | 212 | |
213 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
213 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
214 | 214 | |
215 | - $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' . __('Embed', 'event_espresso') . '</a> '; |
|
215 | + $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">'.__('Embed', 'event_espresso').'</a> '; |
|
216 | 216 | $permalink_string .= ' |
217 | 217 | <div id="js-ts-iframe" style="display:none"> |
218 | 218 | <div style="width:100%; height: 500px;"> |
219 | - <iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe> |
|
219 | + <iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe> |
|
220 | 220 | </div> |
221 | 221 | </div>'; |
222 | 222 | } |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * @param mixed $event |
236 | 236 | * @return bool |
237 | 237 | */ |
238 | - protected static function set_event( $event = null ) { |
|
239 | - if( $event === null ) { |
|
238 | + protected static function set_event($event = null) { |
|
239 | + if ($event === null) { |
|
240 | 240 | global $post; |
241 | 241 | $event = $post; |
242 | 242 | } |
243 | - if ( $event instanceof EE_Event ) { |
|
243 | + if ($event instanceof EE_Event) { |
|
244 | 244 | self::$_event = $event; |
245 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
245 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
246 | 246 | self::$_event = $event->EE_Event; |
247 | - } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
|
248 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
247 | + } else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') { |
|
248 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
249 | 249 | self::$_event = $event->EE_Event; |
250 | 250 | } else { |
251 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
252 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
253 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
251 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
252 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
253 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | return true; |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * @param bool $view_details |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
272 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
273 | 273 | // reset filter for displaying submit button |
274 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
274 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
275 | 275 | // poke and prod incoming event till it tells us what it is |
276 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
276 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | && ( |
285 | 285 | ! self::$_event->display_ticket_selector() |
286 | 286 | || $view_details |
287 | - || post_password_required( $event_post ) |
|
287 | + || post_password_required($event_post) |
|
288 | 288 | || ( |
289 | 289 | $_event_active_status != EE_Datetime::active |
290 | 290 | && $_event_active_status != EE_Datetime::upcoming |
@@ -302,70 +302,70 @@ discard block |
||
302 | 302 | $template_args = array(); |
303 | 303 | $template_args['event_status'] = $_event_active_status; |
304 | 304 | |
305 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
306 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
305 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
306 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
307 | 307 | |
308 | 308 | $template_args['EVT_ID'] = self::$_event->ID(); |
309 | 309 | $template_args['event'] = self::$_event; |
310 | 310 | |
311 | 311 | // is the event expired ? |
312 | 312 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
313 | - if ( $template_args['event_is_expired'] ) { |
|
314 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
313 | + if ($template_args['event_is_expired']) { |
|
314 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | $ticket_query_args = array( |
318 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
319 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
318 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
319 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
320 | 320 | ); |
321 | 321 | |
322 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
322 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
323 | 323 | //use the correct applicable time query depending on what version of core is being run. |
324 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
325 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
324 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
325 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | // get all tickets for this event ordered by the datetime |
329 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
329 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
330 | 330 | |
331 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
332 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
331 | + if (count($template_args['tickets']) < 1) { |
|
332 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
336 | - $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
|
337 | - if ( $template_args['max_atndz'] < 1 ) { |
|
338 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
339 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
340 | - $sales_closed_msg .= sprintf( |
|
341 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
336 | + $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); |
|
337 | + if ($template_args['max_atndz'] < 1) { |
|
338 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
339 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
340 | + $sales_closed_msg .= sprintf( |
|
341 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
342 | 342 | '<div class="ee-attention" style="text-align: left;"><b>', |
343 | 343 | '</b><br />', |
344 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
344 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
345 | 345 | '</a></span></div>' |
346 | 346 | ); |
347 | 347 | } |
348 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
348 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
349 | 349 | } |
350 | 350 | |
351 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
352 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
351 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
352 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
353 | 353 | |
354 | 354 | // redirecting to another site for registration ?? |
355 | 355 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
356 | 356 | // set up the form (but not for the admin) |
357 | - $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
|
357 | + $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; |
|
358 | 358 | // if not redirecting to another site for registration |
359 | - if ( ! $external_url ) { |
|
360 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
361 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
359 | + if ( ! $external_url) { |
|
360 | + EE_Registry::instance()->load_helper('Template'); |
|
361 | + EE_Registry::instance()->load_helper('URL'); |
|
362 | 362 | // then display the ticket selector |
363 | - $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
363 | + $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
364 | 364 | } else { |
365 | 365 | // if not we still need to trigger the display of the submit button |
366 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
366 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
367 | 367 | //display notice to admin that registration is external |
368 | - $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
368 | + $ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
369 | 369 | } |
370 | 370 | // submit button and form close tag |
371 | 371 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -385,27 +385,27 @@ discard block |
||
385 | 385 | * @param string $external_url |
386 | 386 | * @return string |
387 | 387 | */ |
388 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
388 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
389 | 389 | // if redirecting, we don't need any anything else |
390 | - if ( $external_url ) { |
|
391 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
392 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
393 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
394 | - foreach ( $query_args as $query_arg => $value ) { |
|
395 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
390 | + if ($external_url) { |
|
391 | + EE_Registry::instance()->load_helper('URL'); |
|
392 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
393 | + $query_args = EEH_URL::get_query_string($external_url); |
|
394 | + foreach ($query_args as $query_arg => $value) { |
|
395 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
396 | 396 | } |
397 | 397 | return $html; |
398 | 398 | } |
399 | - EE_Registry::instance()->load_helper( 'Event_View' ); |
|
400 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
401 | - if ( ! $checkout_url ) { |
|
402 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
399 | + EE_Registry::instance()->load_helper('Event_View'); |
|
400 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
401 | + if ( ! $checkout_url) { |
|
402 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
403 | 403 | } |
404 | 404 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
405 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
406 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
|
405 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
406 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); |
|
407 | 407 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
408 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
408 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
409 | 409 | return $html; |
410 | 410 | } |
411 | 411 | |
@@ -420,21 +420,21 @@ discard block |
||
420 | 420 | * @return string |
421 | 421 | */ |
422 | 422 | public static function display_ticket_selector_submit() { |
423 | - if ( ! is_admin() ) { |
|
424 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
|
423 | + if ( ! is_admin()) { |
|
424 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) { |
|
425 | 425 | $btn_text = apply_filters( |
426 | 426 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
427 | - __('Register Now', 'event_espresso' ), |
|
427 | + __('Register Now', 'event_espresso'), |
|
428 | 428 | self::$_event |
429 | 429 | ); |
430 | - $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
|
430 | + $html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"'; |
|
431 | 431 | $html .= ' class="ticket-selector-submit-btn ticket-selector-submit-ajax"'; |
432 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
433 | - $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
|
432 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
433 | + $html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event); |
|
434 | 434 | $html .= '<div class="clear"><br/></div></form>'; |
435 | 435 | return $html; |
436 | - } else if ( is_archive() ) { |
|
437 | - return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
|
436 | + } else if (is_archive()) { |
|
437 | + return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn(); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | return ''; |
@@ -466,13 +466,13 @@ discard block |
||
466 | 466 | * @return string |
467 | 467 | */ |
468 | 468 | public static function display_view_details_btn() { |
469 | - if ( ! self::$_event->get_permalink() ) { |
|
470 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
469 | + if ( ! self::$_event->get_permalink()) { |
|
470 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
471 | 471 | } |
472 | - $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
|
473 | - $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
|
474 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
475 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
472 | + $view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">'; |
|
473 | + $btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event); |
|
474 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
475 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
476 | 476 | $view_details_btn .= '<div class="clear"><br/></div>'; |
477 | 477 | $view_details_btn .= '</form>'; |
478 | 478 | return $view_details_btn; |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | * @return array or FALSE |
492 | 492 | */ |
493 | 493 | public function process_ticket_selections() { |
494 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
494 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
495 | 495 | // check nonce |
496 | - if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) { |
|
496 | + if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) { |
|
497 | 497 | EE_Error::add_error( |
498 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
498 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
499 | 499 | __FILE__, __FUNCTION__, __LINE__ |
500 | 500 | ); |
501 | 501 | return FALSE; |
@@ -509,16 +509,16 @@ discard block |
||
509 | 509 | |
510 | 510 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
511 | 511 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
512 | - EE_Registry::instance()->load_core( 'Session' ); |
|
512 | + EE_Registry::instance()->load_core('Session'); |
|
513 | 513 | // unless otherwise requested, clear the session |
514 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
515 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
514 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
515 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
516 | 516 | } |
517 | 517 | //d( EE_Registry::instance()->SSN ); |
518 | 518 | |
519 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
519 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
520 | 520 | // do we have an event id? |
521 | - if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
521 | + if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
522 | 522 | // validate/sanitize data |
523 | 523 | $valid = self::_validate_post_data(); |
524 | 524 | |
@@ -528,43 +528,43 @@ discard block |
||
528 | 528 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
529 | 529 | |
530 | 530 | //check total tickets ordered vs max number of attendees that can register |
531 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
531 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
532 | 532 | |
533 | 533 | // ordering too many tickets !!! |
534 | 534 | $singular = 'You have attempted to purchase %s ticket.'; |
535 | 535 | $plural = 'You have attempted to purchase %s tickets.'; |
536 | - $limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] ); |
|
536 | + $limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']); |
|
537 | 537 | // dev only message |
538 | 538 | $singular = 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
539 | 539 | $plural = 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
540 | - $limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] ); |
|
541 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
540 | + $limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']); |
|
541 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
542 | 542 | } else { |
543 | 543 | |
544 | 544 | // all data appears to be valid |
545 | 545 | $tckts_slctd = FALSE; |
546 | 546 | $success = TRUE; |
547 | 547 | // load cart |
548 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
548 | + EE_Registry::instance()->load_core('Cart'); |
|
549 | 549 | |
550 | 550 | // cycle thru the number of data rows sent from the event listing |
551 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
551 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
552 | 552 | // does this row actually contain a ticket quantity? |
553 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
553 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
554 | 554 | // YES we have a ticket quantity |
555 | 555 | $tckts_slctd = TRUE; |
556 | 556 | // d( $valid['ticket_obj'][$x] ); |
557 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
557 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
558 | 558 | // then add ticket to cart |
559 | - $ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
559 | + $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
560 | 560 | $success = ! $ticket_added ? FALSE : $success; |
561 | - if ( EE_Error::has_error() ) { |
|
561 | + if (EE_Error::has_error()) { |
|
562 | 562 | break; |
563 | 563 | } |
564 | 564 | } else { |
565 | 565 | // nothing added to cart retrieved |
566 | 566 | EE_Error::add_error( |
567 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
567 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
568 | 568 | __FILE__, __FUNCTION__, __LINE__ |
569 | 569 | ); |
570 | 570 | } |
@@ -573,45 +573,45 @@ discard block |
||
573 | 573 | //d( EE_Registry::instance()->CART ); |
574 | 574 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
575 | 575 | |
576 | - if ( $tckts_slctd ) { |
|
577 | - if ( $success ) { |
|
578 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
576 | + if ($tckts_slctd) { |
|
577 | + if ($success) { |
|
578 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
579 | 579 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
580 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
580 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
581 | 581 | EE_Registry::instance()->SSN->update(); |
582 | 582 | //d( EE_Registry::instance()->CART ); |
583 | 583 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
584 | 584 | // just return TRUE for registrations being made from admin |
585 | - if ( is_admin() ) { |
|
585 | + if (is_admin()) { |
|
586 | 586 | return TRUE; |
587 | 587 | } |
588 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
588 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
589 | 589 | exit(); |
590 | 590 | |
591 | 591 | } else { |
592 | - if ( ! EE_Error::has_error() ) { |
|
592 | + if ( ! EE_Error::has_error()) { |
|
593 | 593 | // nothing added to cart |
594 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
594 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | |
598 | 598 | } else { |
599 | 599 | // no ticket quantities were selected |
600 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
600 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
604 | 604 | // at this point, just return if registration is being made from admin |
605 | - if ( is_admin() ) { |
|
605 | + if (is_admin()) { |
|
606 | 606 | return FALSE; |
607 | 607 | } |
608 | - if ( $valid['return_url'] ) { |
|
609 | - EE_Error::get_notices( FALSE, TRUE ); |
|
610 | - wp_safe_redirect( $valid['return_url'] ); |
|
608 | + if ($valid['return_url']) { |
|
609 | + EE_Error::get_notices(FALSE, TRUE); |
|
610 | + wp_safe_redirect($valid['return_url']); |
|
611 | 611 | exit(); |
612 | - } elseif ( isset( $event_to_add['id'] )) { |
|
613 | - EE_Error::get_notices( FALSE, TRUE ); |
|
614 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
612 | + } elseif (isset($event_to_add['id'])) { |
|
613 | + EE_Error::get_notices(FALSE, TRUE); |
|
614 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
615 | 615 | exit(); |
616 | 616 | } else { |
617 | 617 | echo EE_Error::get_notices(); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | } else { |
621 | 621 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
622 | 622 | EE_Error::add_error( |
623 | - sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
623 | + sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
624 | 624 | __FILE__, __FUNCTION__, __LINE__ |
625 | 625 | ); |
626 | 626 | } |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | * @return array or FALSE |
639 | 639 | */ |
640 | 640 | private static function _validate_post_data() { |
641 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
641 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
642 | 642 | |
643 | 643 | // start with an empty array() |
644 | 644 | $valid_data = array(); |
645 | 645 | // d( $_POST ); |
646 | 646 | //if event id is valid |
647 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' )); |
|
648 | - if ( $id ) { |
|
647 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
648 | + if ($id) { |
|
649 | 649 | // grab valid id |
650 | 650 | $valid_data['id'] = $id; |
651 | 651 | // grab and sanitize return-url |
652 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
652 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
653 | 653 | // array of other form names |
654 | 654 | $inputs_to_clean = array( |
655 | 655 | 'event_id' => 'tkt-slctr-event-id', |
@@ -662,22 +662,22 @@ discard block |
||
662 | 662 | // let's track the total number of tickets ordered.' |
663 | 663 | $valid_data['total_tickets'] = 0; |
664 | 664 | // cycle through $inputs_to_clean array |
665 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
665 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
666 | 666 | // check for POST data |
667 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
667 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
668 | 668 | // grab value |
669 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
669 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
670 | 670 | switch ($what) { |
671 | 671 | |
672 | 672 | // integers |
673 | 673 | case 'event_id': |
674 | - $valid_data[$what] = absint( $input_value ); |
|
674 | + $valid_data[$what] = absint($input_value); |
|
675 | 675 | // get event via the event id we put in the form |
676 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
676 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
677 | 677 | break; |
678 | 678 | case 'rows': |
679 | 679 | case 'max_atndz': |
680 | - $valid_data[$what] = absint( $input_value ); |
|
680 | + $valid_data[$what] = absint($input_value); |
|
681 | 681 | break; |
682 | 682 | |
683 | 683 | // arrays of integers |
@@ -685,27 +685,27 @@ discard block |
||
685 | 685 | // d( $input_value ); |
686 | 686 | $row_qty = $input_value; |
687 | 687 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
688 | - if( ! is_array( $row_qty )) { |
|
688 | + if ( ! is_array($row_qty)) { |
|
689 | 689 | // get number of rows |
690 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
690 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
691 | 691 | // d( $rows ); |
692 | 692 | // explode ints by the dash |
693 | - $row_qty = explode( '-', $row_qty ); |
|
694 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
695 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
696 | - $row_qty = array( $row => $qty ); |
|
693 | + $row_qty = explode('-', $row_qty); |
|
694 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
695 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
696 | + $row_qty = array($row => $qty); |
|
697 | 697 | // d( $row_qty ); |
698 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
699 | - if ( ! isset( $row_qty[$x] )) { |
|
698 | + for ($x = 1; $x <= $rows; $x++) { |
|
699 | + if ( ! isset($row_qty[$x])) { |
|
700 | 700 | $row_qty[$x] = 0; |
701 | 701 | } |
702 | 702 | } |
703 | 703 | } |
704 | - ksort( $row_qty ); |
|
704 | + ksort($row_qty); |
|
705 | 705 | // d( $row_qty ); |
706 | 706 | // cycle thru values |
707 | - foreach ( $row_qty as $qty ) { |
|
708 | - $qty = absint( $qty ); |
|
707 | + foreach ($row_qty as $qty) { |
|
708 | + $qty = absint($qty); |
|
709 | 709 | // sanitize as integers |
710 | 710 | $valid_data[$what][] = $qty; |
711 | 711 | $valid_data['total_tickets'] += $qty; |
@@ -716,19 +716,19 @@ discard block |
||
716 | 716 | case 'ticket_id': |
717 | 717 | $value_array = array(); |
718 | 718 | // cycle thru values |
719 | - foreach ( $input_value as $key=>$value ) { |
|
719 | + foreach ($input_value as $key=>$value) { |
|
720 | 720 | // allow only numbers, letters, spaces, commas and dashes |
721 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
721 | + $value_array[$key] = wp_strip_all_tags($value); |
|
722 | 722 | // get ticket via the ticket id we put in the form |
723 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
724 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
723 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
724 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
725 | 725 | } |
726 | - $valid_data[ $what ] = $value_array; |
|
726 | + $valid_data[$what] = $value_array; |
|
727 | 727 | break; |
728 | 728 | |
729 | 729 | case 'return_url' : |
730 | 730 | // grab and sanitize return-url |
731 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
731 | + $valid_data[$what] = esc_url_raw($input_value); |
|
732 | 732 | break; |
733 | 733 | |
734 | 734 | } // end switch $what |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | } // end foreach $inputs_to_clean |
737 | 737 | |
738 | 738 | } else { |
739 | - EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
739 | + EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
740 | 740 | return FALSE; |
741 | 741 | } |
742 | 742 | |
@@ -754,28 +754,28 @@ discard block |
||
754 | 754 | * @param int $qty |
755 | 755 | * @return TRUE on success, FALSE on fail |
756 | 756 | */ |
757 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
758 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
757 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
758 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
759 | 759 | // get the number of spaces left for this datetime ticket |
760 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
760 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
761 | 761 | // compare available spaces against the number of tickets being purchased |
762 | - if ( $available_spaces >= $qty ) { |
|
762 | + if ($available_spaces >= $qty) { |
|
763 | 763 | // allow addons to prevent a ticket from being added to cart |
764 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) { |
|
764 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) { |
|
765 | 765 | return false; |
766 | 766 | } |
767 | 767 | // add event to cart |
768 | - if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
769 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
768 | + if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
769 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
770 | 770 | return true; |
771 | 771 | } else { |
772 | 772 | return false; |
773 | 773 | } |
774 | 774 | } else { |
775 | 775 | // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets |
776 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
776 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
777 | 777 | // greedy greedy greedy eh? |
778 | - if ( $available_spaces > 0 ) { |
|
778 | + if ($available_spaces > 0) { |
|
779 | 779 | // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces |
780 | 780 | EE_Error::add_error( |
781 | 781 | sprintf( |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | __FILE__, __FUNCTION__, __LINE__ |
792 | 792 | ); |
793 | 793 | } else { |
794 | - EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
794 | + EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
795 | 795 | } |
796 | 796 | return false; |
797 | 797 | } |
@@ -809,22 +809,22 @@ discard block |
||
809 | 809 | * @param bool $get_original_ticket_spaces |
810 | 810 | * @return int |
811 | 811 | */ |
812 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
812 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
813 | 813 | // if the $_available_spaces array has not been set up yet... |
814 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
815 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
814 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
815 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
816 | 816 | } |
817 | 817 | $available_spaces = $ticket->qty() - $ticket->sold(); |
818 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
818 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
819 | 819 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
820 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
820 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
821 | 821 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
822 | - if ( $get_original_ticket_spaces ) { |
|
822 | + if ($get_original_ticket_spaces) { |
|
823 | 823 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
824 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
824 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
825 | 825 | } else { |
826 | 826 | // we want the updated ticket availability as stored in the "datetimes" array |
827 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
827 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 | } |
@@ -840,23 +840,23 @@ discard block |
||
840 | 840 | * @param EE_Ticket $ticket |
841 | 841 | * @return int |
842 | 842 | */ |
843 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
843 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
844 | 844 | // first, get all of the datetimes that are available to this ticket |
845 | 845 | $datetimes = $ticket->get_many_related( |
846 | 846 | 'Datetime', |
847 | - array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' )) |
|
847 | + array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC')) |
|
848 | 848 | ); |
849 | - if ( ! empty( $datetimes )) { |
|
849 | + if ( ! empty($datetimes)) { |
|
850 | 850 | // now loop thru all of the datetimes |
851 | - foreach ( $datetimes as $datetime ) { |
|
852 | - if ( $datetime instanceof EE_Datetime ) { |
|
851 | + foreach ($datetimes as $datetime) { |
|
852 | + if ($datetime instanceof EE_Datetime) { |
|
853 | 853 | // the number of spaces available for the datetime without considering individual ticket quantities |
854 | 854 | $spaces_remaining = $datetime->spaces_remaining(); |
855 | 855 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
856 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
856 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
857 | 857 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
858 | 858 | // else just take the datetime spaces remaining, and assign to the datetimes array |
859 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
859 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | } |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | * @param int $qty |
873 | 873 | * @return int |
874 | 874 | */ |
875 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
876 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
875 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
876 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
877 | 877 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
878 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
878 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
879 | 879 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
880 | - self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty; |
|
880 | + self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty; |
|
881 | 881 | } |
882 | 882 | } |
883 | 883 | } |
@@ -894,8 +894,8 @@ discard block |
||
894 | 894 | */ |
895 | 895 | public static function load_tckt_slctr_assets() { |
896 | 896 | // add some style |
897 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
898 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
897 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
898 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
899 | 899 | wp_enqueue_style('ticket_selector'); |
900 | 900 | // make it dance |
901 | 901 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -909,9 +909,9 @@ discard block |
||
909 | 909 | |
910 | 910 | public static function load_tckt_slctr_assets_admin() { |
911 | 911 | //iframe button js on admin event editor page |
912 | - if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) { |
|
913 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
914 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
912 | + if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') { |
|
913 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
914 | + wp_enqueue_script('ticket_selector_embed'); |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * @param \EE_Registration $item |
333 | 333 | * @return string |
334 | 334 | */ |
335 | - function column_cb($item){ |
|
335 | + function column_cb($item){ |
|
336 | 336 | /** checkbox/lock **/ |
337 | 337 | $transaction = $item->get_first_related( 'Transaction' ); |
338 | 338 | $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related( 'Payment' ) : 0; |
339 | 339 | return $payment_count > 0 ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) . '<span class="ee-lock-icon"></span>' : sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ); |
340 | - } |
|
340 | + } |
|
341 | 341 | |
342 | 342 | |
343 | 343 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | function column__REG_date(EE_Registration $item){ |
373 | 373 | $this->_set_related_details($item); |
374 | - //Build row actions |
|
374 | + //Build row actions |
|
375 | 375 | $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
376 | 376 | $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_lnk_url.'" title="' . esc_attr( $this->_transaction_details['title_attr'] ) . '">' . $item->get_i18n_datetime( 'REG_date' ) . '</a>' : $item->get_i18n_datetime( 'REG_date' ); |
377 | 377 | $view_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $this->_transaction_details['status'], false, 'sentence' ) . '</span>'; |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | } else { |
424 | 424 | return __( 'There is no ticket on this registration', 'event_espresso' ); |
425 | 425 | } |
426 | - } |
|
426 | + } |
|
427 | 427 | |
428 | 428 | |
429 | 429 | |
@@ -445,14 +445,14 @@ discard block |
||
445 | 445 | $t = $item->get_first_related('Transaction'); |
446 | 446 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
447 | 447 | |
448 | - //append group count to name |
|
449 | - $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
448 | + //append group count to name |
|
449 | + $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
450 | 450 | |
451 | - //append reg_code |
|
452 | - $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
451 | + //append reg_code |
|
452 | + $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
453 | 453 | |
454 | - //reg status text for accessibility |
|
455 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
454 | + //reg status text for accessibility |
|
455 | + $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
456 | 456 | |
457 | 457 | //trash/restore/delete actions |
458 | 458 | $actions = array(); |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | * @param \EE_Admin_Page $admin_page |
58 | 58 | * @return EE_Registrations_List_Table |
59 | 59 | */ |
60 | - function __construct( $admin_page ){ |
|
60 | + function __construct($admin_page) { |
|
61 | 61 | |
62 | - if ( ! empty( $_GET['event_id'] ) ) { |
|
62 | + if ( ! empty($_GET['event_id'])) { |
|
63 | 63 | $extra_query_args = array(); |
64 | - foreach ( $admin_page->get_views() as $key => $view_details ) { |
|
65 | - $extra_query_args[$view_details['slug']] = array( 'event_id' => $_GET['event_id'] ); |
|
64 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
65 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
66 | 66 | } |
67 | - $this->_views = $admin_page->get_list_table_view_RLs( $extra_query_args ); |
|
67 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | parent::__construct($admin_page); |
71 | 71 | $this->_status = $this->_admin_page->get_registration_status_array(); |
72 | 72 | |
73 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
73 | + EE_Registry::instance()->load_helper('Template'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @return void |
82 | 82 | */ |
83 | 83 | protected function _setup_data() { |
84 | - $this->_data = $this->_admin_page->get_registrations( $this->_per_page ); |
|
85 | - $this->_all_data_count = $this->_admin_page->get_registrations( $this->_per_page, TRUE, FALSE, FALSE ); |
|
84 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
85 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, TRUE, FALSE, FALSE); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -101,45 +101,45 @@ discard block |
||
101 | 101 | ); |
102 | 102 | |
103 | 103 | |
104 | - if ( isset( $_GET['event_id'] )) { |
|
104 | + if (isset($_GET['event_id'])) { |
|
105 | 105 | $this->_columns = array( |
106 | 106 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
107 | - '_REG_ID' => __( 'ID', 'event_espresso' ), |
|
108 | - 'ATT_fname' => __( 'Name', 'event_espresso' ), |
|
107 | + '_REG_ID' => __('ID', 'event_espresso'), |
|
108 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
109 | 109 | 'ATT_email' => __('Email', 'event_espresso'), |
110 | - '_REG_date' => __( 'Reg Date', 'event_espresso' ), |
|
111 | - 'PRC_amount' => __( 'TKT Price', 'event_espresso' ), |
|
112 | - '_REG_final_price' => __( 'Final Price', 'event_espresso' ), |
|
113 | - 'TXN_total' => __( 'Total Txn', 'event_espresso' ), |
|
110 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
111 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
112 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
113 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
114 | 114 | 'TXN_paid' => __('Paid', 'event_espresso'), |
115 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
115 | + 'actions' => __('Actions', 'event_espresso') |
|
116 | 116 | ); |
117 | 117 | $this->_bottom_buttons = array( |
118 | 118 | 'report'=> array( |
119 | 119 | 'route' => 'registrations_report', |
120 | 120 | 'extra_request' => |
121 | 121 | array( |
122 | - 'EVT_ID'=> isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null, |
|
123 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ) ) |
|
122 | + 'EVT_ID'=> isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
123 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") ) |
|
124 | 124 | ), |
125 | 125 | ); |
126 | 126 | } else { |
127 | 127 | $this->_columns = array( |
128 | 128 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
129 | - '_REG_ID' => __( 'ID', 'event_espresso' ), |
|
130 | - 'ATT_fname' => __( 'Name', 'event_espresso' ), |
|
131 | - '_REG_date' => __( 'TXN Date', 'event_espresso' ), |
|
132 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
133 | - 'DTT_EVT_start' => __( 'Event Date', 'event_espresso' ), |
|
134 | - '_REG_final_price' => __( 'Price', 'event_espresso' ), |
|
135 | - '_REG_paid' => __( 'Paid', 'event_espresso' ), |
|
136 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
129 | + '_REG_ID' => __('ID', 'event_espresso'), |
|
130 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
131 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
132 | + 'event_name' => __('Event', 'event_espresso'), |
|
133 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
134 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
135 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
136 | + 'actions' => __('Actions', 'event_espresso') |
|
137 | 137 | ); |
138 | 138 | $this->_bottom_buttons = array( |
139 | 139 | 'report_all'=> array( |
140 | 140 | 'route' => 'registrations_report', |
141 | 141 | 'extra_request' => array( |
142 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ) ) |
|
142 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") ) |
|
143 | 143 | ), |
144 | 144 | ); |
145 | 145 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $this->_primary_column = '_REG_ID'; |
148 | 148 | |
149 | 149 | $this->_sortable_columns = array( |
150 | - '_REG_date' => array( '_REG_date' => TRUE ), //true means its already sorted |
|
151 | - 'ATT_fname' => array( 'ATT_fname' => FALSE ), |
|
152 | - 'event_name' => array( 'event_name' => FALSE ), |
|
153 | - 'DTT_EVT_start' => array( 'DTT_EVT_start' => FALSE ), |
|
154 | - '_REG_ID' => array( '_REG_ID' => FALSE ), |
|
150 | + '_REG_date' => array('_REG_date' => TRUE), //true means its already sorted |
|
151 | + 'ATT_fname' => array('ATT_fname' => FALSE), |
|
152 | + 'event_name' => array('event_name' => FALSE), |
|
153 | + 'DTT_EVT_start' => array('DTT_EVT_start' => FALSE), |
|
154 | + '_REG_ID' => array('_REG_ID' => FALSE), |
|
155 | 155 | ); |
156 | 156 | |
157 | 157 | $this->_hidden_columns = array(); |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - protected function _get_row_class( $item ) { |
|
164 | - $class = parent::_get_row_class( $item ); |
|
163 | + protected function _get_row_class($item) { |
|
164 | + $class = parent::_get_row_class($item); |
|
165 | 165 | //add status class |
166 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
167 | - if ( $this->_has_checkbox_column ) { |
|
166 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
167 | + if ($this->_has_checkbox_column) { |
|
168 | 168 | $class .= ' has-checkbox-column'; |
169 | 169 | } |
170 | 170 | return $class; |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @param EE_Registration $registration |
179 | 179 | */ |
180 | - protected function _set_related_details( EE_Registration $registration ) { |
|
180 | + protected function _set_related_details(EE_Registration $registration) { |
|
181 | 181 | |
182 | - $transaction = $registration->get_first_related( 'Transaction' ); |
|
182 | + $transaction = $registration->get_first_related('Transaction'); |
|
183 | 183 | $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() : EEM_Transaction::failed_status_code; |
184 | 184 | $this->_transaction_details = array( |
185 | 185 | 'transaction' => $transaction, |
186 | 186 | 'status' => $status, |
187 | 187 | 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
188 | - 'title_attr' => sprintf( __('View Transaction Details (%s)', 'event_espresso'), EEH_Template::pretty_status( $status, false, 'sentence' ) ) |
|
188 | + 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), EEH_Template::pretty_status($status, false, 'sentence')) |
|
189 | 189 | ); |
190 | 190 | |
191 | 191 | $event = $registration->event(); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | 'event' => $event, |
195 | 195 | 'status' => $status, |
196 | 196 | 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
197 | - 'title_attr' => sprintf( __('Edit Event (%s)', 'event_espresso'), EEH_Template::pretty_status( $status, false, 'sentence' ) ) |
|
197 | + 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), EEH_Template::pretty_status($status, false, 'sentence')) |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -209,26 +209,26 @@ discard block |
||
209 | 209 | $filters = array(); |
210 | 210 | |
211 | 211 | //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
212 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
212 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
213 | 213 | |
214 | - $cur_date = isset( $this->_req_data['month_range'] ) ? $this->_req_data['month_range'] : ''; |
|
215 | - $cur_category = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
216 | - $reg_status = isset( $this->_req_data['_reg_status'] ) ? $this->_req_data['_reg_status'] : ''; |
|
214 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
215 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
216 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
217 | 217 | |
218 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown( $cur_date, $reg_status, $cur_category ); |
|
219 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown( $cur_category ); |
|
218 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
219 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
220 | 220 | |
221 | 221 | $status = array(); |
222 | - $status[] = array( 'id' => 0, 'text' => __('Select Status', 'event_espresso') ); |
|
223 | - foreach ( $this->_status as $key => $value ) { |
|
224 | - $status[] = array( 'id' => $key, 'text' => $value ); |
|
222 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
223 | + foreach ($this->_status as $key => $value) { |
|
224 | + $status[] = array('id' => $key, 'text' => $value); |
|
225 | 225 | } |
226 | - if ( $this->_view != 'incomplete' ) { |
|
227 | - $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, isset( $this->_req_data['_reg_status'] ) ? strtoupper( sanitize_key( $this->_req_data['_reg_status'] )) : '' ); |
|
226 | + if ($this->_view != 'incomplete') { |
|
227 | + $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) : ''); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( isset( $this->_req_data['event_id'] ) ) { |
|
231 | - $filters[] = EEH_Form_Fields::hidden_input( 'event_id', $this->_req_data['event_id'], 'reg_event_id' ); |
|
230 | + if (isset($this->_req_data['event_id'])) { |
|
231 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | return $filters; |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | $this->_views['all']['count'] = $this->_total_registrations(); |
246 | 246 | $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
247 | 247 | $this->_views['today']['count'] = $this->_total_registrations_today(); |
248 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_trash_registrations' ) ) { |
|
249 | - $this->_views['incomplete']['count'] = $this->_total_registrations( 'incomplete' ); |
|
250 | - $this->_views['trash']['count'] = $this->_total_registrations( 'trash' ); |
|
248 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_trash_registrations')) { |
|
249 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
250 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -259,23 +259,23 @@ discard block |
||
259 | 259 | * @param string $view |
260 | 260 | * @return int |
261 | 261 | */ |
262 | - protected function _total_registrations( $view = '' ){ |
|
262 | + protected function _total_registrations($view = '') { |
|
263 | 263 | $_where = array(); |
264 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
265 | - if( $EVT_ID ) { |
|
264 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
265 | + if ($EVT_ID) { |
|
266 | 266 | $_where['EVT_ID'] = $EVT_ID; |
267 | 267 | } |
268 | - switch ( $view ) { |
|
268 | + switch ($view) { |
|
269 | 269 | case 'trash' : |
270 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
270 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
271 | 271 | break; |
272 | 272 | case 'incomplete' : |
273 | 273 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
274 | 274 | break; |
275 | 275 | default : |
276 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
276 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
277 | 277 | } |
278 | - return EEM_Registration::instance()->count( array( $_where )); |
|
278 | + return EEM_Registration::instance()->count(array($_where)); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | * @access protected |
286 | 286 | * @return int |
287 | 287 | */ |
288 | - protected function _total_registrations_this_month(){ |
|
289 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
290 | - $_where = $EVT_ID ? array( 'EVT_ID' => $EVT_ID ) : array(); |
|
288 | + protected function _total_registrations_this_month() { |
|
289 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
290 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
291 | 291 | $this_year_r = date('Y', current_time('timestamp')); |
292 | 292 | $time_start = ' 00:00:00'; |
293 | 293 | $time_end = ' 23:59:59'; |
294 | 294 | $this_month_r = date('m', current_time('timestamp')); |
295 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
295 | + $days_this_month = date('t', current_time('timestamp')); |
|
296 | 296 | //setup date query. |
297 | - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ); |
|
298 | - $end_string = EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ); |
|
299 | - $_where['REG_date']= array('BETWEEN', |
|
297 | + $beginning_string = EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'); |
|
298 | + $end_string = EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s'); |
|
299 | + $_where['REG_date'] = array('BETWEEN', |
|
300 | 300 | array( |
301 | 301 | $beginning_string, |
302 | 302 | $end_string |
303 | 303 | )); |
304 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
305 | - return EEM_Registration::instance()->count(array( $_where ) ); |
|
304 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
305 | + return EEM_Registration::instance()->count(array($_where)); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | * @access protected |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - protected function _total_registrations_today(){ |
|
315 | + protected function _total_registrations_today() { |
|
316 | 316 | |
317 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
318 | - $_where = $EVT_ID ? array( 'EVT_ID' => $EVT_ID ) : array(); |
|
317 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
318 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
319 | 319 | $current_date = date('Y-m-d', current_time('timestamp')); |
320 | 320 | $time_start = ' 00:00:00'; |
321 | 321 | $time_end = ' 23:59:59'; |
322 | - $_where['REG_date']= array('BETWEEN', |
|
322 | + $_where['REG_date'] = array('BETWEEN', |
|
323 | 323 | array( |
324 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $current_date . $time_start, 'Y-m-d H:i:s' ), |
|
325 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $current_date . $time_end, 'Y-m-d H:i:s' ) |
|
324 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'), |
|
325 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s') |
|
326 | 326 | )); |
327 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
328 | - return EEM_Registration::instance()->count(array( $_where ) ); |
|
327 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
328 | + return EEM_Registration::instance()->count(array($_where)); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | * @param \EE_Registration $item |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - function column_cb($item){ |
|
340 | + function column_cb($item) { |
|
341 | 341 | /** checkbox/lock **/ |
342 | - $transaction = $item->get_first_related( 'Transaction' ); |
|
343 | - $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related( 'Payment' ) : 0; |
|
344 | - return $payment_count > 0 ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) . '<span class="ee-lock-icon"></span>' : sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ); |
|
342 | + $transaction = $item->get_first_related('Transaction'); |
|
343 | + $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
344 | + return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()).'<span class="ee-lock-icon"></span>' : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -353,14 +353,14 @@ discard block |
||
353 | 353 | * @param \EE_Registration $item |
354 | 354 | * @return string |
355 | 355 | */ |
356 | - function column__REG_ID(EE_Registration $item){ |
|
356 | + function column__REG_ID(EE_Registration $item) { |
|
357 | 357 | $attendee = $item->attendee(); |
358 | 358 | $content = $item->ID(); |
359 | 359 | $content .= '<div class="show-on-mobile-view-only">'; |
360 | 360 | $content .= '<br>'; |
361 | 361 | $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
362 | - $content .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
363 | - $content .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
362 | + $content .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
363 | + $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
364 | 364 | $content .= '</div>'; |
365 | 365 | return $content; |
366 | 366 | } |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | * @param \EE_Registration $item |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - function column__REG_date(EE_Registration $item){ |
|
377 | + function column__REG_date(EE_Registration $item) { |
|
378 | 378 | $this->_set_related_details($item); |
379 | 379 | //Build row actions |
380 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
|
381 | - $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_lnk_url.'" title="' . esc_attr( $this->_transaction_details['title_attr'] ) . '">' . $item->get_i18n_datetime( 'REG_date' ) . '</a>' : $item->get_i18n_datetime( 'REG_date' ); |
|
382 | - $view_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $this->_transaction_details['status'], false, 'sentence' ) . '</span>'; |
|
380 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id']), TXN_ADMIN_URL); |
|
381 | + $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'.$this->_transaction_details['status'].'" href="'.$view_lnk_url.'" title="'.esc_attr($this->_transaction_details['title_attr']).'">'.$item->get_i18n_datetime('REG_date').'</a>' : $item->get_i18n_datetime('REG_date'); |
|
382 | + $view_link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence').'</span>'; |
|
383 | 383 | return $view_link; |
384 | 384 | } |
385 | 385 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | * @param \EE_Registration $item |
393 | 393 | * @return string |
394 | 394 | */ |
395 | - function column_event_name(EE_Registration $item){ |
|
396 | - $this->_set_related_details( $item ); |
|
395 | + function column_event_name(EE_Registration $item) { |
|
396 | + $this->_set_related_details($item); |
|
397 | 397 | // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
398 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$item->event_ID() ), EVENTS_ADMIN_URL ); |
|
398 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$item->event_ID()), EVENTS_ADMIN_URL); |
|
399 | 399 | $event_name = $item->event_name(); |
400 | 400 | $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
401 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $item->event_ID() ) ? '<a class="ee-status-color-' . $this->_event_details['status'] . '" href="' . $edit_event_url . '" title="' . esc_attr( $this->_event_details['title_attr'] ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ) ; |
|
401 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $item->event_ID()) ? '<a class="ee-status-color-'.$this->_event_details['status'].'" href="'.$edit_event_url.'" title="'.esc_attr($this->_event_details['title_attr']).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'); |
|
402 | 402 | |
403 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'event_id'=>$item->event_ID() ), REG_ADMIN_URL ); |
|
404 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Filter this list to only show registrations for %s', 'event_espresso' ), $event_name ) .'">' . __( 'View Registrations', 'event_espresso' ) . '</a>'; |
|
403 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id'=>$item->event_ID()), REG_ADMIN_URL); |
|
404 | + $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), $event_name).'">'.__('View Registrations', 'event_espresso').'</a>'; |
|
405 | 405 | |
406 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions) ); |
|
406 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -415,18 +415,18 @@ discard block |
||
415 | 415 | * @param \EE_Registration $item |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - function column_DTT_EVT_start(EE_Registration $item){ |
|
418 | + function column_DTT_EVT_start(EE_Registration $item) { |
|
419 | 419 | $datetime_strings = array(); |
420 | - $ticket = $item->ticket( TRUE ); |
|
421 | - if ( $ticket instanceof EE_Ticket ) { |
|
420 | + $ticket = $item->ticket(TRUE); |
|
421 | + if ($ticket instanceof EE_Ticket) { |
|
422 | 422 | $remove_defaults = array('default_where_conditions' => 'none'); |
423 | 423 | $datetimes = $ticket->datetimes($remove_defaults); |
424 | - foreach($datetimes as $datetime){ |
|
425 | - $datetime_strings[] = $datetime->get_i18n_datetime( 'DTT_EVT_start' ); |
|
424 | + foreach ($datetimes as $datetime) { |
|
425 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
426 | 426 | } |
427 | - return implode("<br />",$datetime_strings); |
|
427 | + return implode("<br />", $datetime_strings); |
|
428 | 428 | } else { |
429 | - return __( 'There is no ticket on this registration', 'event_espresso' ); |
|
429 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -439,45 +439,45 @@ discard block |
||
439 | 439 | * @param \EE_Registration $item |
440 | 440 | * @return string |
441 | 441 | */ |
442 | - function column_ATT_fname(EE_Registration $item){ |
|
442 | + function column_ATT_fname(EE_Registration $item) { |
|
443 | 443 | $attendee = $item->attendee(); |
444 | 444 | |
445 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
445 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
446 | 446 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
447 | - $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee_name . '</a>' : $attendee_name; |
|
447 | + $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee_name.'</a>' : $attendee_name; |
|
448 | 448 | $link .= $item->count() == 1 ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
449 | 449 | |
450 | 450 | $t = $item->get_first_related('Transaction'); |
451 | 451 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
452 | 452 | |
453 | 453 | //append group count to name |
454 | - $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
454 | + $link .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
455 | 455 | |
456 | 456 | //append reg_code |
457 | - $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
457 | + $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
458 | 458 | |
459 | 459 | //reg status text for accessibility |
460 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
460 | + $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
461 | 461 | |
462 | 462 | //trash/restore/delete actions |
463 | 463 | $actions = array(); |
464 | - if ( $this->_view != 'trash' && $payment_count === 0 && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_trash_registrations', $item->ID() ) ) { |
|
465 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
466 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Trash Registration', 'event_espresso' ) . '">' . __( 'Trash', 'event_espresso' ) . '</a>'; |
|
467 | - } elseif ( $this->_view == 'trash' ) { |
|
464 | + if ($this->_view != 'trash' && $payment_count === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_trash_registrations', $item->ID())) { |
|
465 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
466 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
467 | + } elseif ($this->_view == 'trash') { |
|
468 | 468 | // restore registration link |
469 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_restore_registrations', $item->ID() ) ) { |
|
470 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
471 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Registration', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
469 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_restore_registrations', $item->ID())) { |
|
470 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
471 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
472 | 472 | } |
473 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_ee_delete_registrations', $item->ID() ) ) { |
|
474 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
473 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_ee_delete_registrations', $item->ID())) { |
|
474 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
475 | 475 | |
476 | - $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Registration Permanently', 'event_espresso' ). '">' . __( 'Delete', 'event_espresso' ) . '</a>'; |
|
476 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Registration Permanently', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions) ); |
|
480 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @param \EE_Registration $item |
490 | 490 | * @return string |
491 | 491 | */ |
492 | - function column_ATT_email( EE_Registration $item ) { |
|
492 | + function column_ATT_email(EE_Registration $item) { |
|
493 | 493 | $attendee = $item->get_first_related('Attendee'); |
494 | 494 | return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') : $attendee->email(); |
495 | 495 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * @param \EE_Registration $item |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - function column__REG_count(EE_Registration $item){ |
|
507 | - return sprintf(__( '%1$s / %2$s', 'event_espresso' ), $item->count(), $item->group_size()); |
|
506 | + function column__REG_count(EE_Registration $item) { |
|
507 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -516,16 +516,16 @@ discard block |
||
516 | 516 | * @param \EE_Registration $item |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - function column_PRC_amount(EE_Registration $item){ |
|
519 | + function column_PRC_amount(EE_Registration $item) { |
|
520 | 520 | $ticket = $item->ticket(); |
521 | 521 | |
522 | - $content = isset( $_GET['event_id'] ) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' . $ticket->name() . '</span><br />' : ''; |
|
522 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'.$ticket->name().'</span><br />' : ''; |
|
523 | 523 | |
524 | - if ( $item->final_price() > 0 ) { |
|
525 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
524 | + if ($item->final_price() > 0) { |
|
525 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
526 | 526 | } else { |
527 | 527 | // free event |
528 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
528 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'.__('free', 'event_espresso').'</span>'; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | return $content; |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | * @param \EE_Registration $item |
542 | 542 | * @return string |
543 | 543 | */ |
544 | - function column__REG_final_price(EE_Registration $item){ |
|
544 | + function column__REG_final_price(EE_Registration $item) { |
|
545 | 545 | $ticket = $item->ticket(); |
546 | - $content = isset( $_GET['event_id'] ) || ! $ticket instanceof EE_Ticket ? '' : '<span class="TKT_name">' . $ticket->name() . '</span><br />'; |
|
546 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket ? '' : '<span class="TKT_name">'.$ticket->name().'</span><br />'; |
|
547 | 547 | |
548 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
548 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
549 | 549 | return $content; |
550 | 550 | |
551 | 551 | } |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @param \EE_Registration $item |
560 | 560 | * @return string |
561 | 561 | */ |
562 | - function column__REG_paid(EE_Registration $item){ |
|
563 | - return '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
562 | + function column__REG_paid(EE_Registration $item) { |
|
563 | + return '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>'; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | * @param \EE_Registration $item |
573 | 573 | * @return string |
574 | 574 | */ |
575 | - function column_TXN_total(EE_Registration $item){ |
|
576 | - if($item->transaction()){ |
|
577 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL ); |
|
578 | - return EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID() ) ? '<span class="reg-pad-rght"><a class="status-'. $item->transaction()->status_ID() .'" href="'.$view_txn_lnk_url.'" title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">' . $item->transaction()->pretty_total() . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
579 | - }else{ |
|
575 | + function column_TXN_total(EE_Registration $item) { |
|
576 | + if ($item->transaction()) { |
|
577 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL); |
|
578 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID()) ? '<span class="reg-pad-rght"><a class="status-'.$item->transaction()->status_ID().'" href="'.$view_txn_lnk_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'">'.$item->transaction()->pretty_total().'</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>'; |
|
579 | + } else { |
|
580 | 580 | return __("None", "event_espresso"); |
581 | 581 | } |
582 | 582 | } |
@@ -590,15 +590,15 @@ discard block |
||
590 | 590 | * @param \EE_Registration $item |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - function column_TXN_paid(EE_Registration $item){ |
|
593 | + function column_TXN_paid(EE_Registration $item) { |
|
594 | 594 | |
595 | - if ( $item->count() == 1 ) { |
|
595 | + if ($item->count() == 1) { |
|
596 | 596 | $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
597 | - if ( $transaction->paid() >= $transaction->total() ) { |
|
597 | + if ($transaction->paid() >= $transaction->total()) { |
|
598 | 598 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
599 | 599 | } else { |
600 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL ); |
|
601 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID() ) ? '<span class="reg-pad-rght"><a class="status-'. $transaction->status_ID() .'" href="'.$view_txn_lnk_url.'" title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">' . $item->transaction()->pretty_paid() . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
600 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL); |
|
601 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID()) ? '<span class="reg-pad-rght"><a class="status-'.$transaction->status_ID().'" href="'.$view_txn_lnk_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'">'.$item->transaction()->pretty_paid().'</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
@@ -619,44 +619,44 @@ discard block |
||
619 | 619 | EE_Registry::instance()->load_helper('MSG_Template'); |
620 | 620 | $attendee = $item->attendee(); |
621 | 621 | $ticket = $item->ticket(); |
622 | - $this->_set_related_details( $item ); |
|
622 | + $this->_set_related_details($item); |
|
623 | 623 | |
624 | 624 | //Build row actions |
625 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
626 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$item->attendee_ID() ), REG_ADMIN_URL ); |
|
625 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
626 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$item->attendee_ID()), REG_ADMIN_URL); |
|
627 | 627 | |
628 | 628 | // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
629 | 629 | //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
630 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL, true ); |
|
630 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'resend_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL, true); |
|
631 | 631 | |
632 | 632 | |
633 | 633 | //Build row actions |
634 | - $view_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? ' |
|
634 | + $view_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
635 | 635 | <li> |
636 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
636 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
637 | 637 | <div class="dashicons dashicons-clipboard"></div> |
638 | 638 | </a> |
639 | 639 | </li>' : ''; |
640 | 640 | |
641 | - $edit_lnk = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee' ) && $attendee instanceof EE_Attendee ?' |
|
641 | + $edit_lnk = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') && $attendee instanceof EE_Attendee ? ' |
|
642 | 642 | <li> |
643 | - <a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact Details', 'event_espresso' ) . '" class="tiny-text"> |
|
643 | + <a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text"> |
|
644 | 644 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
645 | 645 | </a> |
646 | 646 | </li>' : ''; |
647 | 647 | |
648 | - $resend_reg_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration', $item->ID() ) ? ' |
|
648 | + $resend_reg_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
649 | 649 | <li> |
650 | - <a href="'.$resend_reg_lnk_url.'" title="' . esc_attr__( 'Resend Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
650 | + <a href="'.$resend_reg_lnk_url.'" title="'.esc_attr__('Resend Registration Details', 'event_espresso').'" class="tiny-text"> |
|
651 | 651 | <div class="dashicons dashicons-email-alt"></div> |
652 | 652 | </a> |
653 | 653 | </li>' : ''; |
654 | 654 | |
655 | 655 | // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
656 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
|
657 | - $view_txn_lnk = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $this->_transaction_details['id'] ) ? ' |
|
656 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$this->_transaction_details['id']), TXN_ADMIN_URL); |
|
657 | + $view_txn_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
658 | 658 | <li> |
659 | - <a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_txn_lnk_url.'" title="' . $this->_transaction_details['title_attr'] . '" class="tiny-text"> |
|
659 | + <a class="ee-status-color-' . $this->_transaction_details['status'].'" href="'.$view_txn_lnk_url.'" title="'.$this->_transaction_details['title_attr'].'" class="tiny-text"> |
|
660 | 660 | <div class="dashicons dashicons-cart"></div> |
661 | 661 | </a> |
662 | 662 | </li>' : ''; |
@@ -664,10 +664,10 @@ discard block |
||
664 | 664 | //invoice link |
665 | 665 | $dl_invoice_lnk_url = $item->invoice_url(); |
666 | 666 | //only show invoice link if message type is active. |
667 | - if ( $item->is_primary_registrant() && $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
667 | + if ($item->is_primary_registrant() && $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
668 | 668 | $dl_invoice_lnk = ' |
669 | 669 | <li> |
670 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
670 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
671 | 671 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
672 | 672 | </a> |
673 | 673 | </li>'; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | $dl_invoice_lnk = ''; |
676 | 676 | } |
677 | 677 | |
678 | - return $this->_action_string( $view_lnk . $edit_lnk . $resend_reg_lnk . $view_txn_lnk . $dl_invoice_lnk, $item, 'ul', 'reg-overview-actions-ul' ); |
|
678 | + return $this->_action_string($view_lnk.$edit_lnk.$resend_reg_lnk.$view_txn_lnk.$dl_invoice_lnk, $item, 'ul', 'reg-overview-actions-ul'); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function instance() { |
130 | 130 | // check if class object is instantiated, and instantiated properly |
131 | - if ( ! self::$_instance instanceof EE_Config ) { |
|
131 | + if ( ! self::$_instance instanceof EE_Config) { |
|
132 | 132 | self::$_instance = new self(); |
133 | 133 | } |
134 | 134 | return self::$_instance; |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | * not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode) |
146 | 146 | * @return EE_Config |
147 | 147 | */ |
148 | - public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){ |
|
149 | - if ( $hard_reset ) { |
|
148 | + public static function reset($hard_reset = FALSE, $reinstantiate = TRUE) { |
|
149 | + if ($hard_reset) { |
|
150 | 150 | self::$_instance->_config_option_names = array(); |
151 | 151 | self::$_instance->_initialize_config(); |
152 | 152 | self::$_instance->update_espresso_config(); |
153 | 153 | } |
154 | - if( self::$_instance instanceof EE_Config ){ |
|
154 | + if (self::$_instance instanceof EE_Config) { |
|
155 | 155 | self::$_instance->shutdown(); |
156 | 156 | } |
157 | 157 | self::$_instance = NULL; |
158 | 158 | //we don't need to reset the static properties imo because those should |
159 | 159 | //only change when a module is added or removed. Currently we don't |
160 | 160 | //support removing a module during a request when it previously existed |
161 | - if( $reinstantiate ){ |
|
161 | + if ($reinstantiate) { |
|
162 | 162 | return self::instance(); |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | return NULL; |
165 | 165 | } |
166 | 166 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return \EE_Config |
175 | 175 | */ |
176 | 176 | private function __construct() { |
177 | - do_action( 'AHEE__EE_Config__construct__begin',$this ); |
|
178 | - $this->_config_option_names = get_option( 'ee_config_option_names', array() ); |
|
177 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
178 | + $this->_config_option_names = get_option('ee_config_option_names', array()); |
|
179 | 179 | // setup empty config classes |
180 | 180 | $this->_initialize_config(); |
181 | 181 | // load existing EE site settings |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | // confirm everything loaded correctly and set filtered defaults if not |
184 | 184 | $this->_verify_config(); |
185 | 185 | // register shortcodes and modules |
186 | - add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 ); |
|
186 | + add_action('AHEE__EE_System__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_and_modules'), 999); |
|
187 | 187 | // initialize shortcodes and modules |
188 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' )); |
|
188 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
189 | 189 | // register widgets |
190 | - add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
190 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
191 | 191 | // shutdown |
192 | - add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
192 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
193 | 193 | // construct__end hook |
194 | - do_action( 'AHEE__EE_Config__construct__end',$this ); |
|
194 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
195 | 195 | // hardcoded hack |
196 | 196 | $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return string current theme set. |
205 | 205 | */ |
206 | 206 | public static function get_current_theme() { |
207 | - return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
207 | + return isset(self::$_instance->template_settings->current_espresso_theme) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -238,27 +238,27 @@ discard block |
||
238 | 238 | */ |
239 | 239 | private function _load_core_config() { |
240 | 240 | // load_core_config__start hook |
241 | - do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
241 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
242 | 242 | $espresso_config = $this->get_espresso_config(); |
243 | - foreach ( $espresso_config as $config => $settings ) { |
|
243 | + foreach ($espresso_config as $config => $settings) { |
|
244 | 244 | // load_core_config__start hook |
245 | - $settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this ); |
|
246 | - if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
247 | - $this->$config = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
245 | + $settings = apply_filters('FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this); |
|
246 | + if (is_object($settings) && property_exists($this, $config)) { |
|
247 | + $this->$config = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
248 | 248 | //call configs populate method to ensure any defaults are set for empty values. |
249 | - if ( method_exists( $settings, 'populate' ) ) { |
|
249 | + if (method_exists($settings, 'populate')) { |
|
250 | 250 | $this->$config->populate(); |
251 | 251 | } |
252 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
252 | + if (method_exists($settings, 'do_hooks')) { |
|
253 | 253 | $this->$config->do_hooks(); |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | - if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) { |
|
257 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', FALSE)) { |
|
258 | 258 | $this->update_espresso_config(); |
259 | 259 | } |
260 | 260 | // load_core_config__end hook |
261 | - do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
261 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -272,40 +272,40 @@ discard block |
||
272 | 272 | protected function _verify_config() { |
273 | 273 | |
274 | 274 | $this->core = $this->core instanceof EE_Core_Config |
275 | - ? $this->core : new EE_Core_Config(); |
|
276 | - $this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
275 | + ? $this->core : new EE_Core_Config(); |
|
276 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
277 | 277 | |
278 | 278 | $this->organization = $this->organization instanceof EE_Organization_Config |
279 | - ? $this->organization : new EE_Organization_Config(); |
|
280 | - $this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
279 | + ? $this->organization : new EE_Organization_Config(); |
|
280 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization); |
|
281 | 281 | |
282 | 282 | $this->currency = $this->currency instanceof EE_Currency_Config |
283 | 283 | ? $this->currency : new EE_Currency_Config(); |
284 | - $this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
284 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
285 | 285 | |
286 | 286 | $this->registration = $this->registration instanceof EE_Registration_Config |
287 | 287 | ? $this->registration : new EE_Registration_Config(); |
288 | - $this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
288 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration); |
|
289 | 289 | |
290 | 290 | $this->admin = $this->admin instanceof EE_Admin_Config |
291 | 291 | ? $this->admin : new EE_Admin_Config(); |
292 | - $this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
292 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
293 | 293 | |
294 | 294 | $this->template_settings = $this->template_settings instanceof EE_Template_Config |
295 | 295 | ? $this->template_settings : new EE_Template_Config(); |
296 | - $this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings ); |
|
296 | + $this->template_settings = apply_filters('FHEE__EE_Config___initialize_config__template_settings', $this->template_settings); |
|
297 | 297 | |
298 | 298 | $this->map_settings = $this->map_settings instanceof EE_Map_Config |
299 | 299 | ? $this->map_settings : new EE_Map_Config(); |
300 | - $this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
300 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings); |
|
301 | 301 | |
302 | 302 | $this->environment = $this->environment instanceof EE_Environment_Config |
303 | 303 | ? $this->environment : new EE_Environment_Config(); |
304 | - $this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
304 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment); |
|
305 | 305 | |
306 | 306 | $this->gateway = $this->gateway instanceof EE_Gateway_Config |
307 | 307 | ? $this->gateway : new EE_Gateway_Config(); |
308 | - $this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
308 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
309 | 309 | |
310 | 310 | } |
311 | 311 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function get_espresso_config() { |
321 | 321 | // grab espresso configuration |
322 | - return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() )); |
|
322 | + return apply_filters('FHEE__EE_Config__get_espresso_config__CFG', get_option('ee_config', array())); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * @param $old_value |
333 | 333 | * @param $value |
334 | 334 | */ |
335 | - public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
335 | + public function double_check_config_comparison($option = '', $old_value, $value) { |
|
336 | 336 | // make sure we're checking the ee config |
337 | - if ( $option == 'ee_config' ) { |
|
337 | + if ($option == 'ee_config') { |
|
338 | 338 | // run a loose comparison of the old value against the new value for type and properties, |
339 | 339 | // but NOT exact instance like WP update_option does |
340 | - if ( $value != $old_value ) { |
|
340 | + if ($value != $old_value) { |
|
341 | 341 | // if they are NOT the same, then remove the hook, |
342 | 342 | // which means the subsequent update results will be based solely on the update query results |
343 | 343 | // the reason we do this is because, as stated above, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | // the string it sees in the db looks the same as the new one it has been passed!!! |
353 | 353 | // This results in the query returning an "affected rows" value of ZERO, |
354 | 354 | // which gets returned immediately by WP update_option and looks like an error. |
355 | - remove_action( 'update_option', array( $this, 'check_config_updated' )); |
|
355 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | } |
@@ -367,11 +367,11 @@ discard block |
||
367 | 367 | */ |
368 | 368 | protected function _reset_espresso_addon_config() { |
369 | 369 | $this->_config_option_names = array(); |
370 | - foreach( $this->addons as $addon_name => $addon_config_obj ) { |
|
371 | - $addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
372 | - $config_class = get_class( $addon_config_obj ); |
|
373 | - if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
374 | - $this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE ); |
|
370 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
371 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
372 | + $config_class = get_class($addon_config_obj); |
|
373 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
374 | + $this->update_config('addons', $addon_name, $addon_config_obj, FALSE); |
|
375 | 375 | } |
376 | 376 | $this->addons->$addon_name = NULL; |
377 | 377 | } |
@@ -387,17 +387,17 @@ discard block |
||
387 | 387 | * @param bool $add_error |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | - public function update_espresso_config( $add_success = FALSE, $add_error = TRUE ) { |
|
390 | + public function update_espresso_config($add_success = FALSE, $add_error = TRUE) { |
|
391 | 391 | // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
392 | 392 | //$clone = clone( self::$_instance ); |
393 | 393 | //self::$_instance = NULL; |
394 | - do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this ); |
|
394 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
395 | 395 | $this->_reset_espresso_addon_config(); |
396 | 396 | // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
397 | 397 | // but BEFORE the actual update occurs |
398 | - add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
398 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
399 | 399 | // now update "ee_config" |
400 | - $saved = update_option( 'ee_config', $this ); |
|
400 | + $saved = update_option('ee_config', $this); |
|
401 | 401 | // if not saved... check if the hook we just added still exists; |
402 | 402 | // if it does, it means one of two things: |
403 | 403 | // that update_option bailed at the ( $value === $old_value ) conditional, |
@@ -408,25 +408,25 @@ discard block |
||
408 | 408 | // but just means no update occurred, so don't display an error to the user. |
409 | 409 | // BUT... if update_option returns FALSE, AND the hook is missing, |
410 | 410 | // then it means that something truly went wrong |
411 | - $saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved; |
|
411 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
412 | 412 | // remove our action since we don't want it in the system anymore |
413 | - remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
414 | - do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
413 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
414 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
415 | 415 | //self::$_instance = $clone; |
416 | 416 | //unset( $clone ); |
417 | 417 | // if config remains the same or was updated successfully |
418 | - if ( $saved ) { |
|
419 | - if ( $add_success ) { |
|
418 | + if ($saved) { |
|
419 | + if ($add_success) { |
|
420 | 420 | EE_Error::add_success( |
421 | - __( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
421 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
422 | 422 | __FILE__, __FUNCTION__, __LINE__ |
423 | 423 | ); |
424 | 424 | } |
425 | 425 | return TRUE; |
426 | 426 | } else { |
427 | - if ( $add_error ) { |
|
427 | + if ($add_error) { |
|
428 | 428 | EE_Error::add_error( |
429 | - __( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
429 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
430 | 430 | __FILE__, __FUNCTION__, __LINE__ |
431 | 431 | ); |
432 | 432 | } |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | $name = '', |
453 | 453 | $config_class = '', |
454 | 454 | $config_obj = NULL, |
455 | - $tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
455 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
456 | 456 | $display_errors = TRUE |
457 | 457 | ) { |
458 | 458 | try { |
459 | - foreach ( $tests_to_run as $test ) { |
|
460 | - switch ( $test ) { |
|
459 | + foreach ($tests_to_run as $test) { |
|
460 | + switch ($test) { |
|
461 | 461 | |
462 | 462 | // TEST #1 : check that section was set |
463 | 463 | case 1 : |
464 | - if ( empty( $section ) ) { |
|
465 | - if ( $display_errors ) { |
|
464 | + if (empty($section)) { |
|
465 | + if ($display_errors) { |
|
466 | 466 | throw new EE_Error( |
467 | 467 | sprintf( |
468 | - __( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ), |
|
468 | + __('No configuration section has been provided while attempting to save "%s".', 'event_espresso'), |
|
469 | 469 | $config_class |
470 | 470 | ) |
471 | 471 | ); |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | // TEST #2 : check that settings section exists |
478 | 478 | case 2 : |
479 | - if ( ! isset( $this->{$section} ) ) { |
|
480 | - if ( $display_errors ) { |
|
479 | + if ( ! isset($this->{$section} )) { |
|
480 | + if ($display_errors) { |
|
481 | 481 | throw new EE_Error( |
482 | - sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
483 | - $section ) |
|
482 | + sprintf(__('The "%s" configuration section does not exist.', 'event_espresso'), |
|
483 | + $section) |
|
484 | 484 | ); |
485 | 485 | } |
486 | 486 | return false; |
@@ -490,12 +490,12 @@ discard block |
||
490 | 490 | // TEST #3 : check that section is the proper format |
491 | 491 | case 3 : |
492 | 492 | if ( |
493 | - ! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
493 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
494 | 494 | ) { |
495 | - if ( $display_errors ) { |
|
495 | + if ($display_errors) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | - __( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ), |
|
498 | + __('The "%s" configuration settings have not been formatted correctly.', 'event_espresso'), |
|
499 | 499 | $section |
500 | 500 | ) |
501 | 501 | ); |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | |
507 | 507 | // TEST #4 : check that config section name has been set |
508 | 508 | case 4 : |
509 | - if ( empty( $name ) ) { |
|
510 | - if ( $display_errors ) { |
|
509 | + if (empty($name)) { |
|
510 | + if ($display_errors) { |
|
511 | 511 | throw new EE_Error( |
512 | - __( 'No name has been provided for the specific configuration section.', 'event_espresso' ) |
|
512 | + __('No name has been provided for the specific configuration section.', 'event_espresso') |
|
513 | 513 | ); |
514 | 514 | } |
515 | 515 | return false; |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | |
519 | 519 | // TEST #5 : check that a config class name has been set |
520 | 520 | case 5 : |
521 | - if ( empty( $config_class ) ) { |
|
522 | - if ( $display_errors ) { |
|
521 | + if (empty($config_class)) { |
|
522 | + if ($display_errors) { |
|
523 | 523 | throw new EE_Error( |
524 | - __( 'No class name has been provided for the specific configuration section.', 'event_espresso' ) |
|
524 | + __('No class name has been provided for the specific configuration section.', 'event_espresso') |
|
525 | 525 | ); |
526 | 526 | } |
527 | 527 | return false; |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | |
531 | 531 | // TEST #6 : verify config class is accessible |
532 | 532 | case 6 : |
533 | - if ( ! class_exists( $config_class ) ) { |
|
534 | - if ( $display_errors ) { |
|
533 | + if ( ! class_exists($config_class)) { |
|
534 | + if ($display_errors) { |
|
535 | 535 | throw new EE_Error( |
536 | 536 | sprintf( |
537 | - __( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ), |
|
537 | + __('The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso'), |
|
538 | 538 | $config_class |
539 | 539 | ) |
540 | 540 | ); |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | |
546 | 546 | // TEST #7 : check that config has even been set |
547 | 547 | case 7 : |
548 | - if ( ! isset( $this->{$section}->{$name} ) ) { |
|
549 | - if ( $display_errors ) { |
|
548 | + if ( ! isset($this->{$section}->{$name} )) { |
|
549 | + if ($display_errors) { |
|
550 | 550 | throw new EE_Error( |
551 | 551 | sprintf( |
552 | - __( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
552 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
553 | 553 | $section, |
554 | 554 | $name |
555 | 555 | ) |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | return false; |
559 | 559 | } else { |
560 | 560 | // and make sure it's not serialized |
561 | - $this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
561 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} ); |
|
562 | 562 | } |
563 | 563 | break; |
564 | 564 | |
565 | 565 | // TEST #8 : check that config is the requested type |
566 | 566 | case 8 : |
567 | - if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
568 | - if ( $display_errors ) { |
|
567 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
568 | + if ($display_errors) { |
|
569 | 569 | throw new EE_Error( |
570 | 570 | sprintf( |
571 | - __( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ), |
|
571 | + __('The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso'), |
|
572 | 572 | $section, |
573 | 573 | $name, |
574 | 574 | $config_class |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | |
582 | 582 | // TEST #9 : verify config object |
583 | 583 | case 9 : |
584 | - if ( ! $config_obj instanceof EE_Config_Base ) { |
|
585 | - if ( $display_errors ) { |
|
584 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
585 | + if ($display_errors) { |
|
586 | 586 | throw new EE_Error( |
587 | 587 | sprintf( |
588 | - __( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
589 | - print_r( $config_obj, true ) |
|
588 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
589 | + print_r($config_obj, true) |
|
590 | 590 | ) |
591 | 591 | ); |
592 | 592 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | - } catch( EE_Error $e ) { |
|
600 | + } catch (EE_Error $e) { |
|
601 | 601 | $e->get_error(); |
602 | 602 | } |
603 | 603 | // you have successfully run the gauntlet |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | * @param string $name |
615 | 615 | * @return string |
616 | 616 | */ |
617 | - private function _generate_config_option_name( $section = '', $name = '' ) { |
|
618 | - return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
617 | + private function _generate_config_option_name($section = '', $name = '') { |
|
618 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param string $name |
630 | 630 | * @return string |
631 | 631 | */ |
632 | - private function _set_config_class( $config_class = '', $name = '' ) { |
|
633 | - return ! empty( $config_class ) |
|
632 | + private function _set_config_class($config_class = '', $name = '') { |
|
633 | + return ! empty($config_class) |
|
634 | 634 | ? $config_class |
635 | - : str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
635 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -646,34 +646,34 @@ discard block |
||
646 | 646 | * @param EE_Config_Base $config_obj |
647 | 647 | * @return EE_Config_Base |
648 | 648 | */ |
649 | - public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
649 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) { |
|
650 | 650 | // ensure config class is set to something |
651 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
651 | + $config_class = $this->_set_config_class($config_class, $name); |
|
652 | 652 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
653 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) { |
|
653 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
654 | 654 | return null; |
655 | 655 | } |
656 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
656 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
657 | 657 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
658 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
659 | - $this->_config_option_names[ $config_option_name ] = $config_class; |
|
658 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
659 | + $this->_config_option_names[$config_option_name] = $config_class; |
|
660 | 660 | } |
661 | 661 | // verify the incoming config object but suppress errors |
662 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) { |
|
662 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
663 | 663 | $config_obj = new $config_class(); |
664 | 664 | } |
665 | - if ( get_option( $config_option_name ) ) { |
|
666 | - update_option( $config_option_name, $config_obj ); |
|
665 | + if (get_option($config_option_name)) { |
|
666 | + update_option($config_option_name, $config_obj); |
|
667 | 667 | $this->{$section}->{$name} = $config_obj; |
668 | 668 | return $this->{$section}->{$name}; |
669 | 669 | } else { |
670 | 670 | // create a wp-option for this config |
671 | - if ( add_option( $config_option_name, $config_obj, '', 'no' )) { |
|
672 | - $this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
671 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
672 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
673 | 673 | return $this->{$section}->{$name}; |
674 | 674 | } else { |
675 | 675 | EE_Error::add_error( |
676 | - sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
676 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
677 | 677 | __FILE__, __FUNCTION__, __LINE__ |
678 | 678 | ); |
679 | 679 | return null; |
@@ -694,37 +694,37 @@ discard block |
||
694 | 694 | * @param bool $throw_errors |
695 | 695 | * @return bool |
696 | 696 | */ |
697 | - public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
698 | - $config_obj = maybe_unserialize( $config_obj ); |
|
697 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) { |
|
698 | + $config_obj = maybe_unserialize($config_obj); |
|
699 | 699 | // get class name of the incoming object |
700 | - $config_class = get_class( $config_obj ); |
|
700 | + $config_class = get_class($config_obj); |
|
701 | 701 | // run tests 1-5 and 9 to verify config |
702 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) { |
|
702 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(1, 2, 3, 4, 7, 9))) { |
|
703 | 703 | return false; |
704 | 704 | } |
705 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
705 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
706 | 706 | // check if config object has been added to db by seeing if config option name is in $this->_config_option_names array |
707 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
707 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
708 | 708 | // save new config to db |
709 | - return $this->set_config( $section, $name, $config_class, $config_obj ); |
|
709 | + return $this->set_config($section, $name, $config_class, $config_obj); |
|
710 | 710 | } else { |
711 | 711 | // first check if the record already exists |
712 | - $existing_config = get_option( $config_option_name ); |
|
713 | - $config_obj = serialize( $config_obj ); |
|
712 | + $existing_config = get_option($config_option_name); |
|
713 | + $config_obj = serialize($config_obj); |
|
714 | 714 | // just return if db record is already up to date |
715 | - if ( $existing_config == $config_obj ) { |
|
715 | + if ($existing_config == $config_obj) { |
|
716 | 716 | $this->{$section}->{$name} = $config_obj; |
717 | 717 | return true; |
718 | - } else if ( update_option( $config_option_name, $config_obj )) { |
|
718 | + } else if (update_option($config_option_name, $config_obj)) { |
|
719 | 719 | // update wp-option for this config class |
720 | 720 | $this->{$section}->{$name} = $config_obj; |
721 | 721 | return true; |
722 | - } elseif ( $throw_errors ) { |
|
722 | + } elseif ($throw_errors) { |
|
723 | 723 | EE_Error::add_error( |
724 | 724 | sprintf( |
725 | - __( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ), |
|
725 | + __('The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso'), |
|
726 | 726 | $config_class, |
727 | - 'EE_Config->' . $section . '->' . $name |
|
727 | + 'EE_Config->'.$section.'->'.$name |
|
728 | 728 | ), |
729 | 729 | __FILE__, __FUNCTION__, __LINE__ |
730 | 730 | ); |
@@ -744,34 +744,34 @@ discard block |
||
744 | 744 | * @param string $config_class |
745 | 745 | * @return mixed EE_Config_Base | NULL |
746 | 746 | */ |
747 | - public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
747 | + public function get_config($section = '', $name = '', $config_class = '') { |
|
748 | 748 | // ensure config class is set to something |
749 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
749 | + $config_class = $this->_set_config_class($config_class, $name); |
|
750 | 750 | // run tests 1-4, 6 and 7 to verify that all params have been set |
751 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) { |
|
751 | + if ( ! $this->_verify_config_params($section, $name, $config_class, NULL, array(1, 2, 3, 4, 5, 6))) { |
|
752 | 752 | return NULL; |
753 | 753 | } |
754 | 754 | // now test if the requested config object exists, but suppress errors |
755 | - if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) { |
|
755 | + if ($this->_verify_config_params($section, $name, $config_class, NULL, array(7, 8), FALSE)) { |
|
756 | 756 | // config already exists, so pass it back |
757 | 757 | return $this->{$section}->{$name}; |
758 | 758 | } |
759 | 759 | // load config option from db if it exists |
760 | - $config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name )); |
|
760 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
761 | 761 | // verify the newly retrieved config object, but suppress errors |
762 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) { |
|
762 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), FALSE)) { |
|
763 | 763 | // config is good, so set it and pass it back |
764 | 764 | $this->{$section}->{$name} = $config_obj; |
765 | 765 | return $this->{$section}->{$name}; |
766 | 766 | } |
767 | 767 | // oops! $config_obj is not already set and does not exist in the db, so create a new one |
768 | - $config_obj =$this->set_config( $section, $name, $config_class ); |
|
768 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
769 | 769 | // verify the newly created config object |
770 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) { |
|
770 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
771 | 771 | return $this->{$section}->{$name}; |
772 | 772 | } else { |
773 | 773 | EE_Error::add_error( |
774 | - sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
774 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
775 | 775 | __FILE__, __FUNCTION__, __LINE__ |
776 | 776 | ); |
777 | 777 | } |
@@ -786,9 +786,9 @@ discard block |
||
786 | 786 | * @param string $config_option_name |
787 | 787 | * @return mixed EE_Config_Base | FALSE |
788 | 788 | */ |
789 | - public function get_config_option( $config_option_name = '' ) { |
|
789 | + public function get_config_option($config_option_name = '') { |
|
790 | 790 | // retrieve the wp-option for this config class. |
791 | - return maybe_unserialize( get_option( $config_option_name )); |
|
791 | + return maybe_unserialize(get_option($config_option_name)); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -801,45 +801,45 @@ discard block |
||
801 | 801 | * @param $page_for_posts |
802 | 802 | * @return void |
803 | 803 | */ |
804 | - public function update_post_shortcodes( $page_for_posts = '' ) { |
|
804 | + public function update_post_shortcodes($page_for_posts = '') { |
|
805 | 805 | // make sure page_for_posts is set |
806 | - $page_for_posts = ! empty( $page_for_posts ) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
806 | + $page_for_posts = ! empty($page_for_posts) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
807 | 807 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
808 | 808 | $critical_shortcodes = $this->core->get_critical_pages_shortcodes_array(); |
809 | 809 | // allow others to mess stuff up :D |
810 | - do_action( 'AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts ); |
|
810 | + do_action('AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts); |
|
811 | 811 | // verify that post_shortcodes is set |
812 | - $this->core->post_shortcodes = isset( $this->core->post_shortcodes ) && is_array( $this->core->post_shortcodes ) ? $this->core->post_shortcodes : array(); |
|
812 | + $this->core->post_shortcodes = isset($this->core->post_shortcodes) && is_array($this->core->post_shortcodes) ? $this->core->post_shortcodes : array(); |
|
813 | 813 | // cycle thru post_shortcodes |
814 | - foreach( $this->core->post_shortcodes as $post_name => $shortcodes ){ |
|
814 | + foreach ($this->core->post_shortcodes as $post_name => $shortcodes) { |
|
815 | 815 | // are there any shortcodes to track ? |
816 | - if ( ! empty( $shortcodes )) { |
|
816 | + if ( ! empty($shortcodes)) { |
|
817 | 817 | // loop thru list of tracked shortcodes |
818 | - foreach( $shortcodes as $shortcode => $post_id ) { |
|
818 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
819 | 819 | // if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode |
820 | - if ( isset( $critical_shortcodes[ $post_id ] ) && $post_name == $page_for_posts ) { |
|
820 | + if (isset($critical_shortcodes[$post_id]) && $post_name == $page_for_posts) { |
|
821 | 821 | // then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog) |
822 | - unset( $this->core->post_shortcodes[ $post_name ][ $shortcode ] ); |
|
822 | + unset($this->core->post_shortcodes[$post_name][$shortcode]); |
|
823 | 823 | } |
824 | 824 | // skip the posts page, because we want all shortcodes registered for it |
825 | - if ( $post_name == $page_for_posts ) { |
|
825 | + if ($post_name == $page_for_posts) { |
|
826 | 826 | continue; |
827 | 827 | } |
828 | 828 | // make sure post still exists |
829 | - $post = get_post( $post_id ); |
|
830 | - if ( $post ) { |
|
829 | + $post = get_post($post_id); |
|
830 | + if ($post) { |
|
831 | 831 | // check that the post name matches what we have saved |
832 | - if ( $post->post_name == $post_name ) { |
|
832 | + if ($post->post_name == $post_name) { |
|
833 | 833 | // if so, then break before hitting the unset below |
834 | 834 | continue; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | // we don't like missing posts around here >:( |
838 | - unset( $this->core->post_shortcodes[ $post_name ] ); |
|
838 | + unset($this->core->post_shortcodes[$post_name]); |
|
839 | 839 | } |
840 | 840 | } else { |
841 | 841 | // you got no shortcodes to keep track of ! |
842 | - unset( $this->core->post_shortcodes[ $post_name ] ); |
|
842 | + unset($this->core->post_shortcodes[$post_name]); |
|
843 | 843 | } |
844 | 844 | } |
845 | 845 | //only show errors |
@@ -858,14 +858,14 @@ discard block |
||
858 | 858 | * @return string |
859 | 859 | */ |
860 | 860 | public static function get_page_for_posts() { |
861 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
862 | - if ( ! $page_for_posts ) { |
|
861 | + $page_for_posts = get_option('page_for_posts'); |
|
862 | + if ( ! $page_for_posts) { |
|
863 | 863 | return 'posts'; |
864 | 864 | } |
865 | 865 | /** @type WPDB $wpdb */ |
866 | 866 | global $wpdb; |
867 | 867 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
868 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts )); |
|
868 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | |
@@ -881,11 +881,11 @@ discard block |
||
881 | 881 | * @return void |
882 | 882 | */ |
883 | 883 | public function register_shortcodes_and_modules() { |
884 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
884 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
885 | 885 | return; |
886 | 886 | } |
887 | 887 | // allow shortcodes to register with WP and to set hooks for the rest of the system |
888 | - EE_Registry::instance()->shortcodes =$this->_register_shortcodes(); |
|
888 | + EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
889 | 889 | // allow modules to set hooks for the rest of the system |
890 | 890 | EE_Registry::instance()->modules = $this->_register_modules(); |
891 | 891 | } |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | * @return void |
900 | 900 | */ |
901 | 901 | public function initialize_shortcodes_and_modules() { |
902 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
902 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
903 | 903 | return; |
904 | 904 | } |
905 | 905 | // allow shortcodes to set hooks for the rest of the system |
@@ -918,26 +918,26 @@ discard block |
||
918 | 918 | * @return void |
919 | 919 | */ |
920 | 920 | public function widgets_init() { |
921 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
921 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
922 | 922 | return; |
923 | 923 | } |
924 | 924 | //only init widgets on admin pages when not in complete maintenance, and |
925 | 925 | //on frontend when not in any maintenance mode |
926 | - if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level() ) { |
|
926 | + if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) { |
|
927 | 927 | // grab list of installed widgets |
928 | - $widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
928 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
929 | 929 | // filter list of modules to register |
930 | - $widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register ); |
|
930 | + $widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register); |
|
931 | 931 | |
932 | - if ( ! empty( $widgets_to_register ) ) { |
|
932 | + if ( ! empty($widgets_to_register)) { |
|
933 | 933 | // cycle thru widget folders |
934 | - foreach ( $widgets_to_register as $widget_path ) { |
|
934 | + foreach ($widgets_to_register as $widget_path) { |
|
935 | 935 | // add to list of installed widget modules |
936 | - EE_Config::register_ee_widget( $widget_path ); |
|
936 | + EE_Config::register_ee_widget($widget_path); |
|
937 | 937 | } |
938 | 938 | } |
939 | 939 | // filter list of installed modules |
940 | - EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets ); |
|
940 | + EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets); |
|
941 | 941 | } |
942 | 942 | } |
943 | 943 | |
@@ -950,54 +950,54 @@ discard block |
||
950 | 950 | * @param string $widget_path - full path up to and including widget folder |
951 | 951 | * @return void |
952 | 952 | */ |
953 | - public static function register_ee_widget( $widget_path = NULL ) { |
|
954 | - do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
953 | + public static function register_ee_widget($widget_path = NULL) { |
|
954 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
955 | 955 | $widget_ext = '.widget.php'; |
956 | 956 | // make all separators match |
957 | - $widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
957 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
958 | 958 | // does the file path INCLUDE the actual file name as part of the path ? |
959 | - if ( strpos( $widget_path, $widget_ext ) !== FALSE ) { |
|
959 | + if (strpos($widget_path, $widget_ext) !== FALSE) { |
|
960 | 960 | // grab and shortcode file name from directory name and break apart at dots |
961 | - $file_name = explode( '.', basename( $widget_path )); |
|
961 | + $file_name = explode('.', basename($widget_path)); |
|
962 | 962 | // take first segment from file name pieces and remove class prefix if it exists |
963 | - $widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
963 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
964 | 964 | // sanitize shortcode directory name |
965 | - $widget = sanitize_key( $widget ); |
|
965 | + $widget = sanitize_key($widget); |
|
966 | 966 | // now we need to rebuild the shortcode path |
967 | - $widget_path = explode( DS, $widget_path ); |
|
967 | + $widget_path = explode(DS, $widget_path); |
|
968 | 968 | // remove last segment |
969 | - array_pop( $widget_path ); |
|
969 | + array_pop($widget_path); |
|
970 | 970 | // glue it back together |
971 | - $widget_path = implode( DS, $widget_path ); |
|
971 | + $widget_path = implode(DS, $widget_path); |
|
972 | 972 | } else { |
973 | 973 | // grab and sanitize widget directory name |
974 | - $widget = sanitize_key( basename( $widget_path )); |
|
974 | + $widget = sanitize_key(basename($widget_path)); |
|
975 | 975 | } |
976 | 976 | // create classname from widget directory name |
977 | - $widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ))); |
|
977 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
978 | 978 | // add class prefix |
979 | - $widget_class = 'EEW_' . $widget; |
|
979 | + $widget_class = 'EEW_'.$widget; |
|
980 | 980 | // does the widget exist ? |
981 | - if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) { |
|
981 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
982 | 982 | $msg = sprintf( |
983 | - __( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ), |
|
983 | + __('The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), |
|
984 | 984 | $widget_class, |
985 | - $widget_path . DS . $widget_class . $widget_ext |
|
985 | + $widget_path.DS.$widget_class.$widget_ext |
|
986 | 986 | ); |
987 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
987 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
988 | 988 | return; |
989 | 989 | } |
990 | 990 | // load the widget class file |
991 | - require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
991 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
992 | 992 | // verify that class exists |
993 | - if ( ! class_exists( $widget_class )) { |
|
994 | - $msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
995 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
993 | + if ( ! class_exists($widget_class)) { |
|
994 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
995 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
996 | 996 | return; |
997 | 997 | } |
998 | - register_widget( $widget_class ); |
|
998 | + register_widget($widget_class); |
|
999 | 999 | // add to array of registered widgets |
1000 | - EE_Registry::instance()->widgets->$widget_class = $widget_path . DS . $widget_class . $widget_ext; |
|
1000 | + EE_Registry::instance()->widgets->$widget_class = $widget_path.DS.$widget_class.$widget_ext; |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | |
@@ -1010,18 +1010,18 @@ discard block |
||
1010 | 1010 | */ |
1011 | 1011 | private function _register_shortcodes() { |
1012 | 1012 | // grab list of installed shortcodes |
1013 | - $shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
1013 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
1014 | 1014 | // filter list of modules to register |
1015 | - $shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register ); |
|
1016 | - if ( ! empty( $shortcodes_to_register ) ) { |
|
1015 | + $shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register); |
|
1016 | + if ( ! empty($shortcodes_to_register)) { |
|
1017 | 1017 | // cycle thru shortcode folders |
1018 | - foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
1018 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
1019 | 1019 | // add to list of installed shortcode modules |
1020 | - EE_Config::register_shortcode( $shortcode_path ); |
|
1020 | + EE_Config::register_shortcode($shortcode_path); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | // filter list of installed modules |
1024 | - return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes ); |
|
1024 | + return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
@@ -1033,56 +1033,56 @@ discard block |
||
1033 | 1033 | * @param string $shortcode_path - full path up to and including shortcode folder |
1034 | 1034 | * @return bool |
1035 | 1035 | */ |
1036 | - public static function register_shortcode( $shortcode_path = NULL ) { |
|
1037 | - do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path ); |
|
1036 | + public static function register_shortcode($shortcode_path = NULL) { |
|
1037 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
1038 | 1038 | $shortcode_ext = '.shortcode.php'; |
1039 | 1039 | // make all separators match |
1040 | - $shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
1040 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
1041 | 1041 | // does the file path INCLUDE the actual file name as part of the path ? |
1042 | - if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) { |
|
1042 | + if (strpos($shortcode_path, $shortcode_ext) !== FALSE) { |
|
1043 | 1043 | // grab shortcode file name from directory name and break apart at dots |
1044 | - $shortcode_file = explode( '.', basename( $shortcode_path )); |
|
1044 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
1045 | 1045 | // take first segment from file name pieces and remove class prefix if it exists |
1046 | - $shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0]; |
|
1046 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0]; |
|
1047 | 1047 | // sanitize shortcode directory name |
1048 | - $shortcode = sanitize_key( $shortcode ); |
|
1048 | + $shortcode = sanitize_key($shortcode); |
|
1049 | 1049 | // now we need to rebuild the shortcode path |
1050 | - $shortcode_path = explode( DS, $shortcode_path ); |
|
1050 | + $shortcode_path = explode(DS, $shortcode_path); |
|
1051 | 1051 | // remove last segment |
1052 | - array_pop( $shortcode_path ); |
|
1052 | + array_pop($shortcode_path); |
|
1053 | 1053 | // glue it back together |
1054 | - $shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
1054 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
1055 | 1055 | } else { |
1056 | 1056 | // we need to generate the filename based off of the folder name |
1057 | 1057 | // grab and sanitize shortcode directory name |
1058 | - $shortcode = sanitize_key( basename( $shortcode_path )); |
|
1059 | - $shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
1058 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
1059 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
1060 | 1060 | } |
1061 | 1061 | // create classname from shortcode directory or file name |
1062 | - $shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ))); |
|
1062 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
1063 | 1063 | // add class prefix |
1064 | - $shortcode_class = 'EES_' . $shortcode; |
|
1064 | + $shortcode_class = 'EES_'.$shortcode; |
|
1065 | 1065 | // does the shortcode exist ? |
1066 | - if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) { |
|
1066 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
1067 | 1067 | $msg = sprintf( |
1068 | - __( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ), |
|
1068 | + __('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'), |
|
1069 | 1069 | $shortcode_class, |
1070 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1070 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
1071 | 1071 | ); |
1072 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1072 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1073 | 1073 | return FALSE; |
1074 | 1074 | } |
1075 | 1075 | // load the shortcode class file |
1076 | - require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
1076 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
1077 | 1077 | // verify that class exists |
1078 | - if ( ! class_exists( $shortcode_class )) { |
|
1079 | - $msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class ); |
|
1080 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1078 | + if ( ! class_exists($shortcode_class)) { |
|
1079 | + $msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class); |
|
1080 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1081 | 1081 | return FALSE; |
1082 | 1082 | } |
1083 | - $shortcode = strtoupper( $shortcode ); |
|
1083 | + $shortcode = strtoupper($shortcode); |
|
1084 | 1084 | // add to array of registered shortcodes |
1085 | - EE_Registry::instance()->shortcodes->$shortcode = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1085 | + EE_Registry::instance()->shortcodes->$shortcode = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
1086 | 1086 | return TRUE; |
1087 | 1087 | } |
1088 | 1088 | |
@@ -1097,23 +1097,23 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | private function _register_modules() { |
1099 | 1099 | // grab list of installed modules |
1100 | - $modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
1100 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1101 | 1101 | // filter list of modules to register |
1102 | - $modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register ); |
|
1102 | + $modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register); |
|
1103 | 1103 | |
1104 | 1104 | |
1105 | - if ( ! empty( $modules_to_register ) ) { |
|
1105 | + if ( ! empty($modules_to_register)) { |
|
1106 | 1106 | // loop through folders |
1107 | - foreach ( $modules_to_register as $module_path ) { |
|
1107 | + foreach ($modules_to_register as $module_path) { |
|
1108 | 1108 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1109 | - if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) { |
|
1109 | + if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') { |
|
1110 | 1110 | // add to list of installed modules |
1111 | - EE_Config::register_module( $module_path ); |
|
1111 | + EE_Config::register_module($module_path); |
|
1112 | 1112 | } |
1113 | 1113 | } |
1114 | 1114 | } |
1115 | 1115 | // filter list of installed modules |
1116 | - return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules ); |
|
1116 | + return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | |
@@ -1126,54 +1126,54 @@ discard block |
||
1126 | 1126 | * @param string $module_path - full path up to and including module folder |
1127 | 1127 | * @return bool |
1128 | 1128 | */ |
1129 | - public static function register_module( $module_path = NULL ) { |
|
1130 | - do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
1129 | + public static function register_module($module_path = NULL) { |
|
1130 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1131 | 1131 | $module_ext = '.module.php'; |
1132 | 1132 | // make all separators match |
1133 | - $module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
1133 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1134 | 1134 | // does the file path INCLUDE the actual file name as part of the path ? |
1135 | - if ( strpos( $module_path, $module_ext ) !== FALSE ) { |
|
1135 | + if (strpos($module_path, $module_ext) !== FALSE) { |
|
1136 | 1136 | // grab and shortcode file name from directory name and break apart at dots |
1137 | - $module_file = explode( '.', basename( $module_path )); |
|
1137 | + $module_file = explode('.', basename($module_path)); |
|
1138 | 1138 | // now we need to rebuild the shortcode path |
1139 | - $module_path = explode( DS, $module_path ); |
|
1139 | + $module_path = explode(DS, $module_path); |
|
1140 | 1140 | // remove last segment |
1141 | - array_pop( $module_path ); |
|
1141 | + array_pop($module_path); |
|
1142 | 1142 | // glue it back together |
1143 | - $module_path = implode( DS, $module_path ) . DS; |
|
1143 | + $module_path = implode(DS, $module_path).DS; |
|
1144 | 1144 | // take first segment from file name pieces and sanitize it |
1145 | - $module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
1145 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1146 | 1146 | // ensure class prefix is added |
1147 | - $module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
1147 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1148 | 1148 | } else { |
1149 | 1149 | // we need to generate the filename based off of the folder name |
1150 | 1150 | // grab and sanitize module name |
1151 | - $module = strtolower( basename( $module_path )); |
|
1152 | - $module = preg_replace( '/[^a-z0-9_\-]/', '', $module); |
|
1151 | + $module = strtolower(basename($module_path)); |
|
1152 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1153 | 1153 | // like trailingslashit() |
1154 | - $module_path = rtrim( $module_path, DS ) . DS; |
|
1154 | + $module_path = rtrim($module_path, DS).DS; |
|
1155 | 1155 | // create classname from module directory name |
1156 | - $module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ))); |
|
1156 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1157 | 1157 | // add class prefix |
1158 | - $module_class = 'EED_' . $module; |
|
1158 | + $module_class = 'EED_'.$module; |
|
1159 | 1159 | } |
1160 | 1160 | // does the module exist ? |
1161 | - if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) { |
|
1162 | - $msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
1163 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1161 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1162 | + $msg = sprintf(__('The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
1163 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1164 | 1164 | return FALSE; |
1165 | 1165 | } |
1166 | 1166 | // load the module class file |
1167 | - require_once( $module_path . $module_class . $module_ext ); |
|
1167 | + require_once($module_path.$module_class.$module_ext); |
|
1168 | 1168 | // verify that class exists |
1169 | - if ( ! class_exists( $module_class )) { |
|
1170 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
1171 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1169 | + if ( ! class_exists($module_class)) { |
|
1170 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1171 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1172 | 1172 | return FALSE; |
1173 | 1173 | } |
1174 | 1174 | // add to array of registered modules |
1175 | - EE_Registry::instance()->modules->$module_class = $module_path . $module_class . $module_ext; |
|
1176 | - do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->$module_class ); |
|
1175 | + EE_Registry::instance()->modules->$module_class = $module_path.$module_class.$module_ext; |
|
1176 | + do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->$module_class); |
|
1177 | 1177 | return TRUE; |
1178 | 1178 | } |
1179 | 1179 | |
@@ -1187,23 +1187,23 @@ discard block |
||
1187 | 1187 | */ |
1188 | 1188 | private function _initialize_shortcodes() { |
1189 | 1189 | // cycle thru shortcode folders |
1190 | - foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
1190 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1191 | 1191 | // add class prefix |
1192 | - $shortcode_class = 'EES_' . $shortcode; |
|
1192 | + $shortcode_class = 'EES_'.$shortcode; |
|
1193 | 1193 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1194 | 1194 | // which set hooks ? |
1195 | - if ( is_admin() ) { |
|
1195 | + if (is_admin()) { |
|
1196 | 1196 | // fire immediately |
1197 | - call_user_func( array( $shortcode_class, 'set_hooks_admin' )); |
|
1197 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1198 | 1198 | } else { |
1199 | 1199 | // delay until other systems are online |
1200 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' )); |
|
1200 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks')); |
|
1201 | 1201 | // convert classname to UPPERCASE and create WP shortcode. |
1202 | - $shortcode_tag = strtoupper( $shortcode ); |
|
1202 | + $shortcode_tag = strtoupper($shortcode); |
|
1203 | 1203 | // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
1204 | - if ( ! shortcode_exists( $shortcode_tag )) { |
|
1204 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
1205 | 1205 | // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
1206 | - add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' )); |
|
1206 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1207 | 1207 | } |
1208 | 1208 | } |
1209 | 1209 | } |
@@ -1220,15 +1220,15 @@ discard block |
||
1220 | 1220 | */ |
1221 | 1221 | private function _initialize_modules() { |
1222 | 1222 | // cycle thru shortcode folders |
1223 | - foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
1223 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1224 | 1224 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1225 | 1225 | // which set hooks ? |
1226 | - if ( is_admin() ) { |
|
1226 | + if (is_admin()) { |
|
1227 | 1227 | // fire immediately |
1228 | - call_user_func( array( $module_class, 'set_hooks_admin' )); |
|
1228 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1229 | 1229 | } else { |
1230 | 1230 | // delay until other systems are online |
1231 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' )); |
|
1231 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks')); |
|
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | } |
@@ -1246,26 +1246,26 @@ discard block |
||
1246 | 1246 | * @param string $key - url param key indicating a route is being called |
1247 | 1247 | * @return bool |
1248 | 1248 | */ |
1249 | - public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) { |
|
1250 | - do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
1251 | - $module = str_replace( 'EED_', '', $module ); |
|
1252 | - $module_class = 'EED_' . $module; |
|
1253 | - if ( ! isset( EE_Registry::instance()->modules->$module_class )) { |
|
1254 | - $msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
1255 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1249 | + public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') { |
|
1250 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1251 | + $module = str_replace('EED_', '', $module); |
|
1252 | + $module_class = 'EED_'.$module; |
|
1253 | + if ( ! isset(EE_Registry::instance()->modules->$module_class)) { |
|
1254 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1255 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | 1256 | return FALSE; |
1257 | 1257 | } |
1258 | - if ( empty( $route )) { |
|
1259 | - $msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
1260 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1258 | + if (empty($route)) { |
|
1259 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1260 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | 1261 | return FALSE; |
1262 | 1262 | } |
1263 | - if ( ! method_exists ( 'EED_' . $module, $method_name )) { |
|
1264 | - $msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route ); |
|
1265 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1263 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1264 | + $msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route); |
|
1265 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1266 | 1266 | return FALSE; |
1267 | 1267 | } |
1268 | - EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
1268 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1269 | 1269 | return TRUE; |
1270 | 1270 | } |
1271 | 1271 | |
@@ -1279,11 +1279,11 @@ discard block |
||
1279 | 1279 | * @param string $key - url param key indicating a route is being called |
1280 | 1280 | * @return string |
1281 | 1281 | */ |
1282 | - public static function get_route( $route = NULL, $key = 'ee' ) { |
|
1283 | - do_action( 'AHEE__EE_Config__get_route__begin',$route ); |
|
1284 | - $route = apply_filters( 'FHEE__EE_Config__get_route',$route ); |
|
1285 | - if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) { |
|
1286 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1282 | + public static function get_route($route = NULL, $key = 'ee') { |
|
1283 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1284 | + $route = apply_filters('FHEE__EE_Config__get_route', $route); |
|
1285 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1286 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1287 | 1287 | } |
1288 | 1288 | return NULL; |
1289 | 1289 | } |
@@ -1312,35 +1312,35 @@ discard block |
||
1312 | 1312 | * @param string $key - url param key indicating a route is being called |
1313 | 1313 | * @return bool |
1314 | 1314 | */ |
1315 | - public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) { |
|
1316 | - do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward ); |
|
1317 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1318 | - $msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route ); |
|
1319 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1315 | + public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') { |
|
1316 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1317 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1318 | + $msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route); |
|
1319 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1320 | 1320 | return FALSE; |
1321 | 1321 | } |
1322 | - if ( empty( $forward )) { |
|
1323 | - $msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
1324 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1322 | + if (empty($forward)) { |
|
1323 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1324 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1325 | 1325 | return FALSE; |
1326 | 1326 | } |
1327 | - if ( is_array( $forward )) { |
|
1328 | - if ( ! isset( $forward[1] )) { |
|
1329 | - $msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route ); |
|
1330 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1327 | + if (is_array($forward)) { |
|
1328 | + if ( ! isset($forward[1])) { |
|
1329 | + $msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route); |
|
1330 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1331 | 1331 | return FALSE; |
1332 | 1332 | } |
1333 | - if ( ! method_exists( $forward[0], $forward[1] )) { |
|
1334 | - $msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route ); |
|
1335 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1333 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1334 | + $msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route); |
|
1335 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1336 | 1336 | return FALSE; |
1337 | 1337 | } |
1338 | - } else if ( ! function_exists( $forward )) { |
|
1339 | - $msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route ); |
|
1340 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1338 | + } else if ( ! function_exists($forward)) { |
|
1339 | + $msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route); |
|
1340 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | 1341 | return FALSE; |
1342 | 1342 | } |
1343 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
1343 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1344 | 1344 | return TRUE; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1355,10 +1355,10 @@ discard block |
||
1355 | 1355 | * @param string $key - url param key indicating a route is being called |
1356 | 1356 | * @return string |
1357 | 1357 | */ |
1358 | - public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) { |
|
1359 | - do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status ); |
|
1360 | - if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) { |
|
1361 | - return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1358 | + public static function get_forward($route = NULL, $status = 0, $key = 'ee') { |
|
1359 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1360 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1361 | + return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status); |
|
1362 | 1362 | } |
1363 | 1363 | return NULL; |
1364 | 1364 | } |
@@ -1375,19 +1375,19 @@ discard block |
||
1375 | 1375 | * @param string $key - url param key indicating a route is being called |
1376 | 1376 | * @return bool |
1377 | 1377 | */ |
1378 | - public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) { |
|
1379 | - do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view ); |
|
1380 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1381 | - $msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route ); |
|
1382 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1378 | + public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') { |
|
1379 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1380 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1381 | + $msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route); |
|
1382 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1383 | 1383 | return FALSE; |
1384 | 1384 | } |
1385 | - if ( ! is_readable( $view )) { |
|
1386 | - $msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view ); |
|
1387 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1385 | + if ( ! is_readable($view)) { |
|
1386 | + $msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view); |
|
1387 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1388 | 1388 | return FALSE; |
1389 | 1389 | } |
1390 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
1390 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1391 | 1391 | return TRUE; |
1392 | 1392 | } |
1393 | 1393 | |
@@ -1404,10 +1404,10 @@ discard block |
||
1404 | 1404 | * @param string $key - url param key indicating a route is being called |
1405 | 1405 | * @return string |
1406 | 1406 | */ |
1407 | - public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) { |
|
1408 | - do_action( 'AHEE__EE_Config__get_view__begin',$route,$status ); |
|
1409 | - if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) { |
|
1410 | - return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1407 | + public static function get_view($route = NULL, $status = 0, $key = 'ee') { |
|
1408 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1409 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1410 | + return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status); |
|
1411 | 1411 | } |
1412 | 1412 | return NULL; |
1413 | 1413 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | |
1417 | 1417 | public function shutdown() { |
1418 | - update_option( 'ee_config_option_names', $this->_config_option_names ); |
|
1418 | + update_option('ee_config_option_names', $this->_config_option_names); |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | * magic functions in use, except we'll allow them to magically set and get stuff... |
1432 | 1432 | * basically, they should just be well-defined stdClasses |
1433 | 1433 | */ |
1434 | -class EE_Config_Base{ |
|
1434 | +class EE_Config_Base { |
|
1435 | 1435 | |
1436 | 1436 | /** |
1437 | 1437 | * Utility function for escaping the value of a property and returning. |
@@ -1440,13 +1440,13 @@ discard block |
||
1440 | 1440 | * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
1441 | 1441 | * @throws \EE_Error |
1442 | 1442 | */ |
1443 | - public function get_pretty( $property ) { |
|
1444 | - if ( ! property_exists( $this, $property ) ) { |
|
1445 | - throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) ); |
|
1443 | + public function get_pretty($property) { |
|
1444 | + if ( ! property_exists($this, $property)) { |
|
1445 | + throw new EE_Error(sprintf(__('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso'), get_class($this), $property)); |
|
1446 | 1446 | } |
1447 | 1447 | //just handling escaping of strings for now. |
1448 | - if ( is_string( $this->$property ) ) { |
|
1449 | - return stripslashes( $this->$property ); |
|
1448 | + if (is_string($this->$property)) { |
|
1449 | + return stripslashes($this->$property); |
|
1450 | 1450 | } |
1451 | 1451 | return $this->$property; |
1452 | 1452 | } |
@@ -1455,19 +1455,19 @@ discard block |
||
1455 | 1455 | |
1456 | 1456 | public function populate() { |
1457 | 1457 | //grab defaults via a new instance of this class. |
1458 | - $class_name = get_class( $this ); |
|
1458 | + $class_name = get_class($this); |
|
1459 | 1459 | $defaults = new $class_name; |
1460 | 1460 | |
1461 | 1461 | //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
1462 | 1462 | //default from our $defaults object. |
1463 | - foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
1464 | - if ( is_null( $this->$property ) ) { |
|
1463 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1464 | + if (is_null($this->$property)) { |
|
1465 | 1465 | $this->$property = $value; |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | //cleanup |
1470 | - unset( $defaults ); |
|
1470 | + unset($defaults); |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | |
@@ -1559,12 +1559,12 @@ discard block |
||
1559 | 1559 | */ |
1560 | 1560 | public function __construct() { |
1561 | 1561 | $current_network_main_site = is_multisite() ? get_current_site() : NULL; |
1562 | - $current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
1562 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1563 | 1563 | // set default organization settings |
1564 | 1564 | $this->current_blog_id = get_current_blog_id(); |
1565 | 1565 | $this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
1566 | - $this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE ); |
|
1567 | - $this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE; |
|
1566 | + $this->ee_ueip_optin = is_main_site() ? get_option('ee_ueip_optin', TRUE) : get_blog_option($current_main_site_id, 'ee_ueip_optin', TRUE); |
|
1567 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', FALSE) : TRUE; |
|
1568 | 1568 | $this->post_shortcodes = array(); |
1569 | 1569 | $this->module_route_map = array(); |
1570 | 1570 | $this->module_forward_map = array(); |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | $this->event_cpt_slug = __('events', 'event_espresso'); |
1584 | 1584 | |
1585 | 1585 | //ueip constant check |
1586 | - if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
1586 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1587 | 1587 | $this->ee_ueip_optin = FALSE; |
1588 | 1588 | $this->ee_ueip_has_notified = TRUE; |
1589 | 1589 | } |
@@ -1623,8 +1623,8 @@ discard block |
||
1623 | 1623 | * @return string |
1624 | 1624 | */ |
1625 | 1625 | public function reg_page_url() { |
1626 | - if ( ! $this->reg_page_url ) { |
|
1627 | - $this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout'; |
|
1626 | + if ( ! $this->reg_page_url) { |
|
1627 | + $this->reg_page_url = get_permalink($this->reg_page_id).'#checkout'; |
|
1628 | 1628 | } |
1629 | 1629 | return $this->reg_page_url; |
1630 | 1630 | } |
@@ -1637,12 +1637,12 @@ discard block |
||
1637 | 1637 | * @return string |
1638 | 1638 | */ |
1639 | 1639 | public function txn_page_url($query_args = array()) { |
1640 | - if ( ! $this->txn_page_url ) { |
|
1641 | - $this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
1640 | + if ( ! $this->txn_page_url) { |
|
1641 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1642 | 1642 | } |
1643 | - if($query_args){ |
|
1644 | - return add_query_arg($query_args,$this->txn_page_url); |
|
1645 | - }else{ |
|
1643 | + if ($query_args) { |
|
1644 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1645 | + } else { |
|
1646 | 1646 | return $this->txn_page_url; |
1647 | 1647 | } |
1648 | 1648 | } |
@@ -1654,12 +1654,12 @@ discard block |
||
1654 | 1654 | * @return string |
1655 | 1655 | */ |
1656 | 1656 | public function thank_you_page_url($query_args = array()) { |
1657 | - if ( ! $this->thank_you_page_url ) { |
|
1658 | - $this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
1657 | + if ( ! $this->thank_you_page_url) { |
|
1658 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1659 | 1659 | } |
1660 | - if($query_args){ |
|
1661 | - return add_query_arg($query_args,$this->thank_you_page_url); |
|
1662 | - }else{ |
|
1660 | + if ($query_args) { |
|
1661 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1662 | + } else { |
|
1663 | 1663 | return $this->thank_you_page_url; |
1664 | 1664 | } |
1665 | 1665 | } |
@@ -1670,8 +1670,8 @@ discard block |
||
1670 | 1670 | * @return string |
1671 | 1671 | */ |
1672 | 1672 | public function cancel_page_url() { |
1673 | - if ( ! $this->cancel_page_url ) { |
|
1674 | - $this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
1673 | + if ( ! $this->cancel_page_url) { |
|
1674 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1675 | 1675 | } |
1676 | 1676 | return $this->cancel_page_url; |
1677 | 1677 | } |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | //reset all url properties |
1700 | 1700 | $this->_reset_urls(); |
1701 | 1701 | //return what to save to db |
1702 | - return array_keys( get_object_vars( $this ) ); |
|
1702 | + return array_keys(get_object_vars($this)); |
|
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | } |
@@ -1931,39 +1931,39 @@ discard block |
||
1931 | 1931 | * @param null $CNT_ISO |
1932 | 1932 | * @return \EE_Currency_Config |
1933 | 1933 | */ |
1934 | - public function __construct( $CNT_ISO = NULL ) { |
|
1934 | + public function __construct($CNT_ISO = NULL) { |
|
1935 | 1935 | |
1936 | 1936 | // get country code from organization settings or use default |
1937 | - $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1937 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1938 | 1938 | // but override if requested |
1939 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
1940 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
1939 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
1940 | + EE_Registry::instance()->load_helper('Activation'); |
|
1941 | 1941 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
1942 | - if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) { |
|
1942 | + if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) { |
|
1943 | 1943 | // retrieve the country settings from the db, just in case they have been customized |
1944 | - $country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
1945 | - if ( $country instanceof EE_Country ) { |
|
1946 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
1947 | - $this->name = $country->currency_name_single(); // Dollar |
|
1948 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
1949 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
1950 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1951 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
1952 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1953 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1944 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
1945 | + if ($country instanceof EE_Country) { |
|
1946 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
1947 | + $this->name = $country->currency_name_single(); // Dollar |
|
1948 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
1949 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
1950 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1951 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
1952 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1953 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1954 | 1954 | } |
1955 | 1955 | } |
1956 | 1956 | // fallback to hardcoded defaults, in case the above failed |
1957 | - if ( empty( $this->code )) { |
|
1957 | + if (empty($this->code)) { |
|
1958 | 1958 | // set default currency settings |
1959 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1960 | - $this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
1961 | - $this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
1962 | - $this->sign = '$'; // currency sign: $ |
|
1963 | - $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1964 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1965 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1966 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1959 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1960 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
1961 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
1962 | + $this->sign = '$'; // currency sign: $ |
|
1963 | + $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1964 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1965 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1966 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1967 | 1967 | } |
1968 | 1968 | } |
1969 | 1969 | } |
@@ -2103,7 +2103,7 @@ discard block |
||
2103 | 2103 | * @since 4.8.8.rc.019 |
2104 | 2104 | */ |
2105 | 2105 | public function do_hooks() { |
2106 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' )); |
|
2106 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2107 | 2107 | } |
2108 | 2108 | |
2109 | 2109 | |
@@ -2111,7 +2111,7 @@ discard block |
||
2111 | 2111 | * @return void |
2112 | 2112 | */ |
2113 | 2113 | public function set_default_reg_status_on_EEM_Event() { |
2114 | - EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
2114 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | |
@@ -2216,10 +2216,10 @@ discard block |
||
2216 | 2216 | * @param bool $reset |
2217 | 2217 | * @return string |
2218 | 2218 | */ |
2219 | - public function log_file_name( $reset = FALSE ) { |
|
2220 | - if ( empty( $this->log_file_name ) || $reset ) { |
|
2221 | - $this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2222 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2219 | + public function log_file_name($reset = FALSE) { |
|
2220 | + if (empty($this->log_file_name) || $reset) { |
|
2221 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt'; |
|
2222 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
2223 | 2223 | } |
2224 | 2224 | return $this->log_file_name; |
2225 | 2225 | } |
@@ -2231,10 +2231,10 @@ discard block |
||
2231 | 2231 | * @param bool $reset |
2232 | 2232 | * @return string |
2233 | 2233 | */ |
2234 | - public function debug_file_name( $reset = FALSE ) { |
|
2235 | - if ( empty( $this->debug_file_name ) || $reset ) { |
|
2236 | - $this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2237 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2234 | + public function debug_file_name($reset = FALSE) { |
|
2235 | + if (empty($this->debug_file_name) || $reset) { |
|
2236 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt'; |
|
2237 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
2238 | 2238 | } |
2239 | 2239 | return $this->debug_file_name; |
2240 | 2240 | } |
@@ -2407,21 +2407,21 @@ discard block |
||
2407 | 2407 | // set default map settings |
2408 | 2408 | $this->use_google_maps = TRUE; |
2409 | 2409 | // for event details pages (reg page) |
2410 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2411 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2412 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2413 | - $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2414 | - $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2415 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2416 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2410 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2411 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2412 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2413 | + $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2414 | + $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2415 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2416 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2417 | 2417 | // for event list pages |
2418 | - $this->event_list_map_width = 300; // ee_map_width |
|
2419 | - $this->event_list_map_height = 185; // ee_map_height |
|
2420 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2421 | - $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2422 | - $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2423 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2424 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2418 | + $this->event_list_map_width = 300; // ee_map_width |
|
2419 | + $this->event_list_map_height = 185; // ee_map_height |
|
2420 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2421 | + $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2422 | + $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2423 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2424 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2425 | 2425 | } |
2426 | 2426 | |
2427 | 2427 | } |
@@ -2432,7 +2432,7 @@ discard block |
||
2432 | 2432 | /** |
2433 | 2433 | * stores Events_Archive settings |
2434 | 2434 | */ |
2435 | -class EE_Events_Archive_Config extends EE_Config_Base{ |
|
2435 | +class EE_Events_Archive_Config extends EE_Config_Base { |
|
2436 | 2436 | |
2437 | 2437 | public $display_status_banner; |
2438 | 2438 | public $display_description; |
@@ -2451,7 +2451,7 @@ discard block |
||
2451 | 2451 | /** |
2452 | 2452 | * class constructor |
2453 | 2453 | */ |
2454 | - public function __construct(){ |
|
2454 | + public function __construct() { |
|
2455 | 2455 | $this->display_status_banner = 0; |
2456 | 2456 | $this->display_description = 1; |
2457 | 2457 | $this->display_ticket_selector = 0; |
@@ -2471,7 +2471,7 @@ discard block |
||
2471 | 2471 | /** |
2472 | 2472 | * Stores Event_Single_Config settings |
2473 | 2473 | */ |
2474 | -class EE_Event_Single_Config extends EE_Config_Base{ |
|
2474 | +class EE_Event_Single_Config extends EE_Config_Base { |
|
2475 | 2475 | |
2476 | 2476 | public $display_status_banner_single; |
2477 | 2477 | public $display_venue; |
@@ -2500,7 +2500,7 @@ discard block |
||
2500 | 2500 | /** |
2501 | 2501 | * Stores Ticket_Selector_Config settings |
2502 | 2502 | */ |
2503 | -class EE_Ticket_Selector_Config extends EE_Config_Base{ |
|
2503 | +class EE_Ticket_Selector_Config extends EE_Config_Base { |
|
2504 | 2504 | public $show_ticket_sale_columns; |
2505 | 2505 | public $show_ticket_details; |
2506 | 2506 | public $show_expired_tickets; |
@@ -2554,7 +2554,7 @@ discard block |
||
2554 | 2554 | * @return void |
2555 | 2555 | */ |
2556 | 2556 | protected function _set_php_values() { |
2557 | - $this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
2557 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
2558 | 2558 | $this->php->version = phpversion(); |
2559 | 2559 | } |
2560 | 2560 | |
@@ -2573,8 +2573,8 @@ discard block |
||
2573 | 2573 | * @type string $msg Any message to be displayed. |
2574 | 2574 | * } |
2575 | 2575 | */ |
2576 | - public function max_input_vars_limit_check( $input_count = 0 ) { |
|
2577 | - if ( ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) { |
|
2576 | + public function max_input_vars_limit_check($input_count = 0) { |
|
2577 | + if (($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) { |
|
2578 | 2578 | return __('The number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.', 'event_espresso'); |
2579 | 2579 | } else { |
2580 | 2580 | return ''; |
@@ -2610,7 +2610,7 @@ discard block |
||
2610 | 2610 | * stores payment gateway info |
2611 | 2611 | * @deprecated |
2612 | 2612 | */ |
2613 | -class EE_Gateway_Config extends EE_Config_Base{ |
|
2613 | +class EE_Gateway_Config extends EE_Config_Base { |
|
2614 | 2614 | |
2615 | 2615 | /** |
2616 | 2616 | * Array with keys that are payment gateways slugs, and values are arrays |
@@ -2632,9 +2632,9 @@ discard block |
||
2632 | 2632 | * class constructor |
2633 | 2633 | * @deprecated |
2634 | 2634 | */ |
2635 | - public function __construct(){ |
|
2635 | + public function __construct() { |
|
2636 | 2636 | $this->payment_settings = array(); |
2637 | - $this->active_gateways = array( 'Invoice' => FALSE ); |
|
2637 | + $this->active_gateways = array('Invoice' => FALSE); |
|
2638 | 2638 | } |
2639 | 2639 | } |
2640 | 2640 |
@@ -87,6 +87,11 @@ |
||
87 | 87 | public function count_units_to_process() { |
88 | 88 | return \EEM_Attendee::instance()->count(); |
89 | 89 | } |
90 | + |
|
91 | + /** |
|
92 | + * @param integer $offset |
|
93 | + * @param integer $limit |
|
94 | + */ |
|
90 | 95 | public function get_csv_data( $offset, $limit ) { |
91 | 96 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
92 | 97 | array( |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use EventEspressoBatchRequest\Helpers\JobParameters; |
19 | 19 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
20 | 20 | |
21 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
22 | 22 | exit('No direct script access allowed'); |
23 | 23 | } |
24 | 24 | |
@@ -27,83 +27,83 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | public function create_job(JobParameters $job_parameters) { |
30 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) { |
|
30 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) { |
|
31 | 31 | throw new BatchRequestException( |
32 | - __( 'You do not have permission to view contacts', 'event_espresso') |
|
32 | + __('You do not have permission to view contacts', 'event_espresso') |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | $filepath = $this->create_file_from_job_with_name( |
36 | 36 | $job_parameters->job_id(), |
37 | 37 | __('contact-list-report.csv', 'event_espresso') |
38 | 38 | ); |
39 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
40 | - $job_parameters->set_job_size( $this->count_units_to_process() ); |
|
39 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
40 | + $job_parameters->set_job_size($this->count_units_to_process()); |
|
41 | 41 | //we should also set the header columns |
42 | - $csv_data_for_row = $this->get_csv_data( 0, 1 ); |
|
43 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
44 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
42 | + $csv_data_for_row = $this->get_csv_data(0, 1); |
|
43 | + \EE_Registry::instance()->load_helper('Export'); |
|
44 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
45 | 45 | //if we actually processed a row there, record it |
46 | - if( $job_parameters->job_size() ) { |
|
47 | - $job_parameters->mark_processed( 1 ); |
|
46 | + if ($job_parameters->job_size()) { |
|
47 | + $job_parameters->mark_processed(1); |
|
48 | 48 | } |
49 | 49 | return new JobStepResponse( |
50 | 50 | $job_parameters, |
51 | - __( 'Contacts report started successfully...', 'event_espresso' ) |
|
51 | + __('Contacts report started successfully...', 'event_espresso') |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
57 | - $csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size ); |
|
58 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
59 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
60 | - $units_processed = count( $csv_data ); |
|
61 | - $job_parameters->mark_processed( $units_processed ); |
|
57 | + $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size); |
|
58 | + \EE_Registry::instance()->load_helper('Export'); |
|
59 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
60 | + $units_processed = count($csv_data); |
|
61 | + $job_parameters->mark_processed($units_processed); |
|
62 | 62 | $extra_response_data = array( |
63 | 63 | 'file_url' => '' |
64 | 64 | ); |
65 | - if( $units_processed < $batch_size ) { |
|
66 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
67 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
65 | + if ($units_processed < $batch_size) { |
|
66 | + $job_parameters->set_status(JobParameters::status_complete); |
|
67 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
68 | 68 | } |
69 | 69 | return new JobStepResponse( |
70 | 70 | $job_parameters, |
71 | 71 | sprintf( |
72 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
73 | - count( $csv_data ) ), |
|
72 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
73 | + count($csv_data) ), |
|
74 | 74 | $extra_response_data ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | 78 | public function cleanup_job(JobParameters $job_parameters) { |
79 | 79 | $this->_file_helper->delete( |
80 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
80 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
81 | 81 | true, |
82 | 82 | 'd' |
83 | 83 | ); |
84 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
84 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function count_units_to_process() { |
88 | 88 | return \EEM_Attendee::instance()->count(); |
89 | 89 | } |
90 | - public function get_csv_data( $offset, $limit ) { |
|
90 | + public function get_csv_data($offset, $limit) { |
|
91 | 91 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
92 | 92 | array( |
93 | - 'limit' => array( $offset, $limit ), |
|
94 | - 'force_join' => array( 'State', 'Country' ) ) ); |
|
93 | + 'limit' => array($offset, $limit), |
|
94 | + 'force_join' => array('State', 'Country') ) ); |
|
95 | 95 | $csv_data = array(); |
96 | - foreach( $attendee_rows as $attendee_row ){ |
|
96 | + foreach ($attendee_rows as $attendee_row) { |
|
97 | 97 | $csv_row = array(); |
98 | - foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
99 | - if( $field_name == 'STA_ID' ){ |
|
100 | - $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
101 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
102 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
103 | - $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
104 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
105 | - }else{ |
|
106 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
98 | + foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
99 | + if ($field_name == 'STA_ID') { |
|
100 | + $state_name_field = \EEM_State::instance()->field_settings_for('STA_name'); |
|
101 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
102 | + }elseif ($field_name == 'CNT_ISO') { |
|
103 | + $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name'); |
|
104 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
105 | + } else { |
|
106 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | $csv_data[] = $csv_row; |
@@ -99,10 +99,10 @@ |
||
99 | 99 | if( $field_name == 'STA_ID' ){ |
100 | 100 | $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
101 | 101 | $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
102 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
102 | + } elseif( $field_name == 'CNT_ISO' ){ |
|
103 | 103 | $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
104 | 104 | $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
107 | 107 | } |
108 | 108 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class {name} |
|
5 | - * |
|
6 | - * Description here |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage |
|
10 | - * @author Mike Nelson |
|
11 | - * @since 4.8.26 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class {name} |
|
5 | + * |
|
6 | + * Description here |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage |
|
10 | + * @author Mike Nelson |
|
11 | + * @since 4.8.26 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace EventEspressoBatchRequest\JobHandlers; |
16 | 16 | use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile; |