@@ -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 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @author Mike Nelson |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Restriction_Generator_Reg_Form extends EE_Restriction_Generator_Base{ |
|
18 | +class EE_Restriction_Generator_Reg_Form extends EE_Restriction_Generator_Base { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
28 | 28 | * @param string $system_field_name |
29 | 29 | */ |
30 | - public function __construct( $system_field_name ) { |
|
30 | + public function __construct($system_field_name) { |
|
31 | 31 | $this->_system_field_name = $system_field_name; |
32 | 32 | } |
33 | 33 | |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | protected function _generate_restrictions() { |
41 | 41 | //if there are no standard caps for this model, then for now all we know |
42 | 42 | //if they need the default cap to access this |
43 | - if( ! $this->model()->cap_slug() ) { |
|
43 | + if ( ! $this->model()->cap_slug()) { |
|
44 | 44 | return array( |
45 | 45 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
46 | 46 | ); |
47 | 47 | } |
48 | 48 | return array( |
49 | - EE_Restriction_Generator_Base::get_cap_name( $this->model(), $this->action() ) => new EE_Return_None_Where_Conditions(), |
|
50 | - EE_Restriction_Generator_Base::get_cap_name( $this->model(), $this->action() . '_system' ) => new EE_Default_Where_Conditions( |
|
49 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
50 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_system') => new EE_Default_Where_Conditions( |
|
51 | 51 | array( |
52 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name( $this->model(), $this->action() . '_system' ) => array( |
|
53 | - $this->_system_field_name => array( 'IN', array( '', 0 ) ), |
|
54 | - $this->_system_field_name . '*' => array( 'IS_NULL' ) |
|
52 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_system') => array( |
|
53 | + $this->_system_field_name => array('IN', array('', 0)), |
|
54 | + $this->_system_field_name.'*' => array('IS_NULL') |
|
55 | 55 | ) |
56 | 56 | ) |
57 | 57 | ) |
@@ -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 | * |
15 | 15 | */ |
16 | -class EE_Restriction_Generator_Taxonomy_Protected extends EE_Restriction_Generator_Base{ |
|
16 | +class EE_Restriction_Generator_Taxonomy_Protected extends EE_Restriction_Generator_Base { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Model chain/path to taxonomy model, including the term_taxonomy model itself |
@@ -24,28 +24,28 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself |
26 | 26 | */ |
27 | - public function __construct( $path_to_taxonomy_model ){ |
|
28 | - if( $path_to_taxonomy_model !== '' && substr( $path_to_taxonomy_model, -1, 1 ) != '.' ) { |
|
27 | + public function __construct($path_to_taxonomy_model) { |
|
28 | + if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') { |
|
29 | 29 | $path_to_taxonomy_model .= '.'; |
30 | 30 | } |
31 | 31 | $this->_path_to_taxonomy_model = $path_to_taxonomy_model; |
32 | 32 | } |
33 | 33 | protected function _generate_restrictions() { |
34 | 34 | //if there are no standard caps for this model, then for allow full access |
35 | - if( ! $this->model()->cap_slug() ) { |
|
35 | + if ( ! $this->model()->cap_slug()) { |
|
36 | 36 | return array( |
37 | 37 | ); |
38 | 38 | } |
39 | 39 | |
40 | 40 | return array( |
41 | - 'ee_manage_event_categories' => new EE_Default_Where_Conditions( array( |
|
42 | - $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' ) |
|
41 | + 'ee_manage_event_categories' => new EE_Default_Where_Conditions(array( |
|
42 | + $this->_path_to_taxonomy_model.'taxonomy*no_ee_manage_event_categories' => array('!=', 'espresso_event_categories') |
|
43 | 43 | )), |
44 | - 'ee_manage_venue_categories' => new EE_Default_Where_Conditions( array( |
|
45 | - $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' ) |
|
44 | + 'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array( |
|
45 | + $this->_path_to_taxonomy_model.'taxonomy*no_ee_manage_venue_categories' => array('!=', 'espresso_venue_categories') |
|
46 | 46 | )), |
47 | - 'ee_manage_event_types' => new EE_Default_Where_Conditions( array( |
|
48 | - $this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' ) |
|
47 | + 'ee_manage_event_types' => new EE_Default_Where_Conditions(array( |
|
48 | + $this->_path_to_taxonomy_model.'taxonomy*ee_manage_event_types' => array('!=', 'espresso_event_types') |
|
49 | 49 | )), |
50 | 50 | ); |
51 | 51 | } |
@@ -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 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @author Mike Nelson |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Restriction_Generator_WP_User extends EE_Restriction_Generator_Base{ |
|
18 | +class EE_Restriction_Generator_WP_User extends EE_Restriction_Generator_Base { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return \EE_Default_Where_Conditions |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | return array( |
26 | 26 | //if they can't access users, they can still access themselves |
27 | - EE_Restriction_Generator_Base::get_cap_name( $this->model(), $this->action() ) => new EE_Default_Where_Conditions( array( |
|
27 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Default_Where_Conditions(array( |
|
28 | 28 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
29 | 29 | )), |
30 | 30 |
@@ -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 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -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 | /** |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @param array $array |
37 | 37 | * @return boolean |
38 | 38 | */ |
39 | - public static function is_associative_array( array $array ) { |
|
40 | - return array_keys( $array ) !== range( 0, count( $array ) - 1 ); |
|
39 | + public static function is_associative_array(array $array) { |
|
40 | + return array_keys($array) !== range(0, count($array) - 1); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param array $arr |
47 | 47 | * @return mixed what ever is in the array |
48 | 48 | */ |
49 | - public static function get_one_item_from_array($arr){ |
|
49 | + public static function get_one_item_from_array($arr) { |
|
50 | 50 | $item = end($arr); |
51 | 51 | reset($arr); |
52 | 52 | return $item; |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * @param mixed $arr |
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | - public static function is_multi_dimensional_array($arr){ |
|
61 | - if(is_array($arr)){ |
|
60 | + public static function is_multi_dimensional_array($arr) { |
|
61 | + if (is_array($arr)) { |
|
62 | 62 | $first_item = reset($arr); |
63 | - if(is_array($first_item)){ |
|
64 | - return true;//yep, there's at least 2 levels to this array |
|
65 | - }else{ |
|
66 | - return false;//nope, only 1 level |
|
63 | + if (is_array($first_item)) { |
|
64 | + return true; //yep, there's at least 2 levels to this array |
|
65 | + } else { |
|
66 | + return false; //nope, only 1 level |
|
67 | 67 | } |
68 | - }else{ |
|
69 | - return false;//its not an array at all! |
|
68 | + } else { |
|
69 | + return false; //its not an array at all! |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param mixed $default |
78 | 78 | * @return mixed |
79 | 79 | */ |
80 | - public static function is_set( $arr, $index, $default ) { |
|
81 | - return isset( $arr[ $index ] ) ? $arr[ $index ] : $default; |
|
80 | + public static function is_set($arr, $index, $default) { |
|
81 | + return isset($arr[$index]) ? $arr[$index] : $default; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * @param mixed $value usually a string, but could be an array or object |
87 | 87 | * @return mixed the UN-serialized data |
88 | 88 | */ |
89 | - public static function maybe_unserialize( $value ) { |
|
89 | + public static function maybe_unserialize($value) { |
|
90 | 90 | $data = maybe_unserialize($value); |
91 | 91 | //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. |
92 | 92 | $token = 'C'; |
93 | 93 | $data = is_string($data) ? trim($data) : $data; |
94 | - if ( is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match( "/^{$token}:[0-9]+:/s", $data ) ) { |
|
94 | + if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
95 | 95 | return unserialize($data); |
96 | 96 | } else { |
97 | 97 | return $data; |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public static function insert_into_array( $target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true ) { |
|
113 | + public static function insert_into_array($target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true) { |
|
114 | 114 | // ensure incoming arrays are actually arrays |
115 | - $target_array = (array)$target_array; |
|
116 | - $array_to_insert = (array)$array_to_insert; |
|
115 | + $target_array = (array) $target_array; |
|
116 | + $array_to_insert = (array) $array_to_insert; |
|
117 | 117 | // if no offset key was supplied |
118 | - if ( empty( $offset )) { |
|
118 | + if (empty($offset)) { |
|
119 | 119 | // use start or end of $target_array based on whether we are adding before or not |
120 | - $offset = $add_before ? 0 : count( $target_array ); |
|
120 | + $offset = $add_before ? 0 : count($target_array); |
|
121 | 121 | } |
122 | 122 | // if offset key is a string, then find the corresponding numeric location for that element |
123 | - $offset = is_int( $offset ) ? $offset : array_search( $offset, array_keys( $target_array ) ); |
|
123 | + $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array)); |
|
124 | 124 | // add one to the offset if adding after |
125 | 125 | $offset = $add_before ? $offset : $offset + 1; |
126 | 126 | // but ensure offset does not exceed the length of the array |
127 | - $offset = $offset > count( $target_array ) ? count( $target_array ) : $offset; |
|
127 | + $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
128 | 128 | // reindex array ??? |
129 | - if ( $preserve_keys ) { |
|
129 | + if ($preserve_keys) { |
|
130 | 130 | // take a slice of the target array from the beginning till the offset, |
131 | 131 | // then add the new data |
132 | 132 | // then add another slice that starts at the offset and goes till the end |
133 | - return array_slice( $target_array, 0, $offset, true ) + $array_to_insert + array_slice( $target_array, $offset, null, true ); |
|
133 | + return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice($target_array, $offset, null, true); |
|
134 | 134 | } else { |
135 | 135 | // since we don't want to preserve keys, we can use array_splice |
136 | - array_splice( $target_array, $offset, 0, $array_to_insert ); |
|
136 | + array_splice($target_array, $offset, 0, $array_to_insert); |
|
137 | 137 | return $target_array; |
138 | 138 | } |
139 | 139 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param array $array2 |
152 | 152 | * @return array |
153 | 153 | */ |
154 | - public static function merge_arrays_and_overwrite_keys( array $array1, array $array2 ) { |
|
155 | - foreach ( $array2 as $key => $value ) { |
|
156 | - $array1[ $key ] = $value; |
|
154 | + public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) { |
|
155 | + foreach ($array2 as $key => $value) { |
|
156 | + $array1[$key] = $value; |
|
157 | 157 | } |
158 | 158 | return $array1; |
159 | 159 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @param mixed $final_value |
172 | 172 | * @return array |
173 | 173 | */ |
174 | - public static function convert_array_values_to_keys( array $flat_array, $final_value = null ) { |
|
174 | + public static function convert_array_values_to_keys(array $flat_array, $final_value = null) { |
|
175 | 175 | $multidimensional = array(); |
176 | 176 | $reference = &$multidimensional; |
177 | - foreach ( $flat_array as $key ) { |
|
178 | - $reference[ $key ] = array(); |
|
179 | - $reference = &$reference[ $key ]; |
|
177 | + foreach ($flat_array as $key) { |
|
178 | + $reference[$key] = array(); |
|
179 | + $reference = &$reference[$key]; |
|
180 | 180 | } |
181 | - if ( $final_value !== null ) { |
|
181 | + if ($final_value !== null) { |
|
182 | 182 | $reference = $final_value; |
183 | 183 | } |
184 | 184 | return $multidimensional; |
@@ -23,10 +23,10 @@ |
||
23 | 23 | private static $_instance = NULL; |
24 | 24 | |
25 | 25 | /** |
26 | - * $_autoloaders |
|
27 | - * @var array $_autoloaders |
|
28 | - * @access private |
|
29 | - */ |
|
26 | + * $_autoloaders |
|
27 | + * @var array $_autoloaders |
|
28 | + * @access private |
|
29 | + */ |
|
30 | 30 | private static $_autoloaders; |
31 | 31 | |
32 | 32 |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -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 | /** |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @return \EEH_Autoloader |
51 | 51 | */ |
52 | 52 | private function __construct() { |
53 | - if ( self::$_autoloaders === null ) { |
|
53 | + if (self::$_autoloaders === null) { |
|
54 | 54 | self::$_autoloaders = array(); |
55 | 55 | $this->_register_custom_autoloaders(); |
56 | - spl_autoload_register( array( $this, 'espresso_autoloader' ) ); |
|
56 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public static function instance() { |
67 | 67 | // check if class object is instantiated |
68 | - if ( ! self::$_instance instanceof EEH_Autoloader ) { |
|
68 | + if ( ! self::$_instance instanceof EEH_Autoloader) { |
|
69 | 69 | self::$_instance = new self(); |
70 | 70 | } |
71 | 71 | return self::$_instance; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @internal param string $class_name - simple class name ie: session |
83 | 83 | * @return void |
84 | 84 | */ |
85 | - public static function espresso_autoloader( $class_name ) { |
|
86 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
87 | - require_once( self::$_autoloaders[ $class_name ] ); |
|
85 | + public static function espresso_autoloader($class_name) { |
|
86 | + if (isset(self::$_autoloaders[$class_name])) { |
|
87 | + require_once(self::$_autoloaders[$class_name]); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -99,26 +99,26 @@ discard block |
||
99 | 99 | * @param bool $debug **deprecated** |
100 | 100 | * @throws \EE_Error |
101 | 101 | */ |
102 | - public static function register_autoloader( $class_paths, $read_check = true, $debug = false ) { |
|
103 | - $class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths ); |
|
104 | - foreach ( $class_paths as $class => $path ) { |
|
102 | + public static function register_autoloader($class_paths, $read_check = true, $debug = false) { |
|
103 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
104 | + foreach ($class_paths as $class => $path) { |
|
105 | 105 | // don't give up! you gotta... |
106 | 106 | // get some class |
107 | - if ( empty( $class )) { |
|
108 | - throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path )); |
|
107 | + if (empty($class)) { |
|
108 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
109 | 109 | } |
110 | 110 | // one day you will find the path young grasshopper |
111 | - if ( empty( $path )) { |
|
112 | - throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class )); |
|
111 | + if (empty($path)) { |
|
112 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
113 | 113 | } |
114 | 114 | // is file readable ? |
115 | - if ( $read_check && ! is_readable( $path )) { |
|
116 | - 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 )); |
|
115 | + if ($read_check && ! is_readable($path)) { |
|
116 | + 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)); |
|
117 | 117 | } |
118 | - if ( ! isset( self::$_autoloaders[ $class ] )) { |
|
119 | - self::$_autoloaders[ $class ] = str_replace( array( '/', '\\' ), DS, $path ); |
|
120 | - if ( EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug ) ) { |
|
121 | - EEH_Debug_Tools::printr( self::$_autoloaders[ $class ], $class, __FILE__, __LINE__ ); |
|
118 | + if ( ! isset(self::$_autoloaders[$class])) { |
|
119 | + self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path); |
|
120 | + if (EE_DEBUG && (EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug)) { |
|
121 | + EEH_Debug_Tools::printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | private function _register_custom_autoloaders() { |
150 | 150 | EEH_Autoloader::$debug = ''; |
151 | 151 | \EEH_Autoloader::register_helpers_autoloaders(); |
152 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'interfaces' ); |
|
153 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE ); |
|
154 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_INTERFACES, true ); |
|
155 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, true ); |
|
156 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES ); |
|
157 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
158 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'messages' ); |
|
159 | - if ( EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' ) { |
|
152 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces'); |
|
153 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
154 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
155 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
156 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
157 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
158 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'messages'); |
|
159 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
160 | 160 | EEH_Debug_Tools::instance()->show_times(); |
161 | 161 | } |
162 | 162 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @access public |
170 | 170 | */ |
171 | 171 | public static function register_helpers_autoloaders() { |
172 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
172 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return void |
196 | 196 | */ |
197 | 197 | public static function register_line_item_display_autoloaders() { |
198 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_display' , true ); |
|
198 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return void |
209 | 209 | */ |
210 | 210 | public static function register_line_item_filter_autoloaders() { |
211 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_filters' , true ); |
|
211 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | */ |
223 | 223 | public static function register_template_part_autoloaders() { |
224 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'template_parts', true ); |
|
224 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'template_parts', true); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -238,35 +238,35 @@ discard block |
||
238 | 238 | * @param bool $debug **deprecated** |
239 | 239 | * @throws \EE_Error |
240 | 240 | */ |
241 | - public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = false, $debug = false ){ |
|
242 | - if ( EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug ) { |
|
243 | - EEH_Debug_Tools::instance()->start_timer( basename( $folder ) ); |
|
241 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) { |
|
242 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug) { |
|
243 | + EEH_Debug_Tools::instance()->start_timer(basename($folder)); |
|
244 | 244 | } |
245 | 245 | // make sure last char is a / |
246 | - $folder .= $folder[strlen($folder)-1] !== DS ? DS : ''; |
|
246 | + $folder .= $folder[strlen($folder) - 1] !== DS ? DS : ''; |
|
247 | 247 | $class_to_filepath_map = array(); |
248 | - $exclude = array( 'index' ); |
|
248 | + $exclude = array('index'); |
|
249 | 249 | //get all the files in that folder that end in php |
250 | - $filepaths = glob( $folder.'*'); |
|
250 | + $filepaths = glob($folder.'*'); |
|
251 | 251 | |
252 | - if ( empty( $filepaths ) ) { |
|
252 | + if (empty($filepaths)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | - foreach( $filepaths as $filepath ) { |
|
257 | - if ( substr( $filepath, -4, 4 ) === '.php' ) { |
|
258 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath ); |
|
259 | - if ( ! in_array( $class_name, $exclude )) { |
|
260 | - $class_to_filepath_map [ $class_name ] = $filepath; |
|
256 | + foreach ($filepaths as $filepath) { |
|
257 | + if (substr($filepath, -4, 4) === '.php') { |
|
258 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
259 | + if ( ! in_array($class_name, $exclude)) { |
|
260 | + $class_to_filepath_map [$class_name] = $filepath; |
|
261 | 261 | } |
262 | - } else if ( $recursive ) { |
|
263 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive, $debug ); |
|
262 | + } else if ($recursive) { |
|
263 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | // 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. |
267 | - self::register_autoloader( $class_to_filepath_map, false, $debug ); |
|
268 | - if ( EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' ) { |
|
269 | - EEH_Debug_Tools::instance()->stop_timer( basename( $folder ) ); |
|
267 | + self::register_autoloader($class_to_filepath_map, false, $debug); |
|
268 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
269 | + EEH_Debug_Tools::instance()->stop_timer(basename($folder)); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * @param string $class_name - simple class name ie: EE_Session |
281 | 281 | * @param string $alias - variation on class name ie: EE_session, session, etc |
282 | 282 | */ |
283 | - public static function add_alias( $class_name, $alias ) { |
|
284 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
285 | - self::$_autoloaders[ $alias ] = self::$_autoloaders[ $class_name ]; |
|
283 | + public static function add_alias($class_name, $alias) { |
|
284 | + if (isset(self::$_autoloaders[$class_name])) { |
|
285 | + self::$_autoloaders[$alias] = self::$_autoloaders[$class_name]; |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 |
@@ -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 | |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * @return int seconds offset |
128 | 128 | */ |
129 | 129 | public static function get_site_timezone_gmt_offset() { |
130 | - $timezone_string = get_option( 'timezone_string' ); |
|
131 | - if ( $timezone_string ) { |
|
130 | + $timezone_string = get_option('timezone_string'); |
|
131 | + if ($timezone_string) { |
|
132 | 132 | try { |
133 | - $timezone = new DateTimeZone( $timezone_string ); |
|
134 | - return $timezone->getOffset( new DateTime() ); //in WordPress DateTime defaults to UTC |
|
135 | - } catch( Exception $e ){} |
|
133 | + $timezone = new DateTimeZone($timezone_string); |
|
134 | + return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
135 | + } catch (Exception $e) {} |
|
136 | 136 | } |
137 | - $offset = get_option( 'gmt_offset' ); |
|
138 | - return (int) ( $offset * HOUR_IN_SECONDS ); |
|
137 | + $offset = get_option('gmt_offset'); |
|
138 | + return (int) ($offset * HOUR_IN_SECONDS); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @param int $gmt_offset |
148 | 148 | * @return int |
149 | 149 | */ |
150 | - public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) { |
|
150 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) { |
|
151 | 151 | //make sure $gmt_offset is int |
152 | 152 | $gmt_offset = (int) $gmt_offset; |
153 | - switch ( $gmt_offset ) { |
|
153 | + switch ($gmt_offset) { |
|
154 | 154 | |
155 | 155 | // case -30600 : |
156 | 156 | // $gmt_offset = -28800; |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | * @return string |
203 | 203 | * @throws \EE_Error |
204 | 204 | */ |
205 | - public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) { |
|
205 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) { |
|
206 | 206 | $abbreviations = timezone_abbreviations_list(); |
207 | - foreach ( $abbreviations as $abbreviation ) { |
|
208 | - foreach ( $abbreviation as $city ) { |
|
209 | - if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) { |
|
207 | + foreach ($abbreviations as $abbreviation) { |
|
208 | + foreach ($abbreviation as $city) { |
|
209 | + if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) { |
|
210 | 210 | // check if the timezone is valid but don't throw any errors if it isn't |
211 | - if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) { |
|
211 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
212 | 212 | return $city['timezone_id']; |
213 | 213 | } |
214 | 214 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | throw new EE_Error( |
218 | 218 | sprintf( |
219 | - __( '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' ), |
|
219 | + __('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'), |
|
220 | 220 | $gmt_offset, |
221 | 221 | '<a href="http://www.php.net/manual/en/timezones.php">', |
222 | 222 | '</a>' |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @access public |
231 | 231 | * @param string $timezone_string |
232 | 232 | */ |
233 | - public static function timezone_select_input( $timezone_string = '' ) { |
|
233 | + public static function timezone_select_input($timezone_string = '') { |
|
234 | 234 | // get WP date time format |
235 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
235 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
236 | 236 | // if passed a value, then use that, else get WP option |
237 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
237 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
238 | 238 | // check if the timezone is valid but don't throw any errors if it isn't |
239 | - $timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false ); |
|
239 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
240 | 240 | $gmt_offset = get_option('gmt_offset'); |
241 | 241 | |
242 | 242 | $check_zone_info = true; |
243 | - if ( empty( $timezone_string )) { |
|
243 | + if (empty($timezone_string)) { |
|
244 | 244 | // Create a UTC+- zone if no timezone string exists |
245 | 245 | $check_zone_info = false; |
246 | - if ( $gmt_offset > 0 ) { |
|
247 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
248 | - } elseif ( $gmt_offset < 0 ) { |
|
249 | - $timezone_string = 'UTC' . $gmt_offset; |
|
246 | + if ($gmt_offset > 0) { |
|
247 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
248 | + } elseif ($gmt_offset < 0) { |
|
249 | + $timezone_string = 'UTC'.$gmt_offset; |
|
250 | 250 | } else { |
251 | 251 | $timezone_string = 'UTC'; |
252 | 252 | } |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | __('%1$sUTC%2$s time is %3$s'), |
269 | 269 | '<abbr title="Coordinated Universal Time">', |
270 | 270 | '</abbr>', |
271 | - '<code>' . date_i18n( $datetime_format , false, 'gmt') . '</code>' |
|
271 | + '<code>'.date_i18n($datetime_format, false, 'gmt').'</code>' |
|
272 | 272 | ); |
273 | 273 | ?></span> |
274 | - <?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?> |
|
275 | - <br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span> |
|
274 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
275 | + <br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
276 | 276 | <?php endif; ?> |
277 | 277 | |
278 | 278 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -304,10 +304,9 @@ discard block |
||
304 | 304 | |
305 | 305 | if ($found) { |
306 | 306 | $message = $tr['isdst'] ? |
307 | - __(' Daylight saving time begins on: %s.' ) : |
|
308 | - __(' Standard time begins on: %s.'); |
|
307 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
309 | 308 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
310 | - printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' ); |
|
309 | + printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
311 | 310 | } else { |
312 | 311 | _e('This timezone does not observe daylight saving time.'); |
313 | 312 | } |
@@ -337,14 +336,14 @@ discard block |
||
337 | 336 | * |
338 | 337 | * @return int $unix_timestamp with the offset applied for the given timezone. |
339 | 338 | */ |
340 | - public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) { |
|
339 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') { |
|
341 | 340 | $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
342 | - $timezone_string = self::get_valid_timezone_string( $timezone_string ); |
|
343 | - $TimeZone = new DateTimeZone( $timezone_string ); |
|
341 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
342 | + $TimeZone = new DateTimeZone($timezone_string); |
|
344 | 343 | |
345 | - $DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone ); |
|
346 | - $offset = timezone_offset_get( $TimeZone, $DateTime ); |
|
347 | - return (int)$DateTime->format( 'U' ) + (int)$offset; |
|
344 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
345 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
346 | + return (int) $DateTime->format('U') + (int) $offset; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | |
@@ -359,17 +358,17 @@ discard block |
||
359 | 358 | * @param string $datetime_field_name the datetime fieldname to be manipulated |
360 | 359 | * @return EE_Base_Class |
361 | 360 | */ |
362 | - protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) { |
|
361 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) { |
|
363 | 362 | // grab current datetime format |
364 | 363 | $current_format = $obj->get_format(); |
365 | 364 | // set new full timestamp format |
366 | - $obj->set_date_format( EE_Datetime_Field::mysql_date_format ); |
|
367 | - $obj->set_time_format( EE_Datetime_Field::mysql_time_format ); |
|
365 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
366 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
368 | 367 | // set the new date value using a full timestamp format so that no data is lost |
369 | - $obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) ); |
|
368 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
370 | 369 | // reset datetime formats |
371 | - $obj->set_date_format( $current_format[0] ); |
|
372 | - $obj->set_time_format( $current_format[1] ); |
|
370 | + $obj->set_date_format($current_format[0]); |
|
371 | + $obj->set_time_format($current_format[1]); |
|
373 | 372 | return $obj; |
374 | 373 | } |
375 | 374 | |
@@ -386,11 +385,11 @@ discard block |
||
386 | 385 | * @param integer $value what you want to increment the time by |
387 | 386 | * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it (chaining) |
388 | 387 | */ |
389 | - public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
388 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
390 | 389 | //get the raw UTC date. |
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 ); |
|
390 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
391 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
392 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
394 | 393 | } |
395 | 394 | |
396 | 395 | |
@@ -405,11 +404,11 @@ discard block |
||
405 | 404 | * @param int $value |
406 | 405 | * @return \EE_Base_Class |
407 | 406 | */ |
408 | - public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
407 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
409 | 408 | //get the raw UTC date |
410 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
411 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' ); |
|
412 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
409 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
410 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
411 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
413 | 412 | } |
414 | 413 | |
415 | 414 | |
@@ -422,44 +421,44 @@ discard block |
||
422 | 421 | * @return \DateTime return whatever type came in. |
423 | 422 | * @throws \EE_Error |
424 | 423 | */ |
425 | - protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) { |
|
426 | - if ( ! $DateTime instanceof DateTime ) { |
|
424 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') { |
|
425 | + if ( ! $DateTime instanceof DateTime) { |
|
427 | 426 | throw new EE_Error( |
428 | 427 | sprintf( |
429 | - __( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ), |
|
430 | - print_r( $DateTime, true ) |
|
428 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
429 | + print_r($DateTime, true) |
|
431 | 430 | ) |
432 | 431 | ); |
433 | 432 | } |
434 | - switch ( $period ) { |
|
433 | + switch ($period) { |
|
435 | 434 | case 'years' : |
436 | - $value = 'P' . $value . 'Y'; |
|
435 | + $value = 'P'.$value.'Y'; |
|
437 | 436 | break; |
438 | 437 | case 'months' : |
439 | - $value = 'P' . $value . 'M'; |
|
438 | + $value = 'P'.$value.'M'; |
|
440 | 439 | break; |
441 | 440 | case 'weeks' : |
442 | - $value = 'P' . $value . 'W'; |
|
441 | + $value = 'P'.$value.'W'; |
|
443 | 442 | break; |
444 | 443 | case 'days' : |
445 | - $value = 'P' . $value . 'D'; |
|
444 | + $value = 'P'.$value.'D'; |
|
446 | 445 | break; |
447 | 446 | case 'hours' : |
448 | - $value = 'PT' . $value . 'H'; |
|
447 | + $value = 'PT'.$value.'H'; |
|
449 | 448 | break; |
450 | 449 | case 'minutes' : |
451 | - $value = 'PT' . $value . 'M'; |
|
450 | + $value = 'PT'.$value.'M'; |
|
452 | 451 | break; |
453 | 452 | case 'seconds' : |
454 | - $value = 'PT' . $value . 'S'; |
|
453 | + $value = 'PT'.$value.'S'; |
|
455 | 454 | break; |
456 | 455 | } |
457 | - switch ( $operand ) { |
|
456 | + switch ($operand) { |
|
458 | 457 | case '+': |
459 | - $DateTime->add( new DateInterval( $value ) ); |
|
458 | + $DateTime->add(new DateInterval($value)); |
|
460 | 459 | break; |
461 | 460 | case '-': |
462 | - $DateTime->sub( new DateInterval( $value ) ); |
|
461 | + $DateTime->sub(new DateInterval($value)); |
|
463 | 462 | break; |
464 | 463 | } |
465 | 464 | return $DateTime; |
@@ -475,16 +474,16 @@ discard block |
||
475 | 474 | * @return \DateTime return whatever type came in. |
476 | 475 | * @throws \EE_Error |
477 | 476 | */ |
478 | - protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
479 | - if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) { |
|
477 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
478 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
480 | 479 | throw new EE_Error( |
481 | 480 | sprintf( |
482 | - __( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ), |
|
483 | - print_r( $timestamp, true ) |
|
481 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
482 | + print_r($timestamp, true) |
|
484 | 483 | ) |
485 | 484 | ); |
486 | 485 | } |
487 | - switch ( $period ) { |
|
486 | + switch ($period) { |
|
488 | 487 | case 'years' : |
489 | 488 | $value = YEAR_IN_SECONDS * $value; |
490 | 489 | break; |
@@ -504,9 +503,9 @@ discard block |
||
504 | 503 | $value = MINUTE_IN_SECONDS * $value; |
505 | 504 | break; |
506 | 505 | } |
507 | - switch ( $operand ) { |
|
506 | + switch ($operand) { |
|
508 | 507 | case '+': |
509 | - $timestamp += $value; |
|
508 | + $timestamp += $value; |
|
510 | 509 | break; |
511 | 510 | case '-': |
512 | 511 | $timestamp -= $value; |
@@ -526,11 +525,11 @@ discard block |
||
526 | 525 | * @param string $operand What operand you wish to use for the calculation |
527 | 526 | * @return mixed string|DateTime return whatever type came in. |
528 | 527 | */ |
529 | - public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
530 | - if ( $DateTime_or_timestamp instanceof DateTime ) { |
|
531 | - return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand ); |
|
532 | - } else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) { |
|
533 | - return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand ); |
|
528 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
529 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
530 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
531 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
532 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
534 | 533 | } else { |
535 | 534 | //error |
536 | 535 | return $DateTime_or_timestamp; |
@@ -560,24 +559,24 @@ discard block |
||
560 | 559 | * 'moment' => //date and time format. |
561 | 560 | * ) |
562 | 561 | */ |
563 | - public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) { |
|
564 | - if ( $date_format_string === null ) { |
|
565 | - $date_format_string = get_option( 'date_format' ); |
|
562 | + public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) { |
|
563 | + if ($date_format_string === null) { |
|
564 | + $date_format_string = get_option('date_format'); |
|
566 | 565 | } |
567 | 566 | |
568 | - if ( $time_format_string === null ) { |
|
569 | - $time_format_string = get_option( 'time_format' ); |
|
567 | + if ($time_format_string === null) { |
|
568 | + $time_format_string = get_option('time_format'); |
|
570 | 569 | } |
571 | 570 | |
572 | - $date_format = self::_php_to_js_moment_converter( $date_format_string ); |
|
573 | - $time_format = self::_php_to_js_moment_converter( $time_format_string ); |
|
571 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
572 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
574 | 573 | |
575 | 574 | return array( |
576 | 575 | 'js' => array( |
577 | 576 | 'date' => $date_format['js'], |
578 | 577 | 'time' => $time_format['js'] |
579 | 578 | ), |
580 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment' ] |
|
579 | + 'moment' => $date_format['moment'].' '.$time_format['moment'] |
|
581 | 580 | ); |
582 | 581 | } |
583 | 582 | |
@@ -591,7 +590,7 @@ discard block |
||
591 | 590 | * |
592 | 591 | * @return array js and moment formats. |
593 | 592 | */ |
594 | - protected static function _php_to_js_moment_converter( $format_string ) { |
|
593 | + protected static function _php_to_js_moment_converter($format_string) { |
|
595 | 594 | /** |
596 | 595 | * This is a map of symbols for formats. |
597 | 596 | * The index is the php symbol, the equivalent values are in the array. |
@@ -748,15 +747,15 @@ discard block |
||
748 | 747 | $jquery_ui_format = ""; |
749 | 748 | $moment_format = ""; |
750 | 749 | $escaping = false; |
751 | - for ( $i = 0; $i < strlen($format_string); $i++ ) { |
|
750 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
752 | 751 | $char = $format_string[$i]; |
753 | - if ( $char === '\\' ) { // PHP date format escaping character |
|
752 | + if ($char === '\\') { // PHP date format escaping character |
|
754 | 753 | $i++; |
755 | - if ( $escaping ) { |
|
754 | + if ($escaping) { |
|
756 | 755 | $jquery_ui_format .= $format_string[$i]; |
757 | 756 | $moment_format .= $format_string[$i]; |
758 | 757 | } else { |
759 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
758 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
760 | 759 | $moment_format .= $format_string[$i]; |
761 | 760 | } |
762 | 761 | $escaping = true; |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | } |
776 | 775 | } |
777 | 776 | } |
778 | - return array( 'js' => $jquery_ui_format, 'moment' => $moment_format ); |
|
777 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
779 | 778 | } |
780 | 779 | |
781 | 780 | |
@@ -790,25 +789,25 @@ discard block |
||
790 | 789 | * errors is returned. So for client code calling, check for is_array() to |
791 | 790 | * indicate failed validations. |
792 | 791 | */ |
793 | - public static function validate_format_string( $format_string ) { |
|
792 | + public static function validate_format_string($format_string) { |
|
794 | 793 | $error_msg = array(); |
795 | 794 | //time format checks |
796 | - switch ( true ) { |
|
797 | - case strpos( $format_string, 'h' ) !== false : |
|
798 | - case strpos( $format_string, 'g' ) !== false : |
|
795 | + switch (true) { |
|
796 | + case strpos($format_string, 'h') !== false : |
|
797 | + case strpos($format_string, 'g') !== false : |
|
799 | 798 | /** |
800 | 799 | * if the time string has a lowercase 'h' which == 12 hour time format and there |
801 | 800 | * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
802 | 801 | * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
803 | 802 | */ |
804 | - if ( strpos( strtoupper( $format_string ), 'A' ) === false ) { |
|
805 | - $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' ); |
|
803 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
804 | + $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'); |
|
806 | 805 | } |
807 | 806 | break; |
808 | 807 | |
809 | 808 | } |
810 | 809 | |
811 | - return empty( $error_msg ) ? true : $error_msg; |
|
810 | + return empty($error_msg) ? true : $error_msg; |
|
812 | 811 | } |
813 | 812 | |
814 | 813 | |
@@ -830,11 +829,11 @@ discard block |
||
830 | 829 | * @param mixed $date_2 |
831 | 830 | * @return bool |
832 | 831 | */ |
833 | - public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) { |
|
832 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) { |
|
834 | 833 | |
835 | 834 | if ( |
836 | - ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) || |
|
837 | - ( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' ) |
|
835 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
836 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
838 | 837 | ) { |
839 | 838 | return false; |
840 | 839 | } |
@@ -851,11 +850,11 @@ discard block |
||
851 | 850 | * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
852 | 851 | * @return string |
853 | 852 | */ |
854 | - public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) { |
|
853 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) { |
|
855 | 854 | try { |
856 | 855 | /** need to account for timezone offset on the selects */ |
857 | - $DateTimeZone = new DateTimeZone( $timezone_string ); |
|
858 | - } catch ( Exception $e ) { |
|
856 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
857 | + } catch (Exception $e) { |
|
859 | 858 | $DateTimeZone = null; |
860 | 859 | } |
861 | 860 | |
@@ -863,10 +862,10 @@ discard block |
||
863 | 862 | * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
864 | 863 | * Hence we do the calc for DateTimeZone::getOffset. |
865 | 864 | */ |
866 | - $offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' ); |
|
865 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
867 | 866 | $query_interval = $offset < 0 |
868 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)' |
|
869 | - : 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)'; |
|
867 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
868 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
870 | 869 | return $query_interval; |
871 | 870 | } |
872 | 871 | |
@@ -878,47 +877,47 @@ discard block |
||
878 | 877 | * @return string |
879 | 878 | */ |
880 | 879 | public static function get_timezone_string_for_display() { |
881 | - $pretty_timezone = apply_filters( 'FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '' ); |
|
882 | - if( ! empty( $pretty_timezone ) ) { |
|
883 | - return esc_html( $pretty_timezone ); |
|
880 | + $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
881 | + if ( ! empty($pretty_timezone)) { |
|
882 | + return esc_html($pretty_timezone); |
|
884 | 883 | } |
885 | - $timezone_string = get_option( 'timezone_string' ); |
|
886 | - if( $timezone_string ) { |
|
884 | + $timezone_string = get_option('timezone_string'); |
|
885 | + if ($timezone_string) { |
|
887 | 886 | static $mo_loaded = false; |
888 | 887 | // Load translations for continents and cities just like wp_timezone_choice does |
889 | - if ( ! $mo_loaded ) { |
|
888 | + if ( ! $mo_loaded) { |
|
890 | 889 | $locale = get_locale(); |
891 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
892 | - load_textdomain( 'continents-cities', $mofile ); |
|
890 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
891 | + load_textdomain('continents-cities', $mofile); |
|
893 | 892 | $mo_loaded = true; |
894 | 893 | } |
895 | 894 | //well that was easy. |
896 | - $parts = explode('/', $timezone_string ); |
|
895 | + $parts = explode('/', $timezone_string); |
|
897 | 896 | //remove the continent |
898 | - unset( $parts[0] ); |
|
897 | + unset($parts[0]); |
|
899 | 898 | $t_parts = array(); |
900 | - foreach( $parts as $part ) { |
|
901 | - $t_parts[] = translate( str_replace( '_', ' ', $part ), 'continents-cities' ); |
|
899 | + foreach ($parts as $part) { |
|
900 | + $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
902 | 901 | } |
903 | - return implode( ' - ', $t_parts ); |
|
902 | + return implode(' - ', $t_parts); |
|
904 | 903 | } |
905 | 904 | //they haven't set the timezone string, so let's return a string like "UTC+1" |
906 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
907 | - if( intval( $gmt_offset ) >= 0 ) { |
|
905 | + $gmt_offset = get_option('gmt_offset'); |
|
906 | + if (intval($gmt_offset) >= 0) { |
|
908 | 907 | $prefix = '+'; |
909 | 908 | } else { |
910 | 909 | $prefix = ''; |
911 | 910 | } |
912 | - $parts = explode( '.', (string) $gmt_offset ); |
|
913 | - if( count( $parts ) === 1 ) { |
|
911 | + $parts = explode('.', (string) $gmt_offset); |
|
912 | + if (count($parts) === 1) { |
|
914 | 913 | $parts[1] = '00'; |
915 | 914 | } else { |
916 | 915 | //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
917 | 916 | //to minutes, eg 30 or 15, respectively |
918 | - $hour_fraction = (float)( '0.' . $parts[1] ); |
|
919 | - $parts[1] = (string)$hour_fraction * 60; |
|
917 | + $hour_fraction = (float) ('0.'.$parts[1]); |
|
918 | + $parts[1] = (string) $hour_fraction * 60; |
|
920 | 919 | } |
921 | - return sprintf( __( 'UTC%1$s', 'event_espresso' ), $prefix . implode( ':', $parts ) ); |
|
920 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts)); |
|
922 | 921 | } |
923 | 922 | |
924 | 923 |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EEH_HTML |
|
5 | - * |
|
3 | + * |
|
4 | + * Class EEH_HTML |
|
5 | + * |
|
6 | 6 | * Sometimes when writing PHP you need to generate some standard HTML, |
7 | 7 | * but either not enough to warrant creating a template file, |
8 | 8 | * or the amount of PHP conditionals and/or loops peppered throughout the HTML |
9 | 9 | * just make it really ugly and difficult to read. |
10 | 10 | * This class simply adds a bunch of methods for generating basic HTML tags. |
11 | 11 | * Most of the methods have the same name as the HTML tag they generate, and most have the same set of parameters. |
12 | - * |
|
13 | - * @package Event Espresso |
|
14 | - * @subpackage core |
|
15 | - * @author Brent Christensen |
|
16 | - * @since $VID:$ |
|
17 | - * |
|
18 | - */ |
|
12 | + * |
|
13 | + * @package Event Espresso |
|
14 | + * @subpackage core |
|
15 | + * @author Brent Christensen |
|
16 | + * @since $VID:$ |
|
17 | + * |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | class EEH_HTML { |
21 | 21 |
@@ -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_HTML ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_HTML) { |
|
45 | 45 | self::$_instance = new EEH_HTML(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | $other_attributes = '', |
103 | 103 | $force_close = false |
104 | 104 | ) { |
105 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
106 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
107 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
108 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
109 | - $html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>'; |
|
110 | - $html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag ) . $content : ''; |
|
111 | - $indent = ! empty( $content ) || $force_close ? TRUE : FALSE; |
|
112 | - $html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : ''; |
|
105 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
106 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
107 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
108 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
109 | + $html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>'; |
|
110 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : ''; |
|
111 | + $indent = ! empty($content) || $force_close ? TRUE : FALSE; |
|
112 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
113 | 113 | return $html; |
114 | 114 | } |
115 | 115 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @param bool $indent |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) { |
|
129 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) { |
|
130 | 130 | $comment = ''; |
131 | - if ( $id ) { |
|
132 | - $comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag ); |
|
133 | - } else if ( $class ) { |
|
134 | - $comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag ); |
|
131 | + if ($id) { |
|
132 | + $comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag); |
|
133 | + } else if ($class) { |
|
134 | + $comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag); |
|
135 | 135 | } |
136 | 136 | $html = $indent ? EEH_HTML::nl( -1, $tag ) : ''; |
137 | - $html .= '</' . $tag . '>' . $comment; |
|
137 | + $html .= '</'.$tag.'>'.$comment; |
|
138 | 138 | return $html; |
139 | 139 | } |
140 | 140 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
157 | - return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes ); |
|
156 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
157 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param string $class - html class attribute |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public static function divx( $id = '', $class = '' ) { |
|
171 | - return EEH_HTML::_close_tag( 'div', $id, $class ); |
|
170 | + public static function divx($id = '', $class = '') { |
|
171 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
188 | - return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
187 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
188 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
205 | - return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
204 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
205 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
222 | - return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
221 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
222 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
239 | - return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
238 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
239 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
256 | - return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
255 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
256 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
273 | - return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
272 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
273 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
290 | - return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
289 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
290 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
306 | - return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes ); |
|
305 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') { |
|
306 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | * @param string $class - html class attribute |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function ulx( $id = '', $class = '' ) { |
|
320 | - return EEH_HTML::_close_tag( 'ul', $id, $class ); |
|
319 | + public static function ulx($id = '', $class = '') { |
|
320 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
338 | - return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes ); |
|
337 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
338 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * @param string $class - html class attribute |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public static function lix( $id = '', $class = '' ) { |
|
352 | - return EEH_HTML::_close_tag( 'li', $id, $class ); |
|
351 | + public static function lix($id = '', $class = '') { |
|
352 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
369 | - return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes ); |
|
368 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
369 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $class - html class attribute |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public static function tablex( $id = '', $class = '' ) { |
|
382 | - return EEH_HTML::_close_tag( 'table', $id, $class ); |
|
381 | + public static function tablex($id = '', $class = '') { |
|
382 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
399 | - return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes ); |
|
398 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
399 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $class - html class attribute |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public static function theadx( $id = '', $class = '' ) { |
|
412 | - return EEH_HTML::_close_tag( 'thead', $id, $class ); |
|
411 | + public static function theadx($id = '', $class = '') { |
|
412 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
429 | - return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes ); |
|
428 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
429 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $class - html class attribute |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public static function tbodyx( $id = '', $class = '' ) { |
|
442 | - return EEH_HTML::_close_tag( 'tbody', $id, $class ); |
|
441 | + public static function tbodyx($id = '', $class = '') { |
|
442 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
459 | - return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes ); |
|
458 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
459 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | * @param string $class - html class attribute |
469 | 469 | * @return string |
470 | 470 | */ |
471 | - public static function trx( $id = '', $class = '' ) { |
|
472 | - return EEH_HTML::_close_tag( 'tr', $id, $class ); |
|
471 | + public static function trx($id = '', $class = '') { |
|
472 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
489 | - return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes ); |
|
488 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
489 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $class - html class attribute |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function thx( $id = '', $class = '' ) { |
|
502 | - return EEH_HTML::_close_tag( 'th', $id, $class ); |
|
501 | + public static function thx($id = '', $class = '') { |
|
502 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
519 | - return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes ); |
|
518 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
519 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $class - html class attribute |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public static function tdx( $id = '', $class = '' ) { |
|
532 | - return EEH_HTML::_close_tag( 'td', $id, $class ); |
|
531 | + public static function tdx($id = '', $class = '') { |
|
532 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * @param int $colspan |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - public static function no_row( $content = '', $colspan = 2 ) { |
|
546 | + public static function no_row($content = '', $colspan = 2) { |
|
547 | 547 | return EEH_HTML::tr( |
548 | - EEH_HTML::td( $content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"' ), |
|
549 | - '', '', 'padding:0; border:none;' |
|
548 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'), |
|
549 | + '', '', 'padding:0; border:none;' |
|
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
567 | 567 | * @return string |
568 | 568 | */ |
569 | - public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
570 | - $link_text = ! empty( $link_text ) ? $link_text : $href; |
|
571 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
572 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
573 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
574 | - $attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : ''; |
|
575 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
576 | - return '<a href="' . $href . '" ' . $attributes . '>' . $link_text . '</a>'; |
|
569 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
570 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
571 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
572 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
573 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
574 | + $attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : ''; |
|
575 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
576 | + return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>'; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
@@ -590,14 +590,14 @@ discard block |
||
590 | 590 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
594 | - $attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : ''; |
|
595 | - $attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : ''; |
|
596 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
597 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
598 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
599 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
600 | - return '<img' . $attributes . '/>'; |
|
593 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
594 | + $attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : ''; |
|
595 | + $attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : ''; |
|
596 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
597 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
598 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
599 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
600 | + return '<img'.$attributes.'/>'; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
616 | 616 | * @return string |
617 | 617 | */ |
618 | - protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
619 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
620 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
621 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
622 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
623 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
618 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
619 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
620 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
621 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
622 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
623 | + return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>'; |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
640 | - return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes ); |
|
639 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
640 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
657 | - return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes ); |
|
656 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
657 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
671 | 671 | * @return string |
672 | 672 | */ |
673 | - public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
674 | - return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes ); |
|
673 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
674 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | * @param string $comment |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function comment( $comment = '' ) { |
|
687 | - return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
686 | + public static function comment($comment = '') { |
|
687 | + return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : ''; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -695,8 +695,8 @@ discard block |
||
695 | 695 | * @param int $nmbr - the number of line breaks to return |
696 | 696 | * @return string |
697 | 697 | */ |
698 | - public static function br( $nmbr = 1 ) { |
|
699 | - return str_repeat( '<br />', $nmbr ); |
|
698 | + public static function br($nmbr = 1) { |
|
699 | + return str_repeat('<br />', $nmbr); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | * @param int $nmbr - the number of non-breaking spaces to return |
708 | 708 | * @return string |
709 | 709 | */ |
710 | - public static function nbsp( $nmbr = 1 ) { |
|
711 | - return str_repeat( ' ', $nmbr ); |
|
710 | + public static function nbsp($nmbr = 1) { |
|
711 | + return str_repeat(' ', $nmbr); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -722,9 +722,9 @@ discard block |
||
722 | 722 | * @param string $id |
723 | 723 | * @return string |
724 | 724 | */ |
725 | - public static function sanitize_id( $id = '' ) { |
|
726 | - $key = str_replace( ' ', '-', trim( $id ) ); |
|
727 | - return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key ); |
|
725 | + public static function sanitize_id($id = '') { |
|
726 | + $key = str_replace(' ', '-', trim($id)); |
|
727 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | * @param string $tag |
737 | 737 | * @return string - newline character plus # of indents passed (can be + or -) |
738 | 738 | */ |
739 | - public static function nl( $indent = 0, $tag = 'none' ) { |
|
739 | + public static function nl($indent = 0, $tag = 'none') { |
|
740 | 740 | $html = "\n"; |
741 | - EEH_HTML::indent( $indent, $tag ); |
|
742 | - for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) { |
|
741 | + EEH_HTML::indent($indent, $tag); |
|
742 | + for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) { |
|
743 | 743 | $html .= "\t"; |
744 | 744 | } |
745 | 745 | return $html; |
@@ -754,17 +754,17 @@ discard block |
||
754 | 754 | * @param int $indent can be negative to decrease the indentation level |
755 | 755 | * @param string $tag |
756 | 756 | */ |
757 | - public static function indent( $indent, $tag = 'none' ){ |
|
757 | + public static function indent($indent, $tag = 'none') { |
|
758 | 758 | static $default_indentation = FALSE; |
759 | - if ( ! $default_indentation ) { |
|
759 | + if ( ! $default_indentation) { |
|
760 | 760 | EEH_HTML::_set_default_indentation(); |
761 | 761 | $default_indentation = TRUE; |
762 | 762 | } |
763 | - if ( ! isset( EEH_HTML::$_indent[ $tag ] )) { |
|
764 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
763 | + if ( ! isset(EEH_HTML::$_indent[$tag])) { |
|
764 | + EEH_HTML::$_indent[$tag] = 0; |
|
765 | 765 | } |
766 | - EEH_HTML::$_indent[ $tag ] += (int)$indent; |
|
767 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
766 | + EEH_HTML::$_indent[$tag] += (int) $indent; |
|
767 | + EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0; |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * @global array $allowedtags |
811 | 811 | * @return array |
812 | 812 | */ |
813 | - public static function get_simple_tags(){ |
|
813 | + public static function get_simple_tags() { |
|
814 | 814 | global $allowedtags; |
815 | 815 | $tags_we_allow = $allowedtags; |
816 | - $tags_we_allow['ol']=array(); |
|
817 | - $tags_we_allow['ul']=array(); |
|
818 | - $tags_we_allow['li']=array(); |
|
819 | - $tags_we_allow['br']=array(); |
|
820 | - $tags_we_allow['p']=array(); |
|
821 | - return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow ); |
|
816 | + $tags_we_allow['ol'] = array(); |
|
817 | + $tags_we_allow['ul'] = array(); |
|
818 | + $tags_we_allow['li'] = array(); |
|
819 | + $tags_we_allow['br'] = array(); |
|
820 | + $tags_we_allow['p'] = array(); |
|
821 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 |