@@ -595,8 +595,6 @@ |
||
595 | 595 | * converts it into a "remote" filepath (the filepath the currently-in-use |
596 | 596 | * $wp_filesystem needs to use access the folder or file). |
597 | 597 | * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins |
598 | - * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one |
|
599 | - * is in use, so you need to provide it |
|
600 | 598 | * @param string $local_filepath the filepath to the folder/file locally |
601 | 599 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
602 | 600 | * ftp or ssh, will use to access the folder |
@@ -27,23 +27,23 @@ discard block |
||
27 | 27 | * @throws EE_Error |
28 | 28 | * @return WP_Filesystem_Base |
29 | 29 | */ |
30 | - private static function _get_wp_filesystem( $filepath = null) { |
|
31 | - if( apply_filters( |
|
30 | + private static function _get_wp_filesystem($filepath = null) { |
|
31 | + if (apply_filters( |
|
32 | 32 | 'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', |
33 | - $filepath && EEH_File::is_in_uploads_folder( $filepath ), |
|
34 | - $filepath ) ) { |
|
35 | - if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) { |
|
36 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
33 | + $filepath && EEH_File::is_in_uploads_folder($filepath), |
|
34 | + $filepath )) { |
|
35 | + if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) { |
|
36 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
37 | 37 | $method = 'direct'; |
38 | - $wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
39 | - require_once( $wp_filesystem_direct_file ); |
|
40 | - EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() ); |
|
38 | + $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
39 | + require_once($wp_filesystem_direct_file); |
|
40 | + EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array()); |
|
41 | 41 | } |
42 | 42 | return EEH_File::$_wp_filesystem_direct; |
43 | 43 | } |
44 | 44 | global $wp_filesystem; |
45 | 45 | // no filesystem setup ??? |
46 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
46 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
47 | 47 | // if some eager beaver's just trying to get in there too early... |
48 | 48 | // let them do it, because we are one of those eager beavers! :P |
49 | 49 | /** |
@@ -56,34 +56,34 @@ discard block |
||
56 | 56 | * and there may be troubles if the WP files are owned by a different user |
57 | 57 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
58 | 58 | */ |
59 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
59 | + if (FALSE && ! did_action('wp_loaded')) { |
|
60 | 60 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
61 | - if ( WP_DEBUG ) { |
|
62 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
61 | + if (WP_DEBUG) { |
|
62 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
63 | 63 | } |
64 | - throw new EE_Error( $msg ); |
|
64 | + throw new EE_Error($msg); |
|
65 | 65 | } else { |
66 | 66 | // should be loaded if we are past the wp_loaded hook... |
67 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
68 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
69 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
67 | + if ( ! function_exists('WP_Filesystem')) { |
|
68 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
69 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
70 | 70 | } |
71 | 71 | // turn on output buffering so that we can capture the credentials form |
72 | 72 | ob_start(); |
73 | - $credentials = request_filesystem_credentials( '' ); |
|
73 | + $credentials = request_filesystem_credentials(''); |
|
74 | 74 | // store credentials form for the time being |
75 | 75 | EEH_File::$_credentials_form = ob_get_clean(); |
76 | 76 | // basically check for direct or previously configured access |
77 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
77 | + if ( ! WP_Filesystem($credentials)) { |
|
78 | 78 | // if credentials do NOT exist |
79 | - if ( $credentials === FALSE ) { |
|
80 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
81 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
82 | - } elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
83 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
79 | + if ($credentials === FALSE) { |
|
80 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
81 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
82 | + } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
83 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
84 | 84 | throw new EE_Error( |
85 | 85 | sprintf( |
86 | - __( 'WP Filesystem Error: $1%s', 'event_espresso' ), |
|
86 | + __('WP Filesystem Error: $1%s', 'event_espresso'), |
|
87 | 87 | $wp_filesystem->errors->get_error_message() ) ); |
88 | 88 | } |
89 | 89 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * display_request_filesystem_credentials_form |
97 | 97 | */ |
98 | 98 | public static function display_request_filesystem_credentials_form() { |
99 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
100 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
99 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
100 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -115,29 +115,29 @@ discard block |
||
115 | 115 | * @throws EE_Error |
116 | 116 | * @return bool |
117 | 117 | */ |
118 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
118 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
119 | 119 | // load WP_Filesystem and set file permissions |
120 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
121 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
122 | - if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) { |
|
123 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
124 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
120 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
121 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
122 | + if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
123 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
124 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
125 | 125 | $msg = sprintf( |
126 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
126 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
127 | 127 | $file_name, |
128 | 128 | '<br />' |
129 | 129 | ); |
130 | - if ( EEH_File::exists( $full_file_path )) { |
|
131 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
130 | + if (EEH_File::exists($full_file_path)) { |
|
131 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
132 | 132 | } else { |
133 | 133 | // no file permissions means the file was not found |
134 | 134 | $msg .= sprintf( |
135 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
135 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
136 | 136 | $full_file_path |
137 | 137 | ); |
138 | 138 | } |
139 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
140 | - throw new EE_Error( $msg . '||' . $msg ); |
|
139 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
140 | + throw new EE_Error($msg.'||'.$msg); |
|
141 | 141 | } |
142 | 142 | return FALSE; |
143 | 143 | } |
@@ -154,24 +154,24 @@ discard block |
||
154 | 154 | * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
157 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
158 | 158 | // load WP_Filesystem and set file permissions |
159 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
159 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
160 | 160 | // check file permissions |
161 | - $perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
162 | - if ( $perms ) { |
|
161 | + $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
162 | + if ($perms) { |
|
163 | 163 | // file permissions exist, but way be set incorrectly |
164 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
165 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
164 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
165 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
166 | 166 | return sprintf( |
167 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
167 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
168 | 168 | $type_of_file, |
169 | 169 | $perms |
170 | 170 | ); |
171 | 171 | } else { |
172 | 172 | // file exists but file permissions could not be read ?!?! |
173 | 173 | return sprintf( |
174 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
174 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
175 | 175 | $full_file_path |
176 | 176 | ); |
177 | 177 | } |
@@ -189,35 +189,35 @@ discard block |
||
189 | 189 | * can't write to it |
190 | 190 | * @return bool false if folder isn't writable; true if it exists and is writeable, |
191 | 191 | */ |
192 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
193 | - if ( empty( $folder )) { |
|
192 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
193 | + if (empty($folder)) { |
|
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | // remove ending DS |
197 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
198 | - $parent_folder = EEH_File::get_parent_folder( $folder ); |
|
197 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
198 | + $parent_folder = EEH_File::get_parent_folder($folder); |
|
199 | 199 | // add DS to folder |
200 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
201 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $folder ); |
|
202 | - if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
200 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
201 | + $wp_filesystem = EEH_File::_get_wp_filesystem($folder); |
|
202 | + if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
203 | 203 | //ok so it doesn't exist. Does its parent? Can we write to it? |
204 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
204 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
207 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
208 | 208 | return false; |
209 | 209 | } else { |
210 | - if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
211 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
212 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
213 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
214 | - throw new EE_Error( $msg ); |
|
210 | + if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
211 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
212 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
213 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
214 | + throw new EE_Error($msg); |
|
215 | 215 | } |
216 | 216 | return false; |
217 | 217 | } |
218 | - EEH_File::add_htaccess_deny_from_all( $folder ); |
|
218 | + EEH_File::add_htaccess_deny_from_all($folder); |
|
219 | 219 | } |
220 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
220 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | return true; |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | * @throws EE_Error |
233 | 233 | * @return bool |
234 | 234 | */ |
235 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
235 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
236 | 236 | // load WP_Filesystem and set file permissions |
237 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_path ); |
|
238 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
239 | - if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) { |
|
240 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
241 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
242 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
243 | - throw new EE_Error( $msg ); |
|
237 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_path); |
|
238 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
239 | + if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) { |
|
240 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
241 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
242 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
243 | + throw new EE_Error($msg); |
|
244 | 244 | } |
245 | 245 | return FALSE; |
246 | 246 | } |
@@ -257,25 +257,25 @@ discard block |
||
257 | 257 | * @throws EE_Error |
258 | 258 | * @return bool |
259 | 259 | */ |
260 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
260 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
261 | 261 | // load WP_Filesystem and set file permissions |
262 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
263 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
264 | - $parent_folder = EEH_File::get_parent_folder( $full_file_path ); |
|
265 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
266 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
262 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
263 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
264 | + $parent_folder = EEH_File::get_parent_folder($full_file_path); |
|
265 | + if ( ! EEH_File::exists($full_file_path)) { |
|
266 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
267 | 267 | return false; |
268 | 268 | } |
269 | - if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
270 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
271 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
272 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
273 | - throw new EE_Error( $msg ); |
|
269 | + if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
270 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
271 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
272 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
273 | + throw new EE_Error($msg); |
|
274 | 274 | } |
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | } |
278 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
278 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
279 | 279 | return false; |
280 | 280 | } |
281 | 281 | return true; |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | * @param string $file_or_folder_path |
288 | 288 | * @return string parent folder, ENDING with a directory separator |
289 | 289 | */ |
290 | - public static function get_parent_folder( $file_or_folder_path ) { |
|
290 | + public static function get_parent_folder($file_or_folder_path) { |
|
291 | 291 | //find the last DS, ignoring a DS on the very end |
292 | 292 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
293 | 293 | //parent folder, "/var/something/" |
294 | - $ds = strrpos( $file_or_folder_path, DS, -2 ); |
|
295 | - return substr( $file_or_folder_path, 0, $ds + 1 ); |
|
294 | + $ds = strrpos($file_or_folder_path, DS, -2); |
|
295 | + return substr($file_or_folder_path, 0, $ds + 1); |
|
296 | 296 | } |
297 | 297 | |
298 | - public static function ensure_folder_exists_recursively( $folder ) { |
|
298 | + public static function ensure_folder_exists_recursively($folder) { |
|
299 | 299 | |
300 | 300 | } |
301 | 301 | |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | * @param string $full_file_path |
307 | 307 | * @return string |
308 | 308 | */ |
309 | - public static function get_file_contents( $full_file_path = '' ){ |
|
310 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
311 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
309 | + public static function get_file_contents($full_file_path = '') { |
|
310 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
311 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
312 | 312 | // load WP_Filesystem and set file permissions |
313 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
314 | - return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
313 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
314 | + return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
315 | 315 | } |
316 | 316 | return ''; |
317 | 317 | } |
@@ -326,26 +326,26 @@ discard block |
||
326 | 326 | * @throws EE_Error |
327 | 327 | * @return bool |
328 | 328 | */ |
329 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
330 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
331 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
332 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
333 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
334 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
335 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
336 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
337 | - throw new EE_Error( $msg ); |
|
329 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
330 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
331 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
332 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
333 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
334 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
335 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
336 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
337 | + throw new EE_Error($msg); |
|
338 | 338 | } |
339 | 339 | return FALSE; |
340 | 340 | } |
341 | 341 | // load WP_Filesystem and set file permissions |
342 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
342 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
343 | 343 | // write the file |
344 | - if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) { |
|
345 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
346 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
347 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
348 | - throw new EE_Error( $msg ); |
|
344 | + if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) { |
|
345 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
346 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
347 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
348 | + throw new EE_Error($msg); |
|
349 | 349 | } |
350 | 350 | return FALSE; |
351 | 351 | } |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | * @param string $full_file_path |
362 | 362 | * @return bool |
363 | 363 | */ |
364 | - public static function exists( $full_file_path = '' ) { |
|
365 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
366 | - return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE; |
|
364 | + public static function exists($full_file_path = '') { |
|
365 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
366 | + return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | * @param string $full_file_path |
376 | 376 | * @return bool |
377 | 377 | */ |
378 | - public static function is_readable( $full_file_path = '' ) { |
|
379 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
380 | - if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
378 | + public static function is_readable($full_file_path = '') { |
|
379 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
380 | + if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
381 | 381 | return true; |
382 | 382 | } else { |
383 | 383 | return false; |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param string $full_file_path |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
397 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
396 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
397 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param string $full_file_path |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
408 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
407 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
408 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $full_file_path |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public static function get_file_extension( $full_file_path = '' ) { |
|
419 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
418 | + public static function get_file_extension($full_file_path = '') { |
|
419 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -427,15 +427,15 @@ discard block |
||
427 | 427 | * @param string $folder |
428 | 428 | * @return bool |
429 | 429 | */ |
430 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
431 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
432 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
433 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
430 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
431 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
432 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
433 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
434 | 434 | return FALSE; |
435 | 435 | } |
436 | 436 | } |
437 | - if ( ! EEH_File::exists( $folder . 'index.html' ) ) { |
|
438 | - if ( ! EEH_File::write_to_file( $folder . 'index.html', 'cheating huh?', '.html' )) { |
|
437 | + if ( ! EEH_File::exists($folder.'index.html')) { |
|
438 | + if ( ! EEH_File::write_to_file($folder.'index.html', 'cheating huh?', '.html')) { |
|
439 | 439 | return FALSE; |
440 | 440 | } |
441 | 441 | } |
@@ -450,11 +450,11 @@ discard block |
||
450 | 450 | * @param string $file_path |
451 | 451 | * @return string |
452 | 452 | */ |
453 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
453 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
454 | 454 | //extract file from path |
455 | - $filename = basename( $file_path ); |
|
455 | + $filename = basename($file_path); |
|
456 | 456 | //now remove the first period and everything after |
457 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
457 | + $pos_of_first_period = strpos($filename, '.'); |
|
458 | 458 | return substr($filename, 0, $pos_of_first_period); |
459 | 459 | } |
460 | 460 | |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | * @param string $file_path |
467 | 467 | * @return string |
468 | 468 | */ |
469 | - public static function standardise_directory_separators( $file_path ){ |
|
470 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
469 | + public static function standardise_directory_separators($file_path) { |
|
470 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $file_path |
479 | 479 | * @return string |
480 | 480 | */ |
481 | - public static function end_with_directory_separator( $file_path ){ |
|
482 | - return rtrim( $file_path, '/\\' ) . DS; |
|
481 | + public static function end_with_directory_separator($file_path) { |
|
482 | + return rtrim($file_path, '/\\').DS; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | * @param $file_path |
490 | 490 | * @return string |
491 | 491 | */ |
492 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
493 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
492 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
493 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -507,21 +507,21 @@ discard block |
||
507 | 507 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
508 | 508 | * and values are their filepaths |
509 | 509 | */ |
510 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
510 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
511 | 511 | $class_to_folder_path = array(); |
512 | - foreach( $folder_paths as $folder_path ){ |
|
513 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
512 | + foreach ($folder_paths as $folder_path) { |
|
513 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
514 | 514 | // load WP_Filesystem and set file permissions |
515 | - $files_in_folder = glob( $folder_path . '*' ); |
|
515 | + $files_in_folder = glob($folder_path.'*'); |
|
516 | 516 | $class_to_folder_path = array(); |
517 | - if ( $files_in_folder ) { |
|
518 | - foreach( $files_in_folder as $file_path ){ |
|
517 | + if ($files_in_folder) { |
|
518 | + foreach ($files_in_folder as $file_path) { |
|
519 | 519 | //only add files, not folders |
520 | - if ( ! is_dir( $file_path )) { |
|
521 | - if ( $index_numerically ) { |
|
520 | + if ( ! is_dir($file_path)) { |
|
521 | + if ($index_numerically) { |
|
522 | 522 | $class_to_folder_path[] = $file_path; |
523 | 523 | } else { |
524 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
524 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
525 | 525 | $class_to_folder_path[$classname] = $file_path; |
526 | 526 | } |
527 | 527 | } |
@@ -541,39 +541,39 @@ discard block |
||
541 | 541 | * @return boolean success |
542 | 542 | * @throws EE_Error |
543 | 543 | */ |
544 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
545 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
546 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
547 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
548 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
549 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
550 | - throw new EE_Error( $msg ); |
|
544 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
545 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
546 | + if ( ! EEH_File::exists($full_source_path)) { |
|
547 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
548 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
549 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
550 | + throw new EE_Error($msg); |
|
551 | 551 | } |
552 | 552 | return FALSE; |
553 | 553 | } |
554 | 554 | |
555 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
556 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
557 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
558 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
559 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
560 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
561 | - throw new EE_Error( $msg ); |
|
555 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
556 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
557 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
558 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
559 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
560 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
561 | + throw new EE_Error($msg); |
|
562 | 562 | } |
563 | 563 | return FALSE; |
564 | 564 | } |
565 | 565 | |
566 | 566 | // load WP_Filesystem and set file permissions |
567 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file ); |
|
567 | + $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file); |
|
568 | 568 | // write the file |
569 | 569 | if ( ! $wp_filesystem->copy( |
570 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), |
|
571 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), |
|
570 | + EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), |
|
571 | + EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), |
|
572 | 572 | $overwrite )) { |
573 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
574 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
575 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
576 | - throw new EE_Error( $msg ); |
|
573 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
574 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
575 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
576 | + throw new EE_Error($msg); |
|
577 | 577 | } |
578 | 578 | return FALSE; |
579 | 579 | } |
@@ -585,9 +585,9 @@ discard block |
||
585 | 585 | * @param string $filepath |
586 | 586 | * @return boolean |
587 | 587 | */ |
588 | - public static function is_in_uploads_folder( $filepath ) { |
|
588 | + public static function is_in_uploads_folder($filepath) { |
|
589 | 589 | $uploads = wp_upload_dir(); |
590 | - return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false; |
|
590 | + return strpos($filepath, $uploads['basedir']) === 0 ? true : false; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
602 | 602 | * ftp or ssh, will use to access the folder |
603 | 603 | */ |
604 | - public static function convert_local_filepath_to_remote_filepath( $local_filepath ) { |
|
605 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath ); |
|
606 | - return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath ); |
|
604 | + public static function convert_local_filepath_to_remote_filepath($local_filepath) { |
|
605 | + $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath); |
|
606 | + return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | // End of file EEH_File.helper.php |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -32,30 +32,30 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - public function __construct( $routing = TRUE ) { |
|
36 | - parent::__construct( $routing ); |
|
37 | - define( 'GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/' ); |
|
35 | + public function __construct($routing = TRUE) { |
|
36 | + parent::__construct($routing); |
|
37 | + define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'general_settings/templates/'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | 42 | protected function _extend_page_config() { |
43 | 43 | |
44 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings'; |
|
44 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'general_settings'; |
|
45 | 45 | |
46 | 46 | //filters and action hooks here |
47 | - add_action('AHEE__admin_option_settings__template__before', array( $this, 'use_venue_and_staff_manager_settings'), 10 ); |
|
48 | - add_action( 'AHEE__admin_option_settings__template__before', array( $this, 'debug_logging_options' ), 9 ); |
|
49 | - add_filter( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', array( $this, 'update_debug_logging_options' ), 10, 1 ); |
|
47 | + add_action('AHEE__admin_option_settings__template__before', array($this, 'use_venue_and_staff_manager_settings'), 10); |
|
48 | + add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9); |
|
49 | + add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', array($this, 'update_debug_logging_options'), 10, 1); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - public function use_venue_and_staff_manager_settings( $template_args ) { |
|
56 | - $_args['use_personnel_manager_select'] = EEH_Form_Fields::select_input('use_personnel_manager', $template_args['values'], $template_args['use_personnel_manager'] ); |
|
57 | - $template = GEN_SET_CAF_TEMPLATE_PATH . 'use_venue_and_staff_manager_settings.template.php'; |
|
58 | - EEH_Template::display_template( $template, $_args ); |
|
55 | + public function use_venue_and_staff_manager_settings($template_args) { |
|
56 | + $_args['use_personnel_manager_select'] = EEH_Form_Fields::select_input('use_personnel_manager', $template_args['values'], $template_args['use_personnel_manager']); |
|
57 | + $template = GEN_SET_CAF_TEMPLATE_PATH.'use_venue_and_staff_manager_settings.template.php'; |
|
58 | + EEH_Template::display_template($template, $_args); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param array $template_args |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function debug_logging_options( $template_args = array() ) { |
|
71 | + public function debug_logging_options($template_args = array()) { |
|
72 | 72 | $template_args['use_full_logging'] = EE_Registry::instance()->CFG->admin->use_full_logging; |
73 | - $template_args['use_remote_logging'] = isset( EE_Registry::instance()->CFG->admin->use_remote_logging ) ? absint( EE_Registry::instance()->CFG->admin->use_remote_logging ) : FALSE; |
|
74 | - $template_args['remote_logging_url'] = isset( EE_Registry::instance()->CFG->admin->remote_logging_url ) && ! empty( EE_Registry::instance()->CFG->admin->remote_logging_url ) ? stripslashes( EE_Registry::instance()->CFG->admin->remote_logging_url ) : ''; |
|
75 | - $template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php'; |
|
76 | - EEH_Template::display_template( $template, $template_args ); |
|
73 | + $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : FALSE; |
|
74 | + $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : ''; |
|
75 | + $template = GEN_SET_CAF_TEMPLATE_PATH.'debug_log_settings.template.php'; |
|
76 | + EEH_Template::display_template($template, $template_args); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | * @param array $admin_options |
85 | 85 | * @return array |
86 | 86 | */ |
87 | - public function update_debug_logging_options( $admin_options = array() ) { |
|
88 | - $use_full_logging = isset( $this->_req_data['use_full_logging'] ) ? (bool)absint( $this->_req_data['use_full_logging'] ) : $admin_options->use_full_logging; |
|
87 | + public function update_debug_logging_options($admin_options = array()) { |
|
88 | + $use_full_logging = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging; |
|
89 | 89 | $admin_options->use_full_logging = $use_full_logging; |
90 | 90 | |
91 | - if ( $use_full_logging === FALSE ) { |
|
92 | - EE_Error::get_notices( FALSE ); |
|
91 | + if ($use_full_logging === FALSE) { |
|
92 | + EE_Error::get_notices(FALSE); |
|
93 | 93 | EE_Error::reset_notices(); |
94 | 94 | } |
95 | 95 | |
96 | - $admin_options->use_remote_logging = isset( $this->_req_data['use_remote_logging'] ) ? absint( $this->_req_data['use_remote_logging'] ) : $admin_options->use_remote_logging; |
|
97 | - $admin_options->remote_logging_url = isset( $this->_req_data['remote_logging_url'] ) ? esc_url_raw( $this->_req_data['remote_logging_url'] ) : $admin_options->remote_logging_url; |
|
96 | + $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging; |
|
97 | + $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url; |
|
98 | 98 | return $admin_options; |
99 | 99 | } |
100 | 100 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
3 | -if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) { |
|
4 | - set_error_handler( array( 'EE_Error', 'error_handler' )); |
|
5 | - register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' )); |
|
3 | +if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) { |
|
4 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
5 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
6 | 6 | } |
7 | 7 | /** |
8 | 8 | * |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access private |
65 | 65 | * @var boolean |
66 | 66 | */ |
67 | - private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
|
67 | + private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @access public |
76 | 76 | * @echo string |
77 | 77 | */ |
78 | - function __construct( $message, $code = 0, Exception $previous = NULL ) { |
|
79 | - if ( version_compare( phpversion(), '5.3.0', '<' )) { |
|
80 | - parent::__construct( $message, $code ); |
|
78 | + function __construct($message, $code = 0, Exception $previous = NULL) { |
|
79 | + if (version_compare(phpversion(), '5.3.0', '<')) { |
|
80 | + parent::__construct($message, $code); |
|
81 | 81 | } else { |
82 | - parent::__construct( $message, $code, $previous ); |
|
82 | + parent::__construct($message, $code, $previous); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param $line |
95 | 95 | * @return void |
96 | 96 | */ |
97 | - public static function error_handler( $code, $message, $file, $line ) { |
|
98 | - $type = EE_Error::error_type( $code ); |
|
97 | + public static function error_handler($code, $message, $file, $line) { |
|
98 | + $type = EE_Error::error_type($code); |
|
99 | 99 | $site = site_url(); |
100 | - switch ( $site ) { |
|
100 | + switch ($site) { |
|
101 | 101 | case 'http://ee4.eventespresso.com/' : |
102 | 102 | case 'http://ee4decaf.eventespresso.com/' : |
103 | 103 | case 'http://ee4hf.eventespresso.com/' : |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | $to = '[email protected]'; |
111 | 111 | break; |
112 | 112 | default : |
113 | - $to = get_option( 'admin_email' ); |
|
113 | + $to = get_option('admin_email'); |
|
114 | 114 | } |
115 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
116 | - $msg = EE_Error::_format_error( $type, $message, $file, $line ); |
|
117 | - if ( function_exists( 'wp_mail' )) { |
|
118 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | - wp_mail( $to, $subject, $msg ); |
|
115 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
116 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
117 | + if (function_exists('wp_mail')) { |
|
118 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
119 | + wp_mail($to, $subject, $msg); |
|
120 | 120 | } |
121 | 121 | echo '<div id="message" class="espresso-notices error"><p>'; |
122 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
122 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
123 | 123 | echo '<br /></p></div>'; |
124 | 124 | } |
125 | 125 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param $code |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public static function error_type( $code ) { |
|
136 | - switch( $code ) { |
|
135 | + public static function error_type($code) { |
|
136 | + switch ($code) { |
|
137 | 137 | case E_ERROR: // 1 // |
138 | 138 | return 'E_ERROR'; |
139 | 139 | case E_WARNING: // 2 // |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function fatal_error_handler() { |
181 | 181 | $last_error = error_get_last(); |
182 | - if ( $last_error['type'] === E_ERROR ) { |
|
183 | - EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] ); |
|
182 | + if ($last_error['type'] === E_ERROR) { |
|
183 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param $line |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - private static function _format_error( $code, $message, $file, $line ) { |
|
198 | + private static function _format_error($code, $message, $file, $line) { |
|
199 | 199 | $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
200 | 200 | $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
201 | 201 | $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param $content_type |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - public static function set_content_type( $content_type ) { |
|
216 | + public static function set_content_type($content_type) { |
|
217 | 217 | return 'text/html'; |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function get_error() { |
229 | 229 | |
230 | - if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
|
230 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) { |
|
231 | 231 | throw $this; |
232 | 232 | } |
233 | 233 | // get separate user and developer messages if they exist |
234 | - $msg = explode( '||', $this->getMessage() ); |
|
234 | + $msg = explode('||', $this->getMessage()); |
|
235 | 235 | $user_msg = $msg[0]; |
236 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
236 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
237 | 237 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
238 | 238 | |
239 | 239 | // add details to _all_exceptions array |
240 | 240 | $x_time = time(); |
241 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
242 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
243 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
244 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
245 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
246 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
247 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
241 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
242 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
243 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
244 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
245 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
246 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
247 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
248 | 248 | self::$_error_count++; |
249 | 249 | |
250 | 250 | //add_action( 'shutdown', array( $this, 'display_errors' )); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @access public |
260 | 260 | * @return boolean |
261 | 261 | */ |
262 | - public static function has_error(){ |
|
262 | + public static function has_error() { |
|
263 | 263 | return self::$_error_count ? TRUE : FALSE; |
264 | 264 | } |
265 | 265 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @access public |
271 | 271 | * @echo string |
272 | 272 | */ |
273 | - public function display_errors(){ |
|
273 | + public function display_errors() { |
|
274 | 274 | |
275 | 275 | $trace_details = ''; |
276 | 276 | |
@@ -331,18 +331,18 @@ discard block |
||
331 | 331 | </style> |
332 | 332 | <div id="ee-error-message" class="error">'; |
333 | 333 | |
334 | - if ( ! WP_DEBUG ) { |
|
334 | + if ( ! WP_DEBUG) { |
|
335 | 335 | $output .= ' |
336 | 336 | <p>'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // cycle thru errors |
340 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
340 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
341 | 341 | |
342 | 342 | // process trace info |
343 | - if ( empty( $ex['trace'] )) { |
|
343 | + if (empty($ex['trace'])) { |
|
344 | 344 | |
345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
345 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
@@ -357,50 +357,50 @@ discard block |
||
357 | 357 | <th scope="col" align="left">Method( arguments )</th> |
358 | 358 | </tr>'; |
359 | 359 | |
360 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
360 | + $last_on_stack = count($ex['trace']) - 1; |
|
361 | 361 | // reverse array so that stack is in proper chronological order |
362 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
362 | + $sorted_trace = array_reverse($ex['trace']); |
|
363 | 363 | |
364 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
364 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
365 | 365 | |
366 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
367 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
368 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
369 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
370 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
371 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
366 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
367 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
368 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
369 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
370 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
371 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
372 | 372 | $zebra = $nmbr % 2 ? ' odd' : ''; |
373 | 373 | |
374 | - if ( empty( $file ) && ! empty( $class )) { |
|
375 | - $a = new ReflectionClass( $class ); |
|
374 | + if (empty($file) && ! empty($class)) { |
|
375 | + $a = new ReflectionClass($class); |
|
376 | 376 | $file = $a->getFileName(); |
377 | - if ( empty( $line ) && ! empty( $function )) { |
|
378 | - $b = new ReflectionMethod( $class, $function ); |
|
377 | + if (empty($line) && ! empty($function)) { |
|
378 | + $b = new ReflectionMethod($class, $function); |
|
379 | 379 | $line = $b->getStartLine(); |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( $nmbr == $last_on_stack ) { |
|
383 | + if ($nmbr == $last_on_stack) { |
|
384 | 384 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
385 | 385 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
386 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
386 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
387 | 387 | } |
388 | 388 | |
389 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
390 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
391 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
392 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
393 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
394 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
395 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
389 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
390 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
391 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
392 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
393 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
394 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
395 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
396 | 396 | |
397 | 397 | $trace_details .= ' |
398 | 398 | <tr> |
399 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
400 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
401 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
402 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
403 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
399 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
400 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
401 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
402 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
403 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
404 | 404 | </tr>'; |
405 | 405 | |
406 | 406 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
416 | 416 | |
417 | 417 | // add generic non-identifying messages for non-privileged uesrs |
418 | - if ( ! WP_DEBUG ) { |
|
418 | + if ( ! WP_DEBUG) { |
|
419 | 419 | |
420 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
420 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
421 | 421 | |
422 | 422 | } else { |
423 | 423 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $output .= ' |
426 | 426 | <div class="ee-error-dev-msg-dv"> |
427 | 427 | <p class="ee-error-dev-msg-pg"> |
428 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
429 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
430 | - <a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '"> |
|
431 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
428 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
429 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
430 | + <a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'"> |
|
431 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
432 | 432 | </a><br /> |
433 | 433 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
434 | 434 | </p> |
435 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
435 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
436 | 436 | ' . $trace_details; |
437 | 437 | |
438 | - if ( ! empty( $class )) { |
|
438 | + if ( ! empty($class)) { |
|
439 | 439 | $output .= ' |
440 | 440 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
441 | 441 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
442 | 442 | <h3>Class Details</h3>'; |
443 | - $a = new ReflectionClass( $class ); |
|
443 | + $a = new ReflectionClass($class); |
|
444 | 444 | $output .= ' |
445 | - <pre>' . $a . '</pre> |
|
445 | + <pre>' . $a.'</pre> |
|
446 | 446 | </div> |
447 | 447 | </div>'; |
448 | 448 | } |
@@ -454,14 +454,14 @@ discard block |
||
454 | 454 | |
455 | 455 | } |
456 | 456 | |
457 | - $this->write_to_error_log( $time, $ex ); |
|
457 | + $this->write_to_error_log($time, $ex); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | 461 | // remove last linebreak |
462 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
462 | + $output = substr($output, 0, (count($output) - 7)); |
|
463 | 463 | |
464 | - if ( ! WP_DEBUG ) { |
|
464 | + if ( ! WP_DEBUG) { |
|
465 | 465 | $output .= ' |
466 | 466 | </p>'; |
467 | 467 | } |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | $output .= ' |
470 | 470 | </div>'; |
471 | 471 | |
472 | - $output .= self::_print_scripts( TRUE ); |
|
472 | + $output .= self::_print_scripts(TRUE); |
|
473 | 473 | |
474 | - if ( defined( 'DOING_AJAX' )) { |
|
475 | - echo json_encode( array( 'error' => $output )); |
|
474 | + if (defined('DOING_AJAX')) { |
|
475 | + echo json_encode(array('error' => $output)); |
|
476 | 476 | exit(); |
477 | 477 | } |
478 | 478 | |
@@ -492,29 +492,29 @@ discard block |
||
492 | 492 | * @ param array $arguments |
493 | 493 | * @ return string |
494 | 494 | */ |
495 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
495 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
496 | 496 | |
497 | 497 | $arg_string = ''; |
498 | - if ( ! empty( $arguments )) { |
|
498 | + if ( ! empty($arguments)) { |
|
499 | 499 | |
500 | 500 | $args = array(); |
501 | 501 | |
502 | - foreach ( $arguments as $arg ) { |
|
502 | + foreach ($arguments as $arg) { |
|
503 | 503 | |
504 | - if ( ! empty( $arg )) { |
|
504 | + if ( ! empty($arg)) { |
|
505 | 505 | |
506 | - if ( is_string( $arg )) { |
|
507 | - $args[] = " '" . $arg . "'"; |
|
508 | - } elseif ( is_array( $arg )) { |
|
509 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
510 | - } elseif ( is_null( $arg )) { |
|
506 | + if (is_string($arg)) { |
|
507 | + $args[] = " '".$arg."'"; |
|
508 | + } elseif (is_array($arg)) { |
|
509 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
510 | + } elseif (is_null($arg)) { |
|
511 | 511 | $args[] = ' NULL'; |
512 | - } elseif ( is_bool( $arg )) { |
|
513 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
514 | - } elseif ( is_object( $arg )) { |
|
515 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
516 | - } elseif ( is_resource( $arg )) { |
|
517 | - $args[] = get_resource_type( $arg ); |
|
512 | + } elseif (is_bool($arg)) { |
|
513 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
514 | + } elseif (is_object($arg)) { |
|
515 | + $args[] = ' OBJECT '.get_class($arg); |
|
516 | + } elseif (is_resource($arg)) { |
|
517 | + $args[] = get_resource_type($arg); |
|
518 | 518 | } else { |
519 | 519 | $args[] = $arg; |
520 | 520 | } |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
525 | - $arg_string = implode( ', ', $args ); |
|
525 | + $arg_string = implode(', ', $args); |
|
526 | 526 | } |
527 | - if ( $array ) { |
|
527 | + if ($array) { |
|
528 | 528 | $arg_string .= ' )'; |
529 | 529 | } |
530 | 530 | return $arg_string; |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $line the line number where the error occurred - just use __LINE__ |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
548 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
547 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
548 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
549 | 549 | self::$_error_count++; |
550 | 550 | } |
551 | 551 | |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @param string $line the line number where the error occurred - just use __LINE__ |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
567 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
566 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
567 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
@@ -581,8 +581,8 @@ discard block |
||
581 | 581 | * @param string $line the line number where the error occurred - just use __LINE__ |
582 | 582 | * @return void |
583 | 583 | */ |
584 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
585 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
584 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
585 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | |
@@ -600,12 +600,12 @@ discard block |
||
600 | 600 | * @param string $line the line number where the error occurred - just use __LINE__ |
601 | 601 | * @return void |
602 | 602 | */ |
603 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
604 | - if ( empty( $msg )) { |
|
603 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
604 | + if (empty($msg)) { |
|
605 | 605 | EE_Error::doing_it_wrong( |
606 | - 'EE_Error::add_' . $type . '()', |
|
606 | + 'EE_Error::add_'.$type.'()', |
|
607 | 607 | sprintf( |
608 | - __( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ), |
|
608 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), |
|
609 | 609 | $type, |
610 | 610 | $file, |
611 | 611 | $line |
@@ -613,27 +613,27 @@ discard block |
||
613 | 613 | EVENT_ESPRESSO_VERSION |
614 | 614 | ); |
615 | 615 | } |
616 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
616 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
617 | 617 | EE_Error::doing_it_wrong( |
618 | 618 | 'EE_Error::add_error()', |
619 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ), |
|
619 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), |
|
620 | 620 | EVENT_ESPRESSO_VERSION |
621 | 621 | ); |
622 | 622 | } |
623 | 623 | // get separate user and developer messages if they exist |
624 | - $msg = explode( '||', $msg ); |
|
624 | + $msg = explode('||', $msg); |
|
625 | 625 | $user_msg = $msg[0]; |
626 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
626 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
627 | 627 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
628 | 628 | // add notice if message exists |
629 | - if ( ! empty( $msg )) { |
|
629 | + if ( ! empty($msg)) { |
|
630 | 630 | // get error code, but only on error |
631 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
632 | - $msg .= '<br/><span class="tiny-text">' . EE_Error::generate_error_code( $file, $func, $line ) . '</span>'; |
|
631 | + if (WP_DEBUG && $type == 'errors') { |
|
632 | + $msg .= '<br/><span class="tiny-text">'.EE_Error::generate_error_code($file, $func, $line).'</span>'; |
|
633 | 633 | } |
634 | 634 | // add notice |
635 | - self::$_espresso_notices[ $type ][] = $msg; |
|
636 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
635 | + self::$_espresso_notices[$type][] = $msg; |
|
636 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | * @access private |
688 | 688 | * @return void |
689 | 689 | */ |
690 | - public static function reset_notices(){ |
|
690 | + public static function reset_notices() { |
|
691 | 691 | self::$_espresso_notices['success'] = FALSE; |
692 | 692 | self::$_espresso_notices['attention'] = FALSE; |
693 | 693 | self::$_espresso_notices['errors'] = FALSE; |
@@ -700,14 +700,14 @@ discard block |
||
700 | 700 | * @access public |
701 | 701 | * @return int |
702 | 702 | */ |
703 | - public static function has_notices(){ |
|
703 | + public static function has_notices() { |
|
704 | 704 | $has_notices = 0; |
705 | 705 | // check for success messages |
706 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
706 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
707 | 707 | // check for attention messages |
708 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
708 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
709 | 709 | // check for error messages |
710 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
710 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
711 | 711 | return $has_notices; |
712 | 712 | } |
713 | 713 | |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | * @param boolean $remove_empty whether or not to unset empty messages |
723 | 723 | * @return array |
724 | 724 | */ |
725 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
726 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
725 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
726 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
727 | 727 | |
728 | 728 | $success_messages = ''; |
729 | 729 | $attention_messages = ''; |
@@ -733,44 +733,44 @@ discard block |
||
733 | 733 | // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
734 | 734 | |
735 | 735 | // either save notices to the db |
736 | - if ( $save_to_transient ) { |
|
737 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
736 | + if ($save_to_transient) { |
|
737 | + update_option('ee_notices', self::$_espresso_notices); |
|
738 | 738 | return; |
739 | 739 | } |
740 | 740 | // grab any notices that have been previously saved |
741 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
742 | - foreach ( $notices as $type => $notice ) { |
|
743 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
741 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
742 | + foreach ($notices as $type => $notice) { |
|
743 | + if (is_array($notice) && ! empty($notice)) { |
|
744 | 744 | // make sure that existsing notice type is an array |
745 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
745 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
746 | 746 | // merge stored notices with any newly created ones |
747 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
747 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
748 | 748 | $print_scripts = TRUE; |
749 | 749 | } |
750 | 750 | } |
751 | 751 | // now clear any stored notices |
752 | - update_option( 'ee_notices', FALSE ); |
|
752 | + update_option('ee_notices', FALSE); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | // check for success messages |
756 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
756 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
757 | 757 | // combine messages |
758 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
758 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
759 | 759 | $print_scripts = TRUE; |
760 | 760 | } |
761 | 761 | |
762 | 762 | // check for attention messages |
763 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
763 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
764 | 764 | // combine messages |
765 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
765 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
766 | 766 | $print_scripts = TRUE; |
767 | 767 | } |
768 | 768 | |
769 | 769 | // check for error messages |
770 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
771 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
770 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
771 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
772 | 772 | // combine messages |
773 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
773 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
774 | 774 | $print_scripts = TRUE; |
775 | 775 | } |
776 | 776 | |
@@ -784,21 +784,21 @@ discard block |
||
784 | 784 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
785 | 785 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
786 | 786 | //showMessage( $success_messages ); |
787 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
787 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | if ($attention_messages != '') { |
791 | 791 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
792 | 792 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
793 | 793 | //showMessage( $error_messages, TRUE ); |
794 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
794 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | if ($error_messages != '') { |
798 | 798 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
799 | 799 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
800 | 800 | //showMessage( $error_messages, TRUE ); |
801 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
801 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | $notices .= '</div>'; |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | 'errors' => $error_messages |
812 | 812 | ); |
813 | 813 | |
814 | - if ( $remove_empty ) { |
|
814 | + if ($remove_empty) { |
|
815 | 815 | // remove empty notices |
816 | 816 | foreach ($notices as $type => $notice) { |
817 | 817 | if (empty($notice)) { |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | } |
822 | 822 | } |
823 | 823 | |
824 | - if ( $print_scripts ) { |
|
824 | + if ($print_scripts) { |
|
825 | 825 | self::_print_scripts(); |
826 | 826 | } |
827 | 827 | |
@@ -841,17 +841,17 @@ discard block |
||
841 | 841 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
842 | 842 | * @return void |
843 | 843 | */ |
844 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
845 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
846 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
844 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
845 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
846 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
847 | 847 | //maybe initialize persistent_admin_notices |
848 | - if ( empty( $persistent_admin_notices )) { |
|
849 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
848 | + if (empty($persistent_admin_notices)) { |
|
849 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
850 | 850 | } |
851 | - $pan_name = sanitize_key( $pan_name ); |
|
852 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
853 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
854 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
851 | + $pan_name = sanitize_key($pan_name); |
|
852 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
853 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
854 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -867,34 +867,34 @@ discard block |
||
867 | 867 | * @param bool $return_immediately |
868 | 868 | * @return void |
869 | 869 | */ |
870 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
871 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
872 | - if ( ! empty( $pan_name )) { |
|
873 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
870 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
871 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
872 | + if ( ! empty($pan_name)) { |
|
873 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
874 | 874 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
875 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
875 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
876 | 876 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
877 | - if ( $purge ) { |
|
878 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
877 | + if ($purge) { |
|
878 | + unset($persistent_admin_notices[$pan_name]); |
|
879 | 879 | } else { |
880 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
880 | + $persistent_admin_notices[$pan_name] = NULL; |
|
881 | 881 | } |
882 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
883 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
882 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
883 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | } |
887 | - if ( $return_immediately ) { |
|
887 | + if ($return_immediately) { |
|
888 | 888 | return; |
889 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
889 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
890 | 890 | // grab any notices and concatenate into string |
891 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
891 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
892 | 892 | exit(); |
893 | 893 | } else { |
894 | 894 | // save errors to a transient to be displayed on next request (after redirect) |
895 | - EE_Error::get_notices( FALSE, TRUE ); |
|
896 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
897 | - wp_safe_redirect( urldecode( $return_url )); |
|
895 | + EE_Error::get_notices(FALSE, TRUE); |
|
896 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
897 | + wp_safe_redirect(urldecode($return_url)); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
@@ -909,20 +909,20 @@ discard block |
||
909 | 909 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
910 | 910 | * @return string |
911 | 911 | */ |
912 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
913 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
912 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
913 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
914 | 914 | $args = array( |
915 | 915 | 'nag_notice' => $pan_name, |
916 | - 'return_url' => urlencode( $return_url ), |
|
916 | + 'return_url' => urlencode($return_url), |
|
917 | 917 | 'ajax_url' => WP_AJAX_URL, |
918 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
918 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
919 | 919 | ); |
920 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
920 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
921 | 921 | return ' |
922 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
923 | - <p>' . $pan_message . '</p> |
|
924 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
925 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
922 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
923 | + <p>' . $pan_message.'</p> |
|
924 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
925 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
926 | 926 | </a> |
927 | 927 | <div style="clear:both;"></div> |
928 | 928 | </div>'; |
@@ -938,17 +938,17 @@ discard block |
||
938 | 938 | * @param string $return_url |
939 | 939 | * @return array |
940 | 940 | */ |
941 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
941 | + public static function get_persistent_admin_notices($return_url = '') { |
|
942 | 942 | $notices = ''; |
943 | 943 | // check for persistent admin notices |
944 | - if ( $persistent_admin_notices = get_option( 'ee_pers_admin_notices', FALSE )) { |
|
944 | + if ($persistent_admin_notices = get_option('ee_pers_admin_notices', FALSE)) { |
|
945 | 945 | // load scripts |
946 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
947 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
948 | - wp_enqueue_script( 'ee_error_js' ); |
|
946 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
947 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
948 | + wp_enqueue_script('ee_error_js'); |
|
949 | 949 | // and display notices |
950 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
951 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
950 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
951 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | return $notices; |
@@ -963,26 +963,26 @@ discard block |
||
963 | 963 | * @param bool $force_print |
964 | 964 | * @return void |
965 | 965 | */ |
966 | - private static function _print_scripts( $force_print = FALSE ) { |
|
967 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
968 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
966 | + private static function _print_scripts($force_print = FALSE) { |
|
967 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
968 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
969 | 969 | return; |
970 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
971 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
972 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
973 | - wp_enqueue_script( 'ee_error_js' ); |
|
974 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
970 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
971 | + add_filter('FHEE_load_css', '__return_true'); |
|
972 | + add_filter('FHEE_load_js', '__return_true'); |
|
973 | + wp_enqueue_script('ee_error_js'); |
|
974 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
975 | 975 | } |
976 | 976 | } else { |
977 | 977 | return ' |
978 | 978 | <script> |
979 | 979 | /* <![CDATA[ */ |
980 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
980 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
981 | 981 | /* ]]> */ |
982 | 982 | </script> |
983 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
984 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
985 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
983 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
984 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
985 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
986 | 986 | '; |
987 | 987 | |
988 | 988 | } |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | * @ param string $line |
1017 | 1017 | * @ return string |
1018 | 1018 | */ |
1019 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
1020 | - $file = explode( '.', basename( $file )); |
|
1021 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
1022 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
1023 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
1019 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
1020 | + $file = explode('.', basename($file)); |
|
1021 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1022 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1023 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1024 | 1024 | return $error_code; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1036,36 +1036,36 @@ discard block |
||
1036 | 1036 | * @ param object $ex |
1037 | 1037 | * @ return void |
1038 | 1038 | */ |
1039 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
1039 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
1040 | 1040 | |
1041 | - if ( ! $ex ) { |
|
1041 | + if ( ! $ex) { |
|
1042 | 1042 | return; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - if ( ! $time ) { |
|
1045 | + if ( ! $time) { |
|
1046 | 1046 | $time = time(); |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1050 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
1051 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1052 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
1053 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
1054 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1055 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1056 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1057 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1058 | - |
|
1059 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1049 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1050 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1051 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1052 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1053 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1054 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1055 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1056 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1057 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1058 | + |
|
1059 | + EE_Registry::instance()->load_helper('File'); |
|
1060 | 1060 | try { |
1061 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
1062 | - if ( ! $clear ) { |
|
1061 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
1062 | + if ( ! $clear) { |
|
1063 | 1063 | //get existing log file and append new log info |
1064 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
1064 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
1065 | 1065 | } |
1066 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
1067 | - } catch( EE_Error $e ){ |
|
1068 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
1066 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
1067 | + } catch (EE_Error $e) { |
|
1068 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
1069 | 1069 | return; |
1070 | 1070 | } |
1071 | 1071 | |
@@ -1089,10 +1089,10 @@ discard block |
||
1089 | 1089 | * @param int $error_type |
1090 | 1090 | * @return void |
1091 | 1091 | */ |
1092 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
1093 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
1092 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
1093 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1094 | 1094 | EE_Registry::instance()->load_helper('Debug_Tools'); |
1095 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
1095 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
1096 | 1096 | } |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1112,13 +1112,13 @@ discard block |
||
1112 | 1112 | */ |
1113 | 1113 | function espresso_error_enqueue_scripts() { |
1114 | 1114 | // js for error handling |
1115 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1116 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1115 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1116 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1117 | 1117 | } |
1118 | -if ( is_admin() ) { |
|
1119 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1118 | +if (is_admin()) { |
|
1119 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1120 | 1120 | } else { |
1121 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1121 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 |
@@ -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,11 +108,11 @@ 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 | - } catch( EE_Error $e ){ |
|
115 | - 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 | + } catch (EE_Error $e) { |
|
115 | + EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | } |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * @param string $type |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - private function _format_message( $file = '', $function = '', $message = '', $type = '' ) { |
|
133 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
134 | - $msg .= '[' . current_time( 'mysql' ) . '] '; |
|
135 | - $msg .= ! empty( $file ) ? basename( $file ) : ''; |
|
136 | - $msg .= ! empty( $file ) && ! empty( $function ) ? ' -> ' : ''; |
|
137 | - $msg .= ! empty( $function ) ? $function . '()' : ''; |
|
132 | + private function _format_message($file = '', $function = '', $message = '', $type = '') { |
|
133 | + $msg = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
134 | + $msg .= '['.current_time('mysql').'] '; |
|
135 | + $msg .= ! empty($file) ? basename($file) : ''; |
|
136 | + $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
137 | + $msg .= ! empty($function) ? $function.'()' : ''; |
|
138 | 138 | $msg .= PHP_EOL; |
139 | - $type = ! empty( $type ) ? $type : 'log message'; |
|
140 | - $msg .= ! empty( $message ) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
139 | + $type = ! empty($type) ? $type : 'log message'; |
|
140 | + $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : ''; |
|
141 | 141 | return $msg; |
142 | 142 | } |
143 | 143 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param string $message |
153 | 153 | * @param string $type |
154 | 154 | */ |
155 | - public function log( $file = '', $function = '', $message = '', $type = '' ) { |
|
156 | - $this->_log .= $this->_format_message( $file, $function, $message, $type ); |
|
155 | + public function log($file = '', $function = '', $message = '', $type = '') { |
|
156 | + $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | public function write_log() { |
166 | 166 | try { |
167 | 167 | //get existing log file and append new log info |
168 | - $this->_log = EEH_File::get_file_contents( $this->_logs_folder . $this->_log_file ) . $this->_log; |
|
169 | - EEH_File::write_to_file( $this->_logs_folder . $this->_log_file, $this->_log, 'Event Espresso Log' ); |
|
170 | - } catch( EE_Error $e ){ |
|
171 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
168 | + $this->_log = EEH_File::get_file_contents($this->_logs_folder.$this->_log_file).$this->_log; |
|
169 | + EEH_File::write_to_file($this->_logs_folder.$this->_log_file, $this->_log, 'Event Espresso Log'); |
|
170 | + } catch (EE_Error $e) { |
|
171 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | } |
@@ -181,31 +181,31 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function send_log() { |
183 | 183 | |
184 | - if ( empty( $this->_remote_logging_url )) { |
|
184 | + if (empty($this->_remote_logging_url)) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | 187 | |
188 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
189 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
190 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
191 | - $data .= '&time=' . time(); |
|
192 | - $data .= '&remote_log=' . $this->_log; |
|
193 | - $data .= '&request_array=' . json_encode( $_REQUEST ); |
|
188 | + $data = 'domain='.$_SERVER['HTTP_HOST']; |
|
189 | + $data .= '&ip='.$_SERVER['SERVER_ADDR']; |
|
190 | + $data .= '&server_type='.$_SERVER['SERVER_SOFTWARE']; |
|
191 | + $data .= '&time='.time(); |
|
192 | + $data .= '&remote_log='.$this->_log; |
|
193 | + $data .= '&request_array='.json_encode($_REQUEST); |
|
194 | 194 | $data .= '&action=save'; |
195 | 195 | |
196 | - if ( defined( 'EELOGGING_PASS' )) { |
|
197 | - $data .= '&pass=' . EELOGGING_PASS; |
|
196 | + if (defined('EELOGGING_PASS')) { |
|
197 | + $data .= '&pass='.EELOGGING_PASS; |
|
198 | 198 | } |
199 | - if ( defined( 'EELOGGING_KEY' )) { |
|
200 | - $data .= '&key=' . EELOGGING_KEY; |
|
199 | + if (defined('EELOGGING_KEY')) { |
|
200 | + $data .= '&key='.EELOGGING_KEY; |
|
201 | 201 | } |
202 | 202 | |
203 | - $c = curl_init( $this->_remote_logging_url ); |
|
204 | - curl_setopt( $c, CURLOPT_POST, TRUE ); |
|
205 | - curl_setopt( $c, CURLOPT_POSTFIELDS, $data ); |
|
206 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, TRUE ); |
|
207 | - curl_exec( $c ); |
|
208 | - curl_close( $c ); |
|
203 | + $c = curl_init($this->_remote_logging_url); |
|
204 | + curl_setopt($c, CURLOPT_POST, TRUE); |
|
205 | + curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
206 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); |
|
207 | + curl_exec($c); |
|
208 | + curl_close($c); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | * previous entries are overwritten |
217 | 217 | */ |
218 | 218 | public function write_debug() { |
219 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
219 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
220 | 220 | $this->_debug_log = ''; |
221 | - foreach ( $_GET as $key => $value ) { |
|
222 | - $this->_debug_log .= '$_GET["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
221 | + foreach ($_GET as $key => $value) { |
|
222 | + $this->_debug_log .= '$_GET["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
223 | 223 | } |
224 | - foreach ( $_POST as $key => $value ) { |
|
225 | - $this->_debug_log .= '$_POST["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
224 | + foreach ($_POST as $key => $value) { |
|
225 | + $this->_debug_log .= '$_POST["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
226 | 226 | } |
227 | 227 | try { |
228 | - EEH_File::write_to_file( $this->_logs_folder . $this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log' ); |
|
229 | - } catch( EE_Error $e ){ |
|
230 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso debug log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
228 | + EEH_File::write_to_file($this->_logs_folder.$this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log'); |
|
229 | + } catch (EE_Error $e) { |
|
230 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso debug log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * __clone |
240 | 240 | */ |
241 | 241 | public function __clone() { |
242 | - trigger_error( __( 'Clone is not allowed.', 'event_espresso' ), E_USER_ERROR ); |
|
242 | + trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param $table_name |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
60 | + public static function ensure_table_name_has_prefix($table_name) { |
|
61 | 61 | global $wpdb; |
62 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
62 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * be called on plugin activation and reactivation |
86 | 86 | * @return boolean success, whether the database and folders are setup properly |
87 | 87 | */ |
88 | - public static function initialize_db_and_folders(){ |
|
88 | + public static function initialize_db_and_folders() { |
|
89 | 89 | $good_filesystem = EEH_Activation::create_upload_directories(); |
90 | 90 | $good_db = EEH_Activation::create_database_tables(); |
91 | 91 | return $good_filesystem && $good_db; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * upon activation of a new plugin, reactivation, and at the end |
100 | 100 | * of running migration scripts |
101 | 101 | */ |
102 | - public static function initialize_db_content(){ |
|
102 | + public static function initialize_db_content() { |
|
103 | 103 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
104 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
104 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | EEH_Activation::remove_cron_tasks(); |
119 | 119 | EEH_Activation::create_cron_tasks(); |
120 | 120 | //also, check for CAF default db content |
121 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
121 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
122 | 122 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
123 | 123 | //which users really won't care about on initial activation |
124 | 124 | EE_Error::overwrite_success(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return array |
138 | 138 | * @throws \EE_Error |
139 | 139 | */ |
140 | - public static function get_cron_tasks( $which_to_include ) { |
|
140 | + public static function get_cron_tasks($which_to_include) { |
|
141 | 141 | $cron_tasks = apply_filters( |
142 | 142 | 'FHEE__EEH_Activation__get_cron_tasks', |
143 | 143 | array( |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
147 | 147 | ) |
148 | 148 | ); |
149 | - if( $which_to_include === 'all' ) { |
|
149 | + if ($which_to_include === 'all') { |
|
150 | 150 | //leave as-is |
151 | - }elseif( $which_to_include === 'old' ) { |
|
152 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
151 | + }elseif ($which_to_include === 'old') { |
|
152 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
153 | 153 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
154 | 154 | }); |
155 | - }elseif( $which_to_include === 'current' ) { |
|
156 | - $cron_tasks = array_filter( $cron_tasks ); |
|
157 | - }elseif( WP_DEBUG ) { |
|
158 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
159 | - }else{ |
|
155 | + }elseif ($which_to_include === 'current') { |
|
156 | + $cron_tasks = array_filter($cron_tasks); |
|
157 | + }elseif (WP_DEBUG) { |
|
158 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
159 | + } else { |
|
160 | 160 | //leave as-is |
161 | 161 | } |
162 | 162 | return $cron_tasks; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public static function create_cron_tasks() { |
169 | 169 | |
170 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
171 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
172 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
170 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
171 | + if ( ! wp_next_scheduled($hook_name)) { |
|
172 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * Remove the currently-existing and now-removed cron tasks. |
180 | 180 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
181 | 181 | */ |
182 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
182 | + public static function remove_cron_tasks($remove_all = true) { |
|
183 | 183 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
184 | 184 | $crons = _get_cron_array(); |
185 | - $crons = is_array( $crons ) ? $crons : array(); |
|
185 | + $crons = is_array($crons) ? $crons : array(); |
|
186 | 186 | /* reminder that $crons looks like: top-level keys are timestamps, |
187 | 187 | * and their values are arrays. |
188 | 188 | * The 2nd level arrays have keys with each of the cron task hooknames to run at that time |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | * ... |
201 | 201 | * ... |
202 | 202 | */ |
203 | - foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) { |
|
204 | - foreach( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
205 | - if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) ) { |
|
206 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
203 | + foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) { |
|
204 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
205 | + if (array_key_exists($hook_name, $hooks_to_fire_at_time)) { |
|
206 | + unset($crons[$timestamp][$hook_name]); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
210 | - _set_cron_array( $crons ); |
|
210 | + _set_cron_array($crons); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public static function CPT_initialization() { |
224 | 224 | // register Custom Post Types |
225 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
225 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
226 | 226 | flush_rewrite_rules(); |
227 | 227 | } |
228 | 228 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @return void |
241 | 241 | */ |
242 | 242 | public static function reset_and_update_config() { |
243 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
244 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
243 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
244 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
245 | 245 | //EE_Config::reset(); |
246 | 246 | } |
247 | 247 | |
@@ -254,23 +254,23 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public static function load_calendar_config() { |
256 | 256 | // grab array of all plugin folders and loop thru it |
257 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
258 | - if ( empty( $plugins ) ) { |
|
257 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
258 | + if (empty($plugins)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | - foreach ( $plugins as $plugin_path ) { |
|
261 | + foreach ($plugins as $plugin_path) { |
|
262 | 262 | // grab plugin folder name from path |
263 | - $plugin = basename( $plugin_path ); |
|
263 | + $plugin = basename($plugin_path); |
|
264 | 264 | // drill down to Espresso plugins |
265 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
265 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
266 | 266 | // then to calendar related plugins |
267 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
267 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
268 | 268 | // this is what we are looking for |
269 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
269 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
270 | 270 | // does it exist in this folder ? |
271 | - if ( is_readable( $calendar_config )) { |
|
271 | + if (is_readable($calendar_config)) { |
|
272 | 272 | // YEAH! let's load it |
273 | - require_once( $calendar_config ); |
|
273 | + require_once($calendar_config); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -287,21 +287,21 @@ discard block |
||
287 | 287 | * @param \EE_Config $EE_Config |
288 | 288 | * @return \stdClass |
289 | 289 | */ |
290 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
291 | - $convert_from_array = array( 'addons' ); |
|
290 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
291 | + $convert_from_array = array('addons'); |
|
292 | 292 | // in case old settings were saved as an array |
293 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
293 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
294 | 294 | // convert existing settings to an object |
295 | 295 | $config_array = $settings; |
296 | 296 | $settings = new stdClass(); |
297 | - foreach ( $config_array as $key => $value ){ |
|
298 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
299 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
297 | + foreach ($config_array as $key => $value) { |
|
298 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
299 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
300 | 300 | } else { |
301 | 301 | $settings->$key = $value; |
302 | 302 | } |
303 | 303 | } |
304 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
304 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
305 | 305 | } |
306 | 306 | return $settings; |
307 | 307 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public static function deactivate_event_espresso() { |
319 | 319 | // check permissions |
320 | - if ( current_user_can( 'activate_plugins' )) { |
|
321 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
320 | + if (current_user_can('activate_plugins')) { |
|
321 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -340,79 +340,79 @@ discard block |
||
340 | 340 | $critical_pages = array( |
341 | 341 | array( |
342 | 342 | 'id' =>'reg_page_id', |
343 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
343 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
344 | 344 | 'post' => NULL, |
345 | 345 | 'code' => 'ESPRESSO_CHECKOUT' |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'id' => 'txn_page_id', |
349 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
349 | + 'name' => __('Transactions', 'event_espresso'), |
|
350 | 350 | 'post' => NULL, |
351 | 351 | 'code' => 'ESPRESSO_TXN_PAGE' |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'id' => 'thank_you_page_id', |
355 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
355 | + 'name' => __('Thank You', 'event_espresso'), |
|
356 | 356 | 'post' => NULL, |
357 | 357 | 'code' => 'ESPRESSO_THANK_YOU' |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'id' => 'cancel_page_id', |
361 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
361 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
362 | 362 | 'post' => NULL, |
363 | 363 | 'code' => 'ESPRESSO_CANCELLED' |
364 | 364 | ), |
365 | 365 | ); |
366 | 366 | |
367 | - foreach ( $critical_pages as $critical_page ) { |
|
367 | + foreach ($critical_pages as $critical_page) { |
|
368 | 368 | // is critical page ID set in config ? |
369 | - if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) { |
|
369 | + if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) { |
|
370 | 370 | // attempt to find post by ID |
371 | - $critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] ); |
|
371 | + $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']); |
|
372 | 372 | } |
373 | 373 | // no dice? |
374 | - if ( $critical_page['post'] == NULL ) { |
|
374 | + if ($critical_page['post'] == NULL) { |
|
375 | 375 | // attempt to find post by title |
376 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
376 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
377 | 377 | // still nothing? |
378 | - if ( $critical_page['post'] == NULL ) { |
|
379 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
378 | + if ($critical_page['post'] == NULL) { |
|
379 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
380 | 380 | // REALLY? Still nothing ??!?!? |
381 | - if ( $critical_page['post'] == NULL ) { |
|
382 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
383 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
381 | + if ($critical_page['post'] == NULL) { |
|
382 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
383 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
384 | 384 | break; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
388 | 388 | // track post_shortcodes |
389 | - if ( $critical_page['post'] ) { |
|
390 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
389 | + if ($critical_page['post']) { |
|
390 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
391 | 391 | } |
392 | 392 | // check that Post ID matches critical page ID in config |
393 | - if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) { |
|
393 | + if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) { |
|
394 | 394 | //update Config with post ID |
395 | 395 | EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID; |
396 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
397 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
398 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
396 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
397 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
398 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | - $critical_page_problem = ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem; |
|
402 | + $critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | - if ( $critical_page_problem ) { |
|
406 | + if ($critical_page_problem) { |
|
407 | 407 | $msg = sprintf( |
408 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
409 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
408 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
409 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
410 | 410 | ); |
411 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
411 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
412 | 412 | } |
413 | 413 | |
414 | - if ( EE_Error::has_notices() ) { |
|
415 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
414 | + if (EE_Error::has_notices()) { |
|
415 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | } |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | * parameter to the shortcode |
426 | 426 | * @return WP_Post or NULl |
427 | 427 | */ |
428 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
428 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
429 | 429 | global $wpdb; |
430 | 430 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
431 | 431 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
432 | - if($post_id){ |
|
432 | + if ($post_id) { |
|
433 | 433 | return get_post($post_id); |
434 | - }else{ |
|
434 | + } else { |
|
435 | 435 | return NULL; |
436 | 436 | } |
437 | 437 | |
@@ -448,32 +448,32 @@ discard block |
||
448 | 448 | * @param array $critical_page |
449 | 449 | * @return array |
450 | 450 | */ |
451 | - public static function create_critical_page( $critical_page ) { |
|
451 | + public static function create_critical_page($critical_page) { |
|
452 | 452 | |
453 | 453 | $post_args = array( |
454 | 454 | 'post_title' => $critical_page['name'], |
455 | 455 | 'post_status' => 'publish', |
456 | 456 | 'post_type' => 'page', |
457 | 457 | 'comment_status' => 'closed', |
458 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
458 | + 'post_content' => '['.$critical_page['code'].']' |
|
459 | 459 | ); |
460 | 460 | |
461 | - $post_id = wp_insert_post( $post_args ); |
|
462 | - if ( ! $post_id ) { |
|
461 | + $post_id = wp_insert_post($post_args); |
|
462 | + if ( ! $post_id) { |
|
463 | 463 | $msg = sprintf( |
464 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
464 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
465 | 465 | $critical_page['name'] |
466 | 466 | ); |
467 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
467 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
468 | 468 | return $critical_page; |
469 | 469 | } |
470 | 470 | // get newly created post's details |
471 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
471 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
472 | 472 | $msg = sprintf( |
473 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
473 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
474 | 474 | $critical_page['name'] |
475 | 475 | ); |
476 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
476 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | return $critical_page; |
@@ -492,34 +492,34 @@ discard block |
||
492 | 492 | * @param array $critical_page |
493 | 493 | * @return void |
494 | 494 | */ |
495 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
495 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
496 | 496 | // check the goods |
497 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
497 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
498 | 498 | $msg = sprintf( |
499 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
499 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
500 | 500 | $critical_page['name'] |
501 | 501 | ); |
502 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
502 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
503 | 503 | return; |
504 | 504 | } |
505 | 505 | // map shortcode to post |
506 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
506 | + EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
507 | 507 | // and make sure it's NOT added to the WP "Posts Page" |
508 | 508 | // name of the WP Posts Page |
509 | 509 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
510 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) { |
|
511 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
510 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) { |
|
511 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]); |
|
512 | 512 | } |
513 | - if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) { |
|
514 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
513 | + if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) { |
|
514 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]); |
|
515 | 515 | } |
516 | 516 | // update post_shortcode CFG |
517 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
517 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
518 | 518 | $msg = sprintf( |
519 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
519 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
520 | 520 | $critical_page['name'] |
521 | 521 | ); |
522 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
522 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
@@ -537,24 +537,24 @@ discard block |
||
537 | 537 | public static function get_default_creator_id() { |
538 | 538 | global $wpdb; |
539 | 539 | |
540 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
540 | + if ( ! empty(self::$_default_creator_id)) { |
|
541 | 541 | return self::$_default_creator_id; |
542 | 542 | }/**/ |
543 | 543 | |
544 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
544 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
545 | 545 | |
546 | 546 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
547 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
548 | - if ( $pre_filtered_id !== false ) { |
|
547 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
548 | + if ($pre_filtered_id !== false) { |
|
549 | 549 | return (int) $pre_filtered_id; |
550 | 550 | } |
551 | 551 | |
552 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
553 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
554 | - $user_id = $wpdb->get_var( $query ); |
|
555 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
556 | - if ( $user_id && intval( $user_id ) ) { |
|
557 | - self::$_default_creator_id = intval( $user_id ); |
|
552 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
553 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
554 | + $user_id = $wpdb->get_var($query); |
|
555 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
556 | + if ($user_id && intval($user_id)) { |
|
557 | + self::$_default_creator_id = intval($user_id); |
|
558 | 558 | return self::$_default_creator_id; |
559 | 559 | } else { |
560 | 560 | return NULL; |
@@ -581,29 +581,29 @@ discard block |
||
581 | 581 | * @return void |
582 | 582 | * @throws EE_Error if there are database errors |
583 | 583 | */ |
584 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
585 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
584 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
585 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
586 | 586 | return; |
587 | 587 | } |
588 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
589 | - if ( ! function_exists( 'dbDelta' )) { |
|
590 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
588 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
589 | + if ( ! function_exists('dbDelta')) { |
|
590 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
591 | 591 | } |
592 | 592 | /** @var WPDB $wpdb */ |
593 | 593 | global $wpdb; |
594 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
594 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
595 | 595 | // do we need to first delete an existing version of this table ? |
596 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
596 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
597 | 597 | // ok, delete the table... but ONLY if it's empty |
598 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
598 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
599 | 599 | // table is NOT empty, are you SURE you want to delete this table ??? |
600 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
601 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
602 | - } else if ( ! $deleted_safely ) { |
|
600 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
601 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
602 | + } else if ( ! $deleted_safely) { |
|
603 | 603 | // so we should be more cautious rather than just dropping tables so easily |
604 | 604 | EE_Error::add_persistent_admin_notice( |
605 | - 'bad_table_' . $wp_table_name . '_detected', |
|
606 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
605 | + 'bad_table_'.$wp_table_name.'_detected', |
|
606 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
607 | 607 | $wp_table_name, |
608 | 608 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
609 | 609 | '<b>wp-config.php</b>', |
@@ -612,25 +612,25 @@ discard block |
||
612 | 612 | } |
613 | 613 | } |
614 | 614 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
615 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
615 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
616 | 616 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
617 | 617 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
618 | 618 | //happened. And then we can choose to tell the end user |
619 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
620 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
619 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
620 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
621 | 621 | ob_start(); |
622 | - dbDelta( $SQL ); |
|
622 | + dbDelta($SQL); |
|
623 | 623 | $output = ob_get_contents(); |
624 | 624 | ob_end_clean(); |
625 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
626 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
627 | - if( ! empty( $output ) ){ |
|
628 | - throw new EE_Error( $output ); |
|
625 | + $wpdb->show_errors($old_show_errors_policy); |
|
626 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
627 | + if ( ! empty($output)) { |
|
628 | + throw new EE_Error($output); |
|
629 | 629 | } |
630 | 630 | } else { |
631 | 631 | throw new EE_Error( |
632 | 632 | sprintf( |
633 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
633 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
634 | 634 | '<br />', |
635 | 635 | $sql |
636 | 636 | ) |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)' |
653 | 653 | * @return bool|int |
654 | 654 | */ |
655 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
656 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
655 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
656 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
657 | 657 | return FALSE; |
658 | 658 | } |
659 | 659 | global $wpdb; |
660 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
660 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
661 | 661 | $fields = self::get_fields_on_table($table_name); |
662 | - if (!in_array($column_name, $fields)){ |
|
663 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
662 | + if ( ! in_array($column_name, $fields)) { |
|
663 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
664 | 664 | //echo "alter query:$alter_query"; |
665 | 665 | return $wpdb->query($alter_query); |
666 | 666 | } |
@@ -679,15 +679,15 @@ discard block |
||
679 | 679 | * @param string $table_name, without prefixed $wpdb->prefix |
680 | 680 | * @return array of database column names |
681 | 681 | */ |
682 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
682 | + public static function get_fields_on_table($table_name = NULL) { |
|
683 | 683 | global $wpdb; |
684 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
685 | - if ( ! empty( $table_name )) { |
|
684 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
685 | + if ( ! empty($table_name)) { |
|
686 | 686 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
687 | 687 | if ($columns !== FALSE) { |
688 | 688 | $field_array = array(); |
689 | - foreach($columns as $column ){ |
|
690 | - $field_array[] = $column->Field;; |
|
689 | + foreach ($columns as $column) { |
|
690 | + $field_array[] = $column->Field; ; |
|
691 | 691 | } |
692 | 692 | return $field_array; |
693 | 693 | } |
@@ -705,12 +705,12 @@ discard block |
||
705 | 705 | * @param string $table_name |
706 | 706 | * @return bool |
707 | 707 | */ |
708 | - public static function db_table_is_empty( $table_name ) { |
|
708 | + public static function db_table_is_empty($table_name) { |
|
709 | 709 | global $wpdb; |
710 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
711 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
712 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
713 | - return absint( $count ) === 0 ? true : false; |
|
710 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
711 | + if (EEH_Activation::table_exists($table_name)) { |
|
712 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
713 | + return absint($count) === 0 ? true : false; |
|
714 | 714 | } |
715 | 715 | return false; |
716 | 716 | } |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | * @param string $table_name |
726 | 726 | * @return bool | int |
727 | 727 | */ |
728 | - public static function delete_db_table_if_empty( $table_name ) { |
|
729 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
730 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
728 | + public static function delete_db_table_if_empty($table_name) { |
|
729 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
730 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
731 | 731 | } |
732 | 732 | return false; |
733 | 733 | } |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | * @param string $table_name |
743 | 743 | * @return bool | int |
744 | 744 | */ |
745 | - public static function delete_unused_db_table( $table_name ) { |
|
745 | + public static function delete_unused_db_table($table_name) { |
|
746 | 746 | global $wpdb; |
747 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
748 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
749 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
747 | + if (EEH_Activation::table_exists($table_name)) { |
|
748 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
749 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
750 | 750 | } |
751 | 751 | return false; |
752 | 752 | } |
@@ -762,18 +762,18 @@ discard block |
||
762 | 762 | * @param string $index_name |
763 | 763 | * @return bool | int |
764 | 764 | */ |
765 | - public static function drop_index( $table_name, $index_name ) { |
|
766 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
765 | + public static function drop_index($table_name, $index_name) { |
|
766 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
767 | 767 | return FALSE; |
768 | 768 | } |
769 | 769 | global $wpdb; |
770 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
770 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
771 | 771 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
772 | 772 | if ( |
773 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
774 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
773 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
774 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
775 | 775 | ) { |
776 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
776 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
777 | 777 | } |
778 | 778 | return TRUE; |
779 | 779 | } |
@@ -789,27 +789,27 @@ discard block |
||
789 | 789 | * @return boolean success (whether database is setup properly or not) |
790 | 790 | */ |
791 | 791 | public static function create_database_tables() { |
792 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
792 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
793 | 793 | //find the migration script that sets the database to be compatible with the code |
794 | 794 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
795 | - if( $dms_name ){ |
|
796 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
797 | - $current_data_migration_script->set_migrating( false ); |
|
795 | + if ($dms_name) { |
|
796 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
797 | + $current_data_migration_script->set_migrating(false); |
|
798 | 798 | $current_data_migration_script->schema_changes_before_migration(); |
799 | 799 | $current_data_migration_script->schema_changes_after_migration(); |
800 | - if( $current_data_migration_script->get_errors() ){ |
|
801 | - if( WP_DEBUG ){ |
|
802 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
803 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
800 | + if ($current_data_migration_script->get_errors()) { |
|
801 | + if (WP_DEBUG) { |
|
802 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
803 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
804 | 804 | } |
805 | - }else{ |
|
806 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
805 | + } else { |
|
806 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
807 | 807 | } |
808 | 808 | return false; |
809 | 809 | } |
810 | 810 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
811 | - }else{ |
|
812 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
811 | + } else { |
|
812 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | return true; |
@@ -829,27 +829,27 @@ discard block |
||
829 | 829 | public static function initialize_system_questions() { |
830 | 830 | // QUESTION GROUPS |
831 | 831 | global $wpdb; |
832 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
832 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
833 | 833 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
834 | 834 | // what we have |
835 | - $question_groups = $wpdb->get_col( $SQL ); |
|
835 | + $question_groups = $wpdb->get_col($SQL); |
|
836 | 836 | // check the response |
837 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
837 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
838 | 838 | // what we should have |
839 | - $QSG_systems = array( 1, 2 ); |
|
839 | + $QSG_systems = array(1, 2); |
|
840 | 840 | // loop thru what we should have and compare to what we have |
841 | - foreach ( $QSG_systems as $QSG_system ) { |
|
841 | + foreach ($QSG_systems as $QSG_system) { |
|
842 | 842 | // reset values array |
843 | 843 | $QSG_values = array(); |
844 | 844 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
845 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
845 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
846 | 846 | // add it |
847 | - switch ( $QSG_system ) { |
|
847 | + switch ($QSG_system) { |
|
848 | 848 | |
849 | 849 | case 1: |
850 | 850 | $QSG_values = array( |
851 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
852 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
851 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
852 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
853 | 853 | 'QSG_desc' => '', |
854 | 854 | 'QSG_order' => 1, |
855 | 855 | 'QSG_show_group_name' => 1, |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | |
862 | 862 | case 2: |
863 | 863 | $QSG_values = array( |
864 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
865 | - 'QSG_identifier' => 'address-information-' . time(), |
|
864 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
865 | + 'QSG_identifier' => 'address-information-'.time(), |
|
866 | 866 | 'QSG_desc' => '', |
867 | 867 | 'QSG_order' => 2, |
868 | 868 | 'QSG_show_group_name' => 1, |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | |
875 | 875 | } |
876 | 876 | // make sure we have some values before inserting them |
877 | - if ( ! empty( $QSG_values )) { |
|
877 | + if ( ! empty($QSG_values)) { |
|
878 | 878 | // insert system question |
879 | 879 | $wpdb->insert( |
880 | 880 | $table_name, |
881 | 881 | $QSG_values, |
882 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
882 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
883 | 883 | ); |
884 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
884 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | } |
@@ -890,10 +890,10 @@ discard block |
||
890 | 890 | |
891 | 891 | // QUESTIONS |
892 | 892 | global $wpdb; |
893 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
893 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
894 | 894 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
895 | 895 | // what we have |
896 | - $questions = $wpdb->get_col( $SQL ); |
|
896 | + $questions = $wpdb->get_col($SQL); |
|
897 | 897 | // what we should have |
898 | 898 | $QST_systems = array( |
899 | 899 | 'fname', |
@@ -910,22 +910,22 @@ discard block |
||
910 | 910 | $order_for_group_1 = 1; |
911 | 911 | $order_for_group_2 = 1; |
912 | 912 | // loop thru what we should have and compare to what we have |
913 | - foreach ( $QST_systems as $QST_system ) { |
|
913 | + foreach ($QST_systems as $QST_system) { |
|
914 | 914 | // reset values array |
915 | 915 | $QST_values = array(); |
916 | 916 | // if we don't have what we should have |
917 | - if ( ! in_array( $QST_system, $questions )) { |
|
917 | + if ( ! in_array($QST_system, $questions)) { |
|
918 | 918 | // add it |
919 | - switch ( $QST_system ) { |
|
919 | + switch ($QST_system) { |
|
920 | 920 | |
921 | 921 | case 'fname': |
922 | 922 | $QST_values = array( |
923 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
924 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
923 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
924 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
925 | 925 | 'QST_system' => 'fname', |
926 | 926 | 'QST_type' => 'TEXT', |
927 | 927 | 'QST_required' => 1, |
928 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
928 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
929 | 929 | 'QST_order' => 1, |
930 | 930 | 'QST_admin_only' => 0, |
931 | 931 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -935,12 +935,12 @@ discard block |
||
935 | 935 | |
936 | 936 | case 'lname': |
937 | 937 | $QST_values = array( |
938 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
939 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
938 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
939 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
940 | 940 | 'QST_system' => 'lname', |
941 | 941 | 'QST_type' => 'TEXT', |
942 | 942 | 'QST_required' => 1, |
943 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
943 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
944 | 944 | 'QST_order' => 2, |
945 | 945 | 'QST_admin_only' => 0, |
946 | 946 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -950,12 +950,12 @@ discard block |
||
950 | 950 | |
951 | 951 | case 'email': |
952 | 952 | $QST_values = array( |
953 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
954 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
953 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
954 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
955 | 955 | 'QST_system' => 'email', |
956 | 956 | 'QST_type' => 'TEXT', |
957 | 957 | 'QST_required' => 1, |
958 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
958 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
959 | 959 | 'QST_order' => 3, |
960 | 960 | 'QST_admin_only' => 0, |
961 | 961 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -965,12 +965,12 @@ discard block |
||
965 | 965 | |
966 | 966 | case 'address': |
967 | 967 | $QST_values = array( |
968 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
969 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
968 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
969 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
970 | 970 | 'QST_system' => 'address', |
971 | 971 | 'QST_type' => 'TEXT', |
972 | 972 | 'QST_required' => 0, |
973 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
973 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
974 | 974 | 'QST_order' => 4, |
975 | 975 | 'QST_admin_only' => 0, |
976 | 976 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -980,12 +980,12 @@ discard block |
||
980 | 980 | |
981 | 981 | case 'address2': |
982 | 982 | $QST_values = array( |
983 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
984 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
983 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
984 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
985 | 985 | 'QST_system' => 'address2', |
986 | 986 | 'QST_type' => 'TEXT', |
987 | 987 | 'QST_required' => 0, |
988 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
988 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
989 | 989 | 'QST_order' => 5, |
990 | 990 | 'QST_admin_only' => 0, |
991 | 991 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -995,12 +995,12 @@ discard block |
||
995 | 995 | |
996 | 996 | case 'city': |
997 | 997 | $QST_values = array( |
998 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
999 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
998 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
999 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1000 | 1000 | 'QST_system' => 'city', |
1001 | 1001 | 'QST_type' => 'TEXT', |
1002 | 1002 | 'QST_required' => 0, |
1003 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1003 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1004 | 1004 | 'QST_order' => 6, |
1005 | 1005 | 'QST_admin_only' => 0, |
1006 | 1006 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1010,12 +1010,12 @@ discard block |
||
1010 | 1010 | |
1011 | 1011 | case 'state': |
1012 | 1012 | $QST_values = array( |
1013 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1014 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1013 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1014 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1015 | 1015 | 'QST_system' => 'state', |
1016 | 1016 | 'QST_type' => 'STATE', |
1017 | 1017 | 'QST_required' => 0, |
1018 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1018 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1019 | 1019 | 'QST_order' => 7, |
1020 | 1020 | 'QST_admin_only' => 0, |
1021 | 1021 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1025,12 +1025,12 @@ discard block |
||
1025 | 1025 | |
1026 | 1026 | case 'country' : |
1027 | 1027 | $QST_values = array( |
1028 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1029 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1028 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1029 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1030 | 1030 | 'QST_system' => 'country', |
1031 | 1031 | 'QST_type' => 'COUNTRY', |
1032 | 1032 | 'QST_required' => 0, |
1033 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1033 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1034 | 1034 | 'QST_order' => 8, |
1035 | 1035 | 'QST_admin_only' => 0, |
1036 | 1036 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1040,12 +1040,12 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | case 'zip': |
1042 | 1042 | $QST_values = array( |
1043 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1044 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1043 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1044 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1045 | 1045 | 'QST_system' => 'zip', |
1046 | 1046 | 'QST_type' => 'TEXT', |
1047 | 1047 | 'QST_required' => 0, |
1048 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1048 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1049 | 1049 | 'QST_order' => 9, |
1050 | 1050 | 'QST_admin_only' => 0, |
1051 | 1051 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1055,12 +1055,12 @@ discard block |
||
1055 | 1055 | |
1056 | 1056 | case 'phone': |
1057 | 1057 | $QST_values = array( |
1058 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1059 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1058 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1059 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1060 | 1060 | 'QST_system' => 'phone', |
1061 | 1061 | 'QST_type' => 'TEXT', |
1062 | 1062 | 'QST_required' => 0, |
1063 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1063 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1064 | 1064 | 'QST_order' => 10, |
1065 | 1065 | 'QST_admin_only' => 0, |
1066 | 1066 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1069,34 +1069,34 @@ discard block |
||
1069 | 1069 | break; |
1070 | 1070 | |
1071 | 1071 | } |
1072 | - if ( ! empty( $QST_values )) { |
|
1072 | + if ( ! empty($QST_values)) { |
|
1073 | 1073 | // insert system question |
1074 | 1074 | $wpdb->insert( |
1075 | 1075 | $table_name, |
1076 | 1076 | $QST_values, |
1077 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1077 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1078 | 1078 | ); |
1079 | 1079 | $QST_ID = $wpdb->insert_id; |
1080 | 1080 | |
1081 | 1081 | // QUESTION GROUP QUESTIONS |
1082 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1082 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1083 | 1083 | $system_question_we_want = EEM_Question_Group::system_personal; |
1084 | 1084 | } else { |
1085 | 1085 | $system_question_we_want = EEM_Question_Group::system_address; |
1086 | 1086 | } |
1087 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1088 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1087 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1088 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1089 | 1089 | } else { |
1090 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1091 | - if( is_array( $id_col ) ) { |
|
1092 | - $QSG_ID = reset( $id_col ); |
|
1090 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1091 | + if (is_array($id_col)) { |
|
1092 | + $QSG_ID = reset($id_col); |
|
1093 | 1093 | } else { |
1094 | 1094 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1095 | 1095 | EE_Log::instance()->log( |
1096 | 1096 | __FILE__, |
1097 | 1097 | __FUNCTION__, |
1098 | 1098 | sprintf( |
1099 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1099 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1100 | 1100 | $QST_ID ), |
1101 | 1101 | 'error' ); |
1102 | 1102 | continue; |
@@ -1105,9 +1105,9 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | // add system questions to groups |
1107 | 1107 | $wpdb->insert( |
1108 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1109 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1110 | - array( '%d', '%d','%d' ) |
|
1108 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1109 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1110 | + array('%d', '%d', '%d') |
|
1111 | 1111 | ); |
1112 | 1112 | } |
1113 | 1113 | } |
@@ -1119,11 +1119,11 @@ discard block |
||
1119 | 1119 | * Makes sure the default payment method (Invoice) is active. |
1120 | 1120 | * This used to be done automatically as part of constructing the old gateways config |
1121 | 1121 | */ |
1122 | - public static function insert_default_payment_methods(){ |
|
1123 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1124 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1125 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1126 | - }else{ |
|
1122 | + public static function insert_default_payment_methods() { |
|
1123 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1124 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1125 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1126 | + } else { |
|
1127 | 1127 | EEM_Payment_Method::instance()->verify_button_urls(); |
1128 | 1128 | } |
1129 | 1129 | } |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | |
1140 | 1140 | global $wpdb; |
1141 | 1141 | |
1142 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1142 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1143 | 1143 | |
1144 | 1144 | $table_name = EEM_Status::instance()->table(); |
1145 | 1145 | |
@@ -1205,35 +1205,35 @@ discard block |
||
1205 | 1205 | * @return boolean success of verifying upload directories exist |
1206 | 1206 | */ |
1207 | 1207 | public static function create_upload_directories() { |
1208 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1208 | + EE_Registry::instance()->load_helper('File'); |
|
1209 | 1209 | // Create the required folders |
1210 | 1210 | $folders = array( |
1211 | 1211 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1212 | 1212 | EVENT_ESPRESSO_GATEWAY_DIR, |
1213 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1214 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1215 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1213 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1214 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1215 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1216 | 1216 | ); |
1217 | - foreach ( $folders as $folder ) { |
|
1217 | + foreach ($folders as $folder) { |
|
1218 | 1218 | try { |
1219 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1220 | - @ chmod( $folder, 0755 ); |
|
1221 | - } catch( EE_Error $e ){ |
|
1219 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1220 | + @ chmod($folder, 0755); |
|
1221 | + } catch (EE_Error $e) { |
|
1222 | 1222 | EE_Error::add_error( |
1223 | 1223 | sprintf( |
1224 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1224 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1225 | 1225 | $folder, |
1226 | - '<br />' . $e->getMessage() |
|
1226 | + '<br />'.$e->getMessage() |
|
1227 | 1227 | ), |
1228 | 1228 | __FILE__, __FUNCTION__, __LINE__ |
1229 | 1229 | ); |
1230 | 1230 | //indicate we'll need to fix this later |
1231 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1231 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1232 | 1232 | return FALSE; |
1233 | 1233 | } |
1234 | 1234 | } |
1235 | 1235 | //remember EE's folders are all good |
1236 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1236 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1237 | 1237 | return TRUE; |
1238 | 1238 | } |
1239 | 1239 | |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | * @return boolean |
1247 | 1247 | */ |
1248 | 1248 | public static function upload_directories_incomplete() { |
1249 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1249 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | |
@@ -1265,16 +1265,16 @@ discard block |
||
1265 | 1265 | $installed_messengers = $default_messengers = array(); |
1266 | 1266 | |
1267 | 1267 | //include our helper |
1268 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1268 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1269 | 1269 | |
1270 | 1270 | //get all installed messenger objects |
1271 | 1271 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1272 | 1272 | |
1273 | 1273 | //let's setup the $installed messengers in an array AND the messengers that are set to be activated on install. |
1274 | - foreach ( $installed['messengers'] as $msgr ) { |
|
1275 | - if ( $msgr instanceof EE_messenger ) { |
|
1274 | + foreach ($installed['messengers'] as $msgr) { |
|
1275 | + if ($msgr instanceof EE_messenger) { |
|
1276 | 1276 | $installed_messengers[$msgr->name] = $msgr; |
1277 | - if ( $msgr->activate_on_install ) { |
|
1277 | + if ($msgr->activate_on_install) { |
|
1278 | 1278 | $default_messengers[] = $msgr->name; |
1279 | 1279 | } |
1280 | 1280 | } |
@@ -1284,36 +1284,36 @@ discard block |
||
1284 | 1284 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1285 | 1285 | |
1286 | 1286 | //things that have already been activated before |
1287 | - $has_activated = get_option( 'ee_has_activated_messenger' ); |
|
1287 | + $has_activated = get_option('ee_has_activated_messenger'); |
|
1288 | 1288 | |
1289 | 1289 | //do an initial loop to determine if we need to continue |
1290 | 1290 | $def_ms = array(); |
1291 | - foreach ( $default_messengers as $msgr ) { |
|
1292 | - if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue; |
|
1291 | + foreach ($default_messengers as $msgr) { |
|
1292 | + if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue; |
|
1293 | 1293 | $def_ms[] = $msgr; |
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | //setup the $installed_mts in an array |
1297 | - foreach ( $installed['message_types'] as $imt ) { |
|
1298 | - if ( $imt instanceof EE_message_type ) { |
|
1297 | + foreach ($installed['message_types'] as $imt) { |
|
1298 | + if ($imt instanceof EE_message_type) { |
|
1299 | 1299 | $installed_mts[$imt->name] = $imt; |
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | //loop through default array for default messengers (if present) |
1304 | - if ( ! empty( $def_ms ) ) { |
|
1305 | - foreach ( $def_ms as $messenger ) { |
|
1304 | + if ( ! empty($def_ms)) { |
|
1305 | + foreach ($def_ms as $messenger) { |
|
1306 | 1306 | //all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger. |
1307 | - if ( ! isset( $installed_messengers[$messenger] )) { |
|
1307 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1308 | 1308 | continue; |
1309 | 1309 | } |
1310 | 1310 | /** @var EE_messenger[] $installed_messengers */ |
1311 | 1311 | $default_mts = $installed_messengers[$messenger]->get_default_message_types(); |
1312 | 1312 | $active_messengers[$messenger]['obj'] = $installed_messengers[$messenger]; |
1313 | - foreach ( $default_mts as $index => $mt ) { |
|
1313 | + foreach ($default_mts as $index => $mt) { |
|
1314 | 1314 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1315 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1316 | - unset( $default_mts[$index] ); |
|
1315 | + if ( ! isset($installed_mts[$mt])) { |
|
1316 | + unset($default_mts[$index]); |
|
1317 | 1317 | continue; |
1318 | 1318 | } |
1319 | 1319 | |
@@ -1322,41 +1322,41 @@ discard block |
||
1322 | 1322 | /** @var EE_message_type[] $installed_mts */ |
1323 | 1323 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1324 | 1324 | $settings = array(); |
1325 | - if ( is_array( $settings_fields ) ) { |
|
1326 | - foreach ( $settings_fields as $field => $values ) { |
|
1327 | - if ( isset( $values['default'] ) ) { |
|
1325 | + if (is_array($settings_fields)) { |
|
1326 | + foreach ($settings_fields as $field => $values) { |
|
1327 | + if (isset($values['default'])) { |
|
1328 | 1328 | $settings[$field] = $values['default']; |
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | } |
1332 | 1332 | |
1333 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1333 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1334 | 1334 | $has_activated[$messenger][] = $mt; |
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | //setup any initial settings for the messenger |
1338 | 1338 | $msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields(); |
1339 | 1339 | |
1340 | - if ( !empty( $msgr_settings ) ) { |
|
1341 | - foreach ( $msgr_settings as $field => $value ) { |
|
1340 | + if ( ! empty($msgr_settings)) { |
|
1341 | + foreach ($msgr_settings as $field => $value) { |
|
1342 | 1342 | $active_messengers[$messenger]['settings'][$field] = $value; |
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | //now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate. |
1347 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1347 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1348 | 1348 | |
1349 | 1349 | //let's generate all the templates but only if the messenger has default_mts (otherwise its just activated). |
1350 | - if ( !empty( $default_mts ) ) { |
|
1351 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE ); |
|
1350 | + if ( ! empty($default_mts)) { |
|
1351 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE); |
|
1352 | 1352 | } |
1353 | 1353 | } |
1354 | 1354 | } //end check for empty( $def_ms ) |
1355 | 1355 | |
1356 | 1356 | //still need to see if there are any message types to activate for active messengers |
1357 | - foreach ( $active_messengers as $messenger => $settings ) { |
|
1357 | + foreach ($active_messengers as $messenger => $settings) { |
|
1358 | 1358 | $msg_obj = $settings['obj']; |
1359 | - if ( ! $msg_obj instanceof EE_messenger ) { |
|
1359 | + if ( ! $msg_obj instanceof EE_messenger) { |
|
1360 | 1360 | continue; |
1361 | 1361 | } |
1362 | 1362 | |
@@ -1364,45 +1364,45 @@ discard block |
||
1364 | 1364 | $new_default_mts = array(); |
1365 | 1365 | |
1366 | 1366 | //loop through each default mt reported by the messenger and make sure its set in its active db entry. |
1367 | - foreach( $all_default_mts as $index => $mt ) { |
|
1367 | + foreach ($all_default_mts as $index => $mt) { |
|
1368 | 1368 | //already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated). |
1369 | - if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) || EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) { |
|
1369 | + if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) { |
|
1370 | 1370 | continue; |
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1374 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1375 | - unset( $all_default_mts[$mt] ); |
|
1374 | + if ( ! isset($installed_mts[$mt])) { |
|
1375 | + unset($all_default_mts[$mt]); |
|
1376 | 1376 | continue; |
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1380 | 1380 | $settings = array(); |
1381 | - if ( is_array( $settings_fields ) ) { |
|
1382 | - foreach ( $settings_fields as $field => $values ) { |
|
1383 | - if ( isset( $values['default'] ) ) { |
|
1381 | + if (is_array($settings_fields)) { |
|
1382 | + foreach ($settings_fields as $field => $values) { |
|
1383 | + if (isset($values['default'])) { |
|
1384 | 1384 | $settings[$field] = $values['default']; |
1385 | 1385 | } |
1386 | 1386 | } |
1387 | 1387 | } |
1388 | 1388 | |
1389 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1389 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1390 | 1390 | $new_default_mts[] = $mt; |
1391 | 1391 | $has_activated[$messenger][] = $mt; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | |
1395 | - if ( ! empty( $new_default_mts ) ) { |
|
1396 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE ); |
|
1395 | + if ( ! empty($new_default_mts)) { |
|
1396 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE); |
|
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | //now let's save the settings for this messenger! |
1402 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1402 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1403 | 1403 | |
1404 | 1404 | //update $has_activated record |
1405 | - update_option( 'ee_has_activated_messenger', $has_activated ); |
|
1405 | + update_option('ee_has_activated_messenger', $has_activated); |
|
1406 | 1406 | |
1407 | 1407 | //that's it! |
1408 | 1408 | return $success; |
@@ -1422,47 +1422,47 @@ discard block |
||
1422 | 1422 | */ |
1423 | 1423 | public static function validate_messages_system() { |
1424 | 1424 | //include our helper |
1425 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1425 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1426 | 1426 | |
1427 | 1427 | //get active and installed messengers/message types. |
1428 | 1428 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1429 | 1429 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1430 | 1430 | $installed_messengers = $installed_mts = array(); |
1431 | 1431 | //set up the arrays so they can be handled easier. |
1432 | - foreach( $installed['messengers'] as $im ) { |
|
1433 | - if ( $im instanceof EE_messenger ) { |
|
1432 | + foreach ($installed['messengers'] as $im) { |
|
1433 | + if ($im instanceof EE_messenger) { |
|
1434 | 1434 | $installed_messengers[$im->name] = $im; |
1435 | 1435 | } |
1436 | 1436 | } |
1437 | - foreach( $installed['message_types'] as $imt ) { |
|
1438 | - if ( $imt instanceof EE_message_type ) { |
|
1437 | + foreach ($installed['message_types'] as $imt) { |
|
1438 | + if ($imt instanceof EE_message_type) { |
|
1439 | 1439 | $installed_mts[$imt->name] = $imt; |
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | |
1443 | 1443 | //now let's loop through the active array and validate |
1444 | - foreach( $active_messengers as $messenger => $active_details ) { |
|
1444 | + foreach ($active_messengers as $messenger => $active_details) { |
|
1445 | 1445 | //first let's see if this messenger is installed. |
1446 | - if ( ! isset( $installed_messengers[$messenger] ) ) { |
|
1446 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1447 | 1447 | //not set so let's just remove from actives and make sure templates are inactive. |
1448 | - unset( $active_messengers[$messenger] ); |
|
1449 | - EEH_MSG_Template::update_to_inactive( $messenger ); |
|
1448 | + unset($active_messengers[$messenger]); |
|
1449 | + EEH_MSG_Template::update_to_inactive($messenger); |
|
1450 | 1450 | continue; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | 1453 | //messenger is active, so let's just make sure that any active message types not installed are deactivated. |
1454 | - $mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array(); |
|
1455 | - foreach ( $mts as $mt_name => $mt ) { |
|
1456 | - if ( ! isset( $installed_mts[$mt_name] ) ) { |
|
1457 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
1458 | - EEH_MSG_Template::update_to_inactive( $messenger, $mt_name ); |
|
1454 | + $mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array(); |
|
1455 | + foreach ($mts as $mt_name => $mt) { |
|
1456 | + if ( ! isset($installed_mts[$mt_name])) { |
|
1457 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]); |
|
1458 | + EEH_MSG_Template::update_to_inactive($messenger, $mt_name); |
|
1459 | 1459 | } |
1460 | 1460 | } |
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | //all done! let's update the active_messengers. |
1464 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1465 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1464 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1465 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1466 | 1466 | return; |
1467 | 1467 | } |
1468 | 1468 | |
@@ -1476,12 +1476,12 @@ discard block |
||
1476 | 1476 | * @static |
1477 | 1477 | * @return void |
1478 | 1478 | */ |
1479 | - public static function create_no_ticket_prices_array(){ |
|
1479 | + public static function create_no_ticket_prices_array() { |
|
1480 | 1480 | // this creates an array for tracking events that have no active ticket prices created |
1481 | 1481 | // this allows us to warn admins of the situation so that it can be corrected |
1482 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1483 | - if ( ! $espresso_no_ticket_prices ) { |
|
1484 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1482 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1483 | + if ( ! $espresso_no_ticket_prices) { |
|
1484 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1485 | 1485 | } |
1486 | 1486 | } |
1487 | 1487 | |
@@ -1503,24 +1503,24 @@ discard block |
||
1503 | 1503 | * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/ |
1504 | 1504 | * @global wpdb $wpdb |
1505 | 1505 | */ |
1506 | - public static function delete_all_espresso_cpt_data(){ |
|
1506 | + public static function delete_all_espresso_cpt_data() { |
|
1507 | 1507 | global $wpdb; |
1508 | 1508 | //get all the CPT post_types |
1509 | 1509 | $ee_post_types = array(); |
1510 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1511 | - if ( method_exists( $model_name, 'instance' )) { |
|
1512 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1513 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1514 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1510 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1511 | + if (method_exists($model_name, 'instance')) { |
|
1512 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1513 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1514 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1515 | 1515 | } |
1516 | 1516 | } |
1517 | 1517 | } |
1518 | 1518 | //get all our CPTs |
1519 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1519 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1520 | 1520 | $cpt_ids = $wpdb->get_col($query); |
1521 | 1521 | //delete each post meta and term relations too |
1522 | - foreach($cpt_ids as $post_id){ |
|
1523 | - wp_delete_post($post_id,true); |
|
1522 | + foreach ($cpt_ids as $post_id) { |
|
1523 | + wp_delete_post($post_id, true); |
|
1524 | 1524 | } |
1525 | 1525 | } |
1526 | 1526 | |
@@ -1534,18 +1534,18 @@ discard block |
||
1534 | 1534 | * @param bool $remove_all |
1535 | 1535 | * @return void |
1536 | 1536 | */ |
1537 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1537 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1538 | 1538 | global $wpdb; |
1539 | 1539 | $undeleted_tables = array(); |
1540 | 1540 | |
1541 | 1541 | // load registry |
1542 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1543 | - if ( method_exists( $model_name, 'instance' )) { |
|
1544 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1545 | - if ( $model_obj instanceof EEM_Base ) { |
|
1546 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1547 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1548 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1542 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1543 | + if (method_exists($model_name, 'instance')) { |
|
1544 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1545 | + if ($model_obj instanceof EEM_Base) { |
|
1546 | + foreach ($model_obj->get_tables() as $table) { |
|
1547 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1548 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1549 | 1549 | case false : |
1550 | 1550 | $undeleted_tables[] = $table->get_table_name(); |
1551 | 1551 | break; |
@@ -1570,8 +1570,8 @@ discard block |
||
1570 | 1570 | 'esp_promotion_rule', |
1571 | 1571 | 'esp_rule' |
1572 | 1572 | ); |
1573 | - foreach( $tables_without_models as $table ){ |
|
1574 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1573 | + foreach ($tables_without_models as $table) { |
|
1574 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | |
@@ -1608,58 +1608,58 @@ discard block |
||
1608 | 1608 | 'ee_pers_admin_notices' => true, |
1609 | 1609 | 'ee_upload_directories_incomplete' => true, |
1610 | 1610 | ); |
1611 | - if( is_main_site() ) { |
|
1612 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1611 | + if (is_main_site()) { |
|
1612 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | $undeleted_options = array(); |
1616 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1616 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1617 | 1617 | |
1618 | - if( $no_wildcard ){ |
|
1619 | - if( ! delete_option( $option_name ) ){ |
|
1618 | + if ($no_wildcard) { |
|
1619 | + if ( ! delete_option($option_name)) { |
|
1620 | 1620 | $undeleted_options[] = $option_name; |
1621 | 1621 | } |
1622 | - }else{ |
|
1623 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1624 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1625 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1622 | + } else { |
|
1623 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1624 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1625 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1626 | 1626 | $undeleted_options[] = $option_name_from_wildcard; |
1627 | 1627 | } |
1628 | 1628 | } |
1629 | 1629 | } |
1630 | 1630 | } |
1631 | 1631 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1632 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1632 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1633 | 1633 | |
1634 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1634 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1635 | 1635 | $db_update_sans_ee4 = array(); |
1636 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1637 | - if( $version[0] =='3'){//if its NON EE4 |
|
1636 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1637 | + if ($version[0] == '3') {//if its NON EE4 |
|
1638 | 1638 | $db_update_sans_ee4[$version] = $times_activated; |
1639 | 1639 | } |
1640 | 1640 | } |
1641 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1641 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | $errors = ''; |
1645 | - if ( ! empty( $undeleted_tables )) { |
|
1645 | + if ( ! empty($undeleted_tables)) { |
|
1646 | 1646 | $errors .= sprintf( |
1647 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1647 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1648 | 1648 | '<br/>', |
1649 | - implode( ',<br/>', $undeleted_tables ) |
|
1649 | + implode(',<br/>', $undeleted_tables) |
|
1650 | 1650 | ); |
1651 | 1651 | } |
1652 | - if ( ! empty( $undeleted_options )) { |
|
1653 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1652 | + if ( ! empty($undeleted_options)) { |
|
1653 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1654 | 1654 | $errors .= sprintf( |
1655 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1655 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1656 | 1656 | '<br/>', |
1657 | - implode( ',<br/>', $undeleted_options ) |
|
1657 | + implode(',<br/>', $undeleted_options) |
|
1658 | 1658 | ); |
1659 | 1659 | |
1660 | 1660 | } |
1661 | - if ( $errors != '' ) { |
|
1662 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1661 | + if ($errors != '') { |
|
1662 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | |
@@ -1669,23 +1669,23 @@ discard block |
||
1669 | 1669 | * @param string $table_name with or without $wpdb->prefix |
1670 | 1670 | * @return boolean |
1671 | 1671 | */ |
1672 | - public static function table_exists( $table_name ){ |
|
1672 | + public static function table_exists($table_name) { |
|
1673 | 1673 | global $wpdb, $EZSQL_ERROR; |
1674 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1674 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1675 | 1675 | //ignore if this causes an sql error |
1676 | 1676 | $old_error = $wpdb->last_error; |
1677 | 1677 | $old_suppress_errors = $wpdb->suppress_errors(); |
1678 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1678 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1679 | 1679 | $ezsql_error_cache = $EZSQL_ERROR; |
1680 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1681 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1682 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1680 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1681 | + $wpdb->show_errors($old_show_errors_value); |
|
1682 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1683 | 1683 | $new_error = $wpdb->last_error; |
1684 | 1684 | $wpdb->last_error = $old_error; |
1685 | 1685 | $EZSQL_ERROR = $ezsql_error_cache; |
1686 | - if( empty( $new_error ) ){ |
|
1686 | + if (empty($new_error)) { |
|
1687 | 1687 | return TRUE; |
1688 | - }else{ |
|
1688 | + } else { |
|
1689 | 1689 | return FALSE; |
1690 | 1690 | } |
1691 | 1691 | } |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | /** |
1694 | 1694 | * Resets the cache on EEH_Activation |
1695 | 1695 | */ |
1696 | - public static function reset(){ |
|
1696 | + public static function reset() { |
|
1697 | 1697 | self::$_default_creator_id = NULL; |
1698 | 1698 | self::$_initialized_db_content_already_in_this_request = false; |
1699 | 1699 | } |
@@ -1092,14 +1092,14 @@ discard block |
||
1092 | 1092 | $QSG_ID = reset( $id_col ); |
1093 | 1093 | } else { |
1094 | 1094 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1095 | - EE_Log::instance()->log( |
|
1096 | - __FILE__, |
|
1097 | - __FUNCTION__, |
|
1098 | - sprintf( |
|
1099 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1100 | - $QST_ID ), |
|
1101 | - 'error' ); |
|
1102 | - continue; |
|
1095 | + EE_Log::instance()->log( |
|
1096 | + __FILE__, |
|
1097 | + __FUNCTION__, |
|
1098 | + sprintf( |
|
1099 | + __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1100 | + $QST_ID ), |
|
1101 | + 'error' ); |
|
1102 | + continue; |
|
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | |
@@ -1629,8 +1629,8 @@ discard block |
||
1629 | 1629 | } |
1630 | 1630 | } |
1631 | 1631 | } |
1632 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1633 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1632 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1633 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1634 | 1634 | |
1635 | 1635 | if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
1636 | 1636 | $db_update_sans_ee4 = array(); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - trigger_error( sprintf( __('%1$s was called <strong>incorrectly</strong>. %2$s %3$s','event_espresso' ), $function, $message, $version ), $error_type ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', 'event_espresso'), $function, $message, $version), $error_type); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -323,22 +323,22 @@ discard block |
||
323 | 323 | * @param string $debug_index |
324 | 324 | * @param string $debug_key |
325 | 325 | */ |
326 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
327 | - if ( WP_DEBUG && false ) { |
|
328 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
329 | - $debug_data = get_option( $debug_key, array() ); |
|
326 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
327 | + if (WP_DEBUG && false) { |
|
328 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
329 | + $debug_data = get_option($debug_key, array()); |
|
330 | 330 | $default_data = array( |
331 | - $class => $func . '() : ' . $line, |
|
331 | + $class => $func.'() : '.$line, |
|
332 | 332 | 'REQ' => $display_request ? $_REQUEST : '', |
333 | 333 | ); |
334 | 334 | // don't serialize objects |
335 | - $info = self::strip_objects( $info ); |
|
336 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
337 | - if ( ! isset( $debug_data[$index] ) ) { |
|
335 | + $info = self::strip_objects($info); |
|
336 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
337 | + if ( ! isset($debug_data[$index])) { |
|
338 | 338 | $debug_data[$index] = array(); |
339 | 339 | } |
340 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
341 | - update_option( $debug_key, $debug_data ); |
|
340 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
341 | + update_option($debug_key, $debug_data); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
@@ -350,26 +350,26 @@ discard block |
||
350 | 350 | * @param array $info |
351 | 351 | * @return array |
352 | 352 | */ |
353 | - public static function strip_objects( $info = array() ) { |
|
354 | - foreach ( $info as $key => $value ) { |
|
355 | - if ( is_array( $value ) ) { |
|
356 | - $info[ $key ] = self::strip_objects( $value ); |
|
357 | - } else if ( is_object( $value ) ) { |
|
358 | - $object_class = get_class( $value ); |
|
359 | - $info[ $object_class ] = array(); |
|
360 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
361 | - if ( method_exists( $value, 'ID' ) ) { |
|
362 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
353 | + public static function strip_objects($info = array()) { |
|
354 | + foreach ($info as $key => $value) { |
|
355 | + if (is_array($value)) { |
|
356 | + $info[$key] = self::strip_objects($value); |
|
357 | + } else if (is_object($value)) { |
|
358 | + $object_class = get_class($value); |
|
359 | + $info[$object_class] = array(); |
|
360 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
361 | + if (method_exists($value, 'ID')) { |
|
362 | + $info[$object_class]['ID'] = $value->ID(); |
|
363 | 363 | } |
364 | - if ( method_exists( $value, 'status' ) ) { |
|
365 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
366 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
367 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
364 | + if (method_exists($value, 'status')) { |
|
365 | + $info[$object_class]['status'] = $value->status(); |
|
366 | + } else if (method_exists($value, 'status_ID')) { |
|
367 | + $info[$object_class]['status'] = $value->status_ID(); |
|
368 | 368 | } |
369 | - unset( $info[ $key ] ); |
|
369 | + unset($info[$key]); |
|
370 | 370 | } |
371 | 371 | } |
372 | - return (array)$info; |
|
372 | + return (array) $info; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -386,31 +386,31 @@ discard block |
||
386 | 386 | * @param string $height |
387 | 387 | * @param bool $die |
388 | 388 | */ |
389 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false ) { |
|
389 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false) { |
|
390 | 390 | //$print_r = false; |
391 | - if ( is_object( $var ) ) { |
|
391 | + if (is_object($var)) { |
|
392 | 392 | $var_name = ! $var_name ? 'object' : $var_name; |
393 | 393 | //$print_r = true; |
394 | - } else if ( is_array( $var ) ) { |
|
394 | + } else if (is_array($var)) { |
|
395 | 395 | $var_name = ! $var_name ? 'array' : $var_name; |
396 | 396 | //$print_r = true; |
397 | - } else if ( is_numeric( $var ) ) { |
|
397 | + } else if (is_numeric($var)) { |
|
398 | 398 | $var_name = ! $var_name ? 'numeric' : $var_name; |
399 | - } else if ( is_string( $var ) ) { |
|
399 | + } else if (is_string($var)) { |
|
400 | 400 | $var_name = ! $var_name ? 'string' : $var_name; |
401 | - } else if ( is_null( $var ) ) { |
|
401 | + } else if (is_null($var)) { |
|
402 | 402 | $var_name = ! $var_name ? 'null' : $var_name; |
403 | 403 | } |
404 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
404 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
405 | 405 | ob_start(); |
406 | - echo '<pre style="display:block; width:100%; height:' . $height . '; border:2px solid light-blue;">'; |
|
407 | - echo '<h5 style="color:#2EA2CC;"><b>' . $var_name . '</b></h5><span style="color:#E76700">'; |
|
406 | + echo '<pre style="display:block; width:100%; height:'.$height.'; border:2px solid light-blue;">'; |
|
407 | + echo '<h5 style="color:#2EA2CC;"><b>'.$var_name.'</b></h5><span style="color:#E76700">'; |
|
408 | 408 | //$print_r ? print_r( $var ) : var_dump( $var ); |
409 | - var_dump( $var ); |
|
410 | - echo '</span><br /><span style="font-size:10px;font-weight:normal;">' . $file . '<br />line no: ' . $line . '</span></pre>'; |
|
409 | + var_dump($var); |
|
410 | + echo '</span><br /><span style="font-size:10px;font-weight:normal;">'.$file.'<br />line no: '.$line.'</span></pre>'; |
|
411 | 411 | $result = ob_get_clean(); |
412 | - if ( $die ) { |
|
413 | - die( $result ); |
|
412 | + if ($die) { |
|
413 | + die($result); |
|
414 | 414 | } else { |
415 | 415 | echo $result; |
416 | 416 | } |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * borrowed from Kint Debugger |
428 | 428 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
429 | 429 | */ |
430 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
431 | - function dump_wp_query(){ |
|
430 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
431 | + function dump_wp_query() { |
|
432 | 432 | global $wp_query; |
433 | 433 | d($wp_query); |
434 | 434 | } |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * borrowed from Kint Debugger |
439 | 439 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
440 | 440 | */ |
441 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
442 | - function dump_wp(){ |
|
441 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
442 | + function dump_wp() { |
|
443 | 443 | global $wp; |
444 | 444 | d($wp); |
445 | 445 | } |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * borrowed from Kint Debugger |
450 | 450 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
451 | 451 | */ |
452 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
453 | - function dump_post(){ |
|
452 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
453 | + function dump_post() { |
|
454 | 454 | global $post; |
455 | 455 | d($post); |
456 | 456 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * The main purpose of this method is to return the parent for the model object |
99 | 99 | * |
100 | 100 | * @access public |
101 | - * @return int |
|
101 | + * @return boolean |
|
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | 104 | return $this->get( 'parent' ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | /** |
110 | 110 | * return the _status property |
111 | - * @return string |
|
111 | + * @return boolean |
|
112 | 112 | */ |
113 | 113 | public function status() { |
114 | 114 | return $this->get( 'status' ); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
132 | 132 | * @access protected |
133 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
133 | + * @param string $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class using the given size params. |
161 | - * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
161 | + * @param integer[] $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | 164 | public function feature_image_url( $size = 'thumbnail' ) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * This is a method for restoring this_obj using details from the given $revision_id |
173 | 173 | * |
174 | 174 | * @param int $revision_id ID of the revision we're getting data from |
175 | - * @param array $related_obj_names if included this will be used to restore for related obj |
|
175 | + * @param string[] $related_obj_names if included this will be used to restore for related obj |
|
176 | 176 | * if not included then we just do restore on the meta. |
177 | 177 | * We will accept an array of related_obj_names for restoration here. |
178 | 178 | * @param array $where_query You can optionally include an array of key=>value pairs |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
228 | 228 | * @param string $meta_key |
229 | 229 | * @param boolean $single |
230 | - * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
230 | + * @return string|null <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
231 | 231 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
232 | 232 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
233 | 233 | */ |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
259 | - * @param mixed $meta_key |
|
260 | - * @param mixed $meta_value |
|
259 | + * @param string $meta_key |
|
260 | + * @param boolean $meta_value |
|
261 | 261 | * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
262 | 262 | * @throws EE_Error |
263 | 263 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
276 | 276 | * |
277 | - * @param mixed $meta_key |
|
277 | + * @param string $meta_key |
|
278 | 278 | * @param mixed $meta_value |
279 | 279 | * @throws EE_Error |
280 | 280 | * @return boolean False for failure. True for success. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** |
302 | 302 | * Gets all the term-taxonomies for this CPT |
303 | 303 | * @param array $query_params |
304 | - * @return EE_Term_Taxonomy |
|
304 | + * @return EE_Base_Class[] |
|
305 | 305 | */ |
306 | 306 | public function term_taxonomies( $query_params = array() ) { |
307 | 307 | return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $parent_term_taxonomy_id optional |
48 | 48 | * @return EE_Term_Taxonomy |
49 | 49 | */ |
50 | - function add_event_category( $category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL ) { |
|
51 | - return $this->get_model()->add_event_category( $this, $category_name, $category_description, $parent_term_taxonomy_id ); |
|
50 | + function add_event_category($category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL) { |
|
51 | + return $this->get_model()->add_event_category($this, $category_name, $category_description, $parent_term_taxonomy_id); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param string $category_name |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - function remove_event_category( $category_name ) { |
|
62 | - return $this->get_model()->remove_event_category( $this, $category_name ); |
|
61 | + function remove_event_category($category_name) { |
|
62 | + return $this->get_model()->remove_event_category($this, $category_name); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param EE_Term_Taxonomy $term_taxonomy |
71 | 71 | * @return EE_Base_Class the relation was removed from |
72 | 72 | */ |
73 | - function remove_relation_to_term_taxonomy( $term_taxonomy ) { |
|
74 | - if ( !$term_taxonomy ) { |
|
75 | - EE_Error::add_error( sprintf( __( "No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso" ), get_class( $this ), $this->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
73 | + function remove_relation_to_term_taxonomy($term_taxonomy) { |
|
74 | + if ( ! $term_taxonomy) { |
|
75 | + EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return NULL; |
77 | 77 | } |
78 | - $term_taxonomy->set_count( $term_taxonomy->count() - 1 ); |
|
78 | + $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
79 | 79 | $term_taxonomy->save(); |
80 | - return $this->_remove_relation_to( $term_taxonomy, 'Term_Taxonomy' ); |
|
80 | + return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return int |
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | - return $this->get( 'parent' ); |
|
104 | + return $this->get('parent'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return string |
112 | 112 | */ |
113 | 113 | public function status() { |
114 | - return $this->get( 'status' ); |
|
114 | + return $this->get('status'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param string $status |
121 | 121 | */ |
122 | - public function set_status( $status ) { |
|
123 | - $this->set( 'status', $status ); |
|
122 | + public function set_status($status) { |
|
123 | + $this->set('status', $status); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
137 | - protected function _get_feature_image( $size, $attr ) { |
|
137 | + protected function _get_feature_image($size, $attr) { |
|
138 | 138 | //first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
139 | - $attr_key = is_array( $attr ) ? implode( '_', $attr ) : $attr; |
|
140 | - $cache_key = is_array( $size ) ? implode( '_', $size ) . $attr_key : $size . $attr_key; |
|
141 | - $this->_feature_image[ $cache_key ] = isset( $this->_feature_image[ $cache_key ] ) ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image( $this->ID(), $size, $attr ); |
|
142 | - return $this->_feature_image[ $cache_key ]; |
|
139 | + $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
|
140 | + $cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key; |
|
141 | + $this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
142 | + return $this->_feature_image[$cache_key]; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string|array $attr |
151 | 151 | * @return string of html |
152 | 152 | */ |
153 | - public function feature_image( $size = 'thumbnail', $attr = '' ) { |
|
154 | - return $this->_get_feature_image( $size, $attr ); |
|
153 | + public function feature_image($size = 'thumbnail', $attr = '') { |
|
154 | + return $this->_get_feature_image($size, $attr); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | - public function feature_image_url( $size = 'thumbnail' ) { |
|
165 | - $attachment = wp_get_attachment_image_src( get_post_thumbnail_id( $this->ID() ), $size ); |
|
166 | - return !empty( $attachment ) ? $attachment[ 0 ] : FALSE; |
|
164 | + public function feature_image_url($size = 'thumbnail') { |
|
165 | + $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
166 | + return ! empty($attachment) ? $attachment[0] : FALSE; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -185,37 +185,37 @@ discard block |
||
185 | 185 | * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names sent); |
186 | 186 | * @return void |
187 | 187 | */ |
188 | - public function restore_revision( $revision_id, $related_obj_names = array(), $where_query = array() ) { |
|
188 | + public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) { |
|
189 | 189 | //get revision object |
190 | - $revision_obj = $this->get_model()->get_one_by_ID( $revision_id ); |
|
191 | - if ( $revision_obj instanceof EE_CPT_Base ) { |
|
190 | + $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
191 | + if ($revision_obj instanceof EE_CPT_Base) { |
|
192 | 192 | //no related_obj_name so we assume we're saving a revision on this object. |
193 | - if ( empty( $related_obj_names ) ) { |
|
193 | + if (empty($related_obj_names)) { |
|
194 | 194 | $fields = $this->get_model()->get_meta_table_fields(); |
195 | - foreach ( $fields as $field ) { |
|
196 | - $this->set( $field, $revision_obj->get( $field ) ); |
|
195 | + foreach ($fields as $field) { |
|
196 | + $this->set($field, $revision_obj->get($field)); |
|
197 | 197 | } |
198 | 198 | $this->save(); |
199 | 199 | } |
200 | - $related_obj_names = (array)$related_obj_names; |
|
201 | - foreach ( $related_obj_names as $related_name ) { |
|
200 | + $related_obj_names = (array) $related_obj_names; |
|
201 | + foreach ($related_obj_names as $related_name) { |
|
202 | 202 | //related_obj_name so we're saving a revision on an object related to this object |
203 | 203 | //do we have $where_query params for this related object? If we do then we include that. |
204 | - $cols_n_values = isset( $where_query[ $related_name ] ) ? $where_query[ $related_name ] : array(); |
|
205 | - $where_params = !empty( $cols_n_values ) ? array( $cols_n_values ) : array(); |
|
206 | - $related_objs = $this->get_many_related( $related_name, $where_params ); |
|
207 | - $revision_related_objs = $revision_obj->get_many_related( $related_name, $where_params ); |
|
204 | + $cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array(); |
|
205 | + $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
206 | + $related_objs = $this->get_many_related($related_name, $where_params); |
|
207 | + $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
208 | 208 | //load helper |
209 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
209 | + EE_Registry::instance()->load_helper('Array'); |
|
210 | 210 | //remove related objs from this object that are not in revision |
211 | 211 | //array_diff *should* work cause I think objects are indexed by ID? |
212 | - $related_to_remove = EEH_Array::object_array_diff( $related_objs, $revision_related_objs ); |
|
213 | - foreach ( $related_to_remove as $rr ) { |
|
214 | - $this->_remove_relation_to( $rr, $related_name, $cols_n_values ); |
|
212 | + $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
213 | + foreach ($related_to_remove as $rr) { |
|
214 | + $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
215 | 215 | } |
216 | 216 | //add all related objs attached to revision to this object |
217 | - foreach ( $revision_related_objs as $r_obj ) { |
|
218 | - $this->_add_relation_to( $r_obj, $related_name, $cols_n_values ); |
|
217 | + foreach ($revision_related_objs as $r_obj) { |
|
218 | + $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
232 | 232 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
233 | 233 | */ |
234 | - public function get_post_meta( $meta_key = NULL, $single = FALSE ) { |
|
235 | - return get_post_meta( $this->ID(), $meta_key, $single ); |
|
234 | + public function get_post_meta($meta_key = NULL, $single = FALSE) { |
|
235 | + return get_post_meta($this->ID(), $meta_key, $single); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @throws EE_Error |
246 | 246 | * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false. |
247 | 247 | */ |
248 | - public function update_post_meta( $meta_key, $meta_value, $prev_value = NULL ) { |
|
249 | - if ( !$this->ID() ) { |
|
250 | - throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) ); |
|
248 | + public function update_post_meta($meta_key, $meta_value, $prev_value = NULL) { |
|
249 | + if ( ! $this->ID()) { |
|
250 | + throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso"))); |
|
251 | 251 | } |
252 | - return update_post_meta( $this->ID(), $meta_key, $meta_value, $prev_value ); |
|
252 | + return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | * @throws EE_Error |
263 | 263 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
264 | 264 | */ |
265 | - public function add_post_meta( $meta_key, $meta_value, $unique = FALSE ) { |
|
266 | - if ( !$this->ID() ) { |
|
267 | - throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) ); |
|
265 | + public function add_post_meta($meta_key, $meta_value, $unique = FALSE) { |
|
266 | + if ( ! $this->ID()) { |
|
267 | + throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso"))); |
|
268 | 268 | } |
269 | - return add_post_meta( $this->ID(), $meta_key, $meta_value, $unique ); |
|
269 | + return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | * @throws EE_Error |
280 | 280 | * @return boolean False for failure. True for success. |
281 | 281 | */ |
282 | - public function delete_post_meta( $meta_key, $meta_value = '' ) { |
|
283 | - if ( ! $this->ID() ) { |
|
284 | - throw new EE_Error( sprintf( __( "Can not delete post meta field for a post that has never been saved.", "event_espresso" ) ) ); |
|
282 | + public function delete_post_meta($meta_key, $meta_value = '') { |
|
283 | + if ( ! $this->ID()) { |
|
284 | + throw new EE_Error(sprintf(__("Can not delete post meta field for a post that has never been saved.", "event_espresso"))); |
|
285 | 285 | } |
286 | - return delete_post_meta( $this->ID(), $meta_key, $meta_value ); |
|
286 | + return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @return string |
294 | 294 | */ |
295 | 295 | public function get_permalink() { |
296 | - return get_permalink( $this->ID() ); |
|
296 | + return get_permalink($this->ID()); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param array $query_params |
304 | 304 | * @return EE_Term_Taxonomy |
305 | 305 | */ |
306 | - public function term_taxonomies( $query_params = array() ) { |
|
307 | - return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
|
306 | + public function term_taxonomies($query_params = array()) { |
|
307 | + return $this->get_many_related('Term_Taxonomy', $query_params); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @access public |
84 | 84 | * @param string $new_status |
85 | 85 | * @param bool $use_default |
86 | - * @return bool|void |
|
86 | + * @return boolean |
|
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | 89 | public function set_status( $new_status = null, $use_default = false ) { |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | * |
1064 | 1064 | * @access public |
1065 | 1065 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1066 | - * @return mixed void|string |
|
1066 | + * @return string void|string |
|
1067 | 1067 | */ |
1068 | 1068 | public function pretty_active_status( $echo = TRUE ) { |
1069 | 1069 | $active_status = $this->get_active_status(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * date_format and the second value is the time format |
36 | 36 | * @return EE_Event |
37 | 37 | */ |
38 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
39 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
40 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
38 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
40 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * the website will be used. |
49 | 49 | * @return EE_Event |
50 | 50 | */ |
51 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
52 | - return new self( $props_n_values, TRUE, $timezone ); |
|
51 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
52 | + return new self($props_n_values, TRUE, $timezone); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @param mixed $field_value |
62 | 62 | * @param bool $use_default |
63 | 63 | */ |
64 | - public function set( $field_name, $field_value, $use_default = false ) { |
|
65 | - switch ( $field_name ) { |
|
64 | + public function set($field_name, $field_value, $use_default = false) { |
|
65 | + switch ($field_name) { |
|
66 | 66 | case 'status' : |
67 | - $this->set_status( $field_value, $use_default ); |
|
67 | + $this->set_status($field_value, $use_default); |
|
68 | 68 | break; |
69 | 69 | default : |
70 | - parent::set( $field_name, $field_value, $use_default ); |
|
70 | + parent::set($field_name, $field_value, $use_default); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -86,29 +86,29 @@ discard block |
||
86 | 86 | * @return bool|void |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public function set_status( $new_status = null, $use_default = false ) { |
|
89 | + public function set_status($new_status = null, $use_default = false) { |
|
90 | 90 | // get current Event status |
91 | 91 | $old_status = $this->status(); |
92 | 92 | // if status has changed |
93 | - if ( $old_status != $new_status ) { |
|
93 | + if ($old_status != $new_status) { |
|
94 | 94 | // TO sold_out |
95 | - if ( $new_status == EEM_Event::sold_out ) { |
|
95 | + if ($new_status == EEM_Event::sold_out) { |
|
96 | 96 | // save the previous event status so that we can revert if the event is no longer sold out |
97 | - $this->add_post_meta( '_previous_event_status', $old_status ); |
|
98 | - do_action( 'AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status ); |
|
97 | + $this->add_post_meta('_previous_event_status', $old_status); |
|
98 | + do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
99 | 99 | // OR FROM sold_out |
100 | - } else if ( $old_status == EEM_Event::sold_out ) { |
|
101 | - $this->delete_post_meta( '_previous_event_status' ); |
|
102 | - do_action( 'AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status ); |
|
100 | + } else if ($old_status == EEM_Event::sold_out) { |
|
101 | + $this->delete_post_meta('_previous_event_status'); |
|
102 | + do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
103 | 103 | } |
104 | 104 | // update status |
105 | - parent::set( 'status', $new_status, $use_default ); |
|
106 | - do_action( 'AHEE__EE_Event__set_status__after_update', $this ); |
|
105 | + parent::set('status', $new_status, $use_default); |
|
106 | + do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
107 | 107 | return true; |
108 | 108 | } else { |
109 | 109 | // even though the old value matches the new value, it's still good to |
110 | 110 | // allow the parent set method to have a say |
111 | - parent::set( 'status', $new_status, $use_default ); |
|
111 | + parent::set('status', $new_status, $use_default); |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param array $query_params like EEM_Base::get_all |
122 | 122 | * @return EE_Datetime[] |
123 | 123 | */ |
124 | - public function datetimes( $query_params = array() ) { |
|
125 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
124 | + public function datetimes($query_params = array()) { |
|
125 | + return $this->get_many_related('Datetime', $query_params); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return EE_Datetime[] |
134 | 134 | */ |
135 | 135 | public function datetimes_in_chronological_order() { |
136 | - return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) ); |
|
136 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param null $limit |
150 | 150 | * @return \EE_Datetime[] |
151 | 151 | */ |
152 | - public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) { |
|
153 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit ); |
|
152 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) { |
|
153 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return EE_Datetime |
161 | 161 | */ |
162 | 162 | public function first_datetime() { |
163 | - return $this->get_first_related( 'Datetime' ); |
|
163 | + return $this->get_first_related('Datetime'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param bool $try_to_exclude_deleted |
172 | 172 | * @return EE_Datetime |
173 | 173 | */ |
174 | - public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) { |
|
175 | - if ( !empty ( $this->_Primary_Datetime ) ) { |
|
174 | + public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) { |
|
175 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
176 | 176 | return $this->_Primary_Datetime; |
177 | 177 | } |
178 | - $this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted ); |
|
178 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted); |
|
179 | 179 | return $this->_Primary_Datetime; |
180 | 180 | } |
181 | 181 | |
@@ -186,30 +186,30 @@ discard block |
||
186 | 186 | * @param array $query_params like EEM_Base::get_all |
187 | 187 | * @return EE_Ticket[] |
188 | 188 | */ |
189 | - public function tickets( $query_params = array() ) { |
|
189 | + public function tickets($query_params = array()) { |
|
190 | 190 | //first get all datetimes |
191 | 191 | $datetimes = $this->datetimes_ordered(); |
192 | - if ( ! $datetimes ) { |
|
192 | + if ( ! $datetimes) { |
|
193 | 193 | return array(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | $datetime_ids = array(); |
197 | - foreach ( $datetimes as $datetime ) { |
|
197 | + foreach ($datetimes as $datetime) { |
|
198 | 198 | $datetime_ids[] = $datetime->ID(); |
199 | 199 | } |
200 | 200 | |
201 | - $where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) ); |
|
201 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
202 | 202 | |
203 | 203 | //if incoming $query_params has where conditions let's merge but not override existing. |
204 | - if ( is_array( $query_params ) && isset( $query_params[0]) ) { |
|
205 | - $where_params = array_merge( $query_params[0], $where_params ); |
|
206 | - unset( $query_params[0] ); |
|
204 | + if (is_array($query_params) && isset($query_params[0])) { |
|
205 | + $where_params = array_merge($query_params[0], $where_params); |
|
206 | + unset($query_params[0]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | //now add $where_params to $query_params |
210 | 210 | $query_params[0] = $where_params; |
211 | 211 | |
212 | - return EEM_Ticket::instance()->get_all( $query_params ); |
|
212 | + return EEM_Ticket::instance()->get_all($query_params); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | function additional_limit() { |
221 | - return $this->get( 'EVT_additional_limit' ); |
|
221 | + return $this->get('EVT_additional_limit'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @return bool |
228 | 228 | */ |
229 | 229 | function allow_overflow() { |
230 | - return $this->get( 'EVT_allow_overflow' ); |
|
230 | + return $this->get('EVT_allow_overflow'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return bool |
237 | 237 | */ |
238 | 238 | function created() { |
239 | - return $this->get( 'EVT_created' ); |
|
239 | + return $this->get('EVT_created'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return bool |
246 | 246 | */ |
247 | 247 | function description() { |
248 | - return $this->get( 'EVT_desc' ); |
|
248 | + return $this->get('EVT_desc'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return string of html |
256 | 256 | */ |
257 | 257 | function description_filtered() { |
258 | - return $this->get_pretty( 'EVT_desc' ); |
|
258 | + return $this->get_pretty('EVT_desc'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @return bool |
265 | 265 | */ |
266 | 266 | function display_description() { |
267 | - return $this->get( 'EVT_display_desc' ); |
|
267 | + return $this->get('EVT_display_desc'); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return bool |
274 | 274 | */ |
275 | 275 | function display_ticket_selector() { |
276 | - return (bool)$this->get( 'EVT_display_ticket_selector' ); |
|
276 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return bool |
283 | 283 | */ |
284 | 284 | function external_url() { |
285 | - return $this->get( 'EVT_external_URL' ); |
|
285 | + return $this->get('EVT_external_URL'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | function member_only() { |
294 | - return $this->get( 'EVT_member_only' ); |
|
294 | + return $this->get('EVT_member_only'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return bool |
301 | 301 | */ |
302 | 302 | function phone() { |
303 | - return $this->get( 'EVT_phone' ); |
|
303 | + return $this->get('EVT_phone'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return bool |
310 | 310 | */ |
311 | 311 | function modified() { |
312 | - return $this->get( 'EVT_modified' ); |
|
312 | + return $this->get('EVT_modified'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return bool |
319 | 319 | */ |
320 | 320 | function name() { |
321 | - return $this->get( 'EVT_name' ); |
|
321 | + return $this->get('EVT_name'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return bool |
328 | 328 | */ |
329 | 329 | function order() { |
330 | - return $this->get( 'EVT_order' ); |
|
330 | + return $this->get('EVT_order'); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @return bool|string |
337 | 337 | */ |
338 | 338 | function default_registration_status() { |
339 | - $event_default_registration_status = $this->get( 'EVT_default_registration_status' ); |
|
340 | - return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
339 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
340 | + return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param bool $not_full_desc |
349 | 349 | * @return bool|string |
350 | 350 | */ |
351 | - function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) { |
|
352 | - $short_desc = $this->get( 'EVT_short_desc' ); |
|
353 | - if ( !empty( $short_desc ) || $not_full_desc ) { |
|
351 | + function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) { |
|
352 | + $short_desc = $this->get('EVT_short_desc'); |
|
353 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
354 | 354 | return $short_desc; |
355 | 355 | } |
356 | 356 | else { |
357 | - $full_desc = $this->get( 'EVT_desc' ); |
|
358 | - return wp_trim_words( $full_desc, $num_words, $more ); |
|
357 | + $full_desc = $this->get('EVT_desc'); |
|
358 | + return wp_trim_words($full_desc, $num_words, $more); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @return bool |
366 | 366 | */ |
367 | 367 | function slug() { |
368 | - return $this->get( 'EVT_slug' ); |
|
368 | + return $this->get('EVT_slug'); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @return bool |
375 | 375 | */ |
376 | 376 | function timezone_string() { |
377 | - return $this->get( 'EVT_timezone_string' ); |
|
377 | + return $this->get('EVT_timezone_string'); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return bool |
384 | 384 | */ |
385 | 385 | function visible_on() { |
386 | - return $this->get( 'EVT_visible_on' ); |
|
386 | + return $this->get('EVT_visible_on'); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @return bool |
393 | 393 | */ |
394 | 394 | function wp_user() { |
395 | - return $this->get( 'EVT_wp_user' ); |
|
395 | + return $this->get('EVT_wp_user'); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return bool |
402 | 402 | */ |
403 | 403 | function donations() { |
404 | - return $this->get( 'EVT_donations' ); |
|
404 | + return $this->get('EVT_donations'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | /** |
410 | 410 | * @param $limit |
411 | 411 | */ |
412 | - function set_additional_limit( $limit ) { |
|
413 | - $this->set( 'EVT_additional_limit', $limit ); |
|
412 | + function set_additional_limit($limit) { |
|
413 | + $this->set('EVT_additional_limit', $limit); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | /** |
419 | 419 | * @param $created |
420 | 420 | */ |
421 | - function set_created( $created ) { |
|
422 | - $this->set( 'EVT_created', $created ); |
|
421 | + function set_created($created) { |
|
422 | + $this->set('EVT_created', $created); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | /** |
428 | 428 | * @param $desc |
429 | 429 | */ |
430 | - function set_description( $desc ) { |
|
431 | - $this->set( 'EVT_desc', $desc ); |
|
430 | + function set_description($desc) { |
|
431 | + $this->set('EVT_desc', $desc); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | /** |
437 | 437 | * @param $display_desc |
438 | 438 | */ |
439 | - function set_display_description( $display_desc ) { |
|
440 | - $this->set( 'EVT_display_desc', $display_desc ); |
|
439 | + function set_display_description($display_desc) { |
|
440 | + $this->set('EVT_display_desc', $display_desc); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | /** |
446 | 446 | * @param $display_ticket_selector |
447 | 447 | */ |
448 | - function set_display_ticket_selector( $display_ticket_selector ) { |
|
449 | - $this->set( 'EVT_display_ticket_selector', $display_ticket_selector ); |
|
448 | + function set_display_ticket_selector($display_ticket_selector) { |
|
449 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | /** |
455 | 455 | * @param $external_url |
456 | 456 | */ |
457 | - function set_external_url( $external_url ) { |
|
458 | - $this->set( 'EVT_external_URL', $external_url ); |
|
457 | + function set_external_url($external_url) { |
|
458 | + $this->set('EVT_external_URL', $external_url); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | /** |
464 | 464 | * @param $member_only |
465 | 465 | */ |
466 | - function set_member_only( $member_only ) { |
|
467 | - $this->set( 'EVT_member_only', $member_only ); |
|
466 | + function set_member_only($member_only) { |
|
467 | + $this->set('EVT_member_only', $member_only); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | /** |
473 | 473 | * @param $event_phone |
474 | 474 | */ |
475 | - function set_event_phone( $event_phone ) { |
|
476 | - $this->set( 'EVT_phone', $event_phone ); |
|
475 | + function set_event_phone($event_phone) { |
|
476 | + $this->set('EVT_phone', $event_phone); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | /** |
482 | 482 | * @param $modified |
483 | 483 | */ |
484 | - function set_modified( $modified ) { |
|
485 | - $this->set( 'EVT_modified', $modified ); |
|
484 | + function set_modified($modified) { |
|
485 | + $this->set('EVT_modified', $modified); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | /** |
491 | 491 | * @param $name |
492 | 492 | */ |
493 | - function set_name( $name ) { |
|
494 | - $this->set( 'EVT_name', $name ); |
|
493 | + function set_name($name) { |
|
494 | + $this->set('EVT_name', $name); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | /** |
500 | 500 | * @param $order |
501 | 501 | */ |
502 | - function set_order( $order ) { |
|
503 | - $this->set( 'EVT_order', $order ); |
|
502 | + function set_order($order) { |
|
503 | + $this->set('EVT_order', $order); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | /** |
509 | 509 | * @param $short_desc |
510 | 510 | */ |
511 | - function set_short_description( $short_desc ) { |
|
512 | - $this->set( 'EVT_short_desc', $short_desc ); |
|
511 | + function set_short_description($short_desc) { |
|
512 | + $this->set('EVT_short_desc', $short_desc); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | /** |
518 | 518 | * @param $slug |
519 | 519 | */ |
520 | - function set_slug( $slug ) { |
|
521 | - $this->set( 'EVT_slug', $slug ); |
|
520 | + function set_slug($slug) { |
|
521 | + $this->set('EVT_slug', $slug); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | /** |
527 | 527 | * @param $timezone_string |
528 | 528 | */ |
529 | - function set_timezone_string( $timezone_string ) { |
|
530 | - $this->set( 'EVT_timezone_string', $timezone_string ); |
|
529 | + function set_timezone_string($timezone_string) { |
|
530 | + $this->set('EVT_timezone_string', $timezone_string); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * @param $visible_on |
537 | 537 | */ |
538 | - function set_visible_on( $visible_on ) { |
|
539 | - $this->set( 'EVT_visible_on', $visible_on ); |
|
538 | + function set_visible_on($visible_on) { |
|
539 | + $this->set('EVT_visible_on', $visible_on); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | /** |
545 | 545 | * @param $wp_user |
546 | 546 | */ |
547 | - function set_wp_user( $wp_user ) { |
|
548 | - $this->set( 'EVT_wp_user', $wp_user ); |
|
547 | + function set_wp_user($wp_user) { |
|
548 | + $this->set('EVT_wp_user', $wp_user); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | /** |
554 | 554 | * @param $default_registration_status |
555 | 555 | */ |
556 | - function set_default_registration_status( $default_registration_status ) { |
|
557 | - $this->set( 'EVT_default_registration_status', $default_registration_status ); |
|
556 | + function set_default_registration_status($default_registration_status) { |
|
557 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | /** |
563 | 563 | * @param $donations |
564 | 564 | */ |
565 | - function set_donations( $donations ) { |
|
566 | - $this->set( 'EVT_donations', $donations ); |
|
565 | + function set_donations($donations) { |
|
566 | + $this->set('EVT_donations', $donations); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @param EE_Venue /int $venue_id_or_obj |
574 | 574 | * @return EE_Venue |
575 | 575 | */ |
576 | - function add_venue( $venue_id_or_obj ) { |
|
577 | - return $this->_add_relation_to( $venue_id_or_obj, 'Venue' ); |
|
576 | + function add_venue($venue_id_or_obj) { |
|
577 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @param EE_Venue /int $venue_id_or_obj |
585 | 585 | * @return EE_Venue |
586 | 586 | */ |
587 | - function remove_venue( $venue_id_or_obj ) { |
|
588 | - return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' ); |
|
587 | + function remove_venue($venue_id_or_obj) { |
|
588 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | * @param array $query_params like EEM_Base::get_all's $query_params |
596 | 596 | * @return EE_Venue[] |
597 | 597 | */ |
598 | - function venues( $query_params = array() ) { |
|
599 | - return $this->get_many_related( 'Venue', $query_params ); |
|
598 | + function venues($query_params = array()) { |
|
599 | + return $this->get_many_related('Venue', $query_params); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | private function _has_ID_and_is_published() { |
610 | 610 | // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
611 | - return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE; |
|
611 | + return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -620,21 +620,21 @@ discard block |
||
620 | 620 | */ |
621 | 621 | public function is_upcoming() { |
622 | 622 | // check if event id is present and if this event is published |
623 | - if ( $this->is_inactive() ) { |
|
623 | + if ($this->is_inactive()) { |
|
624 | 624 | return FALSE; |
625 | 625 | } |
626 | 626 | // set initial value |
627 | 627 | $upcoming = FALSE; |
628 | 628 | //next let's get all datetimes and loop through them |
629 | 629 | $datetimes = $this->datetimes_in_chronological_order(); |
630 | - foreach ( $datetimes as $datetime ) { |
|
631 | - if ( $datetime instanceof EE_Datetime ) { |
|
630 | + foreach ($datetimes as $datetime) { |
|
631 | + if ($datetime instanceof EE_Datetime) { |
|
632 | 632 | //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
633 | - if ( $datetime->is_expired() ) { |
|
633 | + if ($datetime->is_expired()) { |
|
634 | 634 | continue; |
635 | 635 | } |
636 | 636 | //if this dtt is active then we return false. |
637 | - if ( $datetime->is_active() ) { |
|
637 | + if ($datetime->is_active()) { |
|
638 | 638 | return FALSE; |
639 | 639 | } |
640 | 640 | //otherwise let's check upcoming status |
@@ -651,21 +651,21 @@ discard block |
||
651 | 651 | */ |
652 | 652 | public function is_active() { |
653 | 653 | // check if event id is present and if this event is published |
654 | - if ( $this->is_inactive() ) { |
|
654 | + if ($this->is_inactive()) { |
|
655 | 655 | return FALSE; |
656 | 656 | } |
657 | 657 | // set initial value |
658 | 658 | $active = FALSE; |
659 | 659 | //next let's get all datetimes and loop through them |
660 | 660 | $datetimes = $this->datetimes_in_chronological_order(); |
661 | - foreach ( $datetimes as $datetime ) { |
|
662 | - if ( $datetime instanceof EE_Datetime ) { |
|
661 | + foreach ($datetimes as $datetime) { |
|
662 | + if ($datetime instanceof EE_Datetime) { |
|
663 | 663 | //if this dtt is expired then we continue cause one of the other datetimes might be active. |
664 | - if ( $datetime->is_expired() ) { |
|
664 | + if ($datetime->is_expired()) { |
|
665 | 665 | continue; |
666 | 666 | } |
667 | 667 | //if this dtt is upcoming then we return false. |
668 | - if ( $datetime->is_upcoming() ) { |
|
668 | + if ($datetime->is_upcoming()) { |
|
669 | 669 | return FALSE; |
670 | 670 | } |
671 | 671 | //otherwise let's check active status |
@@ -682,17 +682,17 @@ discard block |
||
682 | 682 | */ |
683 | 683 | public function is_expired() { |
684 | 684 | // check if event id is present and if this event is published |
685 | - if ( $this->is_inactive() ) { |
|
685 | + if ($this->is_inactive()) { |
|
686 | 686 | return FALSE; |
687 | 687 | } |
688 | 688 | // set initial value |
689 | 689 | $expired = FALSE; |
690 | 690 | //first let's get all datetimes and loop through them |
691 | 691 | $datetimes = $this->datetimes_in_chronological_order(); |
692 | - foreach ( $datetimes as $datetime ) { |
|
693 | - if ( $datetime instanceof EE_Datetime ) { |
|
692 | + foreach ($datetimes as $datetime) { |
|
693 | + if ($datetime instanceof EE_Datetime) { |
|
694 | 694 | //if this dtt is upcoming or active then we return false. |
695 | - if ( $datetime->is_upcoming() || $datetime->is_active() ) { |
|
695 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
696 | 696 | return FALSE; |
697 | 697 | } |
698 | 698 | //otherwise let's check active status |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function is_inactive() { |
711 | 711 | // check if event id is present and if this event is published |
712 | - if ( $this->_has_ID_and_is_published() ) { |
|
712 | + if ($this->_has_ID_and_is_published()) { |
|
713 | 713 | return FALSE; |
714 | 714 | } |
715 | 715 | return TRUE; |
@@ -727,37 +727,37 @@ discard block |
||
727 | 727 | */ |
728 | 728 | public function perform_sold_out_status_check() { |
729 | 729 | // get all unexpired untrashed tickets |
730 | - $tickets = $this->tickets( array( |
|
730 | + $tickets = $this->tickets(array( |
|
731 | 731 | array( |
732 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
732 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
733 | 733 | 'TKT_deleted' => false |
734 | 734 | ) |
735 | 735 | )); |
736 | 736 | // if all the tickets are just expired, then don't update the event status to sold out |
737 | - if ( empty( $tickets )) { |
|
737 | + if (empty($tickets)) { |
|
738 | 738 | return true; |
739 | 739 | } |
740 | 740 | // set initial value |
741 | 741 | $spaces_remaining = 0; |
742 | - foreach( $tickets as $ticket ) { |
|
743 | - if ( $ticket instanceof EE_Ticket ) { |
|
744 | - $spaces_remaining += $ticket->qty( 'saleable' ); |
|
742 | + foreach ($tickets as $ticket) { |
|
743 | + if ($ticket instanceof EE_Ticket) { |
|
744 | + $spaces_remaining += $ticket->qty('saleable'); |
|
745 | 745 | } |
746 | 746 | } |
747 | - if ( $spaces_remaining === 0 ) { |
|
748 | - $this->set_status( EEM_Event::sold_out ); |
|
749 | - if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) { |
|
747 | + if ($spaces_remaining === 0) { |
|
748 | + $this->set_status(EEM_Event::sold_out); |
|
749 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
750 | 750 | $this->save(); |
751 | 751 | } |
752 | 752 | $sold_out = TRUE; |
753 | 753 | } else { |
754 | 754 | $sold_out = FALSE; |
755 | 755 | // was event previously marked as sold out ? |
756 | - if ( $this->status() == EEM_Event::sold_out ) { |
|
756 | + if ($this->status() == EEM_Event::sold_out) { |
|
757 | 757 | // revert status to previous value, if it was set |
758 | - $previous_event_status = $this->get_post_meta( '_previous_event_status', true ); |
|
759 | - if ( $previous_event_status ) { |
|
760 | - $this->set_status( $previous_event_status ); |
|
758 | + $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
759 | + if ($previous_event_status) { |
|
760 | + $this->set_status($previous_event_status); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -781,15 +781,15 @@ discard block |
||
781 | 781 | */ |
782 | 782 | public function spaces_remaining_for_sale() { |
783 | 783 | //first get total available spaces including consideration for tickets that have already sold. |
784 | - $spaces_available = $this->total_available_spaces( true ); |
|
784 | + $spaces_available = $this->total_available_spaces(true); |
|
785 | 785 | |
786 | 786 | //if total available = 0, then exit right away because that means everything is expired. |
787 | - if ( $spaces_available === 0 ) { |
|
787 | + if ($spaces_available === 0) { |
|
788 | 788 | return 0; |
789 | 789 | } |
790 | 790 | |
791 | 791 | //subtract total approved registrations from spaces available to get how many are remaining. |
792 | - $spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
792 | + $spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
793 | 793 | $spaces_remaining = $spaces_available - $spots_taken; |
794 | 794 | |
795 | 795 | return $spaces_remaining > 0 ? $spaces_remaining : 0; |
@@ -822,29 +822,29 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
824 | 824 | */ |
825 | - public function total_available_spaces( $current_total_available = false ) { |
|
825 | + public function total_available_spaces($current_total_available = false) { |
|
826 | 826 | $spaces_available = 0; |
827 | 827 | |
828 | 828 | //first get all tickets on the event and include expired tickets |
829 | - $tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) ); |
|
829 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
830 | 830 | $ticket_sums = array(); |
831 | 831 | $datetime_limits = array(); |
832 | 832 | |
833 | 833 | //loop through tickets and normalize them |
834 | - foreach ( $tickets as $ticket ) { |
|
835 | - $datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
834 | + foreach ($tickets as $ticket) { |
|
835 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
836 | 836 | |
837 | - if ( empty( $datetimes ) ) { |
|
837 | + if (empty($datetimes)) { |
|
838 | 838 | continue; |
839 | 839 | } |
840 | 840 | |
841 | 841 | //first datetime should be the lowest datetime |
842 | - $least_datetime = reset( $datetimes ); |
|
842 | + $least_datetime = reset($datetimes); |
|
843 | 843 | |
844 | 844 | //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
845 | 845 | //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
846 | - if ( $current_total_available ) { |
|
847 | - if ( $ticket->is_remaining() ) { |
|
846 | + if ($current_total_available) { |
|
847 | + if ($ticket->is_remaining()) { |
|
848 | 848 | $remaining = $ticket->remaining(); |
849 | 849 | } else { |
850 | 850 | $spaces_available += $ticket->sold(); |
@@ -852,23 +852,23 @@ discard block |
||
852 | 852 | continue; |
853 | 853 | } |
854 | 854 | } else { |
855 | - $remaining = min( $ticket->qty(), $least_datetime->reg_limit() ); |
|
855 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
859 | - if ( $remaining == EE_INF ) { |
|
859 | + if ($remaining == EE_INF) { |
|
860 | 860 | return EE_INF; |
861 | 861 | } |
862 | 862 | |
863 | 863 | //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
864 | 864 | //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
865 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes ); |
|
865 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
866 | 866 | $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
867 | - foreach ( $datetimes as $datetime ) { |
|
868 | - if ( $datetime->reg_limit() === EE_INF ) { |
|
867 | + foreach ($datetimes as $datetime) { |
|
868 | + if ($datetime->reg_limit() === EE_INF) { |
|
869 | 869 | $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
870 | 870 | } else { |
871 | - $ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
871 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
872 | 872 | } |
873 | 873 | $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
874 | 874 | } |
@@ -879,74 +879,74 @@ discard block |
||
879 | 879 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
880 | 880 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
881 | 881 | //$current_total_available ) for the datetimes on the ticket. |
882 | - usort( $ticket_sums, function( $a, $b ) { |
|
883 | - if ( $a['sum'] == $b['sum'] ) { |
|
884 | - if ( $a['datetime_sums'] == $b['datetime_sums'] ) { |
|
882 | + usort($ticket_sums, function($a, $b) { |
|
883 | + if ($a['sum'] == $b['sum']) { |
|
884 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
885 | 885 | return 0; |
886 | 886 | } |
887 | 887 | |
888 | 888 | return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
889 | 889 | } |
890 | - return ( $a['sum'] < $b['sum'] ) ? -1 : 1; |
|
890 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
891 | 891 | }); |
892 | 892 | |
893 | 893 | //now let's loop through the sorted tickets and simulate sellouts |
894 | - foreach ( $ticket_sums as $ticket_info ) { |
|
895 | - if ( $ticket_info['ticket'] instanceof EE_Ticket ) { |
|
894 | + foreach ($ticket_sums as $ticket_info) { |
|
895 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
896 | 896 | |
897 | - $datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
897 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
898 | 898 | //need to sort these $datetimes by remaining (only if $current_total_available) |
899 | 899 | //setup datetimes for simulation |
900 | 900 | $ticket_datetimes_remaining = array(); |
901 | - foreach( $datetimes as $datetime ) { |
|
901 | + foreach ($datetimes as $datetime) { |
|
902 | 902 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
903 | 903 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
904 | 904 | } |
905 | - usort( $ticket_datetimes_remaining, function( $a, $b ) { |
|
906 | - if ( $a['rem'] == $b['rem'] ) { |
|
905 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
906 | + if ($a['rem'] == $b['rem']) { |
|
907 | 907 | return 0; |
908 | 908 | } |
909 | - return ( $a['rem'] < $b['rem'] ) ? -1 : 1; |
|
909 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
910 | 910 | }); |
911 | 911 | |
912 | 912 | |
913 | 913 | //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
914 | 914 | //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
915 | - $lowest_datetime = reset( $ticket_datetimes_remaining ); |
|
915 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
916 | 916 | |
917 | 917 | //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
918 | 918 | // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
919 | 919 | // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
920 | 920 | // to the next ticket. |
921 | - if ( $current_total_available ) { |
|
922 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() ); |
|
921 | + if ($current_total_available) { |
|
922 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
923 | 923 | } else { |
924 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() ); |
|
924 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
928 | 928 | //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
929 | 929 | //available. |
930 | - if ( $remaining === EE_INF ) { |
|
930 | + if ($remaining === EE_INF) { |
|
931 | 931 | $spaces_available += $ticket_info['ticket']->qty(); |
932 | 932 | continue; |
933 | 933 | } |
934 | 934 | |
935 | 935 | //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
936 | - if ( $current_total_available ) { |
|
936 | + if ($current_total_available) { |
|
937 | 937 | $spaces_available += $ticket_info['ticket']->sold(); |
938 | 938 | } |
939 | 939 | |
940 | - if ( $remaining <= 0 ) { |
|
940 | + if ($remaining <= 0) { |
|
941 | 941 | continue; |
942 | 942 | } else { |
943 | 943 | $spaces_available += $remaining; |
944 | 944 | } |
945 | 945 | |
946 | 946 | //loop through the datetimes and sell them out! |
947 | - foreach ( $ticket_datetimes_remaining as $datetime_info ) { |
|
948 | - if ( $datetime_info['datetime'] instanceof EE_Datetime ) { |
|
949 | - $datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining; |
|
947 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
948 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
949 | + $datetime_limits[$datetime_info['datetime']->ID()] += - $remaining; |
|
950 | 950 | } |
951 | 951 | } |
952 | 952 | } |
@@ -962,8 +962,8 @@ discard block |
||
962 | 962 | * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event |
963 | 963 | * @return boolean |
964 | 964 | */ |
965 | - public function is_sold_out( $actual = FALSE ) { |
|
966 | - if ( ! $actual ) { |
|
965 | + public function is_sold_out($actual = FALSE) { |
|
966 | + if ( ! $actual) { |
|
967 | 967 | return $this->status() == EEM_Event::sold_out; |
968 | 968 | } |
969 | 969 | else { |
@@ -1001,36 +1001,36 @@ discard block |
||
1001 | 1001 | * @param bool $reset |
1002 | 1002 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
1003 | 1003 | */ |
1004 | - public function get_active_status( $reset = FALSE ) { |
|
1004 | + public function get_active_status($reset = FALSE) { |
|
1005 | 1005 | // if the active status has already been set, then just use that value (unless we are resetting it) |
1006 | - if ( ! empty( $this->_active_status ) && ! $reset ) { |
|
1006 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
1007 | 1007 | return $this->_active_status; |
1008 | 1008 | } |
1009 | 1009 | //first check if event id is present on this object |
1010 | - if ( ! $this->ID() ) { |
|
1010 | + if ( ! $this->ID()) { |
|
1011 | 1011 | return FALSE; |
1012 | 1012 | } |
1013 | 1013 | //first get all datetimes ordered by date |
1014 | 1014 | $datetimes = $this->datetimes_in_chronological_order(); |
1015 | 1015 | //next loop through $datetimes and setup status array |
1016 | 1016 | $status_array = array(); |
1017 | - foreach ( $datetimes as $datetime ) { |
|
1018 | - if ( $datetime instanceof EE_Datetime ) { |
|
1017 | + foreach ($datetimes as $datetime) { |
|
1018 | + if ($datetime instanceof EE_Datetime) { |
|
1019 | 1019 | $status_array[] = $datetime->get_active_status(); |
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | //now we can conditionally determine status |
1023 | - if ( $this->status() == 'publish' ) { |
|
1024 | - if ( in_array( EE_Datetime::active, $status_array ) ) { |
|
1023 | + if ($this->status() == 'publish') { |
|
1024 | + if (in_array(EE_Datetime::active, $status_array)) { |
|
1025 | 1025 | $this->_active_status = EE_Datetime::active; |
1026 | 1026 | } else { |
1027 | - if ( in_array( EE_Datetime::upcoming, $status_array ) ) { |
|
1027 | + if (in_array(EE_Datetime::upcoming, $status_array)) { |
|
1028 | 1028 | $this->_active_status = EE_Datetime::upcoming; |
1029 | 1029 | } else { |
1030 | - if ( in_array( EE_Datetime::expired, $status_array ) ) { |
|
1030 | + if (in_array(EE_Datetime::expired, $status_array)) { |
|
1031 | 1031 | $this->_active_status = EE_Datetime::expired; |
1032 | 1032 | } else { |
1033 | - if ( in_array( EE_Datetime::sold_out, $status_array ) ) { |
|
1033 | + if (in_array(EE_Datetime::sold_out, $status_array)) { |
|
1034 | 1034 | $this->_active_status = EE_Datetime::sold_out; |
1035 | 1035 | } else { |
1036 | 1036 | $this->_active_status = EE_Datetime::expired; //catchall |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | } |
1040 | 1040 | } |
1041 | 1041 | } else { |
1042 | - switch ( $this->status() ) { |
|
1042 | + switch ($this->status()) { |
|
1043 | 1043 | case EEM_Event::sold_out : |
1044 | 1044 | $this->_active_status = EE_Datetime::sold_out; |
1045 | 1045 | break; |
@@ -1065,10 +1065,10 @@ discard block |
||
1065 | 1065 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1066 | 1066 | * @return mixed void|string |
1067 | 1067 | */ |
1068 | - public function pretty_active_status( $echo = TRUE ) { |
|
1068 | + public function pretty_active_status($echo = TRUE) { |
|
1069 | 1069 | $active_status = $this->get_active_status(); |
1070 | - $status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>'; |
|
1071 | - if ( $echo ) { |
|
1070 | + $status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>'; |
|
1071 | + if ($echo) { |
|
1072 | 1072 | echo $status; |
1073 | 1073 | return ''; |
1074 | 1074 | } |
@@ -1082,12 +1082,12 @@ discard block |
||
1082 | 1082 | */ |
1083 | 1083 | public function get_number_of_tickets_sold() { |
1084 | 1084 | $tkt_sold = 0; |
1085 | - if ( !$this->ID() ) { |
|
1085 | + if ( ! $this->ID()) { |
|
1086 | 1086 | return 0; |
1087 | 1087 | } |
1088 | 1088 | $datetimes = $this->datetimes(); |
1089 | - foreach ( $datetimes as $datetime ) { |
|
1090 | - if ( $datetime instanceof EE_Datetime ) { |
|
1089 | + foreach ($datetimes as $datetime) { |
|
1090 | + if ($datetime instanceof EE_Datetime) { |
|
1091 | 1091 | $tkt_sold += $datetime->sold(); |
1092 | 1092 | } |
1093 | 1093 | } |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | * @return int |
1103 | 1103 | */ |
1104 | 1104 | public function get_count_of_all_registrations() { |
1105 | - return EEM_Event::instance()->count_related( $this, 'Registration' ); |
|
1105 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
@@ -1112,9 +1112,9 @@ discard block |
||
1112 | 1112 | * @return EE_Ticket |
1113 | 1113 | */ |
1114 | 1114 | public function get_ticket_with_earliest_start_time() { |
1115 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1116 | - $query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) ); |
|
1117 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1115 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1116 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1117 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | * @return EE_Ticket |
1125 | 1125 | */ |
1126 | 1126 | public function get_ticket_with_latest_end_time() { |
1127 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1128 | - $query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) ); |
|
1129 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1127 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1128 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1129 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | |
@@ -1138,11 +1138,11 @@ discard block |
||
1138 | 1138 | public function tickets_on_sale() { |
1139 | 1139 | $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
1140 | 1140 | $latest_ticket = $this->get_ticket_with_latest_end_time(); |
1141 | - if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) { |
|
1141 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1142 | 1142 | return FALSE; |
1143 | 1143 | } |
1144 | 1144 | //check on sale for these two tickets. |
1145 | - if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) { |
|
1145 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1146 | 1146 | return TRUE; |
1147 | 1147 | } |
1148 | 1148 | return FALSE; |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | * @return string |
1157 | 1157 | */ |
1158 | 1158 | public function get_permalink() { |
1159 | - if ( $this->external_url() ) { |
|
1159 | + if ($this->external_url()) { |
|
1160 | 1160 | return $this->external_url(); |
1161 | 1161 | } |
1162 | 1162 | else { |
@@ -1171,10 +1171,10 @@ discard block |
||
1171 | 1171 | * @param array $query_params like EEM_Base::get_all |
1172 | 1172 | * @return EE_Term |
1173 | 1173 | */ |
1174 | - public function first_event_category( $query_params = array() ) { |
|
1175 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1176 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1177 | - return EEM_Term::instance()->get_one( $query_params ); |
|
1174 | + public function first_event_category($query_params = array()) { |
|
1175 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1176 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1177 | + return EEM_Term::instance()->get_one($query_params); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | |
@@ -1184,10 +1184,10 @@ discard block |
||
1184 | 1184 | * @param array $query_params |
1185 | 1185 | * @return EE_Term[] |
1186 | 1186 | */ |
1187 | - public function get_all_event_categories( $query_params = array() ) { |
|
1188 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1189 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1190 | - return EEM_Term::instance()->get_all( $query_params ); |
|
1187 | + public function get_all_event_categories($query_params = array()) { |
|
1188 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1189 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1190 | + return EEM_Term::instance()->get_all($query_params); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | /** |
@@ -1195,8 +1195,8 @@ discard block |
||
1195 | 1195 | * @param array $query_params @see EEM_Base::get_all |
1196 | 1196 | * @return EE_Question_Group[] |
1197 | 1197 | */ |
1198 | - public function question_groups($query_params = array()){ |
|
1199 | - $query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' )); |
|
1198 | + public function question_groups($query_params = array()) { |
|
1199 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1200 | 1200 | return $this->get_many_related('Question_Group', $query_params); |
1201 | 1201 | } |
1202 | 1202 | |
@@ -1236,12 +1236,12 @@ discard block |
||
1236 | 1236 | */ |
1237 | 1237 | public function get_admin_edit_link() { |
1238 | 1238 | EE_Registry::instance()->load_helper('URL'); |
1239 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1239 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1240 | 1240 | 'page' => 'espresso_events', |
1241 | 1241 | 'action' => 'edit', |
1242 | 1242 | 'post' => $this->ID() |
1243 | 1243 | ), |
1244 | - admin_url( 'admin.php' ) |
|
1244 | + admin_url('admin.php') |
|
1245 | 1245 | ); |
1246 | 1246 | } |
1247 | 1247 | |
@@ -1254,11 +1254,11 @@ discard block |
||
1254 | 1254 | */ |
1255 | 1255 | public function get_admin_settings_link() { |
1256 | 1256 | EE_Registry::instance()->load_helper('URL'); |
1257 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1257 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1258 | 1258 | 'page' => 'espresso_events', |
1259 | 1259 | 'action' => 'default_event_settings' |
1260 | 1260 | ), |
1261 | - admin_url( 'admin.php' ) |
|
1261 | + admin_url('admin.php') |
|
1262 | 1262 | ); |
1263 | 1263 | } |
1264 | 1264 | |
@@ -1274,11 +1274,11 @@ discard block |
||
1274 | 1274 | public function get_admin_overview_link() { |
1275 | 1275 | |
1276 | 1276 | EE_Registry::instance()->load_helper('URL'); |
1277 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1277 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1278 | 1278 | 'page' => 'espresso_events', |
1279 | 1279 | 'action' => 'default' |
1280 | 1280 | ), |
1281 | - admin_url( 'admin.php' ) |
|
1281 | + admin_url('admin.php') |
|
1282 | 1282 | ); |
1283 | 1283 | } |
1284 | 1284 |
@@ -352,8 +352,7 @@ discard block |
||
352 | 352 | $short_desc = $this->get( 'EVT_short_desc' ); |
353 | 353 | if ( !empty( $short_desc ) || $not_full_desc ) { |
354 | 354 | return $short_desc; |
355 | - } |
|
356 | - else { |
|
355 | + } else { |
|
357 | 356 | $full_desc = $this->get( 'EVT_desc' ); |
358 | 357 | return wp_trim_words( $full_desc, $num_words, $more ); |
359 | 358 | } |
@@ -965,8 +964,7 @@ discard block |
||
965 | 964 | public function is_sold_out( $actual = FALSE ) { |
966 | 965 | if ( ! $actual ) { |
967 | 966 | return $this->status() == EEM_Event::sold_out; |
968 | - } |
|
969 | - else { |
|
967 | + } else { |
|
970 | 968 | return $this->perform_sold_out_status_check(); |
971 | 969 | } |
972 | 970 | } |
@@ -1158,8 +1156,7 @@ discard block |
||
1158 | 1156 | public function get_permalink() { |
1159 | 1157 | if ( $this->external_url() ) { |
1160 | 1158 | return $this->external_url(); |
1161 | - } |
|
1162 | - else { |
|
1159 | + } else { |
|
1163 | 1160 | return parent::get_permalink(); |
1164 | 1161 | } |
1165 | 1162 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | 'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ), |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,45 +593,45 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out( true ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
610 | + if ($event->is_sold_out(true)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | 612 | EE_Error::add_attention( |
613 | 613 | sprintf( |
614 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
615 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
614 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
615 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | } |
619 | 619 | return; |
620 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
620 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
621 | 621 | EE_Error::add_attention( |
622 | 622 | sprintf( |
623 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | - 'event_espresso' ), |
|
625 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
623 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | + 'event_espresso'), |
|
625 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
626 | 626 | ) |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
630 | - if ( ! $event->tickets_on_sale() ) { |
|
630 | + if ( ! $event->tickets_on_sale()) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | //made it here so show warning |
634 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
634 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
674 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
675 | 675 | $this->_views['trash'] = array( |
676 | 676 | 'slug' => 'trash', |
677 | 677 | 'label' => __('Trash', 'event_espresso'), |
@@ -701,39 +701,39 @@ discard block |
||
701 | 701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
702 | 702 | ) |
703 | 703 | ); |
704 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
704 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
705 | 705 | $statuses = array( |
706 | 706 | 'sold_out_status' => array( |
707 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
708 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
707 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
708 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
709 | 709 | ), |
710 | 710 | 'active_status' => array( |
711 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
712 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
711 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
712 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
713 | 713 | ), |
714 | 714 | 'upcoming_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'postponed_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'cancelled_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'expired_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'inactive_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
733 | 733 | ) |
734 | 734 | ); |
735 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
736 | - return array_merge( $items, $statuses ); |
|
735 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
736 | + return array_merge($items, $statuses); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @return EEM_Event |
746 | 746 | */ |
747 | 747 | private function _event_model() { |
748 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
749 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
748 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
749 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
750 | 750 | } |
751 | 751 | return $this->_event_model; |
752 | 752 | } |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * @param string $new_slug what the slug is |
766 | 766 | * @return string The new html string for the permalink area |
767 | 767 | */ |
768 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
768 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
769 | 769 | //make sure this is only when editing |
770 | - if ( !empty( $id ) ) { |
|
771 | - $post = get_post( $id ); |
|
772 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
773 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">'; |
|
770 | + if ( ! empty($id)) { |
|
771 | + $post = get_post($id); |
|
772 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
773 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">'; |
|
774 | 774 | } |
775 | 775 | return $return; |
776 | 776 | } |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @return string html for generated table |
787 | 787 | */ |
788 | 788 | protected function _events_overview_list_table() { |
789 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
790 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
789 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
790 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
791 | 791 | $this->_display_legend($this->_event_legend_items()); |
792 | 792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
793 | 793 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -805,51 +805,51 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | |
808 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
808 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
809 | 809 | |
810 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
810 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
811 | 811 | //getout we're not processing an event save. |
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $event_values = array( |
816 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
817 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
816 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
817 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
818 | 818 | 'EVT_additional_limit' => min( |
819 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
820 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
823 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
824 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
826 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
819 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
820 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
823 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
824 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
826 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
827 | 827 | ); |
828 | 828 | |
829 | 829 | //update event |
830 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
830 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
834 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | |
838 | 838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
839 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
839 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
840 | 840 | |
841 | 841 | $att_success = TRUE; |
842 | 842 | |
843 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
845 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
843 | + foreach ($event_update_callbacks as $e_callback) { |
|
844 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
845 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | //any errors? |
849 | - if ( $success && FALSE === $att_success ) { |
|
850 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | - } else if ( $success === FALSE ) { |
|
852 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + if ($success && FALSE === $att_success) { |
|
850 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | + } else if ($success === FALSE) { |
|
852 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @see parent::restore_item() |
861 | 861 | */ |
862 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
862 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
863 | 863 | //copy existing event meta to new post |
864 | 864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
865 | - if ( $post_evt instanceof EE_Event ) { |
|
865 | + if ($post_evt instanceof EE_Event) { |
|
866 | 866 | //meta revision restore |
867 | - $post_evt->restore_revision( $revision_id ); |
|
867 | + $post_evt->restore_revision($revision_id); |
|
868 | 868 | //related objs restore |
869 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
869 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -879,52 +879,52 @@ discard block |
||
879 | 879 | * @param array $data The request data from the form |
880 | 880 | * @return bool Success or fail. |
881 | 881 | */ |
882 | - protected function _default_venue_update( $evtobj, $data ) { |
|
883 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
882 | + protected function _default_venue_update($evtobj, $data) { |
|
883 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
884 | 884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
885 | 885 | $rows_affected = NULL; |
886 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
886 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
887 | 887 | |
888 | 888 | // very important. If we don't have a venue name... |
889 | 889 | // then we'll get out because not necessary to create empty venue |
890 | - if ( empty( $data['venue_title'] ) ) { |
|
890 | + if (empty($data['venue_title'])) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $venue_array = array( |
895 | 895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
896 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
897 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
898 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
899 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
900 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
901 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
902 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
903 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
904 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
905 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
906 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
907 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
908 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
909 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
911 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
896 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
897 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
898 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
899 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
900 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
901 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
902 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
903 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
904 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
905 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
906 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
907 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
908 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
909 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
911 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
912 | 912 | 'status' => 'publish' |
913 | 913 | ); |
914 | 914 | |
915 | 915 | |
916 | 916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
917 | - if ( !empty( $venue_id ) ) { |
|
918 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
919 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
917 | + if ( ! empty($venue_id)) { |
|
918 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
919 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
920 | 920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
921 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
921 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
922 | 922 | return $rows_affected > 0 ? TRUE : FALSE; |
923 | 923 | } else { |
924 | 924 | //we insert the venue |
925 | - $venue_id = $venue_model->insert( $venue_array ); |
|
926 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
927 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
925 | + $venue_id = $venue_model->insert($venue_array); |
|
926 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
927 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
928 | 928 | } |
929 | 929 | //when we have the ancestor come in it's already been handled by the revision save. |
930 | 930 | } |
@@ -938,55 +938,55 @@ discard block |
||
938 | 938 | * @param array $data The request data from the form |
939 | 939 | * @return bool success or fail |
940 | 940 | */ |
941 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
941 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
942 | 942 | $success = true; |
943 | 943 | $saved_dtt = null; |
944 | 944 | $saved_tickets = array(); |
945 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
945 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
946 | 946 | |
947 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
947 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
948 | 948 | //trim all values to ensure any excess whitespace is removed. |
949 | - $dtt = array_map( 'trim', $dtt ); |
|
950 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
949 | + $dtt = array_map('trim', $dtt); |
|
950 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
951 | 951 | $datetime_values = array( |
952 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
952 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
953 | 953 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
954 | 954 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
955 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
955 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
956 | 956 | 'DTT_order' => $row, |
957 | 957 | ); |
958 | 958 | |
959 | 959 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
960 | 960 | |
961 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
962 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - foreach ( $datetime_values as $field => $value ) { |
|
966 | - $DTM->set( $field, $value ); |
|
961 | + if ( ! empty($dtt['DTT_ID'])) { |
|
962 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + foreach ($datetime_values as $field => $value) { |
|
966 | + $DTM->set($field, $value); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
970 | 970 | $saved_dtts[$DTM->ID()] = $DTM; |
971 | 971 | } else { |
972 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
973 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
974 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
975 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
976 | - foreach ( $datetime_values as $field => $value ) { |
|
977 | - $DTM->set( $field, $value ); |
|
972 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
973 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
974 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
975 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
976 | + foreach ($datetime_values as $field => $value) { |
|
977 | + $DTM->set($field, $value); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | $DTM->save(); |
981 | 981 | |
982 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
982 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
983 | 983 | |
984 | 984 | //load DTT helper |
985 | 985 | EE_Registry::instance()->load_helper('DTT_Helper'); |
986 | 986 | |
987 | 987 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
988 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
989 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
988 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
989 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
990 | 990 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
991 | 991 | $DTT->save(); |
992 | 992 | } |
@@ -994,45 +994,45 @@ discard block |
||
994 | 994 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
995 | 995 | $saved_dtt = $DTT; |
996 | 996 | |
997 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
997 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | //no dtts get deleted so we don't do any of that logic here. |
1001 | 1001 | //update tickets next |
1002 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1003 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1004 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1002 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1003 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1004 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1005 | 1005 | $update_prices = false; |
1006 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1006 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1007 | 1007 | |
1008 | 1008 | // trim inputs to ensure any excess whitespace is removed. |
1009 | - $tkt = array_map( 'trim', $tkt ); |
|
1009 | + $tkt = array_map('trim', $tkt); |
|
1010 | 1010 | |
1011 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1011 | + if (empty($tkt['TKT_start_date'])) { |
|
1012 | 1012 | //let's use now in the set timezone. |
1013 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1014 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1013 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1014 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1017 | + if (empty($tkt['TKT_end_date'])) { |
|
1018 | 1018 | //use the start date of the first datetime |
1019 | 1019 | $dtt = $evtobj->first_datetime(); |
1020 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1020 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $TKT_values = array( |
1024 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1025 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1026 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1027 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1024 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1025 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1026 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1027 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1028 | 1028 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1029 | 1029 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1030 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1032 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1033 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1030 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1032 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1033 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1034 | 1034 | 'TKT_row' => $row, |
1035 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1035 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1036 | 1036 | 'TKT_price' => $ticket_price |
1037 | 1037 | ); |
1038 | 1038 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1043 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1043 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1044 | 1044 | $TKT_values['TKT_ID'] = 0; |
1045 | 1045 | $TKT_values['TKT_is_default'] = 0; |
1046 | 1046 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1051,58 +1051,58 @@ discard block |
||
1051 | 1051 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1052 | 1052 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1053 | 1053 | |
1054 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1055 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1056 | - if ( $TKT instanceof EE_Ticket ) { |
|
1057 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1054 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1055 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1056 | + if ($TKT instanceof EE_Ticket) { |
|
1057 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1058 | 1058 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1059 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1060 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1061 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1059 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1060 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1061 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1062 | 1062 | //set new values |
1063 | - foreach ( $TKT_values as $field => $value ) { |
|
1064 | - if ( $field == 'TKT_qty' ) { |
|
1065 | - $TKT->set_qty( $value ); |
|
1063 | + foreach ($TKT_values as $field => $value) { |
|
1064 | + if ($field == 'TKT_qty') { |
|
1065 | + $TKT->set_qty($value); |
|
1066 | 1066 | } else { |
1067 | - $TKT->set( $field, $value ); |
|
1067 | + $TKT->set($field, $value); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1071 | - if ( $create_new_TKT ) { |
|
1071 | + if ($create_new_TKT) { |
|
1072 | 1072 | //archive the old ticket first |
1073 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1073 | + $TKT->set('TKT_deleted', 1); |
|
1074 | 1074 | $TKT->save(); |
1075 | 1075 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1076 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1076 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1077 | 1077 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1078 | 1078 | $TKT = clone $TKT; |
1079 | - $TKT->set( 'TKT_ID', 0 ); |
|
1080 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1081 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1082 | - $TKT->set( 'TKT_sold', 0 ); |
|
1079 | + $TKT->set('TKT_ID', 0); |
|
1080 | + $TKT->set('TKT_deleted', 0); |
|
1081 | + $TKT->set('TKT_price', $ticket_price); |
|
1082 | + $TKT->set('TKT_sold', 0); |
|
1083 | 1083 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1084 | 1084 | $update_prices = true; |
1085 | 1085 | } |
1086 | 1086 | //make sure price is set if it hasn't been already |
1087 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1087 | + $TKT->set('TKT_price', $ticket_price); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | } else { |
1091 | 1091 | //no TKT_id so a new TKT |
1092 | 1092 | $TKT_values['TKT_price'] = $ticket_price; |
1093 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1094 | - if ( $TKT instanceof EE_Ticket ) { |
|
1093 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1094 | + if ($TKT instanceof EE_Ticket) { |
|
1095 | 1095 | //need to reset values to properly account for the date formats |
1096 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1097 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1098 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1096 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1097 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1098 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1099 | 1099 | |
1100 | 1100 | //set new values |
1101 | - foreach ( $TKT_values as $field => $value ) { |
|
1102 | - if ( $field == 'TKT_qty' ) { |
|
1103 | - $TKT->set_qty( $value ); |
|
1101 | + foreach ($TKT_values as $field => $value) { |
|
1102 | + if ($field == 'TKT_qty') { |
|
1103 | + $TKT->set_qty($value); |
|
1104 | 1104 | } else { |
1105 | - $TKT->set( $field, $value ); |
|
1105 | + $TKT->set($field, $value); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | // cap ticket qty by datetime reg limits |
1113 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1113 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1114 | 1114 | //update ticket. |
1115 | 1115 | $TKT->save(); |
1116 | 1116 | |
1117 | 1117 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1118 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1119 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1118 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1119 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1120 | 1120 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1121 | 1121 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | //initially let's add the ticket to the dtt |
1126 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1126 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1127 | 1127 | |
1128 | 1128 | $saved_tickets[$TKT->ID()] = $TKT; |
1129 | 1129 | |
1130 | 1130 | //add prices to ticket |
1131 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1131 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1132 | 1132 | } |
1133 | 1133 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1134 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1134 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1136 | 1136 | |
1137 | - foreach ( $tickets_removed as $id ) { |
|
1138 | - $id = absint( $id ); |
|
1137 | + foreach ($tickets_removed as $id) { |
|
1138 | + $id = absint($id); |
|
1139 | 1139 | |
1140 | 1140 | //get the ticket for this id |
1141 | 1141 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1144 | 1144 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1145 | 1145 | |
1146 | - foreach( $dtts as $dtt ) { |
|
1146 | + foreach ($dtts as $dtt) { |
|
1147 | 1147 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1155 | 1155 | $tkt_to_remove->delete_permanently(); |
1156 | 1156 | } |
1157 | - return array( $saved_dtt, $saved_tickets ); |
|
1157 | + return array($saved_dtt, $saved_tickets); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1169,31 +1169,31 @@ discard block |
||
1169 | 1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1173 | - foreach ( $prices as $row => $prc ) { |
|
1172 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1173 | + foreach ($prices as $row => $prc) { |
|
1174 | 1174 | $PRC_values = array( |
1175 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1176 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1177 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1178 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1179 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1175 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1176 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1177 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1178 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1179 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1180 | 1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1181 | 1181 | 'PRC_order' => $row |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1184 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1185 | 1185 | $PRC_values['PRC_ID'] = 0; |
1186 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1186 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1187 | 1187 | } else { |
1188 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1188 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1189 | 1189 | //update this price with new values |
1190 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1191 | - $PRC->set( $field, $newprc ); |
|
1190 | + foreach ($PRC_values as $field => $newprc) { |
|
1191 | + $PRC->set($field, $newprc); |
|
1192 | 1192 | } |
1193 | 1193 | $PRC->save(); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1196 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1216,33 +1216,33 @@ discard block |
||
1216 | 1216 | |
1217 | 1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1218 | 1218 | |
1219 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1219 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1220 | 1220 | |
1221 | 1221 | |
1222 | 1222 | //if no postid then get out cause we need it for stuff in here |
1223 | - if ( empty( $postid ) ) return; |
|
1223 | + if (empty($postid)) return; |
|
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | //handle datetime saves |
1227 | 1227 | $items = array(); |
1228 | 1228 | |
1229 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1230 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1229 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1230 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1231 | 1231 | |
1232 | 1232 | //now let's get the attached datetimes from the most recent autosave |
1233 | 1233 | $dtts = $event->get_many_related('Datetime'); |
1234 | 1234 | |
1235 | 1235 | $dtt_ids = array(); |
1236 | - foreach( $dtts as $dtt ) { |
|
1236 | + foreach ($dtts as $dtt) { |
|
1237 | 1237 | $dtt_ids[] = $dtt->ID(); |
1238 | 1238 | $order = $dtt->order(); |
1239 | 1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1240 | 1240 | } |
1241 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1241 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1242 | 1242 | |
1243 | 1243 | //handle DECAF venues |
1244 | 1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1245 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1245 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1246 | 1246 | $venue = $event->get_first_related('Venue'); |
1247 | 1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1248 | 1248 | } |
@@ -1253,23 +1253,23 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $ticket_ids = array(); |
1255 | 1255 | $price_ids = array(); |
1256 | - foreach ( $tickets as $ticket ) { |
|
1256 | + foreach ($tickets as $ticket) { |
|
1257 | 1257 | $ticket_ids[] = $price->ID(); |
1258 | 1258 | $ticket_order = $price->get('TKT_order'); |
1259 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1261 | 1261 | |
1262 | 1262 | //now we have to make sure the prices are updated appropriately |
1263 | 1263 | $prices = $ticket->get_many_related('Prices'); |
1264 | 1264 | |
1265 | - foreach ( $prices as $price ) { |
|
1265 | + foreach ($prices as $price) { |
|
1266 | 1266 | $price_ids[] = $price->ID(); |
1267 | 1267 | $price_order = $price->get('PRC_order'); |
1268 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1269 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1270 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1268 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1269 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1270 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1271 | 1271 | } |
1272 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1272 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1273 | 1273 | } |
1274 | 1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1275 | 1275 | } |
@@ -1287,12 +1287,12 @@ discard block |
||
1287 | 1287 | private function _generate_publish_box_extra_content() { |
1288 | 1288 | |
1289 | 1289 | //load formatter helper |
1290 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1290 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1291 | 1291 | |
1292 | 1292 | //args for getting related registrations |
1293 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1294 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1295 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1293 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1294 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1295 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1296 | 1296 | |
1297 | 1297 | |
1298 | 1298 | // publish box |
@@ -1321,9 +1321,9 @@ discard block |
||
1321 | 1321 | ), |
1322 | 1322 | REG_ADMIN_URL |
1323 | 1323 | ), |
1324 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1325 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1326 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1324 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1325 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1326 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1327 | 1327 | 'misc_pub_section_class' => apply_filters( |
1328 | 1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1329 | 1329 | 'misc-pub-section' |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1343 | 1343 | $this->_cpt_model_obj |
1344 | 1344 | ); |
1345 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1345 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1346 | 1346 | // load template |
1347 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1347 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1376,16 +1376,16 @@ discard block |
||
1376 | 1376 | $this->verify_cpt_object(); |
1377 | 1377 | add_meta_box( |
1378 | 1378 | 'espresso_event_editor_tickets', |
1379 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1380 | - array( $this, 'ticket_metabox' ), |
|
1379 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1380 | + array($this, 'ticket_metabox'), |
|
1381 | 1381 | $this->page_slug, |
1382 | 1382 | 'normal', |
1383 | 1383 | 'high' |
1384 | 1384 | ); |
1385 | 1385 | add_meta_box( |
1386 | 1386 | 'espresso_event_editor_event_options', |
1387 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1388 | - array( $this, 'registration_options_meta_box' ), |
|
1387 | + __('Event Registration Options', 'event_espresso'), |
|
1388 | + array($this, 'registration_options_meta_box'), |
|
1389 | 1389 | $this->page_slug, |
1390 | 1390 | 'side', |
1391 | 1391 | 'default' |
@@ -1415,38 +1415,38 @@ discard block |
||
1415 | 1415 | 'disabled' => '' |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1418 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1419 | 1419 | |
1420 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1420 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * 1. Start with retrieving Datetimes |
1424 | 1424 | * 2. Fore each datetime get related tickets |
1425 | 1425 | * 3. For each ticket get related prices |
1426 | 1426 | */ |
1427 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1428 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1427 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1428 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1429 | 1429 | /** @type EE_Datetime $first_datetime */ |
1430 | - $first_datetime = array_slice( $times, 0, 1 ); |
|
1430 | + $first_datetime = array_slice($times, 0, 1); |
|
1431 | 1431 | //do we get related tickets? |
1432 | - if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) { |
|
1433 | - foreach ( $times as $time ) { |
|
1434 | - if ( $time instanceof EE_Datetime ) { |
|
1432 | + if ($first_datetime[0]->get('DTT_ID') !== 0) { |
|
1433 | + foreach ($times as $time) { |
|
1434 | + if ($time instanceof EE_Datetime) { |
|
1435 | 1435 | $existing_datetime_ids[] = $time->get('DTT_ID'); |
1436 | 1436 | $template_args['time'] = $time; |
1437 | 1437 | $related_tickets = $time->tickets( |
1438 | 1438 | array( |
1439 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1439 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1440 | 1440 | 'default_where_conditions' => 'none' |
1441 | 1441 | ) |
1442 | 1442 | ); |
1443 | 1443 | |
1444 | - if ( !empty($related_tickets) ) { |
|
1444 | + if ( ! empty($related_tickets)) { |
|
1445 | 1445 | $template_args['total_ticket_rows'] = count($related_tickets); |
1446 | 1446 | $row = 0; |
1447 | - foreach ( $related_tickets as $ticket ) { |
|
1447 | + foreach ($related_tickets as $ticket) { |
|
1448 | 1448 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1449 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1449 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1450 | 1450 | |
1451 | 1451 | $row++; |
1452 | 1452 | } |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | $template_args['total_ticket_rows'] = 1; |
1455 | 1455 | /** @type EE_Ticket $ticket */ |
1456 | 1456 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1457 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1457 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | } |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | $template_args['time'] = $times[0]; |
1463 | 1463 | /** @type EE_Ticket $ticket */ |
1464 | 1464 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1465 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1465 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1466 | 1466 | // NOTE: we're just sending the first default row |
1467 | 1467 | // (decaf can't manage default tickets so this should be sufficient); |
1468 | 1468 | } |
@@ -1471,8 +1471,8 @@ discard block |
||
1471 | 1471 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1472 | 1472 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1473 | 1473 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1474 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1475 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1474 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1475 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1476 | 1476 | EEH_Template::display_template($template, $template_args); |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1487,21 +1487,21 @@ discard block |
||
1487 | 1487 | * @param int $row |
1488 | 1488 | * @return string generated html for the ticket row. |
1489 | 1489 | */ |
1490 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1490 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1491 | 1491 | $template_args = array( |
1492 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1493 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1492 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1493 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1494 | 1494 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1495 | 1495 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1496 | 1496 | 'TKT_name' => $ticket->get('TKT_name'), |
1497 | 1497 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1498 | 1498 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1499 | 1499 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1500 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1500 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1501 | 1501 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1502 | 1502 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1503 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1504 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1503 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1504 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1505 | 1505 | ); |
1506 | 1506 | |
1507 | 1507 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1517,23 +1517,23 @@ discard block |
||
1517 | 1517 | |
1518 | 1518 | //make sure we have default start and end dates if skeleton |
1519 | 1519 | //handle rows that should NOT be empty |
1520 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1520 | + if (empty($template_args['TKT_start_date'])) { |
|
1521 | 1521 | //if empty then the start date will be now. |
1522 | 1522 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1523 | 1523 | } |
1524 | 1524 | |
1525 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1525 | + if (empty($template_args['TKT_end_date'])) { |
|
1526 | 1526 | //get the earliest datetime (if present); |
1527 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1527 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1528 | 1528 | |
1529 | - if ( !empty( $earliest_dtt ) ) |
|
1529 | + if ( ! empty($earliest_dtt)) |
|
1530 | 1530 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1531 | 1531 | else |
1532 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1532 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | - $template_args = array_merge( $template_args, $price_args ); |
|
1536 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1535 | + $template_args = array_merge($template_args, $price_args); |
|
1536 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1537 | 1537 | return EEH_Template::display_template($template, $template_args, TRUE); |
1538 | 1538 | } |
1539 | 1539 | |
@@ -1562,8 +1562,8 @@ discard block |
||
1562 | 1562 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1563 | 1563 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1564 | 1564 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1565 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1566 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1565 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1566 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1567 | 1567 | EEH_Template::display_template($templatepath, $template_args); |
1568 | 1568 | } |
1569 | 1569 | |
@@ -1591,21 +1591,21 @@ discard block |
||
1591 | 1591 | $EEME = $this->_event_model(); |
1592 | 1592 | |
1593 | 1593 | $offset = ($current_page - 1) * $per_page; |
1594 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1594 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1595 | 1595 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1596 | 1596 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1597 | 1597 | |
1598 | 1598 | if (isset($this->_req_data['month_range'])) { |
1599 | 1599 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1600 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1601 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1600 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1601 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | $where = array(); |
1605 | 1605 | |
1606 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1606 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1607 | 1607 | //determine what post_status our condition will have for the query. |
1608 | - switch ( $status ) { |
|
1608 | + switch ($status) { |
|
1609 | 1609 | case 'month' : |
1610 | 1610 | case 'today' : |
1611 | 1611 | case NULL : |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | break; |
1614 | 1614 | |
1615 | 1615 | case 'draft' : |
1616 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1616 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1617 | 1617 | break; |
1618 | 1618 | |
1619 | 1619 | default : |
@@ -1621,43 +1621,43 @@ discard block |
||
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | //categories? |
1624 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1624 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1625 | 1625 | |
1626 | - if ( !empty ( $category ) ) { |
|
1626 | + if ( ! empty ($category)) { |
|
1627 | 1627 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1628 | 1628 | $where['Term_Taxonomy.term_id'] = $category; |
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | //date where conditions |
1632 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1632 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1633 | 1633 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1634 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1635 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1636 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1637 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1634 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1635 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1636 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1637 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1638 | 1638 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1639 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1640 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1641 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1642 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1643 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1644 | - $now = date( 'Y-m-01' ); |
|
1645 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1646 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1647 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1648 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1639 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1640 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1641 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1642 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1643 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1644 | + $now = date('Y-m-01'); |
|
1645 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1646 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1647 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1648 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | |
1652 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1653 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1652 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1653 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1654 | 1654 | } else { |
1655 | - if ( ! isset( $where['status'] ) ) { |
|
1656 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1655 | + if ( ! isset($where['status'])) { |
|
1656 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1657 | 1657 | $where['OR'] = array( |
1658 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1658 | + 'status*restrict_private' => array('!=', 'private'), |
|
1659 | 1659 | 'AND' => array( |
1660 | - 'status*inclusive' => array( '=', 'private' ), |
|
1660 | + 'status*inclusive' => array('=', 'private'), |
|
1661 | 1661 | 'EVT_wp_user' => get_current_user_id() |
1662 | 1662 | ) |
1663 | 1663 | ); |
@@ -1665,16 +1665,16 @@ discard block |
||
1665 | 1665 | } |
1666 | 1666 | } |
1667 | 1667 | |
1668 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1669 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1668 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1669 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1670 | 1670 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1671 | 1671 | } |
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | |
1675 | 1675 | //search query handling |
1676 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1677 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1676 | + if (isset($this->_req_data['s'])) { |
|
1677 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1678 | 1678 | $where['OR'] = array( |
1679 | 1679 | 'EVT_name' => array('LIKE', $search_string), |
1680 | 1680 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1683,32 +1683,32 @@ discard block |
||
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | |
1686 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1687 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1686 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1687 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1688 | 1688 | |
1689 | 1689 | |
1690 | 1690 | //let's first check if we have special requests coming in. |
1691 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1692 | - switch ( $this->_req_data['active_status'] ) { |
|
1691 | + if (isset($this->_req_data['active_status'])) { |
|
1692 | + switch ($this->_req_data['active_status']) { |
|
1693 | 1693 | case 'upcoming' : |
1694 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1694 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1695 | 1695 | break; |
1696 | 1696 | |
1697 | 1697 | case 'expired' : |
1698 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1698 | + return $EEME->get_expired_events($query_params, $count); |
|
1699 | 1699 | break; |
1700 | 1700 | |
1701 | 1701 | case 'active' : |
1702 | - return $EEME->get_active_events( $query_params, $count ); |
|
1702 | + return $EEME->get_active_events($query_params, $count); |
|
1703 | 1703 | break; |
1704 | 1704 | |
1705 | 1705 | case 'inactive' : |
1706 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1706 | + return $EEME->get_inactive_events($query_params, $count); |
|
1707 | 1707 | break; |
1708 | 1708 | } |
1709 | 1709 | } |
1710 | 1710 | |
1711 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1711 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1712 | 1712 | |
1713 | 1713 | return $events; |
1714 | 1714 | } |
@@ -1717,23 +1717,23 @@ discard block |
||
1717 | 1717 | |
1718 | 1718 | |
1719 | 1719 | //handling for WordPress CPT actions (trash, restore, delete) |
1720 | - public function trash_cpt_item( $post_id ) { |
|
1720 | + public function trash_cpt_item($post_id) { |
|
1721 | 1721 | $this->_req_data['EVT_ID'] = $post_id; |
1722 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1722 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | |
1726 | 1726 | |
1727 | 1727 | |
1728 | - public function restore_cpt_item( $post_id ) { |
|
1728 | + public function restore_cpt_item($post_id) { |
|
1729 | 1729 | $this->_req_data['EVT_ID'] = $post_id; |
1730 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1730 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | |
1734 | - public function delete_cpt_item( $post_id ) { |
|
1734 | + public function delete_cpt_item($post_id) { |
|
1735 | 1735 | $this->_req_data['EVT_ID'] = $post_id; |
1736 | - $this->_delete_event( FALSE ); |
|
1736 | + $this->_delete_event(FALSE); |
|
1737 | 1737 | } |
1738 | 1738 | |
1739 | 1739 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | * @param string $event_status |
1746 | 1746 | * @return void |
1747 | 1747 | */ |
1748 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1748 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1749 | 1749 | //determine the event id and set to array. |
1750 | 1750 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1751 | 1751 | // loop thru events |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | // clean status |
1754 | 1754 | $event_status = sanitize_key($event_status); |
1755 | 1755 | // grab status |
1756 | - if (!empty($event_status)) { |
|
1756 | + if ( ! empty($event_status)) { |
|
1757 | 1757 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1758 | 1758 | } else { |
1759 | 1759 | $success = FALSE; |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | } |
1768 | 1768 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1769 | 1769 | |
1770 | - if ( $redirect_after ) |
|
1770 | + if ($redirect_after) |
|
1771 | 1771 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1772 | 1772 | } |
1773 | 1773 | |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | // clean status |
1783 | 1783 | $event_status = sanitize_key($event_status); |
1784 | 1784 | // grab status |
1785 | - if (!empty($event_status)) { |
|
1785 | + if ( ! empty($event_status)) { |
|
1786 | 1786 | $success = TRUE; |
1787 | 1787 | //determine the event id and set to array. |
1788 | 1788 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1817,15 +1817,15 @@ discard block |
||
1817 | 1817 | * @param string $event_status |
1818 | 1818 | * @return bool |
1819 | 1819 | */ |
1820 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1820 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1821 | 1821 | // grab event id |
1822 | - if (!$EVT_ID) { |
|
1822 | + if ( ! $EVT_ID) { |
|
1823 | 1823 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1824 | 1824 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1825 | 1825 | return FALSE; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1828 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1829 | 1829 | |
1830 | 1830 | // clean status |
1831 | 1831 | $event_status = sanitize_key($event_status); |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | $hook = FALSE; |
1852 | 1852 | } |
1853 | 1853 | //use class to change status |
1854 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1854 | + $this->_cpt_model_obj->set_status($event_status); |
|
1855 | 1855 | $success = $this->_cpt_model_obj->save(); |
1856 | 1856 | |
1857 | 1857 | if ($success === FALSE) { |
@@ -1873,15 +1873,15 @@ discard block |
||
1873 | 1873 | * @access protected |
1874 | 1874 | * @param bool $redirect_after |
1875 | 1875 | */ |
1876 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1876 | + protected function _delete_event($redirect_after = TRUE) { |
|
1877 | 1877 | //determine the event id and set to array. |
1878 | 1878 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1879 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1879 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1880 | 1880 | |
1881 | 1881 | |
1882 | 1882 | // loop thru events |
1883 | 1883 | if ($EVT_ID) { |
1884 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1884 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1885 | 1885 | // get list of events with no prices |
1886 | 1886 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1887 | 1887 | // remove this event from the list of events with no prices |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1896 | 1896 | } |
1897 | 1897 | |
1898 | - if ( $redirect_after ) |
|
1898 | + if ($redirect_after) |
|
1899 | 1899 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1913,12 +1913,12 @@ discard block |
||
1913 | 1913 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1914 | 1914 | // loop thru events |
1915 | 1915 | foreach ($EVT_IDs as $EVT_ID) { |
1916 | - $EVT_ID = absint( $EVT_ID ); |
|
1917 | - if ( $EVT_ID ) { |
|
1918 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1916 | + $EVT_ID = absint($EVT_ID); |
|
1917 | + if ($EVT_ID) { |
|
1918 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1919 | 1919 | $success = $results !== FALSE ? $success : FALSE; |
1920 | 1920 | // remove this event from the list of events with no prices |
1921 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1921 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1922 | 1922 | } else { |
1923 | 1923 | $success = FALSE; |
1924 | 1924 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1938,21 +1938,21 @@ discard block |
||
1938 | 1938 | * @param int $EVT_ID |
1939 | 1939 | * @return bool |
1940 | 1940 | */ |
1941 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1941 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1942 | 1942 | // grab event id |
1943 | - if ( ! $EVT_ID ) { |
|
1943 | + if ( ! $EVT_ID) { |
|
1944 | 1944 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1945 | 1945 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1946 | 1946 | return FALSE; |
1947 | 1947 | } |
1948 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1948 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1949 | 1949 | |
1950 | 1950 | //need to delete related tickets and prices first. |
1951 | 1951 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1952 | - foreach ( $datetimes as $datetime ) { |
|
1952 | + foreach ($datetimes as $datetime) { |
|
1953 | 1953 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1954 | 1954 | $tickets = $datetime->get_many_related('Ticket'); |
1955 | - foreach ( $tickets as $ticket ) { |
|
1955 | + foreach ($tickets as $ticket) { |
|
1956 | 1956 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1957 | 1957 | $ticket->delete_related_permanently('Price'); |
1958 | 1958 | $ticket->delete_permanently(); |
@@ -1962,14 +1962,14 @@ discard block |
||
1962 | 1962 | |
1963 | 1963 | //what about related venues or terms? |
1964 | 1964 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1965 | - foreach ( $venues as $venue ) { |
|
1965 | + foreach ($venues as $venue) { |
|
1966 | 1966 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | //any attached question groups? |
1970 | 1970 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1971 | - if ( !empty( $question_groups ) ) { |
|
1972 | - foreach ( $question_groups as $question_group ) { |
|
1971 | + if ( ! empty($question_groups)) { |
|
1972 | + foreach ($question_groups as $question_group) { |
|
1973 | 1973 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1974 | 1974 | } |
1975 | 1975 | } |
@@ -1978,12 +1978,12 @@ discard block |
||
1978 | 1978 | |
1979 | 1979 | |
1980 | 1980 | //Message Template Groups |
1981 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1981 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1982 | 1982 | |
1983 | 1983 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1984 | 1984 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1985 | 1985 | |
1986 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1986 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1987 | 1987 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1988 | 1988 | } |
1989 | 1989 | |
@@ -1997,7 +1997,7 @@ discard block |
||
1997 | 1997 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1998 | 1998 | return FALSE; |
1999 | 1999 | } |
2000 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted' ); |
|
2000 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted'); |
|
2001 | 2001 | return TRUE; |
2002 | 2002 | } |
2003 | 2003 | |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | */ |
2015 | 2015 | public function total_events() { |
2016 | 2016 | |
2017 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2017 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2018 | 2018 | return $count; |
2019 | 2019 | } |
2020 | 2020 | |
@@ -2029,10 +2029,10 @@ discard block |
||
2029 | 2029 | */ |
2030 | 2030 | public function total_events_draft() { |
2031 | 2031 | $where = array( |
2032 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2032 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2033 | 2033 | ); |
2034 | 2034 | |
2035 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2035 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2036 | 2036 | return $count; |
2037 | 2037 | } |
2038 | 2038 | |
@@ -2051,7 +2051,7 @@ discard block |
||
2051 | 2051 | 'status' => 'trash' |
2052 | 2052 | ); |
2053 | 2053 | |
2054 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2054 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2055 | 2055 | return $count; |
2056 | 2056 | } |
2057 | 2057 | |
@@ -2079,11 +2079,11 @@ discard block |
||
2079 | 2079 | // translated |
2080 | 2080 | TRUE |
2081 | 2081 | ); |
2082 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2082 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2083 | 2083 | |
2084 | 2084 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2085 | 2085 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2086 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2086 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2087 | 2087 | $this->display_admin_page_with_sidebar(); |
2088 | 2088 | } |
2089 | 2089 | |
@@ -2109,9 +2109,9 @@ discard block |
||
2109 | 2109 | |
2110 | 2110 | protected function _template_settings() { |
2111 | 2111 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2112 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2113 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2114 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2112 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2113 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2114 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | |
@@ -2124,22 +2124,22 @@ discard block |
||
2124 | 2124 | * @return void |
2125 | 2125 | */ |
2126 | 2126 | private function _set_category_object() { |
2127 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2127 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2128 | 2128 | return; //already have the category object so get out. |
2129 | 2129 | |
2130 | 2130 | //set default category object |
2131 | 2131 | $this->_set_empty_category_object(); |
2132 | 2132 | |
2133 | 2133 | //only set if we've got an id |
2134 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2134 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2135 | 2135 | return; |
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2139 | 2139 | |
2140 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2140 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2141 | 2141 | |
2142 | - if ( !empty( $term ) ) { |
|
2142 | + if ( ! empty($term)) { |
|
2143 | 2143 | $this->_category->category_name = $term->name; |
2144 | 2144 | $this->_category->category_identifier = $term->slug; |
2145 | 2145 | $this->_category->category_desc = $term->description; |
@@ -2153,13 +2153,13 @@ discard block |
||
2153 | 2153 | |
2154 | 2154 | private function _set_empty_category_object() { |
2155 | 2155 | $this->_category = new stdClass(); |
2156 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2156 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2157 | 2157 | $this->_category->id = $this->_category->parent = 0; |
2158 | 2158 | } |
2159 | 2159 | |
2160 | 2160 | |
2161 | 2161 | protected function _category_list_table() { |
2162 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2162 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2163 | 2163 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2164 | 2164 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2165 | 2165 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2169,22 +2169,22 @@ discard block |
||
2169 | 2169 | protected function _category_details($view) { |
2170 | 2170 | |
2171 | 2171 | //load formatter helper |
2172 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2172 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2173 | 2173 | //load field generator helper |
2174 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2174 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2175 | 2175 | |
2176 | 2176 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2177 | 2177 | $this->_set_add_edit_form_tags($route); |
2178 | 2178 | |
2179 | 2179 | $this->_set_category_object(); |
2180 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2180 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2181 | 2181 | |
2182 | 2182 | $delete_action = 'delete_category'; |
2183 | 2183 | |
2184 | 2184 | //custom redirect |
2185 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2185 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2186 | 2186 | |
2187 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2187 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2188 | 2188 | |
2189 | 2189 | //take care of contents |
2190 | 2190 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2198,25 +2198,25 @@ discard block |
||
2198 | 2198 | 'type' => 'wp_editor', |
2199 | 2199 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2200 | 2200 | 'class' => 'my_editor_custom', |
2201 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2201 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2202 | 2202 | ); |
2203 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2203 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2204 | 2204 | |
2205 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2205 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2206 | 2206 | |
2207 | 2207 | //setup category select for term parents. |
2208 | 2208 | $category_select_values[] = array( |
2209 | 2209 | 'text' => __('No Parent', 'event_espresso'), |
2210 | 2210 | 'id' => 0 |
2211 | 2211 | ); |
2212 | - foreach ( $all_terms as $term ) { |
|
2212 | + foreach ($all_terms as $term) { |
|
2213 | 2213 | $category_select_values[] = array( |
2214 | 2214 | 'text' => $term->name, |
2215 | 2215 | 'id' => $term->term_id |
2216 | 2216 | ); |
2217 | 2217 | } |
2218 | 2218 | |
2219 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2219 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2220 | 2220 | |
2221 | 2221 | $template_args = array( |
2222 | 2222 | 'category' => $this->_category, |
@@ -2226,15 +2226,15 @@ discard block |
||
2226 | 2226 | 'disable' => '', |
2227 | 2227 | 'disabled_message' => FALSE |
2228 | 2228 | ); |
2229 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2230 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2229 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2230 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | |
2234 | 2234 | protected function _delete_categories() { |
2235 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2235 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2236 | 2236 | |
2237 | - foreach ( $cat_ids as $cat_id ) { |
|
2237 | + foreach ($cat_ids as $cat_id) { |
|
2238 | 2238 | $this->_delete_category($cat_id); |
2239 | 2239 | } |
2240 | 2240 | |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | $query_args = array( |
2243 | 2243 | 'action' => 'category_list' |
2244 | 2244 | ); |
2245 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2245 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2246 | 2246 | |
2247 | 2247 | } |
2248 | 2248 | |
@@ -2252,61 +2252,61 @@ discard block |
||
2252 | 2252 | |
2253 | 2253 | protected function _delete_category($cat_id) { |
2254 | 2254 | global $wpdb; |
2255 | - $cat_id = absint( $cat_id ); |
|
2256 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2255 | + $cat_id = absint($cat_id); |
|
2256 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2257 | 2257 | } |
2258 | 2258 | |
2259 | 2259 | |
2260 | 2260 | |
2261 | 2261 | protected function _insert_or_update_category($new_category) { |
2262 | 2262 | |
2263 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2263 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2264 | 2264 | $success = 0; //we already have a success message so lets not send another. |
2265 | 2265 | |
2266 | - if ( $cat_id ) { |
|
2266 | + if ($cat_id) { |
|
2267 | 2267 | $query_args = array( |
2268 | 2268 | 'action' => 'edit_category', |
2269 | 2269 | 'EVT_CAT_ID' => $cat_id |
2270 | 2270 | ); |
2271 | 2271 | } else { |
2272 | - $query_args = array( 'action' => 'add_category' ); |
|
2272 | + $query_args = array('action' => 'add_category'); |
|
2273 | 2273 | } |
2274 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2274 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2275 | 2275 | |
2276 | 2276 | } |
2277 | 2277 | |
2278 | 2278 | |
2279 | 2279 | |
2280 | - private function _insert_category( $update = FALSE ) { |
|
2280 | + private function _insert_category($update = FALSE) { |
|
2281 | 2281 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2282 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2283 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2284 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2282 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2283 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2284 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2285 | 2285 | |
2286 | - if ( empty( $category_name ) ) { |
|
2287 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2288 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2286 | + if (empty($category_name)) { |
|
2287 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2288 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2289 | 2289 | return false; |
2290 | 2290 | } |
2291 | 2291 | |
2292 | - $term_args=array( |
|
2292 | + $term_args = array( |
|
2293 | 2293 | 'name'=>$category_name, |
2294 | 2294 | 'description'=>$category_desc, |
2295 | 2295 | 'parent'=>$category_parent |
2296 | 2296 | ); |
2297 | 2297 | //was the category_identifier input disabled? |
2298 | - if(isset($this->_req_data['category_identifier'])){ |
|
2298 | + if (isset($this->_req_data['category_identifier'])) { |
|
2299 | 2299 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2300 | 2300 | } |
2301 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2301 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2302 | 2302 | |
2303 | - if ( !is_array( $insert_ids ) ) { |
|
2304 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2305 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2303 | + if ( ! is_array($insert_ids)) { |
|
2304 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2305 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2306 | 2306 | } else { |
2307 | 2307 | $cat_id = $insert_ids['term_id']; |
2308 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2309 | - EE_Error::add_success( $msg ); |
|
2308 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2309 | + EE_Error::add_success($msg); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | return $cat_id; |
@@ -2315,32 +2315,32 @@ discard block |
||
2315 | 2315 | |
2316 | 2316 | |
2317 | 2317 | |
2318 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2318 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2319 | 2319 | global $wpdb; |
2320 | 2320 | |
2321 | 2321 | //testing term stuff |
2322 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2323 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2324 | - $limit = ($current_page-1)*$per_page; |
|
2322 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2323 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2324 | + $limit = ($current_page - 1) * $per_page; |
|
2325 | 2325 | |
2326 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2326 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2327 | 2327 | |
2328 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2329 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2328 | + if (isset($this->_req_data['s'])) { |
|
2329 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2330 | 2330 | $where['OR'] = array( |
2331 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2332 | - 'description' => array( 'LIKE', $sstr ) |
|
2331 | + 'Term.name' => array('LIKE', $sstr), |
|
2332 | + 'description' => array('LIKE', $sstr) |
|
2333 | 2333 | ); |
2334 | 2334 | } |
2335 | 2335 | |
2336 | 2336 | $query_params = array( |
2337 | - $where , |
|
2338 | - 'order_by' => array( $orderby => $order ), |
|
2339 | - 'limit' => $limit . ',' . $per_page, |
|
2337 | + $where, |
|
2338 | + 'order_by' => array($orderby => $order), |
|
2339 | + 'limit' => $limit.','.$per_page, |
|
2340 | 2340 | 'force_join' => array('Term') |
2341 | 2341 | ); |
2342 | 2342 | |
2343 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2343 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2344 | 2344 | |
2345 | 2345 | return $categories; |
2346 | 2346 | } |