@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param string $min_core_version |
67 | 67 | * @return string always like '4.3.0.rc.000' |
68 | 68 | */ |
69 | - protected static function _effective_version( $min_core_version ) { |
|
69 | + protected static function _effective_version($min_core_version) { |
|
70 | 70 | // versions: 4 . 3 . 1 . p . 123 |
71 | 71 | // offsets: 0 . 1 . 2 . 3 . 4 |
72 | - $version_parts = explode( '.', $min_core_version ); |
|
72 | + $version_parts = explode('.', $min_core_version); |
|
73 | 73 | //check they specified the micro version (after 2nd period) |
74 | - if( ! isset( $version_parts[ 2 ] ) ) { |
|
75 | - $version_parts[ 2] = '0'; |
|
74 | + if ( ! isset($version_parts[2])) { |
|
75 | + $version_parts[2] = '0'; |
|
76 | 76 | } |
77 | 77 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
78 | 78 | //soon we can assume that's 'rc', but this current version is 'alpha' |
79 | - if( ! isset( $version_parts[ 3 ] ) ) { |
|
80 | - $version_parts[ 3 ] = 'dev'; |
|
79 | + if ( ! isset($version_parts[3])) { |
|
80 | + $version_parts[3] = 'dev'; |
|
81 | 81 | } |
82 | - if( ! isset( $version_parts[ 4 ] ) ) { |
|
83 | - $version_parts[ 4 ] = '000'; |
|
82 | + if ( ! isset($version_parts[4])) { |
|
83 | + $version_parts[4] = '000'; |
|
84 | 84 | } |
85 | - return implode( '.', $version_parts ); |
|
85 | + return implode('.', $version_parts); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @param string $actual_core_version the actual core version, optional |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - public static function _meets_min_core_version_requirement( $min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION ) { |
|
96 | - return version_compare( self::_effective_version( $actual_core_version ), self::_effective_version( $min_core_version ), '>=' ); |
|
95 | + public static function _meets_min_core_version_requirement($min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION) { |
|
96 | + return version_compare(self::_effective_version($actual_core_version), self::_effective_version($min_core_version), '>='); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -155,112 +155,112 @@ discard block |
||
155 | 155 | * @throws EE_Error |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public static function register( $addon_name = '', $setup_args = array() ) { |
|
158 | + public static function register($addon_name = '', $setup_args = array()) { |
|
159 | 159 | // required fields MUST be present, so let's make sure they are. |
160 | - if ( empty( $addon_name ) || ! is_array( $setup_args )) { |
|
161 | - throw new EE_Error( __( 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso' )); |
|
160 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
161 | + throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso')); |
|
162 | 162 | } |
163 | - if ( ! isset($setup_args[ 'main_file_path' ]) || empty( $setup_args[ 'main_file_path' ] ) ){ |
|
164 | - throw new EE_Error( sprintf( __( 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso' ), implode(",", array_keys( $setup_args ) ) ) ); |
|
163 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
164 | + throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args)))); |
|
165 | 165 | } |
166 | 166 | // check that addon has not already been registered with that name |
167 | - if ( isset( self::$_settings[ $addon_name ] ) && ! did_action( 'activate_plugin' ) ) { |
|
168 | - throw new EE_Error( sprintf( __( 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso' ), $addon_name )); |
|
167 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
168 | + throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | // no class name for addon? |
173 | - if ( empty( $setup_args['class_name'] )) { |
|
173 | + if (empty($setup_args['class_name'])) { |
|
174 | 174 | // generate one by first separating name with spaces |
175 | - $class_name = str_replace( array( '-', '_' ), ' ', trim( $addon_name )); |
|
175 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
176 | 176 | //capitalize, then replace spaces with underscores |
177 | - $class_name = str_replace( ' ', '_', ucwords( $class_name )); |
|
177 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
178 | 178 | } else { |
179 | 179 | $class_name = $setup_args['class_name']; |
180 | 180 | } |
181 | - $class_name = strpos( $class_name, 'EE_' ) === 0 ? $class_name : 'EE_' . $class_name; |
|
181 | + $class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
182 | 182 | //setup $_settings array from incoming values. |
183 | 183 | $addon_settings = array( |
184 | 184 | // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
185 | 185 | 'class_name' => $class_name, |
186 | 186 | // the addon slug for use in URLs, etc |
187 | - 'plugin_slug' => isset( $setup_args['plugin_slug'] ) ? (string)$setup_args['plugin_slug'] : '', |
|
187 | + 'plugin_slug' => isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '', |
|
188 | 188 | // page slug to be used when generating the "Settings" link on the WP plugin page |
189 | - 'plugin_action_slug' => isset( $setup_args[ 'plugin_action_slug' ] ) ? (string)$setup_args[ 'plugin_action_slug' ] : '', |
|
189 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '', |
|
190 | 190 | // the "software" version for the addon |
191 | - 'version' => isset( $setup_args['version'] ) ? (string)$setup_args['version'] : '', |
|
191 | + 'version' => isset($setup_args['version']) ? (string) $setup_args['version'] : '', |
|
192 | 192 | // the minimum version of EE Core that the addon will work with |
193 | - 'min_core_version' => isset( $setup_args['min_core_version'] ) ? (string)$setup_args['min_core_version'] : '', |
|
193 | + 'min_core_version' => isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '', |
|
194 | 194 | // the minimum version of WordPress that the addon will work with |
195 | - 'min_wp_version' => isset( $setup_args['min_wp_version'] ) ? (string)$setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
195 | + 'min_wp_version' => isset($setup_args['min_wp_version']) ? (string) $setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
196 | 196 | // full server path to main file (file loaded directly by WP) |
197 | - 'main_file_path' => isset( $setup_args['main_file_path'] ) ? (string)$setup_args['main_file_path'] : '', |
|
197 | + 'main_file_path' => isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '', |
|
198 | 198 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
199 | - 'admin_path' => isset( $setup_args['admin_path'] ) ? (string)$setup_args['admin_path'] : '', |
|
199 | + 'admin_path' => isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '', |
|
200 | 200 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
201 | - 'admin_callback' => isset( $setup_args['admin_callback'] ) ? (string)$setup_args['admin_callback'] : '', |
|
201 | + 'admin_callback' => isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '', |
|
202 | 202 | // the section name for this addon's configuration settings section (defaults to "addons") |
203 | - 'config_section' => isset( $setup_args['config_section'] ) ? (string)$setup_args['config_section'] : 'addons', |
|
203 | + 'config_section' => isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons', |
|
204 | 204 | // the class name for this addon's configuration settings object |
205 | - 'config_class' => isset( $setup_args['config_class'] ) ? (string)$setup_args['config_class'] : '', |
|
205 | + 'config_class' => isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '', |
|
206 | 206 | //the name given to the config for this addons' configuration settings object (optional) |
207 | - 'config_name' => isset( $setup_args['config_name'] ) ? (string) $setup_args['config_name']: '', |
|
207 | + 'config_name' => isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '', |
|
208 | 208 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
209 | - 'autoloader_paths' => isset( $setup_args['autoloader_paths'] ) ? (array)$setup_args['autoloader_paths'] : array(), |
|
209 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(), |
|
210 | 210 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
211 | - 'autoloader_folders' => isset( $setup_args['autoloader_folders'] ) ? (array)$setup_args['autoloader_folders'] : array(), |
|
211 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(), |
|
212 | 212 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
213 | - 'dms_paths' => isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array(), |
|
213 | + 'dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(), |
|
214 | 214 | // array of full server paths to any EED_Modules used by the addon |
215 | - 'module_paths' => isset( $setup_args['module_paths'] ) ? (array)$setup_args['module_paths'] : array(), |
|
215 | + 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
|
216 | 216 | // array of full server paths to any EES_Shortcodes used by the addon |
217 | - 'shortcode_paths' => isset( $setup_args['shortcode_paths'] ) ? (array)$setup_args['shortcode_paths'] : array(), |
|
217 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(), |
|
218 | 218 | // array of full server paths to any WP_Widgets used by the addon |
219 | - 'widget_paths' => isset( $setup_args['widget_paths'] ) ? (array)$setup_args['widget_paths'] : array(), |
|
219 | + 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
|
220 | 220 | // array of PUE options used by the addon |
221 | - 'pue_options' => isset( $setup_args['pue_options'] ) ? (array)$setup_args['pue_options'] : array(), |
|
222 | - 'message_types' => isset( $setup_args['message_types'] ) ? (array) $setup_args['message_types'] : array(), |
|
223 | - 'capabilities' => isset( $setup_args['capabilities'] ) ? (array) $setup_args['capabilities'] : array(), |
|
224 | - 'capability_maps' => isset( $setup_args['capability_maps'] ) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | - 'model_paths' => isset( $setup_args['model_paths'] ) ? (array) $setup_args['model_paths'] : array(), |
|
226 | - 'class_paths' => isset( $setup_args['class_paths'] ) ? (array) $setup_args['class_paths'] : array(), |
|
227 | - 'model_extension_paths' => isset( $setup_args['model_extension_paths'] ) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | - 'class_extension_paths' => isset( $setup_args['class_extension_paths'] ) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | - 'custom_post_types' => isset( $setup_args['custom_post_types'] ) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | - 'custom_taxonomies' => isset( $setup_args['custom_taxonomies'] ) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | - 'payment_method_paths' => isset( $setup_args[ 'payment_method_paths' ] ) ? (array) $setup_args[ 'payment_method_paths' ] : array(), |
|
232 | - 'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array(), |
|
221 | + 'pue_options' => isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(), |
|
222 | + 'message_types' => isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(), |
|
223 | + 'capabilities' => isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(), |
|
224 | + 'capability_maps' => isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | + 'model_paths' => isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(), |
|
226 | + 'class_paths' => isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(), |
|
227 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | + 'custom_post_types' => isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(), |
|
232 | + 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(), |
|
233 | 233 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page that can be used for adding upgrading/marketing info |
234 | - 'plugins_page_row' => isset( $setup_args['plugins_page_row'] ) ? $setup_args['plugins_page_row'] : '', |
|
234 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '', |
|
235 | 235 | ); |
236 | 236 | |
237 | 237 | // if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page |
238 | - $addon_settings[ 'plugin_action_slug' ] = empty( $addon_settings[ 'plugin_action_slug' ] ) && ! empty( $addon_settings[ 'admin_path' ] ) ? $addon_settings[ 'plugin_slug' ] : $addon_settings[ 'plugin_action_slug' ]; |
|
238 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && ! empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug']; |
|
239 | 239 | // full server path to main file (file loaded directly by WP) |
240 | - $addon_settings['plugin_basename'] = plugin_basename( $addon_settings[ 'main_file_path' ] ); |
|
240 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
241 | 241 | |
242 | 242 | global $wp_version; |
243 | 243 | //check whether this addon version is compatible with EE core |
244 | - if ( isset( EE_Register_Addon::$_incompatible_addons[ $addon_name ] ) && |
|
245 | - ! self::_meets_min_core_version_requirement( EE_Register_Addon::$_incompatible_addons[ $addon_name ], $addon_settings[ 'version' ] ) ) { |
|
244 | + if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) && |
|
245 | + ! self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) { |
|
246 | 246 | $incompatibility_message = sprintf( |
247 | - __( 'The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso' ), |
|
247 | + __('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'), |
|
248 | 248 | $addon_name, |
249 | 249 | '<br />', |
250 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ] |
|
250 | + EE_Register_Addon::$_incompatible_addons[$addon_name] |
|
251 | 251 | ); |
252 | - } else if ( ! self::_meets_min_core_version_requirement( $addon_settings[ 'min_core_version' ], espresso_version() ) ) { |
|
252 | + } else if ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())) { |
|
253 | 253 | $incompatibility_message = sprintf( |
254 | 254 | __( |
255 | 255 | 'The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', |
256 | 256 | 'event_espresso' |
257 | 257 | ), |
258 | 258 | $addon_name, |
259 | - self::_effective_version( $addon_settings[ 'min_core_version' ] ), |
|
260 | - self::_effective_version( espresso_version() ), |
|
259 | + self::_effective_version($addon_settings['min_core_version']), |
|
260 | + self::_effective_version(espresso_version()), |
|
261 | 261 | '<br />' |
262 | 262 | ); |
263 | - } else if (version_compare( $wp_version, $addon_settings['min_wp_version'], '<' )) { |
|
263 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
264 | 264 | $incompatibility_message = sprintf( |
265 | 265 | __( |
266 | 266 | 'The Event Espresso "%1$s" addon could not be activated because it requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
@@ -269,137 +269,137 @@ discard block |
||
269 | 269 | $addon_name, |
270 | 270 | $addon_settings['min_wp_version'], |
271 | 271 | '<br />' |
272 | - );; |
|
272 | + ); ; |
|
273 | 273 | } else { |
274 | 274 | $incompatibility_message = ''; |
275 | 275 | } |
276 | - if ( ! empty( $incompatibility_message ) ) { |
|
276 | + if ( ! empty($incompatibility_message)) { |
|
277 | 277 | //remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the |
278 | 278 | //plugin activated fine when it didn't |
279 | - if( isset( $_GET[ 'activate' ]) ) { |
|
280 | - unset( $_GET[ 'activate' ] ); |
|
279 | + if (isset($_GET['activate'])) { |
|
280 | + unset($_GET['activate']); |
|
281 | 281 | } |
282 | - if( isset( $_REQUEST[ 'activate' ] ) ){ |
|
283 | - unset( $_REQUEST[ 'activate' ] ); |
|
282 | + if (isset($_REQUEST['activate'])) { |
|
283 | + unset($_REQUEST['activate']); |
|
284 | 284 | } |
285 | 285 | //and show an error message indicating the plugin didn't activate properly |
286 | - EE_Error::add_error( $incompatibility_message, __FILE__, __FUNCTION__, __LINE__ ); |
|
287 | - if ( current_user_can( 'activate_plugins' )) { |
|
288 | - require_once( ABSPATH.'wp-admin/includes/plugin.php' ); |
|
289 | - deactivate_plugins( plugin_basename( $addon_settings[ 'main_file_path' ] ), TRUE ); |
|
286 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
287 | + if (current_user_can('activate_plugins')) { |
|
288 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
289 | + deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE); |
|
290 | 290 | } |
291 | 291 | return; |
292 | 292 | } |
293 | 293 | //this is an activation request |
294 | - if( did_action( 'activate_plugin' ) ){ |
|
294 | + if (did_action('activate_plugin')) { |
|
295 | 295 | //to find if THIS is the addon that was activated, |
296 | 296 | //just check if we have already registered it or not |
297 | 297 | //(as the newly-activated addon wasn't around the first time addons were registered) |
298 | - if( ! isset( self::$_settings[ $addon_name ] ) ){ |
|
299 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
298 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
299 | + self::$_settings[$addon_name] = $addon_settings; |
|
300 | 300 | $addon = self::_load_and_init_addon_class($addon_name); |
301 | 301 | $addon->set_activation_indicator_option(); |
302 | 302 | //dont bother setting up the rest of the addon. |
303 | 303 | //we know it was just activated and the request will end soon |
304 | 304 | } |
305 | 305 | return; |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | // make sure this was called in the right place! |
308 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) { |
|
308 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
309 | 309 | EE_Error::doing_it_wrong( |
310 | 310 | __METHOD__, |
311 | 311 | sprintf( |
312 | - __( 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.','event_espresso'), |
|
312 | + __('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'), |
|
313 | 313 | $addon_name |
314 | 314 | ), |
315 | 315 | '4.3.0' |
316 | 316 | ); |
317 | 317 | } |
318 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
318 | + self::$_settings[$addon_name] = $addon_settings; |
|
319 | 319 | } |
320 | 320 | // we need cars |
321 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_paths'] )) { |
|
321 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
322 | 322 | // setup autoloader for single file |
323 | - EEH_Autoloader::instance()->register_autoloader( self::$_settings[ $addon_name ]['autoloader_paths'] ); |
|
323 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
324 | 324 | } |
325 | 325 | // setup autoloaders for folders |
326 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_folders'] )) { |
|
327 | - foreach ( self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder ) { |
|
328 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $autoloader_folder ); |
|
326 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
327 | + foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
328 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | // register new models |
332 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
333 | - EE_Register_Model::register( $addon_name, array( 'model_paths' => self::$_settings[ $addon_name ]['model_paths'] , 'class_paths' => self::$_settings[ $addon_name ]['class_paths'])); |
|
332 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
333 | + EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths'])); |
|
334 | 334 | } |
335 | 335 | // register model extensions |
336 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
337 | - EE_Register_Model_Extensions::register( $addon_name, array( 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'] , 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'])); |
|
336 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
337 | + EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'])); |
|
338 | 338 | } |
339 | 339 | // setup DMS |
340 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
341 | - EE_Register_Data_Migration_Scripts::register( $addon_name, array( 'dms_paths' => self::$_settings[ $addon_name ]['dms_paths'] )); |
|
340 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
341 | + EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])); |
|
342 | 342 | } |
343 | 343 | // if config_class is present let's register config. |
344 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
344 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
345 | 345 | EE_Register_Config::register( |
346 | - self::$_settings[ $addon_name ]['config_class'], |
|
346 | + self::$_settings[$addon_name]['config_class'], |
|
347 | 347 | array( |
348 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
349 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'] |
|
348 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
349 | + 'config_name' => self::$_settings[$addon_name]['config_name'] |
|
350 | 350 | ) |
351 | 351 | ); |
352 | 352 | } |
353 | 353 | // register admin page |
354 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
355 | - EE_Register_Admin_Page::register( $addon_name, array( 'page_path' => self::$_settings[ $addon_name ]['admin_path'] )); |
|
354 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
355 | + EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path'])); |
|
356 | 356 | |
357 | 357 | } |
358 | 358 | // add to list of modules to be registered |
359 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
360 | - EE_Register_Module::register( $addon_name, array( 'module_paths' => self::$_settings[ $addon_name ]['module_paths'] )); |
|
359 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
360 | + EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths'])); |
|
361 | 361 | } |
362 | 362 | // add to list of shortcodes to be registered |
363 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
364 | - EE_Register_Shortcode::register( $addon_name, array( 'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] )); |
|
363 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
364 | + EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])); |
|
365 | 365 | } |
366 | 366 | // add to list of widgets to be registered |
367 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
368 | - EE_Register_Widget::register( $addon_name, array( 'widget_paths' => self::$_settings[ $addon_name ]['widget_paths'] )); |
|
367 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
368 | + EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | //register capability related stuff. |
372 | - if ( ! empty( self::$_settings[ $addon_name ]['capabilities'] ) ) { |
|
373 | - EE_Register_Capabilities::register( $addon_name , array( 'capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'] ) ); |
|
372 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
373 | + EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'])); |
|
374 | 374 | } |
375 | 375 | //any message type to register? |
376 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
377 | - add_action( 'EE_Brewing_Regular___messages_caf', array( 'EE_Register_Addon', 'register_message_types' ) ); |
|
376 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
377 | + add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types')); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // if plugin update engine is being used for auto-updates (not needed if PUE is not being used) |
381 | - if ( ! empty( $setup_args['pue_options'] )) { |
|
382 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
383 | - 'pue_plugin_slug' => isset( $setup_args['pue_options']['pue_plugin_slug'] ) ? (string)$setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower( $class_name ), |
|
384 | - 'plugin_basename' => isset( $setup_args['pue_options']['plugin_basename'] ) ? (string)$setup_args['pue_options']['plugin_basename'] : plugin_basename( self::$_settings[ $addon_name ]['main_file_path'] ), |
|
385 | - 'checkPeriod' => isset( $setup_args['pue_options']['checkPeriod'] ) ? (string)$setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | - 'use_wp_update' => isset( $setup_args['pue_options']['use_wp_update'] ) ? (string)$setup_args['pue_options']['use_wp_update'] : FALSE |
|
381 | + if ( ! empty($setup_args['pue_options'])) { |
|
382 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
383 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_'.strtolower($class_name), |
|
384 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']), |
|
385 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE |
|
387 | 387 | ); |
388 | - add_action( 'AHEE__EE_System__brew_espresso__after_pue_init', array( 'EE_Register_Addon', 'load_pue_update' )); |
|
388 | + add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update')); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | //any custom post type/ custom capabilities or default terms to register |
392 | - if ( !empty( self::$_settings[$addon_name]['custom_post_types'] ) || !empty( self::$_settings[$addon_name]['custom_taxonomies'] ) ) { |
|
393 | - EE_Register_CPT::register( $addon_name, array( 'cpts' => self::$_settings[$addon_name]['custom_post_types'] , 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'] ) ); |
|
392 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])) { |
|
393 | + EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'])); |
|
394 | 394 | } |
395 | - if( ! empty( self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ){ |
|
396 | - EE_Register_Payment_Method::register($addon_name, array( 'payment_method_paths' => self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ); |
|
395 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
396 | + EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])); |
|
397 | 397 | } |
398 | 398 | // load and instantiate main addon class |
399 | 399 | $addon = self::_load_and_init_addon_class($addon_name); |
400 | 400 | // call any additional admin_callback functions during load_admin_controller hook |
401 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_callback'] )) { |
|
402 | - add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $addon, self::$_settings[ $addon_name ]['admin_callback'] )); |
|
401 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
402 | + add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback'])); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | * @param string $addon_name |
411 | 411 | * @return EE_Addon |
412 | 412 | */ |
413 | - private static function _load_and_init_addon_class($addon_name){ |
|
414 | - $addon = EE_Registry::instance()->load_addon( dirname( self::$_settings[ $addon_name ]['main_file_path'] ), self::$_settings[ $addon_name ]['class_name'] ); |
|
415 | - $addon->set_name( $addon_name ); |
|
416 | - $addon->set_plugin_slug( self::$_settings[ $addon_name ][ 'plugin_slug' ] ); |
|
417 | - $addon->set_plugin_basename( self::$_settings[ $addon_name ][ 'plugin_basename' ] ); |
|
418 | - $addon->set_main_plugin_file( self::$_settings[ $addon_name ]['main_file_path'] ); |
|
419 | - $addon->set_plugin_action_slug( self::$_settings[ $addon_name ][ 'plugin_action_slug' ] ); |
|
420 | - $addon->set_plugins_page_row( self::$_settings[ $addon_name ][ 'plugins_page_row' ] ); |
|
421 | - $addon->set_version( self::$_settings[ $addon_name ]['version'] ); |
|
422 | - $addon->set_min_core_version( self::_effective_version( self::$_settings[ $addon_name ]['min_core_version'] ) ); |
|
423 | - $addon->set_config_section( self::$_settings[ $addon_name ]['config_section'] ); |
|
424 | - $addon->set_config_class( self::$_settings[ $addon_name ]['config_class'] ); |
|
425 | - $addon->set_config_name( self::$_settings[ $addon_name ]['config_name'] ); |
|
413 | + private static function _load_and_init_addon_class($addon_name) { |
|
414 | + $addon = EE_Registry::instance()->load_addon(dirname(self::$_settings[$addon_name]['main_file_path']), self::$_settings[$addon_name]['class_name']); |
|
415 | + $addon->set_name($addon_name); |
|
416 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
417 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
418 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
419 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
420 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
421 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
422 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
423 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
424 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
425 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
426 | 426 | //unfortunately this can't be hooked in upon construction, because we don't have |
427 | 427 | //the plugin mainfile's path upon construction. |
428 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon,'deactivation')); |
|
428 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
429 | 429 | return $addon; |
430 | 430 | } |
431 | 431 | |
@@ -438,18 +438,18 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public static function load_pue_update() { |
440 | 440 | // load PUE client |
441 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
441 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
442 | 442 | // cycle thru settings |
443 | - foreach ( self::$_settings as $settings ) { |
|
444 | - if ( ! empty( $settings['pue_options'] )) { |
|
443 | + foreach (self::$_settings as $settings) { |
|
444 | + if ( ! empty($settings['pue_options'])) { |
|
445 | 445 | // initiate the class and start the plugin update engine! |
446 | 446 | new PluginUpdateEngineChecker( |
447 | 447 | // host file URL |
448 | 448 | 'https://eventespresso.com', |
449 | 449 | // plugin slug(s) |
450 | 450 | array( |
451 | - 'premium' => array( 'p' => $settings['pue_options']['pue_plugin_slug'] ), |
|
452 | - 'prerelease' => array( 'beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr' ) |
|
451 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
452 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr') |
|
453 | 453 | ), |
454 | 454 | // options |
455 | 455 | array( |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * @return void |
478 | 478 | */ |
479 | 479 | public static function register_message_types() { |
480 | - foreach ( self::$_settings as $settings ) { |
|
481 | - foreach( $settings['message_types'] as $message_type => $message_type_settings ) { |
|
482 | - EE_Register_Message_Type::register( $message_type, $message_type_settings ); |
|
480 | + foreach (self::$_settings as $settings) { |
|
481 | + foreach ($settings['message_types'] as $message_type => $message_type_settings) { |
|
482 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
@@ -495,60 +495,60 @@ discard block |
||
495 | 495 | * @throws EE_Error |
496 | 496 | * @return void |
497 | 497 | */ |
498 | - public static function deregister( $addon_name = NULL ) { |
|
499 | - if ( isset( self::$_settings[ $addon_name ] )) { |
|
500 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
501 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
498 | + public static function deregister($addon_name = NULL) { |
|
499 | + if (isset(self::$_settings[$addon_name])) { |
|
500 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
501 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
502 | 502 | // setup DMS |
503 | - EE_Register_Data_Migration_Scripts::deregister( $addon_name ); |
|
503 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
504 | 504 | } |
505 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
505 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
506 | 506 | // register admin page |
507 | - EE_Register_Admin_Page::deregister( $addon_name ); |
|
507 | + EE_Register_Admin_Page::deregister($addon_name); |
|
508 | 508 | } |
509 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
509 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
510 | 510 | // add to list of modules to be registered |
511 | - EE_Register_Module::deregister( $addon_name ); |
|
511 | + EE_Register_Module::deregister($addon_name); |
|
512 | 512 | } |
513 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
513 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
514 | 514 | // add to list of shortcodes to be registered |
515 | - EE_Register_Shortcode::deregister( $addon_name ); |
|
515 | + EE_Register_Shortcode::deregister($addon_name); |
|
516 | 516 | } |
517 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
517 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
518 | 518 | // if config_class present let's register config. |
519 | - EE_Register_Config::deregister( self::$_settings[ $addon_name ]['config_class']); |
|
519 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
520 | 520 | } |
521 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
521 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
522 | 522 | // add to list of widgets to be registered |
523 | - EE_Register_Widget::deregister( $addon_name ); |
|
523 | + EE_Register_Widget::deregister($addon_name); |
|
524 | 524 | } |
525 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || |
|
526 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
525 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || |
|
526 | + ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
527 | 527 | // add to list of shortcodes to be registered |
528 | - EE_Register_Model::deregister( $addon_name ); |
|
528 | + EE_Register_Model::deregister($addon_name); |
|
529 | 529 | } |
530 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || |
|
531 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
530 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || |
|
531 | + ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
532 | 532 | // add to list of shortcodes to be registered |
533 | - EE_Register_Model_Extensions::deregister( $addon_name ); |
|
533 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
534 | 534 | } |
535 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
536 | - foreach( self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings ) { |
|
537 | - EE_Register_Message_Type::deregister( $message_type ); |
|
535 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
536 | + foreach (self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
537 | + EE_Register_Message_Type::deregister($message_type); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | //deregister capabilities for addon |
541 | - if ( ! empty( self::$_settings[$addon_name]['capabilities'] ) || ! empty( self::$_settings[$addon_name]['capability_maps']) ) { |
|
542 | - EE_Register_Capabilities::deregister( $addon_name ); |
|
541 | + if ( ! empty(self::$_settings[$addon_name]['capabilities']) || ! empty(self::$_settings[$addon_name]['capability_maps'])) { |
|
542 | + EE_Register_Capabilities::deregister($addon_name); |
|
543 | 543 | } |
544 | 544 | //deregister custom_post_types for addon |
545 | - if ( ! empty( self::$_settings[$addon_name]['custom_post_types'] ) ) { |
|
546 | - EE_Register_CPT::deregister( $addon_name ); |
|
545 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
546 | + EE_Register_CPT::deregister($addon_name); |
|
547 | 547 | } |
548 | - remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array( EE_Registry::instance()->addons->{$class_name}, 'deactivation' ) ); |
|
549 | - remove_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required' ) ); |
|
548 | + remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')); |
|
549 | + remove_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')); |
|
550 | 550 | unset(EE_Registry::instance()->addons->{$class_name}); |
551 | - unset( self::$_settings[ $addon_name ] ); |
|
551 | + unset(self::$_settings[$addon_name]); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param \Transactions_Admin_Page $admin_page |
33 | 33 | */ |
34 | - public function __construct( \Transactions_Admin_Page $admin_page ){ |
|
35 | - parent::__construct( $admin_page ); |
|
34 | + public function __construct(\Transactions_Admin_Page $admin_page) { |
|
35 | + parent::__construct($admin_page); |
|
36 | 36 | $this->_status = $this->_admin_page->get_transaction_status_array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | *_setup_data |
43 | 43 | */ |
44 | 44 | protected function _setup_data() { |
45 | - $this->_data = $this->_admin_page->get_transactions( $this->_per_page ); |
|
46 | - $status = ! empty( $this->_req_data['status'] )? $this->_req_data['status'] : 'all'; |
|
47 | - $this->_all_data_count = $this->_admin_page->get_transactions( $this->_per_page, TRUE, $status ); |
|
45 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
46 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
47 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, TRUE, $status); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | 'ajax' => TRUE, |
60 | 60 | 'screen' => $this->_admin_page->get_current_screen()->id |
61 | 61 | ); |
62 | - $ID_column_name = __( 'ID', 'event_espresso' ); |
|
62 | + $ID_column_name = __('ID', 'event_espresso'); |
|
63 | 63 | $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
64 | - $ID_column_name .= __( 'Transaction Date', 'event_espresso' ); |
|
64 | + $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
65 | 65 | $ID_column_name .= '</span> '; |
66 | 66 | $this->_columns = array( |
67 | 67 | 'TXN_ID' => $ID_column_name, |
68 | - 'TXN_timestamp' => __( 'Transaction Date', 'event_espresso' ), |
|
69 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
70 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
71 | - 'ATT_fname' => __( 'Primary Registrant', 'event_espresso' ), |
|
72 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
73 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
68 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
69 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
70 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
71 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
72 | + 'event_name' => __('Event', 'event_espresso'), |
|
73 | + 'actions' => __('Actions', 'event_espresso') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $this->_sortable_columns = array( |
77 | - 'TXN_ID' => array( 'TXN_ID' => FALSE ), |
|
78 | - 'event_name' => array( 'event_name'=> FALSE ), |
|
79 | - 'ATT_fname' => array( 'ATT_fname'=> FALSE ), |
|
80 | - 'TXN_timestamp' => array( 'TXN_timestamp'=> TRUE ) //true means its already sorted |
|
77 | + 'TXN_ID' => array('TXN_ID' => FALSE), |
|
78 | + 'event_name' => array('event_name'=> FALSE), |
|
79 | + 'ATT_fname' => array('ATT_fname'=> FALSE), |
|
80 | + 'TXN_timestamp' => array('TXN_timestamp'=> TRUE) //true means its already sorted |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | $this->_primary_column = 'TXN_ID'; |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | * @throws \EE_Error |
97 | 97 | */ |
98 | - protected function _get_row_class( $item ) { |
|
99 | - $class = parent::_get_row_class( $item ); |
|
98 | + protected function _get_row_class($item) { |
|
99 | + $class = parent::_get_row_class($item); |
|
100 | 100 | //add status class |
101 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
102 | - if ( $this->_has_checkbox_column ) { |
|
101 | + $class .= ' ee-status-strip txn-status-'.$item->status_ID(); |
|
102 | + if ($this->_has_checkbox_column) { |
|
103 | 103 | $class .= ' has-checkbox-column'; |
104 | 104 | } |
105 | 105 | return $class; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function _get_table_filters() { |
118 | 118 | $filters = array(); |
119 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
120 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y', current_time('timestamp') ); |
|
119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
120 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', current_time('timestamp')); |
|
121 | 121 | ob_start(); |
122 | 122 | ?> |
123 | 123 | <label for="txn-filter-start-date">Display Transactions from </label> |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | *_add_view_counts |
137 | 137 | */ |
138 | 138 | protected function _add_view_counts() { |
139 | - $this->_views['all']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'all' ); |
|
140 | - $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'abandoned' ); |
|
141 | - $this->_views['failed']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'failed' ); |
|
139 | + $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'all'); |
|
140 | + $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'abandoned'); |
|
141 | + $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'failed'); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | * @return string |
151 | 151 | * @throws \EE_Error |
152 | 152 | */ |
153 | - public function column_TXN_ID( EE_Transaction $item ){ |
|
154 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
155 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__( 'Go to Transaction Details', 'event_espresso' ) . '">' . $item->ID() . '</a>'; |
|
153 | + public function column_TXN_ID(EE_Transaction $item) { |
|
154 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
155 | + $content = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'.$item->ID().'</a>'; |
|
156 | 156 | |
157 | 157 | //txn timestamp |
158 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp( $item ) . '</span>'; |
|
158 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($item).'</span>'; |
|
159 | 159 | return $content; |
160 | 160 | } |
161 | 161 | |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * @return mixed|string|void |
167 | 167 | * @throws \EE_Error |
168 | 168 | */ |
169 | - protected function _get_txn_timestamp( EE_Transaction $item ) { |
|
169 | + protected function _get_txn_timestamp(EE_Transaction $item) { |
|
170 | 170 | //txn timestamp |
171 | 171 | // is TXN less than 2 hours old ? |
172 | 172 | if ( |
173 | - ( $item->failed() || $item->is_abandoned() ) |
|
173 | + ($item->failed() || $item->is_abandoned()) |
|
174 | 174 | && ( |
175 | - ( time() - EE_Registry::instance()->SSN->lifespan() ) < $item->datetime( false, true ) |
|
175 | + (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
176 | 176 | ) |
177 | 177 | ) { |
178 | - $timestamp = __( 'TXN in progress...', 'event_espresso' ); |
|
178 | + $timestamp = __('TXN in progress...', 'event_espresso'); |
|
179 | 179 | } else { |
180 | - $timestamp = $item->get_i18n_datetime( 'TXN_timestamp' ); |
|
180 | + $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
181 | 181 | } |
182 | 182 | return $timestamp; |
183 | 183 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @return string |
192 | 192 | * @throws \EE_Error |
193 | 193 | */ |
194 | - public function column_cb($item ){ |
|
195 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
194 | + public function column_cb($item) { |
|
195 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | * @return string |
205 | 205 | * @throws \EE_Error |
206 | 206 | */ |
207 | - public function column_TXN_timestamp( EE_Transaction $item ){ |
|
208 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
209 | - $txn_date = '<a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details for TXN #', 'event_espresso' ) . $item->ID() . '">' . $this->_get_txn_timestamp( $item ) . '</a>'; |
|
207 | + public function column_TXN_timestamp(EE_Transaction $item) { |
|
208 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
209 | + $txn_date = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details for TXN #', 'event_espresso').$item->ID().'">'.$this->_get_txn_timestamp($item).'</a>'; |
|
210 | 210 | //status |
211 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
211 | + $txn_date .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
212 | 212 | return $txn_date; |
213 | 213 | } |
214 | 214 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | - public function column_TXN_total( EE_Transaction $item ){ |
|
225 | - if ( $item->get('TXN_total') > 0 ) { |
|
226 | - return '<span class="txn-pad-rght">' . apply_filters( 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item ) . '</span>'; |
|
224 | + public function column_TXN_total(EE_Transaction $item) { |
|
225 | + if ($item->get('TXN_total') > 0) { |
|
226 | + return '<span class="txn-pad-rght">'.apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item).'</span>'; |
|
227 | 227 | } else { |
228 | - return '<span class="txn-overview-free-event-spn">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
228 | + return '<span class="txn-overview-free-event-spn">'.__('free', 'event_espresso').'</span>'; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @return mixed|string |
239 | 239 | * @throws \EE_Error |
240 | 240 | */ |
241 | - public function column_TXN_paid( EE_Transaction $item ){ |
|
241 | + public function column_TXN_paid(EE_Transaction $item) { |
|
242 | 242 | $transaction_total = $item->get('TXN_total'); |
243 | 243 | $transaction_paid = $item->get('TXN_paid'); |
244 | 244 | |
245 | - if ( \EEH_Money::compare_floats( $transaction_total, 0,'>' ) ) { |
|
245 | + if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
246 | 246 | // monies owing |
247 | 247 | $span_class = 'txn-overview-part-payment-spn'; |
248 | - if ( \EEH_Money::compare_floats( $transaction_paid, $transaction_total, '>=' ) ) { |
|
248 | + if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
249 | 249 | // paid in full |
250 | 250 | $span_class = 'txn-overview-full-payment-spn'; |
251 | - } elseif ( \EEH_Money::compare_floats( $transaction_paid, 0, '==' ) ) { |
|
251 | + } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
252 | 252 | // no payments made |
253 | 253 | $span_class = 'txn-overview-no-payment-spn'; |
254 | 254 | } |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | $payment_method = $item->payment_method(); |
261 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' ); |
|
261 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso'); |
|
262 | 262 | |
263 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
264 | - if ( $transaction_paid > 0 ) { |
|
265 | - $content .= '<br><span class="ee-status-text-small">' . sprintf( __( '...via %s', 'event_espresso' ), $payment_method_name ) . '</span>'; |
|
263 | + $content = '<span class="'.$span_class.' txn-pad-rght">'.$transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid.'</span>'; |
|
264 | + if ($transaction_paid > 0) { |
|
265 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), $payment_method_name).'</span>'; |
|
266 | 266 | } |
267 | 267 | return $content; |
268 | 268 | } |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | * @return string|void |
277 | 277 | * @throws \EE_Error |
278 | 278 | */ |
279 | - public function column_ATT_fname( EE_Transaction $item ){ |
|
279 | + public function column_ATT_fname(EE_Transaction $item) { |
|
280 | 280 | $primary_reg = $item->primary_registration(); |
281 | 281 | $attendee = $primary_reg->get_first_related('Attendee'); |
282 | - if ( $attendee instanceof EE_Attendee ) { |
|
283 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$primary_reg->ID() ), REG_ADMIN_URL ); |
|
284 | - $content = EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
285 | - $content .= '<br>' . $attendee->email(); |
|
282 | + if ($attendee instanceof EE_Attendee) { |
|
283 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$primary_reg->ID()), REG_ADMIN_URL); |
|
284 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee->full_name().'</a>' : $attendee->full_name(); |
|
285 | + $content .= '<br>'.$attendee->email(); |
|
286 | 286 | return $content; |
287 | 287 | } |
288 | 288 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', 'event_espresso'); |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @return string|void |
298 | 298 | * @throws \EE_Error |
299 | 299 | */ |
300 | - public function column_ATT_email( EE_Transaction $item ){ |
|
300 | + public function column_ATT_email(EE_Transaction $item) { |
|
301 | 301 | $attendee = $item->primary_registration()->get_first_related('Attendee'); |
302 | - if ( ! empty( $attendee ) ) { |
|
303 | - return '<a href="mailto:' . $attendee->get( 'ATT_email' ) . '">' . $attendee->get( 'ATT_email' ) . '</a>'; |
|
302 | + if ( ! empty($attendee)) { |
|
303 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">'.$attendee->get('ATT_email').'</a>'; |
|
304 | 304 | } else { |
305 | 305 | return $item->failed() || $item->is_abandoned() |
306 | - ? __( 'no contact record.', 'event_espresso' ) |
|
306 | + ? __('no contact record.', 'event_espresso') |
|
307 | 307 | : __( |
308 | 308 | 'No contact record, because the transaction was abandoned or the registration process failed.', |
309 | 309 | 'event_espresso' |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | * @return string|void |
321 | 321 | * @throws \EE_Error |
322 | 322 | */ |
323 | - public function column_event_name( EE_Transaction $item ){ |
|
323 | + public function column_event_name(EE_Transaction $item) { |
|
324 | 324 | $actions = array(); |
325 | 325 | $event = $item->primary_registration()->get_first_related('Event'); |
326 | - if ( !empty( $event ) ) { |
|
327 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$event->ID() ), EVENTS_ADMIN_URL ); |
|
326 | + if ( ! empty($event)) { |
|
327 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$event->ID()), EVENTS_ADMIN_URL); |
|
328 | 328 | $event_name = $event->get('EVT_name'); |
329 | 329 | |
330 | 330 | //filter this view by transactions for this event |
331 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event->ID() ) ); |
|
332 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ) { |
|
333 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
331 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event->ID())); |
|
332 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
333 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'" title="'.esc_attr__('Filter transactions by this event', 'event_espresso').'">'.__('View Transactions for this event', 'event_espresso').'</a>'; |
|
334 | 334 | } |
335 | 335 | |
336 | - return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ? '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Edit Event: %s', 'event_espresso' ), $event->get('EVT_name') ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ), $this->row_actions($actions) ); |
|
336 | + return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID()) ? '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Edit Event: %s', 'event_espresso'), $event->get('EVT_name')).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
337 | 337 | } else { |
338 | 338 | return __('The event associated with this transaction via the primary registration cannot be retrieved.', 'event_espresso'); |
339 | 339 | } |
@@ -348,35 +348,35 @@ discard block |
||
348 | 348 | * @return string |
349 | 349 | * @throws \EE_Error |
350 | 350 | */ |
351 | - public function column_actions( EE_Transaction $item ){ |
|
351 | + public function column_actions(EE_Transaction $item) { |
|
352 | 352 | |
353 | 353 | $registration = $item->primary_registration(); |
354 | 354 | $attendee = $registration->attendee(); |
355 | 355 | |
356 | 356 | //Build row actions |
357 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
357 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
358 | 358 | $dl_invoice_lnk_url = $registration->invoice_url(); |
359 | 359 | $dl_receipt_lnk_url = $registration->receipt_url(); |
360 | - $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
361 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
362 | - $related_messages_link = EEH_MSG_Template::get_message_action_link( 'see_notifications_for', null, array( |
|
360 | + $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
361 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
362 | + $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
363 | 363 | 'TXN_ID' => $item->ID() |
364 | 364 | )); |
365 | 365 | |
366 | 366 | //Build row actions |
367 | 367 | $view_lnk = ' |
368 | 368 | <li> |
369 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '" class="tiny-text"> |
|
369 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
370 | 370 | <span class="dashicons dashicons-cart"></span> |
371 | 371 | </a> |
372 | 372 | </li>'; |
373 | 373 | |
374 | 374 | $dl_invoice_lnk = ''; |
375 | 375 | //only show invoice link if message type is active. |
376 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
376 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
377 | 377 | $dl_invoice_lnk = ' |
378 | 378 | <li> |
379 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
379 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
380 | 380 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
381 | 381 | </a> |
382 | 382 | </li>'; |
@@ -384,17 +384,17 @@ discard block |
||
384 | 384 | |
385 | 385 | $dl_receipt_lnk = ''; |
386 | 386 | //only show receipt link if message type is active. |
387 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'receipt' ) ) { |
|
387 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
388 | 388 | $dl_receipt_lnk = ' |
389 | 389 | <li> |
390 | - <a title="' . esc_attr__( 'View Transaction Receipt', 'event_espresso' ) . '" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
390 | + <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
391 | 391 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
392 | 392 | </a> |
393 | 393 | </li>'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | //only show payment reminder link if the message type is active. |
397 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
397 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
398 | 398 | $send_pay_lnk = $attendee instanceof EE_Attendee |
399 | 399 | && EE_Registry::instance()->CAP->current_user_can( |
400 | 400 | 'ee_send_message', |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | ) |
403 | 403 | ? ' |
404 | 404 | <li> |
405 | - <a href="'.$send_pay_lnk_url.'" title="' . esc_attr__( 'Send Payment Reminder', 'event_espresso' ) . '" class="tiny-text"> |
|
405 | + <a href="'.$send_pay_lnk_url.'" title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text"> |
|
406 | 406 | <span class="dashicons dashicons-email-alt"></span> |
407 | 407 | </a> |
408 | 408 | </li>' |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | ) |
423 | 423 | ? ' |
424 | 424 | <li> |
425 | - <a href="'.$view_reg_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
425 | + <a href="'.$view_reg_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
426 | 426 | <span class="dashicons dashicons-clipboard"></span> |
427 | 427 | </a> |
428 | 428 | </li>' |
429 | 429 | : ''; |
430 | 430 | |
431 | 431 | $view_related_messages_lnk = ''; |
432 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
433 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
432 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
433 | + $view_related_messages_lnk = '<li>'.$related_messages_link.'</li>'; |
|
434 | 434 | } |
435 | 435 | |
436 | - return $this->_action_string( $view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul' ); |
|
436 | + return $this->_action_string($view_lnk.$dl_invoice_lnk.$dl_receipt_lnk.$view_reg_lnk.$send_pay_lnk.$view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ) { |
115 | 115 | $new_value = null; |
116 | 116 | if ( $field_obj instanceof \EE_Infinite_Integer_Field |
117 | - && in_array( $original_value, array( null, '' ), true ) |
|
117 | + && in_array( $original_value, array( null, '' ), true ) |
|
118 | 118 | ) { |
119 | 119 | $new_value = EE_INF; |
120 | 120 | } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $original_value, |
175 | 175 | $requested_version |
176 | 176 | ); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | |
180 | 180 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | $requested_version, |
49 | 49 | $timezone_string = 'UTC' |
50 | 50 | ) { |
51 | - if ( is_array( $original_value_maybe_array ) ) { |
|
51 | + if (is_array($original_value_maybe_array)) { |
|
52 | 52 | $new_value_maybe_array = array(); |
53 | - foreach ( $original_value_maybe_array as $array_key => $array_item ) { |
|
54 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( |
|
53 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
54 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json( |
|
55 | 55 | $field_obj, |
56 | 56 | $array_item, |
57 | 57 | $requested_version, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param string $request_version (eg 4.8.36) |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ) { |
|
81 | - if ( is_array( $original_value_maybe_array ) ) { |
|
80 | + public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) { |
|
81 | + if (is_array($original_value_maybe_array)) { |
|
82 | 82 | $new_value_maybe_array = array(); |
83 | - foreach ( $original_value_maybe_array as $array_key => $array_item ) { |
|
84 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( |
|
83 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
84 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json( |
|
85 | 85 | $field_obj, |
86 | 86 | $array_item, |
87 | 87 | $request_version |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | $timezone_string = 'UTC' |
114 | 114 | ) { |
115 | 115 | $new_value = null; |
116 | - if ( $field_obj instanceof \EE_Infinite_Integer_Field |
|
117 | - && in_array( $original_value, array( null, '' ), true ) |
|
116 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
117 | + && in_array($original_value, array(null, ''), true) |
|
118 | 118 | ) { |
119 | 119 | $new_value = EE_INF; |
120 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
120 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
121 | 121 | //treat the provided value as being in this timezone |
122 | - $offset_secs_string = $field_obj->get_timezone_offset( new \DateTimeZone( $timezone_string ) ); |
|
123 | - $offset_secs = (int) substr( $offset_secs_string, 1 ); |
|
124 | - $offset_sign = substr( $offset_secs_string, 0, 1 ) ? substr( $offset_secs_string, 0, 1 ) : '+'; |
|
122 | + $offset_secs_string = $field_obj->get_timezone_offset(new \DateTimeZone($timezone_string)); |
|
123 | + $offset_secs = (int) substr($offset_secs_string, 1); |
|
124 | + $offset_sign = substr($offset_secs_string, 0, 1) ? substr($offset_secs_string, 0, 1) : '+'; |
|
125 | 125 | $offset_string = |
126 | 126 | str_pad( |
127 | - floor( $offset_secs / HOUR_IN_SECONDS ), |
|
127 | + floor($offset_secs / HOUR_IN_SECONDS), |
|
128 | 128 | 2, |
129 | 129 | '0', |
130 | 130 | STR_PAD_LEFT |
131 | 131 | ) |
132 | 132 | . ':' |
133 | 133 | . str_pad( |
134 | - ( $offset_secs % HOUR_IN_SECONDS ) / MINUTE_IN_SECONDS, |
|
134 | + ($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS, |
|
135 | 135 | 2, |
136 | 136 | '0', |
137 | 137 | STR_PAD_LEFT |
138 | 138 | ); |
139 | - $new_value = rest_parse_date( $original_value . $offset_sign . $offset_string ); |
|
139 | + $new_value = rest_parse_date($original_value.$offset_sign.$offset_string); |
|
140 | 140 | } else { |
141 | 141 | $new_value = $original_value; |
142 | 142 | } |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | >>>>>>> master |
158 | 158 | * @return mixed |
159 | 159 | */ |
160 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
161 | - if( $original_value === EE_INF ) { |
|
160 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
161 | + if ($original_value === EE_INF) { |
|
162 | 162 | $new_value = Model_Data_Translator::ee_inf_in_rest; |
163 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
164 | - if( $original_value instanceof \DateTime ) { |
|
165 | - $new_value = $original_value->format( 'Y-m-d H:i:s' ); |
|
166 | - } elseif( is_int( $original_value ) ) { |
|
167 | - $new_value = date( 'Y-m-d H:i:s', $original_value ); |
|
163 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
164 | + if ($original_value instanceof \DateTime) { |
|
165 | + $new_value = $original_value->format('Y-m-d H:i:s'); |
|
166 | + } elseif (is_int($original_value)) { |
|
167 | + $new_value = date('Y-m-d H:i:s', $original_value); |
|
168 | 168 | } else { |
169 | 169 | $new_value = $original_value; |
170 | 170 | } |
171 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
171 | + $new_value = mysql_to_rfc3339($new_value); |
|
172 | 172 | } else { |
173 | 173 | $new_value = $original_value; |
174 | 174 | } |
175 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
175 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
176 | 176 | $new_value, |
177 | 177 | $field_obj, |
178 | 178 | $original_value, |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | * @return array |
193 | 193 | * @throws \EE_Error |
194 | 194 | */ |
195 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
195 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
196 | 196 | $query_param_for_models = array(); |
197 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
198 | - $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ); |
|
197 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
198 | + $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key); |
|
199 | 199 | $field = Model_Data_Translator::deduce_field_from_query_param( |
200 | 200 | $query_param_sans_stars, |
201 | 201 | $model |
202 | 202 | ); |
203 | 203 | //double-check is it a *_gmt field? |
204 | - if( ! $field instanceof \EE_Model_Field_Base |
|
205 | - && Model_Data_Translator::is_gmt_date_field_name( $query_param_sans_stars ) ) { |
|
204 | + if ( ! $field instanceof \EE_Model_Field_Base |
|
205 | + && Model_Data_Translator::is_gmt_date_field_name($query_param_sans_stars)) { |
|
206 | 206 | //yep, take off '_gmt', and find the field |
207 | - $query_param_key = Model_Data_Translator::remove_gmt_from_field_name( $query_param_sans_stars ); |
|
207 | + $query_param_key = Model_Data_Translator::remove_gmt_from_field_name($query_param_sans_stars); |
|
208 | 208 | $field = Model_Data_Translator::deduce_field_from_query_param( |
209 | 209 | $query_param_key, |
210 | 210 | $model |
@@ -214,22 +214,22 @@ discard block |
||
214 | 214 | //so it's not a GMT field. Set the timezone on the model to the default |
215 | 215 | $timezone = \EEH_DTT_Helper::get_valid_timezone_string(); |
216 | 216 | } |
217 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
217 | + if ($field instanceof \EE_Model_Field_Base) { |
|
218 | 218 | //did they specify an operator? |
219 | - if( is_array( $query_param_value ) ) { |
|
220 | - $op = $query_param_value[ 0 ]; |
|
221 | - $translated_value = array( $op ); |
|
222 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
223 | - $value = $query_param_value[ 1 ]; |
|
224 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version, $timezone ); |
|
219 | + if (is_array($query_param_value)) { |
|
220 | + $op = $query_param_value[0]; |
|
221 | + $translated_value = array($op); |
|
222 | + if (isset($query_param_value[1])) { |
|
223 | + $value = $query_param_value[1]; |
|
224 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version, $timezone); |
|
225 | 225 | } |
226 | 226 | } else { |
227 | - $translated_value = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version, $timezone ); |
|
227 | + $translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version, $timezone); |
|
228 | 228 | } |
229 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
229 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
230 | 230 | } else { |
231 | 231 | //so it's not for a field, assume it's a logic query param key |
232 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
232 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | return $query_param_for_models; |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param string $field_name |
242 | 242 | * @return boolean |
243 | 243 | */ |
244 | - public static function is_gmt_date_field_name( $field_name ) { |
|
244 | + public static function is_gmt_date_field_name($field_name) { |
|
245 | 245 | return substr( |
246 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $field_name ), |
|
246 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name), |
|
247 | 247 | -4, |
248 | 248 | 4 |
249 | 249 | ) === '_gmt'; |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | * @param string $field_name |
255 | 255 | * @return string |
256 | 256 | */ |
257 | - public static function remove_gmt_from_field_name( $field_name ) { |
|
258 | - if( ! Model_Data_Translator::is_gmt_date_field_name( $field_name ) ) { |
|
257 | + public static function remove_gmt_from_field_name($field_name) { |
|
258 | + if ( ! Model_Data_Translator::is_gmt_date_field_name($field_name)) { |
|
259 | 259 | return $field_name; |
260 | 260 | } |
261 | - $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $field_name ); |
|
261 | + $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name); |
|
262 | 262 | $query_param_sans_gmt_and_sans_stars = substr( |
263 | 263 | $query_param_sans_stars, |
264 | 264 | 0, |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | '_gmt' |
268 | 268 | ) |
269 | 269 | ); |
270 | - return str_replace( $query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name ); |
|
270 | + return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param string $field_name |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public static function prepare_field_name_from_json( $field_name ) { |
|
279 | - if( Model_Data_Translator::is_gmt_date_field_name( $field_name ) ) { |
|
280 | - return Model_Data_Translator::remove_gmt_from_field_name( $field_name ); |
|
278 | + public static function prepare_field_name_from_json($field_name) { |
|
279 | + if (Model_Data_Translator::is_gmt_date_field_name($field_name)) { |
|
280 | + return Model_Data_Translator::remove_gmt_from_field_name($field_name); |
|
281 | 281 | } |
282 | 282 | return $field_name; |
283 | 283 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @param array $field_names |
288 | 288 | * @return array of field names (possibly include model prefixes) |
289 | 289 | */ |
290 | - public static function prepare_field_names_from_json( array $field_names ) { |
|
290 | + public static function prepare_field_names_from_json(array $field_names) { |
|
291 | 291 | $new_array = array(); |
292 | - foreach( $field_names as $key => $field_name ) { |
|
293 | - $new_array[ $key ] = Model_Data_Translator::prepare_field_name_from_json( $field_name ); |
|
292 | + foreach ($field_names as $key => $field_name) { |
|
293 | + $new_array[$key] = Model_Data_Translator::prepare_field_name_from_json($field_name); |
|
294 | 294 | } |
295 | 295 | return $new_array; |
296 | 296 | } |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * @param array $field_names_as_keys |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public static function prepare_field_names_in_array_keys_from_json( array $field_names_as_keys ) { |
|
304 | + public static function prepare_field_names_in_array_keys_from_json(array $field_names_as_keys) { |
|
305 | 305 | $new_array = array(); |
306 | - foreach( $field_names_as_keys as $field_name => $value ) { |
|
307 | - $new_array[ Model_Data_Translator::prepare_field_name_from_json( $field_name ) ] = $value; |
|
306 | + foreach ($field_names_as_keys as $field_name => $value) { |
|
307 | + $new_array[Model_Data_Translator::prepare_field_name_from_json($field_name)] = $value; |
|
308 | 308 | } |
309 | 309 | return $new_array; |
310 | 310 | } |
@@ -317,27 +317,27 @@ discard block |
||
317 | 317 | * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API |
318 | 318 | * @return array which can be passed into the EE4 REST API when querying a model resource |
319 | 319 | */ |
320 | - public static function prepare_query_params_for_rest_api( array $model_query_params, \EEM_Base $model, $requested_version = null ) { |
|
321 | - if( $requested_version === null ) { |
|
322 | - $requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ; |
|
320 | + public static function prepare_query_params_for_rest_api(array $model_query_params, \EEM_Base $model, $requested_version = null) { |
|
321 | + if ($requested_version === null) { |
|
322 | + $requested_version = \EED_Core_Rest_Api::latest_rest_api_version(); |
|
323 | 323 | } |
324 | 324 | $rest_query_params = $model_query_params; |
325 | - if ( isset( $model_query_params[0] ) ) { |
|
326 | - $rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
327 | - $model_query_params[ 0 ], |
|
325 | + if (isset($model_query_params[0])) { |
|
326 | + $rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
327 | + $model_query_params[0], |
|
328 | 328 | $model, |
329 | 329 | $requested_version |
330 | 330 | ); |
331 | - unset( $rest_query_params[0] ); |
|
331 | + unset($rest_query_params[0]); |
|
332 | 332 | } |
333 | - if ( isset( $model_query_params[ 'having' ] ) ) { |
|
334 | - $rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
335 | - $model_query_params[ 'having' ], |
|
333 | + if (isset($model_query_params['having'])) { |
|
334 | + $rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
335 | + $model_query_params['having'], |
|
336 | 336 | $model, |
337 | 337 | $requested_version |
338 | 338 | ); |
339 | 339 | } |
340 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version ); |
|
340 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -347,29 +347,29 @@ discard block |
||
347 | 347 | * @param string $requested_version eg "4.8.36" |
348 | 348 | * @return array ready for use in the rest api query params |
349 | 349 | */ |
350 | - public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
350 | + public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
351 | 351 | $query_param_for_models = array(); |
352 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
352 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
353 | 353 | $field = Model_Data_Translator::deduce_field_from_query_param( |
354 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
354 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
355 | 355 | $model |
356 | 356 | ); |
357 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
357 | + if ($field instanceof \EE_Model_Field_Base) { |
|
358 | 358 | //did they specify an operator? |
359 | - if( is_array( $query_param_value ) ) { |
|
360 | - $op = $query_param_value[ 0 ]; |
|
361 | - $translated_value = array( $op ); |
|
362 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
363 | - $value = $query_param_value[ 1 ]; |
|
364 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version ); |
|
359 | + if (is_array($query_param_value)) { |
|
360 | + $op = $query_param_value[0]; |
|
361 | + $translated_value = array($op); |
|
362 | + if (isset($query_param_value[1])) { |
|
363 | + $value = $query_param_value[1]; |
|
364 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version); |
|
365 | 365 | } |
366 | 366 | } else { |
367 | - $translated_value = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version ); |
|
367 | + $translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version); |
|
368 | 368 | } |
369 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
369 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
370 | 370 | } else { |
371 | 371 | //so it's not for a field, assume it's a logic query param key |
372 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version ); |
|
372 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | return $query_param_for_models; |
@@ -381,11 +381,11 @@ discard block |
||
381 | 381 | * @param $condition_query_param_key |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
384 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
385 | 385 | $pos_of_star = strpos($condition_query_param_key, '*'); |
386 | - if($pos_of_star === FALSE){ |
|
386 | + if ($pos_of_star === FALSE) { |
|
387 | 387 | return $condition_query_param_key; |
388 | - }else{ |
|
388 | + } else { |
|
389 | 389 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
390 | 390 | return $condition_query_param_sans_star; |
391 | 391 | } |
@@ -401,26 +401,26 @@ discard block |
||
401 | 401 | * @return \EE_Model_Field_Base |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
404 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
405 | 405 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
406 | 406 | //which will help us find the database table and column |
407 | 407 | |
408 | - $query_param_parts = explode(".",$query_param_name); |
|
409 | - if(empty($query_param_parts)){ |
|
410 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
408 | + $query_param_parts = explode(".", $query_param_name); |
|
409 | + if (empty($query_param_parts)) { |
|
410 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
411 | 411 | } |
412 | 412 | $number_of_parts = count($query_param_parts); |
413 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
414 | - if($number_of_parts == 1){ |
|
413 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
414 | + if ($number_of_parts == 1) { |
|
415 | 415 | $field_name = $last_query_param_part; |
416 | - }else{// $number_of_parts >= 2 |
|
416 | + } else {// $number_of_parts >= 2 |
|
417 | 417 | //the last part is the column name, and there are only 2parts. therefore... |
418 | 418 | $field_name = $last_query_param_part; |
419 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
419 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
420 | 420 | } |
421 | - try{ |
|
421 | + try { |
|
422 | 422 | return $model->field_settings_for($field_name); |
423 | - }catch(\EE_Error $e){ |
|
423 | + } catch (\EE_Error $e) { |
|
424 | 424 | return null; |
425 | 425 | } |
426 | 426 | } |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @param \WP_REST_Request $request |
47 | 47 | * @return \WP_REST_Response|\WP_Error |
48 | 48 | */ |
49 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
49 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
50 | 50 | $controller = new Read(); |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $matches = $controller->parse_route( |
53 | 53 | $request->get_route(), |
54 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
55 | - array( 'version', 'model' ) |
|
54 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
55 | + array('version', 'model') |
|
56 | 56 | ); |
57 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
58 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
59 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
57 | + $controller->set_requested_version($matches['version']); |
|
58 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
59 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
60 | 60 | return $controller->send_response( |
61 | 61 | new \WP_Error( |
62 | 62 | 'endpoint_parsing_error', |
63 | 63 | sprintf( |
64 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
64 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
65 | 65 | $model_name_singular |
66 | 66 | ) |
67 | 67 | ) |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | return $controller->send_response( |
71 | 71 | $controller->get_entities_from_model( |
72 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
72 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
73 | 73 | $request |
74 | 74 | ) |
75 | 75 | ); |
76 | - } catch( \Exception $e ) { |
|
77 | - return $controller->send_response( $e ); |
|
76 | + } catch (\Exception $e) { |
|
77 | + return $controller->send_response($e); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @param \WP_REST_Request $request |
85 | 85 | * @return \WP_REST_Response|\WP_Error |
86 | 86 | */ |
87 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
87 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
88 | 88 | $controller = new Read(); |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $matches = $controller->parse_route( |
91 | 91 | $request->get_route(), |
92 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
93 | - array( 'version', 'model', 'id' ) ); |
|
94 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
95 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
96 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
92 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
93 | + array('version', 'model', 'id') ); |
|
94 | + $controller->set_requested_version($matches['version']); |
|
95 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
96 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
97 | 97 | return $controller->send_response( |
98 | 98 | new \WP_Error( |
99 | 99 | 'endpoint_parsing_error', |
100 | 100 | sprintf( |
101 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
101 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
102 | 102 | $model_name_singular |
103 | 103 | ) |
104 | 104 | ) |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | return $controller->send_response( |
108 | 108 | $controller->get_entity_from_model( |
109 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
109 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
110 | 110 | $request |
111 | 111 | ) |
112 | 112 | ); |
113 | - } catch( \Exception $e ) { |
|
114 | - return $controller->send_response( $e ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return $controller->send_response($e); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | * @param \WP_REST_Request $request |
124 | 124 | * @return \WP_REST_Response|\WP_Error |
125 | 125 | */ |
126 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
126 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
127 | 127 | $controller = new Read(); |
128 | - try{ |
|
128 | + try { |
|
129 | 129 | $matches = $controller->parse_route( |
130 | 130 | $request->get_route(), |
131 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
132 | - array( 'version', 'model', 'id', 'related_model' ) |
|
131 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
132 | + array('version', 'model', 'id', 'related_model') |
|
133 | 133 | ); |
134 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
135 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
136 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
134 | + $controller->set_requested_version($matches['version']); |
|
135 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
136 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
137 | 137 | return $controller->send_response( |
138 | 138 | new \WP_Error( |
139 | 139 | 'endpoint_parsing_error', |
140 | 140 | sprintf( |
141 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
141 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
142 | 142 | $main_model_name_singular |
143 | 143 | ) |
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | } |
147 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
147 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
148 | 148 | //assume the related model name is plural and try to find the model's name |
149 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
149 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
152 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
152 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
153 | 153 | } |
154 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
154 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
155 | 155 | return $controller->send_response( |
156 | 156 | new \WP_Error( |
157 | 157 | 'endpoint_parsing_error', |
158 | 158 | sprintf( |
159 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
159 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
160 | 160 | $related_model_name_singular |
161 | 161 | ) |
162 | 162 | ) |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | |
166 | 166 | return $controller->send_response( |
167 | 167 | $controller->get_entities_from_relation( |
168 | - $request->get_param( 'id' ), |
|
169 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
168 | + $request->get_param('id'), |
|
169 | + $main_model->related_settings_for($related_model_name_singular), |
|
170 | 170 | $request |
171 | 171 | ) |
172 | 172 | ); |
173 | - } catch( \Exception $e ) { |
|
174 | - return $controller->send_response( $e ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + return $controller->send_response($e); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,28 +184,28 @@ discard block |
||
184 | 184 | * @param \WP_REST_Request $request |
185 | 185 | * @return array|\WP_Error |
186 | 186 | */ |
187 | - public function get_entities_from_model( $model, $request) { |
|
188 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
189 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
190 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
187 | + public function get_entities_from_model($model, $request) { |
|
188 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
189 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
190 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
191 | 191 | return new \WP_Error( |
192 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
192 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
193 | 193 | sprintf( |
194 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
194 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
195 | 195 | $model_name_plural, |
196 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
196 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
197 | 197 | ), |
198 | - array( 'status' => 403 ) |
|
198 | + array('status' => 403) |
|
199 | 199 | ); |
200 | 200 | } |
201 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
202 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
201 | + if ( ! $request->get_header('no_rest_headers')) { |
|
202 | + $this->_set_headers_from_query_params($model, $query_params); |
|
203 | 203 | } |
204 | 204 | /** @type array $results */ |
205 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
205 | + $results = $model->get_all_wpdb_results($query_params); |
|
206 | 206 | $nice_results = array( ); |
207 | - foreach ( $results as $result ) { |
|
208 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
207 | + foreach ($results as $result) { |
|
208 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
209 | 209 | $model, |
210 | 210 | $result, |
211 | 211 | $request |
@@ -225,64 +225,64 @@ discard block |
||
225 | 225 | * @param \WP_REST_Request $request |
226 | 226 | * @return array|\WP_Error |
227 | 227 | */ |
228 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
229 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
228 | + public function get_entities_from_relation($id, $relation, $request) { |
|
229 | + $context = $this->validate_context($request->get_param('caps')); |
|
230 | 230 | $model = $relation->get_this_model(); |
231 | 231 | $related_model = $relation->get_other_model(); |
232 | 232 | //check if they can access the 1st model object |
233 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
234 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
233 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
234 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
235 | 235 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
236 | 236 | } |
237 | 237 | $restricted_query_params = $query_params; |
238 | - $restricted_query_params[ 'caps' ] = $context; |
|
239 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
240 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
238 | + $restricted_query_params['caps'] = $context; |
|
239 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
240 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
241 | 241 | |
242 | - if( |
|
242 | + if ( |
|
243 | 243 | ! ( |
244 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
245 | - && $model->exists( $restricted_query_params ) |
|
244 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
245 | + && $model->exists($restricted_query_params) |
|
246 | 246 | ) |
247 | - ){ |
|
248 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
249 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
250 | - }else{ |
|
251 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
247 | + ) { |
|
248 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
249 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
250 | + } else { |
|
251 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
252 | 252 | } |
253 | 253 | return new \WP_Error( |
254 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
254 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
255 | 255 | sprintf( |
256 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
256 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
257 | 257 | $related_model_name_maybe_plural, |
258 | 258 | $relation->get_this_model()->get_this_model_name(), |
259 | 259 | implode( |
260 | 260 | ',', |
261 | 261 | array_keys( |
262 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
262 | + Capabilities::get_missing_permissions($related_model, $context) |
|
263 | 263 | ) |
264 | 264 | ) |
265 | 265 | ), |
266 | - array( 'status' => 403 ) |
|
266 | + array('status' => 403) |
|
267 | 267 | ); |
268 | 268 | } |
269 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
270 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
271 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
272 | - $query_params[ 'caps' ] = $context; |
|
273 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
274 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
269 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
270 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
271 | + $query_params['default_where_conditions'] = 'none'; |
|
272 | + $query_params['caps'] = $context; |
|
273 | + if ( ! $request->get_header('no_rest_headers')) { |
|
274 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
275 | 275 | } |
276 | 276 | /** @type array $results */ |
277 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
277 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
278 | 278 | $nice_results = array(); |
279 | - foreach( $results as $result ) { |
|
279 | + foreach ($results as $result) { |
|
280 | 280 | $nice_result = $this->create_entity_from_wpdb_result( |
281 | 281 | $relation->get_other_model(), |
282 | 282 | $result, |
283 | 283 | $request |
284 | 284 | ); |
285 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
285 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
286 | 286 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
287 | 287 | //if there are conflicts we prefer the properties from the main model |
288 | 288 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | $result, |
291 | 291 | $request |
292 | 292 | ); |
293 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
293 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
294 | 294 | //but keep the meta stuff from the main model |
295 | - if( isset( $nice_result['meta'] ) ){ |
|
295 | + if (isset($nice_result['meta'])) { |
|
296 | 296 | $joined_result['meta'] = $nice_result['meta']; |
297 | 297 | } |
298 | 298 | $nice_result = $joined_result; |
299 | 299 | } |
300 | 300 | $nice_results[] = $nice_result; |
301 | 301 | } |
302 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
303 | - return array_shift( $nice_results ); |
|
304 | - }else{ |
|
302 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
303 | + return array_shift($nice_results); |
|
304 | + } else { |
|
305 | 305 | return $nice_results; |
306 | 306 | } |
307 | 307 | } |
@@ -314,30 +314,30 @@ discard block |
||
314 | 314 | * @param array $query_params |
315 | 315 | * @return void |
316 | 316 | */ |
317 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
318 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
319 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
317 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
318 | + $this->_set_debug_info('model query params', $query_params); |
|
319 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
320 | 320 | //normally the limit to a 2-part array, where the 2nd item is the limit |
321 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
322 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
321 | + if ( ! isset($query_params['limit'])) { |
|
322 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
323 | 323 | } |
324 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
325 | - $limit_parts = $query_params[ 'limit' ]; |
|
324 | + if (is_array($query_params['limit'])) { |
|
325 | + $limit_parts = $query_params['limit']; |
|
326 | 326 | } else { |
327 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
328 | - if( count( $limit_parts ) == 1 ){ |
|
329 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
327 | + $limit_parts = explode(',', $query_params['limit']); |
|
328 | + if (count($limit_parts) == 1) { |
|
329 | + $limit_parts = array(0, $limit_parts[0]); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | //remove the group by and having parts of the query, as those will |
333 | 333 | //make the sql query return an array of values, instead of just a single value |
334 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
335 | - $count = $model->count( $query_params, null, true ); |
|
334 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
335 | + $count = $model->count($query_params, null, true); |
|
336 | 336 | |
337 | - $pages = $count / $limit_parts[ 1 ]; |
|
338 | - $this->_set_response_header( 'Total', $count, false ); |
|
339 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
340 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
337 | + $pages = $count / $limit_parts[1]; |
|
338 | + $this->_set_response_header('Total', $count, false); |
|
339 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
340 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -350,47 +350,47 @@ discard block |
||
350 | 350 | * @param string $deprecated no longer used |
351 | 351 | * @return array ready for being converted into json for sending to client |
352 | 352 | */ |
353 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
354 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
353 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
354 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
355 | 355 | //ok so this was called in the old style, where the 3rd arg was |
356 | 356 | //$include, and the 4th arg was $context |
357 | 357 | //now setup the request just to avoid fatal errors, although we won't be able |
358 | 358 | //to truly make use of it because it's kinda devoid of info |
359 | 359 | $rest_request = new \WP_REST_Request(); |
360 | - $rest_request->set_param( 'include', $rest_request ); |
|
361 | - $rest_request->set_param( 'caps', $deprecated ); |
|
360 | + $rest_request->set_param('include', $rest_request); |
|
361 | + $rest_request->set_param('caps', $deprecated); |
|
362 | 362 | } |
363 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
364 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
363 | + if ($rest_request->get_param('caps') == null) { |
|
364 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
365 | 365 | } |
366 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
367 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
368 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
369 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
370 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
366 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
367 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
368 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
369 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
370 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
371 | 371 | $entity_array = apply_filters( |
372 | 372 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
373 | 373 | $entity_array, |
374 | 374 | $model, |
375 | - $rest_request->get_param( 'caps' ), |
|
375 | + $rest_request->get_param('caps'), |
|
376 | 376 | $rest_request, |
377 | 377 | $this |
378 | 378 | ); |
379 | 379 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
380 | 380 | $entity_array, |
381 | 381 | $model, |
382 | - $rest_request->get_param( 'caps' ), |
|
382 | + $rest_request->get_param('caps'), |
|
383 | 383 | $this->get_model_version_info() |
384 | 384 | ); |
385 | 385 | $this->_set_debug_info( |
386 | 386 | 'inaccessible fields', |
387 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
387 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
388 | 388 | ); |
389 | 389 | return apply_filters( |
390 | 390 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
391 | 391 | $result_without_inaccessible_fields, |
392 | 392 | $model, |
393 | - $rest_request->get_param( 'caps' ) |
|
393 | + $rest_request->get_param('caps') |
|
394 | 394 | ); |
395 | 395 | } |
396 | 396 | |
@@ -402,39 +402,39 @@ discard block |
||
402 | 402 | * @param array $db_row |
403 | 403 | * @return array entity mostly ready for converting to JSON and sending in the response |
404 | 404 | */ |
405 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
406 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
407 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
408 | - foreach( $result as $field_name => $raw_field_value ) { |
|
405 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
406 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
407 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
408 | + foreach ($result as $field_name => $raw_field_value) { |
|
409 | 409 | $field_obj = $model->field_settings_for($field_name); |
410 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
411 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
412 | - unset( $result[ $field_name ] ); |
|
413 | - }elseif( |
|
414 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
415 | - ){ |
|
416 | - $result[ $field_name ] = array( |
|
417 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
418 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
410 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
411 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
412 | + unset($result[$field_name]); |
|
413 | + }elseif ( |
|
414 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
415 | + ) { |
|
416 | + $result[$field_name] = array( |
|
417 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
418 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
419 | 419 | ); |
420 | - }elseif( |
|
421 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
422 | - ){ |
|
423 | - $result[ $field_name ] = array( |
|
424 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
425 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
420 | + }elseif ( |
|
421 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
422 | + ) { |
|
423 | + $result[$field_name] = array( |
|
424 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
425 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
426 | 426 | ); |
427 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
428 | - if( $field_value instanceof \DateTime ) { |
|
427 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
428 | + if ($field_value instanceof \DateTime) { |
|
429 | 429 | $timezone = $field_value->getTimezone(); |
430 | - $field_value->setTimezone( new \DateTimeZone( 'UTC' ) ); |
|
431 | - $result[ $field_name . '_gmt' ] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | + $field_value->setTimezone(new \DateTimeZone('UTC')); |
|
431 | + $result[$field_name.'_gmt'] = Model_Data_Translator::prepare_field_value_for_json( |
|
432 | 432 | $field_obj, |
433 | 433 | $field_value, |
434 | 434 | $this->get_model_version_info()->requested_version() |
435 | 435 | ); |
436 | - $field_value->setTimezone( $timezone ); |
|
437 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | + $field_value->setTimezone($timezone); |
|
437 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
438 | 438 | $field_obj, |
439 | 439 | $field_value, |
440 | 440 | $this->get_model_version_info()->requested_version() |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | } else { |
445 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
445 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
446 | 446 | $field_obj, |
447 | - $field_obj->prepare_for_get( $field_value ), |
|
447 | + $field_obj->prepare_for_get($field_value), |
|
448 | 448 | $this->get_model_version_info()->requested_version() |
449 | 449 | ); |
450 | 450 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * @param array $entity_array |
460 | 460 | * @return array modified entity |
461 | 461 | */ |
462 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
463 | - if( $model instanceof \EEM_CPT_Base ) { |
|
464 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
462 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
463 | + if ($model instanceof \EEM_CPT_Base) { |
|
464 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
465 | 465 | } |
466 | 466 | return $entity_array; |
467 | 467 | } |
@@ -475,20 +475,20 @@ discard block |
||
475 | 475 | * @param array $entity_array |
476 | 476 | * @return array the _links item in the entity |
477 | 477 | */ |
478 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
478 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
479 | 479 | //add basic links |
480 | 480 | $links = array( |
481 | 481 | 'self' => array( |
482 | 482 | array( |
483 | 483 | 'href' => $this->get_versioned_link_to( |
484 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
484 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
485 | 485 | ) |
486 | 486 | ) |
487 | 487 | ), |
488 | 488 | 'collection' => array( |
489 | 489 | array( |
490 | 490 | 'href' => $this->get_versioned_link_to( |
491 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
491 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
492 | 492 | ) |
493 | 493 | ) |
494 | 494 | ), |
@@ -496,24 +496,24 @@ discard block |
||
496 | 496 | |
497 | 497 | //add link to the wp core endpoint, if wp api is active |
498 | 498 | global $wp_rest_server; |
499 | - if( $model instanceof \EEM_CPT_Base && |
|
499 | + if ($model instanceof \EEM_CPT_Base && |
|
500 | 500 | $wp_rest_server instanceof \WP_REST_Server && |
501 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
502 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
501 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
502 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
503 | 503 | array( |
504 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
504 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
505 | 505 | 'single' => true |
506 | 506 | ) |
507 | 507 | ); |
508 | 508 | } |
509 | 509 | |
510 | 510 | //add links to related models |
511 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
512 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
513 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
511 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
512 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
513 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
514 | 514 | array( |
515 | 515 | 'href' => $this->get_versioned_link_to( |
516 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
516 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
517 | 517 | ), |
518 | 518 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
519 | 519 | ) |
@@ -529,51 +529,51 @@ discard block |
||
529 | 529 | * @param array $entity_array |
530 | 530 | * @return array the modified entity |
531 | 531 | */ |
532 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
533 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
534 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
532 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
533 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
534 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
535 | 535 | //if they passed in * or didn't specify any includes, return everything |
536 | - if( ! in_array( '*', $includes_for_this_model ) |
|
537 | - && ! empty( $includes_for_this_model ) ) { |
|
538 | - if( $model->has_primary_key_field() ) { |
|
536 | + if ( ! in_array('*', $includes_for_this_model) |
|
537 | + && ! empty($includes_for_this_model)) { |
|
538 | + if ($model->has_primary_key_field()) { |
|
539 | 539 | //always include the primary key. ya just gotta know that at least |
540 | 540 | $includes_for_this_model[] = $model->primary_key_name(); |
541 | 541 | } |
542 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
542 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
543 | 543 | $includes_for_this_model[] = '_calculated_fields'; |
544 | 544 | } |
545 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
545 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
546 | 546 | } |
547 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
548 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
547 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
548 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
549 | 549 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
550 | - $rest_request->get_param( 'include' ), |
|
550 | + $rest_request->get_param('include'), |
|
551 | 551 | $relation_name |
552 | 552 | ); |
553 | 553 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
554 | - $rest_request->get_param( 'calculate' ), |
|
554 | + $rest_request->get_param('calculate'), |
|
555 | 555 | $relation_name |
556 | 556 | ); |
557 | 557 | //did they specify they wanted to include a related model, or |
558 | 558 | //specific fields from a related model? |
559 | 559 | //or did they specify to calculate a field from a related model? |
560 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
560 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
561 | 561 | //if so, we should include at least some part of the related model |
562 | 562 | $pretend_related_request = new \WP_REST_Request(); |
563 | 563 | $pretend_related_request->set_query_params( |
564 | 564 | array( |
565 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
565 | + 'caps' => $rest_request->get_param('caps'), |
|
566 | 566 | 'include' => $related_fields_to_include, |
567 | 567 | 'calculate' => $related_fields_to_calculate, |
568 | 568 | ) |
569 | 569 | ); |
570 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
570 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
571 | 571 | $related_results = $this->get_entities_from_relation( |
572 | - $entity_array[ $model->primary_key_name() ], |
|
572 | + $entity_array[$model->primary_key_name()], |
|
573 | 573 | $relation_obj, |
574 | 574 | $pretend_related_request |
575 | 575 | ); |
576 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
576 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
577 | 577 | ? null |
578 | 578 | : $related_results; |
579 | 579 | } |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | * @param array $arr |
588 | 588 | * @return array |
589 | 589 | */ |
590 | - private function _remove_model_names_from_array( $arr ) { |
|
591 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
590 | + private function _remove_model_names_from_array($arr) { |
|
591 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
592 | 592 | } |
593 | 593 | /** |
594 | 594 | * Gets the calculated fields for the response |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | * @param \WP_REST_Request $rest_request |
599 | 599 | * @return \stdClass the _calculations item in the entity |
600 | 600 | */ |
601 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
601 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
602 | 602 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
603 | - $rest_request->get_param( 'calculate' ), |
|
603 | + $rest_request->get_param('calculate'), |
|
604 | 604 | '' |
605 | 605 | ); |
606 | 606 | //note: setting calculate=* doesn't do anything |
607 | 607 | $calculated_fields_to_return = new \stdClass(); |
608 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
609 | - try{ |
|
608 | + foreach ($calculated_fields as $field_to_calculate) { |
|
609 | + try { |
|
610 | 610 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
611 | 611 | null, |
612 | 612 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | ), |
619 | 619 | $this->get_model_version_info()->requested_version() |
620 | 620 | ); |
621 | - } catch( Rest_Exception $e ) { |
|
621 | + } catch (Rest_Exception $e) { |
|
622 | 622 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
623 | 623 | $this->_set_response_header( |
624 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
624 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
625 | 625 | $e->getMessage(), |
626 | 626 | true |
627 | 627 | ); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
636 | 636 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
637 | 637 | */ |
638 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
638 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
639 | 639 | return rest_url( |
640 | 640 | \EED_Core_Rest_Api::ee_api_namespace |
641 | 641 | . $this->get_model_version_info()->requested_version() |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | * @param \EE_Model_Relation_Base $relation_obj |
652 | 652 | * @return string |
653 | 653 | */ |
654 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
655 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
656 | - return strtolower( $relation_name ); |
|
657 | - }else{ |
|
658 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
654 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
655 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
656 | + return strtolower($relation_name); |
|
657 | + } else { |
|
658 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
@@ -668,43 +668,43 @@ discard block |
||
668 | 668 | * @param \WP_REST_Request $request |
669 | 669 | * @return array|\WP_Error |
670 | 670 | */ |
671 | - public function get_entity_from_model( $model, $request ) { |
|
672 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
673 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
671 | + public function get_entity_from_model($model, $request) { |
|
672 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
673 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
674 | 674 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
675 | 675 | } |
676 | 676 | $restricted_query_params = $query_params; |
677 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
678 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
679 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
680 | - if ( ! empty ( $model_rows ) ) { |
|
677 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
678 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
679 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
680 | + if ( ! empty ($model_rows)) { |
|
681 | 681 | return $this->create_entity_from_wpdb_result( |
682 | 682 | $model, |
683 | - array_shift( $model_rows ), |
|
683 | + array_shift($model_rows), |
|
684 | 684 | $request ); |
685 | 685 | } else { |
686 | 686 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
687 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
688 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
689 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
687 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
688 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
689 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
690 | 690 | //you got shafted- it existed but we didn't want to tell you! |
691 | 691 | return new \WP_Error( |
692 | 692 | 'rest_user_cannot_read', |
693 | 693 | sprintf( |
694 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
695 | - strtolower( $model->get_this_model_name() ), |
|
694 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
695 | + strtolower($model->get_this_model_name()), |
|
696 | 696 | Capabilities::get_missing_permissions_string( |
697 | 697 | $model, |
698 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
698 | + $this->validate_context($request->get_param('caps')) ) |
|
699 | 699 | ), |
700 | - array( 'status' => 403 ) |
|
700 | + array('status' => 403) |
|
701 | 701 | ); |
702 | 702 | } else { |
703 | 703 | //it's not you. It just doesn't exist |
704 | 704 | return new \WP_Error( |
705 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
706 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
707 | - array( 'status' => 404 ) |
|
705 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
706 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
707 | + array('status' => 404) |
|
708 | 708 | ); |
709 | 709 | } |
710 | 710 | } |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | * @param string $context |
718 | 718 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
719 | 719 | */ |
720 | - public function validate_context( $context ) { |
|
721 | - if( ! $context ) { |
|
720 | + public function validate_context($context) { |
|
721 | + if ( ! $context) { |
|
722 | 722 | $context = \EEM_Base::caps_read; |
723 | 723 | } |
724 | 724 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
725 | - if( in_array( $context, $valid_contexts ) ){ |
|
725 | + if (in_array($context, $valid_contexts)) { |
|
726 | 726 | return $context; |
727 | - }else{ |
|
727 | + } else { |
|
728 | 728 | return \EEM_Base::caps_read; |
729 | 729 | } |
730 | 730 | } |
@@ -743,87 +743,87 @@ discard block |
||
743 | 743 | * that absolutely no results should be returned |
744 | 744 | * @throws \EE_Error |
745 | 745 | */ |
746 | - public function create_model_query_params( $model, $query_parameters ) { |
|
746 | + public function create_model_query_params($model, $query_parameters) { |
|
747 | 747 | $model_query_params = array( ); |
748 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
749 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
750 | - $query_parameters[ 'where' ], |
|
748 | + if (isset($query_parameters['where'])) { |
|
749 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
750 | + $query_parameters['where'], |
|
751 | 751 | $model, |
752 | 752 | $this->get_model_version_info()->requested_version() |
753 | 753 | ); |
754 | 754 | } |
755 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
756 | - $order_by = $query_parameters[ 'order_by' ]; |
|
757 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
758 | - $order_by = $query_parameters[ 'orderby' ]; |
|
759 | - }else{ |
|
755 | + if (isset($query_parameters['order_by'])) { |
|
756 | + $order_by = $query_parameters['order_by']; |
|
757 | + } elseif (isset($query_parameters['orderby'])) { |
|
758 | + $order_by = $query_parameters['orderby']; |
|
759 | + } else { |
|
760 | 760 | $order_by = null; |
761 | 761 | } |
762 | - if( $order_by !== null ){ |
|
763 | - if( is_array( $order_by ) ) { |
|
764 | - $order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json( $order_by ); |
|
762 | + if ($order_by !== null) { |
|
763 | + if (is_array($order_by)) { |
|
764 | + $order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json($order_by); |
|
765 | 765 | } else { |
766 | 766 | //it's a single item |
767 | - $order_by = Model_Data_Translator::prepare_field_name_from_json( $order_by ); |
|
767 | + $order_by = Model_Data_Translator::prepare_field_name_from_json($order_by); |
|
768 | 768 | } |
769 | - $model_query_params[ 'order_by' ] = $order_by; |
|
769 | + $model_query_params['order_by'] = $order_by; |
|
770 | 770 | } |
771 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
772 | - $group_by = $query_parameters[ 'group_by' ]; |
|
773 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
774 | - $group_by = $query_parameters[ 'groupby' ]; |
|
775 | - }else{ |
|
776 | - $group_by = array_keys( $model->get_combined_primary_key_fields() ); |
|
771 | + if (isset($query_parameters['group_by'])) { |
|
772 | + $group_by = $query_parameters['group_by']; |
|
773 | + } elseif (isset($query_parameters['groupby'])) { |
|
774 | + $group_by = $query_parameters['groupby']; |
|
775 | + } else { |
|
776 | + $group_by = array_keys($model->get_combined_primary_key_fields()); |
|
777 | 777 | } |
778 | 778 | //make sure they're all real names |
779 | - if( is_array( $group_by ) ) { |
|
780 | - $group_by = Model_Data_Translator::prepare_field_names_from_json( $group_by ); |
|
779 | + if (is_array($group_by)) { |
|
780 | + $group_by = Model_Data_Translator::prepare_field_names_from_json($group_by); |
|
781 | 781 | } |
782 | - if( $group_by !== null ){ |
|
783 | - $model_query_params[ 'group_by' ] = $group_by; |
|
782 | + if ($group_by !== null) { |
|
783 | + $model_query_params['group_by'] = $group_by; |
|
784 | 784 | } |
785 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
786 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
787 | - $query_parameters[ 'having' ], |
|
785 | + if (isset($query_parameters['having'])) { |
|
786 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
787 | + $query_parameters['having'], |
|
788 | 788 | $model, |
789 | 789 | $this->get_model_version_info()->requested_version() |
790 | 790 | ); |
791 | 791 | } |
792 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
793 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
792 | + if (isset($query_parameters['order'])) { |
|
793 | + $model_query_params['order'] = $query_parameters['order']; |
|
794 | 794 | } |
795 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
796 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
795 | + if (isset($query_parameters['mine'])) { |
|
796 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
797 | 797 | } |
798 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
798 | + if (isset($query_parameters['limit'])) { |
|
799 | 799 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
800 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
801 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
802 | - }else { |
|
803 | - $limit_array = $query_parameters[ 'limit' ]; |
|
800 | + if ( ! is_array($query_parameters['limit'])) { |
|
801 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
802 | + } else { |
|
803 | + $limit_array = $query_parameters['limit']; |
|
804 | 804 | } |
805 | 805 | $sanitized_limit = array(); |
806 | - foreach( $limit_array as $key => $limit_part ) { |
|
807 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
806 | + foreach ($limit_array as $key => $limit_part) { |
|
807 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
808 | 808 | throw new \EE_Error( |
809 | 809 | sprintf( |
810 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
811 | - json_encode( $query_parameters[ 'limit' ] ) |
|
810 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
811 | + json_encode($query_parameters['limit']) |
|
812 | 812 | ) |
813 | 813 | ); |
814 | 814 | } |
815 | - $sanitized_limit[] = (int)$limit_part; |
|
815 | + $sanitized_limit[] = (int) $limit_part; |
|
816 | 816 | } |
817 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
818 | - }else{ |
|
819 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
817 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
818 | + } else { |
|
819 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
820 | 820 | } |
821 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
822 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
823 | - }else{ |
|
824 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
821 | + if (isset($query_parameters['caps'])) { |
|
822 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
823 | + } else { |
|
824 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
825 | 825 | } |
826 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
826 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
838 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
839 | 839 | $model_ready_query_params = array(); |
840 | - foreach( $query_params as $key => $value ) { |
|
841 | - if( is_array( $value ) ) { |
|
842 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
843 | - }else{ |
|
844 | - $model_ready_query_params[ $key ] = $value; |
|
840 | + foreach ($query_params as $key => $value) { |
|
841 | + if (is_array($value)) { |
|
842 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
843 | + } else { |
|
844 | + $model_ready_query_params[$key] = $value; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | return $model_ready_query_params; |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | * @param $query_params |
856 | 856 | * @return array |
857 | 857 | */ |
858 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
858 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
859 | 859 | $model_ready_query_params = array(); |
860 | - foreach( $query_params as $key => $value ) { |
|
861 | - if( is_array( $value ) ) { |
|
862 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
860 | + foreach ($query_params as $key => $value) { |
|
861 | + if (is_array($value)) { |
|
862 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
863 | 863 | } else { |
864 | - $model_ready_query_params[ $key ] = $value; |
|
864 | + $model_ready_query_params[$key] = $value; |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | return $model_ready_query_params; |
@@ -876,33 +876,33 @@ discard block |
||
876 | 876 | * we only return strings starting with that and a period; if no prefix was specified |
877 | 877 | * we return all items containing NO periods |
878 | 878 | */ |
879 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
880 | - if( is_string( $string_to_explode ) ) { |
|
881 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
882 | - } else if( is_array( $string_to_explode ) ) { |
|
879 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
880 | + if (is_string($string_to_explode)) { |
|
881 | + $exploded_contents = explode(',', $string_to_explode); |
|
882 | + } else if (is_array($string_to_explode)) { |
|
883 | 883 | $exploded_contents = $string_to_explode; |
884 | 884 | } else { |
885 | 885 | $exploded_contents = array(); |
886 | 886 | } |
887 | 887 | //if the string was empty, we want an empty array |
888 | - $exploded_contents = array_filter( $exploded_contents ); |
|
888 | + $exploded_contents = array_filter($exploded_contents); |
|
889 | 889 | $contents_with_prefix = array(); |
890 | - foreach( $exploded_contents as $item ) { |
|
891 | - $item = trim( $item ); |
|
890 | + foreach ($exploded_contents as $item) { |
|
891 | + $item = trim($item); |
|
892 | 892 | //if no prefix was provided, so we look for items with no "." in them |
893 | - if( ! $prefix ) { |
|
893 | + if ( ! $prefix) { |
|
894 | 894 | //does this item have a period? |
895 | - if( strpos( $item, '.' ) === false ) { |
|
895 | + if (strpos($item, '.') === false) { |
|
896 | 896 | //if not, then its what we're looking for |
897 | 897 | $contents_with_prefix[] = $item; |
898 | 898 | } |
899 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
899 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
900 | 900 | //this item has the prefix and a period, grab it |
901 | 901 | $contents_with_prefix[] = substr( |
902 | 902 | $item, |
903 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
903 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
904 | 904 | ); |
905 | - } else if( $item === $prefix ) { |
|
905 | + } else if ($item === $prefix) { |
|
906 | 906 | //this item is JUST the prefix |
907 | 907 | //so let's grab everything after, which is a blank string |
908 | 908 | $contents_with_prefix[] = ''; |
@@ -925,33 +925,33 @@ discard block |
||
925 | 925 | * the fields for that model, with the model's name removed from each. |
926 | 926 | * If $include_string was blank or '*' returns an empty array |
927 | 927 | */ |
928 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
929 | - if( is_array( $include_string ) ) { |
|
930 | - $include_string = implode( ',', $include_string ); |
|
928 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
929 | + if (is_array($include_string)) { |
|
930 | + $include_string = implode(',', $include_string); |
|
931 | 931 | } |
932 | - if( $include_string === '*' || $include_string === '' ) { |
|
932 | + if ($include_string === '*' || $include_string === '') { |
|
933 | 933 | return array(); |
934 | 934 | } |
935 | - $includes = explode( ',', $include_string ); |
|
935 | + $includes = explode(',', $include_string); |
|
936 | 936 | $extracted_fields_to_include = array(); |
937 | - if( $model_name ){ |
|
938 | - foreach( $includes as $field_to_include ) { |
|
939 | - $field_to_include = trim( $field_to_include ); |
|
940 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
937 | + if ($model_name) { |
|
938 | + foreach ($includes as $field_to_include) { |
|
939 | + $field_to_include = trim($field_to_include); |
|
940 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
941 | 941 | //found the model name at the exact start |
942 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
942 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
943 | 943 | $extracted_fields_to_include[] = $field_sans_model_name; |
944 | - }elseif( $field_to_include == $model_name ){ |
|
944 | + }elseif ($field_to_include == $model_name) { |
|
945 | 945 | $extracted_fields_to_include[] = '*'; |
946 | 946 | } |
947 | 947 | } |
948 | - }else{ |
|
948 | + } else { |
|
949 | 949 | //look for ones with no period |
950 | - foreach( $includes as $field_to_include ) { |
|
951 | - $field_to_include = trim( $field_to_include ); |
|
950 | + foreach ($includes as $field_to_include) { |
|
951 | + $field_to_include = trim($field_to_include); |
|
952 | 952 | if ( |
953 | - strpos( $field_to_include, '.' ) === false |
|
954 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
953 | + strpos($field_to_include, '.') === false |
|
954 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
955 | 955 | ) { |
956 | 956 | $extracted_fields_to_include[] = $field_to_include; |
957 | 957 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | */ |
44 | 44 | |
45 | -if ( function_exists( 'espresso_version' ) ) { |
|
45 | +if (function_exists('espresso_version')) { |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * espresso_duplicate_plugin_error |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function espresso_duplicate_plugin_error() { |
52 | 52 | ?> |
53 | 53 | <div class="error"> |
54 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
54 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
55 | 55 | </div> |
56 | 56 | <?php |
57 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
57 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
58 | 58 | } |
59 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
59 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
@@ -67,103 +67,103 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | */ |
69 | 69 | function espresso_version() { |
70 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.9.rc.011' ); |
|
70 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.9.rc.011'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // define versions |
74 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
75 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
76 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
77 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
78 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
79 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
80 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
74 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
75 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
76 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
77 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
78 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
79 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
80 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
81 | 81 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
82 | - if ( ! defined( 'DS' ) ) { |
|
83 | - define( 'DS', '/' ); |
|
82 | + if ( ! defined('DS')) { |
|
83 | + define('DS', '/'); |
|
84 | 84 | } |
85 | - if ( ! defined( 'PS' ) ) { |
|
86 | - define( 'PS', PATH_SEPARATOR ); |
|
85 | + if ( ! defined('PS')) { |
|
86 | + define('PS', PATH_SEPARATOR); |
|
87 | 87 | } |
88 | - if ( ! defined( 'SP' ) ) { |
|
89 | - define( 'SP', ' ' ); |
|
88 | + if ( ! defined('SP')) { |
|
89 | + define('SP', ' '); |
|
90 | 90 | } |
91 | - if ( ! defined( 'EENL' ) ) { |
|
92 | - define( 'EENL', "\n" ); |
|
91 | + if ( ! defined('EENL')) { |
|
92 | + define('EENL', "\n"); |
|
93 | 93 | } |
94 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
94 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
95 | 95 | // define the plugin directory and URL |
96 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
98 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
99 | 99 | // main root folder paths |
100 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
101 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
102 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
103 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
104 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
105 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
106 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
107 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
100 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
101 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
102 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
103 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
104 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
105 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
106 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
107 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
108 | 108 | // core system paths |
109 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
110 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
111 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
112 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
113 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
114 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
115 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
116 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
117 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
118 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
119 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
120 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
109 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
110 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
111 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
112 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
113 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
114 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
115 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
116 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
117 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
118 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
119 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
120 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
121 | 121 | // gateways |
122 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
123 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
122 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
123 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
124 | 124 | // asset URL paths |
125 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
126 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
127 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
128 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
129 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
130 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
125 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
126 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
127 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
128 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
129 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
130 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
131 | 131 | // define upload paths |
132 | 132 | $uploads = wp_upload_dir(); |
133 | 133 | // define the uploads directory and URL |
134 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
135 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
135 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
136 | 136 | // define the templates directory and URL |
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
138 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
138 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
139 | 139 | // define the gateway directory and URL |
140 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
141 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
142 | 142 | // languages folder/path |
143 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
144 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
143 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
144 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
145 | 145 | //check for dompdf fonts in uploads |
146 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
147 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
146 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
147 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
148 | 148 | } |
149 | 149 | //ajax constants |
150 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
151 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
150 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
151 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
152 | 152 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
153 | 153 | //you're better to use this than its straight value (currently -1) in case you ever |
154 | 154 | //want to change its default value! or find when -1 means infinity |
155 | - define( 'EE_INF_IN_DB', -1 ); |
|
156 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
157 | - define( 'EE_DEBUG', false ); |
|
155 | + define('EE_INF_IN_DB', -1); |
|
156 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
157 | + define('EE_DEBUG', false); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * espresso_plugin_activation |
161 | 161 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
162 | 162 | */ |
163 | 163 | function espresso_plugin_activation() { |
164 | - update_option( 'ee_espresso_activation', true ); |
|
164 | + update_option('ee_espresso_activation', true); |
|
165 | 165 | } |
166 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
166 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
167 | 167 | |
168 | 168 | |
169 | 169 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // } |
178 | 178 | // |
179 | 179 | } |
180 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
180 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
181 | 181 | |
182 | 182 | |
183 | 183 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function espresso_load_error_handling() { |
189 | 189 | // load debugging tools |
190 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
191 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
190 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
191 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
192 | 192 | EEH_Debug_Tools::instance(); |
193 | 193 | } |
194 | 194 | // load error handling |
195 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
196 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
195 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
196 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
197 | 197 | } else { |
198 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
198 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | * @param string $full_path_to_file |
210 | 210 | * @throws EE_Error |
211 | 211 | */ |
212 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
212 | + function espresso_load_required($classname, $full_path_to_file) { |
|
213 | 213 | static $error_handling_loaded = false; |
214 | - if ( ! $error_handling_loaded ) { |
|
214 | + if ( ! $error_handling_loaded) { |
|
215 | 215 | espresso_load_error_handling(); |
216 | 216 | $error_handling_loaded = true; |
217 | 217 | } |
218 | - if ( is_readable( $full_path_to_file ) ) { |
|
219 | - require_once( $full_path_to_file ); |
|
218 | + if (is_readable($full_path_to_file)) { |
|
219 | + require_once($full_path_to_file); |
|
220 | 220 | } else { |
221 | - throw new EE_Error ( sprintf( |
|
222 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
221 | + throw new EE_Error(sprintf( |
|
222 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
223 | 223 | $classname |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
229 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
230 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
228 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
229 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
230 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
231 | 231 | new EE_Bootstrap(); |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | |
238 | 238 | |
239 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
239 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
240 | 240 | /** |
241 | 241 | * deactivate_plugin |
242 | 242 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
249 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
250 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
248 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
249 | + if ( ! function_exists('deactivate_plugins')) { |
|
250 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
251 | 251 | } |
252 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
253 | - deactivate_plugins( $plugin_basename ); |
|
252 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
253 | + deactivate_plugins($plugin_basename); |
|
254 | 254 | } |
255 | 255 | } |
@@ -56,26 +56,26 @@ discard block |
||
56 | 56 | * @param bool $routing |
57 | 57 | * @return Registrations_Admin_Page |
58 | 58 | */ |
59 | - public function __construct( $routing = TRUE ) { |
|
60 | - parent::__construct( $routing ); |
|
61 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' )); |
|
59 | + public function __construct($routing = TRUE) { |
|
60 | + parent::__construct($routing); |
|
61 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | 66 | public function wp_loaded() { |
67 | 67 | // when adding a new registration... |
68 | - if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) { |
|
68 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') { |
|
69 | 69 | EE_System::do_not_cache(); |
70 | 70 | if ( |
71 | - ! isset( $this->_req_data[ 'processing_registration' ] ) |
|
72 | - || absint( $this->_req_data[ 'processing_registration' ] ) !== 1 |
|
71 | + ! isset($this->_req_data['processing_registration']) |
|
72 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
73 | 73 | ) { |
74 | 74 | // and it's NOT the attendee information reg step |
75 | 75 | // force cookie expiration by setting time to last week |
76 | - setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' ); |
|
76 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
77 | 77 | // and update the global |
78 | - $_COOKIE[ 'ee_registration_added' ] = 0; |
|
78 | + $_COOKIE['ee_registration_added'] = 0; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | 'trash' => 'post.php' |
110 | 110 | ); |
111 | 111 | |
112 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 ); |
|
112 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
113 | 113 | //add filters so that the comment urls don't take users to a confusing 404 page |
114 | - add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 ); |
|
114 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | - public function clear_comment_link( $link, $comment, $args ) { |
|
118 | + public function clear_comment_link($link, $comment, $args) { |
|
119 | 119 | //gotta make sure this only happens on this route |
120 | - $post_type = get_post_type( $comment->comment_post_ID); |
|
121 | - if ( $post_type == 'espresso_attendees' ) |
|
120 | + $post_type = get_post_type($comment->comment_post_ID); |
|
121 | + if ($post_type == 'espresso_attendees') |
|
122 | 122 | return '#commentsdiv'; |
123 | 123 | return $link; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | protected function _ajax_hooks() { |
128 | 128 | //todo: all hooks for registrations ajax goes in here |
129 | - add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' )); |
|
129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | 'add-attendee' => __('Add Contact', 'event_espresso'), |
142 | 142 | 'edit' => __('Edit Contact', 'event_espresso'), |
143 | 143 | 'report'=> __("Event Registrations CSV Report", "event_espresso"), |
144 | - 'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ), |
|
145 | - 'contact_list_report' => __( 'Contact List Report', 'event_espresso' ), |
|
144 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
145 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
146 | 146 | 'contact_list_export'=> __("Export Data", "event_espresso"), |
147 | 147 | ), |
148 | 148 | 'publishbox' => array( |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | |
171 | 171 | $this->_get_registration_status_array(); |
172 | 172 | |
173 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
|
174 | - $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0; |
|
175 | - $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
|
173 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0; |
|
174 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0; |
|
175 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id; |
|
176 | 176 | |
177 | 177 | $this->_page_routes = array( |
178 | 178 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | 'restore_registrations' => array( |
207 | 207 | 'func' => '_trash_or_restore_registrations', |
208 | - 'args' => array( 'trash' => FALSE ), |
|
208 | + 'args' => array('trash' => FALSE), |
|
209 | 209 | 'noheader' => TRUE, |
210 | 210 | 'capability' => 'ee_delete_registrations' |
211 | 211 | ), |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'filename' => 'registrations_overview_other' |
439 | 439 | ) |
440 | 440 | ), |
441 | - 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
|
441 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
442 | 442 | 'qtips' => array('Registration_List_Table_Tips'), |
443 | 443 | 'list_table' => 'EE_Registrations_List_Table', |
444 | 444 | 'require_nonce' => FALSE |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | 'order' => 15, |
451 | 451 | 'url' => isset($this->_req_data['_REG_ID']) |
452 | 452 | ? add_query_arg( |
453 | - array('_REG_ID' => $this->_req_data['_REG_ID'] ), |
|
453 | + array('_REG_ID' => $this->_req_data['_REG_ID']), |
|
454 | 454 | $this->_current_page_view_url |
455 | 455 | ) |
456 | 456 | : $this->_admin_base_url, |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | 'filename' => 'registrations_details_registrant_details' |
475 | 475 | ) |
476 | 476 | ), |
477 | - 'help_tour' => array( 'Registration_Details_Help_Tour' ), |
|
478 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ), |
|
477 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
478 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')), |
|
479 | 479 | 'require_nonce' => FALSE |
480 | 480 | ), |
481 | 481 | |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | 'order' => 15, |
500 | 500 | 'persistent' => FALSE |
501 | 501 | ), |
502 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ), |
|
502 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
503 | 503 | 'require_nonce' => FALSE |
504 | 504 | ), |
505 | 505 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | 'label' => __('Edit Contact', 'event_espresso'), |
509 | 509 | 'order' => 15, |
510 | 510 | 'persistent' => FALSE, |
511 | - 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
511 | + 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
512 | 512 | ), |
513 | 513 | 'metaboxes' => array('attendee_editor_metaboxes'), |
514 | 514 | 'require_nonce' => FALSE |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | 'filename' => 'registrations_contact_list_other' |
539 | 539 | ) |
540 | 540 | ), |
541 | - 'help_tour' => array( 'Contact_List_Help_Tour' ), |
|
541 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
542 | 542 | 'metaboxes' => array(), |
543 | 543 | 'require_nonce' => FALSE |
544 | 544 | ), |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | protected function _add_screen_options() {} |
558 | 558 | protected function _add_feature_pointers() {} |
559 | 559 | public function admin_init() { |
560 | - EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' ); |
|
560 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso'); |
|
561 | 561 | } |
562 | 562 | public function admin_notices() {} |
563 | 563 | public function admin_footer_scripts() {} |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @return void |
576 | 576 | */ |
577 | 577 | private function _get_registration_status_array() { |
578 | - self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
|
578 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | public function load_scripts_styles() { |
599 | 599 | //style |
600 | 600 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
601 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
601 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
602 | 602 | wp_enqueue_style('espresso_reg'); |
603 | 603 | |
604 | 604 | //script |
605 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
605 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
606 | 606 | wp_enqueue_script('espresso_reg'); |
607 | 607 | } |
608 | 608 | |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | public function load_scripts_styles_edit_attendee() { |
612 | 612 | //stuff to only show up on our attendee edit details page. |
613 | 613 | $attendee_details_translations = array( |
614 | - 'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') ) |
|
614 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created')) |
|
615 | 615 | ); |
616 | - wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations ); |
|
616 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
617 | 617 | wp_enqueue_script('jquery-validate'); |
618 | 618 | } |
619 | 619 | |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | //styles |
623 | 623 | wp_enqueue_style('espresso-ui-theme'); |
624 | 624 | //scripts |
625 | - $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
626 | - $this->_reg_custom_questions_form->wp_enqueue_scripts( true ); |
|
625 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
626 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | public function load_scripts_styles_contact_list() { |
635 | 635 | wp_deregister_style('espresso_reg'); |
636 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
636 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
637 | 637 | wp_enqueue_style('espresso_att'); |
638 | 638 | } |
639 | 639 | |
@@ -642,9 +642,9 @@ discard block |
||
642 | 642 | |
643 | 643 | |
644 | 644 | public function load_scripts_styles_new_registration() { |
645 | - wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
645 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
646 | 646 | wp_enqueue_script('ee-spco-for-admin'); |
647 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
647 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
648 | 648 | EE_Form_Section_Proper::wp_enqueue_scripts(); |
649 | 649 | EED_Ticket_Selector::load_tckt_slctr_assets(); |
650 | 650 | EE_Datepicker_Input::enqueue_styles_and_scripts(); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | //for notification related bulk actions we need to make sure only active messengers have an option. |
672 | 672 | EED_Messages::set_autoloaders(); |
673 | 673 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
674 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
674 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
675 | 675 | $active_mts = $message_resource_manager->list_of_active_message_types(); |
676 | 676 | //key= bulk_action_slug, value= message type. |
677 | 677 | $match_array = array( |
@@ -684,23 +684,23 @@ discard block |
||
684 | 684 | |
685 | 685 | /** setup reg status bulk actions **/ |
686 | 686 | $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
687 | - if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
687 | + if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
688 | 688 | $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso'); |
689 | 689 | } |
690 | 690 | $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
691 | - if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
691 | + if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
692 | 692 | $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso'); |
693 | 693 | } |
694 | 694 | $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
695 | - if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
695 | + if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
696 | 696 | $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso'); |
697 | 697 | } |
698 | 698 | $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
699 | - if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
699 | + if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
700 | 700 | $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso'); |
701 | 701 | } |
702 | 702 | $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
703 | - if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
703 | + if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
704 | 704 | $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso'); |
705 | 705 | } |
706 | 706 | |
@@ -709,29 +709,29 @@ discard block |
||
709 | 709 | 'slug' => 'all', |
710 | 710 | 'label' => __('View All Registrations', 'event_espresso'), |
711 | 711 | 'count' => 0, |
712 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
712 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
713 | 713 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
714 | - ) ) |
|
714 | + )) |
|
715 | 715 | ), |
716 | 716 | 'month' => array( |
717 | 717 | 'slug' => 'month', |
718 | 718 | 'label' => __('This Month', 'event_espresso'), |
719 | 719 | 'count' => 0, |
720 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
720 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
721 | 721 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
722 | 722 | )) |
723 | 723 | ), |
724 | 724 | 'today' => array( |
725 | 725 | 'slug' => 'today', |
726 | - 'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ), |
|
726 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
727 | 727 | 'count' => 0, |
728 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
728 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
729 | 729 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
730 | 730 | )) |
731 | 731 | ) |
732 | 732 | ); |
733 | 733 | |
734 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) { |
|
734 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) { |
|
735 | 735 | $this->_views['incomplete'] = array( |
736 | 736 | 'slug' => 'incomplete', |
737 | 737 | 'label' => __('Incomplete', 'event_espresso'), |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | ) |
768 | 768 | ); |
769 | 769 | |
770 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) { |
|
770 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) { |
|
771 | 771 | $this->_views['trash'] = array( |
772 | 772 | 'slug' => 'trash', |
773 | 773 | 'label' => __('Trash', 'event_espresso'), |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | 'desc' => __('View Transaction Invoice', 'event_espresso') |
807 | 807 | ), |
808 | 808 | ); |
809 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
|
809 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) { |
|
810 | 810 | $fc_items['resend_registration'] = array( |
811 | 811 | 'class' => 'dashicons dashicons-email-alt', |
812 | 812 | 'desc' => __('Resend Registration Details', 'event_espresso') |
813 | 813 | ); |
814 | 814 | } else { |
815 | - $fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' ); |
|
815 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
816 | 816 | } |
817 | 817 | |
818 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
819 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
820 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
818 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
819 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
820 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
821 | 821 | $fc_items['view_related_messages'] = array( |
822 | 822 | 'class' => $related_for_icon['css_class'], |
823 | 823 | 'desc' => $related_for_icon['label'], |
@@ -827,35 +827,35 @@ discard block |
||
827 | 827 | |
828 | 828 | $sc_items = array( |
829 | 829 | 'approved_status' => array( |
830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
831 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
|
830 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
831 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') |
|
832 | 832 | ), |
833 | 833 | 'pending_status' => array( |
834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
835 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
|
834 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
835 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') |
|
836 | 836 | ), |
837 | 837 | 'wait_list' => array( |
838 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
839 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) |
|
838 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
839 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') |
|
840 | 840 | ), |
841 | 841 | 'incomplete_status' => array( |
842 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
843 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' ) |
|
842 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
843 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence') |
|
844 | 844 | ), |
845 | 845 | 'not_approved' => array( |
846 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
847 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
|
846 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
847 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') |
|
848 | 848 | ), |
849 | 849 | 'declined_status' => array( |
850 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
851 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
|
850 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
851 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence') |
|
852 | 852 | ), |
853 | 853 | 'cancelled_status' => array( |
854 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
855 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
|
854 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
855 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence') |
|
856 | 856 | ) |
857 | 857 | ); |
858 | - return array_merge( $fc_items, $sc_items ); |
|
858 | + return array_merge($fc_items, $sc_items); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
@@ -869,9 +869,9 @@ discard block |
||
869 | 869 | */ |
870 | 870 | protected function _registrations_overview_list_table() { |
871 | 871 | $this->_template_args['admin_page_header'] = ''; |
872 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0; |
|
873 | - if ( $EVT_ID ) { |
|
874 | - if ( EE_Registry::instance()->CAP->current_user_can( |
|
872 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
873 | + if ($EVT_ID) { |
|
874 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
875 | 875 | 'ee_edit_registrations', |
876 | 876 | 'espresso_registrations_new_registration', |
877 | 877 | $EVT_ID |
@@ -880,34 +880,34 @@ discard block |
||
880 | 880 | $this->_admin_page_title .= $this->get_action_link_or_button( |
881 | 881 | 'new_registration', |
882 | 882 | 'add-registrant', |
883 | - array( 'event_id' => $EVT_ID ), |
|
883 | + array('event_id' => $EVT_ID), |
|
884 | 884 | 'add-new-h2' |
885 | 885 | ); |
886 | 886 | } |
887 | - $event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
888 | - if ( $event instanceof EE_Event ) { |
|
887 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
888 | + if ($event instanceof EE_Event) { |
|
889 | 889 | $this->_template_args['admin_page_header'] = sprintf( |
890 | - __( '%s Viewing registrations for the event: %s%s', 'event_espresso' ), |
|
890 | + __('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
891 | 891 | '<h3 style="line-height:1.5em;">', |
892 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
893 | - array( 'action' => 'edit', 'post' => $event->ID() ), |
|
892 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
893 | + array('action' => 'edit', 'post' => $event->ID()), |
|
894 | 894 | EVENTS_ADMIN_URL |
895 | - ) . '"> ' . $event->get( 'EVT_name' ) . ' </a> ', |
|
895 | + ).'"> '.$event->get('EVT_name').' </a> ', |
|
896 | 896 | '</h3>' |
897 | 897 | ); |
898 | 898 | } |
899 | - $DTT_ID = ! empty( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : 0; |
|
900 | - $datetime = EEM_Datetime::instance()->get_one_by_ID( $DTT_ID ); |
|
901 | - if ( $datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '' ) { |
|
902 | - $this->_template_args['admin_page_header'] = substr( $this->_template_args['admin_page_header'], 0, -5 ); |
|
899 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
900 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
901 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
902 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
903 | 903 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
904 | 904 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
905 | 905 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
906 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
906 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
907 | 907 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
908 | 908 | } |
909 | 909 | } |
910 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() ); |
|
910 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
911 | 911 | $this->display_admin_list_table_page_with_no_sidebar(); |
912 | 912 | } |
913 | 913 | |
@@ -922,19 +922,19 @@ discard block |
||
922 | 922 | */ |
923 | 923 | private function _set_registration_object() { |
924 | 924 | //get out if we've already set the object |
925 | - if ( is_object( $this->_registration )) { |
|
925 | + if (is_object($this->_registration)) { |
|
926 | 926 | return TRUE; |
927 | 927 | } |
928 | 928 | |
929 | 929 | $REG = EEM_Registration::instance(); |
930 | 930 | |
931 | - $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
931 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
932 | 932 | |
933 | - if ( $this->_registration = $REG->get_one_by_ID( $REG_ID )) |
|
933 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) |
|
934 | 934 | return TRUE; |
935 | 935 | else { |
936 | - $error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID ); |
|
937 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
936 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID); |
|
937 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
938 | 938 | $this->_registration = NULL; |
939 | 939 | return FALSE; |
940 | 940 | } |
@@ -952,25 +952,25 @@ discard block |
||
952 | 952 | * @throws \EE_Error |
953 | 953 | * @return mixed (int|array) int = count || array of registration objects |
954 | 954 | */ |
955 | - public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) { |
|
956 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
957 | - $CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE; |
|
958 | - $DTT_ID = isset( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : null; |
|
959 | - $reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE; |
|
960 | - $month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april |
|
961 | - $today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
962 | - $this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
955 | + public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) { |
|
956 | + $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE; |
|
957 | + $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE; |
|
958 | + $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
|
959 | + $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE; |
|
960 | + $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april |
|
961 | + $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
962 | + $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
963 | 963 | $start_date = FALSE; |
964 | 964 | $end_date = FALSE; |
965 | 965 | $_where = array(); |
966 | - $trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
967 | - $incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
966 | + $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
967 | + $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
968 | 968 | |
969 | 969 | //set orderby |
970 | 970 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
971 | 971 | |
972 | 972 | |
973 | - switch ( $this->_req_data['orderby'] ) { |
|
973 | + switch ($this->_req_data['orderby']) { |
|
974 | 974 | case '_REG_ID': |
975 | 975 | $orderby = 'REG_ID'; |
976 | 976 | break; |
@@ -990,30 +990,30 @@ discard block |
||
990 | 990 | $orderby = 'REG_date'; |
991 | 991 | } |
992 | 992 | |
993 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
994 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
995 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
993 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
994 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
995 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
996 | 996 | |
997 | 997 | |
998 | - $offset = ($current_page-1)*$per_page; |
|
999 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
998 | + $offset = ($current_page - 1) * $per_page; |
|
999 | + $limit = $count ? NULL : array($offset, $per_page); |
|
1000 | 1000 | |
1001 | - if($EVT_ID){ |
|
1002 | - $_where['EVT_ID']=$EVT_ID; |
|
1001 | + if ($EVT_ID) { |
|
1002 | + $_where['EVT_ID'] = $EVT_ID; |
|
1003 | 1003 | } |
1004 | - if($CAT_ID){ |
|
1004 | + if ($CAT_ID) { |
|
1005 | 1005 | $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
1006 | 1006 | } |
1007 | 1007 | //if DTT is included we filter by that datetime. |
1008 | - if ( $DTT_ID ) { |
|
1008 | + if ($DTT_ID) { |
|
1009 | 1009 | $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
1010 | 1010 | } |
1011 | - if ( $incomplete ) { |
|
1011 | + if ($incomplete) { |
|
1012 | 1012 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
1013 | 1013 | } else if ( ! $trash) { |
1014 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
1014 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
1015 | 1015 | } |
1016 | - if($reg_status){ |
|
1016 | + if ($reg_status) { |
|
1017 | 1017 | $_where['STS_ID'] = $reg_status; |
1018 | 1018 | } |
1019 | 1019 | |
@@ -1025,103 +1025,103 @@ discard block |
||
1025 | 1025 | $time_start = ' 00:00:00'; |
1026 | 1026 | $time_end = ' 23:59:59'; |
1027 | 1027 | |
1028 | - if($today_a || $today ){ |
|
1028 | + if ($today_a || $today) { |
|
1029 | 1029 | $curdate = date('Y-m-d', current_time('timestamp')); |
1030 | - $_where['REG_date']= array('BETWEEN', |
|
1030 | + $_where['REG_date'] = array('BETWEEN', |
|
1031 | 1031 | array( |
1032 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ), |
|
1033 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ), |
|
1032 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'), |
|
1033 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'), |
|
1034 | 1034 | )); |
1035 | - }elseif($this_month_a || $this_month){ |
|
1035 | + }elseif ($this_month_a || $this_month) { |
|
1036 | 1036 | $this_month_r = date('m', current_time('timestamp')); |
1037 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
1038 | - $_where['REG_date']= array('BETWEEN', |
|
1037 | + $days_this_month = date('t', current_time('timestamp')); |
|
1038 | + $_where['REG_date'] = array('BETWEEN', |
|
1039 | 1039 | array( |
1040 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ), |
|
1041 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ) |
|
1040 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'), |
|
1041 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s') |
|
1042 | 1042 | )); |
1043 | - }elseif($month_range){ |
|
1043 | + }elseif ($month_range) { |
|
1044 | 1044 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1045 | - $month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : ''; |
|
1046 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1047 | - $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01') ); |
|
1048 | - $_where['REG_date']= array('BETWEEN', |
|
1049 | - array( EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s' ) ) ); |
|
1050 | - }elseif($start_date && $end_date){ |
|
1045 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
|
1046 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1047 | + $days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01')); |
|
1048 | + $_where['REG_date'] = array('BETWEEN', |
|
1049 | + array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s'))); |
|
1050 | + }elseif ($start_date && $end_date) { |
|
1051 | 1051 | throw new EE_Error("not yet supported"); |
1052 | - }elseif($start_date){ |
|
1052 | + }elseif ($start_date) { |
|
1053 | 1053 | throw new EE_Error("not yet supported"); |
1054 | - }elseif($end_date){ |
|
1054 | + }elseif ($end_date) { |
|
1055 | 1055 | throw new EE_Error("not yet supported"); |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
1059 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1058 | + if ( ! empty($this->_req_data['s'])) { |
|
1059 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1060 | 1060 | $_where['OR'] = array( |
1061 | - 'Event.EVT_name' => array( 'LIKE', $sstr), |
|
1062 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
1063 | - 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
1064 | - 'Attendee.ATT_full_name' => array( 'LIKE', $sstr ), |
|
1065 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
1066 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
1067 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
1068 | - 'Attendee.ATT_email' => array('LIKE', $sstr ), |
|
1069 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
1070 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
1071 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
1072 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
1073 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
1074 | - 'REG_count' => array( 'LIKE' , $sstr ), |
|
1075 | - 'REG_group_size' => array( 'LIKE' , $sstr ), |
|
1076 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
1077 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
|
1078 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr ) |
|
1061 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1062 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1063 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
1064 | + 'Attendee.ATT_full_name' => array('LIKE', $sstr), |
|
1065 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
1066 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
1067 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
1068 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
1069 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
1070 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
1071 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
1072 | + 'REG_final_price' => array('LIKE', $sstr), |
|
1073 | + 'REG_code' => array('LIKE', $sstr), |
|
1074 | + 'REG_count' => array('LIKE', $sstr), |
|
1075 | + 'REG_group_size' => array('LIKE', $sstr), |
|
1076 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1077 | + 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
1078 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr) |
|
1079 | 1079 | ); |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | //capability checks |
1083 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) { |
|
1083 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) { |
|
1084 | 1084 | $_where['AND'] = array( |
1085 | 1085 | 'Event.EVT_wp_user' => get_current_user_id() |
1086 | 1086 | ); |
1087 | 1087 | } |
1088 | 1088 | |
1089 | - if( $count ){ |
|
1090 | - if ( $trash ) { |
|
1091 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
1092 | - } else if ( $incomplete ) { |
|
1093 | - return EEM_Registration::instance()->count( array( $_where )); |
|
1089 | + if ($count) { |
|
1090 | + if ($trash) { |
|
1091 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
1092 | + } else if ($incomplete) { |
|
1093 | + return EEM_Registration::instance()->count(array($_where)); |
|
1094 | 1094 | } else { |
1095 | - return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' )); |
|
1095 | + return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only')); |
|
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | 1098 | //make sure we remove default where conditions cause all registrations matching query are returned |
1099 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' ); |
|
1100 | - if ( $per_page !== -1 ) { |
|
1099 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only'); |
|
1100 | + if ($per_page !== -1) { |
|
1101 | 1101 | $query_params['limit'] = $limit; |
1102 | 1102 | } |
1103 | - $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
1103 | + $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
1104 | 1104 | |
1105 | - if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
1105 | + if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
1106 | 1106 | $first_registration = $registrations[0]; |
1107 | 1107 | //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
1108 | 1108 | $event_name = $first_registration->event_obj()->name(); |
1109 | - $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1109 | + $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1110 | 1110 | // edit event link |
1111 | - if ( $event_name != '' ) { |
|
1112 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
|
1113 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
1114 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
1111 | + if ($event_name != '') { |
|
1112 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL); |
|
1113 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
1114 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
|
1118 | - $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
1117 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL); |
|
1118 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
1119 | 1119 | |
1120 | 1120 | $this->_template_args['before_admin_page_content'] = ' |
1121 | 1121 | <div id="admin-page-header"> |
1122 | - <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
|
1123 | - <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
|
1124 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
1122 | + <h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
1123 | + <h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
1124 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
1125 | 1125 | </div> |
1126 | 1126 | '; |
1127 | 1127 | |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | $this->_set_registration_object(); |
1161 | 1161 | |
1162 | - if ( is_object( $this->_registration )) { |
|
1162 | + if (is_object($this->_registration)) { |
|
1163 | 1163 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1164 | 1164 | $this->_session = $transaction->session_data(); |
1165 | 1165 | |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | |
1169 | 1169 | $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
1170 | - $this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' ); |
|
1170 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
1171 | 1171 | |
1172 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime( 'REG_date' ); |
|
1173 | - $this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' ); |
|
1172 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
1173 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
1174 | 1174 | |
1175 | 1175 | $this->_template_args['grand_total'] = $transaction->total(); |
1176 | 1176 | |
@@ -1178,19 +1178,19 @@ discard block |
||
1178 | 1178 | // link back to overview |
1179 | 1179 | $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
1180 | 1180 | $this->_template_args['registration'] = $this->_registration; |
1181 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL ); |
|
1182 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) ); |
|
1183 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) ); |
|
1181 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL); |
|
1182 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php')); |
|
1183 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php')); |
|
1184 | 1184 | |
1185 | 1185 | //next and previous links |
1186 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID' ); |
|
1187 | - $this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : ''; |
|
1188 | - $previous_reg = $this->_registration->previous( null, array(), 'REG_ID' ); |
|
1189 | - $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : ''; |
|
1186 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
1187 | + $this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
1188 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
1189 | + $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
1190 | 1190 | |
1191 | 1191 | // grab header |
1192 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
1193 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1192 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
1193 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1194 | 1194 | |
1195 | 1195 | } else { |
1196 | 1196 | |
@@ -1209,17 +1209,17 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | |
1211 | 1211 | protected function _registration_details_metaboxes() { |
1212 | - do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this ); |
|
1212 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
1213 | 1213 | $this->_set_registration_object(); |
1214 | 1214 | $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
1215 | - add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1216 | - add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1217 | - if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) { |
|
1218 | - add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1215 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
1216 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1217 | + if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) { |
|
1218 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1219 | 1219 | } |
1220 | - add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' ); |
|
1221 | - if ( $this->_registration->group_size() > 1 ) { |
|
1222 | - add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1220 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
1221 | + if ($this->_registration->group_size() > 1) { |
|
1222 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1223 | 1223 | } |
1224 | 1224 | } |
1225 | 1225 | |
@@ -1238,22 +1238,22 @@ discard block |
||
1238 | 1238 | $is_complete = $this->_registration->transaction()->is_completed(); |
1239 | 1239 | //let's get an array of all possible buttons that we can just reference |
1240 | 1240 | $status_buttons = $this->_get_reg_status_buttons(); |
1241 | - $template_args[ 'reg_status_value' ] = $this->_registration->pretty_status(); |
|
1242 | - $template_args[ 'reg_status_class' ] = 'status-' . $this->_registration->status_ID(); |
|
1241 | + $template_args['reg_status_value'] = $this->_registration->pretty_status(); |
|
1242 | + $template_args['reg_status_class'] = 'status-'.$this->_registration->status_ID(); |
|
1243 | 1243 | $template_args['attendee'] = $this->_registration->attendee(); |
1244 | - $template = REG_TEMPLATE_PATH . 'reg_status_change_buttons.template.php'; |
|
1245 | - if ( $this->_set_registration_object() ) { |
|
1244 | + $template = REG_TEMPLATE_PATH.'reg_status_change_buttons.template.php'; |
|
1245 | + if ($this->_set_registration_object()) { |
|
1246 | 1246 | $current_status = $this->_registration->status_ID(); |
1247 | - unset( $status_buttons[$current_status] ); |
|
1248 | - if ( $current_status != EEM_Registration::status_id_pending_payment && $is_complete ) { |
|
1249 | - unset( $status_buttons[EEM_Registration::status_id_pending_payment] ); |
|
1247 | + unset($status_buttons[$current_status]); |
|
1248 | + if ($current_status != EEM_Registration::status_id_pending_payment && $is_complete) { |
|
1249 | + unset($status_buttons[EEM_Registration::status_id_pending_payment]); |
|
1250 | 1250 | } |
1251 | - $template_args['status_buttons'] = implode( "\n", $status_buttons ); |
|
1251 | + $template_args['status_buttons'] = implode("\n", $status_buttons); |
|
1252 | 1252 | } |
1253 | 1253 | $template_args['form_url'] = REG_ADMIN_URL; |
1254 | 1254 | $template_args['REG_ID'] = $this->_registration->ID(); |
1255 | - $template_args['nonce'] = wp_nonce_field( 'change_reg_status_nonce', 'change_reg_status_nonce', FALSE, FALSE ); |
|
1256 | - EEH_Template::display_template( $template, $template_args ); |
|
1255 | + $template_args['nonce'] = wp_nonce_field('change_reg_status_nonce', 'change_reg_status_nonce', FALSE, FALSE); |
|
1256 | + EEH_Template::display_template($template, $template_args); |
|
1257 | 1257 | |
1258 | 1258 | } |
1259 | 1259 | |
@@ -1267,11 +1267,11 @@ discard block |
||
1267 | 1267 | private function _get_reg_status_buttons() { |
1268 | 1268 | |
1269 | 1269 | $buttons = array( |
1270 | - EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) . '">', |
|
1271 | - EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_pending_payment . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) . '">', |
|
1272 | - EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_not_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) . '">', |
|
1273 | - EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_declined . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) . '">', |
|
1274 | - EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_cancelled . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) . '">', |
|
1270 | + EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence').'">', |
|
1271 | + EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_pending_payment.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence').'">', |
|
1272 | + EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_not_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence').'">', |
|
1273 | + EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_declined.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence').'">', |
|
1274 | + EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_cancelled.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence').'">', |
|
1275 | 1275 | ); |
1276 | 1276 | return $buttons; |
1277 | 1277 | } |
@@ -1285,13 +1285,13 @@ discard block |
||
1285 | 1285 | * |
1286 | 1286 | * @return array (array with reg_id(s) updated and whether update was successful. |
1287 | 1287 | */ |
1288 | - protected function _set_registration_status_from_request( $status = false, $notify = false ) { |
|
1289 | - $REG_ID = isset( $this->_req_data['_REG_ID'] ) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
1288 | + protected function _set_registration_status_from_request($status = false, $notify = false) { |
|
1289 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
1290 | 1290 | |
1291 | - $success = $this->_set_registration_status( $REG_ID, $status ); |
|
1291 | + $success = $this->_set_registration_status($REG_ID, $status); |
|
1292 | 1292 | |
1293 | 1293 | //notify? |
1294 | - if ( $success && $notify && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
|
1294 | + if ($success && $notify && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) { |
|
1295 | 1295 | $this->_process_resend_registration(); |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1309,19 +1309,19 @@ discard block |
||
1309 | 1309 | * @param bool $status |
1310 | 1310 | * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations). |
1311 | 1311 | */ |
1312 | - protected function _set_registration_status( $REG_ID, $status = false ) { |
|
1312 | + protected function _set_registration_status($REG_ID, $status = false) { |
|
1313 | 1313 | $success = true; |
1314 | 1314 | // set default status if none is passed |
1315 | 1315 | $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
1316 | 1316 | |
1317 | 1317 | //typecast and sanitize reg_id |
1318 | - $reg_ids = array_filter( (array) $REG_ID, 'absint' ); |
|
1318 | + $reg_ids = array_filter((array) $REG_ID, 'absint'); |
|
1319 | 1319 | |
1320 | 1320 | //loop through REG_ID's and change status |
1321 | - foreach ( $reg_ids as $r_id ) { |
|
1322 | - $registration = EEM_Registration::instance()->get_one_by_ID( $r_id ); |
|
1323 | - if ( $registration instanceof EE_Registration ) { |
|
1324 | - $registration->set_status( $status ); |
|
1321 | + foreach ($reg_ids as $r_id) { |
|
1322 | + $registration = EEM_Registration::instance()->get_one_by_ID($r_id); |
|
1323 | + if ($registration instanceof EE_Registration) { |
|
1324 | + $registration->set_status($status); |
|
1325 | 1325 | $result = $registration->save(); |
1326 | 1326 | |
1327 | 1327 | //verifying explicit fails because update *may* just return 0 for 0 rows affected |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | $this->_req_data['_REG_ID'] = $reg_ids; |
1334 | 1334 | |
1335 | 1335 | //return $success and processed registrations |
1336 | - return array( 'REG_ID' => $reg_ids, 'success' => $success ); |
|
1336 | + return array('REG_ID' => $reg_ids, 'success' => $success); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | |
@@ -1345,37 +1345,37 @@ discard block |
||
1345 | 1345 | * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
1346 | 1346 | * @return void |
1347 | 1347 | */ |
1348 | - protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
|
1348 | + protected function _reg_status_change_return($STS_ID, $notify = false) { |
|
1349 | 1349 | |
1350 | - $result = ! empty( $STS_ID ) ? $this->_set_registration_status_from_request( $STS_ID, $notify ) : array( 'success' => false ); |
|
1350 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) : array('success' => false); |
|
1351 | 1351 | |
1352 | 1352 | |
1353 | - $success = isset( $result['success'] ) && $result['success']; |
|
1353 | + $success = isset($result['success']) && $result['success']; |
|
1354 | 1354 | |
1355 | 1355 | //setup success message |
1356 | - if ( $success ) { |
|
1357 | - $msg = is_array( $result['REG_ID'] ) && count( $result['REG_ID'] ) > 1 ? sprintf( __('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) : sprintf( __('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) ; |
|
1358 | - EE_Error::add_success( $msg ); |
|
1356 | + if ($success) { |
|
1357 | + $msg = is_array($result['REG_ID']) && count($result['REG_ID']) > 1 ? sprintf(__('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower')) : sprintf(__('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
1358 | + EE_Error::add_success($msg); |
|
1359 | 1359 | } else { |
1360 | - EE_Error::add_error( __('Something went wrong, and the status was not changed', 'event_espresso' ), __FILE__, __LINE__, __FUNCTION__ ); |
|
1360 | + EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
1361 | 1361 | } |
1362 | 1362 | |
1363 | - $route = isset( $this->_req_data['return'] ) && $this->_req_data['return'] == 'view_registration' ? array( 'action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0] ) : array( 'action' => 'default' ); |
|
1363 | + $route = isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration' ? array('action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0]) : array('action' => 'default'); |
|
1364 | 1364 | //unset nonces |
1365 | - foreach ( $this->_req_data as $ref => $value ) { |
|
1366 | - if ( strpos( $ref, 'nonce' ) !== false ) { |
|
1367 | - unset( $this->_req_data[$ref] ); |
|
1365 | + foreach ($this->_req_data as $ref => $value) { |
|
1366 | + if (strpos($ref, 'nonce') !== false) { |
|
1367 | + unset($this->_req_data[$ref]); |
|
1368 | 1368 | continue; |
1369 | 1369 | } |
1370 | 1370 | |
1371 | - $value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value ); |
|
1371 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
1372 | 1372 | $this->_req_data[$ref] = $value; |
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | //merge request vars so that the reloaded list table contains any existing filter query params |
1376 | - $route = array_merge( $this->_req_data, $route ); |
|
1376 | + $route = array_merge($this->_req_data, $route); |
|
1377 | 1377 | |
1378 | - $this->_redirect_after_action( false, '', '', $route, true ); |
|
1378 | + $this->_redirect_after_action(false, '', '', $route, true); |
|
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | |
@@ -1387,29 +1387,29 @@ discard block |
||
1387 | 1387 | protected function _change_reg_status() { |
1388 | 1388 | $this->_req_data['return'] = 'view_registration'; |
1389 | 1389 | //set notify based on whether the send notifications toggle is set or not |
1390 | - $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
1391 | - $this->_req_data[ '_reg_status_id' ] = isset( $this->_req_data[ '_reg_status_id' ] ) ? $this->_req_data[ '_reg_status_id' ] : ''; |
|
1390 | + $notify = ! empty($this->_req_data['txn_reg_status_change']['send_notifications']); |
|
1391 | + $this->_req_data['_reg_status_id'] = isset($this->_req_data['_reg_status_id']) ? $this->_req_data['_reg_status_id'] : ''; |
|
1392 | 1392 | |
1393 | - switch ( $this->_req_data['_reg_status_id'] ) { |
|
1394 | - case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) : |
|
1395 | - $this->approve_registration( $notify ); |
|
1393 | + switch ($this->_req_data['_reg_status_id']) { |
|
1394 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
1395 | + $this->approve_registration($notify); |
|
1396 | 1396 | break; |
1397 | - case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) : |
|
1398 | - $this->pending_registration( $notify ); |
|
1397 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
1398 | + $this->pending_registration($notify); |
|
1399 | 1399 | break; |
1400 | - case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) : |
|
1401 | - $this->not_approve_registration( $notify ); |
|
1400 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
1401 | + $this->not_approve_registration($notify); |
|
1402 | 1402 | break; |
1403 | - case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) : |
|
1404 | - $this->decline_registration( $notify ); |
|
1403 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
1404 | + $this->decline_registration($notify); |
|
1405 | 1405 | break; |
1406 | - case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) : |
|
1407 | - $this->cancel_registration( $notify ); |
|
1406 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
1407 | + $this->cancel_registration($notify); |
|
1408 | 1408 | break; |
1409 | 1409 | default : |
1410 | 1410 | $result['success'] = false; |
1411 | - unset( $this->_req_data['return'] ); |
|
1412 | - $this->_reg_status_change_return( '', false ); |
|
1411 | + unset($this->_req_data['return']); |
|
1412 | + $this->_reg_status_change_return('', false); |
|
1413 | 1413 | break; |
1414 | 1414 | } |
1415 | 1415 | } |
@@ -1422,8 +1422,8 @@ discard block |
||
1422 | 1422 | * @param bool $notify whether or not to notify the registrant about their approval. |
1423 | 1423 | * @return void |
1424 | 1424 | */ |
1425 | - protected function approve_registration( $notify = false ) { |
|
1426 | - $this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify ); |
|
1425 | + protected function approve_registration($notify = false) { |
|
1426 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
1427 | 1427 | } |
1428 | 1428 | |
1429 | 1429 | |
@@ -1435,8 +1435,8 @@ discard block |
||
1435 | 1435 | * @param bool $notify whether or not to notify the registrant about their approval. |
1436 | 1436 | * @return void |
1437 | 1437 | */ |
1438 | - protected function decline_registration( $notify = false ) { |
|
1439 | - $this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify ); |
|
1438 | + protected function decline_registration($notify = false) { |
|
1439 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | |
@@ -1448,8 +1448,8 @@ discard block |
||
1448 | 1448 | * @param bool $notify whether or not to notify the registrant about their approval. |
1449 | 1449 | * @return void |
1450 | 1450 | */ |
1451 | - protected function cancel_registration( $notify = false ) { |
|
1452 | - $this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify ); |
|
1451 | + protected function cancel_registration($notify = false) { |
|
1452 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | |
@@ -1462,8 +1462,8 @@ discard block |
||
1462 | 1462 | * @param bool $notify whether or not to notify the registrant about their approval. |
1463 | 1463 | * @return void |
1464 | 1464 | */ |
1465 | - protected function not_approve_registration( $notify = false ) { |
|
1466 | - $this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify ); |
|
1465 | + protected function not_approve_registration($notify = false) { |
|
1466 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | |
@@ -1474,8 +1474,8 @@ discard block |
||
1474 | 1474 | * @param bool $notify whether or not to notify the registrant about their approval. |
1475 | 1475 | * @return void |
1476 | 1476 | */ |
1477 | - protected function pending_registration( $notify = false ) { |
|
1478 | - $this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify ); |
|
1477 | + protected function pending_registration($notify = false) { |
|
1478 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | |
@@ -1489,19 +1489,19 @@ discard block |
||
1489 | 1489 | public function _reg_details_meta_box() { |
1490 | 1490 | EEH_Autoloader::register_line_item_display_autoloaders(); |
1491 | 1491 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
1492 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1492 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1493 | 1493 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1494 | 1494 | $this->_session = $transaction->session_data(); |
1495 | 1495 | |
1496 | 1496 | $filters = new EE_Line_Item_Filter_Collection(); |
1497 | - $filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) ); |
|
1498 | - $filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
1499 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() ); |
|
1497 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
1498 | + $filters->add(new EE_Non_Zero_Line_Item_Filter()); |
|
1499 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item()); |
|
1500 | 1500 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
1501 | 1501 | |
1502 | 1502 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1503 | - $line_item_display = new EE_Line_Item_Display( 'reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy' ); |
|
1504 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item( $filtered_line_item_tree, array( 'EE_Registration' => $this->_registration ) ); |
|
1503 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
1504 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration)); |
|
1505 | 1505 | |
1506 | 1506 | |
1507 | 1507 | $attendee = $this->_registration->attendee(); |
@@ -1512,10 +1512,10 @@ discard block |
||
1512 | 1512 | ) |
1513 | 1513 | ? EEH_Template::get_button_or_link( |
1514 | 1514 | EE_Admin_Page::add_query_args_and_nonce( |
1515 | - array( 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ), |
|
1515 | + array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID()), |
|
1516 | 1516 | TXN_ADMIN_URL |
1517 | 1517 | ), |
1518 | - esc_html__( ' View Transaction' ), |
|
1518 | + esc_html__(' View Transaction'), |
|
1519 | 1519 | 'button secondary-button right', |
1520 | 1520 | 'dashicons dashicons-cart' |
1521 | 1521 | ) |
@@ -1535,59 +1535,59 @@ discard block |
||
1535 | 1535 | ), |
1536 | 1536 | REG_ADMIN_URL |
1537 | 1537 | ), |
1538 | - esc_html__( ' Resend Registration' ), |
|
1538 | + esc_html__(' Resend Registration'), |
|
1539 | 1539 | 'button secondary-button right', |
1540 | 1540 | 'dashicons dashicons-email-alt' |
1541 | 1541 | ) |
1542 | 1542 | : ''; |
1543 | 1543 | |
1544 | 1544 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1545 | - $payment = $transaction->get_first_related( 'Payment' ); |
|
1545 | + $payment = $transaction->get_first_related('Payment'); |
|
1546 | 1546 | $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
1547 | - $payment_method = $payment->get_first_related( 'Payment_Method' ); |
|
1547 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
1548 | 1548 | $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method; |
1549 | - $reg_status_class = 'status-' . $this->_registration->status_ID(); |
|
1549 | + $reg_status_class = 'status-'.$this->_registration->status_ID(); |
|
1550 | 1550 | $reg_details = array( |
1551 | 1551 | 'payment_method' => $payment_method->name(), |
1552 | 1552 | 'response_msg' => $payment->gateway_response(), |
1553 | - 'registration_id' => $this->_registration->get( 'REG_code' ), |
|
1553 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
1554 | 1554 | 'registration_session' => $this->_registration->session_ID(), |
1555 | - 'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '', |
|
1556 | - 'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '', |
|
1555 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
1556 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
1557 | 1557 | ); |
1558 | 1558 | |
1559 | 1559 | |
1560 | - if ( isset( $reg_details['registration_id'] )) { |
|
1560 | + if (isset($reg_details['registration_id'])) { |
|
1561 | 1561 | $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
1562 | - $this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' ); |
|
1562 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
1563 | 1563 | $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
1564 | 1564 | } |
1565 | 1565 | |
1566 | - if ( isset( $reg_details['payment_method'] ) ) { |
|
1566 | + if (isset($reg_details['payment_method'])) { |
|
1567 | 1567 | $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
1568 | - $this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' ); |
|
1568 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso'); |
|
1569 | 1569 | $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
1570 | 1570 | $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
1571 | - $this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' ); |
|
1571 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso'); |
|
1572 | 1572 | $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
1576 | - $this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' ); |
|
1576 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso'); |
|
1577 | 1577 | $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
1578 | 1578 | |
1579 | 1579 | $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
1580 | - $this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' ); |
|
1580 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso'); |
|
1581 | 1581 | $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
1582 | 1582 | |
1583 | 1583 | $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
1584 | - $this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' ); |
|
1584 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
1585 | 1585 | $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
1586 | 1586 | |
1587 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL ); |
|
1587 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL); |
|
1588 | 1588 | |
1589 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1590 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1589 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1590 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1591 | 1591 | |
1592 | 1592 | } |
1593 | 1593 | |
@@ -1601,14 +1601,14 @@ discard block |
||
1601 | 1601 | */ |
1602 | 1602 | public function _reg_questions_meta_box() { |
1603 | 1603 | //allow someone to override this method entirely |
1604 | - if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
|
1605 | - $form = $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
1606 | - $this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : ''; |
|
1604 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration)) { |
|
1605 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
1606 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
1607 | 1607 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
1608 | 1608 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1609 | 1609 | |
1610 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1611 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1610 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1611 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1612 | 1612 | } |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1622,12 +1622,12 @@ discard block |
||
1622 | 1622 | * @param string $output |
1623 | 1623 | * @return string |
1624 | 1624 | */ |
1625 | - public function form_before_question_group( $output ) { |
|
1625 | + public function form_before_question_group($output) { |
|
1626 | 1626 | EE_Error::doing_it_wrong( |
1627 | - __CLASS__ . '::' . __FUNCTION__, |
|
1628 | - __( 'This method would have been protected but was used on a filter callback' |
|
1627 | + __CLASS__.'::'.__FUNCTION__, |
|
1628 | + __('This method would have been protected but was used on a filter callback' |
|
1629 | 1629 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1630 | - 'event_espresso' ), |
|
1630 | + 'event_espresso'), |
|
1631 | 1631 | '4.8.32.rc.000' |
1632 | 1632 | ); |
1633 | 1633 | return ' |
@@ -1646,20 +1646,20 @@ discard block |
||
1646 | 1646 | * @param string $output |
1647 | 1647 | * @return string |
1648 | 1648 | */ |
1649 | - public function form_after_question_group( $output ) { |
|
1649 | + public function form_after_question_group($output) { |
|
1650 | 1650 | EE_Error::doing_it_wrong( |
1651 | - __CLASS__ . '::' . __FUNCTION__, |
|
1652 | - __( 'This method would have been protected but was used on a filter callback' |
|
1651 | + __CLASS__.'::'.__FUNCTION__, |
|
1652 | + __('This method would have been protected but was used on a filter callback' |
|
1653 | 1653 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1654 | - 'event_espresso' ), |
|
1654 | + 'event_espresso'), |
|
1655 | 1655 | '4.8.32.rc.000' |
1656 | 1656 | ); |
1657 | 1657 | return ' |
1658 | 1658 | <tr class="hide-if-no-js"> |
1659 | 1659 | <th> </th> |
1660 | 1660 | <td class="reg-admin-edit-attendee-question-td"> |
1661 | - <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '"> |
|
1662 | - <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span> |
|
1661 | + <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'"> |
|
1662 | + <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span> |
|
1663 | 1663 | <div class="dashicons dashicons-edit"></div> |
1664 | 1664 | </a> |
1665 | 1665 | </td> |
@@ -1679,18 +1679,18 @@ discard block |
||
1679 | 1679 | * @param string $label |
1680 | 1680 | * @return string |
1681 | 1681 | */ |
1682 | - public function form_form_field_label_wrap( $label ) { |
|
1682 | + public function form_form_field_label_wrap($label) { |
|
1683 | 1683 | EE_Error::doing_it_wrong( |
1684 | - __CLASS__ . '::' . __FUNCTION__, |
|
1685 | - __( 'This method would have been protected but was used on a filter callback' |
|
1684 | + __CLASS__.'::'.__FUNCTION__, |
|
1685 | + __('This method would have been protected but was used on a filter callback' |
|
1686 | 1686 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1687 | - 'event_espresso' ), |
|
1687 | + 'event_espresso'), |
|
1688 | 1688 | '4.8.32.rc.000' |
1689 | 1689 | ); |
1690 | 1690 | return ' |
1691 | 1691 | <tr> |
1692 | 1692 | <th> |
1693 | - ' . $label . ' |
|
1693 | + ' . $label.' |
|
1694 | 1694 | </th>'; |
1695 | 1695 | } |
1696 | 1696 | |
@@ -1704,17 +1704,17 @@ discard block |
||
1704 | 1704 | * @param string $input |
1705 | 1705 | * @return string |
1706 | 1706 | */ |
1707 | - public function form_form_field_input__wrap( $input ) { |
|
1707 | + public function form_form_field_input__wrap($input) { |
|
1708 | 1708 | EE_Error::doing_it_wrong( |
1709 | - __CLASS__ . '::' . __FUNCTION__, |
|
1710 | - __( 'This method would have been protected but was used on a filter callback' |
|
1709 | + __CLASS__.'::'.__FUNCTION__, |
|
1710 | + __('This method would have been protected but was used on a filter callback' |
|
1711 | 1711 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1712 | - 'event_espresso' ), |
|
1712 | + 'event_espresso'), |
|
1713 | 1713 | '4.8.32.rc.000' |
1714 | 1714 | ); |
1715 | 1715 | return ' |
1716 | 1716 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
1717 | - ' . $input . ' |
|
1717 | + ' . $input.' |
|
1718 | 1718 | </td> |
1719 | 1719 | </tr>'; |
1720 | 1720 | } |
@@ -1728,14 +1728,14 @@ discard block |
||
1728 | 1728 | * @return void |
1729 | 1729 | */ |
1730 | 1730 | protected function _update_attendee_registration_form() { |
1731 | - do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this ); |
|
1732 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
1733 | - $REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
1734 | - $success = $this->_save_reg_custom_questions_form( $REG_ID ); |
|
1735 | - if( $success ) { |
|
1731 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
1732 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1733 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
1734 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
1735 | + if ($success) { |
|
1736 | 1736 | $what = __('Registration Form', 'event_espresso'); |
1737 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
1738 | - $this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
1737 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
1738 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
1739 | 1739 | } |
1740 | 1740 | } |
1741 | 1741 | } |
@@ -1746,11 +1746,11 @@ discard block |
||
1746 | 1746 | * @param int $REG_ID |
1747 | 1747 | * @return EE_Registration_Custom_Questions_Form |
1748 | 1748 | */ |
1749 | - protected function _get_reg_custom_questions_form( $REG_ID ) { |
|
1750 | - if( ! $this->_reg_custom_questions_form ) { |
|
1751 | - require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' ); |
|
1752 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) ); |
|
1753 | - $this->_reg_custom_questions_form->_construct_finalize( null, null ); |
|
1749 | + protected function _get_reg_custom_questions_form($REG_ID) { |
|
1750 | + if ( ! $this->_reg_custom_questions_form) { |
|
1751 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
1752 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()->get_one_by_ID($REG_ID)); |
|
1753 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
1754 | 1754 | } |
1755 | 1755 | return $this->_reg_custom_questions_form; |
1756 | 1756 | } |
@@ -1763,17 +1763,17 @@ discard block |
||
1763 | 1763 | * @param bool $REG_ID |
1764 | 1764 | * @return bool |
1765 | 1765 | */ |
1766 | - private function _save_reg_custom_questions_form( $REG_ID = FALSE ) { |
|
1766 | + private function _save_reg_custom_questions_form($REG_ID = FALSE) { |
|
1767 | 1767 | |
1768 | 1768 | if ( ! $REG_ID) { |
1769 | - EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1769 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1770 | 1770 | } |
1771 | - $form = $this->_get_reg_custom_questions_form( $REG_ID ); |
|
1772 | - $form->receive_form_submission( $this->_req_data ); |
|
1771 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
1772 | + $form->receive_form_submission($this->_req_data); |
|
1773 | 1773 | $success = false; |
1774 | - if( $form->is_valid() ) { |
|
1775 | - foreach( $form->subforms() as $question_group_id => $question_group_form ) { |
|
1776 | - foreach( $question_group_form->inputs() as $question_id => $input ) { |
|
1774 | + if ($form->is_valid()) { |
|
1775 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
1776 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
1777 | 1777 | $where_conditions = array( |
1778 | 1778 | 'QST_ID' => $question_id, |
1779 | 1779 | 'REG_ID' => $REG_ID |
@@ -1781,19 +1781,19 @@ discard block |
||
1781 | 1781 | $possibly_new_values = array( |
1782 | 1782 | 'ANS_value' => $input->normalized_value() |
1783 | 1783 | ); |
1784 | - $answer = EEM_Answer::instance()->get_one( array( $where_conditions ) ); |
|
1785 | - if( $answer instanceof EE_Answer ) { |
|
1786 | - $success = $answer->save( $possibly_new_values ); |
|
1784 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
1785 | + if ($answer instanceof EE_Answer) { |
|
1786 | + $success = $answer->save($possibly_new_values); |
|
1787 | 1787 | } else { |
1788 | 1788 | //insert it then |
1789 | - $cols_n_vals = array_merge( $where_conditions, $possibly_new_values ); |
|
1790 | - $answer = EE_Answer::new_instance( $cols_n_vals ); |
|
1789 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
1790 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
1791 | 1791 | $success = $answer->save(); |
1792 | 1792 | } |
1793 | 1793 | } |
1794 | 1794 | } |
1795 | 1795 | } else { |
1796 | - EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1796 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
1797 | 1797 | } |
1798 | 1798 | return $success; |
1799 | 1799 | } |
@@ -1811,31 +1811,31 @@ discard block |
||
1811 | 1811 | $registrations = $REG->get_all(array( |
1812 | 1812 | array( |
1813 | 1813 | 'TXN_ID'=>$this->_registration->transaction_ID(), |
1814 | - 'REG_ID'=>array('!=',$this->_registration->ID()) |
|
1814 | + 'REG_ID'=>array('!=', $this->_registration->ID()) |
|
1815 | 1815 | ), |
1816 | 1816 | 'force_join'=>array('Attendee'))); |
1817 | 1817 | |
1818 | 1818 | $this->_template_args['attendees'] = array(); |
1819 | 1819 | $this->_template_args['attendee_notice'] = ''; |
1820 | - if ( empty( $registrations) || ( is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations) ) ) { |
|
1821 | - EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1820 | + if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) { |
|
1821 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1822 | 1822 | $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
1823 | 1823 | } else { |
1824 | 1824 | |
1825 | 1825 | $att_nmbr = 1; |
1826 | - foreach ( $registrations as $registration ) { |
|
1826 | + foreach ($registrations as $registration) { |
|
1827 | 1827 | /* @var $registration EE_Registration */ |
1828 | 1828 | $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object(); |
1829 | - $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID(); |
|
1830 | - $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1831 | - $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1832 | - $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1833 | - $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1829 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
1830 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1831 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1832 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1833 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1834 | 1834 | |
1835 | - $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() ); |
|
1835 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array()); |
|
1836 | 1836 | |
1837 | - $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
1838 | - $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name(); |
|
1837 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
1838 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
1839 | 1839 | |
1840 | 1840 | $att_nmbr++; |
1841 | 1841 | } |
@@ -1845,8 +1845,8 @@ discard block |
||
1845 | 1845 | |
1846 | 1846 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
1847 | 1847 | } |
1848 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
1849 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1848 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
1849 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1850 | 1850 | |
1851 | 1851 | } |
1852 | 1852 | |
@@ -1867,14 +1867,14 @@ discard block |
||
1867 | 1867 | $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
1868 | 1868 | |
1869 | 1869 | //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
1870 | - if ( ! $this->_registration->is_primary_registrant() ) { |
|
1870 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
1871 | 1871 | |
1872 | 1872 | $primary_registration = $this->_registration->get_primary_registration(); |
1873 | 1873 | $primary_attendee = $primary_registration instanceof EE_Registration |
1874 | 1874 | ? $primary_registration->attendee() |
1875 | 1875 | : null; |
1876 | 1876 | |
1877 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) { |
|
1877 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
1878 | 1878 | //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
1879 | 1879 | $primary_registration = NULL; |
1880 | 1880 | } |
@@ -1883,27 +1883,27 @@ discard block |
||
1883 | 1883 | } |
1884 | 1884 | |
1885 | 1885 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
1886 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
1887 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
1888 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
1886 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
1887 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
1888 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
1889 | 1889 | $this->_template_args['phone'] = $attendee->phone(); |
1890 | 1890 | |
1891 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee ); |
|
1891 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
1892 | 1892 | |
1893 | 1893 | |
1894 | 1894 | //edit link |
1895 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
1895 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
1896 | 1896 | $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
1897 | 1897 | |
1898 | 1898 | //create link |
1899 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): ''; |
|
1899 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : ''; |
|
1900 | 1900 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
1901 | 1901 | |
1902 | 1902 | $this->_template_args['att_check'] = $att_check; |
1903 | 1903 | |
1904 | 1904 | |
1905 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
1906 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1905 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
1906 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1907 | 1907 | } |
1908 | 1908 | |
1909 | 1909 | |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | * @access protected |
1917 | 1917 | * @return void |
1918 | 1918 | */ |
1919 | - protected function _trash_or_restore_registrations( $trash = TRUE ) { |
|
1919 | + protected function _trash_or_restore_registrations($trash = TRUE) { |
|
1920 | 1920 | $REGM = EEM_Registration::instance(); |
1921 | 1921 | |
1922 | 1922 | $success = 1; |
@@ -1926,26 +1926,26 @@ discard block |
||
1926 | 1926 | $dtts = array(); |
1927 | 1927 | |
1928 | 1928 | //if empty _REG_ID then get out because there's nothing to do |
1929 | - if ( empty( $this->_req_data['_REG_ID'] ) ) { |
|
1929 | + if (empty($this->_req_data['_REG_ID'])) { |
|
1930 | 1930 | $msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso'); |
1931 | - EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ ); |
|
1932 | - $this->_redirect_after_action(FALSE, '', '', array(), TRUE ); |
|
1931 | + EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
1932 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | //Checkboxes |
1936 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
1936 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
1937 | 1937 | // if array has more than one element than success message should be plural |
1938 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
1938 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
1939 | 1939 | // cycle thru checkboxes |
1940 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
1940 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
1941 | 1941 | /** @var EE_Registration $REG */ |
1942 | - $REG = $REGM->get_one_by_ID( $REG_ID); |
|
1942 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
1943 | 1943 | $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
1944 | - if ( $payment_count > 0 ) { |
|
1945 | - $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ); |
|
1944 | + if ($payment_count > 0) { |
|
1945 | + $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso'); |
|
1946 | 1946 | $error = 1; |
1947 | 1947 | $success = 0; |
1948 | - EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1948 | + EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
1949 | 1949 | continue; //can't trash this registration because it has payments. |
1950 | 1950 | } |
1951 | 1951 | $ticket = $REG->get_first_related('Ticket'); |
@@ -1954,7 +1954,7 @@ discard block |
||
1954 | 1954 | $dtts = array_merge($dtts, $dtt); |
1955 | 1955 | |
1956 | 1956 | $updated = $trash ? $REG->delete() : $REG->restore(); |
1957 | - if ( !$updated ) { |
|
1957 | + if ( ! $updated) { |
|
1958 | 1958 | $success = 0; |
1959 | 1959 | } else { |
1960 | 1960 | $success = 2; |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | $tickets[$ticket->ID()] = $ticket; |
1970 | 1970 | $dtts = $ticket->get_many_related('Datetime'); |
1971 | 1971 | $updated = $trash ? $REG->delete() : $REG->restore(); |
1972 | - if ( ! $updated ) { |
|
1972 | + if ( ! $updated) { |
|
1973 | 1973 | $success = 0; |
1974 | 1974 | } |
1975 | 1975 | |
@@ -1979,10 +1979,10 @@ discard block |
||
1979 | 1979 | EEM_Ticket::instance()->update_tickets_sold($tickets); |
1980 | 1980 | EEM_Datetime::instance()->update_sold($dtts); |
1981 | 1981 | |
1982 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
1983 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
1982 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
1983 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
1984 | 1984 | $overwrite_msgs = $error ? TRUE : FALSE; |
1985 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs ); |
|
1985 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
1986 | 1986 | } |
1987 | 1987 | |
1988 | 1988 | |
@@ -2006,16 +2006,16 @@ discard block |
||
2006 | 2006 | $success = 1; |
2007 | 2007 | |
2008 | 2008 | //Checkboxes |
2009 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2009 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2010 | 2010 | // if array has more than one element than success message should be plural |
2011 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
2011 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2012 | 2012 | // cycle thru checkboxes |
2013 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
2013 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2014 | 2014 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
2015 | - if ( ! $REG instanceof EE_Registration ) |
|
2015 | + if ( ! $REG instanceof EE_Registration) |
|
2016 | 2016 | continue; |
2017 | 2017 | $deleted = $this->_delete_registration($REG); |
2018 | - if ( !$deleted ) { |
|
2018 | + if ( ! $deleted) { |
|
2019 | 2019 | $success = 0; |
2020 | 2020 | } |
2021 | 2021 | } |
@@ -2025,15 +2025,15 @@ discard block |
||
2025 | 2025 | $REG_ID = $this->_req_data['_REG_ID']; |
2026 | 2026 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
2027 | 2027 | $deleted = $this->_delete_registration($REG); |
2028 | - if ( ! $deleted ) { |
|
2028 | + if ( ! $deleted) { |
|
2029 | 2029 | $success = 0; |
2030 | 2030 | } |
2031 | 2031 | |
2032 | 2032 | } |
2033 | 2033 | |
2034 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
2035 | - $action_desc = __( 'permanently deleted.', 'event_espresso' ); |
|
2036 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE ); |
|
2034 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2035 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
2036 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE); |
|
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | |
@@ -2045,31 +2045,31 @@ discard block |
||
2045 | 2045 | * @param EE_Registration $REG registration to be deleted permenantly |
2046 | 2046 | * @return boolean true = successful deletion, false = fail. |
2047 | 2047 | */ |
2048 | - protected function _delete_registration( EE_Registration $REG ) { |
|
2048 | + protected function _delete_registration(EE_Registration $REG) { |
|
2049 | 2049 | //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
2050 | 2050 | $TXN = $REG->get_first_related('Transaction'); |
2051 | 2051 | $REGS = $TXN->get_many_related('Registration'); |
2052 | 2052 | |
2053 | 2053 | $all_trashed = TRUE; |
2054 | - foreach ( $REGS as $registration ) { |
|
2055 | - if ( ! $registration->get('REG_deleted') ) |
|
2054 | + foreach ($REGS as $registration) { |
|
2055 | + if ( ! $registration->get('REG_deleted')) |
|
2056 | 2056 | $all_trashed = FALSE; |
2057 | 2057 | } |
2058 | 2058 | |
2059 | - if ( ! $all_trashed ) { |
|
2060 | - EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2059 | + if ( ! $all_trashed) { |
|
2060 | + EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2061 | 2061 | return false; |
2062 | 2062 | } |
2063 | 2063 | |
2064 | 2064 | //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
2065 | - foreach ( $REGS as $registration ) { |
|
2065 | + foreach ($REGS as $registration) { |
|
2066 | 2066 | |
2067 | 2067 | //delete related answers |
2068 | 2068 | $registration->delete_related_permanently('Answer'); |
2069 | 2069 | |
2070 | 2070 | //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
2071 | 2071 | $attendee = $registration->get_first_related('Attendee'); |
2072 | - if ( $attendee instanceof EE_Attendee ) { |
|
2072 | + if ($attendee instanceof EE_Attendee) { |
|
2073 | 2073 | $registration->_remove_relation_to($attendee, 'Attendee'); |
2074 | 2074 | } |
2075 | 2075 | |
@@ -2079,7 +2079,7 @@ discard block |
||
2079 | 2079 | //now delete permanently the checkins related to this registration. |
2080 | 2080 | $registration->delete_related_permanently('Checkin'); |
2081 | 2081 | |
2082 | - if ( $registration->ID() === $REG->ID() ) |
|
2082 | + if ($registration->ID() === $REG->ID()) |
|
2083 | 2083 | continue; //we don't want to delete permanently the existing registration just yet. |
2084 | 2084 | |
2085 | 2085 | //remove relation to transaction for these registrations if NOT the existing registrations |
@@ -2112,35 +2112,35 @@ discard block |
||
2112 | 2112 | * @return void |
2113 | 2113 | */ |
2114 | 2114 | public function new_registration() { |
2115 | - if ( ! $this->_set_reg_event() ) { |
|
2116 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') ); |
|
2115 | + if ( ! $this->_set_reg_event()) { |
|
2116 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso')); |
|
2117 | 2117 | } |
2118 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
2118 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
2119 | 2119 | // gotta start with a clean slate if we're not coming here via ajax |
2120 | 2120 | if ( |
2121 | - ! defined('DOING_AJAX' ) |
|
2122 | - && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ) ) |
|
2121 | + ! defined('DOING_AJAX') |
|
2122 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
2123 | 2123 | ) { |
2124 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2124 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2125 | 2125 | } |
2126 | 2126 | |
2127 | - $this->_template_args['event_name'] = '' ; |
|
2127 | + $this->_template_args['event_name'] = ''; |
|
2128 | 2128 | // event name |
2129 | - if ( $this->_reg_event ) { |
|
2129 | + if ($this->_reg_event) { |
|
2130 | 2130 | $this->_template_args['event_name'] = $this->_reg_event->name(); |
2131 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL ); |
|
2132 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
2133 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
2131 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL); |
|
2132 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
2133 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
2134 | 2134 | } |
2135 | 2135 | |
2136 | 2136 | $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
2137 | 2137 | |
2138 | - if ( defined('DOING_AJAX' ) ) { |
|
2138 | + if (defined('DOING_AJAX')) { |
|
2139 | 2139 | $this->_return_json(); |
2140 | 2140 | } |
2141 | 2141 | // grab header |
2142 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
2143 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2142 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
2143 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2144 | 2144 | |
2145 | 2145 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
2146 | 2146 | // the details template wrapper |
@@ -2157,7 +2157,7 @@ discard block |
||
2157 | 2157 | * @return string html |
2158 | 2158 | */ |
2159 | 2159 | protected function _get_registration_step_content() { |
2160 | - if ( isset( $_COOKIE[ 'ee_registration_added' ] ) && $_COOKIE[ 'ee_registration_added' ] ) { |
|
2160 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
2161 | 2161 | $warning_msg = sprintf( |
2162 | 2162 | __( |
2163 | 2163 | '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
@@ -2173,7 +2173,7 @@ discard block |
||
2173 | 2173 | '</b>' |
2174 | 2174 | ); |
2175 | 2175 | return ' |
2176 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
2176 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
2177 | 2177 | <script > |
2178 | 2178 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
2179 | 2179 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2208,16 +2208,16 @@ discard block |
||
2208 | 2208 | $cart = EE_Registry::instance()->SSN->cart(); |
2209 | 2209 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2210 | 2210 | |
2211 | - switch ( $step ) { |
|
2211 | + switch ($step) { |
|
2212 | 2212 | case 'ticket' : |
2213 | 2213 | $hidden_fields['processing_registration']['value'] = 1; |
2214 | 2214 | $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
2215 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event ); |
|
2215 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
2216 | 2216 | $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso'); |
2217 | 2217 | $template_args['show_notification_toggle'] = FALSE; |
2218 | 2218 | break; |
2219 | 2219 | case 'questions' : |
2220 | - $hidden_fields[ 'processing_registration' ][ 'value' ] = 2; |
|
2220 | + $hidden_fields['processing_registration']['value'] = 2; |
|
2221 | 2221 | $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', 'event_espresso'); |
2222 | 2222 | //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
2223 | 2223 | $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
@@ -2226,10 +2226,10 @@ discard block |
||
2226 | 2226 | break; |
2227 | 2227 | } |
2228 | 2228 | |
2229 | - $this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route. |
|
2229 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route. |
|
2230 | 2230 | |
2231 | 2231 | return EEH_Template::display_template( |
2232 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
2232 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
2233 | 2233 | ); |
2234 | 2234 | } |
2235 | 2235 | |
@@ -2244,11 +2244,11 @@ discard block |
||
2244 | 2244 | * @return boolean |
2245 | 2245 | */ |
2246 | 2246 | private function _set_reg_event() { |
2247 | - if ( is_object( $this->_reg_event )) { |
|
2247 | + if (is_object($this->_reg_event)) { |
|
2248 | 2248 | return TRUE; |
2249 | 2249 | } |
2250 | - $EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
2251 | - if ( ! $EVT_ID ) { |
|
2250 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE; |
|
2251 | + if ( ! $EVT_ID) { |
|
2252 | 2252 | return FALSE; |
2253 | 2253 | } |
2254 | 2254 | |
@@ -2269,82 +2269,82 @@ discard block |
||
2269 | 2269 | public function process_reg_step() { |
2270 | 2270 | EE_System::do_not_cache(); |
2271 | 2271 | $this->_set_reg_event(); |
2272 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
2272 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
2273 | 2273 | |
2274 | 2274 | //what step are we on? |
2275 | 2275 | $cart = EE_Registry::instance()->SSN->cart(); |
2276 | 2276 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2277 | 2277 | |
2278 | 2278 | //if doing ajax then we need to verify the nonce |
2279 | - if ( defined( 'DOING_AJAX' ) ) { |
|
2280 | - $nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : ''; |
|
2281 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
2279 | + if (defined('DOING_AJAX')) { |
|
2280 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
2281 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
2282 | 2282 | } |
2283 | 2283 | |
2284 | - switch ( $step ) { |
|
2284 | + switch ($step) { |
|
2285 | 2285 | |
2286 | 2286 | case 'ticket' : |
2287 | 2287 | //process ticket selection |
2288 | 2288 | $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
2289 | - if ( $success ) { |
|
2290 | - EE_Error::add_success( __('Tickets Selected. Now complete the registration.'), 'event_espresso'); |
|
2289 | + if ($success) { |
|
2290 | + EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso'); |
|
2291 | 2291 | } else { |
2292 | 2292 | $query_args['step_error'] = $this->_req_data['step_error'] = TRUE; |
2293 | 2293 | } |
2294 | - if ( defined('DOING_AJAX') ) { |
|
2294 | + if (defined('DOING_AJAX')) { |
|
2295 | 2295 | $this->new_registration(); //display next step |
2296 | 2296 | } else { |
2297 | 2297 | $query_args['action'] = 'new_registration'; |
2298 | 2298 | $query_args['processing_registration'] = 1; |
2299 | 2299 | $query_args['event_id'] = $this->_reg_event->ID(); |
2300 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
2300 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2301 | 2301 | } |
2302 | 2302 | break; |
2303 | 2303 | |
2304 | 2304 | case 'questions' : |
2305 | - if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) { |
|
2306 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 ); |
|
2305 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
2306 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
2307 | 2307 | } |
2308 | 2308 | //process registration |
2309 | 2309 | $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
2310 | - if ( $cart instanceof EE_Cart ) { |
|
2310 | + if ($cart instanceof EE_Cart) { |
|
2311 | 2311 | $grand_total = $cart->get_cart_grand_total(); |
2312 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
2312 | + if ($grand_total instanceof EE_Line_Item) { |
|
2313 | 2313 | $grand_total->save_this_and_descendants_to_txn(); |
2314 | 2314 | } |
2315 | 2315 | } |
2316 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
2316 | + if ( ! $transaction instanceof EE_Transaction) { |
|
2317 | 2317 | $query_args = array( |
2318 | 2318 | 'action' => 'new_registration', |
2319 | 2319 | 'processing_registration' => 2, |
2320 | 2320 | 'event_id' => $this->_reg_event->ID() |
2321 | 2321 | ); |
2322 | 2322 | |
2323 | - if ( defined('DOING_AJAX' )) { |
|
2323 | + if (defined('DOING_AJAX')) { |
|
2324 | 2324 | //display registration form again because there are errors (maybe validation?) |
2325 | 2325 | $this->new_registration(); |
2326 | 2326 | return; |
2327 | 2327 | } else { |
2328 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
2328 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2329 | 2329 | return; |
2330 | 2330 | } |
2331 | 2331 | } |
2332 | 2332 | /** @type EE_Transaction_Payments $transaction_payments */ |
2333 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
2333 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
2334 | 2334 | // maybe update status, and make sure to save transaction if not done already |
2335 | - if ( ! $transaction_payments->update_transaction_status_based_on_total_paid( $transaction )) { |
|
2335 | + if ( ! $transaction_payments->update_transaction_status_based_on_total_paid($transaction)) { |
|
2336 | 2336 | $transaction->save(); |
2337 | 2337 | } |
2338 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2338 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2339 | 2339 | $this->_req_data = array(); |
2340 | 2340 | $query_args = array( |
2341 | 2341 | 'action' => 'redirect_to_txn', |
2342 | 2342 | 'TXN_ID' => $transaction->ID(), |
2343 | 2343 | 'EVT_ID' => $this->_reg_event->ID(), |
2344 | - 'event_name' => urlencode( $this->_reg_event->name() ), |
|
2344 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
2345 | 2345 | 'redirect_from' => 'new_registration' |
2346 | 2346 | ); |
2347 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
2347 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2348 | 2348 | break; |
2349 | 2349 | } |
2350 | 2350 | |
@@ -2361,21 +2361,21 @@ discard block |
||
2361 | 2361 | */ |
2362 | 2362 | public function redirect_to_txn() { |
2363 | 2363 | EE_System::do_not_cache(); |
2364 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2364 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2365 | 2365 | $query_args = array( |
2366 | 2366 | 'action' => 'view_transaction', |
2367 | - 'TXN_ID' => isset( $this->_req_data['TXN_ID'] ) ? absint( $this->_req_data[ 'TXN_ID' ] ) : 0, |
|
2367 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
2368 | 2368 | 'page' => 'espresso_transactions' |
2369 | 2369 | ); |
2370 | - if ( isset( $this->_req_data[ 'EVT_ID' ], $this->_req_data[ 'redirect_from' ] ) ) { |
|
2371 | - $query_args['EVT_ID'] = $this->_req_data[ 'EVT_ID' ]; |
|
2372 | - $query_args['event_name'] = urlencode( $this->_req_data[ 'event_name' ] ); |
|
2373 | - $query_args['redirect_from'] = $this->_req_data[ 'redirect_from' ]; |
|
2370 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
2371 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
2372 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
2373 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
2374 | 2374 | } |
2375 | 2375 | EE_Error::add_success( |
2376 | - __( 'Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso' ) |
|
2376 | + __('Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso') |
|
2377 | 2377 | ); |
2378 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
2378 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2379 | 2379 | } |
2380 | 2380 | |
2381 | 2381 | |
@@ -2386,7 +2386,7 @@ discard block |
||
2386 | 2386 | * @return void |
2387 | 2387 | */ |
2388 | 2388 | protected function _attendee_contact_list_table() { |
2389 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2389 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2390 | 2390 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
2391 | 2391 | $this->display_admin_list_table_page_with_no_sidebar(); |
2392 | 2392 | } |
@@ -2401,10 +2401,10 @@ discard block |
||
2401 | 2401 | * @access public |
2402 | 2402 | * @return array |
2403 | 2403 | */ |
2404 | - public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
|
2404 | + public function get_attendees($per_page, $count = FALSE, $trash = FALSE) { |
|
2405 | 2405 | |
2406 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2407 | - require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' ); |
|
2406 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2407 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
2408 | 2408 | $ATT_MDL = EEM_Attendee::instance(); |
2409 | 2409 | |
2410 | 2410 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
@@ -2432,47 +2432,47 @@ discard block |
||
2432 | 2432 | $orderby = 'ATT_lname'; |
2433 | 2433 | } |
2434 | 2434 | |
2435 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
2435 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
2436 | 2436 | |
2437 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
2438 | - $per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
2439 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
2437 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
2438 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
2439 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
2440 | 2440 | |
2441 | 2441 | $_where = array(); |
2442 | 2442 | |
2443 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
2444 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2443 | + if ( ! empty($this->_req_data['s'])) { |
|
2444 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2445 | 2445 | $_where['OR'] = array( |
2446 | - 'Registration.Event.EVT_name' => array( 'LIKE', $sstr), |
|
2447 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
2448 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
2449 | - 'ATT_fname' => array( 'LIKE', $sstr ), |
|
2450 | - 'ATT_lname' => array( 'LIKE', $sstr ), |
|
2451 | - 'ATT_short_bio' => array( 'LIKE', $sstr ), |
|
2452 | - 'ATT_email' => array('LIKE', $sstr ), |
|
2453 | - 'ATT_address' => array( 'LIKE', $sstr ), |
|
2454 | - 'ATT_address2' => array( 'LIKE', $sstr ), |
|
2455 | - 'ATT_city' => array( 'LIKE', $sstr ), |
|
2456 | - 'Country.CNT_name' => array( 'LIKE', $sstr ), |
|
2457 | - 'State.STA_name' => array('LIKE', $sstr ), |
|
2458 | - 'ATT_phone' => array( 'LIKE', $sstr ), |
|
2459 | - 'Registration.REG_final_price' => array( 'LIKE', $sstr ), |
|
2460 | - 'Registration.REG_code' => array( 'LIKE', $sstr ), |
|
2461 | - 'Registration.REG_count' => array( 'LIKE' , $sstr ), |
|
2462 | - 'Registration.REG_group_size' => array( 'LIKE' , $sstr ) |
|
2446 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
2447 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
2448 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
2449 | + 'ATT_fname' => array('LIKE', $sstr), |
|
2450 | + 'ATT_lname' => array('LIKE', $sstr), |
|
2451 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
2452 | + 'ATT_email' => array('LIKE', $sstr), |
|
2453 | + 'ATT_address' => array('LIKE', $sstr), |
|
2454 | + 'ATT_address2' => array('LIKE', $sstr), |
|
2455 | + 'ATT_city' => array('LIKE', $sstr), |
|
2456 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
2457 | + 'State.STA_name' => array('LIKE', $sstr), |
|
2458 | + 'ATT_phone' => array('LIKE', $sstr), |
|
2459 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
2460 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
2461 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
2462 | + 'Registration.REG_group_size' => array('LIKE', $sstr) |
|
2463 | 2463 | ); |
2464 | 2464 | } |
2465 | 2465 | |
2466 | 2466 | |
2467 | - $offset = ($current_page-1)*$per_page; |
|
2468 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
2467 | + $offset = ($current_page - 1) * $per_page; |
|
2468 | + $limit = $count ? NULL : array($offset, $per_page); |
|
2469 | 2469 | |
2470 | - if ( $trash ) { |
|
2471 | - $_where['status'] = array( '!=', 'publish' ); |
|
2472 | - $all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true ): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2470 | + if ($trash) { |
|
2471 | + $_where['status'] = array('!=', 'publish'); |
|
2472 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2473 | 2473 | } else { |
2474 | - $_where['status'] = array( 'IN', array( 'publish' ) ); |
|
2475 | - $all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit ), 'ATT_ID' , true ) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) ); |
|
2474 | + $_where['status'] = array('IN', array('publish')); |
|
2475 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2476 | 2476 | } |
2477 | 2477 | |
2478 | 2478 | return $all_attendees; |
@@ -2489,10 +2489,10 @@ discard block |
||
2489 | 2489 | */ |
2490 | 2490 | protected function _resend_registration() { |
2491 | 2491 | $this->_process_resend_registration(); |
2492 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array( |
|
2492 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array( |
|
2493 | 2493 | 'action' => 'default' |
2494 | 2494 | ); |
2495 | - $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE ); |
|
2495 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2496 | 2496 | } |
2497 | 2497 | |
2498 | 2498 | |
@@ -2500,26 +2500,26 @@ discard block |
||
2500 | 2500 | |
2501 | 2501 | |
2502 | 2502 | |
2503 | - public function _registrations_report(){ |
|
2504 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
2505 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
2503 | + public function _registrations_report() { |
|
2504 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2505 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
2506 | 2506 | array( |
2507 | 2507 | 'page' => 'espresso_batch', |
2508 | 2508 | 'batch' => 'file', |
2509 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
2510 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ), |
|
2511 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
2512 | - )) ); |
|
2509 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
2510 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
2511 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2512 | + ))); |
|
2513 | 2513 | } else { |
2514 | 2514 | $new_request_args = array( |
2515 | 2515 | 'export' => 'report', |
2516 | 2516 | 'action' => 'registrations_report_for_event', |
2517 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
2517 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
2518 | 2518 | ); |
2519 | 2519 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
2520 | 2520 | |
2521 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2522 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2521 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2522 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2523 | 2523 | $EE_Export = EE_Export::instance($this->_req_data); |
2524 | 2524 | $EE_Export->export(); |
2525 | 2525 | } |
@@ -2528,26 +2528,26 @@ discard block |
||
2528 | 2528 | |
2529 | 2529 | |
2530 | 2530 | |
2531 | - public function _contact_list_export(){ |
|
2532 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2533 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2531 | + public function _contact_list_export() { |
|
2532 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2533 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2534 | 2534 | $EE_Export = EE_Export::instance($this->_req_data); |
2535 | 2535 | $EE_Export->export_attendees(); |
2536 | 2536 | } |
2537 | 2537 | } |
2538 | 2538 | |
2539 | - public function _contact_list_report(){ |
|
2540 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
2541 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
2539 | + public function _contact_list_report() { |
|
2540 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2541 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
2542 | 2542 | array( |
2543 | 2543 | 'page' => 'espresso_batch', |
2544 | 2544 | 'batch' => 'file', |
2545 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ), |
|
2546 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
2547 | - )) ); |
|
2545 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
2546 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2547 | + ))); |
|
2548 | 2548 | } else { |
2549 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2550 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2549 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2550 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2551 | 2551 | $EE_Export = EE_Export::instance($this->_req_data); |
2552 | 2552 | $EE_Export->report_attendees(); |
2553 | 2553 | } |
@@ -2566,73 +2566,73 @@ discard block |
||
2566 | 2566 | * @return void |
2567 | 2567 | */ |
2568 | 2568 | protected function _duplicate_attendee() { |
2569 | - $action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default'; |
|
2569 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
2570 | 2570 | //verify we have necessary info |
2571 | - if ( empty($this->_req_data['_REG_ID'] ) ) { |
|
2572 | - EE_Error::add_error( __('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__ ); |
|
2573 | - $query_args = array( 'action' => $action ); |
|
2571 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2572 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
2573 | + $query_args = array('action' => $action); |
|
2574 | 2574 | $this->_redirect_after_action('', '', '', $query_args, TRUE); |
2575 | 2575 | } |
2576 | 2576 | |
2577 | 2577 | //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
2578 | - $registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] ); |
|
2578 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
2579 | 2579 | $attendee = $registration->attendee(); |
2580 | 2580 | |
2581 | 2581 | //remove relation of existing attendee on registration |
2582 | - $registration->_remove_relation_to($attendee, 'Attendee' ); |
|
2582 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2583 | 2583 | //new attendee |
2584 | 2584 | $new_attendee = clone $attendee; |
2585 | - $new_attendee->set( 'ATT_ID', 0 ); |
|
2585 | + $new_attendee->set('ATT_ID', 0); |
|
2586 | 2586 | $new_attendee->save(); |
2587 | 2587 | |
2588 | 2588 | //add new attendee to reg |
2589 | - $registration->_add_relation_to( $new_attendee, 'Attendee'); |
|
2589 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
2590 | 2590 | |
2591 | - EE_Error::add_success( __('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso') ); |
|
2591 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso')); |
|
2592 | 2592 | |
2593 | 2593 | //redirect to edit page for attendee |
2594 | - $query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' ); |
|
2594 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
2595 | 2595 | |
2596 | - $this->_redirect_after_action( '', '', '', $query_args, TRUE ); |
|
2596 | + $this->_redirect_after_action('', '', '', $query_args, TRUE); |
|
2597 | 2597 | } |
2598 | 2598 | |
2599 | 2599 | |
2600 | 2600 | //related to cpt routes |
2601 | 2601 | protected function _insert_update_cpt_item($post_id, $post) { |
2602 | 2602 | $success = true; |
2603 | - $attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id ); |
|
2603 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
2604 | 2604 | //for attendee updates |
2605 | - if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) { |
|
2605 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
2606 | 2606 | //note we should only be UPDATING attendees at this point. |
2607 | 2607 | $updated_fields = array( |
2608 | 2608 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
2609 | 2609 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
2610 | - 'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
2610 | + 'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
2611 | 2611 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
2612 | 2612 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
2613 | - 'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '', |
|
2614 | - 'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '', |
|
2615 | - 'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '', |
|
2616 | - 'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '', |
|
2617 | - 'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '', |
|
2618 | - 'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : '' |
|
2613 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
2614 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
2615 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
2616 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
2617 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
2618 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '' |
|
2619 | 2619 | ); |
2620 | - foreach ( $updated_fields as $field => $value ) { |
|
2620 | + foreach ($updated_fields as $field => $value) { |
|
2621 | 2621 | $attendee->set($field, $value); |
2622 | 2622 | } |
2623 | 2623 | |
2624 | 2624 | $success = $attendee->save(); |
2625 | 2625 | |
2626 | - $attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() ); |
|
2627 | - foreach ( $attendee_update_callbacks as $a_callback ) { |
|
2628 | - if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) { |
|
2629 | - throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback ) ); |
|
2626 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array()); |
|
2627 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
2628 | + if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
2629 | + throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback)); |
|
2630 | 2630 | } |
2631 | 2631 | } |
2632 | 2632 | } |
2633 | 2633 | |
2634 | - if ( $success === FALSE ) |
|
2635 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2634 | + if ($success === FALSE) |
|
2635 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2636 | 2636 | |
2637 | 2637 | } |
2638 | 2638 | |
@@ -2652,17 +2652,17 @@ discard block |
||
2652 | 2652 | remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2653 | 2653 | remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2654 | 2654 | |
2655 | - if ( post_type_supports( 'espresso_attendees', 'excerpt') ) { |
|
2656 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' ); |
|
2655 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
2656 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal'); |
|
2657 | 2657 | } |
2658 | 2658 | |
2659 | - if ( post_type_supports( 'espresso_attendees', 'comments') ) { |
|
2659 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
2660 | 2660 | add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2661 | 2661 | } |
2662 | 2662 | |
2663 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
2664 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' ); |
|
2665 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2663 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
2664 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2665 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | |
@@ -2671,10 +2671,10 @@ discard block |
||
2671 | 2671 | * @param WP_Post $post wp post object |
2672 | 2672 | * @return string attendee contact info ( and form ) |
2673 | 2673 | */ |
2674 | - public function attendee_contact_info( $post ) { |
|
2674 | + public function attendee_contact_info($post) { |
|
2675 | 2675 | //get attendee object ( should already have it ) |
2676 | 2676 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2677 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
2677 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
2678 | 2678 | EEH_Template::display_template($template, $this->_template_args); |
2679 | 2679 | } |
2680 | 2680 | |
@@ -2690,12 +2690,12 @@ discard block |
||
2690 | 2690 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2691 | 2691 | $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
2692 | 2692 | new EE_Question_Form_Input( |
2693 | - EE_Question::new_instance( array( |
|
2693 | + EE_Question::new_instance(array( |
|
2694 | 2694 | 'QST_ID' => 0, |
2695 | 2695 | 'QST_display_text' => __('State/Province', 'event_espresso'), |
2696 | 2696 | 'QST_system' => 'admin-state' |
2697 | 2697 | )), |
2698 | - EE_Answer::new_instance( array( |
|
2698 | + EE_Answer::new_instance(array( |
|
2699 | 2699 | 'ANS_ID' => 0, |
2700 | 2700 | 'ANS_value' => $this->_cpt_model_obj->state_ID() |
2701 | 2701 | )), |
@@ -2708,12 +2708,12 @@ discard block |
||
2708 | 2708 | )); |
2709 | 2709 | $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
2710 | 2710 | new EE_Question_Form_Input( |
2711 | - EE_Question::new_instance( array( |
|
2711 | + EE_Question::new_instance(array( |
|
2712 | 2712 | 'QST_ID' => 0, |
2713 | 2713 | 'QST_display_text' => __('Country', 'event_espresso'), |
2714 | 2714 | 'QST_system' => 'admin-country' |
2715 | 2715 | )), |
2716 | - EE_Answer::new_instance( array( |
|
2716 | + EE_Answer::new_instance(array( |
|
2717 | 2717 | 'ANS_ID' => 0, |
2718 | 2718 | 'ANS_value' => $this->_cpt_model_obj->country_ID() |
2719 | 2719 | )), |
@@ -2724,8 +2724,8 @@ discard block |
||
2724 | 2724 | 'append_qstn_id' => FALSE |
2725 | 2725 | ) |
2726 | 2726 | )); |
2727 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
2728 | - EEH_Template::display_template($template, $this->_template_args ); |
|
2727 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
2728 | + EEH_Template::display_template($template, $this->_template_args); |
|
2729 | 2729 | |
2730 | 2730 | } |
2731 | 2731 | |
@@ -2735,11 +2735,11 @@ discard block |
||
2735 | 2735 | * @access protected |
2736 | 2736 | * @return void |
2737 | 2737 | */ |
2738 | - public function attendee_registrations_meta_box( $post ) { |
|
2738 | + public function attendee_registrations_meta_box($post) { |
|
2739 | 2739 | |
2740 | 2740 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2741 | 2741 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
2742 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
2742 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
2743 | 2743 | EEH_Template::display_template($template, $this->_template_args); |
2744 | 2744 | |
2745 | 2745 | } |
@@ -2753,8 +2753,8 @@ discard block |
||
2753 | 2753 | * @return string html for new form. |
2754 | 2754 | */ |
2755 | 2755 | public function after_title_form_fields($post) { |
2756 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
2757 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
2756 | + if ($post->post_type == 'espresso_attendees') { |
|
2757 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
2758 | 2758 | $template_args['attendee'] = $this->_cpt_model_obj; |
2759 | 2759 | EEH_Template::display_template($template, $template_args); |
2760 | 2760 | } |
@@ -2771,21 +2771,21 @@ discard block |
||
2771 | 2771 | * @access protected |
2772 | 2772 | * @return void |
2773 | 2773 | */ |
2774 | - protected function _trash_or_restore_attendees( $trash = TRUE ) { |
|
2774 | + protected function _trash_or_restore_attendees($trash = TRUE) { |
|
2775 | 2775 | |
2776 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2776 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2777 | 2777 | |
2778 | 2778 | $ATT_MDL = EEM_Attendee::instance(); |
2779 | 2779 | |
2780 | 2780 | $success = 1; |
2781 | 2781 | //Checkboxes |
2782 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2782 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2783 | 2783 | // if array has more than one element than success message should be plural |
2784 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2784 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2785 | 2785 | // cycle thru checkboxes |
2786 | - while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
2787 | - $updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID); |
|
2788 | - if ( !$updated ) { |
|
2786 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2787 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
2788 | + if ( ! $updated) { |
|
2789 | 2789 | $success = 0; |
2790 | 2790 | } |
2791 | 2791 | } |
@@ -2794,18 +2794,18 @@ discard block |
||
2794 | 2794 | // grab single id and delete |
2795 | 2795 | $ATT_ID = absint($this->_req_data['ATT_ID']); |
2796 | 2796 | //get attendee |
2797 | - $att = $ATT_MDL->get_one_by_ID( $ATT_ID ); |
|
2797 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
2798 | 2798 | $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
2799 | 2799 | $updated = $att->save(); |
2800 | - if ( ! $updated ) { |
|
2800 | + if ( ! $updated) { |
|
2801 | 2801 | $success = 0; |
2802 | 2802 | } |
2803 | 2803 | |
2804 | 2804 | } |
2805 | 2805 | |
2806 | - $what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' ); |
|
2807 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
2808 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) ); |
|
2806 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
2807 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2808 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
2809 | 2809 | |
2810 | 2810 | } |
2811 | 2811 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( |
|
100 | + if ( |
|
101 | 101 | apply_filters( |
102 | 102 | 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
103 | - ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
104 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) |
|
103 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
104 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
105 | 105 | ) |
106 | 106 | ) { |
107 | 107 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | } |
110 | 110 | //ok they're using the WP API with Basic Auth |
111 | 111 | $message = sprintf( |
112 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
112 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
113 | 113 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
114 | 114 | '</a>', |
115 | 115 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
116 | 116 | '<br/>' |
117 | 117 | ); |
118 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
119 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
120 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
118 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
119 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
120 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
121 | 121 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
122 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
122 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
123 | 123 | //and send the message to the site admin too |
124 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
125 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
124 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
125 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | /** |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * appear the same as they always did |
131 | 131 | */ |
132 | 132 | protected static function _set_hooks_for_changes() { |
133 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
134 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
133 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
134 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
135 | 135 | //ignore the base parent class |
136 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
136 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
140 | - if ( class_exists( $full_classname )) { |
|
139 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
140 | + if (class_exists($full_classname)) { |
|
141 | 141 | $instance_of_class = new $full_classname; |
142 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
142 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
143 | 143 | $instance_of_class->set_hooks(); |
144 | 144 | } |
145 | 145 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
153 | 153 | */ |
154 | 154 | public static function register_routes() { |
155 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
156 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
157 | - foreach( $routes as $route ) { |
|
155 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
156 | + foreach ($relative_urls as $endpoint => $routes) { |
|
157 | + foreach ($routes as $route) { |
|
158 | 158 | register_rest_route( |
159 | 159 | $namespace, |
160 | 160 | $endpoint, |
161 | 161 | array( |
162 | - 'callback' => $route[ 'callback' ], |
|
163 | - 'methods' => $route[ 'methods' ], |
|
164 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
162 | + 'callback' => $route['callback'], |
|
163 | + 'methods' => $route['methods'], |
|
164 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
165 | 165 | ) |
166 | 166 | ); |
167 | 167 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * next time the WP API is used |
176 | 176 | */ |
177 | 177 | public static function invalidate_cached_route_data_on_version_change() { |
178 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
178 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
179 | 179 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
180 | 180 | } |
181 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
182 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
181 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
182 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
183 | 183 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
184 | 184 | } |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function invalidate_cached_route_data() { |
192 | 192 | //delete the saved EE REST API routes |
193 | - foreach( EED_Core_Rest_Api::versions_served() as $version => $hidden ){ |
|
194 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names . $version ); |
|
193 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
194 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function get_ee_route_data() { |
207 | 207 | $ee_routes = array(); |
208 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
209 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
208 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
209 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
210 | 210 | } |
211 | 211 | return $ee_routes; |
212 | 212 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @param boolean $hidden_endpoints |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
222 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
223 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
224 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
221 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
222 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
223 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
224 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
225 | 225 | } |
226 | 226 | return $ee_routes; |
227 | 227 | } |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param boolean $hidden_endpoints |
236 | 236 | * @return mixed|null|void |
237 | 237 | */ |
238 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
238 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
239 | 239 | $instance = self::instance(); |
240 | 240 | $routes = apply_filters( |
241 | 241 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
242 | 242 | array_replace_recursive( |
243 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
244 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
245 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
246 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
243 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
244 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
245 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
246 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
247 | 247 | ) |
248 | 248 | ); |
249 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
249 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
250 | 250 | return $routes; |
251 | 251 | } |
252 | 252 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return void |
258 | 258 | */ |
259 | 259 | public static function save_ee_routes() { |
260 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
260 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
261 | 261 | $instance = self::instance(); |
262 | 262 | $routes = apply_filters( |
263 | 263 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $instance->_register_rpc_routes() |
269 | 269 | ) |
270 | 270 | ); |
271 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
271 | + update_option(self::saved_routes_option_names, $routes, true); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | */ |
280 | 280 | protected function _register_model_routes() { |
281 | 281 | $model_routes = array( ); |
282 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
283 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
282 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
283 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
284 | 284 | } |
285 | 285 | return $model_routes; |
286 | 286 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param boolean $hidden_endpoint |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
295 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
294 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
295 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
296 | 296 | $models_to_register = apply_filters( |
297 | 297 | 'FHEE__EED_Core_REST_API___register_model_routes', |
298 | 298 | $model_version_info->models_for_requested_version() |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | unset($models_to_register['Extra_Meta']); |
302 | 302 | unset($models_to_register['Extra_Join']); |
303 | 303 | $model_routes = array(); |
304 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
305 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
304 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
305 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
306 | 306 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
307 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
308 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
309 | - $model_routes[ $plural_model_route ] = array( |
|
307 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
308 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
309 | + $model_routes[$plural_model_route] = array( |
|
310 | 310 | array( |
311 | 311 | 'callback' => array( |
312 | 312 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
313 | 313 | 'handle_request_get_all' ), |
314 | 314 | 'methods' => WP_REST_Server::READABLE, |
315 | 315 | 'hidden_endpoint' => $hidden_endpoint, |
316 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
316 | + 'args' => $this->_get_read_query_params($model, $version), |
|
317 | 317 | '_links' => array( |
318 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
318 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
319 | 319 | ) |
320 | 320 | ), |
321 | 321 | // array( |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | // 'hidden_endpoint' => $hidden_endpoint |
327 | 327 | // ) |
328 | 328 | ); |
329 | - $model_routes[ $singular_model_route ] = array( |
|
329 | + $model_routes[$singular_model_route] = array( |
|
330 | 330 | array( |
331 | 331 | 'callback' => array( |
332 | 332 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
333 | 333 | 'handle_request_get_one' ), |
334 | 334 | 'methods' => WP_REST_Server::READABLE, |
335 | 335 | 'hidden_endpoint' => $hidden_endpoint, |
336 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
336 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
337 | 337 | ), |
338 | 338 | // array( |
339 | 339 | // 'callback' => array( |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | // ), |
345 | 345 | ); |
346 | 346 | //@todo: also handle DELETE for a single item |
347 | - foreach ( $model_version_info->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
347 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
348 | 348 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
349 | 349 | $relation_name, |
350 | 350 | $relation_obj |
351 | 351 | ); |
352 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
352 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
353 | 353 | array( |
354 | 354 | 'callback' => array( |
355 | 355 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
356 | 356 | 'handle_request_get_related' ), |
357 | 357 | 'methods' => WP_REST_Server::READABLE, |
358 | 358 | 'hidden_endpoint' => $hidden_endpoint, |
359 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
359 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
360 | 360 | ), |
361 | 361 | // array( |
362 | 362 | // 'callback' => array( |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | protected function _register_rpc_routes() { |
381 | 381 | $routes = array(); |
382 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
383 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
382 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
383 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
384 | 384 | } |
385 | 385 | return $routes; |
386 | 386 | } |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param boolean $hidden_endpoint |
392 | 392 | * @return array |
393 | 393 | */ |
394 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
394 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
395 | 395 | $this_versions_routes = array(); |
396 | 396 | //checkin endpoint |
397 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
397 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
398 | 398 | array( |
399 | 399 | 'callback' => array( |
400 | 400 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | 'force' => array( |
406 | 406 | 'required' => false, |
407 | 407 | 'default' => false, |
408 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
408 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
409 | 409 | ) |
410 | 410 | ) |
411 | 411 | ) |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $version |
425 | 425 | * @return array |
426 | 426 | */ |
427 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
427 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
428 | 428 | return apply_filters( |
429 | 429 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
430 | 430 | array( |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'calculate' => array( |
436 | 436 | 'required' => false, |
437 | 437 | 'default' => '', |
438 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
438 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | $model, |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | * @return array describing the args acceptable when querying this model |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
456 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
457 | 457 | $default_orderby = array(); |
458 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
459 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
458 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
459 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
460 | 460 | } |
461 | 461 | return array_merge( |
462 | - $this->_get_response_selection_query_params( $model, $version ), |
|
462 | + $this->_get_response_selection_query_params($model, $version), |
|
463 | 463 | array( |
464 | 464 | 'where' => array( |
465 | 465 | 'required' => false, |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | */ |
497 | 497 | protected function _register_config_routes() { |
498 | 498 | $config_routes = array(); |
499 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
500 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
499 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
500 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
501 | 501 | } |
502 | 502 | return $config_routes; |
503 | 503 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param boolean $hidden_endpoint |
509 | 509 | * @return array |
510 | 510 | */ |
511 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
511 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
512 | 512 | return array( |
513 | 513 | 'config' => array( |
514 | 514 | array( |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function _register_meta_routes() { |
540 | 540 | $meta_routes = array(); |
541 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
542 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
541 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
542 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
543 | 543 | } |
544 | 544 | return $meta_routes; |
545 | 545 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param boolean $hidden_endpoint |
551 | 551 | * @return array |
552 | 552 | */ |
553 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
553 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
554 | 554 | return array( |
555 | 555 | 'resources' => array( |
556 | 556 | array( |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | * @param array $route_data |
573 | 573 | * @return array |
574 | 574 | */ |
575 | - public static function hide_old_endpoints( $route_data ) { |
|
576 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
577 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
578 | - foreach( $routes as $route ) { |
|
579 | - if( $route[ 'hidden_endpoint' ] ) { |
|
580 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
581 | - unset( $route_data[ $full_route ] ); |
|
575 | + public static function hide_old_endpoints($route_data) { |
|
576 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
577 | + foreach ($relative_urls as $endpoint => $routes) { |
|
578 | + foreach ($routes as $route) { |
|
579 | + if ($route['hidden_endpoint']) { |
|
580 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
581 | + unset($route_data[$full_route]); |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public static function latest_rest_api_version() { |
619 | 619 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
620 | - $versions_served_keys = array_keys( $versions_served ); |
|
621 | - return end( $versions_served_keys ); |
|
620 | + $versions_served_keys = array_keys($versions_served); |
|
621 | + return end($versions_served_keys); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -632,32 +632,32 @@ discard block |
||
632 | 632 | public static function versions_served() { |
633 | 633 | $versions_served = array(); |
634 | 634 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
635 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
636 | - reset( $possibly_served_versions ); |
|
637 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
638 | - $latest_version = end( $versions_served_historically ); |
|
639 | - reset( $versions_served_historically ); |
|
635 | + $lowest_compatible_version = end($possibly_served_versions); |
|
636 | + reset($possibly_served_versions); |
|
637 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
638 | + $latest_version = end($versions_served_historically); |
|
639 | + reset($versions_served_historically); |
|
640 | 640 | //for each version of core we have ever served: |
641 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
641 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
642 | 642 | //if it's not above the current core version, and it's compatible with the current version of core |
643 | - if( $key_versioned_endpoint == $latest_version ) { |
|
643 | + if ($key_versioned_endpoint == $latest_version) { |
|
644 | 644 | //don't hide the latest version in the index |
645 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
646 | - } else if( |
|
645 | + $versions_served[$key_versioned_endpoint] = false; |
|
646 | + } else if ( |
|
647 | 647 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
648 | 648 | && $key_versioned_endpoint >= $lowest_compatible_version |
649 | 649 | ) { |
650 | 650 | //include, but hide, previous versions which are still supported |
651 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
652 | - } elseif( |
|
651 | + $versions_served[$key_versioned_endpoint] = true; |
|
652 | + } elseif ( |
|
653 | 653 | apply_filters( |
654 | 654 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
655 | 655 | false, |
656 | 656 | $possibly_served_versions |
657 | 657 | ) |
658 | - ){ |
|
658 | + ) { |
|
659 | 659 | //if a version is no longer supported, don't include it in index or list of versions served |
660 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
660 | + $versions_served[$key_versioned_endpoint] = true; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | return $versions_served; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @return string |
671 | 671 | */ |
672 | 672 | public static function core_version() { |
673 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
673 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | * @param WP $WP |
696 | 696 | * @return void |
697 | 697 | */ |
698 | - public function run( $WP ) { |
|
698 | + public function run($WP) { |
|
699 | 699 | |
700 | 700 | } |
701 | 701 |