@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
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 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param int $code |
26 | 26 | * @param \Exception $previous |
27 | 27 | */ |
28 | - public function __construct( $command_name, $message = '', $code = 0, \Exception $previous = null ) { |
|
29 | - if ( empty( $message ) ) { |
|
28 | + public function __construct($command_name, $message = '', $code = 0, \Exception $previous = null) { |
|
29 | + if (empty($message)) { |
|
30 | 30 | $message = sprintf( |
31 | - __( 'The supplied Command Handler "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', 'event_espresso' ), |
|
31 | + __('The supplied Command Handler "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', 'event_espresso'), |
|
32 | 32 | $command_name |
33 | 33 | ); |
34 | 34 | } |
35 | - parent::__construct( $message, $code, $previous ); |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
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 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param \EventEspresso\core\services\commands\CommandInterface $command |
20 | 20 | * @return mixed |
21 | 21 | */ |
22 | - public function handle( CommandInterface $command ); |
|
22 | + public function handle(CommandInterface $command); |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | // End of file CommandHandlerInterface.php |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
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 | |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | * @param \EventEspresso\core\services\commands\CommandHandlerInterface $command_handler |
20 | 20 | * @return mixed |
21 | 21 | */ |
22 | - public function addCommandHandler( CommandHandlerInterface $command_handler ); |
|
22 | + public function addCommandHandler(CommandHandlerInterface $command_handler); |
|
23 | 23 | |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @param \EventEspresso\core\services\commands\CommandInterface $command |
27 | 27 | * @return mixed |
28 | 28 | */ |
29 | - public function getCommandHandler( CommandInterface $command ); |
|
29 | + public function getCommandHandler(CommandInterface $command); |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | // End of file CommandHandlerManagerInterface.php |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * just checks the field isn't blank |
27 | 27 | * |
28 | 28 | * @param $normalized_value |
29 | - * @return bool |
|
29 | + * @return boolean|null |
|
30 | 30 | * @throws \EE_Validation_Error |
31 | 31 | */ |
32 | 32 | function validate($normalized_value) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param \EE_Request $request |
76 | 76 | * @param \EE_Response $response |
77 | 77 | */ |
78 | - protected function __construct( EE_Request $request, EE_Response $response ) { |
|
78 | + protected function __construct(EE_Request $request, EE_Response $response) { |
|
79 | 79 | $this->_request = $request; |
80 | 80 | $this->_response = $response; |
81 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
82 | - do_action( 'EE_Dependency_Map____construct' ); |
|
81 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
82 | + do_action('EE_Dependency_Map____construct'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | * @param \EE_Response $response |
102 | 102 | * @return \EE_Dependency_Map instance |
103 | 103 | */ |
104 | - public static function instance( EE_Request $request = null, EE_Response $response = null ) { |
|
104 | + public static function instance(EE_Request $request = null, EE_Response $response = null) { |
|
105 | 105 | // check if class object is instantiated, and instantiated properly |
106 | - if ( ! self::$_instance instanceof EE_Dependency_Map ) { |
|
107 | - self::$_instance = new EE_Dependency_Map( $request, $response ); |
|
106 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
107 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
108 | 108 | } |
109 | 109 | return self::$_instance; |
110 | 110 | } |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * @param array $dependencies |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public static function register_dependencies( $class, $dependencies ) { |
|
120 | - if ( ! isset( self::$_instance->_dependency_map[ $class ] ) ) { |
|
119 | + public static function register_dependencies($class, $dependencies) { |
|
120 | + if ( ! isset(self::$_instance->_dependency_map[$class])) { |
|
121 | 121 | // we need to make sure that any aliases used when registering a dependency |
122 | 122 | // get resolved to the correct class name |
123 | - foreach ( (array) $dependencies as $dependency => $load_source ) { |
|
124 | - $alias = self::$_instance->get_alias( $dependency ); |
|
125 | - unset( $dependencies[ $dependency ] ); |
|
126 | - $dependencies[ $alias ] = $load_source; |
|
123 | + foreach ((array) $dependencies as $dependency => $load_source) { |
|
124 | + $alias = self::$_instance->get_alias($dependency); |
|
125 | + unset($dependencies[$dependency]); |
|
126 | + $dependencies[$alias] = $load_source; |
|
127 | 127 | } |
128 | - self::$_instance->_dependency_map[ $class ] = (array) $dependencies; |
|
128 | + self::$_instance->_dependency_map[$class] = (array) $dependencies; |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | return false; |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | * @return bool |
140 | 140 | * @throws \EE_Error |
141 | 141 | */ |
142 | - public static function register_class_loader( $class_name, $loader = 'load_core' ) { |
|
142 | + public static function register_class_loader($class_name, $loader = 'load_core') { |
|
143 | 143 | // check that loader method starts with "load_" and exists in EE_Registry |
144 | - if ( strpos( $loader, 'load_' ) !== 0 || ! method_exists( 'EE_Registry', $loader ) ) { |
|
144 | + if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) { |
|
145 | 145 | throw new EE_Error( |
146 | 146 | sprintf( |
147 | - __( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ), |
|
147 | + __('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'), |
|
148 | 148 | $loader |
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
152 | - $class_name = self::$_instance->get_alias( $class_name ); |
|
153 | - if ( ! isset( self::$_instance->_class_loaders[ $class_name ] ) ) { |
|
154 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
152 | + $class_name = self::$_instance->get_alias($class_name); |
|
153 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
154 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
155 | 155 | return true; |
156 | 156 | } |
157 | 157 | return false; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param string $class_name |
175 | 175 | * @return boolean |
176 | 176 | */ |
177 | - public function has( $class_name = '' ) { |
|
178 | - return isset( $this->_dependency_map[ $class_name ] ) ? true : false; |
|
177 | + public function has($class_name = '') { |
|
178 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param string $dependency |
188 | 188 | * @return bool |
189 | 189 | */ |
190 | - public function has_dependency_for_class( $class_name = '', $dependency = '' ) { |
|
191 | - $dependency = $this->get_alias( $dependency ); |
|
192 | - return isset( $this->_dependency_map[ $class_name ], $this->_dependency_map[ $class_name ][ $dependency ] ) |
|
190 | + public function has_dependency_for_class($class_name = '', $dependency = '') { |
|
191 | + $dependency = $this->get_alias($dependency); |
|
192 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
193 | 193 | ? true |
194 | 194 | : false; |
195 | 195 | } |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | * @param string $dependency |
204 | 204 | * @return int |
205 | 205 | */ |
206 | - public function loading_strategy_for_class_dependency( $class_name = '', $dependency = '' ) { |
|
207 | - $dependency = $this->get_alias( $dependency ); |
|
208 | - return $this->has_dependency_for_class( $class_name, $dependency ) |
|
209 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
206 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') { |
|
207 | + $dependency = $this->get_alias($dependency); |
|
208 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
209 | + ? $this->_dependency_map[$class_name][$dependency] |
|
210 | 210 | : EE_Dependency_Map::not_registered; |
211 | 211 | } |
212 | 212 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @param string $class_name |
217 | 217 | * @return string | Closure |
218 | 218 | */ |
219 | - public function class_loader( $class_name ) { |
|
220 | - $class_name = $this->get_alias( $class_name ); |
|
221 | - return isset( $this->_class_loaders[ $class_name ] ) ? $this->_class_loaders[ $class_name ] : ''; |
|
219 | + public function class_loader($class_name) { |
|
220 | + $class_name = $this->get_alias($class_name); |
|
221 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @param string $alias |
240 | 240 | * @return bool |
241 | 241 | */ |
242 | - public function add_alias( $class_name, $alias ) { |
|
243 | - $this->_aliases[ $class_name ] = $alias; |
|
242 | + public function add_alias($class_name, $alias) { |
|
243 | + $this->_aliases[$class_name] = $alias; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param string $class_name |
252 | 252 | * @return boolean |
253 | 253 | */ |
254 | - public function has_alias( $class_name = '' ) { |
|
255 | - return isset( $this->_aliases[ $class_name ] ) ? true : false; |
|
254 | + public function has_alias($class_name = '') { |
|
255 | + return isset($this->_aliases[$class_name]) ? true : false; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | * @param string $class_name |
273 | 273 | * @return boolean |
274 | 274 | */ |
275 | - public function get_alias( $class_name = '' ) { |
|
276 | - return $this->has_alias( $class_name ) |
|
277 | - ? $this->get_alias( $this->_aliases[ $class_name ] ) |
|
275 | + public function get_alias($class_name = '') { |
|
276 | + return $this->has_alias($class_name) |
|
277 | + ? $this->get_alias($this->_aliases[$class_name]) |
|
278 | 278 | : $class_name; |
279 | 279 | } |
280 | 280 | |
@@ -461,17 +461,17 @@ discard block |
||
461 | 461 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
462 | 462 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
463 | 463 | 'EE_Messages_Generator' => function() { |
464 | - return EE_Registry::instance()->load_lib( 'Messages_Generator', array(), false, false ); |
|
464 | + return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false); |
|
465 | 465 | }, |
466 | - 'EE_Messages_Template_Defaults' => function( $arguments = array() ) { |
|
467 | - return EE_Registry::instance()->load_lib( 'Messages_Template_Defaults', $arguments, false, false ); |
|
466 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
467 | + return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false); |
|
468 | 468 | }, |
469 | 469 | //load_model |
470 | 470 | 'EEM_Message_Template_Group' => 'load_model', |
471 | 471 | 'EEM_Message_Template' => 'load_model', |
472 | 472 | //load_helper |
473 | 473 | 'EEH_Parse_Shortcodes' => function() { |
474 | - if ( EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ) ) { |
|
474 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
475 | 475 | return new EEH_Parse_Shortcodes(); |
476 | 476 | } |
477 | 477 | return null; |
@@ -968,7 +968,7 @@ |
||
968 | 968 | $dependency = null; |
969 | 969 | // should dependency be loaded from cache ? |
970 | 970 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( $class_name, $param_class ) |
971 | - !== EE_Dependency_Map::load_new_object |
|
971 | + !== EE_Dependency_Map::load_new_object |
|
972 | 972 | ? true |
973 | 973 | : false; |
974 | 974 | // we might have a dependency... |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @param \EE_Dependency_Map $dependency_map |
185 | 185 | * @return \EE_Registry instance |
186 | 186 | */ |
187 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
187 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
188 | 188 | // check if class object is instantiated |
189 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
190 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
189 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
190 | + self::$_instance = new EE_Registry($dependency_map); |
|
191 | 191 | } |
192 | 192 | return self::$_instance; |
193 | 193 | } |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | * @param \EE_Dependency_Map $dependency_map |
203 | 203 | * @return \EE_Registry |
204 | 204 | */ |
205 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
205 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
206 | 206 | $this->_dependency_map = $dependency_map; |
207 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
207 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | $this->modules = new stdClass(); |
233 | 233 | $this->shortcodes = new stdClass(); |
234 | 234 | $this->widgets = new stdClass(); |
235 | - $this->load_core( 'Base', array(), true ); |
|
235 | + $this->load_core('Base', array(), true); |
|
236 | 236 | // add our request and response objects to the cache |
237 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
237 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
238 | 238 | $this->_set_cached_class( |
239 | 239 | $request_loader(), |
240 | 240 | 'EE_Request' |
241 | 241 | ); |
242 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
242 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
243 | 243 | $this->_set_cached_class( |
244 | 244 | $response_loader(), |
245 | 245 | 'EE_Response' |
246 | 246 | ); |
247 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
247 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function init() { |
259 | 259 | // Get current page protocol |
260 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
260 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
261 | 261 | // Output admin-ajax.php URL with same protocol as current page |
262 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
263 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
262 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
263 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | * @return string |
272 | 272 | */ |
273 | 273 | public static function localize_i18n_js_strings() { |
274 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
275 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
276 | - if ( is_scalar( $value ) ) { |
|
277 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
274 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
275 | + foreach ($i18n_js_strings as $key => $value) { |
|
276 | + if (is_scalar($value)) { |
|
277 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
281 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * @param mixed string | EED_Module $module |
288 | 288 | */ |
289 | - public function add_module( $module ) { |
|
290 | - if ( $module instanceof EED_Module ) { |
|
291 | - $module_class = get_class( $module ); |
|
289 | + public function add_module($module) { |
|
290 | + if ($module instanceof EED_Module) { |
|
291 | + $module_class = get_class($module); |
|
292 | 292 | $this->modules->{$module_class} = $module; |
293 | 293 | } else { |
294 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
295 | - $this->load_core( 'Module_Request_Router' ); |
|
294 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
295 | + $this->load_core('Module_Request_Router'); |
|
296 | 296 | } |
297 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
297 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * @param string $module_name |
305 | 305 | * @return mixed EED_Module | NULL |
306 | 306 | */ |
307 | - public function get_module( $module_name = '' ) { |
|
308 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
307 | + public function get_module($module_name = '') { |
|
308 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -319,20 +319,20 @@ discard block |
||
319 | 319 | * @param bool $load_only |
320 | 320 | * @return mixed |
321 | 321 | */ |
322 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
322 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
323 | 323 | $core_paths = apply_filters( |
324 | 324 | 'FHEE__EE_Registry__load_core__core_paths', |
325 | 325 | array( |
326 | 326 | EE_CORE, |
327 | 327 | EE_ADMIN, |
328 | 328 | EE_CPTS, |
329 | - EE_CORE . 'data_migration_scripts' . DS, |
|
330 | - EE_CORE . 'request_stack' . DS, |
|
331 | - EE_CORE . 'middleware' . DS, |
|
329 | + EE_CORE.'data_migration_scripts'.DS, |
|
330 | + EE_CORE.'request_stack'.DS, |
|
331 | + EE_CORE.'middleware'.DS, |
|
332 | 332 | ) |
333 | 333 | ); |
334 | 334 | // retrieve instantiated class |
335 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
335 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | * @param bool $load_only |
347 | 347 | * @return mixed |
348 | 348 | */ |
349 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
349 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
350 | 350 | $service_paths = apply_filters( |
351 | 351 | 'FHEE__EE_Registry__load_service__service_paths', |
352 | 352 | array( |
353 | - EE_CORE . 'services' . DS, |
|
353 | + EE_CORE.'services'.DS, |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | // retrieve instantiated class |
357 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
357 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @param mixed $arguments |
368 | 368 | * @return EE_Data_Migration_Script_Base |
369 | 369 | */ |
370 | - public function load_dms( $class_name, $arguments = array() ) { |
|
370 | + public function load_dms($class_name, $arguments = array()) { |
|
371 | 371 | // retrieve instantiated class |
372 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
372 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
385 | 385 | * @return EE_Base_Class | bool |
386 | 386 | */ |
387 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
388 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
387 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
388 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
389 | 389 | EE_CORE, |
390 | 390 | EE_CLASSES, |
391 | 391 | EE_BUSINESS |
392 | - ) ); |
|
392 | + )); |
|
393 | 393 | // retrieve instantiated class |
394 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
394 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | * @param bool $load_only |
405 | 405 | * @return EEH_Base | bool |
406 | 406 | */ |
407 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
407 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
408 | 408 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
409 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
409 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
410 | 410 | // retrieve instantiated class |
411 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
411 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | * @param bool $cache whether to cache the object or not. |
424 | 424 | * @return mixed |
425 | 425 | */ |
426 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
426 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
427 | 427 | $paths = array( |
428 | 428 | EE_LIBRARIES, |
429 | - EE_LIBRARIES . 'messages' . DS, |
|
430 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
431 | - EE_LIBRARIES . 'qtips' . DS, |
|
432 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
429 | + EE_LIBRARIES.'messages'.DS, |
|
430 | + EE_LIBRARIES.'shortcodes'.DS, |
|
431 | + EE_LIBRARIES.'qtips'.DS, |
|
432 | + EE_LIBRARIES.'payment_methods'.DS, |
|
433 | 433 | ); |
434 | 434 | // retrieve instantiated class |
435 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
435 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * @param bool $load_only |
446 | 446 | * @return EEM_Base | bool |
447 | 447 | */ |
448 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
449 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
448 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
449 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
450 | 450 | EE_MODELS, |
451 | 451 | EE_CORE |
452 | - ) ); |
|
452 | + )); |
|
453 | 453 | // retrieve instantiated class |
454 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
454 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | * @param bool $load_only |
465 | 465 | * @return mixed | bool |
466 | 466 | */ |
467 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
467 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
468 | 468 | $paths = array( |
469 | - EE_MODELS . 'fields' . DS, |
|
470 | - EE_MODELS . 'helpers' . DS, |
|
471 | - EE_MODELS . 'relations' . DS, |
|
472 | - EE_MODELS . 'strategies' . DS |
|
469 | + EE_MODELS.'fields'.DS, |
|
470 | + EE_MODELS.'helpers'.DS, |
|
471 | + EE_MODELS.'relations'.DS, |
|
472 | + EE_MODELS.'strategies'.DS |
|
473 | 473 | ); |
474 | 474 | // retrieve instantiated class |
475 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
475 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
483 | 483 | * @return boolean |
484 | 484 | */ |
485 | - public function is_model_name( $model_name ) { |
|
486 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
485 | + public function is_model_name($model_name) { |
|
486 | + return isset($this->models[$model_name]) ? true : false; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * @param bool $load_only |
499 | 499 | * @return mixed |
500 | 500 | */ |
501 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
501 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
502 | 502 | // retrieve instantiated class |
503 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
503 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | * @param bool $load_only |
516 | 516 | * @return EE_Addon |
517 | 517 | */ |
518 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
518 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
519 | 519 | // retrieve instantiated class |
520 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
520 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -548,35 +548,35 @@ discard block |
||
548 | 548 | $load_only = false, |
549 | 549 | $addon = false |
550 | 550 | ) { |
551 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
552 | - if ( ! class_exists( $class_name ) ) { |
|
551 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
552 | + if ( ! class_exists($class_name)) { |
|
553 | 553 | // maybe the class is registered with a preceding \ |
554 | - $class_name = strpos( $class_name, '\\' ) !== 0 ? '\\' . $class_name : $class_name; |
|
554 | + $class_name = strpos($class_name, '\\') !== 0 ? '\\'.$class_name : $class_name; |
|
555 | 555 | // still doesn't exist ? |
556 | - if ( ! class_exists( $class_name ) ) { |
|
556 | + if ( ! class_exists($class_name)) { |
|
557 | 557 | return null; |
558 | 558 | } |
559 | 559 | } |
560 | 560 | // if we're only loading the class and it already exists, then let's just return true immediately |
561 | - if ( $load_only ) { |
|
561 | + if ($load_only) { |
|
562 | 562 | return true; |
563 | 563 | } |
564 | 564 | $addon = $addon ? 'addon' : ''; |
565 | 565 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
566 | 566 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
567 | 567 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
568 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
568 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
569 | 569 | // return object if it's already cached |
570 | - $cached_class = $this->_get_cached_class( $class_name, $addon ); |
|
571 | - if ( $cached_class !== null ) { |
|
570 | + $cached_class = $this->_get_cached_class($class_name, $addon); |
|
571 | + if ($cached_class !== null) { |
|
572 | 572 | return $cached_class; |
573 | 573 | } |
574 | 574 | } |
575 | 575 | // instantiate the requested object |
576 | - $class_obj = $this->_create_object( $class_name, $arguments, $addon, $from_db ); |
|
577 | - if ( $this->_cache_on && $cache ) { |
|
576 | + $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db); |
|
577 | + if ($this->_cache_on && $cache) { |
|
578 | 578 | // save it for later... kinda like gum { : $ |
579 | - $this->_set_cached_class( $class_obj, $class_name, $addon, $from_db ); |
|
579 | + $this->_set_cached_class($class_obj, $class_name, $addon, $from_db); |
|
580 | 580 | } |
581 | 581 | $this->_cache_on = true; |
582 | 582 | return $class_obj; |
@@ -611,47 +611,47 @@ discard block |
||
611 | 611 | $load_only = false |
612 | 612 | ) { |
613 | 613 | // strip php file extension |
614 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
614 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
615 | 615 | // does the class have a prefix ? |
616 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
616 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
617 | 617 | // make sure $class_prefix is uppercase |
618 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
618 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
619 | 619 | // add class prefix ONCE!!! |
620 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
620 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
621 | 621 | } |
622 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
623 | - $class_exists = class_exists( $class_name ); |
|
622 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
623 | + $class_exists = class_exists($class_name); |
|
624 | 624 | // if we're only loading the class and it already exists, then let's just return true immediately |
625 | - if ( $load_only && $class_exists ) { |
|
625 | + if ($load_only && $class_exists) { |
|
626 | 626 | return true; |
627 | 627 | } |
628 | 628 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
629 | 629 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
630 | 630 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
631 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
631 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
632 | 632 | // return object if it's already cached |
633 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
634 | - if ( $cached_class !== null ) { |
|
633 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
634 | + if ($cached_class !== null) { |
|
635 | 635 | return $cached_class; |
636 | 636 | } |
637 | 637 | } |
638 | 638 | // if the class doesn't already exist.. then we need to try and find the file and load it |
639 | - if ( ! $class_exists ) { |
|
639 | + if ( ! $class_exists) { |
|
640 | 640 | // get full path to file |
641 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
641 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
642 | 642 | // load the file |
643 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
643 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
644 | 644 | // if loading failed, or we are only loading a file but NOT instantiating an object |
645 | - if ( ! $loaded || $load_only ) { |
|
645 | + if ( ! $loaded || $load_only) { |
|
646 | 646 | // return boolean if only loading, or null if an object was expected |
647 | 647 | return $load_only ? $loaded : null; |
648 | 648 | } |
649 | 649 | } |
650 | 650 | // instantiate the requested object |
651 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
652 | - if ( $this->_cache_on && $cache ) { |
|
651 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
652 | + if ($this->_cache_on && $cache) { |
|
653 | 653 | // save it for later... kinda like gum { : $ |
654 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
654 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
655 | 655 | } |
656 | 656 | $this->_cache_on = true; |
657 | 657 | return $class_obj; |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | * @param string $class_prefix |
675 | 675 | * @return null|object |
676 | 676 | */ |
677 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
678 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
679 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
677 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
678 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
679 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
680 | 680 | } else { |
681 | 681 | // have to specify something, but not anything that will conflict |
682 | 682 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
683 | 683 | } |
684 | 684 | // check if class has already been loaded, and return it if it has been |
685 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
685 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
686 | 686 | return $this->{$class_abbreviation}; |
687 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
687 | + } else if (isset ($this->{$class_name} )) { |
|
688 | 688 | return $this->{$class_name}; |
689 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
689 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
690 | 690 | return $this->LIB->{$class_name}; |
691 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
691 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
692 | 692 | return $this->addons->{$class_name}; |
693 | 693 | } |
694 | 694 | return null; |
@@ -709,20 +709,20 @@ discard block |
||
709 | 709 | * @param array $file_paths |
710 | 710 | * @return string | bool |
711 | 711 | */ |
712 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
712 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
713 | 713 | // make sure $file_paths is an array |
714 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
714 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
715 | 715 | // cycle thru paths |
716 | - foreach ( $file_paths as $key => $file_path ) { |
|
716 | + foreach ($file_paths as $key => $file_path) { |
|
717 | 717 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
718 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
718 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
719 | 719 | // prep file type |
720 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
720 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
721 | 721 | // build full file path |
722 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
722 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
723 | 723 | //does the file exist and can be read ? |
724 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
725 | - return $file_paths[ $key ]; |
|
724 | + if (is_readable($file_paths[$key])) { |
|
725 | + return $file_paths[$key]; |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | return false; |
@@ -744,29 +744,29 @@ discard block |
||
744 | 744 | * @return boolean |
745 | 745 | * @throws \EE_Error |
746 | 746 | */ |
747 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
747 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
748 | 748 | // don't give up! you gotta... |
749 | 749 | try { |
750 | 750 | //does the file exist and can it be read ? |
751 | - if ( ! $path ) { |
|
751 | + if ( ! $path) { |
|
752 | 752 | // so sorry, can't find the file |
753 | - throw new EE_Error ( |
|
753 | + throw new EE_Error( |
|
754 | 754 | sprintf( |
755 | - __( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ), |
|
756 | - trim( $type, '.' ), |
|
755 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
756 | + trim($type, '.'), |
|
757 | 757 | $class_name, |
758 | - '<br />' . implode( ',<br />', $file_paths ) |
|
758 | + '<br />'.implode(',<br />', $file_paths) |
|
759 | 759 | ) |
760 | 760 | ); |
761 | 761 | } |
762 | 762 | // get the file |
763 | - require_once( $path ); |
|
763 | + require_once($path); |
|
764 | 764 | // if the class isn't already declared somewhere |
765 | - if ( class_exists( $class_name, false ) === false ) { |
|
765 | + if (class_exists($class_name, false) === false) { |
|
766 | 766 | // so sorry, not a class |
767 | 767 | throw new EE_Error( |
768 | 768 | sprintf( |
769 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
769 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
770 | 770 | $type, |
771 | 771 | $path, |
772 | 772 | $class_name |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
777 | - } catch ( EE_Error $e ) { |
|
777 | + } catch (EE_Error $e) { |
|
778 | 778 | $e->get_error(); |
779 | 779 | return false; |
780 | 780 | } |
@@ -806,61 +806,61 @@ discard block |
||
806 | 806 | * @return null | object |
807 | 807 | * @throws \EE_Error |
808 | 808 | */ |
809 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
809 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
810 | 810 | $class_obj = null; |
811 | 811 | $instantiation_mode = '0) none'; |
812 | 812 | // don't give up! you gotta... |
813 | 813 | try { |
814 | 814 | // create reflection |
815 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
815 | + $reflector = $this->get_ReflectionClass($class_name); |
|
816 | 816 | // make sure arguments are an array |
817 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
817 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
818 | 818 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
819 | 819 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
820 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
820 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
821 | 821 | ? $arguments |
822 | - : array( $arguments ); |
|
822 | + : array($arguments); |
|
823 | 823 | // attempt to inject dependencies ? |
824 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
825 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
824 | + if ($this->_dependency_map->has($class_name)) { |
|
825 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
826 | 826 | } |
827 | 827 | // instantiate the class if possible |
828 | - if ( $reflector->isAbstract() ) { |
|
828 | + if ($reflector->isAbstract()) { |
|
829 | 829 | // nothing to instantiate, loading file was enough |
830 | 830 | // does not throw an exception so $instantiation_mode is unused |
831 | 831 | // $instantiation_mode = "1) no constructor abstract class"; |
832 | 832 | $class_obj = true; |
833 | - } else if ( $reflector->getConstructor() === null && $reflector->isInstantiable() && empty( $arguments ) ) { |
|
833 | + } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) { |
|
834 | 834 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
835 | 835 | $instantiation_mode = "2) no constructor but instantiable"; |
836 | 836 | $class_obj = $reflector->newInstance(); |
837 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
837 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
838 | 838 | $instantiation_mode = "3) new_instance_from_db()"; |
839 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
840 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
839 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
840 | + } else if (method_exists($class_name, 'new_instance')) { |
|
841 | 841 | $instantiation_mode = "4) new_instance()"; |
842 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
843 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
842 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
843 | + } else if (method_exists($class_name, 'instance')) { |
|
844 | 844 | $instantiation_mode = "5) instance()"; |
845 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
846 | - } else if ( $reflector->isInstantiable() ) { |
|
845 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
846 | + } else if ($reflector->isInstantiable()) { |
|
847 | 847 | $instantiation_mode = "6) constructor"; |
848 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
848 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
849 | 849 | } else { |
850 | 850 | // heh ? something's not right ! |
851 | 851 | throw new EE_Error( |
852 | 852 | sprintf( |
853 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
853 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
854 | 854 | $type, |
855 | 855 | $class_name |
856 | 856 | ) |
857 | 857 | ); |
858 | 858 | } |
859 | - } catch ( Exception $e ) { |
|
860 | - if ( ! $e instanceof EE_Error ) { |
|
859 | + } catch (Exception $e) { |
|
860 | + if ( ! $e instanceof EE_Error) { |
|
861 | 861 | $e = new EE_Error( |
862 | 862 | sprintf( |
863 | - __( 'The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso' ), |
|
863 | + __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'), |
|
864 | 864 | $class_name, |
865 | 865 | '<br />', |
866 | 866 | $e->getMessage(), |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @param array $array |
881 | 881 | * @return bool |
882 | 882 | */ |
883 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
884 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
883 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
884 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -896,14 +896,14 @@ discard block |
||
896 | 896 | * @param string $class_name |
897 | 897 | * @return ReflectionClass |
898 | 898 | */ |
899 | - public function get_ReflectionClass( $class_name ) { |
|
899 | + public function get_ReflectionClass($class_name) { |
|
900 | 900 | if ( |
901 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
902 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
901 | + ! isset($this->_reflectors[$class_name]) |
|
902 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
903 | 903 | ) { |
904 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
904 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
905 | 905 | } |
906 | - return $this->_reflectors[ $class_name ]; |
|
906 | + return $this->_reflectors[$class_name]; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | |
@@ -928,50 +928,50 @@ discard block |
||
928 | 928 | * @return array |
929 | 929 | * @throws \ReflectionException |
930 | 930 | */ |
931 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
931 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
932 | 932 | // let's examine the constructor |
933 | 933 | $constructor = $reflector->getConstructor(); |
934 | 934 | // whu? huh? nothing? |
935 | - if ( ! $constructor ) { |
|
935 | + if ( ! $constructor) { |
|
936 | 936 | return $arguments; |
937 | 937 | } |
938 | 938 | // get constructor parameters |
939 | 939 | $params = $constructor->getParameters(); |
940 | 940 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
941 | - $argument_keys = array_keys( $arguments ); |
|
941 | + $argument_keys = array_keys($arguments); |
|
942 | 942 | // now loop thru all of the constructors expected parameters |
943 | - foreach ( $params as $index => $param ) { |
|
943 | + foreach ($params as $index => $param) { |
|
944 | 944 | // is this a dependency for a specific class ? |
945 | 945 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
946 | 946 | if ( |
947 | 947 | // param is not even a class |
948 | - empty( $param_class ) |
|
948 | + empty($param_class) |
|
949 | 949 | // and something already exists in the incoming arguments for this param |
950 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
950 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
951 | 951 | ) { |
952 | 952 | // so let's skip this argument and move on to the next |
953 | 953 | continue; |
954 | 954 | } else if ( |
955 | 955 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
956 | - ! empty( $param_class ) |
|
957 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
958 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
956 | + ! empty($param_class) |
|
957 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
958 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
959 | 959 | ) { |
960 | 960 | // skip this argument and move on to the next |
961 | 961 | continue; |
962 | 962 | } else if ( |
963 | 963 | // parameter is type hinted as a class, and should be injected |
964 | - ! empty( $param_class ) |
|
965 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
964 | + ! empty($param_class) |
|
965 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
966 | 966 | ) { |
967 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
967 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
968 | 968 | } else { |
969 | 969 | try { |
970 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
971 | - } catch ( ReflectionException $e ) { |
|
970 | + $arguments[$index] = $param->getDefaultValue(); |
|
971 | + } catch (ReflectionException $e) { |
|
972 | 972 | throw new ReflectionException( |
973 | 973 | sprintf( |
974 | - __( '%1$s for parameter "$%2$s"', 'event_espresso' ), |
|
974 | + __('%1$s for parameter "$%2$s"', 'event_espresso'), |
|
975 | 975 | $e->getMessage(), |
976 | 976 | $param->getName() |
977 | 977 | ) |
@@ -993,30 +993,30 @@ discard block |
||
993 | 993 | * @param mixed $index |
994 | 994 | * @return array |
995 | 995 | */ |
996 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
996 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
997 | 997 | $dependency = null; |
998 | 998 | // should dependency be loaded from cache ? |
999 | - $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( $class_name, $param_class ) |
|
999 | + $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class) |
|
1000 | 1000 | !== EE_Dependency_Map::load_new_object |
1001 | 1001 | ? true |
1002 | 1002 | : false; |
1003 | 1003 | // we might have a dependency... |
1004 | 1004 | // let's MAYBE try and find it in our cache if that's what's been requested |
1005 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
1005 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
1006 | 1006 | // and grab it if it exists |
1007 | - if ( $cached_class instanceof $param_class ) { |
|
1007 | + if ($cached_class instanceof $param_class) { |
|
1008 | 1008 | $dependency = $cached_class; |
1009 | - } else if ( $param_class != $class_name ) { |
|
1009 | + } else if ($param_class != $class_name) { |
|
1010 | 1010 | // obtain the loader method from the dependency map |
1011 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
1011 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
1012 | 1012 | // is loader a custom closure ? |
1013 | - if ( $loader instanceof Closure ) { |
|
1013 | + if ($loader instanceof Closure) { |
|
1014 | 1014 | $dependency = $loader(); |
1015 | 1015 | } else { |
1016 | 1016 | // set the cache on property for the recursive loading call |
1017 | 1017 | $this->_cache_on = $cache_on; |
1018 | 1018 | // if not, then let's try and load it via the registry |
1019 | - if ( method_exists( $this, $loader ) ) { |
|
1019 | + if (method_exists($this, $loader)) { |
|
1020 | 1020 | $dependency = $this->{$loader}($param_class); |
1021 | 1021 | } else { |
1022 | 1022 | $dependency = $this->create($param_class, array(), $cache_on); |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | // did we successfully find the correct dependency ? |
1027 | - if ( $dependency instanceof $param_class ) { |
|
1027 | + if ($dependency instanceof $param_class) { |
|
1028 | 1028 | // then let's inject it into the incoming array of arguments at the correct location |
1029 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
1030 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
1029 | + if (isset($argument_keys[$index])) { |
|
1030 | + $arguments[$argument_keys[$index]] = $dependency; |
|
1031 | 1031 | } else { |
1032 | - $arguments[ $index ] = $dependency; |
|
1032 | + $arguments[$index] = $dependency; |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | return $arguments; |
@@ -1054,19 +1054,19 @@ discard block |
||
1054 | 1054 | * @param bool $from_db |
1055 | 1055 | * @return void |
1056 | 1056 | */ |
1057 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
1058 | - if ( empty( $class_obj ) ) { |
|
1057 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
1058 | + if (empty($class_obj)) { |
|
1059 | 1059 | return; |
1060 | 1060 | } |
1061 | 1061 | // return newly instantiated class |
1062 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
1063 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
1062 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
1063 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
1064 | 1064 | $this->{$class_abbreviation} = $class_obj; |
1065 | - } else if ( property_exists( $this, $class_name ) ) { |
|
1065 | + } else if (property_exists($this, $class_name)) { |
|
1066 | 1066 | $this->{$class_name} = $class_obj; |
1067 | - } else if ( $class_prefix == 'addon' ) { |
|
1067 | + } else if ($class_prefix == 'addon') { |
|
1068 | 1068 | $this->addons->{$class_name} = $class_obj; |
1069 | - } else if ( ! $from_db ) { |
|
1069 | + } else if ( ! $from_db) { |
|
1070 | 1070 | $this->LIB->{$class_name} = $class_obj; |
1071 | 1071 | } |
1072 | 1072 | } |
@@ -1083,12 +1083,12 @@ discard block |
||
1083 | 1083 | * @param array $arguments |
1084 | 1084 | * @return object |
1085 | 1085 | */ |
1086 | - public static function factory( $classname, $arguments = array() ) { |
|
1087 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
1088 | - if ( $loader instanceof Closure ) { |
|
1089 | - return $loader( $arguments ); |
|
1090 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
1091 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
1086 | + public static function factory($classname, $arguments = array()) { |
|
1087 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
1088 | + if ($loader instanceof Closure) { |
|
1089 | + return $loader($arguments); |
|
1090 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
1091 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
1092 | 1092 | } |
1093 | 1093 | return null; |
1094 | 1094 | } |
@@ -1101,9 +1101,9 @@ discard block |
||
1101 | 1101 | * @param string $name |
1102 | 1102 | * @return EE_Addon |
1103 | 1103 | */ |
1104 | - public function get_addon_by_name( $name ) { |
|
1105 | - foreach ( $this->addons as $addon ) { |
|
1106 | - if ( $addon->name() == $name ) { |
|
1104 | + public function get_addon_by_name($name) { |
|
1105 | + foreach ($this->addons as $addon) { |
|
1106 | + if ($addon->name() == $name) { |
|
1107 | 1107 | return $addon; |
1108 | 1108 | } |
1109 | 1109 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | */ |
1120 | 1120 | public function get_addons_by_name() { |
1121 | 1121 | $addons = array(); |
1122 | - foreach ( $this->addons as $addon ) { |
|
1123 | - $addons[ $addon->name() ] = $addon; |
|
1122 | + foreach ($this->addons as $addon) { |
|
1123 | + $addons[$addon->name()] = $addon; |
|
1124 | 1124 | } |
1125 | 1125 | return $addons; |
1126 | 1126 | } |
@@ -1135,14 +1135,14 @@ discard block |
||
1135 | 1135 | * @return \EEM_Base |
1136 | 1136 | * @throws \EE_Error |
1137 | 1137 | */ |
1138 | - public function reset_model( $model_name ) { |
|
1139 | - $model = $this->load_model( $model_name ); |
|
1140 | - $model_class_name = get_class( $model ); |
|
1138 | + public function reset_model($model_name) { |
|
1139 | + $model = $this->load_model($model_name); |
|
1140 | + $model_class_name = get_class($model); |
|
1141 | 1141 | //get that model reset it and make sure we nuke the old reference to it |
1142 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
1142 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
1143 | 1143 | $this->LIB->{$model_class_name} = $model::reset(); |
1144 | 1144 | } else { |
1145 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
1145 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
1146 | 1146 | } |
1147 | 1147 | return $this->LIB->{$model_class_name}; |
1148 | 1148 | } |
@@ -1179,13 +1179,13 @@ discard block |
||
1179 | 1179 | * |
1180 | 1180 | * @return EE_Registry |
1181 | 1181 | */ |
1182 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
1182 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
1183 | 1183 | $instance = self::instance(); |
1184 | 1184 | EEH_Activation::reset(); |
1185 | 1185 | |
1186 | 1186 | //properties that get reset |
1187 | 1187 | $instance->_cache_on = true; |
1188 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
1188 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
1189 | 1189 | $instance->CART = null; |
1190 | 1190 | $instance->MRM = null; |
1191 | 1191 | $instance->LIB = new stdClass(); |
@@ -1193,9 +1193,9 @@ discard block |
||
1193 | 1193 | //messages reset |
1194 | 1194 | EED_Messages::reset(); |
1195 | 1195 | |
1196 | - if ( $reset_models ) { |
|
1197 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
1198 | - $instance->reset_model( $model_name ); |
|
1196 | + if ($reset_models) { |
|
1197 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
1198 | + $instance->reset_model($model_name); |
|
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | * @param $a |
1218 | 1218 | * @param $b |
1219 | 1219 | */ |
1220 | - final function __call( $a, $b ) { |
|
1220 | + final function __call($a, $b) { |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | /** |
1226 | 1226 | * @param $a |
1227 | 1227 | */ |
1228 | - final function __get( $a ) { |
|
1228 | + final function __get($a) { |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | * @param $a |
1235 | 1235 | * @param $b |
1236 | 1236 | */ |
1237 | - final function __set( $a, $b ) { |
|
1237 | + final function __set($a, $b) { |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | /** |
1243 | 1243 | * @param $a |
1244 | 1244 | */ |
1245 | - final function __isset( $a ) { |
|
1245 | + final function __isset($a) { |
|
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | /** |
1251 | 1251 | * @param $a |
1252 | 1252 | */ |
1253 | - final function __unset( $a ) { |
|
1253 | + final function __unset($a) { |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | * @param $a |
1298 | 1298 | * @param $b |
1299 | 1299 | */ |
1300 | - final static function __callStatic( $a, $b ) { |
|
1300 | + final static function __callStatic($a, $b) { |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | /** |
@@ -1306,9 +1306,9 @@ discard block |
||
1306 | 1306 | */ |
1307 | 1307 | public function cpt_models() { |
1308 | 1308 | $cpt_models = array(); |
1309 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1310 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1311 | - $cpt_models[ $short_name ] = $classname; |
|
1309 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1310 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1311 | + $cpt_models[$short_name] = $classname; |
|
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | return $cpt_models; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
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 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param int $code |
26 | 26 | * @param \Exception $previous |
27 | 27 | */ |
28 | - public function __construct( $command_handler_name, $message = '', $code = 0, \Exception $previous = null ) { |
|
29 | - if ( empty( $message ) ) { |
|
28 | + public function __construct($command_handler_name, $message = '', $code = 0, \Exception $previous = null) { |
|
29 | + if (empty($message)) { |
|
30 | 30 | $message = sprintf( |
31 | - __( 'The requested Command Handler "%1$s" could not be located or does not exist.', 'event_espresso' ), |
|
31 | + __('The requested Command Handler "%1$s" could not be located or does not exist.', 'event_espresso'), |
|
32 | 32 | $command_handler_name |
33 | 33 | ); |
34 | 34 | } |
35 | - parent::__construct( $message, $code, $previous ); |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * set session data |
365 | 365 | * @access public |
366 | 366 | * @param array $data |
367 | - * @return TRUE on success, FALSE on fail |
|
367 | + * @return boolean on success, FALSE on fail |
|
368 | 368 | */ |
369 | 369 | public function set_session_data( $data ) { |
370 | 370 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * @initiate session |
394 | 394 | * @access private |
395 | - * @return TRUE on success, FALSE on fail |
|
395 | + * @return boolean on success, FALSE on fail |
|
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | 398 | private function _espresso_session() { |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @update session data prior to saving to the db |
532 | 532 | * @access public |
533 | 533 | * @param bool $new_session |
534 | - * @return TRUE on success, FALSE on fail |
|
534 | + * @return boolean on success, FALSE on fail |
|
535 | 535 | */ |
536 | 536 | public function update( $new_session = FALSE ) { |
537 | 537 | $this->_session_data = isset( $this->_session_data ) |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * This is a callback for the 'wp_redirect' filter |
626 | 626 | * |
627 | 627 | * @param string $location |
628 | - * @return mixed |
|
628 | + * @return string |
|
629 | 629 | */ |
630 | 630 | public function update_on_redirect( $location ) { |
631 | 631 | $this->update(); |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | * @access public |
812 | 812 | * @param array $data_to_reset |
813 | 813 | * @param bool $show_all_notices |
814 | - * @return TRUE on success, FALSE on fail |
|
814 | + * @return boolean on success, FALSE on fail |
|
815 | 815 | */ |
816 | 816 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
817 | 817 | // if $data_to_reset is not in an array, then put it in one |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Event Espresso |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * array for defining default session vars |
105 | 105 | * @var array |
106 | 106 | */ |
107 | - private $_default_session_vars = array ( |
|
107 | + private $_default_session_vars = array( |
|
108 | 108 | 'id' => NULL, |
109 | 109 | 'user_id' => NULL, |
110 | 110 | 'ip_address' => NULL, |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @param \EE_Encryption $encryption |
128 | 128 | * @return EE_Session |
129 | 129 | */ |
130 | - public static function instance( EE_Encryption $encryption = null ) { |
|
130 | + public static function instance(EE_Encryption $encryption = null) { |
|
131 | 131 | // check if class object is instantiated |
132 | 132 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
133 | 133 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
134 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
135 | - self::$_instance = new self( $encryption ); |
|
134 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
135 | + self::$_instance = new self($encryption); |
|
136 | 136 | } |
137 | 137 | return self::$_instance; |
138 | 138 | } |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @access protected |
146 | 146 | * @param \EE_Encryption $encryption |
147 | 147 | */ |
148 | - protected function __construct( EE_Encryption $encryption = null ) { |
|
148 | + protected function __construct(EE_Encryption $encryption = null) { |
|
149 | 149 | |
150 | 150 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
151 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
151 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
152 | 152 | return NULL; |
153 | 153 | } |
154 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
155 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
156 | - define( 'ESPRESSO_SESSION', true ); |
|
154 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
155 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
156 | + define('ESPRESSO_SESSION', true); |
|
157 | 157 | } |
158 | 158 | // default session lifespan in seconds |
159 | 159 | $this->_lifespan = apply_filters( |
@@ -167,36 +167,36 @@ discard block |
||
167 | 167 | * } |
168 | 168 | */ |
169 | 169 | // retrieve session options from db |
170 | - $session_settings = get_option( 'ee_session_settings' ); |
|
171 | - if ( $session_settings !== FALSE ) { |
|
170 | + $session_settings = get_option('ee_session_settings'); |
|
171 | + if ($session_settings !== FALSE) { |
|
172 | 172 | // cycle though existing session options |
173 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
173 | + foreach ($session_settings as $var_name => $session_setting) { |
|
174 | 174 | // set values for class properties |
175 | - $var_name = '_' . $var_name; |
|
175 | + $var_name = '_'.$var_name; |
|
176 | 176 | $this->{$var_name} = $session_setting; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | // are we using encryption? |
180 | - if ( $this->_use_encryption && $encryption instanceof EE_Encryption ) { |
|
180 | + if ($this->_use_encryption && $encryption instanceof EE_Encryption) { |
|
181 | 181 | // encrypt data via: $this->encryption->encrypt(); |
182 | 182 | $this->encryption = $encryption; |
183 | 183 | } |
184 | 184 | // filter hook allows outside functions/classes/plugins to change default empty cart |
185 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
186 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
185 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
186 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
187 | 187 | // apply default session vars |
188 | 188 | $this->_set_defaults(); |
189 | 189 | // check for existing session and retrieve it from db |
190 | - if ( ! $this->_espresso_session() ) { |
|
190 | + if ( ! $this->_espresso_session()) { |
|
191 | 191 | // or just start a new one |
192 | 192 | $this->_create_espresso_session(); |
193 | 193 | } |
194 | 194 | // check request for 'clear_session' param |
195 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
195 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
196 | 196 | // once everything is all said and done, |
197 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
198 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
199 | - add_filter( 'wp_redirect', array( $this, 'update_on_redirect' ), 100, 1 ); |
|
197 | + add_action('shutdown', array($this, 'update'), 100); |
|
198 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
199 | + add_filter('wp_redirect', array($this, 'update_on_redirect'), 100, 1); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function _set_defaults() { |
229 | 229 | // set some defaults |
230 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
231 | - if ( is_array( $default_var )) { |
|
232 | - $this->_session_data[ $key ] = array(); |
|
230 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
231 | + if (is_array($default_var)) { |
|
232 | + $this->_session_data[$key] = array(); |
|
233 | 233 | } else { |
234 | - $this->_session_data[ $key ] = ''; |
|
234 | + $this->_session_data[$key] = ''; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param \EE_Cart $cart |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function set_cart( EE_Cart $cart ) { |
|
256 | + public function set_cart(EE_Cart $cart) { |
|
257 | 257 | $this->_session_data['cart'] = $cart; |
258 | 258 | return TRUE; |
259 | 259 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return \EE_Cart |
274 | 274 | */ |
275 | 275 | public function cart() { |
276 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
276 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param \EE_Checkout $checkout |
283 | 283 | * @return bool |
284 | 284 | */ |
285 | - public function set_checkout( EE_Checkout $checkout ) { |
|
285 | + public function set_checkout(EE_Checkout $checkout) { |
|
286 | 286 | $this->_session_data['checkout'] = $checkout; |
287 | 287 | return TRUE; |
288 | 288 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return \EE_Checkout |
303 | 303 | */ |
304 | 304 | public function checkout() { |
305 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
305 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param \EE_Transaction $transaction |
312 | 312 | * @return bool |
313 | 313 | */ |
314 | - public function set_transaction( EE_Transaction $transaction ) { |
|
314 | + public function set_transaction(EE_Transaction $transaction) { |
|
315 | 315 | // first remove the session from the transaction before we save the transaction in the session |
316 | - $transaction->set_txn_session_data( NULL ); |
|
316 | + $transaction->set_txn_session_data(NULL); |
|
317 | 317 | $this->_session_data['transaction'] = $transaction; |
318 | 318 | return TRUE; |
319 | 319 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return \EE_Transaction |
334 | 334 | */ |
335 | 335 | public function transaction() { |
336 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
336 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | * @param bool $reset_cache |
346 | 346 | * @return array |
347 | 347 | */ |
348 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
349 | - if ( $reset_cache ) { |
|
348 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
349 | + if ($reset_cache) { |
|
350 | 350 | $this->reset_cart(); |
351 | 351 | $this->reset_checkout(); |
352 | 352 | $this->reset_transaction(); |
353 | 353 | } |
354 | - if ( ! empty( $key )) { |
|
355 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
356 | - } else { |
|
354 | + if ( ! empty($key)) { |
|
355 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
356 | + } else { |
|
357 | 357 | return $this->_session_data; |
358 | 358 | } |
359 | 359 | } |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | * @param array $data |
367 | 367 | * @return TRUE on success, FALSE on fail |
368 | 368 | */ |
369 | - public function set_session_data( $data ) { |
|
369 | + public function set_session_data($data) { |
|
370 | 370 | |
371 | 371 | // nothing ??? bad data ??? go home! |
372 | - if ( empty( $data ) || ! is_array( $data )) { |
|
373 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + if (empty($data) || ! is_array($data)) { |
|
373 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
374 | 374 | return FALSE; |
375 | 375 | } |
376 | 376 | |
377 | - foreach ( $data as $key =>$value ) { |
|
378 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
379 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
377 | + foreach ($data as $key =>$value) { |
|
378 | + if (isset($this->_default_session_vars[$key])) { |
|
379 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
380 | 380 | return FALSE; |
381 | 381 | } else { |
382 | - $this->_session_data[ $key ] = $value; |
|
382 | + $this->_session_data[$key] = $value; |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | 398 | private function _espresso_session() { |
399 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
399 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
400 | 400 | // check that session has started |
401 | - if ( session_id() === '' ) { |
|
401 | + if (session_id() === '') { |
|
402 | 402 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
403 | 403 | session_start(); |
404 | 404 | } |
@@ -407,57 +407,57 @@ discard block |
||
407 | 407 | // and the visitors IP |
408 | 408 | $this->_ip_address = $this->_visitor_ip(); |
409 | 409 | // set the "user agent" |
410 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
410 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
411 | 411 | // now let's retrieve what's in the db |
412 | 412 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
413 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
414 | - if ( $session_data ) { |
|
415 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
416 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
417 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
413 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
414 | + if ($session_data) { |
|
415 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
416 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
417 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
418 | 418 | EE_Error::add_error( |
419 | 419 | sprintf( |
420 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
421 | - EE_Session::session_id_prefix . $this->_sid |
|
420 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
421 | + EE_Session::session_id_prefix.$this->_sid |
|
422 | 422 | ), |
423 | 423 | __FILE__, __FUNCTION__, __LINE__ |
424 | 424 | ); |
425 | 425 | } |
426 | 426 | } |
427 | 427 | // un-encrypt the data |
428 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
428 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
429 | 429 | // unserialize |
430 | - $session_data = maybe_unserialize( $session_data ); |
|
430 | + $session_data = maybe_unserialize($session_data); |
|
431 | 431 | // just a check to make sure the session array is indeed an array |
432 | - if ( ! is_array( $session_data ) ) { |
|
432 | + if ( ! is_array($session_data)) { |
|
433 | 433 | // no?!?! then something is wrong |
434 | 434 | return FALSE; |
435 | 435 | } |
436 | 436 | // get the current time in UTC |
437 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
437 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
438 | 438 | // and reset the session expiration |
439 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
439 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
440 | 440 | |
441 | 441 | } else { |
442 | 442 | // set initial site access time and the session expiration |
443 | 443 | $this->_set_init_access_and_expiration(); |
444 | 444 | // set referer |
445 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
445 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
446 | 446 | // no previous session = go back and create one (on top of the data above) |
447 | 447 | return FALSE; |
448 | 448 | } |
449 | 449 | // now the user agent |
450 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
450 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
451 | 451 | return FALSE; |
452 | 452 | } |
453 | 453 | // wait a minute... how old are you? |
454 | - if ( $this->_time > $this->_expiration ) { |
|
454 | + if ($this->_time > $this->_expiration) { |
|
455 | 455 | // yer too old fer me! |
456 | 456 | // wipe out everything that isn't a default session datum |
457 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
457 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
458 | 458 | } |
459 | 459 | // make event espresso session data available to plugin |
460 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
460 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
461 | 461 | return TRUE; |
462 | 462 | |
463 | 463 | } |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | */ |
476 | 476 | protected function _generate_session_id() { |
477 | 477 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
478 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
479 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
478 | + if (isset($_REQUEST['EESID'])) { |
|
479 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
480 | 480 | } else { |
481 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
481 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
482 | 482 | } |
483 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
483 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -492,20 +492,20 @@ discard block |
||
492 | 492 | */ |
493 | 493 | protected function _get_sid_salt() { |
494 | 494 | // was session id salt already saved to db ? |
495 | - if ( empty( $this->_sid_salt ) ) { |
|
495 | + if (empty($this->_sid_salt)) { |
|
496 | 496 | // no? then maybe use WP defined constant |
497 | - if ( defined( 'AUTH_SALT' ) ) { |
|
497 | + if (defined('AUTH_SALT')) { |
|
498 | 498 | $this->_sid_salt = AUTH_SALT; |
499 | 499 | } |
500 | 500 | // if salt doesn't exist or is too short |
501 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
501 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
502 | 502 | // create a new one |
503 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
503 | + $this->_sid_salt = wp_generate_password(64); |
|
504 | 504 | } |
505 | 505 | // and save it as a permanent session setting |
506 | - $session_settings = get_option( 'ee_session_settings' ); |
|
507 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
508 | - update_option( 'ee_session_settings', $session_settings ); |
|
506 | + $session_settings = get_option('ee_session_settings'); |
|
507 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
508 | + update_option('ee_session_settings', $session_settings); |
|
509 | 509 | } |
510 | 510 | return $this->_sid_salt; |
511 | 511 | } |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param bool $new_session |
534 | 534 | * @return TRUE on success, FALSE on fail |
535 | 535 | */ |
536 | - public function update( $new_session = FALSE ) { |
|
537 | - $this->_session_data = isset( $this->_session_data ) |
|
538 | - && is_array( $this->_session_data ) |
|
539 | - && isset( $this->_session_data['id']) |
|
536 | + public function update($new_session = FALSE) { |
|
537 | + $this->_session_data = isset($this->_session_data) |
|
538 | + && is_array($this->_session_data) |
|
539 | + && isset($this->_session_data['id']) |
|
540 | 540 | ? $this->_session_data |
541 | 541 | : NULL; |
542 | - if ( empty( $this->_session_data )) { |
|
542 | + if (empty($this->_session_data)) { |
|
543 | 543 | $this->_set_defaults(); |
544 | 544 | } |
545 | 545 | $session_data = array(); |
546 | - foreach ( $this->_session_data as $key => $value ) { |
|
546 | + foreach ($this->_session_data as $key => $value) { |
|
547 | 547 | |
548 | - switch( $key ) { |
|
548 | + switch ($key) { |
|
549 | 549 | |
550 | 550 | case 'id' : |
551 | 551 | // session ID |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | break; |
564 | 564 | |
565 | 565 | case 'init_access' : |
566 | - $session_data['init_access'] = absint( $value ); |
|
566 | + $session_data['init_access'] = absint($value); |
|
567 | 567 | break; |
568 | 568 | |
569 | 569 | case 'last_access' : |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | case 'expiration' : |
575 | 575 | // when the session expires |
576 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
576 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
577 | 577 | ? $this->_expiration |
578 | 578 | : $session_data['init_access'] + $this->_lifespan; |
579 | 579 | break; |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | |
586 | 586 | case 'pages_visited' : |
587 | 587 | $page_visit = $this->_get_page_visit(); |
588 | - if ( $page_visit ) { |
|
588 | + if ($page_visit) { |
|
589 | 589 | // set pages visited where the first will be the http referrer |
590 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
590 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
591 | 591 | // we'll only save the last 10 page visits. |
592 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
592 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | |
604 | 604 | $this->_session_data = $session_data; |
605 | 605 | // creating a new session does not require saving to the db just yet |
606 | - if ( ! $new_session ) { |
|
606 | + if ( ! $new_session) { |
|
607 | 607 | // ready? let's save |
608 | - if ( $this->_save_session_to_db() ) { |
|
608 | + if ($this->_save_session_to_db()) { |
|
609 | 609 | return TRUE; |
610 | 610 | } else { |
611 | 611 | return FALSE; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @param string $location |
628 | 628 | * @return mixed |
629 | 629 | */ |
630 | - public function update_on_redirect( $location ) { |
|
630 | + public function update_on_redirect($location) { |
|
631 | 631 | $this->update(); |
632 | 632 | return $location; |
633 | 633 | } |
@@ -639,9 +639,9 @@ discard block |
||
639 | 639 | * @return bool |
640 | 640 | */ |
641 | 641 | private function _create_espresso_session( ) { |
642 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
642 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
643 | 643 | // use the update function for now with $new_session arg set to TRUE |
644 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
644 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | |
@@ -660,21 +660,21 @@ discard block |
||
660 | 660 | || ! ( |
661 | 661 | EE_Registry::instance()->REQ->is_espresso_page() |
662 | 662 | || EE_Registry::instance()->REQ->front_ajax |
663 | - || is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
663 | + || is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
664 | 664 | ) |
665 | 665 | ) { |
666 | 666 | return FALSE; |
667 | 667 | } |
668 | 668 | // first serialize all of our session data |
669 | - $session_data = serialize( $this->_session_data ); |
|
669 | + $session_data = serialize($this->_session_data); |
|
670 | 670 | // encrypt it if we are using encryption |
671 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
671 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
672 | 672 | // maybe save hash check |
673 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
674 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
673 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
674 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
675 | 675 | } |
676 | 676 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
677 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
677 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | |
@@ -700,10 +700,10 @@ discard block |
||
700 | 700 | 'HTTP_FORWARDED', |
701 | 701 | 'REMOTE_ADDR' |
702 | 702 | ); |
703 | - foreach ( $server_keys as $key ){ |
|
704 | - if ( isset( $_SERVER[ $key ] )) { |
|
705 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
706 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
703 | + foreach ($server_keys as $key) { |
|
704 | + if (isset($_SERVER[$key])) { |
|
705 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
706 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
707 | 707 | $visitor_ip = $ip; |
708 | 708 | } |
709 | 709 | } |
@@ -724,45 +724,45 @@ discard block |
||
724 | 724 | public function _get_page_visit() { |
725 | 725 | |
726 | 726 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
727 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
727 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
728 | 728 | |
729 | 729 | // check for request url |
730 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
730 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
731 | 731 | |
732 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
732 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
733 | 733 | |
734 | - $ru_bits = explode( '?', $request_uri ); |
|
734 | + $ru_bits = explode('?', $request_uri); |
|
735 | 735 | $request_uri = $ru_bits[0]; |
736 | 736 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
737 | 737 | |
738 | 738 | // check for and grab host as well |
739 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
740 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
739 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
740 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
741 | 741 | } else { |
742 | 742 | $http_host = ''; |
743 | 743 | } |
744 | 744 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
745 | 745 | |
746 | 746 | // check for page_id in SERVER REQUEST |
747 | - if ( isset( $_REQUEST['page_id'] )) { |
|
747 | + if (isset($_REQUEST['page_id'])) { |
|
748 | 748 | // rebuild $e_reg without any of the extra parameters |
749 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
749 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
750 | 750 | } else { |
751 | 751 | $page_id = '?'; |
752 | 752 | } |
753 | 753 | // check for $e_reg in SERVER REQUEST |
754 | - if ( isset( $_REQUEST['ee'] )) { |
|
754 | + if (isset($_REQUEST['ee'])) { |
|
755 | 755 | // rebuild $e_reg without any of the extra parameters |
756 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
756 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
757 | 757 | } else { |
758 | 758 | $e_reg = ''; |
759 | 759 | } |
760 | 760 | |
761 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
761 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
762 | 762 | |
763 | 763 | } |
764 | 764 | |
765 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
765 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
766 | 766 | |
767 | 767 | } |
768 | 768 | |
@@ -791,14 +791,14 @@ discard block |
||
791 | 791 | * @param string $function |
792 | 792 | * @return void |
793 | 793 | */ |
794 | - public function clear_session( $class = '', $function = '' ) { |
|
794 | + public function clear_session($class = '', $function = '') { |
|
795 | 795 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
796 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
796 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
797 | 797 | $this->reset_cart(); |
798 | 798 | $this->reset_checkout(); |
799 | 799 | $this->reset_transaction(); |
800 | 800 | // wipe out everything that isn't a default session datum |
801 | - $this->reset_data( array_keys( $this->_session_data )); |
|
801 | + $this->reset_data(array_keys($this->_session_data)); |
|
802 | 802 | // reset initial site access time and the session expiration |
803 | 803 | $this->_set_init_access_and_expiration(); |
804 | 804 | $this->_save_session_to_db(); |
@@ -813,42 +813,42 @@ discard block |
||
813 | 813 | * @param bool $show_all_notices |
814 | 814 | * @return TRUE on success, FALSE on fail |
815 | 815 | */ |
816 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
816 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
817 | 817 | // if $data_to_reset is not in an array, then put it in one |
818 | - if ( ! is_array( $data_to_reset ) ) { |
|
819 | - $data_to_reset = array ( $data_to_reset ); |
|
818 | + if ( ! is_array($data_to_reset)) { |
|
819 | + $data_to_reset = array($data_to_reset); |
|
820 | 820 | } |
821 | 821 | // nothing ??? go home! |
822 | - if ( empty( $data_to_reset )) { |
|
823 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
822 | + if (empty($data_to_reset)) { |
|
823 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
824 | 824 | return FALSE; |
825 | 825 | } |
826 | 826 | $return_value = TRUE; |
827 | 827 | // since $data_to_reset is an array, cycle through the values |
828 | - foreach ( $data_to_reset as $reset ) { |
|
828 | + foreach ($data_to_reset as $reset) { |
|
829 | 829 | |
830 | 830 | // first check to make sure it is a valid session var |
831 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
831 | + if (isset($this->_session_data[$reset])) { |
|
832 | 832 | // then check to make sure it is not a default var |
833 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
833 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
834 | 834 | // remove session var |
835 | - unset( $this->_session_data[ $reset ] ); |
|
836 | - if ( $show_all_notices ) { |
|
837 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
835 | + unset($this->_session_data[$reset]); |
|
836 | + if ($show_all_notices) { |
|
837 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
838 | 838 | } |
839 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
839 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
840 | 840 | |
841 | 841 | } else { |
842 | 842 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
843 | - if ( $show_all_notices ) { |
|
844 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
843 | + if ($show_all_notices) { |
|
844 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
845 | 845 | } |
846 | 846 | $return_value = FALSE; |
847 | 847 | } |
848 | 848 | |
849 | - } else if ( $show_all_notices ) { |
|
849 | + } else if ($show_all_notices) { |
|
850 | 850 | // oops! that session var does not exist! |
851 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
852 | 852 | $return_value = FALSE; |
853 | 853 | } |
854 | 854 | |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | * @return string |
870 | 870 | */ |
871 | 871 | public function wp_loaded() { |
872 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
873 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
872 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
873 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
874 | 874 | } |
875 | 875 | } |
876 | 876 | |
@@ -895,24 +895,24 @@ discard block |
||
895 | 895 | */ |
896 | 896 | public function garbage_collection() { |
897 | 897 | // only perform during regular requests |
898 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
898 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
899 | 899 | /** @type WPDB $wpdb */ |
900 | 900 | global $wpdb; |
901 | 901 | // since transient expiration timestamps are set in the future, we can compare against NOW |
902 | 902 | $expiration = time(); |
903 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
903 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
904 | 904 | // filter the query limit. Set to 0 to turn off garbage collection |
905 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
905 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
906 | 906 | // non-zero LIMIT means take out the trash |
907 | - if ( $expired_session_transient_delete_query_limit ) { |
|
907 | + if ($expired_session_transient_delete_query_limit) { |
|
908 | 908 | //array of transient keys that require garbage collection |
909 | 909 | $session_keys = array( |
910 | 910 | EE_Session::session_id_prefix, |
911 | 911 | EE_Session::hash_check_prefix, |
912 | 912 | ); |
913 | - foreach ( $session_keys as $session_key ) { |
|
914 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
915 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
913 | + foreach ($session_keys as $session_key) { |
|
914 | + $session_key = str_replace('_', '\_', $session_key); |
|
915 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
916 | 916 | $SQL = " |
917 | 917 | SELECT option_name |
918 | 918 | FROM {$wpdb->options} |
@@ -922,28 +922,28 @@ discard block |
||
922 | 922 | OR option_value > {$too_far_in_the_the_future} ) |
923 | 923 | LIMIT {$expired_session_transient_delete_query_limit} |
924 | 924 | "; |
925 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
925 | + $expired_sessions = $wpdb->get_col($SQL); |
|
926 | 926 | // valid results? |
927 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
927 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
928 | 928 | // format array of results into something usable within the actual DELETE query's IN clause |
929 | 929 | $expired = array(); |
930 | - foreach ( $expired_sessions as $expired_session ) { |
|
931 | - $expired[ ] = "'" . $expired_session . "'"; |
|
932 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
930 | + foreach ($expired_sessions as $expired_session) { |
|
931 | + $expired[] = "'".$expired_session."'"; |
|
932 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
933 | 933 | } |
934 | - $expired = implode( ', ', $expired ); |
|
934 | + $expired = implode(', ', $expired); |
|
935 | 935 | $SQL = " |
936 | 936 | DELETE FROM {$wpdb->options} |
937 | 937 | WHERE option_name |
938 | 938 | IN ( $expired ); |
939 | 939 | "; |
940 | - $results = $wpdb->query( $SQL ); |
|
940 | + $results = $wpdb->query($SQL); |
|
941 | 941 | // if something went wrong, then notify the admin |
942 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
943 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
942 | + if ($results instanceof WP_Error && is_admin()) { |
|
943 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
944 | 944 | } |
945 | 945 | } |
946 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
946 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * stating where the proper subsections should be placed (but usually leaving them to layout |
9 | 9 | * their own headers and footers etc). |
10 | 10 | */ |
11 | -abstract class EE_Form_Section_Layout_Base{ |
|
11 | +abstract class EE_Form_Section_Layout_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Form form section to lay out |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * __construct |
23 | 23 | */ |
24 | - function __construct(){ |
|
24 | + function __construct() { |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * The form section on which this strategy is to perform |
31 | 31 | * @param EE_Form_Section_Proper $form |
32 | 32 | */ |
33 | - function _construct_finalize(EE_Form_Section_Proper $form){ |
|
33 | + function _construct_finalize(EE_Form_Section_Proper $form) { |
|
34 | 34 | $this->_form_section = $form; |
35 | 35 | } |
36 | 36 | |
@@ -53,28 +53,28 @@ discard block |
||
53 | 53 | * Returns the HTML |
54 | 54 | * @return string HTML for displaying |
55 | 55 | */ |
56 | - function layout_form(){ |
|
56 | + function layout_form() { |
|
57 | 57 | $html = ''; |
58 | 58 | // layout_form_begin |
59 | 59 | $html .= apply_filters( |
60 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
60 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(), |
|
61 | 61 | $this->layout_form_begin(), |
62 | 62 | $this->_form_section |
63 | 63 | ); |
64 | 64 | // layout_form_loop |
65 | 65 | $html .= apply_filters( |
66 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
66 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(), |
|
67 | 67 | $this->layout_form_loop(), |
68 | 68 | $this->_form_section |
69 | 69 | ); |
70 | 70 | // layout_form_end |
71 | 71 | $html .= apply_filters( |
72 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
72 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(), |
|
73 | 73 | $this->layout_form_end(), |
74 | 74 | $this->_form_section |
75 | 75 | ); |
76 | 76 | |
77 | - $html = $this->add_form_section_hooks_and_filters( $html ); |
|
77 | + $html = $this->add_form_section_hooks_and_filters($html); |
|
78 | 78 | return $html; |
79 | 79 | } |
80 | 80 | |
@@ -83,20 +83,20 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - function layout_form_loop(){ |
|
86 | + function layout_form_loop() { |
|
87 | 87 | $html = ''; |
88 | - foreach( $this->_form_section->subsections() as $name => $subsection ){ |
|
89 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
88 | + foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
89 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
90 | 90 | $html .= apply_filters( |
91 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
92 | - $this->layout_input( $subsection ), |
|
91 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'.$name.'__in_'.$this->_form_section->name(), |
|
92 | + $this->layout_input($subsection), |
|
93 | 93 | $this->_form_section, |
94 | 94 | $subsection |
95 | 95 | ); |
96 | - } elseif ( $subsection instanceof EE_Form_Section_Base ){ |
|
96 | + } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
97 | 97 | $html .= apply_filters( |
98 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
99 | - $this->layout_subsection( $subsection ), |
|
98 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'.$name.'__in_'.$this->_form_section->name(), |
|
99 | + $this->layout_subsection($subsection), |
|
100 | 100 | $this->_form_section, |
101 | 101 | $subsection |
102 | 102 | ); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param EE_Form_Section_Base $subsection |
145 | 145 | * @return string html |
146 | 146 | */ |
147 | - abstract function layout_subsection( $subsection ); |
|
147 | + abstract function layout_subsection($subsection); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | * @param EE_Form_Input_Base $input |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public function display_label($input){ |
|
157 | - $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
158 | - $label_text = $input->required() ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' : $input->html_label_text(); |
|
159 | - return '<label id="' . $input->html_label_id() . '" class="' . $class . '" style="' . $input->html_label_style() . '" for="' . $input->html_name() . '">' . $label_text . '</label>'; |
|
156 | + public function display_label($input) { |
|
157 | + $class = $input->required() ? 'ee-required-label '.$input->html_label_class() : $input->html_label_class(); |
|
158 | + $label_text = $input->required() ? $input->html_label_text().'<span class="ee-asterisk">*</span>' : $input->html_label_text(); |
|
159 | + return '<label id="'.$input->html_label_id().'" class="'.$class.'" style="'.$input->html_label_style().'" for="'.$input->html_name().'">'.$label_text.'</label>'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | * @param EE_Form_Input_Base $input |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function display_errors($input){ |
|
173 | - if( $input->get_validation_errors() ){ |
|
174 | - return "<label id='" . $input->html_id() . "-error' class='error' for='{$input->html_name()}'>" . $input->get_validation_error_string() . "</label>"; |
|
175 | - }else{ |
|
172 | + public function display_errors($input) { |
|
173 | + if ($input->get_validation_errors()) { |
|
174 | + return "<label id='".$input->html_id()."-error' class='error' for='{$input->html_name()}'>".$input->get_validation_error_string()."</label>"; |
|
175 | + } else { |
|
176 | 176 | return ''; |
177 | 177 | } |
178 | 178 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | * @param EE_Form_Input_Base $input |
183 | 183 | * @return string |
184 | 184 | */ |
185 | - public function display_help_text( $input ){ |
|
186 | - if ( $input->html_help_text() != '' ) { |
|
185 | + public function display_help_text($input) { |
|
186 | + if ($input->html_help_text() != '') { |
|
187 | 187 | $tag = is_admin() ? 'p' : 'span'; |
188 | - return '<' . $tag . ' id="' . $input->html_id() . '-help" class="' . $input->html_help_class() . '" style="' . $input->html_help_style() . '">' . $input->html_help_text() . '</' . $tag . '>'; |
|
188 | + return '<'.$tag.' id="'.$input->html_id().'-help" class="'.$input->html_help_class().'" style="'.$input->html_help_style().'">'.$input->html_help_text().'</'.$tag.'>'; |
|
189 | 189 | } |
190 | 190 | return ''; |
191 | 191 | } |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | * @param string $html |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function add_form_section_hooks_and_filters( $html ){ |
|
200 | + public function add_form_section_hooks_and_filters($html) { |
|
201 | 201 | // replace dashes and spaces with underscores |
202 | - $hook_name = str_replace( array( '-', ' ' ), '_', $this->_form_section->html_id() ); |
|
203 | - do_action( 'AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section ); |
|
204 | - $html = apply_filters( 'AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section ); |
|
205 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
206 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
202 | + $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
203 | + do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section); |
|
204 | + $html = apply_filters('AFEE__Form_Section_Layout__'.$hook_name.'__html', $html, $this->_form_section); |
|
205 | + $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->'; |
|
206 | + $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->'; |
|
207 | 207 | return $html; |
208 | 208 | } |
209 | 209 |