@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param EE_Response $response |
51 | 51 | * @return EE_Response |
52 | 52 | */ |
53 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
53 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
54 | 54 | $this->request = $request; |
55 | 55 | $this->response = $response; |
56 | 56 | // central repository for classes |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | // workarounds for PHP < 5.3 |
59 | 59 | $this->_load_class_tools(); |
60 | 60 | // PSR4 Autoloaders |
61 | - EE_Registry::instance()->load_core( 'EE_Psr4AutoloaderInit' ); |
|
61 | + EE_Registry::instance()->load_core('EE_Psr4AutoloaderInit'); |
|
62 | 62 | // deprecated functions |
63 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
63 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
64 | 64 | // load interfaces |
65 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
65 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
66 | 66 | //// WP cron jobs |
67 | - EE_Registry::instance()->load_core( 'Cron_Tasks' ); |
|
68 | - EE_Registry::instance()->load_core( 'EE_System' ); |
|
67 | + EE_Registry::instance()->load_core('Cron_Tasks'); |
|
68 | + EE_Registry::instance()->load_core('EE_System'); |
|
69 | 69 | |
70 | 70 | return $this->response; |
71 | 71 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | private function _load_registry() { |
82 | - if ( is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
83 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
82 | + if (is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
83 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
84 | 84 | } else { |
85 | - $msg = __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ); |
|
86 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
87 | - wp_die( EE_Error::get_notices() ); |
|
85 | + $msg = __('The EE_Registry core class could not be loaded.', 'event_espresso'); |
|
86 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
87 | + wp_die(EE_Error::get_notices()); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | private function _load_class_tools() { |
99 | - if ( is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
100 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
99 | + if (is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
100 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
101 | 101 | } else { |
102 | - $msg = __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ); |
|
103 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
102 | + $msg = __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'); |
|
103 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param \EE_Request $request |
116 | 116 | * @param \EE_Response $response |
117 | 117 | */ |
118 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
118 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
119 | 119 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
120 | 120 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
121 | 121 | //die(); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function instance() { |
158 | 158 | // check if class object is instantiated |
159 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Registry )) { |
|
159 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Registry)) { |
|
160 | 160 | self::$_instance = new self(); |
161 | 161 | } |
162 | 162 | return self::$_instance; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @return EE_Registry |
172 | 172 | */ |
173 | 173 | private function __construct() { |
174 | - $this->load_core( 'Base' ); |
|
174 | + $this->load_core('Base'); |
|
175 | 175 | // class library |
176 | 176 | $this->LIB = new StdClass(); |
177 | 177 | $this->addons = new StdClass(); |
178 | 178 | $this->modules = new StdClass(); |
179 | 179 | $this->shortcodes = new StdClass(); |
180 | 180 | $this->widgets = new StdClass(); |
181 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' )); |
|
181 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function init() { |
193 | 193 | // Get current page protocol |
194 | - $protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://'; |
|
194 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
195 | 195 | // Output admin-ajax.php URL with same protocol as current page |
196 | - self::$i18n_js_strings['ajax_url'] = admin_url( 'admin-ajax.php', $protocol ); |
|
197 | - self::$i18n_js_strings['wp_debug'] = defined( 'WP_DEBUG' ) ? WP_DEBUG : FALSE; |
|
196 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
197 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : FALSE; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @return string |
206 | 206 | */ |
207 | 207 | public static function localize_i18n_js_strings() { |
208 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
209 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
210 | - if ( is_scalar( $value ) ) { |
|
211 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
208 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
209 | + foreach ($i18n_js_strings as $key => $value) { |
|
210 | + if (is_scalar($value)) { |
|
211 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
215 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * @param mixed string | EED_Module $module |
222 | 222 | */ |
223 | - public function add_module( $module ) { |
|
224 | - if ( $module instanceof EED_Module ) { |
|
225 | - $module_class = get_class( $module ); |
|
223 | + public function add_module($module) { |
|
224 | + if ($module instanceof EED_Module) { |
|
225 | + $module_class = get_class($module); |
|
226 | 226 | $this->modules->{$module_class} = $module; |
227 | 227 | } else { |
228 | - if ( ! class_exists( 'EE_Module_Request_Router' )) { |
|
229 | - $this->load_core( 'Module_Request_Router' ); |
|
228 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
229 | + $this->load_core('Module_Request_Router'); |
|
230 | 230 | } |
231 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
231 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param string $module_name |
239 | 239 | * @return mixed EED_Module | NULL |
240 | 240 | */ |
241 | - public function get_module( $module_name = '' ) { |
|
242 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
241 | + public function get_module($module_name = '') { |
|
242 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * @param bool $load_only |
253 | 253 | * @return mixed |
254 | 254 | */ |
255 | - public function load_core ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
255 | + public function load_core($class_name, $arguments = array(), $load_only = FALSE) { |
|
256 | 256 | $core_paths = apply_filters( |
257 | 257 | 'FHEE__EE_Registry__load_core__core_paths', |
258 | 258 | array( |
259 | 259 | EE_CORE, |
260 | 260 | EE_ADMIN, |
261 | 261 | EE_CPTS, |
262 | - EE_CORE . 'data_migration_scripts' . DS |
|
262 | + EE_CORE.'data_migration_scripts'.DS |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | // retrieve instantiated class |
266 | - return $this->_load( $core_paths, 'EE_' , $class_name, 'core', $arguments, FALSE, TRUE, $load_only ); |
|
266 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, FALSE, TRUE, $load_only); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param mixed $arguments |
277 | 277 | * @return EE_Data_Migration_Script_Base |
278 | 278 | */ |
279 | - public function load_dms ( $class_name, $arguments = array() ) { |
|
279 | + public function load_dms($class_name, $arguments = array()) { |
|
280 | 280 | // retrieve instantiated class |
281 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_' , $class_name, 'dms', $arguments, FALSE, FALSE, FALSE ); |
|
281 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, FALSE, FALSE, FALSE); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
294 | 294 | * @return EE_Base_Class |
295 | 295 | */ |
296 | - public function load_class ( $class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
297 | - $paths = apply_filters('FHEE__EE_Registry__load_class__paths',array( |
|
296 | + public function load_class($class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
297 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
298 | 298 | EE_CORE, |
299 | 299 | EE_CLASSES, |
300 | 300 | EE_BUSINESS |
301 | 301 | )); |
302 | 302 | // retrieve instantiated class |
303 | - return $this->_load( $paths, 'EE_' , $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
303 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * @param bool $load_only |
315 | 315 | * @return EEH_Base |
316 | 316 | */ |
317 | - public function load_helper ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
318 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS ) ); |
|
317 | + public function load_helper($class_name, $arguments = array(), $load_only = TRUE) { |
|
318 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
319 | 319 | // retrieve instantiated class |
320 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only ); |
|
320 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | * @param bool $load_only |
332 | 332 | * @return mixed |
333 | 333 | */ |
334 | - public function load_lib ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
334 | + public function load_lib($class_name, $arguments = array(), $load_only = FALSE) { |
|
335 | 335 | $paths = array( |
336 | 336 | EE_LIBRARIES, |
337 | - EE_LIBRARIES . 'messages' . DS, |
|
338 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
339 | - EE_LIBRARIES . 'qtips' . DS, |
|
340 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
337 | + EE_LIBRARIES.'messages'.DS, |
|
338 | + EE_LIBRARIES.'shortcodes'.DS, |
|
339 | + EE_LIBRARIES.'qtips'.DS, |
|
340 | + EE_LIBRARIES.'payment_methods'.DS, |
|
341 | 341 | ); |
342 | 342 | // retrieve instantiated class |
343 | - return $this->_load( $paths, 'EE_' , $class_name, 'lib', $arguments, FALSE, TRUE, $load_only ); |
|
343 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, FALSE, TRUE, $load_only); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | * @param bool $load_only |
354 | 354 | * @return EEM_Base |
355 | 355 | */ |
356 | - public function load_model ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
357 | - $paths = apply_filters('FHEE__EE_Registry__load_model__paths',array( |
|
356 | + public function load_model($class_name, $arguments = array(), $load_only = FALSE) { |
|
357 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
358 | 358 | EE_MODELS, |
359 | 359 | EE_CORE |
360 | 360 | )); |
361 | 361 | // retrieve instantiated class |
362 | - return $this->_load( $paths, 'EEM_' , $class_name, 'model', $arguments, FALSE, TRUE, $load_only ); |
|
362 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, FALSE, TRUE, $load_only); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | * @param bool $load_only |
373 | 373 | * @return mixed |
374 | 374 | */ |
375 | - public function load_model_class ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
375 | + public function load_model_class($class_name, $arguments = array(), $load_only = TRUE) { |
|
376 | 376 | $paths = array( |
377 | - EE_MODELS . 'fields' . DS, |
|
378 | - EE_MODELS . 'helpers' . DS, |
|
379 | - EE_MODELS . 'relations' . DS, |
|
380 | - EE_MODELS . 'strategies' . DS |
|
377 | + EE_MODELS.'fields'.DS, |
|
378 | + EE_MODELS.'helpers'.DS, |
|
379 | + EE_MODELS.'relations'.DS, |
|
380 | + EE_MODELS.'strategies'.DS |
|
381 | 381 | ); |
382 | 382 | // retrieve instantiated class |
383 | - return $this->_load( $paths, 'EE_' , $class_name, '', $arguments, FALSE, TRUE, $load_only ); |
|
383 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, FALSE, TRUE, $load_only); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
393 | 393 | * @return boolean |
394 | 394 | */ |
395 | - public function is_model_name( $model_name ){ |
|
396 | - return isset( $this->models[ $model_name ] ) ? TRUE : FALSE; |
|
395 | + public function is_model_name($model_name) { |
|
396 | + return isset($this->models[$model_name]) ? TRUE : FALSE; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @param bool $load_only |
409 | 409 | * @return mixed |
410 | 410 | */ |
411 | - public function load_file ( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE ) { |
|
411 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE) { |
|
412 | 412 | // retrieve instantiated class |
413 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
413 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * @param bool $load_only |
426 | 426 | * @return EE_Addon |
427 | 427 | */ |
428 | - public function load_addon ( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE ) { |
|
428 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE) { |
|
429 | 429 | // retrieve instantiated class |
430 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
430 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * @internal param string $file_path - file path including file name |
446 | 446 | * @return bool | object |
447 | 447 | */ |
448 | - private function _load ( $file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
448 | + private function _load($file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
449 | 449 | // strip php file extension |
450 | - $class_name = str_replace( '.php', '', trim( $class_name )); |
|
450 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
451 | 451 | // does the class have a prefix ? |
452 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
452 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
453 | 453 | // make sure $class_prefix is uppercase |
454 | - $class_prefix = strtoupper( trim( $class_prefix )); |
|
454 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
455 | 455 | // add class prefix ONCE!!! |
456 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
456 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $class_abbreviations = array( |
@@ -466,56 +466,56 @@ discard block |
||
466 | 466 | ); |
467 | 467 | |
468 | 468 | // check if class has already been loaded, and return it if it has been |
469 | - if ( isset( $class_abbreviations[ $class_name ] ) && ! is_null( $this->$class_abbreviations[ $class_name ] )) { |
|
470 | - return $this->$class_abbreviations[ $class_name ]; |
|
471 | - } else if ( isset ( $this->{$class_name} )) { |
|
469 | + if (isset($class_abbreviations[$class_name]) && ! is_null($this->$class_abbreviations[$class_name])) { |
|
470 | + return $this->$class_abbreviations[$class_name]; |
|
471 | + } else if (isset ($this->{$class_name} )) { |
|
472 | 472 | return $this->{$class_name}; |
473 | - } else if ( isset ( $this->LIB->$class_name )) { |
|
473 | + } else if (isset ($this->LIB->$class_name)) { |
|
474 | 474 | return $this->LIB->$class_name; |
475 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->$class_name )) { |
|
475 | + } else if ($class_prefix == 'addon' && isset ($this->addons->$class_name)) { |
|
476 | 476 | return $this->addons->$class_name; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // assume all paths lead nowhere |
480 | 480 | $path = FALSE; |
481 | 481 | // make sure $file_paths is an array |
482 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
482 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
483 | 483 | // cycle thru paths |
484 | - foreach ( $file_paths as $key => $file_path ) { |
|
484 | + foreach ($file_paths as $key => $file_path) { |
|
485 | 485 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
486 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
486 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
487 | 487 | // prep file type |
488 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
488 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
489 | 489 | // build full file path |
490 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
490 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
491 | 491 | //does the file exist and can be read ? |
492 | - if ( is_readable( $file_paths[ $key ] )) { |
|
493 | - $path = $file_paths[ $key ]; |
|
492 | + if (is_readable($file_paths[$key])) { |
|
493 | + $path = $file_paths[$key]; |
|
494 | 494 | break; |
495 | 495 | } |
496 | 496 | } |
497 | 497 | // don't give up! you gotta... |
498 | 498 | try { |
499 | 499 | //does the file exist and can it be read ? |
500 | - if ( ! $path ) { |
|
500 | + if ( ! $path) { |
|
501 | 501 | // so sorry, can't find the file |
502 | - throw new EE_Error ( |
|
503 | - sprintf ( |
|
504 | - __('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'), |
|
505 | - trim( $type, '.' ), |
|
502 | + throw new EE_Error( |
|
503 | + sprintf( |
|
504 | + __('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'), |
|
505 | + trim($type, '.'), |
|
506 | 506 | $class_name, |
507 | - '<br />' . implode( ',<br />', $file_paths ) |
|
507 | + '<br />'.implode(',<br />', $file_paths) |
|
508 | 508 | ) |
509 | 509 | ); |
510 | 510 | } |
511 | 511 | // get the file |
512 | - require_once( $path ); |
|
512 | + require_once($path); |
|
513 | 513 | // if the class isn't already declared somewhere |
514 | - if ( class_exists( $class_name, FALSE ) === FALSE ) { |
|
514 | + if (class_exists($class_name, FALSE) === FALSE) { |
|
515 | 515 | // so sorry, not a class |
516 | 516 | throw new EE_Error( |
517 | 517 | sprintf( |
518 | - __('The %s file %s does not appear to contain the %s Class.','event_espresso'), |
|
518 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
519 | 519 | $type, |
520 | 520 | $path, |
521 | 521 | $class_name |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | ); |
524 | 524 | } |
525 | 525 | |
526 | - } catch ( EE_Error $e ) { |
|
526 | + } catch (EE_Error $e) { |
|
527 | 527 | $e->get_error(); |
528 | 528 | } |
529 | 529 | |
@@ -531,38 +531,38 @@ discard block |
||
531 | 531 | // don't give up! you gotta... |
532 | 532 | try { |
533 | 533 | // create reflection |
534 | - $reflector = new ReflectionClass( $class_name ); |
|
534 | + $reflector = new ReflectionClass($class_name); |
|
535 | 535 | // instantiate the class and add to the LIB array for tracking |
536 | 536 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
537 | - if ( $reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only ) { |
|
537 | + if ($reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only) { |
|
538 | 538 | // $instantiation_mode = 0; |
539 | 539 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
540 | 540 | return TRUE; |
541 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
541 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
542 | 542 | // $instantiation_mode = 1; |
543 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
544 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
543 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
544 | + } else if (method_exists($class_name, 'new_instance')) { |
|
545 | 545 | // $instantiation_mode = 2; |
546 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
547 | - } else if ( method_exists( $class_name, 'instance' )) { |
|
546 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
547 | + } else if (method_exists($class_name, 'instance')) { |
|
548 | 548 | // $instantiation_mode = 3; |
549 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
550 | - } else if ( $reflector->isInstantiable() ) { |
|
549 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
550 | + } else if ($reflector->isInstantiable()) { |
|
551 | 551 | // $instantiation_mode = 4; |
552 | - $class_obj = $reflector->newInstance( $arguments ); |
|
553 | - } else if ( ! $load_only ) { |
|
552 | + $class_obj = $reflector->newInstance($arguments); |
|
553 | + } else if ( ! $load_only) { |
|
554 | 554 | // heh ? something's not right ! |
555 | 555 | // $instantiation_mode = 5; |
556 | 556 | throw new EE_Error( |
557 | 557 | sprintf( |
558 | - __('The %s file %s could not be instantiated.','event_espresso'), |
|
558 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
559 | 559 | $type, |
560 | 560 | $class_name |
561 | 561 | ) |
562 | 562 | ); |
563 | 563 | } |
564 | 564 | |
565 | - } catch ( EE_Error $e ) { |
|
565 | + } catch (EE_Error $e) { |
|
566 | 566 | $e->get_error(); |
567 | 567 | } |
568 | 568 | |
@@ -574,15 +574,15 @@ discard block |
||
574 | 574 | // EEH_Debug_Tools::printr( $class_obj, '$class_obj <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
575 | 575 | |
576 | 576 | |
577 | - if ( isset( $class_obj )) { |
|
577 | + if (isset($class_obj)) { |
|
578 | 578 | // return newly instantiated class |
579 | - if ( isset( $class_abbreviations[ $class_name ] )) { |
|
580 | - $this->$class_abbreviations[ $class_name ] = $class_obj; |
|
581 | - } else if ( EEH_Class_Tools::has_property( $this, $class_name )) { |
|
579 | + if (isset($class_abbreviations[$class_name])) { |
|
580 | + $this->$class_abbreviations[$class_name] = $class_obj; |
|
581 | + } else if (EEH_Class_Tools::has_property($this, $class_name)) { |
|
582 | 582 | $this->{$class_name} = $class_obj; |
583 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
583 | + } else if ($class_prefix == 'addon' && $cache) { |
|
584 | 584 | $this->addons->$class_name = $class_obj; |
585 | - } else if ( !$from_db && $cache ) { |
|
585 | + } else if ( ! $from_db && $cache) { |
|
586 | 586 | $this->LIB->$class_name = $class_obj; |
587 | 587 | } |
588 | 588 | return $class_obj; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @param $a |
608 | 608 | * @param $b |
609 | 609 | */ |
610 | - final function __call($a,$b) {} |
|
610 | + final function __call($a, $b) {} |
|
611 | 611 | |
612 | 612 | |
613 | 613 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @param $a |
623 | 623 | * @param $b |
624 | 624 | */ |
625 | - final function __set($a,$b) {} |
|
625 | + final function __set($a, $b) {} |
|
626 | 626 | |
627 | 627 | |
628 | 628 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @param $a |
663 | 663 | * @param $b |
664 | 664 | */ |
665 | - final static function __callStatic($a,$b) {} |
|
665 | + final static function __callStatic($a, $b) {} |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * Gets the addon by its name/slug (not classname. For that, just |
@@ -670,9 +670,9 @@ discard block |
||
670 | 670 | * @param string $name |
671 | 671 | * @return EE_Addon |
672 | 672 | */ |
673 | - public function get_addon_by_name( $name ){ |
|
674 | - foreach($this->addons as $addon){ |
|
675 | - if( $addon->name() == $name){ |
|
673 | + public function get_addon_by_name($name) { |
|
674 | + foreach ($this->addons as $addon) { |
|
675 | + if ($addon->name() == $name) { |
|
676 | 676 | return $addon; |
677 | 677 | } |
678 | 678 | } |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return EE_Addon[] where the KEYS are the addon's name() |
685 | 685 | */ |
686 | - public function get_addons_by_name(){ |
|
686 | + public function get_addons_by_name() { |
|
687 | 687 | $addons = array(); |
688 | - foreach($this->addons as $addon){ |
|
689 | - $addons[ $addon->name() ] = $addon; |
|
688 | + foreach ($this->addons as $addon) { |
|
689 | + $addons[$addon->name()] = $addon; |
|
690 | 690 | } |
691 | 691 | return $addons; |
692 | 692 | } |
@@ -701,14 +701,14 @@ discard block |
||
701 | 701 | * @return EEM_Base |
702 | 702 | * @throws EE_Error |
703 | 703 | */ |
704 | - public function reset_model( $model_name ){ |
|
705 | - $model = $this->load_model( $model_name ); |
|
706 | - $model_class_name = get_class( $model ); |
|
704 | + public function reset_model($model_name) { |
|
705 | + $model = $this->load_model($model_name); |
|
706 | + $model_class_name = get_class($model); |
|
707 | 707 | //get that model reset it and make sure we nuke the old reference to it |
708 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
708 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
709 | 709 | $this->LIB->$model_class_name = $model::reset(); |
710 | - }else{ |
|
711 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
710 | + } else { |
|
711 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
712 | 712 | } |
713 | 713 | return $this->LIB->$model_class_name; |
714 | 714 | } |
@@ -724,15 +724,15 @@ discard block |
||
724 | 724 | * currently reinstantiate the singletons at the moment) |
725 | 725 | * @return EE_Registry |
726 | 726 | */ |
727 | - public static function reset( $hard = FALSE, $reinstantiate = TRUE ){ |
|
727 | + public static function reset($hard = FALSE, $reinstantiate = TRUE) { |
|
728 | 728 | $instance = self::instance(); |
729 | 729 | $instance->load_helper('Activation'); |
730 | 730 | EEH_Activation::reset(); |
731 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
731 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
732 | 732 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
733 | 733 | $instance->LIB = new stdClass(); |
734 | - foreach( array_keys( $instance->non_abstract_db_models ) as $model_name ){ |
|
735 | - $instance->reset_model( $model_name ); |
|
734 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
735 | + $instance->reset_model($model_name); |
|
736 | 736 | } |
737 | 737 | return $instance; |
738 | 738 | } |
@@ -743,9 +743,9 @@ discard block |
||
743 | 743 | */ |
744 | 744 | public function cpt_models() { |
745 | 745 | $cpt_models = array(); |
746 | - foreach( $this->non_abstract_db_models as $shortname => $classname ) { |
|
747 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
748 | - $cpt_models[ $shortname ] = $classname; |
|
746 | + foreach ($this->non_abstract_db_models as $shortname => $classname) { |
|
747 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
748 | + $cpt_models[$shortname] = $classname; |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | return $cpt_models; |
@@ -11,25 +11,25 @@ discard block |
||
11 | 11 | final class EE_Registry { |
12 | 12 | |
13 | 13 | /** |
14 | - * EE_Registry Object |
|
15 | - * @var EE_Registry $_instance |
|
16 | - * @access private |
|
17 | - */ |
|
14 | + * EE_Registry Object |
|
15 | + * @var EE_Registry $_instance |
|
16 | + * @access private |
|
17 | + */ |
|
18 | 18 | private static $_instance = NULL; |
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * EE_Cart Object |
|
23 | - * @access public |
|
24 | - * @var EE_Cart $CART |
|
25 | - */ |
|
22 | + * EE_Cart Object |
|
23 | + * @access public |
|
24 | + * @var EE_Cart $CART |
|
25 | + */ |
|
26 | 26 | public $CART = NULL; |
27 | 27 | |
28 | 28 | /** |
29 | - * EE_Config Object |
|
30 | - * @access public |
|
31 | - * @var EE_Config $CFG |
|
32 | - */ |
|
29 | + * EE_Config Object |
|
30 | + * @access public |
|
31 | + * @var EE_Config $CFG |
|
32 | + */ |
|
33 | 33 | public $CFG = NULL; |
34 | 34 | |
35 | 35 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | /** |
47 | - * StdClass object for storing library classes in |
|
48 | - * @public LIB |
|
49 | - */ |
|
47 | + * StdClass object for storing library classes in |
|
48 | + * @public LIB |
|
49 | + */ |
|
50 | 50 | public $LIB = NULL; |
51 | 51 | |
52 | 52 | /** |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public $REQ = NULL; |
58 | 58 | |
59 | 59 | /** |
60 | - * EE_Session Object |
|
61 | - * @access public |
|
62 | - * @var EE_Session $SSN |
|
63 | - */ |
|
60 | + * EE_Session Object |
|
61 | + * @access public |
|
62 | + * @var EE_Session $SSN |
|
63 | + */ |
|
64 | 64 | public $SSN = NULL; |
65 | 65 | |
66 | 66 | |
@@ -127,21 +127,21 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
130 | - * $i18n_js_strings - internationalization for JS strings |
|
131 | - * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
|
132 | - * in js file: var translatedString = eei18n.string_key; |
|
133 | - * |
|
134 | - * @access public |
|
135 | - * @var array |
|
136 | - */ |
|
130 | + * $i18n_js_strings - internationalization for JS strings |
|
131 | + * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
|
132 | + * in js file: var translatedString = eei18n.string_key; |
|
133 | + * |
|
134 | + * @access public |
|
135 | + * @var array |
|
136 | + */ |
|
137 | 137 | public static $i18n_js_strings = array(); |
138 | 138 | |
139 | 139 | /** |
140 | - * $main_file - path to espresso.php |
|
141 | - * |
|
142 | - * @access public |
|
143 | - * @var array |
|
144 | - */ |
|
140 | + * $main_file - path to espresso.php |
|
141 | + * |
|
142 | + * @access public |
|
143 | + * @var array |
|
144 | + */ |
|
145 | 145 | public $main_file; |
146 | 146 | |
147 | 147 |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param object $post The post object of the cpt that was saved. |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - abstract protected function _insert_update_cpt_item( $post_id, $post ); |
|
116 | + abstract protected function _insert_update_cpt_item($post_id, $post); |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $post_id The ID of the cpt that was trashed |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - abstract public function trash_cpt_item( $post_id ); |
|
129 | + abstract public function trash_cpt_item($post_id); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $post_id theID of the cpt that was untrashed |
138 | 138 | * @return void |
139 | 139 | */ |
140 | - abstract public function restore_cpt_item( $post_id ); |
|
140 | + abstract public function restore_cpt_item($post_id); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $post_id the ID of the cpt that was deleted |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - abstract public function delete_cpt_item( $post_id ); |
|
151 | + abstract public function delete_cpt_item($post_id); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | |
@@ -161,32 +161,32 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function _before_page_setup() { |
163 | 163 | |
164 | - $page = isset( $this->_req_data['page'] ) ? $this->_req_data['page'] : $this->page_slug; |
|
164 | + $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
|
165 | 165 | |
166 | - $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes ); |
|
166 | + $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes); |
|
167 | 167 | |
168 | 168 | //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
169 | - $this->_cpt_object = isset($this->_req_data['action']) && isset( $this->_cpt_routes[$this->_req_data['action']] ) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object( $page ); |
|
169 | + $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object($page); |
|
170 | 170 | |
171 | 171 | //tweak pagenow for page loading. |
172 | - if( ! $this->_pagenow_map ) { |
|
172 | + if ( ! $this->_pagenow_map) { |
|
173 | 173 | $this->_pagenow_map = array( |
174 | 174 | 'create_new' => 'post-new.php', |
175 | 175 | 'edit' => 'post.php', |
176 | 176 | 'trash' => 'post.php' |
177 | 177 | ); |
178 | 178 | } |
179 | - add_action( 'current_screen', array( $this, 'modify_pagenow') ); |
|
179 | + add_action('current_screen', array($this, 'modify_pagenow')); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
183 | 183 | //get current page from autosave |
184 | - $current_page = isset( $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] ) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | - $this->_current_page = isset( $this->_req_data['current_page'] ) ? $this->_req_data['current_page'] : $current_page; |
|
184 | + $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | + $this->_current_page = isset($this->_req_data['current_page']) ? $this->_req_data['current_page'] : $current_page; |
|
186 | 186 | |
187 | 187 | |
188 | 188 | //autosave... make sure its only for the correct page |
189 | - if ( !empty($this->_current_page ) && $this->_current_page == $this->page_slug ) { |
|
189 | + if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
|
190 | 190 | //setup autosave ajax hook |
191 | 191 | //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
192 | 192 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - public function modify_pagenow( $current_screen ) { |
|
205 | + public function modify_pagenow($current_screen) { |
|
206 | 206 | global $pagenow; |
207 | 207 | //possibly reset pagenow. |
208 | - if ( ! empty( $this->_req_data['page'] ) && $this->_req_data['page'] == $this->page_slug && !empty( $this->_req_data['action'] ) && isset( $this->_pagenow_map[$this->_req_data['action'] ] ) ) { |
|
208 | + if ( ! empty($this->_req_data['page']) && $this->_req_data['page'] == $this->page_slug && ! empty($this->_req_data['action']) && isset($this->_pagenow_map[$this->_req_data['action']])) { |
|
209 | 209 | $pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
210 | 210 | } |
211 | 211 | } |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically you would send along the id of a metabox container. |
221 | 221 | * @return void |
222 | 222 | */ |
223 | - protected function _register_autosave_containers( $ids ) { |
|
224 | - $this->_autosave_containers = array_merge( $this->_autosave_fields, (array) $ids ); |
|
223 | + protected function _register_autosave_containers($ids) { |
|
224 | + $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | |
237 | 237 | $containers = array(); |
238 | 238 | |
239 | - if ( empty( $wp_meta_boxes ) ) |
|
239 | + if (empty($wp_meta_boxes)) |
|
240 | 240 | return; |
241 | 241 | |
242 | - $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
242 | + $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
243 | 243 | |
244 | - foreach ( $current_metaboxes as $box_context ) { |
|
245 | - foreach ( $box_context as $box_details ) { |
|
246 | - foreach ( $box_details as $box ) { |
|
247 | - if ( is_array( $box['callback'] ) && ( $box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks ) ){ |
|
244 | + foreach ($current_metaboxes as $box_context) { |
|
245 | + foreach ($box_context as $box_details) { |
|
246 | + foreach ($box_details as $box) { |
|
247 | + if (is_array($box['callback']) && ($box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks)) { |
|
248 | 248 | $containers[] = $box['id']; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - $this->_autosave_containers = array_merge( $this->_autosave_containers, $containers ); |
|
254 | + $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
|
255 | 255 | |
256 | 256 | //add hidden inputs container |
257 | 257 | $this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2 |
269 | 269 | |
270 | 270 | //filter _autosave_containers |
271 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this ); |
|
272 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', $containers, $this ); |
|
271 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this); |
|
272 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers', $containers, $this); |
|
273 | 273 | |
274 | - wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers ); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
274 | + wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
275 | 275 | |
276 | 276 | $unsaved_data_msg = array( |
277 | - 'eventmsg' => sprintf( __("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
277 | + 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
278 | 278 | 'inputChanged' => 0 |
279 | 279 | ); |
280 | 280 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function load_page_dependencies() { |
287 | 287 | try { |
288 | 288 | $this->_load_page_dependencies(); |
289 | - } catch ( EE_Error $e ) { |
|
289 | + } catch (EE_Error $e) { |
|
290 | 290 | $e->get_error(); |
291 | 291 | } |
292 | 292 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | protected function _load_page_dependencies() { |
303 | 303 | |
304 | 304 | //we only add stuff if this is a cpt_route! |
305 | - if ( !$this->_cpt_route ) { |
|
305 | + if ( ! $this->_cpt_route) { |
|
306 | 306 | parent::_load_page_dependencies(); |
307 | 307 | return; |
308 | 308 | } |
@@ -312,72 +312,72 @@ discard block |
||
312 | 312 | |
313 | 313 | //the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
314 | 314 | //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
315 | - add_action('edit_form_after_title', array( $this, 'cpt_post_form_hidden_input') ); |
|
315 | + add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
|
316 | 316 | |
317 | 317 | //inject our Admin page nav tabs... |
318 | 318 | //let's make sure the nav tabs are set if they aren't already |
319 | 319 | //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
320 | - add_action('post_edit_form_tag', array( $this, 'inject_nav_tabs' ) ); |
|
320 | + add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
|
321 | 321 | |
322 | 322 | //modify the post_updated messages array |
323 | - add_action('post_updated_messages', array( $this, 'post_update_messages' ), 10 ); |
|
323 | + add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
|
324 | 324 | |
325 | 325 | //add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
326 | - add_filter( 'pre_get_shortlink', array( $this, 'add_shortlink_button_to_editor' ), 10, 4 ); |
|
326 | + add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
|
327 | 327 | |
328 | 328 | //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
329 | - if ( !empty($this->_labels['publishbox'] ) ) { |
|
329 | + if ( ! empty($this->_labels['publishbox'])) { |
|
330 | 330 | |
331 | - $box_label = is_array( $this->_labels['publishbox'] ) && isset( $this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
331 | + $box_label = is_array($this->_labels['publishbox']) && isset($this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
332 | 332 | |
333 | - remove_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
334 | - add_meta_box( 'submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
333 | + remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
334 | + add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | //let's add page_templates metabox if this cpt added support for it. |
338 | - if ( $this->_supports_page_templates($this->_cpt_object->name) ) { |
|
339 | - add_meta_box( 'page_templates', __('Page Template', 'event_espresso' ), array( $this, 'page_template_meta_box' ), $this->_cpt_routes[$this->_req_action], 'side', 'default' ); |
|
338 | + if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
339 | + add_meta_box('page_templates', __('Page Template', 'event_espresso'), array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
|
340 | 340 | }/**/ |
341 | 341 | |
342 | 342 | |
343 | 343 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
345 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
344 | + if (method_exists($this, 'extra_permalink_field_buttons')) |
|
345 | + add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
|
346 | 346 | |
347 | 347 | //add preview button |
348 | - add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
|
348 | + add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
|
349 | 349 | |
350 | 350 | |
351 | 351 | //insert our own post_stati dropdown |
352 | - add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
|
352 | + add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
|
353 | 353 | |
354 | 354 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
355 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
356 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
355 | + if (method_exists($this, 'extra_misc_actions_publish_box')) |
|
356 | + add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
|
357 | 357 | |
358 | 358 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
360 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
359 | + if (method_exists($this, 'edit_form_after_title')) |
|
360 | + add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
|
361 | 361 | |
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
365 | 365 | */ |
366 | - add_filter( 'clean_url', array( $this, 'switch_core_wp_urls_with_ours' ), 10, 3 ); |
|
366 | + add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | parent::_load_page_dependencies(); |
370 | 370 | |
371 | 371 | //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
372 | 372 | global $pagenow; |
373 | - do_action( 'load-' . $pagenow ); |
|
373 | + do_action('load-'.$pagenow); |
|
374 | 374 | |
375 | 375 | $this->modify_current_screen(); |
376 | - add_action( 'admin_enqueue_scripts', array( $this, 'setup_autosave_hooks'), 30 ); |
|
376 | + add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
|
377 | 377 | //we route REALLY early. |
378 | 378 | try { |
379 | 379 | $this->_route_admin_request(); |
380 | - } catch ( EE_Error $e ) { |
|
380 | + } catch (EE_Error $e) { |
|
381 | 381 | $e->get_error(); |
382 | 382 | } |
383 | 383 | } |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string possibly a new url for our route. |
398 | 398 | */ |
399 | - public function switch_core_wp_urls_with_ours( $good_protocol_url, $original_url, $_context ) { |
|
399 | + public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) { |
|
400 | 400 | $routes_to_match = array( |
401 | 401 | 0 => array( |
402 | 402 | 'edit.php?post_type=espresso_attendees', |
403 | 403 | 'admin.php?page=espresso_registrations&action=contact_list' |
404 | 404 | ), |
405 | 405 | 1 => array( |
406 | - 'edit.php?post_type=' . $this->_cpt_object->name, |
|
407 | - 'admin.php?page=' . $this->_cpt_object->name |
|
406 | + 'edit.php?post_type='.$this->_cpt_object->name, |
|
407 | + 'admin.php?page='.$this->_cpt_object->name |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | |
411 | - foreach( $routes_to_match as $route_matches ) { |
|
412 | - if ( strpos( $good_protocol_url, $route_matches[0] ) !== false ) { |
|
413 | - return str_replace( $route_matches[0], $route_matches[1], $good_protocol_url ); |
|
411 | + foreach ($routes_to_match as $route_matches) { |
|
412 | + if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
413 | + return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | } |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | * @param string $cpt_name The cpt slug we're checking on. |
427 | 427 | * @return bool True supported, false not. |
428 | 428 | */ |
429 | - private function _supports_page_templates( $cpt_name ) { |
|
429 | + private function _supports_page_templates($cpt_name) { |
|
430 | 430 | $cpt_args = EE_Register_CPTs::get_CPTs(); |
431 | - $cpt_args = isset( $cpt_args[$cpt_name] ) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | - return ! empty( $cpt_args['page_templates'] ) ? TRUE : FALSE; |
|
431 | + $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | + return ! empty($cpt_args['page_templates']) ? TRUE : FALSE; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | public function page_template_meta_box() { |
445 | 445 | global $post; |
446 | 446 | $template = ''; |
447 | - if ( count( get_page_templates( $post ) ) != 0 ) { |
|
448 | - $page_template = get_post_meta( $post->ID, '_wp_page_template', TRUE ); |
|
449 | - $template = !empty( $page_template ) ? $page_template : ''; |
|
447 | + if (count(get_page_templates($post)) != 0) { |
|
448 | + $page_template = get_post_meta($post->ID, '_wp_page_template', TRUE); |
|
449 | + $template = ! empty($page_template) ? $page_template : ''; |
|
450 | 450 | } |
451 | 451 | ?> |
452 | 452 | <p><strong><?php _e('Template') ?></strong></p> |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | * @param string $new_slug what the slug is |
471 | 471 | * @return string The new html string for the permalink area |
472 | 472 | */ |
473 | - public function preview_button_html( $return, $id, $new_title, $new_slug ) { |
|
474 | - $post = get_post( $id ); |
|
475 | - if ( 'publish' != get_post_status( $post ) ) { |
|
476 | - $return .= '<span_id="view-post-btn"><a href="' . wp_get_shortlink($id, 'post') . '" class="button button-small">' . __('Preview', 'event_espresso') . '</a></span>' . "\n"; |
|
473 | + public function preview_button_html($return, $id, $new_title, $new_slug) { |
|
474 | + $post = get_post($id); |
|
475 | + if ('publish' != get_post_status($post)) { |
|
476 | + $return .= '<span_id="view-post-btn"><a href="'.wp_get_shortlink($id, 'post').'" class="button button-small">'.__('Preview', 'event_espresso').'</a></span>'."\n"; |
|
477 | 477 | } |
478 | 478 | return $return; |
479 | 479 | } |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | 'cur_status' => $this->_cpt_model_obj->status(), |
494 | 494 | 'statuses' => $statuses, |
495 | 495 | 'cur_status_label' => $cur_status_label, |
496 | - 'localized_status_save' => sprintf( __('Save %s', 'event_espresso'), $cur_status_label ) |
|
496 | + 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label) |
|
497 | 497 | ); |
498 | 498 | |
499 | 499 | //we'll add a trash post status (WP doesn't add one for some reason) |
500 | - if ( $this->_cpt_model_obj->status() == 'trash' ) { |
|
500 | + if ($this->_cpt_model_obj->status() == 'trash') { |
|
501 | 501 | $template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
502 | 502 | $statuses['trash'] = __('Trashed', 'event_espresso'); |
503 | 503 | $template_args['statuses'] = $statuses; |
504 | 504 | } |
505 | 505 | |
506 | - $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
507 | - EEH_Template::display_template( $template, $template_args ); |
|
506 | + $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php'; |
|
507 | + EEH_Template::display_template($template, $template_args); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -543,22 +543,22 @@ discard block |
||
543 | 543 | public function do_extra_autosave_stuff() { |
544 | 544 | |
545 | 545 | //next let's check for the autosave nonce (we'll use _verify_nonce ) |
546 | - $nonce = isset( $this->_req_data['autosavenonce'] ) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | - $this->_verify_nonce( $nonce, 'autosave' ); |
|
546 | + $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | + $this->_verify_nonce($nonce, 'autosave'); |
|
548 | 548 | |
549 | 549 | |
550 | 550 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
551 | + if ( ! defined('DOING_AUTOSAVE')) define('DOING_AUTOSAVE', true); |
|
552 | 552 | |
553 | 553 | //if we made it here then the nonce checked out. Let's run our methods and actions |
554 | - if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
|
555 | - call_user_func( array( $this, '_ee_autosave_' . $this->_current_view ) ); |
|
554 | + if (method_exists($this, '_ee_autosave_'.$this->_current_view)) { |
|
555 | + call_user_func(array($this, '_ee_autosave_'.$this->_current_view)); |
|
556 | 556 | } else { |
557 | 557 | $this->_template_args['success'] = TRUE; |
558 | 558 | } |
559 | 559 | |
560 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this ); |
|
561 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class( $this ), $this ); |
|
560 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
561 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this); |
|
562 | 562 | |
563 | 563 | //now let's return json |
564 | 564 | $this->_return_json(); |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | protected function _extend_page_config_for_cpt() { |
579 | 579 | |
580 | 580 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
581 | + if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) |
|
582 | 582 | return; |
583 | 583 | |
584 | 584 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585 | - if ( !empty( $this->_cpt_object ) ) { |
|
586 | - $this->_page_routes = array_merge( array( |
|
585 | + if ( ! empty($this->_cpt_object)) { |
|
586 | + $this->_page_routes = array_merge(array( |
|
587 | 587 | 'create_new' => '_create_new_cpt_item', |
588 | 588 | 'edit' => '_edit_cpt_item' |
589 | - ), $this->_page_routes ); |
|
589 | + ), $this->_page_routes); |
|
590 | 590 | |
591 | 591 | |
592 | - $this->_page_config = array_merge( array( |
|
592 | + $this->_page_config = array_merge(array( |
|
593 | 593 | 'create_new' => array( |
594 | 594 | 'nav' => array( |
595 | 595 | 'label' => $this->_cpt_object->labels->add_new_item, |
@@ -611,23 +611,23 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
614 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
614 | + if ( ! isset($this->_cpt_routes[$this->_req_action])) |
|
615 | 615 | return; |
616 | 616 | |
617 | 617 | |
618 | - $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
|
618 | + $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? TRUE : FALSE; |
|
619 | 619 | //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
620 | 620 | |
621 | 621 | |
622 | - if ( empty( $this->_cpt_object ) ) { |
|
623 | - $msg = sprintf( __('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this) ); |
|
624 | - throw new EE_Error( $msg ); |
|
622 | + if (empty($this->_cpt_object)) { |
|
623 | + $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this)); |
|
624 | + throw new EE_Error($msg); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
628 | - if ( $this->_cpt_route ) { |
|
629 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
630 | - $this->_set_model_object( $id ); |
|
628 | + if ($this->_cpt_route) { |
|
629 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
630 | + $this->_set_model_object($id); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | } |
@@ -643,17 +643,17 @@ discard block |
||
643 | 643 | * @param int $id The id to retrieve the model object for. If empty we set a default object. |
644 | 644 | * @return void |
645 | 645 | */ |
646 | - protected function _set_model_object( $id = NULL ) { |
|
646 | + protected function _set_model_object($id = NULL) { |
|
647 | 647 | |
648 | - if ( empty( $this->_cpt_model_names ) || ! isset( $this->_cpt_routes[ $this->_req_action ] ) || ( is_object( $this->_cpt_model_obj ) && $this->_cpt_model_obj->ID() == $id )) { |
|
648 | + if (empty($this->_cpt_model_names) || ! isset($this->_cpt_routes[$this->_req_action]) || (is_object($this->_cpt_model_obj) && $this->_cpt_model_obj->ID() == $id)) { |
|
649 | 649 | //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent. |
650 | 650 | return; |
651 | 651 | } |
652 | 652 | // load CPT object model |
653 | - $model = EE_Registry::instance()->load_model( $this->_cpt_model_names[$this->_req_action] ); |
|
654 | - $this->_cpt_model_obj = ! empty( $id ) ? $model->get_one_by_ID( $id ) : $model->create_default_object(); |
|
653 | + $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
|
654 | + $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
|
655 | 655 | //d( $this->_cpt_model_obj ); |
656 | - do_action( 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object' ); |
|
656 | + do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
@@ -667,47 +667,47 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function admin_init_global() { |
669 | 669 | |
670 | - $post = isset( $this->_req_data['post'] ) ? get_post( $this->_req_data['post'] ) : NULL; |
|
670 | + $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : NULL; |
|
671 | 671 | |
672 | 672 | //its possible this is a new save so let's catch that instead |
673 | - $post = isset( $this->_req_data['post_ID'] ) ? get_post( $this->_req_data['post_ID'] ) : $post; |
|
673 | + $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
|
674 | 674 | $post_type = $post ? $post->post_type : false; |
675 | 675 | |
676 | 676 | $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
677 | 677 | |
678 | - $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
678 | + $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
679 | 679 | |
680 | - add_filter( 'get_delete_post_link', array( $this, 'modify_delete_post_link'), 10, 3 ); |
|
681 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link'), 10, 3 ); |
|
680 | + add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
681 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
682 | 682 | |
683 | 683 | |
684 | - if ( $post_type === $route_to_check ) { |
|
685 | - add_filter('redirect_post_location', array( $this, 'cpt_post_location_redirect'), 10, 2 ); |
|
684 | + if ($post_type === $route_to_check) { |
|
685 | + add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
|
686 | 686 | //catch trashed wp redirect |
687 | - add_filter('wp_redirect', array( $this, 'cpt_trash_post_location_redirect' ), 10, 2 ); |
|
687 | + add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | //now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
691 | - $revision = isset( $this->_req_data['revision'] ) ? $this->_req_data['revision'] : NULL; |
|
691 | + $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
|
692 | 692 | |
693 | 693 | /**var_dump($this->_req_data); |
694 | 694 | exit();/**/ |
695 | 695 | |
696 | - if ( !empty( $revision ) ) { |
|
697 | - $action = isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : NULL; |
|
696 | + if ( ! empty($revision)) { |
|
697 | + $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : NULL; |
|
698 | 698 | |
699 | 699 | //doing a restore? |
700 | - if ( !empty( $action ) && $action == 'restore' ) { |
|
700 | + if ( ! empty($action) && $action == 'restore') { |
|
701 | 701 | |
702 | 702 | //get post for revision |
703 | - $rev_post = get_post( $revision ); |
|
704 | - $rev_parent = get_post( $rev_post->post_parent ); |
|
703 | + $rev_post = get_post($revision); |
|
704 | + $rev_parent = get_post($rev_post->post_parent); |
|
705 | 705 | |
706 | 706 | //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
707 | - if ( $rev_parent && $rev_parent->post_type == $this->page_slug ) { |
|
708 | - add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2 ); |
|
707 | + if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
708 | + add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
|
709 | 709 | //restores of revisions |
710 | - add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2 ); |
|
710 | + add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
|
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
@@ -716,15 +716,15 @@ discard block |
||
716 | 716 | //NOTE we ONLY want to run these hooks if we're on the right class for the given post type. Otherwise we could see some really freaky things happen! |
717 | 717 | |
718 | 718 | |
719 | - if ( $post_type && $post_type === $route_to_check ) { |
|
719 | + if ($post_type && $post_type === $route_to_check) { |
|
720 | 720 | //$post_id, $post |
721 | - add_action('save_post', array( $this, 'insert_update'), 10, 2 ); |
|
721 | + add_action('save_post', array($this, 'insert_update'), 10, 2); |
|
722 | 722 | |
723 | 723 | //$post_id |
724 | - add_action('trashed_post', array( $this, 'trash_cpt_item' ), 10 ); |
|
725 | - add_action('trashed_post', array( $this, 'dont_permanently_delete_ee_cpts'), 10 ); |
|
726 | - add_action('untrashed_post', array( $this, 'restore_cpt_item'), 10 ); |
|
727 | - add_action('after_delete_post', array( $this, 'delete_cpt_item'), 10 ); |
|
724 | + add_action('trashed_post', array($this, 'trash_cpt_item'), 10); |
|
725 | + add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
726 | + add_action('untrashed_post', array($this, 'restore_cpt_item'), 10); |
|
727 | + add_action('after_delete_post', array($this, 'delete_cpt_item'), 10); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | } |
@@ -739,15 +739,15 @@ discard block |
||
739 | 739 | * @return void |
740 | 740 | */ |
741 | 741 | public function verify_cpt_object() { |
742 | - $label = !empty( $this->_cpt_object ) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
742 | + $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
743 | 743 | // verify event object |
744 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
745 | - throw new EE_Error( sprintf( __('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso' ), $label ) ); |
|
744 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
745 | + throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso'), $label)); |
|
746 | 746 | } |
747 | 747 | //if auto-draft then throw an error |
748 | - if ( $this->_cpt_model_obj->get('status') == 'auto-draft' ) { |
|
748 | + if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
|
749 | 749 | EE_Error::overwrite_errors(); |
750 | - EE_Error::add_error( sprintf( __('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label ), __FILE__, __FUNCTION__, __LINE__ ); |
|
750 | + EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label), __FILE__, __FUNCTION__, __LINE__); |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | |
@@ -776,22 +776,22 @@ discard block |
||
776 | 776 | public function load_global_scripts_styles() { |
777 | 777 | parent::load_global_scripts_styles(); |
778 | 778 | |
779 | - if ( $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
779 | + if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
780 | 780 | //setup custom post status object for localize script but only if we've got a cpt object |
781 | 781 | $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
782 | 782 | |
783 | - if ( !empty($statuses) ) { |
|
783 | + if ( ! empty($statuses)) { |
|
784 | 784 | //get ALL statuses! |
785 | 785 | $statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
786 | 786 | //setup object |
787 | 787 | $ee_cpt_statuses = array(); |
788 | - foreach ( $statuses as $status => $label ) { |
|
788 | + foreach ($statuses as $status => $label) { |
|
789 | 789 | $ee_cpt_statuses[$status] = array( |
790 | 790 | 'label' => $label, |
791 | - 'save_label' => sprintf( __('Save as %s', 'event_espresso'), $label ) |
|
791 | + 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label) |
|
792 | 792 | ); |
793 | 793 | } |
794 | - wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses ); |
|
794 | + wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | } |
@@ -805,10 +805,10 @@ discard block |
||
805 | 805 | * @param WP_Post $post Post object from WP |
806 | 806 | * @return void |
807 | 807 | */ |
808 | - public function insert_update( $post_id, $post ) { |
|
808 | + public function insert_update($post_id, $post) { |
|
809 | 809 | |
810 | 810 | //make sure that if this is a revision OR trash action that we don't do any updates! |
811 | - if ( isset( $this->_req_data['action'] ) && ( $this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash' ) ) |
|
811 | + if (isset($this->_req_data['action']) && ($this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash')) |
|
812 | 812 | return; |
813 | 813 | |
814 | 814 | //check for autosave and update our req_data property accordingly. |
@@ -823,19 +823,19 @@ discard block |
||
823 | 823 | }/**/ //TODO reactivate after autosave is implemented in 4.2 |
824 | 824 | |
825 | 825 | //take care of updating any selected page_template IF this cpt supports it. |
826 | - if ( $this->_supports_page_templates($post->post_type ) && !empty( $this->_req_data['page_template'] ) ) { |
|
826 | + if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
|
827 | 827 | $post->page_template = $this->_req_data['page_template']; |
828 | - $page_templates = wp_get_theme()->get_page_templates( $post ); |
|
829 | - if ( 'default' != $this->_req_data['page_template'] && ! isset( $page_templates[ $this->_req_data['page_template'] ] ) ) { |
|
830 | - EE_Error::add_error( __('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
828 | + $page_templates = wp_get_theme()->get_page_templates($post); |
|
829 | + if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
830 | + EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | } else { |
832 | - update_post_meta( $post_id, '_wp_page_template', $this->_req_data['page_template'] ); |
|
832 | + update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
836 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
837 | 837 | return; //TODO we'll remove this after reimplementing autosave in 4.2 |
838 | - $this->_insert_update_cpt_item( $post_id, $post ); |
|
838 | + $this->_insert_update_cpt_item($post_id, $post); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @param int $post_id ID of the post |
849 | 849 | * @return void |
850 | 850 | */ |
851 | - public function dont_permanently_delete_ee_cpts( $post_id ) { |
|
852 | - delete_post_meta( $post_id, '_wp_trash_meta_status' ); |
|
851 | + public function dont_permanently_delete_ee_cpts($post_id) { |
|
852 | + delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
853 | 853 | delete_post_meta($post_id, '_wp_trash_meta_time'); |
854 | 854 | |
855 | 855 | //our cpts may have comments so let's take care of that too |
@@ -868,14 +868,14 @@ discard block |
||
868 | 868 | * @param int $revision_id ID of revision being restored |
869 | 869 | * @return void |
870 | 870 | */ |
871 | - public function restore_revision( $post_id, $revision_id ) { |
|
872 | - $this->_restore_cpt_item( $post_id, $revision_id ); |
|
871 | + public function restore_revision($post_id, $revision_id) { |
|
872 | + $this->_restore_cpt_item($post_id, $revision_id); |
|
873 | 873 | |
874 | 874 | //global action |
875 | - do_action( 'AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
875 | + do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
876 | 876 | |
877 | 877 | //class specific action so you can limit hooking into a specific page. |
878 | - do_action( 'AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id ); |
|
878 | + do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * @param int $revision_id ID of revision for item |
887 | 887 | * @return void |
888 | 888 | */ |
889 | - abstract protected function _restore_cpt_item( $post_id, $revision_id ); |
|
889 | + abstract protected function _restore_cpt_item($post_id, $revision_id); |
|
890 | 890 | |
891 | 891 | |
892 | 892 | |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | */ |
906 | 906 | public function modify_current_screen() { |
907 | 907 | //ONLY do this if the current page_route IS a cpt route |
908 | - if ( !$this->_cpt_route ) return; |
|
908 | + if ( ! $this->_cpt_route) return; |
|
909 | 909 | //routing things REALLY early b/c this is a cpt admin page |
910 | - set_current_screen( $this->_cpt_routes[$this->_req_action]); |
|
910 | + set_current_screen($this->_cpt_routes[$this->_req_action]); |
|
911 | 911 | $this->_current_screen = get_current_screen(); |
912 | 912 | $this->_current_screen->base = 'event-espresso'; |
913 | 913 | $this->_add_help_tabs(); //we make sure we add any help tabs back in! |
@@ -928,8 +928,8 @@ discard block |
||
928 | 928 | * @param string $title The new title (or existing if there is no editor_title defined) |
929 | 929 | * @return string |
930 | 930 | */ |
931 | - public function add_custom_editor_default_title( $title ) { |
|
932 | - return isset( $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] ) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
931 | + public function add_custom_editor_default_title($title) { |
|
932 | + return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | |
@@ -942,11 +942,11 @@ discard block |
||
942 | 942 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
943 | 943 | * @return string |
944 | 944 | */ |
945 | - public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
|
946 | - if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
|
947 | - $post = get_post( $id ); |
|
948 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
949 | - $shortlink = home_url('?p=' . $post->ID); |
|
945 | + public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) { |
|
946 | + if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
947 | + $post = get_post($id); |
|
948 | + if (isset($post->post_type) && $this->page_slug == $post->post_type) |
|
949 | + $shortlink = home_url('?p='.$post->ID); |
|
950 | 950 | } |
951 | 951 | return $shortlink; |
952 | 952 | } |
@@ -959,10 +959,10 @@ discard block |
||
959 | 959 | * @return void |
960 | 960 | */ |
961 | 961 | public function route_admin_request() { |
962 | - if ( $this->_cpt_route ) return; |
|
962 | + if ($this->_cpt_route) return; |
|
963 | 963 | try { |
964 | 964 | $this->_route_admin_request(); |
965 | - } catch ( EE_Error $e ) { |
|
965 | + } catch (EE_Error $e) { |
|
966 | 966 | $e->get_error(); |
967 | 967 | } |
968 | 968 | } |
@@ -975,12 +975,12 @@ discard block |
||
975 | 975 | * @return string html |
976 | 976 | */ |
977 | 977 | public function cpt_post_form_hidden_input() { |
978 | - echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
978 | + echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />'; |
|
979 | 979 | |
980 | 980 | //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
981 | 981 | echo '<div id="ee-cpt-hidden-inputs">'; |
982 | - echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
983 | - echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
982 | + echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />'; |
|
983 | + echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />'; |
|
984 | 984 | echo '</div>'; |
985 | 985 | } |
986 | 986 | |
@@ -993,12 +993,12 @@ discard block |
||
993 | 993 | * @param int $status Status for http header |
994 | 994 | * @return string new (or original) url to redirect to. |
995 | 995 | */ |
996 | - public function revision_redirect( $location, $status ) { |
|
996 | + public function revision_redirect($location, $status) { |
|
997 | 997 | //get revision |
998 | 998 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
999 | 999 | |
1000 | 1000 | //can't do anything without revision so let's get out if not present |
1001 | - if ( empty( $rev_id ) ) |
|
1001 | + if (empty($rev_id)) |
|
1002 | 1002 | return $location; |
1003 | 1003 | |
1004 | 1004 | //get rev_post_data |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | 'message' => 5 |
1013 | 1013 | ); |
1014 | 1014 | |
1015 | - $this->_process_notices( $query_args, TRUE ); |
|
1016 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1015 | + $this->_process_notices($query_args, TRUE); |
|
1016 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | |
@@ -1026,16 +1026,16 @@ discard block |
||
1026 | 1026 | * @param string $context optional, defaults to display. How to write the '&' |
1027 | 1027 | * @return string the link |
1028 | 1028 | */ |
1029 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
1030 | - $post = get_post( $id ); |
|
1031 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1029 | + public function modify_edit_post_link($link, $id, $context) { |
|
1030 | + $post = get_post($id); |
|
1031 | + if ( ! isset($this->_req_data['action']) || ! isset($this->_cpt_routes[$this->_req_data['action']]) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
|
1032 | 1032 | return $link; |
1033 | 1033 | $query_args = array( |
1034 | 1034 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1035 | 1035 | 'post' => $id |
1036 | 1036 | ); |
1037 | 1037 | |
1038 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1038 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | |
@@ -1047,12 +1047,12 @@ discard block |
||
1047 | 1047 | * @param bool $force_delete whether this is forcing a hard delete instead of trash |
1048 | 1048 | * @return string new delete link |
1049 | 1049 | */ |
1050 | - public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
|
1050 | + public function modify_delete_post_link($delete_link, $post_id, $force_delete) { |
|
1051 | 1051 | $post = get_post($post_id); |
1052 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1052 | + if ( ! isset($this->_req_data['action']) || (isset($this->_cpt_routes[$this->_req_data['action']]) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])) |
|
1053 | 1053 | return $delete_link; |
1054 | 1054 | |
1055 | - return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
|
1055 | + return add_query_arg(array('current_route' => 'trash'), $delete_link); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | |
@@ -1063,16 +1063,16 @@ discard block |
||
1063 | 1063 | * @param string $status status |
1064 | 1064 | * @return string url to redirect to |
1065 | 1065 | */ |
1066 | - public function cpt_trash_post_location_redirect( $location, $status ) { |
|
1067 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1066 | + public function cpt_trash_post_location_redirect($location, $status) { |
|
1067 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) |
|
1068 | 1068 | return $location; |
1069 | 1069 | |
1070 | - $post = get_post( $this->_req_data['post'] ); |
|
1071 | - $query_args = array( 'action' => 'default' ); |
|
1070 | + $post = get_post($this->_req_data['post']); |
|
1071 | + $query_args = array('action' => 'default'); |
|
1072 | 1072 | $this->_cpt_object = get_post_type_object($post->post_type); |
1073 | - EE_Error::add_success( sprintf( __('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name) ); |
|
1074 | - $this->_process_notices( $query_args, TRUE ); |
|
1075 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1073 | + EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name)); |
|
1074 | + $this->_process_notices($query_args, TRUE); |
|
1075 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * @param string $post_id This is the 'ID' value of the wp_posts table |
1088 | 1088 | * @return string the new location to redirect to |
1089 | 1089 | */ |
1090 | - public function cpt_post_location_redirect( $location, $post_id ) { |
|
1090 | + public function cpt_post_location_redirect($location, $post_id) { |
|
1091 | 1091 | //we DO have a match so let's setup the url |
1092 | 1092 | |
1093 | 1093 | //we have to get the post to determine our route |
@@ -1095,14 +1095,14 @@ discard block |
||
1095 | 1095 | $edit_route = $this->_cpt_edit_routes[$post->post_type]; |
1096 | 1096 | |
1097 | 1097 | //shared query_args |
1098 | - $query_args = array( 'action' => $edit_route, 'post' => $post_id ); |
|
1098 | + $query_args = array('action' => $edit_route, 'post' => $post_id); |
|
1099 | 1099 | $admin_url = $this->_admin_base_url; |
1100 | 1100 | // $append = ''; |
1101 | 1101 | |
1102 | - if ( isset( $this->_req_data['save'] ) || isset( $this->_req_data['publish'] ) ) { |
|
1103 | - $status = get_post_status( $post_id ); |
|
1104 | - if ( isset( $this->_req_data['publish'] ) ) { |
|
1105 | - switch ( $status ) { |
|
1102 | + if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
1103 | + $status = get_post_status($post_id); |
|
1104 | + if (isset($this->_req_data['publish'])) { |
|
1105 | + switch ($status) { |
|
1106 | 1106 | case 'pending': |
1107 | 1107 | $message = 8; |
1108 | 1108 | break; |
@@ -1115,13 +1115,13 @@ discard block |
||
1115 | 1115 | } else { |
1116 | 1116 | $message = 'draft' == $status ? 10 : 1; |
1117 | 1117 | } |
1118 | - } else if ( isset( $this->_req_data['addmeta']) && $this->_req_data['addmeta'] ) { |
|
1118 | + } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
|
1119 | 1119 | $message = 2; |
1120 | 1120 | // $append = '#postcustom'; |
1121 | - } else if ( isset( $this->_req_data['deletemeta']) && $this->_req_data['deletemeta'] ) { |
|
1121 | + } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
|
1122 | 1122 | $message = 3; |
1123 | 1123 | // $append = '#postcustom'; |
1124 | - } elseif ( $this->_req_data['action'] == 'post-quickpress-save-cont' ) { |
|
1124 | + } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
|
1125 | 1125 | $message = 7; |
1126 | 1126 | } else { |
1127 | 1127 | $message = 4; |
@@ -1129,12 +1129,12 @@ discard block |
||
1129 | 1129 | |
1130 | 1130 | //change the message if the post type is not viewable on the frontend |
1131 | 1131 | $this->_cpt_object = get_post_type_object($post->post_type); |
1132 | - $message = $message === 1 && !$this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1132 | + $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1133 | 1133 | |
1134 | - $query_args = array_merge( array( 'message' => $message ), $query_args ); |
|
1134 | + $query_args = array_merge(array('message' => $message), $query_args); |
|
1135 | 1135 | |
1136 | - $this->_process_notices( $query_args, TRUE ); |
|
1137 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1136 | + $this->_process_notices($query_args, TRUE); |
|
1137 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | |
@@ -1166,10 +1166,10 @@ discard block |
||
1166 | 1166 | * @param array $messages the original messages array |
1167 | 1167 | * @return array the new messages array |
1168 | 1168 | */ |
1169 | - public function post_update_messages( $messages ) { |
|
1169 | + public function post_update_messages($messages) { |
|
1170 | 1170 | global $post; |
1171 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1172 | - $id = empty( $id ) && is_object( $post ) ? $post->ID : NULL; |
|
1171 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1172 | + $id = empty($id) && is_object($post) ? $post->ID : NULL; |
|
1173 | 1173 | |
1174 | 1174 | // $post_type = $post ? $post->post_type : false; |
1175 | 1175 | |
@@ -1182,9 +1182,9 @@ discard block |
||
1182 | 1182 | 0 => '', //Unused. Messages start at index 1. |
1183 | 1183 | |
1184 | 1184 | 1 => sprintf( |
1185 | - __( '%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1185 | + __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1186 | 1186 | $this->_cpt_object->labels->singular_name, |
1187 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1187 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1188 | 1188 | '</a>' |
1189 | 1189 | ), |
1190 | 1190 | |
@@ -1192,38 +1192,38 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | 3 => __('Custom field deleted.'), |
1194 | 1194 | |
1195 | - 4 => sprintf( __( '%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1195 | + 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1196 | 1196 | |
1197 | - 5 => isset( $_GET['revision'] ) ? sprintf( __('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title( (int) $_GET['revision'], FALSE ) ) : FALSE, |
|
1197 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], FALSE)) : FALSE, |
|
1198 | 1198 | |
1199 | 1199 | 6 => sprintf( |
1200 | - __( '%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1200 | + __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1201 | 1201 | $this->_cpt_object->labels->singular_name, |
1202 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1202 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1203 | 1203 | '</a>' |
1204 | 1204 | ), |
1205 | 1205 | |
1206 | - 7 => sprintf( __( '%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1206 | + 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1207 | 1207 | |
1208 | 1208 | 8 => sprintf( |
1209 | 1209 | __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
1210 | 1210 | $this->_cpt_object->labels->singular_name, |
1211 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) . '">', |
|
1211 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">', |
|
1212 | 1212 | '</a>' |
1213 | 1213 | ), |
1214 | 1214 | |
1215 | 1215 | 9 => sprintf( |
1216 | - __( '%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1216 | + __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1217 | 1217 | $this->_cpt_object->labels->singular_name, |
1218 | - '<strong>' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date )) . '</strong>', |
|
1219 | - '<a target="_blank" href="' . esc_url( get_permalink( $id )), |
|
1218 | + '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>', |
|
1219 | + '<a target="_blank" href="'.esc_url(get_permalink($id)), |
|
1220 | 1220 | '</a>' |
1221 | 1221 | ), |
1222 | 1222 | |
1223 | 1223 | 10 => sprintf( |
1224 | 1224 | __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
1225 | 1225 | $this->_cpt_object->labels->singular_name, |
1226 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) , |
|
1226 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
1227 | 1227 | '</a>' |
1228 | 1228 | ) |
1229 | 1229 | ); |
@@ -1250,24 +1250,24 @@ discard block |
||
1250 | 1250 | $post_type_object = $this->_cpt_object; |
1251 | 1251 | $title = $post_type_object->labels->add_new_item; |
1252 | 1252 | $editing = TRUE; |
1253 | - wp_enqueue_script( 'autosave' ); |
|
1254 | - $post = $post = get_default_post_to_edit( $this->_cpt_routes[$this->_req_action], TRUE ); |
|
1253 | + wp_enqueue_script('autosave'); |
|
1254 | + $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], TRUE); |
|
1255 | 1255 | $post_ID = $post->ID; |
1256 | 1256 | $is_IE = $is_IE; |
1257 | 1257 | |
1258 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1258 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1259 | 1259 | |
1260 | 1260 | //modify the default editor title field with default title. |
1261 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1261 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1262 | 1262 | |
1263 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1263 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | |
1267 | 1267 | |
1268 | 1268 | |
1269 | 1269 | public function add_new_admin_page_global() { |
1270 | - $admin_page = !empty( $this->_req_data['post'] ) ? 'post-php' : 'post-new-php'; |
|
1270 | + $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
|
1271 | 1271 | ?> |
1272 | 1272 | <script type="text/javascript"> |
1273 | 1273 | adminpage = '<?php echo $admin_page; ?>'; |
@@ -1289,16 +1289,16 @@ discard block |
||
1289 | 1289 | */ |
1290 | 1290 | protected function _edit_cpt_item() { |
1291 | 1291 | global $post, $title, $is_IE, $post_type, $post_type_object; |
1292 | - $post_id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1293 | - $post = !empty( $post_id ) ? get_post( $post_id, OBJECT, 'edit' ) : NULL; |
|
1292 | + $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1293 | + $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : NULL; |
|
1294 | 1294 | |
1295 | - if ( empty ( $post ) ) { |
|
1296 | - wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); |
|
1295 | + if (empty ($post)) { |
|
1296 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if ( ! empty( $_GET['get-post-lock'] ) ) { |
|
1300 | - wp_set_post_lock( $post_id ); |
|
1301 | - wp_redirect( get_edit_post_link( $post_id, 'url' ) ); |
|
1299 | + if ( ! empty($_GET['get-post-lock'])) { |
|
1300 | + wp_set_post_lock($post_id); |
|
1301 | + wp_redirect(get_edit_post_link($post_id, 'url')); |
|
1302 | 1302 | exit(); |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1310,32 +1310,32 @@ discard block |
||
1310 | 1310 | $post_type_object = $this->_cpt_object; |
1311 | 1311 | $is_IE = $is_IE; |
1312 | 1312 | |
1313 | - if ( ! wp_check_post_lock( $post->ID ) ) { |
|
1314 | - $active_post_lock = wp_set_post_lock( $post->ID ); |
|
1313 | + if ( ! wp_check_post_lock($post->ID)) { |
|
1314 | + $active_post_lock = wp_set_post_lock($post->ID); |
|
1315 | 1315 | //wp_enqueue_script('autosave'); |
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | $title = $this->_cpt_object->labels->edit_item; |
1319 | 1319 | |
1320 | - add_action('admin_footer', '_admin_notice_post_locked' ); |
|
1320 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
1321 | 1321 | |
1322 | - if ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && !isset( $this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']] ) ) { |
|
1323 | - $create_new_action = apply_filters( 'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this ); |
|
1322 | + if (isset($this->_cpt_routes[$this->_req_data['action']]) && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])) { |
|
1323 | + $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this); |
|
1324 | 1324 | |
1325 | - $post_new_file = EE_Admin_Page::add_query_args_and_nonce( array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php' ); |
|
1325 | + $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php'); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | - if ( post_type_supports($this->_cpt_routes[$this->_req_action], 'comments') ) { |
|
1328 | + if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
|
1329 | 1329 | wp_enqueue_script('admin-comments'); |
1330 | 1330 | enqueue_comment_hotkeys_js(); |
1331 | 1331 | } |
1332 | 1332 | |
1333 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1333 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1334 | 1334 | |
1335 | 1335 | //modify the default editor title field with default title. |
1336 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1336 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1337 | 1337 | |
1338 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1338 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1339 | 1339 | |
1340 | 1340 | } |
1341 | 1341 |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * EE_Admin_Page_CPT class |
|
4 | - * |
|
5 | - * This class is for child classes that utilize core WP CPT views for add/edit pages. All you have to do is extend this class instead of the usual EE_Admin_Page class for your child. |
|
6 | - * |
|
7 | - * Please not the following caveats: |
|
8 | - * |
|
9 | - * 1. When using add_meta_box() - it must use $this->wp_page_slug as the screen_id for the page NOT $this->_current_screen->id. This is b/c there is a bug with how WP renders its custom post type pages that doesn't accept the default current_screen for metaboxes. |
|
10 | - * |
|
11 | - * 2. the same is true for any help_tabs or screen_options you want to add to custom post type views. |
|
12 | - * |
|
13 | - * 3. it is EXPECTED that $this->page_slug will be IDENTICAL to what slug/id was used when doing register_post_type(). So for instance, if you registered a "books" post type then $this->page_slug = 'espresso_books' would NOT be valid. So the correct id for the new post type would be "espresso_books". Remember, you can still use something totally different for front-end rewrite slugs in your configuration array for the register post type. |
|
14 | - * |
|
15 | - * @package Event Espresso |
|
16 | - * @subpackage includes/core/admin/EE_Admin_Page.core.php |
|
17 | - * @abstract |
|
18 | - * @author Darren Ethier |
|
19 | - * |
|
20 | - */ |
|
3 | + * EE_Admin_Page_CPT class |
|
4 | + * |
|
5 | + * This class is for child classes that utilize core WP CPT views for add/edit pages. All you have to do is extend this class instead of the usual EE_Admin_Page class for your child. |
|
6 | + * |
|
7 | + * Please not the following caveats: |
|
8 | + * |
|
9 | + * 1. When using add_meta_box() - it must use $this->wp_page_slug as the screen_id for the page NOT $this->_current_screen->id. This is b/c there is a bug with how WP renders its custom post type pages that doesn't accept the default current_screen for metaboxes. |
|
10 | + * |
|
11 | + * 2. the same is true for any help_tabs or screen_options you want to add to custom post type views. |
|
12 | + * |
|
13 | + * 3. it is EXPECTED that $this->page_slug will be IDENTICAL to what slug/id was used when doing register_post_type(). So for instance, if you registered a "books" post type then $this->page_slug = 'espresso_books' would NOT be valid. So the correct id for the new post type would be "espresso_books". Remember, you can still use something totally different for front-end rewrite slugs in your configuration array for the register post type. |
|
14 | + * |
|
15 | + * @package Event Espresso |
|
16 | + * @subpackage includes/core/admin/EE_Admin_Page.core.php |
|
17 | + * @abstract |
|
18 | + * @author Darren Ethier |
|
19 | + * |
|
20 | + */ |
|
21 | 21 | abstract class EE_Admin_Page_CPT extends EE_Admin_Page { |
22 | 22 | |
23 | 23 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | /** |
81 | - * @var EE_CPT_Base |
|
82 | - */ |
|
81 | + * @var EE_CPT_Base |
|
82 | + */ |
|
83 | 83 | protected $_cpt_model_obj = FALSE; |
84 | 84 | |
85 | 85 |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Venue extends EEM_CPT_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Venue','event_espresso'); |
|
33 | - $this->plural_item = __('Venues','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
33 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Venue_CPT'=> new EE_Primary_Table('posts', 'ID'), |
36 | 36 | 'Venue_Meta'=>new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID') |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | 'Venue_CPT'=>array( |
40 | 40 | 'VNU_ID'=>new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
41 | 41 | 'VNU_name'=>new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), |
42 | - 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false,''), |
|
43 | - 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false,''), |
|
44 | - 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE,time()), |
|
45 | - 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true,''), |
|
46 | - 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE,time()), |
|
47 | - 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false ), |
|
48 | - 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false,0), |
|
42 | + 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), |
|
43 | + 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
44 | + 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, time()), |
|
45 | + 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), |
|
46 | + 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, time()), |
|
47 | + 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), |
|
48 | + 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), |
|
49 | 49 | 'VNU_order'=>new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
50 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'),// EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
50 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'), // EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
51 | 51 | ), |
52 | 52 | 'Venue_Meta'=>array( |
53 | 53 | 'VNUM_ID'=>new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), |
54 | 54 | 'VNU_ID_fk'=>new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), |
55 | 55 | 'VNU_address'=>new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), |
56 | - 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true,''), |
|
56 | + 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), |
|
57 | 57 | 'VNU_city'=>new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), |
58 | 58 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), |
59 | 59 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), |
60 | 60 | 'VNU_zip'=>new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), |
61 | 61 | 'VNU_phone'=>new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), |
62 | - 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true,EE_INF), |
|
62 | + 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), |
|
63 | 63 | 'VNU_url'=>new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), |
64 | 64 | 'VNU_virtual_phone'=>new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), |
65 | - 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true ), |
|
66 | - 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true ), |
|
67 | - 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false ) |
|
65 | + 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), |
|
66 | + 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), |
|
67 | + 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false) |
|
68 | 68 | |
69 | 69 | )); |
70 | 70 | $this->_model_relations = array( |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | ); |
77 | 77 | $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_venues', 'VNUM_ID'); |
78 | 78 | //this model is generally available for reading |
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
80 | - parent::__construct( $timezone ); |
|
79 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
80 | + parent::__construct($timezone); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
@@ -7,32 +7,32 @@ discard block |
||
7 | 7 | * other than explicitly setting it to EE_INF. |
8 | 8 | * Makes use of constant EE_INF_IN_DB set in espresso.php, and EE_INF, which is a PHP constant definedin the ether |
9 | 9 | */ |
10 | -class EE_Infinite_Integer_Field extends EE_Model_Field_Base{ |
|
11 | - function get_wpdb_data_type(){ |
|
10 | +class EE_Infinite_Integer_Field extends EE_Model_Field_Base { |
|
11 | + function get_wpdb_data_type() { |
|
12 | 12 | return '%d'; |
13 | 13 | } |
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | - if($value_of_field_on_model_object === EE_INF){ |
|
15 | + if ($value_of_field_on_model_object === EE_INF) { |
|
16 | 16 | return EE_INF_IN_DB; |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return intval($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
22 | - if($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
22 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
23 | 23 | $value_inputted_for_field_on_model_object === EE_INF || |
24 | 24 | $value_inputted_for_field_on_model_object === "EE_INF" |
25 | - ){ |
|
25 | + ) { |
|
26 | 26 | return EE_INF; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | return intval($value_inputted_for_field_on_model_object); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
32 | 32 | $intval = intval($value_inputted_for_field_on_model_object); |
33 | - if($intval == EE_INF_IN_DB){ |
|
33 | + if ($intval == EE_INF_IN_DB) { |
|
34 | 34 | return EE_INF; |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return $intval; |
37 | 37 | } |
38 | 38 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = null ) { |
|
49 | - if( $value_on_field_to_be_outputted === EE_INF ){ |
|
50 | - switch($schema){ |
|
48 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
49 | + if ($value_on_field_to_be_outputted === EE_INF) { |
|
50 | + switch ($schema) { |
|
51 | 51 | case 'input': |
52 | 52 | return ''; |
53 | 53 | case 'symbol': |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * @return \EEH_Autoloader |
41 | 41 | */ |
42 | 42 | private function __construct() { |
43 | - if ( self::$_autoloaders === null ) { |
|
43 | + if (self::$_autoloaders === null) { |
|
44 | 44 | self::$_autoloaders = array(); |
45 | 45 | $this->_register_custom_autoloaders(); |
46 | - spl_autoload_register( array( $this, 'espresso_autoloader' ) ); |
|
46 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function instance() { |
57 | 57 | // check if class object is instantiated |
58 | - if ( ! self::$_instance instanceof EEH_Autoloader ) { |
|
58 | + if ( ! self::$_instance instanceof EEH_Autoloader) { |
|
59 | 59 | self::$_instance = new self(); |
60 | 60 | } |
61 | 61 | return self::$_instance; |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @internal param string $class_name - simple class name ie: session |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function espresso_autoloader( $class_name ) { |
|
76 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
77 | - require_once( self::$_autoloaders[ $class_name ] ); |
|
75 | + public static function espresso_autoloader($class_name) { |
|
76 | + if (isset(self::$_autoloaders[$class_name])) { |
|
77 | + require_once(self::$_autoloaders[$class_name]); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -90,26 +90,26 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | * @throws \EE_Error |
92 | 92 | */ |
93 | - public static function register_autoloader( $class_paths, $read_check = true, $debug = false ) { |
|
94 | - $class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths ); |
|
95 | - foreach ( $class_paths as $class => $path ) { |
|
93 | + public static function register_autoloader($class_paths, $read_check = true, $debug = false) { |
|
94 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
95 | + foreach ($class_paths as $class => $path) { |
|
96 | 96 | // don't give up! you gotta... |
97 | 97 | // get some class |
98 | - if ( empty( $class )) { |
|
99 | - throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path )); |
|
98 | + if (empty($class)) { |
|
99 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
100 | 100 | } |
101 | 101 | // one day you will find the path young grasshopper |
102 | - if ( empty( $path )) { |
|
103 | - throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class )); |
|
102 | + if (empty($path)) { |
|
103 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
104 | 104 | } |
105 | 105 | // is file readable ? |
106 | - if ( $read_check && ! is_readable( $path )) { |
|
107 | - throw new EE_Error ( sprintf( __( 'The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s','event_espresso' ), $class, $path )); |
|
106 | + if ($read_check && ! is_readable($path)) { |
|
107 | + throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
108 | 108 | } |
109 | - if ( ! isset( self::$_autoloaders[ $class ] )) { |
|
110 | - self::$_autoloaders[ $class ] = str_replace( array( '/', '\\' ), DS, $path ); |
|
111 | - if ( WP_DEBUG && $debug ) { |
|
112 | - EEH_Debug_Tools::printr( self::$_autoloaders[ $class ], $class, __FILE__, __LINE__ ); |
|
109 | + if ( ! isset(self::$_autoloaders[$class])) { |
|
110 | + self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path); |
|
111 | + if (WP_DEBUG && $debug) { |
|
112 | + EEH_Debug_Tools::printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @return void |
139 | 139 | */ |
140 | 140 | private function _register_custom_autoloaders() { |
141 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'interfaces' ); |
|
142 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE ); |
|
143 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_INTERFACES, true ); |
|
144 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, true ); |
|
145 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES ); |
|
146 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
141 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces'); |
|
142 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
143 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
144 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
145 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
146 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return void |
170 | 170 | */ |
171 | 171 | public static function register_line_item_display_autoloaders() { |
172 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_display' , true ); |
|
172 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | public static function register_line_item_filter_autoloaders() { |
185 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_filters' , true ); |
|
185 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return void |
196 | 196 | */ |
197 | 197 | public static function register_template_part_autoloaders() { |
198 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'template_parts', true ); |
|
198 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'template_parts', true); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -213,30 +213,30 @@ discard block |
||
213 | 213 | * @return void |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = false, $debug = false ){ |
|
216 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) { |
|
217 | 217 | // make sure last char is a / |
218 | - $folder .= $folder[strlen($folder)-1] != DS ? DS : ''; |
|
218 | + $folder .= $folder[strlen($folder) - 1] != DS ? DS : ''; |
|
219 | 219 | $class_to_filepath_map = array(); |
220 | - $exclude = array( 'index' ); |
|
220 | + $exclude = array('index'); |
|
221 | 221 | //get all the files in that folder that end in php |
222 | - $filepaths = glob( $folder.'*'); |
|
222 | + $filepaths = glob($folder.'*'); |
|
223 | 223 | |
224 | - if ( empty( $filepaths ) ) { |
|
224 | + if (empty($filepaths)) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - foreach( $filepaths as $filepath ) { |
|
229 | - if ( substr( $filepath, -4, 4 ) == '.php' ) { |
|
230 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath ); |
|
231 | - if ( ! in_array( $class_name, $exclude )) { |
|
232 | - $class_to_filepath_map [ $class_name ] = $filepath; |
|
228 | + foreach ($filepaths as $filepath) { |
|
229 | + if (substr($filepath, -4, 4) == '.php') { |
|
230 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
231 | + if ( ! in_array($class_name, $exclude)) { |
|
232 | + $class_to_filepath_map [$class_name] = $filepath; |
|
233 | 233 | } |
234 | - } else if ( $recursive ) { |
|
235 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive ); |
|
234 | + } else if ($recursive) { |
|
235 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
239 | - self::register_autoloader( $class_to_filepath_map, false, $debug ); |
|
239 | + self::register_autoloader($class_to_filepath_map, false, $debug); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * ------------------------------------------------------------------------ |
11 | 11 | */ |
12 | -class EEH_URL{ |
|
12 | +class EEH_URL { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * _add_query_arg |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public static function add_query_args_and_nonce( $args = array(), $url = '', $exclude_nonce = false ) { |
|
25 | - if ( empty( $url ) ) { |
|
26 | - $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' ); |
|
27 | - $dev_msg = $user_msg . "\n" . sprintf( |
|
28 | - __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso' ), |
|
24 | + public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) { |
|
25 | + if (empty($url)) { |
|
26 | + $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso'); |
|
27 | + $dev_msg = $user_msg."\n".sprintf( |
|
28 | + __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'), |
|
29 | 29 | __CLASS__ |
30 | 30 | ); |
31 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
31 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
32 | 32 | } |
33 | 33 | // check that an action exists and add nonce |
34 | - if ( ! $exclude_nonce ) { |
|
35 | - if ( isset( $args['action'] ) && ! empty( $args['action'] ) ) { |
|
36 | - $args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' ) ) ); |
|
34 | + if ( ! $exclude_nonce) { |
|
35 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
36 | + $args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce'))); |
|
37 | 37 | } else { |
38 | - $args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' ) ) ); |
|
38 | + $args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce'))); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | //finally, let's always add a return address (if present) :) |
43 | - $args = ! empty( $_REQUEST['action'] ) ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) : $args; |
|
43 | + $args = ! empty($_REQUEST['action']) ? array_merge($args, array('return' => $_REQUEST['action'])) : $args; |
|
44 | 44 | |
45 | - return add_query_arg( $args, $url ); |
|
45 | + return add_query_arg($args, $url); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly |
56 | 56 | * @return boolean |
57 | 57 | */ |
58 | - public static function remote_file_exists( $url, $args = array() ){ |
|
59 | - $results = wp_remote_request($url,array_merge( array( |
|
58 | + public static function remote_file_exists($url, $args = array()) { |
|
59 | + $results = wp_remote_request($url, array_merge(array( |
|
60 | 60 | 'method'=>'GET', |
61 | 61 | 'redirection'=>1 |
62 | - ), $args ) ); |
|
63 | - if( ! $results instanceof WP_Error && |
|
62 | + ), $args)); |
|
63 | + if ( ! $results instanceof WP_Error && |
|
64 | 64 | isset($results['response']) && |
65 | 65 | isset($results['response']['code']) && |
66 | - $results['response']['code'] == '200'){ |
|
66 | + $results['response']['code'] == '200') { |
|
67 | 67 | return true; |
68 | - }else{ |
|
68 | + } else { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | } |
@@ -81,29 +81,29 @@ discard block |
||
81 | 81 | * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) { |
|
84 | + public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) { |
|
85 | 85 | // break apart incoming URL |
86 | - $url_bits = parse_url( $url ); |
|
86 | + $url_bits = parse_url($url); |
|
87 | 87 | // HTTP or HTTPS ? |
88 | - $scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://'; |
|
88 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://'; |
|
89 | 89 | // domain |
90 | - $host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : ''; |
|
90 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
91 | 91 | // if only the base URL is requested, then return that now |
92 | - if ( $base_url_only ) { |
|
93 | - return $scheme . $host; |
|
92 | + if ($base_url_only) { |
|
93 | + return $scheme.$host; |
|
94 | 94 | } |
95 | - $port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : ''; |
|
96 | - $user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : ''; |
|
97 | - $pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : ''; |
|
98 | - $pass = ( $user || $pass ) ? $pass . '@' : ''; |
|
99 | - $path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : ''; |
|
95 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
96 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
97 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
98 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
99 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
100 | 100 | // if the query string is not required, then return what we have so far |
101 | - if ( $remove_query ) { |
|
102 | - return $scheme . $user . $pass . $host . $port . $path; |
|
101 | + if ($remove_query) { |
|
102 | + return $scheme.$user.$pass.$host.$port.$path; |
|
103 | 103 | } |
104 | - $query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : ''; |
|
105 | - $fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : ''; |
|
106 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
104 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
105 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
106 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string |
117 | 117 | * @return string|array |
118 | 118 | */ |
119 | - public static function get_query_string( $url = '', $as_array = TRUE ) { |
|
119 | + public static function get_query_string($url = '', $as_array = TRUE) { |
|
120 | 120 | // break apart incoming URL |
121 | - $url_bits = parse_url( $url ); |
|
121 | + $url_bits = parse_url($url); |
|
122 | 122 | // grab query string from URL |
123 | - $query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : ''; |
|
123 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
124 | 124 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
125 | - if ( ! $as_array ) { |
|
125 | + if ( ! $as_array) { |
|
126 | 126 | return $query; |
127 | 127 | } |
128 | 128 | // if no query string exists then just return an empty array now |
129 | - if ( empty( $query )) { |
|
129 | + if (empty($query)) { |
|
130 | 130 | return array(); |
131 | 131 | } |
132 | 132 | // empty array to hold results |
133 | 133 | $query_params = array(); |
134 | 134 | // now break apart the query string into separate params |
135 | - $query = explode( '&', $query ); |
|
135 | + $query = explode('&', $query); |
|
136 | 136 | // loop thru our query params |
137 | - foreach ( $query as $query_args ) { |
|
137 | + foreach ($query as $query_args) { |
|
138 | 138 | // break apart the key value pairs |
139 | - $query_args = explode( '=', $query_args ); |
|
139 | + $query_args = explode('=', $query_args); |
|
140 | 140 | // and add to our results array |
141 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
141 | + $query_params[$query_args[0]] = $query_args[1]; |
|
142 | 142 | } |
143 | 143 | return $query_params; |
144 | 144 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * prevent_prefetching |
150 | 150 | * @return void |
151 | 151 | */ |
152 | - public static function prevent_prefetching(){ |
|
152 | + public static function prevent_prefetching() { |
|
153 | 153 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
154 | 154 | remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
155 | 155 | } |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @param string $prefix Use this to prefix the string with something. |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public static function generate_unique_token( $prefix = '' ) { |
|
168 | - $token = md5( uniqid() . mt_rand() ); |
|
169 | - return $prefix ? $prefix . '_' . $token : $token; |
|
167 | + public static function generate_unique_token($prefix = '') { |
|
168 | + $token = md5(uniqid().mt_rand()); |
|
169 | + return $prefix ? $prefix.'_'.$token : $token; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * add_nocache_headers |
176 | 176 | * @return void |
177 | 177 | */ |
178 | - public static function add_nocache_headers(){ |
|
178 | + public static function add_nocache_headers() { |
|
179 | 179 | // add no cache headers |
180 | 180 | // add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 ); |
181 | 181 | // plus a little extra for nginx |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | * @param string $server_variable |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public static function filter_input_server_url( $server_variable = 'REQUEST_URI' ){ |
|
195 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') { |
|
196 | 196 | $URL = ''; |
197 | 197 | $server_variables = array( |
198 | 198 | 'REQUEST_URI' => 1, |
199 | 199 | 'HTTP_HOST' => 1, |
200 | 200 | 'PHP_SELF' => 1, |
201 | 201 | ); |
202 | - $server_variable = strtoupper( $server_variable ); |
|
202 | + $server_variable = strtoupper($server_variable); |
|
203 | 203 | // whitelist INPUT_SERVER var |
204 | - if ( isset( $server_variables[ $server_variable ] ) ) { |
|
205 | - $URL = filter_input( INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE ); |
|
206 | - if ( empty( $URL ) ) { |
|
207 | - $URL = esc_url( $_SERVER[ $server_variable ] ); |
|
204 | + if (isset($server_variables[$server_variable])) { |
|
205 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
206 | + if (empty($URL)) { |
|
207 | + $URL = esc_url($_SERVER[$server_variable]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | return $URL; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_CVV_Input extends EE_Text_Input{ |
|
11 | +class EE_CVV_Input extends EE_Text_Input { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param array $input_settings { |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function __construct($input_settings = array()) { |
19 | 19 | $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
20 | - $this->_add_validation_strategy( new EE_Int_Validation_Strategy(isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
20 | + $this->_add_validation_strategy(new EE_Int_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
21 | 21 | parent::__construct($input_settings); |
22 | - if( |
|
23 | - ! isset( $input_settings[ 'include_whats_this_link' ] ) || |
|
24 | - ( isset( $input_settings[ 'include_whats_this_link' ] ) && |
|
25 | - $input_settings[ 'include_whats_this_link' ] == true ) ) { |
|
22 | + if ( |
|
23 | + ! isset($input_settings['include_whats_this_link']) || |
|
24 | + (isset($input_settings['include_whats_this_link']) && |
|
25 | + $input_settings['include_whats_this_link'] == true) ) { |
|
26 | 26 | $this->_html_label_text = sprintf( |
27 | 27 | _x( |
28 | 28 | '%1$s %2$s(What\'s this?)%3$s', |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * needed helpers and models (see all the methods starting with "set_", eg seg_line_item_helper which should be passed an object |
31 | 31 | * which implements EEHI_Line_Item_Helper; etc). |
32 | 32 | */ |
33 | -abstract class EE_Gateway{ |
|
33 | +abstract class EE_Gateway { |
|
34 | 34 | /** |
35 | 35 | * a constant used as a possible value for $_currencies_supported to indicate |
36 | 36 | * that ALL currencies are supported by this gateway |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @return EE_Gateway |
110 | 110 | */ |
111 | - public function __construct(){ |
|
111 | + public function __construct() { |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * beginning again) |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function __sleep(){ |
|
123 | + public function __sleep() { |
|
124 | 124 | $properties = get_object_vars($this); |
125 | - unset( $properties[ '_pay_model' ] ); |
|
126 | - unset( $properties[ '_pay_log' ] ); |
|
125 | + unset($properties['_pay_model']); |
|
126 | + unset($properties['_pay_log']); |
|
127 | 127 | return array_keys($properties); |
128 | 128 | } |
129 | 129 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * see $_supports_sending_refunds |
132 | 132 | * @return boolean |
133 | 133 | */ |
134 | - public function supports_sending_refunds(){ |
|
134 | + public function supports_sending_refunds() { |
|
135 | 135 | return $this->_supports_sending_refunds; |
136 | 136 | } |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * see $_supports_receiving_refunds |
140 | 140 | * @return boolean |
141 | 141 | */ |
142 | - public function supports_receiving_refunds(){ |
|
142 | + public function supports_receiving_refunds() { |
|
143 | 143 | return $this->_supports_receiving_refunds; |
144 | 144 | } |
145 | 145 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return EE_Payment for the refund |
155 | 155 | * @throws EE_Error |
156 | 156 | */ |
157 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
157 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
158 | 158 | return NULL; |
159 | 159 | } |
160 | 160 | |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * etc |
166 | 166 | * @param array $settings_array |
167 | 167 | */ |
168 | - public function set_settings($settings_array){ |
|
169 | - foreach($settings_array as $name => $value){ |
|
168 | + public function set_settings($settings_array) { |
|
169 | + foreach ($settings_array as $name => $value) { |
|
170 | 170 | $property_name = "_".$name; |
171 | 171 | $this->$property_name = $value; |
172 | 172 | } |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * See this class description |
176 | 176 | * @param EEMI_Payment $payment_model |
177 | 177 | */ |
178 | - public function set_payment_model($payment_model){ |
|
178 | + public function set_payment_model($payment_model) { |
|
179 | 179 | $this->_pay_model = $payment_model; |
180 | 180 | } |
181 | 181 | /** |
182 | 182 | * See this class description |
183 | 183 | * @param EEMI_Payment_Log $payment_log_model |
184 | 184 | */ |
185 | - public function set_payment_log($payment_log_model){ |
|
185 | + public function set_payment_log($payment_log_model) { |
|
186 | 186 | $this->_pay_log = $payment_log_model; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * See this class description |
191 | 191 | * @param EEHI_Template $template_helper |
192 | 192 | */ |
193 | - public function set_template_helper($template_helper){ |
|
193 | + public function set_template_helper($template_helper) { |
|
194 | 194 | $this->_template = $template_helper; |
195 | 195 | } |
196 | 196 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * See this class description |
199 | 199 | * @param EEHI_Line_Item $line_item_helper |
200 | 200 | */ |
201 | - public function set_line_item_helper( $line_item_helper ){ |
|
201 | + public function set_line_item_helper($line_item_helper) { |
|
202 | 202 | $this->_line_item = $line_item_helper; |
203 | 203 | } |
204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * See this class description |
207 | 207 | * @param EEHI_Money $money_helper |
208 | 208 | */ |
209 | - public function set_money_helper( $money_helper ){ |
|
209 | + public function set_money_helper($money_helper) { |
|
210 | 210 | $this->_money = $money_helper; |
211 | 211 | } |
212 | 212 | |
@@ -215,23 +215,23 @@ discard block |
||
215 | 215 | * @param $message |
216 | 216 | * @param $payment |
217 | 217 | */ |
218 | - public function log($message,$payment){ |
|
219 | - if($payment instanceof EEI_Payment){ |
|
220 | - $type='Payment'; |
|
218 | + public function log($message, $payment) { |
|
219 | + if ($payment instanceof EEI_Payment) { |
|
220 | + $type = 'Payment'; |
|
221 | 221 | $id = $payment->ID(); |
222 | - }else{ |
|
222 | + } else { |
|
223 | 223 | $type = 'Payment_Method'; |
224 | 224 | $id = $this->_ID; |
225 | 225 | } |
226 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
226 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
227 | 227 | } |
228 | 228 | /** |
229 | 229 | * Formats the amount so it can generally be sent to gateways |
230 | 230 | * @param float $amount |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - public function format_currency($amount){ |
|
234 | - return number_format( $amount, 2, '.', '' ); |
|
233 | + public function format_currency($amount) { |
|
234 | + return number_format($amount, 2, '.', ''); |
|
235 | 235 | // return $this->_template->format_currency($amount, true); |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
241 | 241 | * @return mixed array or string |
242 | 242 | */ |
243 | - public function currencies_supported(){ |
|
243 | + public function currencies_supported() { |
|
244 | 244 | return $this->_currencies_supported; |
245 | 245 | } |
246 | 246 | |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | * @param EE_Transaction $transaction |
253 | 253 | * @return float |
254 | 254 | */ |
255 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
255 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
256 | 256 | $total_line_item = $transaction->total_line_item(); |
257 | 257 | $total = 0; |
258 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
259 | - $total += max( $item_line_item->total(), 0 ); |
|
258 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
259 | + $total += max($item_line_item->total(), 0); |
|
260 | 260 | } |
261 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
262 | - $total += max( $tax_line_item->total(), 0 ); |
|
261 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
262 | + $total += max($tax_line_item->total(), 0); |
|
263 | 263 | } |
264 | 264 | return $total; |
265 | 265 | } |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * @param EEI_Payment $payment |
271 | 271 | * @return boolean |
272 | 272 | */ |
273 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
273 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
274 | 274 | return $this->_money->compare_floats( |
275 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
275 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
276 | 276 | $payment->transaction()->total() ) && |
277 | 277 | $this->_money->compare_floats( |
278 | 278 | $payment->amount(), |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param EE_Payment $payment |
291 | 291 | * @return void |
292 | 292 | */ |
293 | - public function update_txn_based_on_payment( $payment ){ |
|
293 | + public function update_txn_based_on_payment($payment) { |
|
294 | 294 | //maybe update the transaction or line items or registrations |
295 | 295 | //but most gateways don't need to do this, because they only update the payment |
296 | 296 | } |