@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * |
15 | 15 | */ |
16 | 16 | class EE_Return_None_Where_Conditions extends EE_Default_Where_Conditions { |
17 | - protected function _get_default_where_conditions(){ |
|
18 | - if( $this->_model->has_primary_key_field() ) { |
|
19 | - return array( $this->_model->primary_key_name() => array('<', 0 ) ); |
|
20 | - }else{ |
|
21 | - $fk_field = $this->_model->get_a_field_of_type( 'EE_Foreign_Key_Field_Base' ); |
|
22 | - return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) ); |
|
17 | + protected function _get_default_where_conditions() { |
|
18 | + if ($this->_model->has_primary_key_field()) { |
|
19 | + return array($this->_model->primary_key_name() => array('<', 0)); |
|
20 | + } else { |
|
21 | + $fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base'); |
|
22 | + return array('AND*impossible' => array($fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL')); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | protected function _get_default_where_conditions(){ |
18 | 18 | if( $this->_model->has_primary_key_field() ) { |
19 | 19 | return array( $this->_model->primary_key_name() => array('<', 0 ) ); |
20 | - }else{ |
|
20 | + } else{ |
|
21 | 21 | $fk_field = $this->_model->get_a_field_of_type( 'EE_Foreign_Key_Field_Base' ); |
22 | 22 | return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) ); |
23 | 23 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
34 | 34 | if($field){ |
35 | 35 | return $field->get_name(); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
38 | 38 | } |
39 | 39 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @author Mike Nelson |
14 | 14 | * @since 4.6.0 |
15 | 15 | */ |
16 | -class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{ |
|
16 | +class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions { |
|
17 | 17 | /** |
18 | 18 | * Strategy for setting default soft delete where conditions. This strategy will find |
19 | 19 | * the field of type 'EE_Trashed_Flag_Field', and add a condition that it be FALSE on all queries involving |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | * Eg, |
23 | 23 | * |
24 | 24 | */ |
25 | - function __construct(){} |
|
25 | + function __construct() {} |
|
26 | 26 | /** |
27 | 27 | * Gets the where default where conditions for a custom post type model |
28 | 28 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
29 | 29 | */ |
30 | - protected function _get_default_where_conditions(){ |
|
30 | + protected function _get_default_where_conditions() { |
|
31 | 31 | $trashed_field_name = $this->deleted_field_name(); |
32 | 32 | return array( |
33 | 33 | $trashed_field_name => false |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * @return string |
40 | 40 | * @throws EE_Error |
41 | 41 | */ |
42 | - private function deleted_field_name(){ |
|
42 | + private function deleted_field_name() { |
|
43 | 43 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
44 | - if($field){ |
|
44 | + if ($field) { |
|
45 | 45 | return $field->get_name(); |
46 | - }else{ |
|
47 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
46 | + } else { |
|
47 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -61,10 +61,10 @@ |
||
61 | 61 | $first_item = reset($arr); |
62 | 62 | if(is_array($first_item)){ |
63 | 63 | return true;//yep, there's at least 2 levels to this array |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | return false;//nope, only 1 level |
66 | 66 | } |
67 | - }else{ |
|
67 | + } else{ |
|
68 | 68 | return false;//its not an array at all! |
69 | 69 | } |
70 | 70 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
3 | 3 | |
4 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
4 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EE_Array |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $array2 an array of objects |
27 | 27 | * @return array an array of objects found in array 1 that aren't found in array 2. |
28 | 28 | */ |
29 | - public static function object_array_diff( $array1, $array2 ) { |
|
30 | - return array_udiff( $array1, $array2, array('self', '_compare_objects' )); |
|
29 | + public static function object_array_diff($array1, $array2) { |
|
30 | + return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param array $arr |
36 | 36 | * @return boolean |
37 | 37 | */ |
38 | - public static function is_associative_array($arr){ |
|
38 | + public static function is_associative_array($arr) { |
|
39 | 39 | return array_keys($arr) !== range(0, count($arr) - 1); |
40 | 40 | } |
41 | 41 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param array $arr |
46 | 46 | * @return mixed what ever is in the array |
47 | 47 | */ |
48 | - public static function get_one_item_from_array($arr){ |
|
48 | + public static function get_one_item_from_array($arr) { |
|
49 | 49 | $item = end($arr); |
50 | 50 | reset($arr); |
51 | 51 | return $item; |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @param mixed $arr |
57 | 57 | * @return boolean |
58 | 58 | */ |
59 | - public static function is_multi_dimensional_array($arr){ |
|
60 | - if(is_array($arr)){ |
|
59 | + public static function is_multi_dimensional_array($arr) { |
|
60 | + if (is_array($arr)) { |
|
61 | 61 | $first_item = reset($arr); |
62 | - if(is_array($first_item)){ |
|
63 | - return true;//yep, there's at least 2 levels to this array |
|
64 | - }else{ |
|
65 | - return false;//nope, only 1 level |
|
62 | + if (is_array($first_item)) { |
|
63 | + return true; //yep, there's at least 2 levels to this array |
|
64 | + } else { |
|
65 | + return false; //nope, only 1 level |
|
66 | 66 | } |
67 | - }else{ |
|
68 | - return false;//its not an array at all! |
|
67 | + } else { |
|
68 | + return false; //its not an array at all! |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param mixed $default |
77 | 77 | * @return mixed |
78 | 78 | */ |
79 | - public static function is_set( $arr, $index, $default ) { |
|
80 | - return isset( $arr[ $index ] ) ? $arr[ $index ] : $default; |
|
79 | + public static function is_set($arr, $index, $default) { |
|
80 | + return isset($arr[$index]) ? $arr[$index] : $default; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @param mixed $value usually a string, but could be an array or object |
86 | 86 | * @return mixed the UNserialized data |
87 | 87 | */ |
88 | - public static function maybe_unserialize( $value ) { |
|
88 | + public static function maybe_unserialize($value) { |
|
89 | 89 | $data = maybe_unserialize($value); |
90 | 90 | //it's possible that this still has serialized data if its the session. WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically. |
91 | 91 | $token = 'C'; |
92 | 92 | $data = is_string($data) ? trim($data) : $data; |
93 | - if ( is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match( "/^{$token}:[0-9]+:/s", $data ) ) { |
|
93 | + if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
94 | 94 | return unserialize($data); |
95 | 95 | } else { |
96 | 96 | return $data; |
@@ -109,30 +109,30 @@ discard block |
||
109 | 109 | * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public static function insert_into_array( $target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true ) { |
|
112 | + public static function insert_into_array($target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true) { |
|
113 | 113 | // ensure incoming arrays are actually arrays |
114 | - $target_array = (array)$target_array; |
|
115 | - $array_to_insert = (array)$array_to_insert; |
|
114 | + $target_array = (array) $target_array; |
|
115 | + $array_to_insert = (array) $array_to_insert; |
|
116 | 116 | // if no offset key was supplied |
117 | - if ( empty( $offset )) { |
|
117 | + if (empty($offset)) { |
|
118 | 118 | // use start or end of $target_array based on whether we are adding before or not |
119 | - $offset = $add_before ? 0 : count( $target_array ); |
|
119 | + $offset = $add_before ? 0 : count($target_array); |
|
120 | 120 | } |
121 | 121 | // if offset key is a string, then find the corresponding numeric location for that element |
122 | - $offset = is_int( $offset ) ? $offset : array_search( $offset, array_keys( $target_array ) ); |
|
122 | + $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array)); |
|
123 | 123 | // add one to the offset if adding after |
124 | 124 | $offset = $add_before ? $offset : $offset + 1; |
125 | 125 | // but ensure offset does not exceed the length of the array |
126 | - $offset = $offset > count( $target_array ) ? count( $target_array ) : $offset; |
|
126 | + $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
127 | 127 | // reindex array ??? |
128 | - if ( $preserve_keys ) { |
|
128 | + if ($preserve_keys) { |
|
129 | 129 | // take a slice of the target array from the beginning till the offset, |
130 | 130 | // then add the new data |
131 | 131 | // then add another slice that starts at the offset and goes till the end |
132 | - return array_slice( $target_array, 0, $offset, true ) + $array_to_insert + array_slice( $target_array, $offset, null, true ); |
|
132 | + return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice($target_array, $offset, null, true); |
|
133 | 133 | } else { |
134 | 134 | // since we don't want to preserve keys, we can use array_splice |
135 | - array_splice( $target_array, $offset, 0, $array_to_insert ); |
|
135 | + array_splice($target_array, $offset, 0, $array_to_insert); |
|
136 | 136 | return $target_array; |
137 | 137 | } |
138 | 138 | } |
@@ -1,6 +1,7 @@ |
||
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 | 6 | /** |
6 | 7 | * EEH_Autoloader |
@@ -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 |
@@ -25,10 +25,10 @@ |
||
25 | 25 | private static $_instance = null; |
26 | 26 | |
27 | 27 | /** |
28 | - * $_autoloaders |
|
29 | - * @var array $_autoloaders |
|
30 | - * @access private |
|
31 | - */ |
|
28 | + * $_autoloaders |
|
29 | + * @var array $_autoloaders |
|
30 | + * @access private |
|
31 | + */ |
|
32 | 32 | private static $_autoloaders; |
33 | 33 | |
34 | 34 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @ override magic methods |
34 | 34 | * @ return void |
35 | 35 | */ |
36 | - public function __set($a,$b) { return FALSE; } |
|
36 | + public function __set($a, $b) { return FALSE; } |
|
37 | 37 | public function __get($a) { return FALSE; } |
38 | 38 | public function __isset($a) { return FALSE; } |
39 | 39 | public function __unset($a) { return FALSE; } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -799,7 +799,6 @@ |
||
799 | 799 | |
800 | 800 | |
801 | 801 | /** |
802 | - |
|
803 | 802 | * |
804 | 803 | * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
805 | 804 | * very next day then this method will return true. |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -264,10 +265,11 @@ discard block |
||
264 | 265 | // Set TZ so localtime works. |
265 | 266 | date_default_timezone_set($timezone_string); |
266 | 267 | $now = localtime(time(), true); |
267 | - if ($now['tm_isdst']) |
|
268 | - _e('This timezone is currently in daylight saving time.'); |
|
269 | - else |
|
270 | - _e('This timezone is currently in standard time.'); |
|
268 | + if ($now['tm_isdst']) { |
|
269 | + _e('This timezone is currently in daylight saving time.'); |
|
270 | + } else { |
|
271 | + _e('This timezone is currently in standard time.'); |
|
272 | + } |
|
271 | 273 | ?> |
272 | 274 | <br /> |
273 | 275 | <?php |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | * @throws \EE_Error |
55 | 55 | */ |
56 | - public static function get_valid_timezone_string( $timezone_string = '' ) { |
|
56 | + public static function get_valid_timezone_string($timezone_string = '') { |
|
57 | 57 | // if passed a value, then use that, else get WP option |
58 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
58 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
59 | 59 | // value from above exists, use that, else get timezone string from gmt_offset |
60 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | - EEH_DTT_Helper::validate_timezone( $timezone_string ); |
|
60 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
62 | 62 | return $timezone_string; |
63 | 63 | } |
64 | 64 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @return bool |
75 | 75 | * @throws \EE_Error |
76 | 76 | */ |
77 | - public static function validate_timezone( $timezone_string, $throw_error = true ) { |
|
77 | + public static function validate_timezone($timezone_string, $throw_error = true) { |
|
78 | 78 | // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
79 | 79 | try { |
80 | - new DateTimeZone( $timezone_string ); |
|
81 | - } catch ( Exception $e ) { |
|
80 | + new DateTimeZone($timezone_string); |
|
81 | + } catch (Exception $e) { |
|
82 | 82 | // sometimes we take exception to exceptions |
83 | - if ( ! $throw_error ) { |
|
83 | + if ( ! $throw_error) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | throw new EE_Error( |
87 | 87 | sprintf( |
88 | - __( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
88 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
89 | 89 | $timezone_string, |
90 | 90 | '<a href="http://www.php.net/manual/en/timezones.php">', |
91 | 91 | '</a>' |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param string $gmt_offset |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) { |
|
107 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') { |
|
108 | 108 | $timezone_string = 'UTC'; |
109 | - $gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' ); |
|
110 | - if ( $gmt_offset !== '' ) { |
|
109 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
110 | + if ($gmt_offset !== '') { |
|
111 | 111 | // convert GMT offset to seconds |
112 | 112 | $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
113 | 113 | // account for WP offsets that aren't valid UTC |
114 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset ); |
|
114 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
115 | 115 | // although we don't know the TZ abbreviation, we know the UTC offset |
116 | - $timezone_string = timezone_name_from_abbr( null, $gmt_offset ); |
|
116 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
117 | 117 | } |
118 | 118 | // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
119 | - $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset ); |
|
119 | + $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
120 | 120 | return $timezone_string; |
121 | 121 | } |
122 | 122 | |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | * @param int $gmt_offset |
130 | 130 | * @return int |
131 | 131 | */ |
132 | - public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) { |
|
132 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) { |
|
133 | 133 | //make sure $gmt_offset is int |
134 | 134 | $gmt_offset = (int) $gmt_offset; |
135 | - switch ( $gmt_offset ) { |
|
135 | + switch ($gmt_offset) { |
|
136 | 136 | |
137 | 137 | // case -30600 : |
138 | 138 | // $gmt_offset = -28800; |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @return string |
185 | 185 | * @throws \EE_Error |
186 | 186 | */ |
187 | - public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) { |
|
187 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) { |
|
188 | 188 | $abbreviations = timezone_abbreviations_list(); |
189 | - foreach ( $abbreviations as $abbreviation ) { |
|
190 | - foreach ( $abbreviation as $city ) { |
|
191 | - if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) { |
|
189 | + foreach ($abbreviations as $abbreviation) { |
|
190 | + foreach ($abbreviation as $city) { |
|
191 | + if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) { |
|
192 | 192 | // check if the timezone is valid but don't throw any errors if it isn't |
193 | - if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) { |
|
193 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
194 | 194 | return $city['timezone_id']; |
195 | 195 | } |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | throw new EE_Error( |
200 | 200 | sprintf( |
201 | - __( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
201 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
202 | 202 | $gmt_offset, |
203 | 203 | '<a href="http://www.php.net/manual/en/timezones.php">', |
204 | 204 | '</a>' |
@@ -212,23 +212,23 @@ discard block |
||
212 | 212 | * @access public |
213 | 213 | * @param string $timezone_string |
214 | 214 | */ |
215 | - public static function timezone_select_input( $timezone_string = '' ) { |
|
215 | + public static function timezone_select_input($timezone_string = '') { |
|
216 | 216 | // get WP date time format |
217 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
217 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
218 | 218 | // if passed a value, then use that, else get WP option |
219 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
219 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
220 | 220 | // check if the timezone is valid but don't throw any errors if it isn't |
221 | - $timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false ); |
|
221 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
222 | 222 | $gmt_offset = get_option('gmt_offset'); |
223 | 223 | |
224 | 224 | $check_zone_info = true; |
225 | - if ( empty( $timezone_string )) { |
|
225 | + if (empty($timezone_string)) { |
|
226 | 226 | // Create a UTC+- zone if no timezone string exists |
227 | 227 | $check_zone_info = false; |
228 | - if ( $gmt_offset > 0 ) { |
|
229 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
230 | - } elseif ( $gmt_offset < 0 ) { |
|
231 | - $timezone_string = 'UTC' . $gmt_offset; |
|
228 | + if ($gmt_offset > 0) { |
|
229 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
230 | + } elseif ($gmt_offset < 0) { |
|
231 | + $timezone_string = 'UTC'.$gmt_offset; |
|
232 | 232 | } else { |
233 | 233 | $timezone_string = 'UTC'; |
234 | 234 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | __('%1$sUTC%2$s time is %3$s'), |
251 | 251 | '<abbr title="Coordinated Universal Time">', |
252 | 252 | '</abbr>', |
253 | - '<code>' . date_i18n( $datetime_format , false, 'gmt') . '</code>' |
|
253 | + '<code>'.date_i18n($datetime_format, false, 'gmt').'</code>' |
|
254 | 254 | ); |
255 | 255 | ?></span> |
256 | - <?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?> |
|
257 | - <br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span> |
|
256 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
257 | + <br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
258 | 258 | <?php endif; ?> |
259 | 259 | |
260 | 260 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -286,10 +286,9 @@ discard block |
||
286 | 286 | |
287 | 287 | if ($found) { |
288 | 288 | $message = $tr['isdst'] ? |
289 | - __(' Daylight saving time begins on: %s.' ) : |
|
290 | - __(' Standard time begins on: %s.'); |
|
289 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
291 | 290 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
292 | - printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' ); |
|
291 | + printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
293 | 292 | } else { |
294 | 293 | _e('This timezone does not observe daylight saving time.'); |
295 | 294 | } |
@@ -319,14 +318,14 @@ discard block |
||
319 | 318 | * |
320 | 319 | * @return int $unix_timestamp with the offset applied for the given timezone. |
321 | 320 | */ |
322 | - public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) { |
|
321 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') { |
|
323 | 322 | $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
324 | - $timezone_string = self::get_valid_timezone_string( $timezone_string ); |
|
325 | - $TimeZone = new DateTimeZone( $timezone_string ); |
|
323 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
324 | + $TimeZone = new DateTimeZone($timezone_string); |
|
326 | 325 | |
327 | - $DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone ); |
|
328 | - $offset = timezone_offset_get( $TimeZone, $DateTime ); |
|
329 | - return (int)$DateTime->format( 'U' ) + (int)$offset; |
|
326 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
327 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
328 | + return (int) $DateTime->format('U') + (int) $offset; |
|
330 | 329 | } |
331 | 330 | |
332 | 331 | |
@@ -341,17 +340,17 @@ discard block |
||
341 | 340 | * @param string $datetime_field_name the datetime fieldname to be manipulated |
342 | 341 | * @return EE_Base_Class |
343 | 342 | */ |
344 | - protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) { |
|
343 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) { |
|
345 | 344 | // grab current datetime format |
346 | 345 | $current_format = $obj->get_format(); |
347 | 346 | // set new full timestamp format |
348 | - $obj->set_date_format( EE_Datetime_Field::mysql_date_format ); |
|
349 | - $obj->set_time_format( EE_Datetime_Field::mysql_time_format ); |
|
347 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
348 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
350 | 349 | // set the new date value using a full timestamp format so that no data is lost |
351 | - $obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) ); |
|
350 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
352 | 351 | // reset datetime formats |
353 | - $obj->set_date_format( $current_format[0] ); |
|
354 | - $obj->set_time_format( $current_format[1] ); |
|
352 | + $obj->set_date_format($current_format[0]); |
|
353 | + $obj->set_time_format($current_format[1]); |
|
355 | 354 | return $obj; |
356 | 355 | } |
357 | 356 | |
@@ -368,11 +367,11 @@ discard block |
||
368 | 367 | * @param integer $value what you want to increment the time by |
369 | 368 | * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it (chaining) |
370 | 369 | */ |
371 | - public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
370 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
372 | 371 | //get the raw UTC date. |
373 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
374 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value ); |
|
375 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
372 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
373 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
374 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
376 | 375 | } |
377 | 376 | |
378 | 377 | |
@@ -387,11 +386,11 @@ discard block |
||
387 | 386 | * @param int $value |
388 | 387 | * @return \EE_Base_Class |
389 | 388 | */ |
390 | - public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
389 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
391 | 390 | //get the raw UTC date |
392 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
393 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' ); |
|
394 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
391 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
392 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
393 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
395 | 394 | } |
396 | 395 | |
397 | 396 | |
@@ -404,44 +403,44 @@ discard block |
||
404 | 403 | * @return \DateTime return whatever type came in. |
405 | 404 | * @throws \EE_Error |
406 | 405 | */ |
407 | - protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) { |
|
408 | - if ( ! $DateTime instanceof DateTime ) { |
|
406 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') { |
|
407 | + if ( ! $DateTime instanceof DateTime) { |
|
409 | 408 | throw new EE_Error( |
410 | 409 | sprintf( |
411 | - __( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ), |
|
412 | - print_r( $DateTime, true ) |
|
410 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
411 | + print_r($DateTime, true) |
|
413 | 412 | ) |
414 | 413 | ); |
415 | 414 | } |
416 | - switch ( $period ) { |
|
415 | + switch ($period) { |
|
417 | 416 | case 'years' : |
418 | - $value = 'P' . $value . 'Y'; |
|
417 | + $value = 'P'.$value.'Y'; |
|
419 | 418 | break; |
420 | 419 | case 'months' : |
421 | - $value = 'P' . $value . 'M'; |
|
420 | + $value = 'P'.$value.'M'; |
|
422 | 421 | break; |
423 | 422 | case 'weeks' : |
424 | - $value = 'P' . $value . 'W'; |
|
423 | + $value = 'P'.$value.'W'; |
|
425 | 424 | break; |
426 | 425 | case 'days' : |
427 | - $value = 'P' . $value . 'D'; |
|
426 | + $value = 'P'.$value.'D'; |
|
428 | 427 | break; |
429 | 428 | case 'hours' : |
430 | - $value = 'PT' . $value . 'H'; |
|
429 | + $value = 'PT'.$value.'H'; |
|
431 | 430 | break; |
432 | 431 | case 'minutes' : |
433 | - $value = 'PT' . $value . 'M'; |
|
432 | + $value = 'PT'.$value.'M'; |
|
434 | 433 | break; |
435 | 434 | case 'seconds' : |
436 | - $value = 'PT' . $value . 'S'; |
|
435 | + $value = 'PT'.$value.'S'; |
|
437 | 436 | break; |
438 | 437 | } |
439 | - switch ( $operand ) { |
|
438 | + switch ($operand) { |
|
440 | 439 | case '+': |
441 | - $DateTime->add( new DateInterval( $value ) ); |
|
440 | + $DateTime->add(new DateInterval($value)); |
|
442 | 441 | break; |
443 | 442 | case '-': |
444 | - $DateTime->sub( new DateInterval( $value ) ); |
|
443 | + $DateTime->sub(new DateInterval($value)); |
|
445 | 444 | break; |
446 | 445 | } |
447 | 446 | return $DateTime; |
@@ -457,16 +456,16 @@ discard block |
||
457 | 456 | * @return \DateTime return whatever type came in. |
458 | 457 | * @throws \EE_Error |
459 | 458 | */ |
460 | - protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
461 | - if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) { |
|
459 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
460 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
462 | 461 | throw new EE_Error( |
463 | 462 | sprintf( |
464 | - __( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ), |
|
465 | - print_r( $timestamp, true ) |
|
463 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
464 | + print_r($timestamp, true) |
|
466 | 465 | ) |
467 | 466 | ); |
468 | 467 | } |
469 | - switch ( $period ) { |
|
468 | + switch ($period) { |
|
470 | 469 | case 'years' : |
471 | 470 | $value = YEAR_IN_SECONDS * $value; |
472 | 471 | break; |
@@ -486,9 +485,9 @@ discard block |
||
486 | 485 | $value = MINUTE_IN_SECONDS * $value; |
487 | 486 | break; |
488 | 487 | } |
489 | - switch ( $operand ) { |
|
488 | + switch ($operand) { |
|
490 | 489 | case '+': |
491 | - $timestamp += $value; |
|
490 | + $timestamp += $value; |
|
492 | 491 | break; |
493 | 492 | case '-': |
494 | 493 | $timestamp -= $value; |
@@ -508,11 +507,11 @@ discard block |
||
508 | 507 | * @param string $operand What operand you wish to use for the calculation |
509 | 508 | * @return mixed string|DateTime return whatever type came in. |
510 | 509 | */ |
511 | - public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
512 | - if ( $DateTime_or_timestamp instanceof DateTime ) { |
|
513 | - return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand ); |
|
514 | - } else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) { |
|
515 | - return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand ); |
|
510 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
511 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
512 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
513 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
514 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
516 | 515 | } else { |
517 | 516 | //error |
518 | 517 | return $DateTime_or_timestamp; |
@@ -542,24 +541,24 @@ discard block |
||
542 | 541 | * 'moment' => //date and time format. |
543 | 542 | * ) |
544 | 543 | */ |
545 | - public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) { |
|
546 | - if ( $date_format_string === null ) { |
|
547 | - $date_format_string = get_option( 'date_format' ); |
|
544 | + public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) { |
|
545 | + if ($date_format_string === null) { |
|
546 | + $date_format_string = get_option('date_format'); |
|
548 | 547 | } |
549 | 548 | |
550 | - if ( $time_format_string === null ) { |
|
551 | - $time_format_string = get_option( 'time_format' ); |
|
549 | + if ($time_format_string === null) { |
|
550 | + $time_format_string = get_option('time_format'); |
|
552 | 551 | } |
553 | 552 | |
554 | - $date_format = self::_php_to_js_moment_converter( $date_format_string ); |
|
555 | - $time_format = self::_php_to_js_moment_converter( $time_format_string ); |
|
553 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
554 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
556 | 555 | |
557 | 556 | return array( |
558 | 557 | 'js' => array( |
559 | 558 | 'date' => $date_format['js'], |
560 | 559 | 'time' => $time_format['js'] |
561 | 560 | ), |
562 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment' ] |
|
561 | + 'moment' => $date_format['moment'].' '.$time_format['moment'] |
|
563 | 562 | ); |
564 | 563 | } |
565 | 564 | |
@@ -573,7 +572,7 @@ discard block |
||
573 | 572 | * |
574 | 573 | * @return array js and moment formats. |
575 | 574 | */ |
576 | - protected static function _php_to_js_moment_converter( $format_string ) { |
|
575 | + protected static function _php_to_js_moment_converter($format_string) { |
|
577 | 576 | /** |
578 | 577 | * This is a map of symbols for formats. |
579 | 578 | * The index is the php symbol, the equivalent values are in the array. |
@@ -730,15 +729,15 @@ discard block |
||
730 | 729 | $jquery_ui_format = ""; |
731 | 730 | $moment_format = ""; |
732 | 731 | $escaping = false; |
733 | - for ( $i = 0; $i < strlen($format_string); $i++ ) { |
|
732 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
734 | 733 | $char = $format_string[$i]; |
735 | - if ( $char === '\\' ) { // PHP date format escaping character |
|
734 | + if ($char === '\\') { // PHP date format escaping character |
|
736 | 735 | $i++; |
737 | - if ( $escaping ) { |
|
736 | + if ($escaping) { |
|
738 | 737 | $jquery_ui_format .= $format_string[$i]; |
739 | 738 | $moment_format .= $format_string[$i]; |
740 | 739 | } else { |
741 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
740 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
742 | 741 | $moment_format .= $format_string[$i]; |
743 | 742 | } |
744 | 743 | $escaping = true; |
@@ -757,7 +756,7 @@ discard block |
||
757 | 756 | } |
758 | 757 | } |
759 | 758 | } |
760 | - return array( 'js' => $jquery_ui_format, 'moment' => $moment_format ); |
|
759 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
761 | 760 | } |
762 | 761 | |
763 | 762 | |
@@ -772,25 +771,25 @@ discard block |
||
772 | 771 | * errors is returned. So for client code calling, check for is_array() to |
773 | 772 | * indicate failed validations. |
774 | 773 | */ |
775 | - public static function validate_format_string( $format_string ) { |
|
774 | + public static function validate_format_string($format_string) { |
|
776 | 775 | $error_msg = array(); |
777 | 776 | //time format checks |
778 | - switch ( true ) { |
|
779 | - case strpos( $format_string, 'h' ) !== false : |
|
780 | - case strpos( $format_string, 'g' ) !== false : |
|
777 | + switch (true) { |
|
778 | + case strpos($format_string, 'h') !== false : |
|
779 | + case strpos($format_string, 'g') !== false : |
|
781 | 780 | /** |
782 | 781 | * if the time string has a lowercase 'h' which == 12 hour time format and there |
783 | 782 | * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
784 | 783 | * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
785 | 784 | */ |
786 | - if ( strpos( strtoupper( $format_string ), 'A' ) === false ) { |
|
787 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' ); |
|
785 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
786 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso'); |
|
788 | 787 | } |
789 | 788 | break; |
790 | 789 | |
791 | 790 | } |
792 | 791 | |
793 | - return empty( $error_msg ) ? true : $error_msg; |
|
792 | + return empty($error_msg) ? true : $error_msg; |
|
794 | 793 | } |
795 | 794 | |
796 | 795 | |
@@ -812,11 +811,11 @@ discard block |
||
812 | 811 | * @param mixed $date_2 |
813 | 812 | * @return bool |
814 | 813 | */ |
815 | - public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) { |
|
814 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) { |
|
816 | 815 | |
817 | 816 | if ( |
818 | - ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) || |
|
819 | - ( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' ) |
|
817 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
818 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
820 | 819 | ) { |
821 | 820 | return false; |
822 | 821 | } |
@@ -833,11 +832,11 @@ discard block |
||
833 | 832 | * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
834 | 833 | * @return string |
835 | 834 | */ |
836 | - public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) { |
|
835 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) { |
|
837 | 836 | try { |
838 | 837 | /** need to account for timezone offset on the selects */ |
839 | - $DateTimeZone = new DateTimeZone( $timezone_string ); |
|
840 | - } catch ( Exception $e ) { |
|
838 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
839 | + } catch (Exception $e) { |
|
841 | 840 | $DateTimeZone = null; |
842 | 841 | } |
843 | 842 | |
@@ -845,10 +844,10 @@ discard block |
||
845 | 844 | * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
846 | 845 | * Hence we do the calc for DateTimeZone::getOffset. |
847 | 846 | */ |
848 | - $offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' ); |
|
847 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
849 | 848 | $query_interval = $offset < 0 |
850 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)' |
|
851 | - : 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)'; |
|
849 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
850 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
852 | 851 | return $query_interval; |
853 | 852 | } |
854 | 853 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Class EEH_Debug_Tools |
4 | 6 | * |
@@ -122,8 +124,7 @@ discard block |
||
122 | 124 | return; |
123 | 125 | } |
124 | 126 | echo '<h5>For Tag: '. $tag .'</h5>'; |
125 | - } |
|
126 | - else { |
|
127 | + } else { |
|
127 | 128 | $hook=$wp_filter; |
128 | 129 | ksort( $hook ); |
129 | 130 | } |
@@ -183,7 +184,7 @@ discard block |
||
183 | 184 | if( isset( $this->_start_times[ $timer_name ] ) ){ |
184 | 185 | $start_time = $this->_start_times[ $timer_name ]; |
185 | 186 | unset( $this->_start_times[ $timer_name ] ); |
186 | - }else{ |
|
187 | + } else{ |
|
187 | 188 | $start_time = array_pop( $this->_start_times ); |
188 | 189 | } |
189 | 190 | $total_time = microtime( TRUE ) - $start_time; |
@@ -392,7 +392,7 @@ |
||
392 | 392 | * @ access public |
393 | 393 | * @ return void |
394 | 394 | * |
395 | - * @param mixed $var |
|
395 | + * @param string $var |
|
396 | 396 | * @param bool $var_name |
397 | 397 | * @param string $file |
398 | 398 | * @param int $line |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,22 +299,22 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - $error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version); |
|
306 | 306 | |
307 | 307 | //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request. |
308 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
309 | - $error_message .= esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso' ); |
|
308 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
309 | + $error_message .= esc_html__('This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso'); |
|
310 | 310 | $error_message .= '<ul><li>'; |
311 | - $error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() ); |
|
311 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
312 | 312 | $error_message .= '</ul>'; |
313 | - EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' ); |
|
313 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
314 | 314 | //now we set this on the transient so it shows up on the next request. |
315 | - EE_Error::get_notices( is_admin(), true ); |
|
315 | + EE_Error::get_notices(is_admin(), true); |
|
316 | 316 | } else { |
317 | - trigger_error( $error_message, $error_type ); |
|
317 | + trigger_error($error_message, $error_type); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * @param string $debug_index |
337 | 337 | * @param string $debug_key |
338 | 338 | */ |
339 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
340 | - if ( WP_DEBUG && false ) { |
|
341 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
342 | - $debug_data = get_option( $debug_key, array() ); |
|
339 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
340 | + if (WP_DEBUG && false) { |
|
341 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
342 | + $debug_data = get_option($debug_key, array()); |
|
343 | 343 | $default_data = array( |
344 | - $class => $func . '() : ' . $line, |
|
344 | + $class => $func.'() : '.$line, |
|
345 | 345 | 'REQ' => $display_request ? $_REQUEST : '', |
346 | 346 | ); |
347 | 347 | // don't serialize objects |
348 | - $info = self::strip_objects( $info ); |
|
349 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
350 | - if ( ! isset( $debug_data[$index] ) ) { |
|
348 | + $info = self::strip_objects($info); |
|
349 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
350 | + if ( ! isset($debug_data[$index])) { |
|
351 | 351 | $debug_data[$index] = array(); |
352 | 352 | } |
353 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
354 | - update_option( $debug_key, $debug_data ); |
|
353 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
354 | + update_option($debug_key, $debug_data); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -363,26 +363,26 @@ discard block |
||
363 | 363 | * @param array $info |
364 | 364 | * @return array |
365 | 365 | */ |
366 | - public static function strip_objects( $info = array() ) { |
|
367 | - foreach ( $info as $key => $value ) { |
|
368 | - if ( is_array( $value ) ) { |
|
369 | - $info[ $key ] = self::strip_objects( $value ); |
|
370 | - } else if ( is_object( $value ) ) { |
|
371 | - $object_class = get_class( $value ); |
|
372 | - $info[ $object_class ] = array(); |
|
373 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
374 | - if ( method_exists( $value, 'ID' ) ) { |
|
375 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
366 | + public static function strip_objects($info = array()) { |
|
367 | + foreach ($info as $key => $value) { |
|
368 | + if (is_array($value)) { |
|
369 | + $info[$key] = self::strip_objects($value); |
|
370 | + } else if (is_object($value)) { |
|
371 | + $object_class = get_class($value); |
|
372 | + $info[$object_class] = array(); |
|
373 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
374 | + if (method_exists($value, 'ID')) { |
|
375 | + $info[$object_class]['ID'] = $value->ID(); |
|
376 | 376 | } |
377 | - if ( method_exists( $value, 'status' ) ) { |
|
378 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
379 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
380 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
377 | + if (method_exists($value, 'status')) { |
|
378 | + $info[$object_class]['status'] = $value->status(); |
|
379 | + } else if (method_exists($value, 'status_ID')) { |
|
380 | + $info[$object_class]['status'] = $value->status_ID(); |
|
381 | 381 | } |
382 | - unset( $info[ $key ] ); |
|
382 | + unset($info[$key]); |
|
383 | 383 | } |
384 | 384 | } |
385 | - return (array)$info; |
|
385 | + return (array) $info; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -399,24 +399,24 @@ discard block |
||
399 | 399 | * @param int $header |
400 | 400 | * @param bool $die |
401 | 401 | */ |
402 | - public static function printv( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
402 | + public static function printv($var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
403 | 403 | $var_name = ! $var_name ? 'string' : $var_name; |
404 | 404 | $heading_tag = 'h'; |
405 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
406 | - $var_name = ucwords( str_replace( '$', '', $var_name ) ); |
|
407 | - $is_method = method_exists( $var_name, $var ); |
|
408 | - $var_name = ucwords( str_replace( '_', ' ', $var_name ) ); |
|
405 | + $heading_tag .= is_int($header) ? $header : 5; |
|
406 | + $var_name = ucwords(str_replace('$', '', $var_name)); |
|
407 | + $is_method = method_exists($var_name, $var); |
|
408 | + $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
409 | 409 | ob_start(); |
410 | - echo '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>'; |
|
410 | + echo '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>'; |
|
411 | 411 | echo $is_method |
412 | - ? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />' |
|
413 | - : '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />'; |
|
414 | - echo '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
415 | - echo '<br />line no: ' . $line . '</span>'; |
|
416 | - echo '</' . $heading_tag . '>'; |
|
412 | + ? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />' |
|
413 | + : '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />'; |
|
414 | + echo '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
415 | + echo '<br />line no: '.$line.'</span>'; |
|
416 | + echo '</'.$heading_tag.'>'; |
|
417 | 417 | $result = ob_get_clean(); |
418 | - if ( $die ) { |
|
419 | - die( $result ); |
|
418 | + if ($die) { |
|
419 | + die($result); |
|
420 | 420 | } else { |
421 | 421 | echo $result; |
422 | 422 | } |
@@ -435,36 +435,36 @@ discard block |
||
435 | 435 | * @param int $header |
436 | 436 | * @param bool $die |
437 | 437 | */ |
438 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
439 | - $file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file ); |
|
438 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
439 | + $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
440 | 440 | //$print_r = false; |
441 | - if ( is_string( $var ) ) { |
|
442 | - EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die ); |
|
441 | + if (is_string($var)) { |
|
442 | + EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die); |
|
443 | 443 | return; |
444 | - } else if ( is_object( $var ) ) { |
|
444 | + } else if (is_object($var)) { |
|
445 | 445 | $var_name = ! $var_name ? 'object' : $var_name; |
446 | 446 | //$print_r = true; |
447 | - } else if ( is_array( $var ) ) { |
|
447 | + } else if (is_array($var)) { |
|
448 | 448 | $var_name = ! $var_name ? 'array' : $var_name; |
449 | 449 | //$print_r = true; |
450 | - } else if ( is_numeric( $var ) ) { |
|
450 | + } else if (is_numeric($var)) { |
|
451 | 451 | $var_name = ! $var_name ? 'numeric' : $var_name; |
452 | - } else if ( is_null( $var ) ) { |
|
452 | + } else if (is_null($var)) { |
|
453 | 453 | $var_name = ! $var_name ? 'null' : $var_name; |
454 | 454 | } |
455 | 455 | $heading_tag = 'h'; |
456 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
457 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
456 | + $heading_tag .= is_int($header) ? $header : 5; |
|
457 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
458 | 458 | ob_start(); |
459 | - echo '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>'; |
|
459 | + echo '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>'; |
|
460 | 460 | echo '<span style="color:#999;"> : </span><span style="color:#E76700;">'; |
461 | 461 | echo '<pre style="color:#999; padding:1em; background: #fff">'; |
462 | - var_dump( $var ); |
|
463 | - echo '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
464 | - echo '<br />line no: ' . $line . '</span></' . $heading_tag . '>'; |
|
462 | + var_dump($var); |
|
463 | + echo '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
464 | + echo '<br />line no: '.$line.'</span></'.$heading_tag.'>'; |
|
465 | 465 | $result = ob_get_clean(); |
466 | - if ( $die ) { |
|
467 | - die( $result ); |
|
466 | + if ($die) { |
|
467 | + die($result); |
|
468 | 468 | } else { |
469 | 469 | echo $result; |
470 | 470 | } |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * borrowed from Kint Debugger |
482 | 482 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
483 | 483 | */ |
484 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
485 | - function dump_wp_query(){ |
|
484 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
485 | + function dump_wp_query() { |
|
486 | 486 | global $wp_query; |
487 | 487 | d($wp_query); |
488 | 488 | } |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | * borrowed from Kint Debugger |
493 | 493 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
494 | 494 | */ |
495 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
496 | - function dump_wp(){ |
|
495 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
496 | + function dump_wp() { |
|
497 | 497 | global $wp; |
498 | 498 | d($wp); |
499 | 499 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * borrowed from Kint Debugger |
504 | 504 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
505 | 505 | */ |
506 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
507 | - function dump_post(){ |
|
506 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
507 | + function dump_post() { |
|
508 | 508 | global $post; |
509 | 509 | d($post); |
510 | 510 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -432,7 +434,7 @@ discard block |
||
432 | 434 | if($include_expired === null){ |
433 | 435 | if($event instanceof EE_Event && $event->is_expired()){ |
434 | 436 | $include_expired = true; |
435 | - }else{ |
|
437 | + } else{ |
|
436 | 438 | $include_expired = false; |
437 | 439 | } |
438 | 440 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @access public |
40 | 40 | * @param int $EVT_ID |
41 | - * @return object |
|
41 | + * @return null|boolean |
|
42 | 42 | */ |
43 | 43 | public static function get_event( $EVT_ID = 0 ) { |
44 | 44 | $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @access public |
118 | 118 | * @param int $EVT_ID |
119 | - * @return string |
|
119 | + * @return boolean |
|
120 | 120 | */ |
121 | 121 | public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
122 | 122 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * event_active_status |
137 | 137 | * |
138 | 138 | * @access public |
139 | - * @param null $num_words |
|
139 | + * @param integer $num_words |
|
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @access public |
324 | 324 | * @param int $EVT_ID |
325 | - * @return string |
|
325 | + * @return string|null |
|
326 | 326 | */ |
327 | 327 | public static function get_primary_date_obj( $EVT_ID = 0 ) { |
328 | 328 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @access public |
349 | 349 | * @param int $EVT_ID |
350 | - * @return string |
|
350 | + * @return string|null |
|
351 | 351 | */ |
352 | 352 | public static function get_last_date_obj( $EVT_ID = 0 ) { |
353 | 353 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @access public |
374 | 374 | * @param int $EVT_ID |
375 | - * @return string |
|
375 | + * @return string|null |
|
376 | 376 | */ |
377 | 377 | public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
378 | 378 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @access public |
424 | 424 | * @param int $EVT_ID |
425 | - * @param null $include_expired |
|
425 | + * @param false|null $include_expired |
|
426 | 426 | * @param bool $include_deleted |
427 | 427 | * @param null $limit |
428 | 428 | * @return EE_Datetime[] |
@@ -40,27 +40,27 @@ discard block |
||
40 | 40 | * @param int $EVT_ID |
41 | 41 | * @return object |
42 | 42 | */ |
43 | - public static function get_event( $EVT_ID = 0 ) { |
|
44 | - $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
|
43 | + public static function get_event($EVT_ID = 0) { |
|
44 | + $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID); |
|
45 | 45 | // do we already have the Event you are looking for? |
46 | - if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) { |
|
46 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
47 | 47 | return EEH_Event_View::$_event; |
48 | 48 | } |
49 | 49 | EEH_Event_View::$_event = NULL; |
50 | 50 | // international newspaper? |
51 | 51 | global $post; |
52 | 52 | // if this is being called from an EE_Event post, then we can just grab the attached EE_Event object |
53 | - if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) { |
|
53 | + if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) { |
|
54 | 54 | // d( $post ); |
55 | 55 | // grab the event we're looking for |
56 | - if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) { |
|
56 | + if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) { |
|
57 | 57 | EEH_Event_View::$_event = $post->EE_Event; |
58 | 58 | // d( EEH_Event_View::$_event ); |
59 | 59 | } |
60 | 60 | // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID... |
61 | - if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) { |
|
61 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
62 | 62 | // sigh... pull it from the db |
63 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
63 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
64 | 64 | // d( EEH_Event_View::$_event ); |
65 | 65 | } |
66 | 66 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param int $EVT_ID |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - public static function display_ticket_selector( $EVT_ID = 0 ) { |
|
80 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
79 | + public static function display_ticket_selector($EVT_ID = 0) { |
|
80 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
81 | 81 | return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE; |
82 | 82 | } |
83 | 83 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param int $EVT_ID |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public static function event_status( $EVT_ID = 0 ) { |
|
94 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
95 | - return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : ''; |
|
93 | + public static function event_status($EVT_ID = 0) { |
|
94 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
95 | + return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : ''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param int $EVT_ID |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function event_active_status( $EVT_ID = 0 ) { |
|
108 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
107 | + public static function event_active_status($EVT_ID = 0) { |
|
108 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
109 | 109 | return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive'; |
110 | 110 | } |
111 | 111 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param int $EVT_ID |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
|
122 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
121 | + public static function event_has_content_or_excerpt($EVT_ID = 0) { |
|
122 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
123 | 123 | $has_content_or_excerpt = FALSE; |
124 | - if ( $event instanceof EE_Event ) { |
|
125 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE; |
|
124 | + if ($event instanceof EE_Event) { |
|
125 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE; |
|
126 | 126 | } |
127 | - if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) { |
|
127 | + if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) { |
|
128 | 128 | $has_content_or_excerpt = FALSE; |
129 | 129 | } |
130 | 130 | return $has_content_or_excerpt; |
@@ -140,45 +140,45 @@ discard block |
||
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
|
143 | + public static function event_content_or_excerpt($num_words = NULL, $more = NULL) { |
|
144 | 144 | global $post; |
145 | 145 | |
146 | 146 | ob_start(); |
147 | - if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
|
147 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
148 | 148 | |
149 | 149 | // admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option |
150 | 150 | the_content(); |
151 | 151 | |
152 | - } else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) { |
|
152 | + } else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
153 | 153 | |
154 | 154 | // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option |
155 | 155 | // AND an excerpt actually exists |
156 | 156 | the_excerpt(); |
157 | 157 | |
158 | - } else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) { |
|
158 | + } else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
159 | 159 | |
160 | 160 | // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option |
161 | 161 | // but NO excerpt actually exists, so we need to create one |
162 | - if ( ! empty( $num_words )) { |
|
163 | - if ( empty( $more )) { |
|
164 | - $more_link_text = __( '(more…)' ); |
|
165 | - $more = ' <a href="' . get_permalink() . '" class="more-link">' . $more_link_text . '</a>'; |
|
166 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
162 | + if ( ! empty($num_words)) { |
|
163 | + if (empty($more)) { |
|
164 | + $more_link_text = __('(more…)'); |
|
165 | + $more = ' <a href="'.get_permalink().'" class="more-link">'.$more_link_text.'</a>'; |
|
166 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
167 | 167 | } |
168 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
168 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
169 | 169 | |
170 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
170 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
171 | 171 | } else { |
172 | - $content = get_the_content(); |
|
172 | + $content = get_the_content(); |
|
173 | 173 | } |
174 | 174 | global $allowedtags; |
175 | - $content = wp_kses( $content, $allowedtags ); |
|
176 | - $content = strip_shortcodes( $content ); |
|
177 | - echo apply_filters( 'the_content', $content ); |
|
175 | + $content = wp_kses($content, $allowedtags); |
|
176 | + $content = strip_shortcodes($content); |
|
177 | + echo apply_filters('the_content', $content); |
|
178 | 178 | |
179 | 179 | } else { |
180 | 180 | // admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option |
181 | - echo apply_filters( 'the_content', '' ); |
|
181 | + echo apply_filters('the_content', ''); |
|
182 | 182 | } |
183 | 183 | return ob_get_clean(); |
184 | 184 | } |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * @param int $EVT_ID |
193 | 193 | * @return EE_Ticket[] |
194 | 194 | */ |
195 | - public static function event_tickets_available( $EVT_ID = 0 ) { |
|
196 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
195 | + public static function event_tickets_available($EVT_ID = 0) { |
|
196 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
197 | 197 | $tickets_available_for_purchase = array(); |
198 | - if( $event instanceof EE_Event ) { |
|
199 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE ); |
|
200 | - foreach( $datetimes as $datetime ) { |
|
201 | - $tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() ); |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE); |
|
200 | + foreach ($datetimes as $datetime) { |
|
201 | + $tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | return $tickets_available_for_purchase; |
@@ -214,22 +214,22 @@ discard block |
||
214 | 214 | * @param bool $hide_uncategorized |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) { |
|
217 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) { |
|
218 | 218 | $category_links = array(); |
219 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
220 | - if ( $event instanceof EE_Event ) { |
|
221 | - $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' ); |
|
222 | - if ( $event_categories ) { |
|
219 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
220 | + if ($event instanceof EE_Event) { |
|
221 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
222 | + if ($event_categories) { |
|
223 | 223 | // loop thru terms and create links |
224 | - foreach ( $event_categories as $term ) { |
|
225 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
226 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
227 | - $category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>'; |
|
224 | + foreach ($event_categories as $term) { |
|
225 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
226 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
227 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>'; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | - return implode( ', ', $category_links ); |
|
232 | + return implode(', ', $category_links); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @param int $EVT_ID |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
247 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
248 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
249 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
246 | + public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
247 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
248 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
249 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | * @param int $EVT_ID |
261 | 261 | * @return string |
262 | 262 | */ |
263 | - public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
264 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
265 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
266 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
263 | + public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
264 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
265 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
266 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | * @param int $EVT_ID |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
281 | - $datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID ); |
|
282 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
283 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
280 | + public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
281 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
282 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
283 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | * @param int $EVT_ID |
295 | 295 | * @return string |
296 | 296 | */ |
297 | - public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
298 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
299 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
300 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
297 | + public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
298 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
299 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
300 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | * @param int $EVT_ID |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - public static function event_date_as_calendar_page( $EVT_ID = 0 ) { |
|
313 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
314 | - if ( $datetime instanceof EE_Datetime ) { |
|
312 | + public static function event_date_as_calendar_page($EVT_ID = 0) { |
|
313 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
314 | + if ($datetime instanceof EE_Datetime) { |
|
315 | 315 | ?> |
316 | 316 | <div class="event-date-calendar-page-dv"> |
317 | - <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div> |
|
318 | - <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div> |
|
317 | + <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div> |
|
318 | + <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div> |
|
319 | 319 | </div> |
320 | 320 | <?php |
321 | 321 | } |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | * @param int $EVT_ID |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - public static function get_primary_date_obj( $EVT_ID = 0 ) { |
|
334 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
335 | - if ( $event instanceof EE_Event ) { |
|
333 | + public static function get_primary_date_obj($EVT_ID = 0) { |
|
334 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
335 | + if ($event instanceof EE_Event) { |
|
336 | 336 | $datetimes = $event->get_many_related( |
337 | 337 | 'Datetime', |
338 | 338 | array( |
339 | 339 | 'limit' => 1, |
340 | - 'order_by' => array( 'DTT_order' => 'ASC' ) |
|
340 | + 'order_by' => array('DTT_order' => 'ASC') |
|
341 | 341 | ) |
342 | 342 | ); |
343 | - return reset( $datetimes ); |
|
343 | + return reset($datetimes); |
|
344 | 344 | } else { |
345 | 345 | return FALSE; |
346 | 346 | } |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * @param int $EVT_ID |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public static function get_last_date_obj( $EVT_ID = 0 ) { |
|
359 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
360 | - if ( $event instanceof EE_Event ) { |
|
358 | + public static function get_last_date_obj($EVT_ID = 0) { |
|
359 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
360 | + if ($event instanceof EE_Event) { |
|
361 | 361 | $datetimes = $event->get_many_related( |
362 | 362 | 'Datetime', |
363 | 363 | array( |
364 | 364 | 'limit' => 1, |
365 | - 'order_by' => array( 'DTT_order' => 'DESC' ) |
|
365 | + 'order_by' => array('DTT_order' => 'DESC') |
|
366 | 366 | ) |
367 | 367 | ); |
368 | - return end( $datetimes ); |
|
368 | + return end($datetimes); |
|
369 | 369 | } else { |
370 | 370 | return FALSE; |
371 | 371 | } |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | * @param int $EVT_ID |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
|
384 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
385 | - if ( $event instanceof EE_Event ) { |
|
383 | + public static function get_earliest_date_obj($EVT_ID = 0) { |
|
384 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
385 | + if ($event instanceof EE_Event) { |
|
386 | 386 | $datetimes = $event->get_many_related( |
387 | 387 | 'Datetime', |
388 | 388 | array( |
389 | 389 | 'limit' => 1, |
390 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
390 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
391 | 391 | ) |
392 | 392 | ); |
393 | - return reset( $datetimes ); |
|
393 | + return reset($datetimes); |
|
394 | 394 | } else { |
395 | 395 | return FALSE; |
396 | 396 | } |
@@ -405,17 +405,17 @@ discard block |
||
405 | 405 | * @param int $EVT_ID |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - public static function get_latest_date_obj( $EVT_ID = 0 ) { |
|
409 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
410 | - if ( $event instanceof EE_Event ) { |
|
408 | + public static function get_latest_date_obj($EVT_ID = 0) { |
|
409 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
410 | + if ($event instanceof EE_Event) { |
|
411 | 411 | $datetimes = $event->get_many_related( |
412 | 412 | 'Datetime', |
413 | 413 | array( |
414 | 414 | 'limit' => 1, |
415 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
415 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
416 | 416 | ) |
417 | 417 | ); |
418 | - return end( $datetimes ); |
|
418 | + return end($datetimes); |
|
419 | 419 | } else { |
420 | 420 | return FALSE; |
421 | 421 | } |
@@ -433,17 +433,17 @@ discard block |
||
433 | 433 | * @param null $limit |
434 | 434 | * @return EE_Datetime[] |
435 | 435 | */ |
436 | - public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) { |
|
437 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
438 | - if($include_expired === null){ |
|
439 | - if($event instanceof EE_Event && $event->is_expired()){ |
|
436 | + public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) { |
|
437 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
438 | + if ($include_expired === null) { |
|
439 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
440 | 440 | $include_expired = true; |
441 | - }else{ |
|
441 | + } else { |
|
442 | 442 | $include_expired = false; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - if ( $event instanceof EE_Event ) { |
|
446 | + if ($event instanceof EE_Event) { |
|
447 | 447 | return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
448 | 448 | } else { |
449 | 449 | return array(); |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | * @param int $EVT_ID |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - public static function event_link_url( $EVT_ID = 0 ) { |
|
463 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
464 | - if ( $event instanceof EE_Event ) { |
|
465 | - $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() ); |
|
466 | - return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url; |
|
462 | + public static function event_link_url($EVT_ID = 0) { |
|
463 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
464 | + if ($event instanceof EE_Event) { |
|
465 | + $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID()); |
|
466 | + return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url; |
|
467 | 467 | } |
468 | 468 | return NULL; |
469 | 469 | } |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | * @param int $EVT_ID |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public static function event_phone( $EVT_ID = 0 ) { |
|
481 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
482 | - if ( $event instanceof EE_Event ) { |
|
483 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
484 | - return EEH_Schema::telephone( $event->phone() ); |
|
480 | + public static function event_phone($EVT_ID = 0) { |
|
481 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
482 | + if ($event instanceof EE_Event) { |
|
483 | + EE_Registry::instance()->load_helper('Formatter'); |
|
484 | + return EEH_Schema::telephone($event->phone()); |
|
485 | 485 | } |
486 | 486 | return NULL; |
487 | 487 | } |
@@ -498,23 +498,23 @@ discard block |
||
498 | 498 | * @param string $after |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) { |
|
502 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
503 | - if ( $event instanceof EE_Event ) { |
|
501 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') { |
|
502 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
503 | + if ($event instanceof EE_Event) { |
|
504 | 504 | // can the user edit this post ? |
505 | - if ( current_user_can( 'edit_post', $event->ID() )) { |
|
505 | + if (current_user_can('edit_post', $event->ID())) { |
|
506 | 506 | // set link text |
507 | - $link = ! empty( $link ) ? $link : __('edit this event'); |
|
507 | + $link = ! empty($link) ? $link : __('edit this event'); |
|
508 | 508 | // generate nonce |
509 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
509 | + $nonce = wp_create_nonce('edit_nonce'); |
|
510 | 510 | // generate url to event editor for this event |
511 | - $url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() ); |
|
511 | + $url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url()); |
|
512 | 512 | // get edit CPT text |
513 | - $post_type_obj = get_post_type_object( 'espresso_events' ); |
|
513 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
514 | 514 | // build final link html |
515 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>'; |
|
515 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
516 | 516 | // put it all together |
517 | - return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after; |
|
517 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | return ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,22 +363,22 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | //load formatter helper |
374 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
374 | + EE_Registry::instance()->load_helper('Formatter'); |
|
375 | 375 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
376 | 376 | |
377 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
377 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
378 | 378 | //Debug |
379 | 379 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
380 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | - $field .= ' ' . $parameters; |
|
380 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | + $field .= ' '.$parameters; |
|
382 | 382 | if ($autosize) { |
383 | 383 | $size = 'med'; |
384 | 384 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | $size = ''; |
392 | 392 | } |
393 | 393 | |
394 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
394 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
395 | 395 | |
396 | 396 | if (empty($default) && isset($GLOBALS[$name])) |
397 | 397 | $default = stripslashes($GLOBALS[$name]); |
398 | 398 | |
399 | 399 | |
400 | 400 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
401 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
401 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
402 | 402 | if ($default == $values[$i]['id']) { |
403 | 403 | $field .= ' selected = "selected"'; |
404 | 404 | } |
405 | - if ( isset( $values[$i]['class'] ) ) { |
|
406 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
405 | + if (isset($values[$i]['class'])) { |
|
406 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
407 | 407 | } |
408 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
408 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
409 | 409 | } |
410 | 410 | $field .= '</select>'; |
411 | 411 | |
@@ -423,38 +423,38 @@ discard block |
||
423 | 423 | * @param string $question_groups |
424 | 424 | * @return string HTML |
425 | 425 | */ |
426 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
426 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
427 | 427 | |
428 | 428 | $html = ''; |
429 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
430 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
429 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
430 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
431 | 431 | |
432 | - if ( ! empty( $question_groups )) { |
|
432 | + if ( ! empty($question_groups)) { |
|
433 | 433 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
434 | 434 | // loop thru question groups |
435 | - foreach ( $question_groups as $QSG ) { |
|
435 | + foreach ($question_groups as $QSG) { |
|
436 | 436 | // check that questions exist |
437 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
437 | + if ( ! empty($QSG['QSG_questions'])) { |
|
438 | 438 | // use fieldsets |
439 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
439 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
440 | 440 | // group_name |
441 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
441 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
442 | 442 | // group_desc |
443 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
443 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
444 | 444 | |
445 | 445 | $html .= $before_question_group_questions; |
446 | 446 | // loop thru questions |
447 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
447 | + foreach ($QSG['QSG_questions'] as $question) { |
|
448 | 448 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
449 | 449 | $QFI = new EE_Question_Form_Input( |
450 | 450 | $question['qst_obj'], |
451 | 451 | $question['ans_obj'], |
452 | 452 | $question |
453 | 453 | ); |
454 | - $html .= self::generate_form_input( $QFI ); |
|
454 | + $html .= self::generate_form_input($QFI); |
|
455 | 455 | } |
456 | 456 | $html .= $after_question_group_questions; |
457 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
457 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @param string $group_wrapper |
475 | 475 | * @return string HTML |
476 | 476 | */ |
477 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
477 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
478 | 478 | |
479 | 479 | $html = ''; |
480 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
481 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
480 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
481 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
482 | 482 | |
483 | 483 | $default_q_meta = array( |
484 | 484 | 'att_nmbr' => 1, |
@@ -487,55 +487,55 @@ discard block |
||
487 | 487 | 'input_id' => '', |
488 | 488 | 'input_class' => '' |
489 | 489 | ); |
490 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
490 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
491 | 491 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | |
493 | - if ( ! empty( $question_groups )) { |
|
493 | + if ( ! empty($question_groups)) { |
|
494 | 494 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
495 | 495 | // loop thru question groups |
496 | - foreach ( $question_groups as $QSG ) { |
|
497 | - if ( $QSG instanceof EE_Question_Group ) { |
|
496 | + foreach ($question_groups as $QSG) { |
|
497 | + if ($QSG instanceof EE_Question_Group) { |
|
498 | 498 | // check that questions exist |
499 | 499 | |
500 | - $where = array( 'QST_deleted' => 0 ); |
|
501 | - if ( ! $from_admin ) { |
|
500 | + $where = array('QST_deleted' => 0); |
|
501 | + if ( ! $from_admin) { |
|
502 | 502 | $where['QST_admin_only'] = 0; |
503 | 503 | } |
504 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
505 | - if ( ! empty( $questions )) { |
|
504 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
505 | + if ( ! empty($questions)) { |
|
506 | 506 | // use fieldsets |
507 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
507 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
508 | 508 | // group_name |
509 | - if ( $QSG->show_group_name() ) { |
|
510 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
509 | + if ($QSG->show_group_name()) { |
|
510 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
511 | 511 | } |
512 | 512 | // group_desc |
513 | - if ( $QSG->show_group_desc() ) { |
|
514 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
513 | + if ($QSG->show_group_desc()) { |
|
514 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $html .= $before_question_group_questions; |
518 | 518 | // loop thru questions |
519 | - foreach ( $questions as $QST ) { |
|
519 | + foreach ($questions as $QST) { |
|
520 | 520 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
521 | 521 | |
522 | 522 | $answer = NULL; |
523 | 523 | |
524 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
524 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
525 | 525 | // check for answer in $_GET in case we are reprocessing a form after an error |
526 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
527 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
526 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
527 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
528 | 528 | } |
529 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
529 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
530 | 530 | //attendee data from the session |
531 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
531 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | |
536 | 536 | $QFI = new EE_Question_Form_Input( |
537 | 537 | $QST, |
538 | - EE_Answer::new_instance ( array( |
|
538 | + EE_Answer::new_instance(array( |
|
539 | 539 | 'ANS_ID'=> 0, |
540 | 540 | 'QST_ID'=> 0, |
541 | 541 | 'REG_ID'=> 0, |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | $q_meta |
545 | 545 | ); |
546 | 546 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
547 | - $html .= self::generate_form_input( $QFI ); |
|
547 | + $html .= self::generate_form_input($QFI); |
|
548 | 548 | } |
549 | 549 | $html .= $after_question_group_questions; |
550 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
550 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -567,63 +567,63 @@ discard block |
||
567 | 567 | * @param EE_Question_Form_Input $QFI |
568 | 568 | * @return string HTML |
569 | 569 | */ |
570 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
571 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
570 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
571 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
572 | 572 | return ''; |
573 | 573 | } |
574 | 574 | |
575 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
576 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
575 | + $QFI = self::_load_system_dropdowns($QFI); |
|
576 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
577 | 577 | |
578 | 578 | //we also need to verify |
579 | 579 | |
580 | 580 | $display_text = $QFI->get('QST_display_text'); |
581 | 581 | $input_name = $QFI->get('QST_input_name'); |
582 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
582 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
583 | 583 | $input_id = $QFI->get('QST_input_id'); |
584 | 584 | $input_class = $QFI->get('QST_input_class'); |
585 | 585 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
586 | 586 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
587 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
587 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
588 | 588 | $QST_required = $QFI->get('QST_required'); |
589 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
590 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
591 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
592 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
589 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
590 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
591 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
592 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
593 | 593 | $label_class = 'espresso-form-input-lbl'; |
594 | - $QST_options = $QFI->options(true,$answer); |
|
595 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
594 | + $QST_options = $QFI->options(true, $answer); |
|
595 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
596 | 596 | $system_ID = $QFI->get('QST_system'); |
597 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
598 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
597 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
598 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
599 | 599 | |
600 | 600 | |
601 | - switch ( $QFI->get('QST_type') ){ |
|
601 | + switch ($QFI->get('QST_type')) { |
|
602 | 602 | |
603 | 603 | case 'TEXTAREA' : |
604 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
604 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
605 | 605 | break; |
606 | 606 | |
607 | 607 | case 'DROPDOWN' : |
608 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
608 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
609 | 609 | break; |
610 | 610 | |
611 | 611 | |
612 | 612 | case 'RADIO_BTN' : |
613 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
613 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
614 | 614 | break; |
615 | 615 | |
616 | 616 | case 'CHECKBOX' : |
617 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
617 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
618 | 618 | break; |
619 | 619 | |
620 | 620 | case 'DATE' : |
621 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
621 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
622 | 622 | break; |
623 | 623 | |
624 | 624 | case 'TEXT' : |
625 | 625 | default: |
626 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
626 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
627 | 627 | break; |
628 | 628 | |
629 | 629 | } |
@@ -649,31 +649,31 @@ discard block |
||
649 | 649 | * @param string $disabled disabled="disabled" or null |
650 | 650 | * @return string HTML |
651 | 651 | */ |
652 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
652 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
653 | 653 | // need these |
654 | - if ( ! $question || ! $name ) { |
|
654 | + if ( ! $question || ! $name) { |
|
655 | 655 | return NULL; |
656 | 656 | } |
657 | 657 | // prep the answer |
658 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
658 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
659 | 659 | // prep the required array |
660 | - $required = self::prep_required( $required ); |
|
660 | + $required = self::prep_required($required); |
|
661 | 661 | // set disabled tag |
662 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
662 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
663 | 663 | // ya gots ta have style man!!! |
664 | 664 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
665 | - $class = empty( $class ) ? $txt_class : $class; |
|
666 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
667 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
665 | + $class = empty($class) ? $txt_class : $class; |
|
666 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
667 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
668 | 668 | |
669 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
669 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
670 | 670 | // filter label but ensure required text comes before it |
671 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
671 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
672 | 672 | |
673 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
673 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
674 | 674 | |
675 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
676 | - return $label_html . $input_html; |
|
675 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
676 | + return $label_html.$input_html; |
|
677 | 677 | |
678 | 678 | } |
679 | 679 | |
@@ -695,35 +695,35 @@ discard block |
||
695 | 695 | * @param string $disabled disabled="disabled" or null |
696 | 696 | * @return string HTML |
697 | 697 | */ |
698 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
698 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
699 | 699 | // need these |
700 | - if ( ! $question || ! $name ) { |
|
700 | + if ( ! $question || ! $name) { |
|
701 | 701 | return NULL; |
702 | 702 | } |
703 | 703 | // prep the answer |
704 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
704 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
705 | 705 | // prep the required array |
706 | - $required = self::prep_required( $required ); |
|
706 | + $required = self::prep_required($required); |
|
707 | 707 | // make sure $dimensions is an array |
708 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
708 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
709 | 709 | // and set some defaults |
710 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
710 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
711 | 711 | // set disabled tag |
712 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
712 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
713 | 713 | // ya gots ta have style man!!! |
714 | 714 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
715 | - $class = empty( $class ) ? $txt_class : $class; |
|
716 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
717 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
715 | + $class = empty($class) ? $txt_class : $class; |
|
716 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
717 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
718 | 718 | |
719 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
719 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
720 | 720 | // filter label but ensure required text comes before it |
721 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
721 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
722 | 722 | |
723 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
723 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
724 | 724 | |
725 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
726 | - return $label_html . $input_html; |
|
725 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
726 | + return $label_html.$input_html; |
|
727 | 727 | |
728 | 728 | } |
729 | 729 | |
@@ -746,47 +746,47 @@ discard block |
||
746 | 746 | * @param string $disabled disabled="disabled" or null |
747 | 747 | * @return string HTML |
748 | 748 | */ |
749 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
749 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
750 | 750 | |
751 | 751 | // need these |
752 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
752 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
753 | 753 | return NULL; |
754 | 754 | } |
755 | 755 | // prep the answer |
756 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
756 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
757 | 757 | // prep the required array |
758 | - $required = self::prep_required( $required ); |
|
758 | + $required = self::prep_required($required); |
|
759 | 759 | // set disabled tag |
760 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
760 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
761 | 761 | // ya gots ta have style man!!! |
762 | 762 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
763 | - $class = empty( $class ) ? $txt_class : $class; |
|
764 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
765 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
763 | + $class = empty($class) ? $txt_class : $class; |
|
764 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
765 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
766 | 766 | |
767 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
767 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
768 | 768 | // filter label but ensure required text comes before it |
769 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
769 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
770 | 770 | |
771 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
771 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
772 | 772 | // recursively count array elements, to determine total number of options |
773 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
774 | - if ( ! $only_option ) { |
|
773 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
774 | + if ( ! $only_option) { |
|
775 | 775 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
776 | 776 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
777 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
777 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
778 | 778 | } |
779 | - foreach ( $options as $key => $value ) { |
|
779 | + foreach ($options as $key => $value) { |
|
780 | 780 | // if value is an array, then create option groups, else create regular ol' options |
781 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
781 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
782 | 782 | } |
783 | 783 | |
784 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
784 | + $input_html .= "\n\t\t\t".'</select>'; |
|
785 | 785 | |
786 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
786 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
787 | 787 | |
788 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
789 | - return $label_html . $input_html; |
|
788 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
789 | + return $label_html.$input_html; |
|
790 | 790 | |
791 | 791 | } |
792 | 792 | |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | * @param boolean $use_html_entities |
805 | 805 | * @return string |
806 | 806 | */ |
807 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
808 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
809 | - foreach ( $QSOs as $QSO ) { |
|
810 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
807 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
808 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
809 | + foreach ($QSOs as $QSO) { |
|
810 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
811 | 811 | } |
812 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
812 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
813 | 813 | return $html; |
814 | 814 | } |
815 | 815 | |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | * @param boolean $use_html_entities |
825 | 825 | * @return string |
826 | 826 | */ |
827 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
828 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
829 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
830 | - $value = ! empty( $value ) ? $value : $key; |
|
831 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
832 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
827 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
828 | + $key = self::prep_answer($key, $use_html_entities); |
|
829 | + $value = self::prep_answer($value, $use_html_entities); |
|
830 | + $value = ! empty($value) ? $value : $key; |
|
831 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
832 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -853,56 +853,56 @@ discard block |
||
853 | 853 | * @param bool $use_desc_4_label |
854 | 854 | * @return string HTML |
855 | 855 | */ |
856 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
856 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
857 | 857 | // need these |
858 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
858 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
859 | 859 | return NULL; |
860 | 860 | } |
861 | 861 | // prep the answer |
862 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
862 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
863 | 863 | // prep the required array |
864 | - $required = self::prep_required( $required ); |
|
864 | + $required = self::prep_required($required); |
|
865 | 865 | // set disabled tag |
866 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
866 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
867 | 867 | // ya gots ta have style man!!! |
868 | 868 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
869 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
870 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
869 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
870 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
871 | 871 | |
872 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
872 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
873 | 873 | // filter label but ensure required text comes before it |
874 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
874 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
875 | 875 | |
876 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
876 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
877 | 877 | |
878 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
879 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
878 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
879 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
880 | 880 | |
881 | - foreach ( $options as $OPT ) { |
|
882 | - if ( $OPT instanceof EE_Question_Option ) { |
|
883 | - $value = self::prep_option_value( $OPT->value() ); |
|
881 | + foreach ($options as $OPT) { |
|
882 | + if ($OPT instanceof EE_Question_Option) { |
|
883 | + $value = self::prep_option_value($OPT->value()); |
|
884 | 884 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
885 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
886 | - $desc = $OPT->desc();//no self::prep_answer |
|
887 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
888 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
889 | - $opt = '-' . sanitize_key( $value ); |
|
890 | - |
|
891 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
892 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
893 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
894 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
895 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
896 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
897 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
898 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
885 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
886 | + $desc = $OPT->desc(); //no self::prep_answer |
|
887 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
888 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
889 | + $opt = '-'.sanitize_key($value); |
|
890 | + |
|
891 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
892 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
893 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
894 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
895 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
896 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
897 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
898 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
902 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
903 | 903 | |
904 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
905 | - return $label_html . $input_html; |
|
904 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
905 | + return $label_html.$input_html; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -925,65 +925,65 @@ discard block |
||
925 | 925 | * @param string $disabled disabled="disabled" or null |
926 | 926 | * @return string HTML |
927 | 927 | */ |
928 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
928 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
929 | 929 | // need these |
930 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
930 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
931 | 931 | return NULL; |
932 | 932 | } |
933 | - $answer = maybe_unserialize( $answer ); |
|
933 | + $answer = maybe_unserialize($answer); |
|
934 | 934 | |
935 | 935 | // prep the answer(s) |
936 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
936 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
937 | 937 | |
938 | - foreach ( $answer as $key => $value ) { |
|
939 | - $key = self::prep_option_value( $key ); |
|
940 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
938 | + foreach ($answer as $key => $value) { |
|
939 | + $key = self::prep_option_value($key); |
|
940 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | // prep the required array |
944 | - $required = self::prep_required( $required ); |
|
944 | + $required = self::prep_required($required); |
|
945 | 945 | // set disabled tag |
946 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
946 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
947 | 947 | // ya gots ta have style man!!! |
948 | 948 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
949 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
950 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
949 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
950 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
951 | 951 | |
952 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
952 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
953 | 953 | // filter label but ensure required text comes before it |
954 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
955 | - |
|
956 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
957 | - |
|
958 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
959 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
960 | - |
|
961 | - foreach ( $options as $OPT ) { |
|
962 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
963 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
964 | - $text = self::prep_answer( $OPT->value() ); |
|
965 | - $desc = $OPT->desc() ; |
|
966 | - $opt = '-' . sanitize_key( $value ); |
|
967 | - |
|
968 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
969 | - |
|
970 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
971 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
972 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
973 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
974 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
975 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
976 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
977 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
954 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
955 | + |
|
956 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
957 | + |
|
958 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
959 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
960 | + |
|
961 | + foreach ($options as $OPT) { |
|
962 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
963 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
964 | + $text = self::prep_answer($OPT->value()); |
|
965 | + $desc = $OPT->desc(); |
|
966 | + $opt = '-'.sanitize_key($value); |
|
967 | + |
|
968 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
969 | + |
|
970 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
971 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
972 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
973 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
974 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
975 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
976 | + if ( ! empty($desc) && $desc != $text) { |
|
977 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
978 | 978 | } |
979 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
979 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
980 | 980 | |
981 | 981 | } |
982 | 982 | |
983 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
983 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
984 | 984 | |
985 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
986 | - return $label_html . $input_html; |
|
985 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
986 | + return $label_html.$input_html; |
|
987 | 987 | |
988 | 988 | } |
989 | 989 | |
@@ -1005,36 +1005,36 @@ discard block |
||
1005 | 1005 | * @param string $disabled disabled="disabled" or null |
1006 | 1006 | * @return string HTML |
1007 | 1007 | */ |
1008 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1008 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1009 | 1009 | // need these |
1010 | - if ( ! $question || ! $name ) { |
|
1010 | + if ( ! $question || ! $name) { |
|
1011 | 1011 | return NULL; |
1012 | 1012 | } |
1013 | 1013 | // prep the answer |
1014 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1014 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1015 | 1015 | // prep the required array |
1016 | - $required = self::prep_required( $required ); |
|
1016 | + $required = self::prep_required($required); |
|
1017 | 1017 | // set disabled tag |
1018 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1018 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1019 | 1019 | // ya gots ta have style man!!! |
1020 | 1020 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1021 | - $class = empty( $class ) ? $txt_class : $class; |
|
1022 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1023 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1021 | + $class = empty($class) ? $txt_class : $class; |
|
1022 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1023 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1024 | 1024 | |
1025 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1025 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1026 | 1026 | // filter label but ensure required text comes before it |
1027 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1027 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1028 | 1028 | |
1029 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1029 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1030 | 1030 | |
1031 | 1031 | // enqueue scripts |
1032 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1033 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1034 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1032 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1033 | + wp_enqueue_style('espresso-ui-theme'); |
|
1034 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1035 | 1035 | |
1036 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1037 | - return $label_html . $input_html; |
|
1036 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1037 | + return $label_html.$input_html; |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @access public |
1047 | 1047 | * @return string |
1048 | 1048 | */ |
1049 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1049 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1050 | 1050 | return $required_text; |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | * @param string $value |
1061 | 1061 | * @return string HTML |
1062 | 1062 | */ |
1063 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1064 | - $id = ! empty( $id ) ? $id : $name; |
|
1065 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1063 | + static function hidden_input($name, $value, $id = '') { |
|
1064 | + $id = ! empty($id) ? $id : $name; |
|
1065 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @param string $question |
1075 | 1075 | * @return string |
1076 | 1076 | */ |
1077 | - static function prep_question( $question ){ |
|
1077 | + static function prep_question($question) { |
|
1078 | 1078 | return $question; |
1079 | 1079 | // $link = ''; |
1080 | 1080 | // // does this label have a help link attached ? |
@@ -1097,13 +1097,13 @@ discard block |
||
1097 | 1097 | * @param mixed $answer |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1100 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1101 | 1101 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1102 | - if ( is_bool( $answer ) ) { |
|
1102 | + if (is_bool($answer)) { |
|
1103 | 1103 | $answer = $answer ? 1 : 0; |
1104 | 1104 | } |
1105 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1106 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1105 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1106 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | |
@@ -1113,18 +1113,18 @@ discard block |
||
1113 | 1113 | * @param array $QSOs array of EE_Question_Option objects |
1114 | 1114 | * @return array |
1115 | 1115 | */ |
1116 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1116 | + public static function prep_answer_options($QSOs = array()) { |
|
1117 | 1117 | $prepped_answer_options = array(); |
1118 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1119 | - foreach( $QSOs as $key => $QSO ) { |
|
1120 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1121 | - $QSO = EE_Question_Option::new_instance( array( |
|
1122 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1123 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1118 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1119 | + foreach ($QSOs as $key => $QSO) { |
|
1120 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1121 | + $QSO = EE_Question_Option::new_instance(array( |
|
1122 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1123 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1124 | 1124 | )); |
1125 | 1125 | } |
1126 | - if ( $QSO->opt_group() ) { |
|
1127 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1126 | + if ($QSO->opt_group()) { |
|
1127 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1128 | 1128 | } else { |
1129 | 1129 | $prepped_answer_options[] = $QSO; |
1130 | 1130 | } |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | * @param string $option_value |
1141 | 1141 | * @return string |
1142 | 1142 | */ |
1143 | - static function prep_option_value( $option_value ){ |
|
1144 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1143 | + static function prep_option_value($option_value) { |
|
1144 | + return esc_attr(trim(stripslashes($option_value))); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | * @param string|array $required |
1153 | 1153 | * @return array |
1154 | 1154 | */ |
1155 | - static function prep_required( $required = array() ){ |
|
1155 | + static function prep_required($required = array()) { |
|
1156 | 1156 | // make sure required is an array |
1157 | - $required = is_array( $required ) ? $required : array(); |
|
1157 | + $required = is_array($required) ? $required : array(); |
|
1158 | 1158 | // and set some defaults |
1159 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1159 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1160 | 1160 | return $required; |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1167,30 +1167,30 @@ discard block |
||
1167 | 1167 | * @param string $value |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | - static function get_label_size_class( $value = FALSE ){ |
|
1171 | - if ( $value === FALSE || $value == '' ) { |
|
1170 | + static function get_label_size_class($value = FALSE) { |
|
1171 | + if ($value === FALSE || $value == '') { |
|
1172 | 1172 | return ' class="medium-lbl"'; |
1173 | 1173 | } |
1174 | 1174 | // determine length of option value |
1175 | - $val_size = strlen( $value ); |
|
1176 | - switch( $val_size ){ |
|
1175 | + $val_size = strlen($value); |
|
1176 | + switch ($val_size) { |
|
1177 | 1177 | case $val_size < 3 : |
1178 | - $size = ' class="nano-lbl"'; |
|
1178 | + $size = ' class="nano-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 6 : |
1181 | - $size = ' class="micro-lbl"'; |
|
1181 | + $size = ' class="micro-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 12 : |
1184 | - $size = ' class="tiny-lbl"'; |
|
1184 | + $size = ' class="tiny-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size < 25 : |
1187 | - $size = ' class="small-lbl"'; |
|
1187 | + $size = ' class="small-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | case $val_size > 100 : |
1190 | - $size = ' class="big-lbl"'; |
|
1190 | + $size = ' class="big-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | default: |
1193 | - $size = ' class="medium-lbl"'; |
|
1193 | + $size = ' class="medium-lbl"'; |
|
1194 | 1194 | break; |
1195 | 1195 | } |
1196 | 1196 | return $size; |
@@ -1204,20 +1204,20 @@ discard block |
||
1204 | 1204 | * @param array $QFI |
1205 | 1205 | * @return array |
1206 | 1206 | */ |
1207 | - private static function _load_system_dropdowns( $QFI ){ |
|
1207 | + private static function _load_system_dropdowns($QFI) { |
|
1208 | 1208 | $QST_system = $QFI->get('QST_system'); |
1209 | - switch ( $QST_system ) { |
|
1209 | + switch ($QST_system) { |
|
1210 | 1210 | case 'state' : |
1211 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_state_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'country' : |
1214 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1214 | + $QFI = self::generate_country_dropdown($QFI); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-state' : |
1217 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | case 'admin-country' : |
1220 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1220 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1221 | 1221 | break; |
1222 | 1222 | } |
1223 | 1223 | return $QFI; |
@@ -1234,13 +1234,13 @@ discard block |
||
1234 | 1234 | * |
1235 | 1235 | * @return EE_Question_Form_Input |
1236 | 1236 | */ |
1237 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1238 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1237 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1238 | + switch ($QFI->get('QST_type')) { |
|
1239 | 1239 | case 'STATE' : |
1240 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_state_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | case 'COUNTRY' : |
1243 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1243 | + $QFI = self::generate_country_dropdown($QFI); |
|
1244 | 1244 | break; |
1245 | 1245 | } |
1246 | 1246 | return $QFI; |
@@ -1254,23 +1254,23 @@ discard block |
||
1254 | 1254 | * @param bool $get_all |
1255 | 1255 | * @return array |
1256 | 1256 | */ |
1257 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1257 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1258 | 1258 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1259 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1260 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1259 | + if ($states && count($states) != count($QST->options())) { |
|
1260 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1261 | 1261 | // if multiple countries, we'll create option groups within the dropdown |
1262 | - foreach ( $states as $state ) { |
|
1263 | - if ( $state instanceof EE_State ) { |
|
1264 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1262 | + foreach ($states as $state) { |
|
1263 | + if ($state instanceof EE_State) { |
|
1264 | + $QSO = EE_Question_Option::new_instance(array( |
|
1265 | 1265 | 'QSO_value' => $state->ID(), |
1266 | 1266 | 'QSO_desc' => $state->name(), |
1267 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1267 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1268 | 1268 | 'QSO_deleted' => FALSE |
1269 | 1269 | )); |
1270 | 1270 | // set option group |
1271 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1271 | + $QSO->set_opt_group($state->country()->name()); |
|
1272 | 1272 | // add option to question |
1273 | - $QST->add_temp_option( $QSO ); |
|
1273 | + $QST->add_temp_option($QSO); |
|
1274 | 1274 | } |
1275 | 1275 | } |
1276 | 1276 | } |
@@ -1286,20 +1286,20 @@ discard block |
||
1286 | 1286 | * @internal param array $question |
1287 | 1287 | * @return array |
1288 | 1288 | */ |
1289 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1289 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1290 | 1290 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1291 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1292 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1291 | + if ($countries && count($countries) != count($QST->options())) { |
|
1292 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1293 | 1293 | // now add countries |
1294 | - foreach ( $countries as $country ) { |
|
1295 | - if ( $country instanceof EE_Country ) { |
|
1296 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1294 | + foreach ($countries as $country) { |
|
1295 | + if ($country instanceof EE_Country) { |
|
1296 | + $QSO = EE_Question_Option::new_instance(array( |
|
1297 | 1297 | 'QSO_value' => $country->ID(), |
1298 | 1298 | 'QSO_desc' => $country->name(), |
1299 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1299 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1300 | 1300 | 'QSO_deleted' => FALSE |
1301 | 1301 | )); |
1302 | - $QST->add_temp_option( $QSO ); |
|
1302 | + $QST->add_temp_option($QSO); |
|
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | } |
@@ -1316,11 +1316,11 @@ discard block |
||
1316 | 1316 | */ |
1317 | 1317 | public static function two_digit_months_dropdown_options() { |
1318 | 1318 | $options = array(); |
1319 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1320 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1321 | - $options[ (string)$mm ] = (string)$mm; |
|
1319 | + for ($x = 1; $x <= 12; $x++) { |
|
1320 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1321 | + $options[(string) $mm] = (string) $mm; |
|
1322 | 1322 | } |
1323 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1323 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | |
@@ -1335,11 +1335,11 @@ discard block |
||
1335 | 1335 | $options = array(); |
1336 | 1336 | $current_year = date('y'); |
1337 | 1337 | $next_decade = $current_year + 10; |
1338 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1339 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1340 | - $options[ (string)$yy ] = (string)$yy; |
|
1338 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1339 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1340 | + $options[(string) $yy] = (string) $yy; |
|
1341 | 1341 | } |
1342 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1342 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | |
@@ -1353,17 +1353,17 @@ discard block |
||
1353 | 1353 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1354 | 1354 | * @return string html |
1355 | 1355 | */ |
1356 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1356 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1357 | 1357 | $_where = array(); |
1358 | - if ( !empty( $status ) ) { |
|
1358 | + if ( ! empty($status)) { |
|
1359 | 1359 | $_where['STS_ID'] = $status; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if ( $evt_category > 0 ) { |
|
1362 | + if ($evt_category > 0) { |
|
1363 | 1363 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1366 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1367 | 1367 | |
1368 | 1368 | //setup vals for select input helper |
1369 | 1369 | $options = array( |
@@ -1373,15 +1373,15 @@ discard block |
||
1373 | 1373 | ) |
1374 | 1374 | ); |
1375 | 1375 | |
1376 | - foreach ( $regdtts as $regdtt ) { |
|
1377 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1376 | + foreach ($regdtts as $regdtt) { |
|
1377 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1378 | 1378 | $options[] = array( |
1379 | 1379 | 'text' => $date, |
1380 | 1380 | 'id' => $date |
1381 | 1381 | ); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1384 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | |
@@ -1395,18 +1395,18 @@ discard block |
||
1395 | 1395 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1396 | 1396 | * @return string html |
1397 | 1397 | */ |
1398 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1398 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1399 | 1399 | //determine what post_status our condition will have for the query. |
1400 | - switch ( $status ) { |
|
1400 | + switch ($status) { |
|
1401 | 1401 | case 'month' : |
1402 | 1402 | case 'today' : |
1403 | 1403 | case NULL : |
1404 | 1404 | case 'all' : |
1405 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1405 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1406 | 1406 | break; |
1407 | 1407 | |
1408 | 1408 | case 'draft' : |
1409 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1409 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1410 | 1410 | |
1411 | 1411 | default : |
1412 | 1412 | $where['Event.status'] = $status; |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | //categories? |
1416 | 1416 | |
1417 | 1417 | |
1418 | - if ( !empty ( $evt_category ) ) { |
|
1418 | + if ( ! empty ($evt_category)) { |
|
1419 | 1419 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1420 | 1420 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1421 | 1421 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | |
1424 | 1424 | // $where['DTT_is_primary'] = 1; |
1425 | 1425 | |
1426 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1426 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1427 | 1427 | |
1428 | 1428 | //let's setup vals for select input helper |
1429 | 1429 | $options = array( |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | //translate month and date |
1439 | 1439 | global $wp_locale; |
1440 | 1440 | |
1441 | - foreach ( $DTTS as $DTT ) { |
|
1442 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1443 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1441 | + foreach ($DTTS as $DTT) { |
|
1442 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1443 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1444 | 1444 | $options[] = array( |
1445 | 1445 | 'text' => $localized_date, |
1446 | 1446 | 'id' => $id |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | |
1451 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1451 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | * @param integer $current_cat currently selected category |
1460 | 1460 | * @return string html for dropdown |
1461 | 1461 | */ |
1462 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1462 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1463 | 1463 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1464 | 1464 | $options = array( |
1465 | 1465 | '0' => array( |
@@ -1469,14 +1469,14 @@ discard block |
||
1469 | 1469 | ); |
1470 | 1470 | |
1471 | 1471 | //setup categories for dropdown |
1472 | - foreach ( $categories as $category ) { |
|
1472 | + foreach ($categories as $category) { |
|
1473 | 1473 | $options[] = array( |
1474 | 1474 | 'text' => $category->get('name'), |
1475 | 1475 | 'id' => $category->ID() |
1476 | 1476 | ); |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1479 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | |
@@ -1495,20 +1495,20 @@ discard block |
||
1495 | 1495 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1496 | 1496 | * @return void |
1497 | 1497 | */ |
1498 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1498 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1499 | 1499 | $btn = ''; |
1500 | - if ( empty( $url ) || empty( $ID )) { |
|
1500 | + if (empty($url) || empty($ID)) { |
|
1501 | 1501 | return $btn; |
1502 | 1502 | } |
1503 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1504 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1505 | - if ( ! $input_only ) { |
|
1506 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1507 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1503 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1504 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1505 | + if ( ! $input_only) { |
|
1506 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1507 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1508 | 1508 | $btn_frm .= $btn; |
1509 | 1509 | $btn_frm .= '</form>'; |
1510 | 1510 | $btn = $btn_frm; |
1511 | - unset ( $btn_frm ); |
|
1511 | + unset ($btn_frm); |
|
1512 | 1512 | } |
1513 | 1513 | return $btn; |
1514 | 1514 | } |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @param mixed $opt_group |
799 | 799 | * @param mixed $QSOs |
800 | - * @param mixed $answer |
|
800 | + * @param string $answer |
|
801 | 801 | * @param boolean $use_html_entities |
802 | 802 | * @return string |
803 | 803 | */ |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | /** |
1148 | 1148 | * prep_required |
1149 | 1149 | * @param string|array $required |
1150 | - * @return array |
|
1150 | + * @return string |
|
1151 | 1151 | */ |
1152 | 1152 | static function prep_required( $required = array() ){ |
1153 | 1153 | // make sure required is an array |
@@ -1198,8 +1198,8 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | /** |
1200 | 1200 | * _load_system_dropdowns |
1201 | - * @param array $QFI |
|
1202 | - * @return array |
|
1201 | + * @param EE_Question_Form_Input $QFI |
|
1202 | + * @return EE_Question_Form_Input |
|
1203 | 1203 | */ |
1204 | 1204 | private static function _load_system_dropdowns( $QFI ){ |
1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | * @param string $nonce_action - if using nonces |
1491 | 1491 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1493 | - * @return void |
|
1493 | + * @return string |
|
1494 | 1494 | */ |
1495 | 1495 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1496 | 1496 | $btn = ''; |