@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\collections; |
3 | 3 | |
4 | -use EventEspresso\core\exceptions\InvalidEntityException; |
|
5 | -use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
4 | +use EventEspresso\core\exceptions\InvalidEntityException; |
|
5 | +use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
6 | 6 | use LimitIterator; |
7 | 7 | |
8 | 8 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
6 | 6 | use LimitIterator; |
7 | 7 | |
8 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
9 | - exit( 'No direct script access allowed' ); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | 10 | } |
11 | 11 | /** |
12 | 12 | * Class Collection |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @param string $collection_interface |
37 | 37 | * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
38 | 38 | */ |
39 | - public function __construct( $collection_interface ) { |
|
40 | - $this->setCollectionInterface( $collection_interface ); |
|
39 | + public function __construct($collection_interface) { |
|
40 | + $this->setCollectionInterface($collection_interface); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param string $collection_interface |
50 | 50 | * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
51 | 51 | */ |
52 | - protected function setCollectionInterface( $collection_interface ) { |
|
53 | - if ( ! ( interface_exists( $collection_interface ) || class_exists( $collection_interface ) ) ) { |
|
54 | - throw new InvalidInterfaceException( $collection_interface ); |
|
52 | + protected function setCollectionInterface($collection_interface) { |
|
53 | + if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
54 | + throw new InvalidInterfaceException($collection_interface); |
|
55 | 55 | } |
56 | 56 | $this->collection_interface = $collection_interface; |
57 | 57 | } |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
72 | 72 | */ |
73 | - public function add( $object, $identifier = null ) { |
|
74 | - if ( ! $object instanceof $this->collection_interface ) { |
|
75 | - throw new InvalidEntityException( $object, $this->collection_interface ); |
|
73 | + public function add($object, $identifier = null) { |
|
74 | + if ( ! $object instanceof $this->collection_interface) { |
|
75 | + throw new InvalidEntityException($object, $this->collection_interface); |
|
76 | 76 | } |
77 | - $this->attach( $object ); |
|
78 | - $this->setIdentifier( $object, $identifier ); |
|
79 | - return $this->contains( $object ); |
|
77 | + $this->attach($object); |
|
78 | + $this->setIdentifier($object, $identifier); |
|
79 | + return $this->contains($object); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | * @param mixed $identifier |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - public function setIdentifier( $object, $identifier = null ) { |
|
96 | - $identifier = ! empty( $identifier ) ? $identifier : spl_object_hash( $object ); |
|
95 | + public function setIdentifier($object, $identifier = null) { |
|
96 | + $identifier = ! empty($identifier) ? $identifier : spl_object_hash($object); |
|
97 | 97 | $this->rewind(); |
98 | - while ( $this->valid() ) { |
|
99 | - if ( $object === $this->current() ) { |
|
100 | - $this->setInfo( $identifier ); |
|
98 | + while ($this->valid()) { |
|
99 | + if ($object === $this->current()) { |
|
100 | + $this->setInfo($identifier); |
|
101 | 101 | $this->rewind(); |
102 | 102 | return true; |
103 | 103 | } |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | * @param mixed $identifier |
118 | 118 | * @return mixed |
119 | 119 | */ |
120 | - public function get( $identifier ) { |
|
120 | + public function get($identifier) { |
|
121 | 121 | $this->rewind(); |
122 | - while ( $this->valid() ) { |
|
123 | - if ( $identifier === $this->getInfo() ) { |
|
122 | + while ($this->valid()) { |
|
123 | + if ($identifier === $this->getInfo()) { |
|
124 | 124 | $object = $this->current(); |
125 | 125 | $this->rewind(); |
126 | 126 | return $object; |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | * @param mixed $identifier |
143 | 143 | * @return bool |
144 | 144 | */ |
145 | - public function has( $identifier ) { |
|
145 | + public function has($identifier) { |
|
146 | 146 | $this->rewind(); |
147 | - while ( $this->valid() ) { |
|
148 | - if ( $identifier === $this->getInfo() ) { |
|
147 | + while ($this->valid()) { |
|
148 | + if ($identifier === $this->getInfo()) { |
|
149 | 149 | $this->rewind(); |
150 | 150 | return true; |
151 | 151 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param $object |
165 | 165 | * @return bool |
166 | 166 | */ |
167 | - public function hasObject( $object ) { |
|
168 | - return $this->contains( $object ); |
|
167 | + public function hasObject($object) { |
|
168 | + return $this->contains($object); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @param $object |
179 | 179 | * @return bool |
180 | 180 | */ |
181 | - public function remove( $object ) { |
|
182 | - $this->detach( $object ); |
|
181 | + public function remove($object) { |
|
182 | + $this->detach($object); |
|
183 | 183 | return true; |
184 | 184 | } |
185 | 185 | |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * @param mixed $identifier |
194 | 194 | * @return boolean |
195 | 195 | */ |
196 | - public function setCurrent( $identifier ) { |
|
196 | + public function setCurrent($identifier) { |
|
197 | 197 | $this->rewind(); |
198 | - while ( $this->valid() ) { |
|
199 | - if ( $identifier === $this->getInfo() ) { |
|
198 | + while ($this->valid()) { |
|
199 | + if ($identifier === $this->getInfo()) { |
|
200 | 200 | return true; |
201 | 201 | } |
202 | 202 | $this->next(); |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | * @param $object |
215 | 215 | * @return boolean |
216 | 216 | */ |
217 | - public function setCurrentUsingObject( $object ) { |
|
217 | + public function setCurrentUsingObject($object) { |
|
218 | 218 | $this->rewind(); |
219 | - while ( $this->valid() ) { |
|
220 | - if ( $this->current() === $object ) { |
|
219 | + while ($this->valid()) { |
|
220 | + if ($this->current() === $object) { |
|
221 | 221 | return true; |
222 | 222 | } |
223 | 223 | $this->next(); |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | * @return mixed |
235 | 235 | */ |
236 | 236 | public function previous() { |
237 | - $index = $this->indexOf( $this->current() ); |
|
238 | - if ( $index === 0 ) { |
|
237 | + $index = $this->indexOf($this->current()); |
|
238 | + if ($index === 0) { |
|
239 | 239 | return $this->current(); |
240 | 240 | } |
241 | 241 | $index--; |
242 | - return $this->objectAtIndex( $index ); |
|
242 | + return $this->objectAtIndex($index); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * @param $object |
252 | 252 | * @return boolean|int|string |
253 | 253 | */ |
254 | - public function indexOf( $object ) { |
|
255 | - if ( ! $this->contains( $object ) ) { |
|
254 | + public function indexOf($object) { |
|
255 | + if ( ! $this->contains($object)) { |
|
256 | 256 | return false; |
257 | 257 | } |
258 | - foreach ( $this as $index => $obj ) { |
|
259 | - if ( $obj === $object ) { |
|
258 | + foreach ($this as $index => $obj) { |
|
259 | + if ($obj === $object) { |
|
260 | 260 | return $index; |
261 | 261 | } |
262 | 262 | } |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | * @param int $index |
273 | 273 | * @return mixed |
274 | 274 | */ |
275 | - public function objectAtIndex( $index ) { |
|
276 | - $iterator = new LimitIterator( $this, $index, 1 ); |
|
275 | + public function objectAtIndex($index) { |
|
276 | + $iterator = new LimitIterator($this, $index, 1); |
|
277 | 277 | $iterator->rewind(); |
278 | 278 | return $iterator->current(); |
279 | 279 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param int $length |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - public function slice( $offset, $length ) { |
|
291 | + public function slice($offset, $length) { |
|
292 | 292 | $slice = array(); |
293 | - $iterator = new LimitIterator( $this, $offset, $length ); |
|
294 | - foreach ( $iterator as $object ) { |
|
293 | + $iterator = new LimitIterator($this, $offset, $length); |
|
294 | + foreach ($iterator as $object) { |
|
295 | 295 | $slice[] = $object; |
296 | 296 | } |
297 | 297 | return $slice; |
@@ -306,35 +306,35 @@ discard block |
||
306 | 306 | * @param mixed $objects A single object or an array of objects |
307 | 307 | * @param int $index |
308 | 308 | */ |
309 | - public function insertAt( $objects, $index ) { |
|
310 | - if ( ! is_array( $objects ) ) { |
|
311 | - $objects = array( $objects ); |
|
309 | + public function insertAt($objects, $index) { |
|
310 | + if ( ! is_array($objects)) { |
|
311 | + $objects = array($objects); |
|
312 | 312 | } |
313 | 313 | // check to ensure that objects don't already exist in the collection |
314 | - foreach ( $objects as $key => $object ) { |
|
315 | - if ( $this->contains( $object ) ) { |
|
316 | - unset( $objects[ $key ] ); |
|
314 | + foreach ($objects as $key => $object) { |
|
315 | + if ($this->contains($object)) { |
|
316 | + unset($objects[$key]); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | // do we have any objects left? |
320 | - if ( ! $objects ) { |
|
320 | + if ( ! $objects) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | // detach any objects at or past this index |
324 | 324 | $remaining = array(); |
325 | - if ( $index < $this->count() ) { |
|
326 | - $remaining = $this->slice( $index, $this->count() - $index ); |
|
327 | - foreach ( $remaining as $object ) { |
|
328 | - $this->detach( $object ); |
|
325 | + if ($index < $this->count()) { |
|
326 | + $remaining = $this->slice($index, $this->count() - $index); |
|
327 | + foreach ($remaining as $object) { |
|
328 | + $this->detach($object); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | // add the new objects we're splicing in |
332 | - foreach ( $objects as $object ) { |
|
333 | - $this->attach( $object ); |
|
332 | + foreach ($objects as $object) { |
|
333 | + $this->attach($object); |
|
334 | 334 | } |
335 | 335 | // attach the objects we previously detached |
336 | - foreach ( $remaining as $object ) { |
|
337 | - $this->attach( $object ); |
|
336 | + foreach ($remaining as $object) { |
|
337 | + $this->attach($object); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | * @see http://stackoverflow.com/a/8736013 |
347 | 347 | * @param int $index |
348 | 348 | */ |
349 | - public function removeAt( $index ) { |
|
350 | - $this->detach( $this->objectAtIndex( $index ) ); |
|
349 | + public function removeAt($index) { |
|
350 | + $this->detach($this->objectAtIndex($index)); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * by calling EE_Object_Collection::set_identifier() |
66 | 66 | * |
67 | 67 | * @access public |
68 | - * @param $object |
|
68 | + * @param \EventEspresso\core\services\progress_steps\ProgressStep $object |
|
69 | 69 | * @param mixed $identifier |
70 | 70 | * @return bool |
71 | 71 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * advances pointer to the provided object |
212 | 212 | * |
213 | 213 | * @access public |
214 | - * @param $object |
|
214 | + * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepFormInterface $object |
|
215 | 215 | * @return boolean |
216 | 216 | */ |
217 | 217 | public function setCurrentUsingObject( $object ) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @see http://stackoverflow.com/a/8736013 |
251 | 251 | * @param $object |
252 | - * @return boolean|int|string |
|
252 | + * @return integer |
|
253 | 253 | */ |
254 | 254 | public function indexOf( $object ) { |
255 | 255 | if ( ! $this->contains( $object ) ) { |
@@ -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... |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\interfaces\InterminableInterface; |
3 | 3 | use EventEspresso\core\interfaces\ResettableInterface; |
4 | 4 | |
5 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * EE_Registry Class |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | * @param \EE_Dependency_Map $dependency_map |
190 | 190 | * @return \EE_Registry instance |
191 | 191 | */ |
192 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
192 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
193 | 193 | // check if class object is instantiated |
194 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
195 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
194 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
195 | + self::$_instance = new EE_Registry($dependency_map); |
|
196 | 196 | } |
197 | 197 | return self::$_instance; |
198 | 198 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param \EE_Dependency_Map $dependency_map |
208 | 208 | * @return \EE_Registry |
209 | 209 | */ |
210 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
210 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
211 | 211 | $this->_dependency_map = $dependency_map; |
212 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
212 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -237,19 +237,19 @@ discard block |
||
237 | 237 | $this->modules = new stdClass(); |
238 | 238 | $this->shortcodes = new stdClass(); |
239 | 239 | $this->widgets = new stdClass(); |
240 | - $this->load_core( 'Base', array(), true ); |
|
240 | + $this->load_core('Base', array(), true); |
|
241 | 241 | // add our request and response objects to the cache |
242 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
242 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
243 | 243 | $this->_set_cached_class( |
244 | 244 | $request_loader(), |
245 | 245 | 'EE_Request' |
246 | 246 | ); |
247 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
247 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
248 | 248 | $this->_set_cached_class( |
249 | 249 | $response_loader(), |
250 | 250 | 'EE_Response' |
251 | 251 | ); |
252 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
252 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function init() { |
264 | 264 | // Get current page protocol |
265 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
265 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
266 | 266 | // Output admin-ajax.php URL with same protocol as current page |
267 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
268 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
267 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
268 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | * @return string |
277 | 277 | */ |
278 | 278 | public static function localize_i18n_js_strings() { |
279 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
280 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
281 | - if ( is_scalar( $value ) ) { |
|
282 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
279 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
280 | + foreach ($i18n_js_strings as $key => $value) { |
|
281 | + if (is_scalar($value)) { |
|
282 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
286 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -291,15 +291,15 @@ discard block |
||
291 | 291 | /** |
292 | 292 | * @param mixed string | EED_Module $module |
293 | 293 | */ |
294 | - public function add_module( $module ) { |
|
295 | - if ( $module instanceof EED_Module ) { |
|
296 | - $module_class = get_class( $module ); |
|
294 | + public function add_module($module) { |
|
295 | + if ($module instanceof EED_Module) { |
|
296 | + $module_class = get_class($module); |
|
297 | 297 | $this->modules->{$module_class} = $module; |
298 | 298 | } else { |
299 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
300 | - $this->load_core( 'Module_Request_Router' ); |
|
299 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
300 | + $this->load_core('Module_Request_Router'); |
|
301 | 301 | } |
302 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
302 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | * @param string $module_name |
310 | 310 | * @return mixed EED_Module | NULL |
311 | 311 | */ |
312 | - public function get_module( $module_name = '' ) { |
|
313 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
312 | + public function get_module($module_name = '') { |
|
313 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | |
@@ -324,20 +324,20 @@ discard block |
||
324 | 324 | * @param bool $load_only |
325 | 325 | * @return mixed |
326 | 326 | */ |
327 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
327 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
328 | 328 | $core_paths = apply_filters( |
329 | 329 | 'FHEE__EE_Registry__load_core__core_paths', |
330 | 330 | array( |
331 | 331 | EE_CORE, |
332 | 332 | EE_ADMIN, |
333 | 333 | EE_CPTS, |
334 | - EE_CORE . 'data_migration_scripts' . DS, |
|
335 | - EE_CORE . 'request_stack' . DS, |
|
336 | - EE_CORE . 'middleware' . DS, |
|
334 | + EE_CORE.'data_migration_scripts'.DS, |
|
335 | + EE_CORE.'request_stack'.DS, |
|
336 | + EE_CORE.'middleware'.DS, |
|
337 | 337 | ) |
338 | 338 | ); |
339 | 339 | // retrieve instantiated class |
340 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
340 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | * @param bool $load_only |
352 | 352 | * @return mixed |
353 | 353 | */ |
354 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
354 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
355 | 355 | $service_paths = apply_filters( |
356 | 356 | 'FHEE__EE_Registry__load_service__service_paths', |
357 | 357 | array( |
358 | - EE_CORE . 'services' . DS, |
|
358 | + EE_CORE.'services'.DS, |
|
359 | 359 | ) |
360 | 360 | ); |
361 | 361 | // retrieve instantiated class |
362 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
362 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | * @param mixed $arguments |
373 | 373 | * @return EE_Data_Migration_Script_Base|mixed |
374 | 374 | */ |
375 | - public function load_dms( $class_name, $arguments = array() ) { |
|
375 | + public function load_dms($class_name, $arguments = array()) { |
|
376 | 376 | // retrieve instantiated class |
377 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
377 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -389,14 +389,14 @@ discard block |
||
389 | 389 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
390 | 390 | * @return EE_Base_Class | bool |
391 | 391 | */ |
392 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
393 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
392 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
393 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
394 | 394 | EE_CORE, |
395 | 395 | EE_CLASSES, |
396 | 396 | EE_BUSINESS |
397 | - ) ); |
|
397 | + )); |
|
398 | 398 | // retrieve instantiated class |
399 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
399 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -409,11 +409,11 @@ discard block |
||
409 | 409 | * @param bool $load_only |
410 | 410 | * @return EEH_Base | bool |
411 | 411 | */ |
412 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
412 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
413 | 413 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
414 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
414 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
415 | 415 | // retrieve instantiated class |
416 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
416 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -428,16 +428,16 @@ discard block |
||
428 | 428 | * @param bool $cache whether to cache the object or not. |
429 | 429 | * @return mixed |
430 | 430 | */ |
431 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
431 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
432 | 432 | $paths = array( |
433 | 433 | EE_LIBRARIES, |
434 | - EE_LIBRARIES . 'messages' . DS, |
|
435 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
436 | - EE_LIBRARIES . 'qtips' . DS, |
|
437 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
434 | + EE_LIBRARIES.'messages'.DS, |
|
435 | + EE_LIBRARIES.'shortcodes'.DS, |
|
436 | + EE_LIBRARIES.'qtips'.DS, |
|
437 | + EE_LIBRARIES.'payment_methods'.DS, |
|
438 | 438 | ); |
439 | 439 | // retrieve instantiated class |
440 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
440 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -450,13 +450,13 @@ discard block |
||
450 | 450 | * @param bool $load_only |
451 | 451 | * @return EEM_Base | bool |
452 | 452 | */ |
453 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
454 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
453 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
454 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
455 | 455 | EE_MODELS, |
456 | 456 | EE_CORE |
457 | - ) ); |
|
457 | + )); |
|
458 | 458 | // retrieve instantiated class |
459 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
459 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | * @param bool $load_only |
470 | 470 | * @return mixed | bool |
471 | 471 | */ |
472 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
472 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
473 | 473 | $paths = array( |
474 | - EE_MODELS . 'fields' . DS, |
|
475 | - EE_MODELS . 'helpers' . DS, |
|
476 | - EE_MODELS . 'relations' . DS, |
|
477 | - EE_MODELS . 'strategies' . DS |
|
474 | + EE_MODELS.'fields'.DS, |
|
475 | + EE_MODELS.'helpers'.DS, |
|
476 | + EE_MODELS.'relations'.DS, |
|
477 | + EE_MODELS.'strategies'.DS |
|
478 | 478 | ); |
479 | 479 | // retrieve instantiated class |
480 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
480 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
488 | 488 | * @return boolean |
489 | 489 | */ |
490 | - public function is_model_name( $model_name ) { |
|
491 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
490 | + public function is_model_name($model_name) { |
|
491 | + return isset($this->models[$model_name]) ? true : false; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | * @param bool $load_only |
504 | 504 | * @return mixed |
505 | 505 | */ |
506 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
506 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
507 | 507 | // retrieve instantiated class |
508 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
508 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -520,9 +520,9 @@ discard block |
||
520 | 520 | * @param bool $load_only |
521 | 521 | * @return EE_Addon |
522 | 522 | */ |
523 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
523 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
524 | 524 | // retrieve instantiated class |
525 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
525 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | |
@@ -553,35 +553,35 @@ discard block |
||
553 | 553 | $load_only = false, |
554 | 554 | $addon = false |
555 | 555 | ) { |
556 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
557 | - if ( ! class_exists( $class_name ) ) { |
|
556 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
557 | + if ( ! class_exists($class_name)) { |
|
558 | 558 | // maybe the class is registered with a preceding \ |
559 | - $class_name = strpos( $class_name, '\\' ) !== 0 ? '\\' . $class_name : $class_name; |
|
559 | + $class_name = strpos($class_name, '\\') !== 0 ? '\\'.$class_name : $class_name; |
|
560 | 560 | // still doesn't exist ? |
561 | - if ( ! class_exists( $class_name ) ) { |
|
561 | + if ( ! class_exists($class_name)) { |
|
562 | 562 | return null; |
563 | 563 | } |
564 | 564 | } |
565 | 565 | // if we're only loading the class and it already exists, then let's just return true immediately |
566 | - if ( $load_only ) { |
|
566 | + if ($load_only) { |
|
567 | 567 | return true; |
568 | 568 | } |
569 | 569 | $addon = $addon ? 'addon' : ''; |
570 | 570 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
571 | 571 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
572 | 572 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
573 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
573 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
574 | 574 | // return object if it's already cached |
575 | - $cached_class = $this->_get_cached_class( $class_name, $addon ); |
|
576 | - if ( $cached_class !== null ) { |
|
575 | + $cached_class = $this->_get_cached_class($class_name, $addon); |
|
576 | + if ($cached_class !== null) { |
|
577 | 577 | return $cached_class; |
578 | 578 | } |
579 | 579 | } |
580 | 580 | // instantiate the requested object |
581 | - $class_obj = $this->_create_object( $class_name, $arguments, $addon, $from_db ); |
|
582 | - if ( $this->_cache_on && $cache ) { |
|
581 | + $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db); |
|
582 | + if ($this->_cache_on && $cache) { |
|
583 | 583 | // save it for later... kinda like gum { : $ |
584 | - $this->_set_cached_class( $class_obj, $class_name, $addon, $from_db ); |
|
584 | + $this->_set_cached_class($class_obj, $class_name, $addon, $from_db); |
|
585 | 585 | } |
586 | 586 | $this->_cache_on = true; |
587 | 587 | return $class_obj; |
@@ -616,47 +616,47 @@ discard block |
||
616 | 616 | $load_only = false |
617 | 617 | ) { |
618 | 618 | // strip php file extension |
619 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
619 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
620 | 620 | // does the class have a prefix ? |
621 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
621 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
622 | 622 | // make sure $class_prefix is uppercase |
623 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
623 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
624 | 624 | // add class prefix ONCE!!! |
625 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
625 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
626 | 626 | } |
627 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
628 | - $class_exists = class_exists( $class_name ); |
|
627 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
628 | + $class_exists = class_exists($class_name); |
|
629 | 629 | // if we're only loading the class and it already exists, then let's just return true immediately |
630 | - if ( $load_only && $class_exists ) { |
|
630 | + if ($load_only && $class_exists) { |
|
631 | 631 | return true; |
632 | 632 | } |
633 | 633 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
634 | 634 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
635 | 635 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
636 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
636 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
637 | 637 | // return object if it's already cached |
638 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
639 | - if ( $cached_class !== null ) { |
|
638 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
639 | + if ($cached_class !== null) { |
|
640 | 640 | return $cached_class; |
641 | 641 | } |
642 | 642 | } |
643 | 643 | // if the class doesn't already exist.. then we need to try and find the file and load it |
644 | - if ( ! $class_exists ) { |
|
644 | + if ( ! $class_exists) { |
|
645 | 645 | // get full path to file |
646 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
646 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
647 | 647 | // load the file |
648 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
648 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
649 | 649 | // if loading failed, or we are only loading a file but NOT instantiating an object |
650 | - if ( ! $loaded || $load_only ) { |
|
650 | + if ( ! $loaded || $load_only) { |
|
651 | 651 | // return boolean if only loading, or null if an object was expected |
652 | 652 | return $load_only ? $loaded : null; |
653 | 653 | } |
654 | 654 | } |
655 | 655 | // instantiate the requested object |
656 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
657 | - if ( $this->_cache_on && $cache ) { |
|
656 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
657 | + if ($this->_cache_on && $cache) { |
|
658 | 658 | // save it for later... kinda like gum { : $ |
659 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
659 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
660 | 660 | } |
661 | 661 | $this->_cache_on = true; |
662 | 662 | return $class_obj; |
@@ -679,24 +679,24 @@ discard block |
||
679 | 679 | * @param string $class_prefix |
680 | 680 | * @return mixed |
681 | 681 | */ |
682 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
683 | - if ( $class_name === 'EE_Registry' ) { |
|
682 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
683 | + if ($class_name === 'EE_Registry') { |
|
684 | 684 | return $this; |
685 | 685 | } |
686 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
687 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
686 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
687 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
688 | 688 | } else { |
689 | 689 | // have to specify something, but not anything that will conflict |
690 | 690 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
691 | 691 | } |
692 | 692 | // check if class has already been loaded, and return it if it has been |
693 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
693 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
694 | 694 | return $this->{$class_abbreviation}; |
695 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
695 | + } else if (isset ($this->{$class_name} )) { |
|
696 | 696 | return $this->{$class_name}; |
697 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
697 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
698 | 698 | return $this->LIB->{$class_name}; |
699 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
699 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
700 | 700 | return $this->addons->{$class_name}; |
701 | 701 | } |
702 | 702 | return null; |
@@ -717,20 +717,20 @@ discard block |
||
717 | 717 | * @param array $file_paths |
718 | 718 | * @return string | bool |
719 | 719 | */ |
720 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
720 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
721 | 721 | // make sure $file_paths is an array |
722 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
722 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
723 | 723 | // cycle thru paths |
724 | - foreach ( $file_paths as $key => $file_path ) { |
|
724 | + foreach ($file_paths as $key => $file_path) { |
|
725 | 725 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
726 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
726 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
727 | 727 | // prep file type |
728 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
728 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
729 | 729 | // build full file path |
730 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
730 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
731 | 731 | //does the file exist and can be read ? |
732 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
733 | - return $file_paths[ $key ]; |
|
732 | + if (is_readable($file_paths[$key])) { |
|
733 | + return $file_paths[$key]; |
|
734 | 734 | } |
735 | 735 | } |
736 | 736 | return false; |
@@ -752,29 +752,29 @@ discard block |
||
752 | 752 | * @return boolean |
753 | 753 | * @throws \EE_Error |
754 | 754 | */ |
755 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
755 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
756 | 756 | // don't give up! you gotta... |
757 | 757 | try { |
758 | 758 | //does the file exist and can it be read ? |
759 | - if ( ! $path ) { |
|
759 | + if ( ! $path) { |
|
760 | 760 | // so sorry, can't find the file |
761 | - throw new EE_Error ( |
|
761 | + throw new EE_Error( |
|
762 | 762 | sprintf( |
763 | - __( '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' ), |
|
764 | - trim( $type, '.' ), |
|
763 | + __('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'), |
|
764 | + trim($type, '.'), |
|
765 | 765 | $class_name, |
766 | - '<br />' . implode( ',<br />', $file_paths ) |
|
766 | + '<br />'.implode(',<br />', $file_paths) |
|
767 | 767 | ) |
768 | 768 | ); |
769 | 769 | } |
770 | 770 | // get the file |
771 | - require_once( $path ); |
|
771 | + require_once($path); |
|
772 | 772 | // if the class isn't already declared somewhere |
773 | - if ( class_exists( $class_name, false ) === false ) { |
|
773 | + if (class_exists($class_name, false) === false) { |
|
774 | 774 | // so sorry, not a class |
775 | 775 | throw new EE_Error( |
776 | 776 | sprintf( |
777 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
777 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
778 | 778 | $type, |
779 | 779 | $path, |
780 | 780 | $class_name |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | ); |
783 | 783 | } |
784 | 784 | |
785 | - } catch ( EE_Error $e ) { |
|
785 | + } catch (EE_Error $e) { |
|
786 | 786 | $e->get_error(); |
787 | 787 | return false; |
788 | 788 | } |
@@ -814,61 +814,61 @@ discard block |
||
814 | 814 | * @return null | object |
815 | 815 | * @throws \EE_Error |
816 | 816 | */ |
817 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
817 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
818 | 818 | $class_obj = null; |
819 | 819 | $instantiation_mode = '0) none'; |
820 | 820 | // don't give up! you gotta... |
821 | 821 | try { |
822 | 822 | // create reflection |
823 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
823 | + $reflector = $this->get_ReflectionClass($class_name); |
|
824 | 824 | // make sure arguments are an array |
825 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
825 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
826 | 826 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
827 | 827 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
828 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
828 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
829 | 829 | ? $arguments |
830 | - : array( $arguments ); |
|
830 | + : array($arguments); |
|
831 | 831 | // attempt to inject dependencies ? |
832 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
833 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
832 | + if ($this->_dependency_map->has($class_name)) { |
|
833 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
834 | 834 | } |
835 | 835 | // instantiate the class if possible |
836 | - if ( $reflector->isAbstract() ) { |
|
836 | + if ($reflector->isAbstract()) { |
|
837 | 837 | // nothing to instantiate, loading file was enough |
838 | 838 | // does not throw an exception so $instantiation_mode is unused |
839 | 839 | // $instantiation_mode = "1) no constructor abstract class"; |
840 | 840 | $class_obj = true; |
841 | - } else if ( $reflector->getConstructor() === null && $reflector->isInstantiable() && empty( $arguments ) ) { |
|
841 | + } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) { |
|
842 | 842 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
843 | 843 | $instantiation_mode = "2) no constructor but instantiable"; |
844 | 844 | $class_obj = $reflector->newInstance(); |
845 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
845 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
846 | 846 | $instantiation_mode = "3) new_instance_from_db()"; |
847 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
848 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
847 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
848 | + } else if (method_exists($class_name, 'new_instance')) { |
|
849 | 849 | $instantiation_mode = "4) new_instance()"; |
850 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
851 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
850 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
851 | + } else if (method_exists($class_name, 'instance')) { |
|
852 | 852 | $instantiation_mode = "5) instance()"; |
853 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
854 | - } else if ( $reflector->isInstantiable() ) { |
|
853 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
854 | + } else if ($reflector->isInstantiable()) { |
|
855 | 855 | $instantiation_mode = "6) constructor"; |
856 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
856 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
857 | 857 | } else { |
858 | 858 | // heh ? something's not right ! |
859 | 859 | throw new EE_Error( |
860 | 860 | sprintf( |
861 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
861 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
862 | 862 | $type, |
863 | 863 | $class_name |
864 | 864 | ) |
865 | 865 | ); |
866 | 866 | } |
867 | - } catch ( Exception $e ) { |
|
868 | - if ( ! $e instanceof EE_Error ) { |
|
867 | + } catch (Exception $e) { |
|
868 | + if ( ! $e instanceof EE_Error) { |
|
869 | 869 | $e = new EE_Error( |
870 | 870 | sprintf( |
871 | - __( 'The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso' ), |
|
871 | + __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'), |
|
872 | 872 | $class_name, |
873 | 873 | '<br />', |
874 | 874 | $e->getMessage(), |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | * @param array $array |
889 | 889 | * @return bool |
890 | 890 | */ |
891 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
892 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
891 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
892 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | |
@@ -904,14 +904,14 @@ discard block |
||
904 | 904 | * @param string $class_name |
905 | 905 | * @return ReflectionClass |
906 | 906 | */ |
907 | - public function get_ReflectionClass( $class_name ) { |
|
907 | + public function get_ReflectionClass($class_name) { |
|
908 | 908 | if ( |
909 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
910 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
909 | + ! isset($this->_reflectors[$class_name]) |
|
910 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
911 | 911 | ) { |
912 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
912 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
913 | 913 | } |
914 | - return $this->_reflectors[ $class_name ]; |
|
914 | + return $this->_reflectors[$class_name]; |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -936,50 +936,50 @@ discard block |
||
936 | 936 | * @return array |
937 | 937 | * @throws \ReflectionException |
938 | 938 | */ |
939 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
939 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
940 | 940 | // let's examine the constructor |
941 | 941 | $constructor = $reflector->getConstructor(); |
942 | 942 | // whu? huh? nothing? |
943 | - if ( ! $constructor ) { |
|
943 | + if ( ! $constructor) { |
|
944 | 944 | return $arguments; |
945 | 945 | } |
946 | 946 | // get constructor parameters |
947 | 947 | $params = $constructor->getParameters(); |
948 | 948 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
949 | - $argument_keys = array_keys( $arguments ); |
|
949 | + $argument_keys = array_keys($arguments); |
|
950 | 950 | // now loop thru all of the constructors expected parameters |
951 | - foreach ( $params as $index => $param ) { |
|
951 | + foreach ($params as $index => $param) { |
|
952 | 952 | // is this a dependency for a specific class ? |
953 | 953 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
954 | 954 | if ( |
955 | 955 | // param is not even a class |
956 | - empty( $param_class ) |
|
956 | + empty($param_class) |
|
957 | 957 | // and something already exists in the incoming arguments for this param |
958 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
958 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
959 | 959 | ) { |
960 | 960 | // so let's 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, exists as an incoming argument, AND it's the correct class |
964 | - ! empty( $param_class ) |
|
965 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
966 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
964 | + ! empty($param_class) |
|
965 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
966 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
967 | 967 | ) { |
968 | 968 | // skip this argument and move on to the next |
969 | 969 | continue; |
970 | 970 | } else if ( |
971 | 971 | // parameter is type hinted as a class, and should be injected |
972 | - ! empty( $param_class ) |
|
973 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
972 | + ! empty($param_class) |
|
973 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
974 | 974 | ) { |
975 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
975 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
976 | 976 | } else { |
977 | 977 | try { |
978 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
979 | - } catch ( ReflectionException $e ) { |
|
978 | + $arguments[$index] = $param->getDefaultValue(); |
|
979 | + } catch (ReflectionException $e) { |
|
980 | 980 | throw new ReflectionException( |
981 | 981 | sprintf( |
982 | - __( '%1$s for parameter "$%2$s"', 'event_espresso' ), |
|
982 | + __('%1$s for parameter "$%2$s"', 'event_espresso'), |
|
983 | 983 | $e->getMessage(), |
984 | 984 | $param->getName() |
985 | 985 | ) |
@@ -1001,30 +1001,30 @@ discard block |
||
1001 | 1001 | * @param mixed $index |
1002 | 1002 | * @return array |
1003 | 1003 | */ |
1004 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
1004 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
1005 | 1005 | $dependency = null; |
1006 | 1006 | // should dependency be loaded from cache ? |
1007 | - $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( $class_name, $param_class ) |
|
1007 | + $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class) |
|
1008 | 1008 | !== EE_Dependency_Map::load_new_object |
1009 | 1009 | ? true |
1010 | 1010 | : false; |
1011 | 1011 | // we might have a dependency... |
1012 | 1012 | // let's MAYBE try and find it in our cache if that's what's been requested |
1013 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
1013 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
1014 | 1014 | // and grab it if it exists |
1015 | - if ( $cached_class instanceof $param_class ) { |
|
1015 | + if ($cached_class instanceof $param_class) { |
|
1016 | 1016 | $dependency = $cached_class; |
1017 | - } else if ( $param_class != $class_name ) { |
|
1017 | + } else if ($param_class != $class_name) { |
|
1018 | 1018 | // obtain the loader method from the dependency map |
1019 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
1019 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
1020 | 1020 | // is loader a custom closure ? |
1021 | - if ( $loader instanceof Closure ) { |
|
1021 | + if ($loader instanceof Closure) { |
|
1022 | 1022 | $dependency = $loader(); |
1023 | 1023 | } else { |
1024 | 1024 | // set the cache on property for the recursive loading call |
1025 | 1025 | $this->_cache_on = $cache_on; |
1026 | 1026 | // if not, then let's try and load it via the registry |
1027 | - if ( method_exists( $this, $loader ) ) { |
|
1027 | + if (method_exists($this, $loader)) { |
|
1028 | 1028 | $dependency = $this->{$loader}($param_class); |
1029 | 1029 | } else { |
1030 | 1030 | $dependency = $this->create($param_class, array(), $cache_on); |
@@ -1032,12 +1032,12 @@ discard block |
||
1032 | 1032 | } |
1033 | 1033 | } |
1034 | 1034 | // did we successfully find the correct dependency ? |
1035 | - if ( $dependency instanceof $param_class ) { |
|
1035 | + if ($dependency instanceof $param_class) { |
|
1036 | 1036 | // then let's inject it into the incoming array of arguments at the correct location |
1037 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
1038 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
1037 | + if (isset($argument_keys[$index])) { |
|
1038 | + $arguments[$argument_keys[$index]] = $dependency; |
|
1039 | 1039 | } else { |
1040 | - $arguments[ $index ] = $dependency; |
|
1040 | + $arguments[$index] = $dependency; |
|
1041 | 1041 | } |
1042 | 1042 | } |
1043 | 1043 | return $arguments; |
@@ -1062,19 +1062,19 @@ discard block |
||
1062 | 1062 | * @param bool $from_db |
1063 | 1063 | * @return void |
1064 | 1064 | */ |
1065 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
1066 | - if ( $class_name === 'EE_Registry' || empty( $class_obj ) ) { |
|
1065 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
1066 | + if ($class_name === 'EE_Registry' || empty($class_obj)) { |
|
1067 | 1067 | return; |
1068 | 1068 | } |
1069 | 1069 | // return newly instantiated class |
1070 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
1071 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
1070 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
1071 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
1072 | 1072 | $this->{$class_abbreviation} = $class_obj; |
1073 | - } else if ( property_exists( $this, $class_name ) ) { |
|
1073 | + } else if (property_exists($this, $class_name)) { |
|
1074 | 1074 | $this->{$class_name} = $class_obj; |
1075 | - } else if ( $class_prefix == 'addon' ) { |
|
1075 | + } else if ($class_prefix == 'addon') { |
|
1076 | 1076 | $this->addons->{$class_name} = $class_obj; |
1077 | - } else if ( ! $from_db ) { |
|
1077 | + } else if ( ! $from_db) { |
|
1078 | 1078 | $this->LIB->{$class_name} = $class_obj; |
1079 | 1079 | } |
1080 | 1080 | } |
@@ -1091,12 +1091,12 @@ discard block |
||
1091 | 1091 | * @param array $arguments |
1092 | 1092 | * @return object |
1093 | 1093 | */ |
1094 | - public static function factory( $classname, $arguments = array() ) { |
|
1095 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
1096 | - if ( $loader instanceof Closure ) { |
|
1097 | - return $loader( $arguments ); |
|
1098 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
1099 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
1094 | + public static function factory($classname, $arguments = array()) { |
|
1095 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
1096 | + if ($loader instanceof Closure) { |
|
1097 | + return $loader($arguments); |
|
1098 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
1099 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
1100 | 1100 | } |
1101 | 1101 | return null; |
1102 | 1102 | } |
@@ -1109,9 +1109,9 @@ discard block |
||
1109 | 1109 | * @param string $name |
1110 | 1110 | * @return EE_Addon |
1111 | 1111 | */ |
1112 | - public function get_addon_by_name( $name ) { |
|
1113 | - foreach ( $this->addons as $addon ) { |
|
1114 | - if ( $addon->name() == $name ) { |
|
1112 | + public function get_addon_by_name($name) { |
|
1113 | + foreach ($this->addons as $addon) { |
|
1114 | + if ($addon->name() == $name) { |
|
1115 | 1115 | return $addon; |
1116 | 1116 | } |
1117 | 1117 | } |
@@ -1127,8 +1127,8 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | public function get_addons_by_name() { |
1129 | 1129 | $addons = array(); |
1130 | - foreach ( $this->addons as $addon ) { |
|
1131 | - $addons[ $addon->name() ] = $addon; |
|
1130 | + foreach ($this->addons as $addon) { |
|
1131 | + $addons[$addon->name()] = $addon; |
|
1132 | 1132 | } |
1133 | 1133 | return $addons; |
1134 | 1134 | } |
@@ -1143,16 +1143,16 @@ discard block |
||
1143 | 1143 | * @return \EEM_Base |
1144 | 1144 | * @throws \EE_Error |
1145 | 1145 | */ |
1146 | - public function reset_model( $model_name ) { |
|
1147 | - $model_class_name = strpos( $model_name, 'EEM_' ) !== 0 ? "EEM_{$model_name}" : $model_name; |
|
1148 | - if( ! isset( $this->LIB->{$model_class_name} ) || ! $this->LIB->{$model_class_name} instanceof EEM_Base ) { |
|
1146 | + public function reset_model($model_name) { |
|
1147 | + $model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name; |
|
1148 | + if ( ! isset($this->LIB->{$model_class_name} ) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) { |
|
1149 | 1149 | return null; |
1150 | 1150 | } |
1151 | 1151 | //get that model reset it and make sure we nuke the old reference to it |
1152 | - if ( $this->LIB->{$model_class_name} instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
1152 | + if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
1153 | 1153 | $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset(); |
1154 | 1154 | } else { |
1155 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
1155 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
1156 | 1156 | } |
1157 | 1157 | return $this->LIB->{$model_class_name}; |
1158 | 1158 | } |
@@ -1189,19 +1189,19 @@ discard block |
||
1189 | 1189 | * |
1190 | 1190 | * @return EE_Registry |
1191 | 1191 | */ |
1192 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
1192 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
1193 | 1193 | $instance = self::instance(); |
1194 | 1194 | $instance->_cache_on = true; |
1195 | 1195 | // reset some "special" classes |
1196 | 1196 | EEH_Activation::reset(); |
1197 | - $instance->CFG = $instance->CFG->reset( $hard, $reinstantiate ); |
|
1197 | + $instance->CFG = $instance->CFG->reset($hard, $reinstantiate); |
|
1198 | 1198 | $instance->CART = null; |
1199 | 1199 | $instance->MRM = null; |
1200 | 1200 | //handle of objects cached on LIB |
1201 | - foreach ( array( 'LIB', 'modules', 'shortcodes' ) as $cache ) { |
|
1202 | - foreach ( $instance->{$cache} as $class_name => $class ) { |
|
1203 | - if ( EE_Registry::_reset_and_unset_object( $class, $reset_models )) { |
|
1204 | - unset( $instance->{$cache}->{$class_name} ); |
|
1201 | + foreach (array('LIB', 'modules', 'shortcodes') as $cache) { |
|
1202 | + foreach ($instance->{$cache} as $class_name => $class) { |
|
1203 | + if (EE_Registry::_reset_and_unset_object($class, $reset_models)) { |
|
1204 | + unset($instance->{$cache}->{$class_name} ); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1219,12 +1219,12 @@ discard block |
||
1219 | 1219 | * @param bool $reset_models |
1220 | 1220 | * @return bool returns true if cached object should be unset |
1221 | 1221 | */ |
1222 | - private static function _reset_and_unset_object( $object, $reset_models ) { |
|
1222 | + private static function _reset_and_unset_object($object, $reset_models) { |
|
1223 | 1223 | static $count = 0; |
1224 | 1224 | $count++; |
1225 | - if ( $object instanceof ResettableInterface ) { |
|
1226 | - if ( $object instanceof EEM_Base ) { |
|
1227 | - if ( $reset_models ) { |
|
1225 | + if ($object instanceof ResettableInterface) { |
|
1226 | + if ($object instanceof EEM_Base) { |
|
1227 | + if ($reset_models) { |
|
1228 | 1228 | $object->reset(); |
1229 | 1229 | return true; |
1230 | 1230 | } |
@@ -1233,7 +1233,7 @@ discard block |
||
1233 | 1233 | $object->reset(); |
1234 | 1234 | return true; |
1235 | 1235 | } |
1236 | - if ( ! $object instanceof InterminableInterface ) { |
|
1236 | + if ( ! $object instanceof InterminableInterface) { |
|
1237 | 1237 | return true; |
1238 | 1238 | } |
1239 | 1239 | return false; |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | * @param $a |
1255 | 1255 | * @param $b |
1256 | 1256 | */ |
1257 | - final function __call( $a, $b ) { |
|
1257 | + final function __call($a, $b) { |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | /** |
1263 | 1263 | * @param $a |
1264 | 1264 | */ |
1265 | - final function __get( $a ) { |
|
1265 | + final function __get($a) { |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | * @param $a |
1272 | 1272 | * @param $b |
1273 | 1273 | */ |
1274 | - final function __set( $a, $b ) { |
|
1274 | + final function __set($a, $b) { |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | /** |
1280 | 1280 | * @param $a |
1281 | 1281 | */ |
1282 | - final function __isset( $a ) { |
|
1282 | + final function __isset($a) { |
|
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | /** |
1288 | 1288 | * @param $a |
1289 | 1289 | */ |
1290 | - final function __unset( $a ) { |
|
1290 | + final function __unset($a) { |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | * @param $a |
1335 | 1335 | * @param $b |
1336 | 1336 | */ |
1337 | - final static function __callStatic( $a, $b ) { |
|
1337 | + final static function __callStatic($a, $b) { |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1343,9 +1343,9 @@ discard block |
||
1343 | 1343 | */ |
1344 | 1344 | public function cpt_models() { |
1345 | 1345 | $cpt_models = array(); |
1346 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1347 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1348 | - $cpt_models[ $short_name ] = $classname; |
|
1346 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1347 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1348 | + $cpt_models[$short_name] = $classname; |
|
1349 | 1349 | } |
1350 | 1350 | } |
1351 | 1351 | 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 | } |