Completed
Branch BETA-4.9-messages-queue (3a5d2a)
by
unknown
31:07 queued 15:44
created
core/helpers/EEH_Autoloader.helper.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 /**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public static function instance() {
40 40
 		// check if class object is instantiated, and instantiated properly
41
-		if ( ! self::$_instance instanceof  EEH_Autoloader ) {
41
+		if ( ! self::$_instance instanceof  EEH_Autoloader) {
42 42
 			self::$_instance = new self();
43 43
 		}
44 44
 		return self::$_instance;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	private function __construct() {
56 56
 		self::$_autoloaders = array();
57 57
 		$this->_register_custom_autoloaders();
58
-		spl_autoload_register( array( $this, 'espresso_autoloader' ));
58
+		spl_autoload_register(array($this, 'espresso_autoloader'));
59 59
 	}
60 60
 
61 61
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 * @internal  param string $class_name - simple class name ie: session
70 70
 	 * @return 	void
71 71
 	 */
72
-	public static function espresso_autoloader( $class_name ) {
73
-		if ( isset( self::$_autoloaders[ $class_name ] ) ) {
74
-			require_once( self::$_autoloaders[ $class_name ] );
72
+	public static function espresso_autoloader($class_name) {
73
+		if (isset(self::$_autoloaders[$class_name])) {
74
+			require_once(self::$_autoloaders[$class_name]);
75 75
 		}
76 76
 	}
77 77
 
@@ -87,26 +87,26 @@  discard block
 block discarded – undo
87 87
 	 * @return void
88 88
 	 * @throws \EE_Error
89 89
 	 */
90
-	public static function register_autoloader( $class_paths, $read_check = true, $debug = false ) {
91
-		$class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths );
92
-		foreach ( $class_paths as $class => $path ) {
90
+	public static function register_autoloader($class_paths, $read_check = true, $debug = false) {
91
+		$class_paths = is_array($class_paths) ? $class_paths : array($class_paths);
92
+		foreach ($class_paths as $class => $path) {
93 93
 			// don't give up! you gotta...
94 94
 			// get some class
95
-			if ( empty( $class )) {
96
-				throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path ));
95
+			if (empty($class)) {
96
+				throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path));
97 97
 			}
98 98
 			// one day you will find the path young grasshopper
99
-			if ( empty( $path )) {
100
-				throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class ));
99
+			if (empty($path)) {
100
+				throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class));
101 101
 			}
102 102
 			// is file readable ?
103
-			if ( $read_check && ! is_readable( $path )) {
104
-				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 ));
103
+			if ($read_check && ! is_readable($path)) {
104
+				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));
105 105
 			}
106
-			if ( ! isset( self::$_autoloaders[ $class ] )) {
107
-				self::$_autoloaders[ $class ] = str_replace( array( '/', '\\' ), DS, $path );
108
-				if ( WP_DEBUG && $debug ) {
109
-					printr( self::$_autoloaders[ $class ], $class, __FILE__, __LINE__ );
106
+			if ( ! isset(self::$_autoloaders[$class])) {
107
+				self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path);
108
+				if (WP_DEBUG && $debug) {
109
+					printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__);
110 110
 				}
111 111
 			}
112 112
 		}
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 	 * 	@return void
136 136
 	 */
137 137
 	private function _register_custom_autoloaders() {
138
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'interfaces' );
139
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE );
140
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_INTERFACES, true );
141
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, true );
142
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES );
143
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true );
138
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces');
139
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE);
140
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true);
141
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true);
142
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES);
143
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true);
144 144
 	}
145 145
 
146 146
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * 	@return void
167 167
 	 */
168 168
 	public static function register_line_item_display_autoloaders() {
169
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(  EE_LIBRARIES . 'line_item_display' , true );
169
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true);
170 170
 	}
171 171
 
172 172
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * 	@return void
180 180
 	 */
181 181
 	public static function register_line_item_filter_autoloaders() {
182
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(  EE_LIBRARIES . 'line_item_filters' , true );
182
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true);
183 183
 	}
184 184
 
185 185
 
@@ -197,30 +197,30 @@  discard block
 block discarded – undo
197 197
 	 * @return void
198 198
 	 * @throws \EE_Error
199 199
 	 */
200
-	public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = false, $debug = false ){
200
+	public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) {
201 201
 		// make sure last char is a /
202
-		$folder .= $folder[strlen($folder)-1] != DS ? DS : '';
202
+		$folder .= $folder[strlen($folder) - 1] != DS ? DS : '';
203 203
 		$class_to_filepath_map = array();
204
-		$exclude = array( 'index' );
204
+		$exclude = array('index');
205 205
 		//get all the files in that folder that end in php
206
-		$filepaths = glob( $folder.'*');
206
+		$filepaths = glob($folder.'*');
207 207
 
208
-		if ( empty( $filepaths ) ) {
208
+		if (empty($filepaths)) {
209 209
 			return;
210 210
 		}
211 211
 
212
-		foreach( $filepaths as $filepath ) {
213
-			if ( substr( $filepath, -4, 4 ) == '.php' ) {
214
-				$class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath );
215
-				if ( ! in_array( $class_name, $exclude )) {
216
-					$class_to_filepath_map [ $class_name ] = str_replace( array( '\/', '/' ), DS, $filepath );
212
+		foreach ($filepaths as $filepath) {
213
+			if (substr($filepath, -4, 4) == '.php') {
214
+				$class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath);
215
+				if ( ! in_array($class_name, $exclude)) {
216
+					$class_to_filepath_map [$class_name] = str_replace(array('\/', '/'), DS, $filepath);
217 217
 				}
218
-			} else if ( $recursive ) {
219
-				EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive );
218
+			} else if ($recursive) {
219
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive);
220 220
 			}
221 221
 		}
222 222
 		// 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.
223
-		self::register_autoloader( $class_to_filepath_map, false, $debug );
223
+		self::register_autoloader($class_to_filepath_map, false, $debug);
224 224
 	}
225 225
 
226 226
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@
 block discarded – undo
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
  *
Please login to merge, or discard this patch.
core/helpers/EEH_Base.helper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
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; }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
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
  *
Please login to merge, or discard this patch.
core/helpers/EEH_Class_Tools.helper.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function get_called_class() {
37 37
 		$backtrace = debug_backtrace();
38
-		if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['class'] ) && ! isset( $backtrace[2]['file'] )) {
38
+		if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) {
39 39
 			return $backtrace[2]['class'];
40
-		} else if ( isset( $backtrace[3] ) && is_array( $backtrace[3] ) && isset( $backtrace[3]['class'] ) && ! isset( $backtrace[3]['file'] )) {
40
+		} else if (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) {
41 41
 			return $backtrace[3]['class'];
42
-		} else if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['file'] ) && isset( $backtrace[2]['line'] )) {
43
-			if ( self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line'] ) {
42
+		} else if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) {
43
+			if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) {
44 44
 				self::$i++;
45 45
 			} else {
46 46
 				self::$i = 0;
47
-				self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line'];
47
+				self::$file_line = $backtrace[2]['file'].$backtrace[2]['line'];
48 48
 			}
49 49
 			// was  class method called via call_user_func ?
50
-			if ( $backtrace[2]['function'] == 'call_user_func' && isset( $backtrace[2]['args'] ) && is_array( $backtrace[2]['args'] )){
51
-				if ( isset( $backtrace[2]['args'][0] ) && isset( $backtrace[2]['args'][0][0] )) {
50
+			if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) {
51
+				if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) {
52 52
 					$called_class = $backtrace[2]['args'][0][0];
53 53
 					// is it an EE function ?
54
-					if ( strpos( $called_class, 'EE' ) === 0 ) {
55
-						$prefix_chars = strpos( $called_class, '_' ) + 1;
56
-						$prefix = substr( $called_class, 0, $prefix_chars );
57
-						$classname = substr( $called_class, $prefix_chars, strlen( $called_class ));
58
-						$classname = $prefix . str_replace( ' ', '_', ucwords( strtolower( str_replace( '_', ' ', $classname  ))));
54
+					if (strpos($called_class, 'EE') === 0) {
55
+						$prefix_chars = strpos($called_class, '_') + 1;
56
+						$prefix = substr($called_class, 0, $prefix_chars);
57
+						$classname = substr($called_class, $prefix_chars, strlen($called_class));
58
+						$classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname))));
59 59
 						return $classname;
60 60
 					}
61 61
 				}
62 62
 			} else {
63
-				$lines = file( $backtrace[2]['file'] );
64
-				preg_match_all( '/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[$backtrace[2]['line']-1], $matches );
65
-				if ( isset( $matches[1] ) && isset( $matches[1][ self::$i ] )) {
66
-					return $matches[1][ self::$i ];
63
+				$lines = file($backtrace[2]['file']);
64
+				preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches);
65
+				if (isset($matches[1]) && isset($matches[1][self::$i])) {
66
+					return $matches[1][self::$i];
67 67
 				}
68 68
 			}
69 69
 		}
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
 	 * 	@param 	string 	$hook
81 81
 	 * 	@return 	array
82 82
 	 */
83
-	public static function get_class_names_for_all_callbacks_on_hook( $hook = NULL ) {
83
+	public static function get_class_names_for_all_callbacks_on_hook($hook = NULL) {
84 84
 		global $wp_filter;
85 85
 		$class_names = array();
86 86
 		// are any callbacks registered for this hook ?
87
-		if ( isset( $wp_filter[ $hook ] )) {
87
+		if (isset($wp_filter[$hook])) {
88 88
 			// loop thru all of the callbacks attached to the deprecated hookpoint
89
-			foreach( $wp_filter[ $hook ] as $priority ) {
90
-				foreach( $priority as $callback ) {
89
+			foreach ($wp_filter[$hook] as $priority) {
90
+				foreach ($priority as $callback) {
91 91
 					// is the callback a non-static class method ?
92
-					if ( isset( $callback['function'] ) && is_array( $callback['function'] )) {
93
-						if ( isset( $callback['function'][0] ) && is_object( $callback['function'][0] )) {
94
-							$class_names[] = get_class( $callback['function'][0] );
92
+					if (isset($callback['function']) && is_array($callback['function'])) {
93
+						if (isset($callback['function'][0]) && is_object($callback['function'][0])) {
94
+							$class_names[] = get_class($callback['function'][0]);
95 95
 						}
96 96
 					// test for static method
97
-					} else if ( strpos( $callback['function'], '::' ) !== FALSE ) {
98
-						$class = explode( '::', $callback['function'] );
97
+					} else if (strpos($callback['function'], '::') !== FALSE) {
98
+						$class = explode('::', $callback['function']);
99 99
 						$class_names[] = $class[0];
100 100
 					} else {
101 101
 						// just a function
@@ -116,24 +116,24 @@  discard block
 block discarded – undo
116 116
 	 * 	@param		string 	$property
117 117
 	 * 	@return 		boolean
118 118
 	 */
119
-	public static function has_property( $class = NULL, $property = NULL ) {
119
+	public static function has_property($class = NULL, $property = NULL) {
120 120
 		// if $class or $property don't exist, then get out, cuz that would be like... fatal dude
121
-		if ( empty( $class ) || empty( $property )) {
121
+		if (empty($class) || empty($property)) {
122 122
 			return FALSE;
123 123
 		}
124 124
 		// if your hosting company doesn't cut the mustard
125
-		if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
125
+		if (version_compare(PHP_VERSION, '5.3.0') < 0) {
126 126
 			// just in case $class is an actual instantiated object
127
-			if ( is_object( $class )) {
128
-				return isset( $class->$property ) ? TRUE : FALSE;
127
+			if (is_object($class)) {
128
+				return isset($class->$property) ? TRUE : FALSE;
129 129
 			} else {
130 130
 				// use reflection for < PHP 5.3 to get details using just the class name
131
-				$reflector = new ReflectionClass( $class );
132
-				return $reflector->hasProperty( $property );
131
+				$reflector = new ReflectionClass($class);
132
+				return $reflector->hasProperty($property);
133 133
 			}
134 134
 		} else {
135 135
 			// or try regular property exists method which works as expected in PHP 5.3+
136
-			return property_exists( $class, $property );
136
+			return property_exists($class, $property);
137 137
 		}
138 138
 	}
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 // if PHP version < 5.3
146
-if ( ! function_exists( 'get_called_class' )) {
146
+if ( ! function_exists('get_called_class')) {
147 147
 	/**
148 148
 	 * @return bool|string
149 149
 	 */
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
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
  *
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 3 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -799,7 +799,6 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
Spacing   +109 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
104 104
 	 * @param string $gmt_offset
105 105
 	 * @return string
106 106
 	 */
107
-	public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) {
107
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '') {
108 108
 		$timezone_string = 'UTC';
109
-		$gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' );
110
-		if ( $gmt_offset !== '' ) {
109
+		$gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
110
+		if ($gmt_offset !== '') {
111 111
 			// convert GMT offset to seconds
112 112
 			$gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
113 113
 			// account for WP offsets that aren't valid UTC
114
-			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset );
114
+			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
115 115
 			// although we don't know the TZ abbreviation, we know the UTC offset
116
-			$timezone_string = timezone_name_from_abbr( null, $gmt_offset );
116
+			$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
117 117
 		}
118 118
 		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
119
-		$timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset );
119
+		$timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
120 120
 		return $timezone_string;
121 121
 	}
122 122
 
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
 	 * @param int $gmt_offset
130 130
 	 * @return int
131 131
 	 */
132
-	public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) {
132
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0) {
133 133
 		//make sure $gmt_offset is int
134 134
 		$gmt_offset = (int) $gmt_offset;
135
-		switch ( $gmt_offset ) {
135
+		switch ($gmt_offset) {
136 136
 
137 137
 			//			case -30600 :
138 138
 			//				$gmt_offset = -28800;
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
 	 * @return string
185 185
 	 * @throws \EE_Error
186 186
 	 */
187
-	public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) {
187
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) {
188 188
 		$abbreviations = timezone_abbreviations_list();
189
-		foreach ( $abbreviations as $abbreviation ) {
190
-			foreach ( $abbreviation as $city ) {
191
-				if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) {
189
+		foreach ($abbreviations as $abbreviation) {
190
+			foreach ($abbreviation as $city) {
191
+				if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) {
192 192
 					// check if the timezone is valid but don't throw any errors if it isn't
193
-					if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) {
193
+					if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
194 194
 						return $city['timezone_id'];
195 195
 					}
196 196
 				}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		}
199 199
 		throw new EE_Error(
200 200
 			sprintf(
201
-				__( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ),
201
+				__('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'),
202 202
 				$gmt_offset,
203 203
 				'<a href="http://www.php.net/manual/en/timezones.php">',
204 204
 				'</a>'
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
 	 * @access public
213 213
 	 * @param string $timezone_string
214 214
 	 */
215
-	public static function timezone_select_input( $timezone_string = '' ) {
215
+	public static function timezone_select_input($timezone_string = '') {
216 216
 		// get WP date time format
217
-		$datetime_format = get_option('date_format') . ' '  . get_option('time_format');
217
+		$datetime_format = get_option('date_format').' '.get_option('time_format');
218 218
 		// if passed a value, then use that, else get WP option
219
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' );
219
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
220 220
 		// check if the timezone is valid but don't throw any errors if it isn't
221
-		$timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false );
221
+		$timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
222 222
 		$gmt_offset = get_option('gmt_offset');
223 223
 
224 224
 		$check_zone_info = true;
225
-		if ( empty( $timezone_string )) {
225
+		if (empty($timezone_string)) {
226 226
 			// Create a UTC+- zone if no timezone string exists
227 227
 			$check_zone_info = false;
228
-			if ( $gmt_offset > 0 ) {
229
-				$timezone_string = 'UTC+' . $gmt_offset;
230
-			} elseif ( $gmt_offset < 0 ) {
231
-				$timezone_string = 'UTC' . $gmt_offset;
228
+			if ($gmt_offset > 0) {
229
+				$timezone_string = 'UTC+'.$gmt_offset;
230
+			} elseif ($gmt_offset < 0) {
231
+				$timezone_string = 'UTC'.$gmt_offset;
232 232
 			} else {
233 233
 				$timezone_string = 'UTC';
234 234
 			}
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 					__('%1$sUTC%2$s time is %3$s'),
251 251
 					'<abbr title="Coordinated Universal Time">',
252 252
 					'</abbr>',
253
-					'<code>' . date_i18n( $datetime_format , false, 'gmt') . '</code>'
253
+					'<code>'.date_i18n($datetime_format, false, 'gmt').'</code>'
254 254
 				);
255 255
 				?></span>
256
-			<?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?>
257
-				<br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span>
256
+			<?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?>
257
+				<br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span>
258 258
 		<?php endif; ?>
259 259
 
260 260
 				<?php if ($check_zone_info && $timezone_string) : ?>
@@ -286,10 +286,9 @@  discard block
 block discarded – undo
286 286
 
287 287
 						if ($found) {
288 288
 							$message = $tr['isdst'] ?
289
-											__(' Daylight saving time begins on: %s.' ) :
290
-											__(' Standard time begins  on: %s.');
289
+											__(' Daylight saving time begins on: %s.') : __(' Standard time begins  on: %s.');
291 290
 							// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
292
-							printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' );
291
+							printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >');
293 292
 						} else {
294 293
 							_e('This timezone does not observe daylight saving time.');
295 294
 						}
@@ -319,14 +318,14 @@  discard block
 block discarded – undo
319 318
 	 *
320 319
 	 * @return int      $unix_timestamp with the offset applied for the given timezone.
321 320
 	 */
322
-	public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) {
321
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') {
323 322
 		$unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp;
324
-		$timezone_string = self::get_valid_timezone_string( $timezone_string );
325
-		$TimeZone = new DateTimeZone( $timezone_string );
323
+		$timezone_string = self::get_valid_timezone_string($timezone_string);
324
+		$TimeZone = new DateTimeZone($timezone_string);
326 325
 
327
-		$DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone );
328
-		$offset = timezone_offset_get( $TimeZone, $DateTime );
329
-		return (int)$DateTime->format( 'U' ) + (int)$offset;
326
+		$DateTime = new DateTime('@'.$unix_timestamp, $TimeZone);
327
+		$offset = timezone_offset_get($TimeZone, $DateTime);
328
+		return (int) $DateTime->format('U') + (int) $offset;
330 329
 	}
331 330
 
332 331
 
@@ -341,17 +340,17 @@  discard block
 block discarded – undo
341 340
 	 * @param  string					$datetime_field_name 	the datetime fieldname to be manipulated
342 341
 	 * @return 	EE_Base_Class
343 342
 	 */
344
-	protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) {
343
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) {
345 344
 		// grab current datetime format
346 345
 		$current_format = $obj->get_format();
347 346
 		// set new full timestamp format
348
-		$obj->set_date_format( EE_Datetime_Field::mysql_date_format );
349
-		$obj->set_time_format( EE_Datetime_Field::mysql_time_format );
347
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
348
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
350 349
 		// set the new date value using a full timestamp format so that no data is lost
351
-		$obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) );
350
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
352 351
 		// reset datetime formats
353
-		$obj->set_date_format( $current_format[0] );
354
-		$obj->set_time_format( $current_format[1] );
352
+		$obj->set_date_format($current_format[0]);
353
+		$obj->set_time_format($current_format[1]);
355 354
 		return $obj;
356 355
 	}
357 356
 
@@ -368,11 +367,11 @@  discard block
 block discarded – undo
368 367
 	 * @param  integer 	$value    what you want to increment the time by
369 368
 	 * @return EE_Base_Class		   return the EE_Base_Class object so right away you can do something with it (chaining)
370 369
 	 */
371
-	public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) {
370
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) {
372 371
 		//get the raw UTC date.
373
-		$DateTime = $obj->get_DateTime_object( $datetime_field_name );
374
-		$DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value );
375
-		return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name );
372
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
373
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
374
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
376 375
 	}
377 376
 
378 377
 
@@ -387,11 +386,11 @@  discard block
 block discarded – undo
387 386
 	 * @param int            $value
388 387
 	 * @return \EE_Base_Class
389 388
 	 */
390
-	public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) {
389
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) {
391 390
 		//get the raw UTC date
392
-		$DateTime = $obj->get_DateTime_object( $datetime_field_name );
393
-		$DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' );
394
-		return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name );
391
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
392
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
393
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
395 394
 	}
396 395
 
397 396
 
@@ -404,44 +403,44 @@  discard block
 block discarded – undo
404 403
 	 * @return \DateTime return whatever type came in.
405 404
 	 * @throws \EE_Error
406 405
 	 */
407
-	protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) {
408
-		if ( ! $DateTime instanceof DateTime ) {
406
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') {
407
+		if ( ! $DateTime instanceof DateTime) {
409 408
 			throw new EE_Error(
410 409
 				sprintf(
411
-					__( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ),
412
-					print_r( $DateTime, true )
410
+					__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
411
+					print_r($DateTime, true)
413 412
 				)
414 413
 			);
415 414
 		}
416
-		switch ( $period ) {
415
+		switch ($period) {
417 416
 			case 'years' :
418
-				$value = 'P' . $value . 'Y';
417
+				$value = 'P'.$value.'Y';
419 418
 				break;
420 419
 			case 'months' :
421
-				$value = 'P' . $value . 'M';
420
+				$value = 'P'.$value.'M';
422 421
 				break;
423 422
 			case 'weeks' :
424
-				$value = 'P' . $value . 'W';
423
+				$value = 'P'.$value.'W';
425 424
 				break;
426 425
 			case 'days' :
427
-				$value = 'P' . $value . 'D';
426
+				$value = 'P'.$value.'D';
428 427
 				break;
429 428
 			case 'hours' :
430
-				$value = 'PT' . $value . 'H';
429
+				$value = 'PT'.$value.'H';
431 430
 				break;
432 431
 			case 'minutes' :
433
-				$value = 'PT' . $value . 'M';
432
+				$value = 'PT'.$value.'M';
434 433
 				break;
435 434
 			case 'seconds' :
436
-				$value = 'PT' . $value . 'S';
435
+				$value = 'PT'.$value.'S';
437 436
 				break;
438 437
 		}
439
-		switch ( $operand ) {
438
+		switch ($operand) {
440 439
 			case '+':
441
-				$DateTime->add( new DateInterval( $value ) );
440
+				$DateTime->add(new DateInterval($value));
442 441
 				break;
443 442
 			case '-':
444
-				$DateTime->sub( new DateInterval( $value ) );
443
+				$DateTime->sub(new DateInterval($value));
445 444
 				break;
446 445
 		}
447 446
 		return $DateTime;
@@ -457,16 +456,16 @@  discard block
 block discarded – undo
457 456
 	 * @return \DateTime return whatever type came in.
458 457
 	 * @throws \EE_Error
459 458
 	 */
460
-	protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) {
461
-		if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) {
459
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') {
460
+		if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
462 461
 			throw new EE_Error(
463 462
 				sprintf(
464
-					__( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ),
465
-					print_r( $timestamp, true )
463
+					__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
464
+					print_r($timestamp, true)
466 465
 				)
467 466
 			);
468 467
 		}
469
-		switch ( $period ) {
468
+		switch ($period) {
470 469
 			case 'years' :
471 470
 				$value = YEAR_IN_SECONDS * $value;
472 471
 				break;
@@ -486,9 +485,9 @@  discard block
 block discarded – undo
486 485
 				$value = MINUTE_IN_SECONDS * $value;
487 486
 				break;
488 487
 		}
489
-		switch ( $operand ) {
488
+		switch ($operand) {
490 489
 			case '+':
491
-				$timestamp  += $value;
490
+				$timestamp += $value;
492 491
 				break;
493 492
 			case '-':
494 493
 				$timestamp -= $value;
@@ -508,11 +507,11 @@  discard block
 block discarded – undo
508 507
 	 * @param  string  $operand What operand you wish to use for the calculation
509 508
 	 * @return mixed string|DateTime          return whatever type came in.
510 509
 	 */
511
-	public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) {
512
-		if ( $DateTime_or_timestamp instanceof DateTime ) {
513
-			return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand );
514
-		} else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) {
515
-			return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand );
510
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') {
511
+		if ($DateTime_or_timestamp instanceof DateTime) {
512
+			return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
513
+		} else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
514
+			return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
516 515
 		} else {
517 516
 			//error
518 517
 			return $DateTime_or_timestamp;
@@ -542,24 +541,24 @@  discard block
 block discarded – undo
542 541
 	 * 			'moment' => //date and time format.
543 542
 	 * 		)
544 543
 	 */
545
-	public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) {
546
-		if ( $date_format_string === null ) {
547
-			$date_format_string = get_option( 'date_format' );
544
+	public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) {
545
+		if ($date_format_string === null) {
546
+			$date_format_string = get_option('date_format');
548 547
 		}
549 548
 
550
-		if ( $time_format_string === null ) {
551
-			$time_format_string = get_option( 'time_format' );
549
+		if ($time_format_string === null) {
550
+			$time_format_string = get_option('time_format');
552 551
 		}
553 552
 
554
-		$date_format = self::_php_to_js_moment_converter( $date_format_string );
555
-		$time_format = self::_php_to_js_moment_converter( $time_format_string );
553
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
554
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
556 555
 
557 556
 		return array(
558 557
 			'js' => array(
559 558
 				'date' => $date_format['js'],
560 559
 				'time' => $time_format['js']
561 560
 				),
562
-			'moment' => $date_format['moment'] . ' ' . $time_format['moment' ]
561
+			'moment' => $date_format['moment'].' '.$time_format['moment']
563 562
 			);
564 563
 	}
565 564
 
@@ -573,7 +572,7 @@  discard block
 block discarded – undo
573 572
 	 *
574 573
 	 * @return array js and moment formats.
575 574
 	 */
576
-	protected static function _php_to_js_moment_converter( $format_string ) {
575
+	protected static function _php_to_js_moment_converter($format_string) {
577 576
 		/**
578 577
 		 * This is a map of symbols for formats.
579 578
 		 * The index is the php symbol, the equivalent values are in the array.
@@ -730,15 +729,15 @@  discard block
 block discarded – undo
730 729
 		$jquery_ui_format = "";
731 730
 		$moment_format = "";
732 731
 		$escaping = false;
733
-		for ( $i = 0; $i < strlen($format_string); $i++ ) {
732
+		for ($i = 0; $i < strlen($format_string); $i++) {
734 733
 			$char = $format_string[$i];
735
-			if ( $char === '\\' )  { // PHP date format escaping character
734
+			if ($char === '\\') { // PHP date format escaping character
736 735
 				$i++;
737
-				if ( $escaping ) {
736
+				if ($escaping) {
738 737
 					$jquery_ui_format .= $format_string[$i];
739 738
 					$moment_format .= $format_string[$i];
740 739
 				} else {
741
-					$jquery_ui_format .= '\'' . $format_string[$i];
740
+					$jquery_ui_format .= '\''.$format_string[$i];
742 741
 					$moment_format .= $format_string[$i];
743 742
 				}
744 743
 				$escaping = true;
@@ -757,7 +756,7 @@  discard block
 block discarded – undo
757 756
 				}
758 757
 			}
759 758
 		}
760
-		return array( 'js' => $jquery_ui_format, 'moment' => $moment_format );
759
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
761 760
 	}
762 761
 
763 762
 
@@ -772,25 +771,25 @@  discard block
 block discarded – undo
772 771
 	 *                           		errors is returned.  So for client code calling, check for is_array() to
773 772
 	 *                           		indicate failed validations.
774 773
 	 */
775
-	public static function validate_format_string( $format_string ) {
774
+	public static function validate_format_string($format_string) {
776 775
 		$error_msg = array();
777 776
 		//time format checks
778
-		switch ( true ) {
779
-			case   strpos( $format_string, 'h' )  !== false  :
780
-			case   strpos( $format_string, 'g' ) !== false :
777
+		switch (true) {
778
+			case   strpos($format_string, 'h') !== false  :
779
+			case   strpos($format_string, 'g') !== false :
781 780
 				/**
782 781
 				 * if the time string has a lowercase 'h' which == 12 hour time format and there
783 782
 				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
784 783
 				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
785 784
 				 */
786
-				if ( strpos( strtoupper( $format_string ), 'A' )  === false ) {
787
-					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' );
785
+				if (strpos(strtoupper($format_string), 'A') === false) {
786
+					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso');
788 787
 				}
789 788
 				break;
790 789
 
791 790
 		}
792 791
 
793
-		return empty( $error_msg ) ? true : $error_msg;
792
+		return empty($error_msg) ? true : $error_msg;
794 793
 	}
795 794
 
796 795
 
@@ -812,11 +811,11 @@  discard block
 block discarded – undo
812 811
 	 * @param mixed $date_2
813 812
 	 * @return bool
814 813
 	 */
815
-	public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) {
814
+	public static function dates_represent_one_24_hour_date($date_1, $date_2) {
816 815
 
817 816
 		if (
818
-			( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) ||
819
-			( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' )
817
+			( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
818
+			($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
820 819
 		) {
821 820
 			return false;
822 821
 		}
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 2 patches
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since 				4.0
9 9
  *
10 10
  */
11
-class EEH_Debug_Tools{
11
+class EEH_Debug_Tools {
12 12
 
13 13
 	/**
14 14
 	 * 	instance of the EEH_Autoloader object
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function instance() {
43 43
 		// check if class object is instantiated, and instantiated properly
44
-		if ( ! self::$_instance instanceof EEH_Debug_Tools ) {
44
+		if ( ! self::$_instance instanceof EEH_Debug_Tools) {
45 45
 			self::$_instance = new self();
46 46
 		}
47 47
 		return self::$_instance;
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	private function __construct() {
59 59
 		// load Kint PHP debugging library
60
-		if ( ! class_exists( 'Kint' ) &&  file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){
60
+		if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) {
61 61
 			// despite EE4 having a check for an existing copy of the Kint debugging class,
62 62
 			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
63 63
 			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
64 64
 			// so we've moved it to our test folder so that it is not included with production releases
65 65
 			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
66
-			require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' );
66
+			require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php');
67 67
 		}
68
-		if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) {
68
+		if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) {
69 69
 			//add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
70 70
 		}
71
-		add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
72
-		add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' ));
71
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
72
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
73 73
 	}
74 74
 
75 75
 
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * 	@return void
81 81
 	 */
82 82
 	public static function show_db_name() {
83
-		if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) {
84
-			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>';
83
+		if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>';
85 85
 		}
86 86
 	}
87 87
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 	 * 	@return void
94 94
 	 */
95 95
 	public function espresso_session_footer_dump() {
96
-		if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) &&  ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) {
97
-			Kint::dump(  EE_Registry::instance()->SSN->id() );
98
-			Kint::dump( EE_Registry::instance()->SSN );
96
+		if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) {
97
+			Kint::dump(EE_Registry::instance()->SSN->id());
98
+			Kint::dump(EE_Registry::instance()->SSN);
99 99
 //			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
100 100
 			$this->espresso_list_hooked_functions();
101 101
 			$this->show_times();
@@ -112,27 +112,27 @@  discard block
 block discarded – undo
112 112
 	 * @param bool $tag
113 113
 	 * @return void
114 114
 	 */
115
-	public function espresso_list_hooked_functions( $tag=FALSE ){
115
+	public function espresso_list_hooked_functions($tag = FALSE) {
116 116
 		global $wp_filter;
117 117
 		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
118
-		if ( $tag ) {
119
-			$hook[$tag]=$wp_filter[$tag];
120
-			if ( ! is_array( $hook[$tag] )) {
121
-				trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING );
118
+		if ($tag) {
119
+			$hook[$tag] = $wp_filter[$tag];
120
+			if ( ! is_array($hook[$tag])) {
121
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
122 122
 				return;
123 123
 			}
124
-			echo '<h5>For Tag: '. $tag .'</h5>';
124
+			echo '<h5>For Tag: '.$tag.'</h5>';
125 125
 		}
126 126
 		else {
127
-			$hook=$wp_filter;
128
-			ksort( $hook );
127
+			$hook = $wp_filter;
128
+			ksort($hook);
129 129
 		}
130
-		foreach( $hook as $tag => $priorities ) {
130
+		foreach ($hook as $tag => $priorities) {
131 131
 			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag</strong><br />";
132
-			ksort( $priorities );
133
-			foreach( $priorities as $priority => $function ){
132
+			ksort($priorities);
133
+			foreach ($priorities as $priority => $function) {
134 134
 				echo $priority;
135
-				foreach( $function as $name => $properties ) {
135
+				foreach ($function as $name => $properties) {
136 136
 					echo "\t$name<br />";
137 137
 				}
138 138
 			}
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	 * @param string $hook_name
149 149
 	 * @return array
150 150
 	 */
151
-	public static function registered_filter_callbacks( $hook_name = '' ) {
151
+	public static function registered_filter_callbacks($hook_name = '') {
152 152
 		$filters = array();
153 153
 		global $wp_filter;
154
-		if ( isset( $wp_filter[ $hook_name ] ) ) {
155
-			$filters[ $hook_name ] = array();
156
-			foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) {
157
-				$filters[ $hook_name ][ $priority ] = array();
158
-				foreach ( $callbacks as $callback ) {
159
-					$filters[ $hook_name ][ $priority ][] = $callback['function'];
154
+		if (isset($wp_filter[$hook_name])) {
155
+			$filters[$hook_name] = array();
156
+			foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
157
+				$filters[$hook_name][$priority] = array();
158
+				foreach ($callbacks as $callback) {
159
+					$filters[$hook_name][$priority][] = $callback['function'];
160 160
 				}
161 161
 			}
162 162
 		}
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 * 	start_timer
170 170
 	 * @param null $timer_name
171 171
 	 */
172
-	public function start_timer( $timer_name = NULL ){
173
-		$this->_start_times[$timer_name] = microtime( TRUE );
172
+	public function start_timer($timer_name = NULL) {
173
+		$this->_start_times[$timer_name] = microtime(TRUE);
174 174
 	}
175 175
 
176 176
 
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 	 * stop_timer
180 180
 	 * @param string $timer_name
181 181
 	 */
182
-	public function stop_timer($timer_name = 'default'){
183
-		if( isset( $this->_start_times[ $timer_name ] ) ){
184
-			$start_time = $this->_start_times[ $timer_name ];
185
-			unset( $this->_start_times[ $timer_name ] );
186
-		}else{
187
-			$start_time = array_pop( $this->_start_times );
182
+	public function stop_timer($timer_name = 'default') {
183
+		if (isset($this->_start_times[$timer_name])) {
184
+			$start_time = $this->_start_times[$timer_name];
185
+			unset($this->_start_times[$timer_name]);
186
+		} else {
187
+			$start_time = array_pop($this->_start_times);
188 188
 		}
189
-		$total_time = microtime( TRUE ) - $start_time;
190
-		switch ( $total_time ) {
189
+		$total_time = microtime(TRUE) - $start_time;
190
+		switch ($total_time) {
191 191
 			case $total_time < 0.00001 :
192 192
 				$color = '#8A549A';
193 193
 				$bold = 'normal';
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 				$bold = 'bold';
214 214
 				break;
215 215
 		}
216
-		$this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0em 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name;
216
+		$this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0em 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name;
217 217
 	 }
218 218
 	 /**
219 219
 	  * Measure the memory usage by PHP so far.
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	  * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
222 222
 	  * @return void
223 223
 	  */
224
-	 public function measure_memory( $label, $output_now = false ) {
225
-		 $memory_used = $this->convert( memory_get_peak_usage( true ) );
226
-		 $this->_memory_usage_points[ $label ] = $memory_used;
227
-		 if( $output_now ) {
224
+	 public function measure_memory($label, $output_now = false) {
225
+		 $memory_used = $this->convert(memory_get_peak_usage(true));
226
+		 $this->_memory_usage_points[$label] = $memory_used;
227
+		 if ($output_now) {
228 228
 			 echo "\r\n<br>$label : $memory_used";
229 229
 		 }
230 230
 	 }
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	  * @param int $size
235 235
 	  * @return string
236 236
 	  */
237
-	 public function convert( $size ) {
238
-		$unit=array('b','kb','mb','gb','tb','pb');
239
-		return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ];
237
+	 public function convert($size) {
238
+		$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
239
+		return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)];
240 240
 	 }
241 241
 
242 242
 
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 	 * @param bool $output_now
247 247
 	 * @return string
248 248
 	 */
249
-	public function show_times($output_now=true){
250
-		$output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points );
251
-		 if($output_now){
249
+	public function show_times($output_now = true) {
250
+		$output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points);
251
+		 if ($output_now) {
252 252
 			 echo $output;
253 253
 			 return '';
254 254
 		 }
@@ -263,27 +263,27 @@  discard block
 block discarded – undo
263 263
 	 * 	@return void
264 264
 	 */
265 265
 	public static function ee_plugin_activation_errors() {
266
-		if ( defined('WP_DEBUG') && WP_DEBUG ) {
266
+		if (defined('WP_DEBUG') && WP_DEBUG) {
267 267
 			$activation_errors = ob_get_contents();
268
-			if ( class_exists( 'EE_Registry' )) {
269
-				EE_Registry::instance()->load_helper( 'File' );
268
+			if (class_exists('EE_Registry')) {
269
+				EE_Registry::instance()->load_helper('File');
270 270
 			} else {
271
-				include_once( EE_HELPERS . 'EEH_File.helper.php' );
271
+				include_once(EE_HELPERS.'EEH_File.helper.php');
272 272
 			}
273
-			if ( class_exists( 'EEH_File' )) {
273
+			if (class_exists('EEH_File')) {
274 274
 				try {
275
-					EEH_File::ensure_folder_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS );
276
-					EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' );
277
-					EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
278
-				} catch( EE_Error $e ){
279
-					EE_Error::add_error( sprintf( __(  'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
275
+					EEH_File::ensure_folder_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS);
276
+					EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html');
277
+					EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
278
+				} catch (EE_Error $e) {
279
+					EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
280 280
 				}
281 281
 			} else {
282 282
 				// old school attempt
283
-				file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
283
+				file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
284 284
 			}
285
-			$activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors;
286
-			update_option( 'ee_plugin_activation_errors', $activation_errors );
285
+			$activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
286
+			update_option('ee_plugin_activation_errors', $activation_errors);
287 287
 		}
288 288
 	}
289 289
 
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 	 * @param int     $error_type
300 300
 	 * @uses trigger_error()
301 301
 	 */
302
-	public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) {
303
-		do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
304
-		$version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version );
305
-		trigger_error( sprintf( __('%1$s was called <strong>incorrectly</strong>. %2$s %3$s','event_espresso' ), $function, $message, $version ), $error_type );
302
+	public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) {
303
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
304
+		$version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version);
305
+		trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', 'event_espresso'), $function, $message, $version), $error_type);
306 306
 	}
307 307
 
308 308
 
@@ -323,22 +323,22 @@  discard block
 block discarded – undo
323 323
 	 * @param string $debug_index
324 324
 	 * @param string $debug_key
325 325
 	 */
326
-	public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false,  $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) {
327
-		if ( WP_DEBUG && false ) {
328
-			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
329
-			$debug_data = get_option( $debug_key, array() );
326
+	public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') {
327
+		if (WP_DEBUG && false) {
328
+			$debug_key = $debug_key.'_'.EE_Session::instance()->id();
329
+			$debug_data = get_option($debug_key, array());
330 330
 			$default_data = array(
331
-				$class => $func . '() : ' . $line,
331
+				$class => $func.'() : '.$line,
332 332
 				'REQ'  => $display_request ? $_REQUEST : '',
333 333
 			);
334 334
 			// don't serialize objects
335
-			$info = self::strip_objects( $info );
336
-			$index = ! empty( $debug_index ) ? $debug_index : 0;
337
-			if ( ! isset( $debug_data[$index] ) ) {
335
+			$info = self::strip_objects($info);
336
+			$index = ! empty($debug_index) ? $debug_index : 0;
337
+			if ( ! isset($debug_data[$index])) {
338 338
 				$debug_data[$index] = array();
339 339
 			}
340
-			$debug_data[$index][microtime()] = array_merge( $default_data, $info );
341
-			update_option( $debug_key, $debug_data );
340
+			$debug_data[$index][microtime()] = array_merge($default_data, $info);
341
+			update_option($debug_key, $debug_data);
342 342
 		}
343 343
 	}
344 344
 
@@ -350,26 +350,26 @@  discard block
 block discarded – undo
350 350
 	 * @param array $info
351 351
 	 * @return array
352 352
 	 */
353
-	public static function strip_objects( $info = array() ) {
354
-		foreach ( $info as $key => $value ) {
355
-			if ( is_array( $value ) ) {
356
-				$info[ $key ] = self::strip_objects( $value );
357
-			} else if ( is_object( $value ) ) {
358
-				$object_class = get_class( $value );
359
-				$info[ $object_class ] = array();
360
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value );
361
-				if ( method_exists( $value, 'ID' ) ) {
362
-					$info[ $object_class ][ 'ID' ] = $value->ID();
353
+	public static function strip_objects($info = array()) {
354
+		foreach ($info as $key => $value) {
355
+			if (is_array($value)) {
356
+				$info[$key] = self::strip_objects($value);
357
+			} else if (is_object($value)) {
358
+				$object_class = get_class($value);
359
+				$info[$object_class] = array();
360
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
361
+				if (method_exists($value, 'ID')) {
362
+					$info[$object_class]['ID'] = $value->ID();
363 363
 				}
364
-				if ( method_exists( $value, 'status' ) ) {
365
-					$info[ $object_class ][ 'status' ] = $value->status();
366
-				} else if ( method_exists( $value, 'status_ID' ) ) {
367
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
364
+				if (method_exists($value, 'status')) {
365
+					$info[$object_class]['status'] = $value->status();
366
+				} else if (method_exists($value, 'status_ID')) {
367
+					$info[$object_class]['status'] = $value->status_ID();
368 368
 				}
369
-				unset( $info[ $key ] );
369
+				unset($info[$key]);
370 370
 			}
371 371
 		}
372
-		return (array)$info;
372
+		return (array) $info;
373 373
 	}
374 374
 
375 375
 
@@ -386,31 +386,31 @@  discard block
 block discarded – undo
386 386
 	 * @param string $height
387 387
 	 * @param bool $die
388 388
 	 */
389
-	public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false ) {
389
+	public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false) {
390 390
 		//$print_r = false;
391
-		if ( is_object( $var ) ) {
391
+		if (is_object($var)) {
392 392
 			$var_name = ! $var_name ? 'object' : $var_name;
393 393
 			//$print_r = true;
394
-		} else if ( is_array( $var ) ) {
394
+		} else if (is_array($var)) {
395 395
 			$var_name = ! $var_name ? 'array' : $var_name;
396 396
 			//$print_r = true;
397
-		} else if ( is_numeric( $var ) ) {
397
+		} else if (is_numeric($var)) {
398 398
 			$var_name = ! $var_name ? 'numeric' : $var_name;
399
-		} else if ( is_string( $var ) ) {
399
+		} else if (is_string($var)) {
400 400
 			$var_name = ! $var_name ? 'string' : $var_name;
401
-		} else if ( is_null( $var ) ) {
401
+		} else if (is_null($var)) {
402 402
 			$var_name = ! $var_name ? 'null' : $var_name;
403 403
 		}
404
-		$var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) );
404
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
405 405
 		ob_start();
406
-		echo '<pre style="display:block; width:100%; height:' . $height . '; border:2px solid light-blue;">';
407
-		echo '<h5 style="color:#2EA2CC;"><b>' . $var_name . '</b></h5><span style="color:#E76700">';
406
+		echo '<pre style="display:block; width:100%; height:'.$height.'; border:2px solid light-blue;">';
407
+		echo '<h5 style="color:#2EA2CC;"><b>'.$var_name.'</b></h5><span style="color:#E76700">';
408 408
 		//$print_r ? print_r( $var ) : var_dump( $var );
409
-		var_dump( $var );
410
-		echo '</span><br /><span style="font-size:10px;font-weight:normal;">' . $file . '<br />line no: ' . $line . '</span></pre>';
409
+		var_dump($var);
410
+		echo '</span><br /><span style="font-size:10px;font-weight:normal;">'.$file.'<br />line no: '.$line.'</span></pre>';
411 411
 		$result = ob_get_clean();
412
-		if ( $die ) {
413
-			die( $result );
412
+		if ($die) {
413
+			die($result);
414 414
 		} else {
415 415
 			echo $result;
416 416
 		}
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
  * borrowed from Kint Debugger
428 428
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
429 429
  */
430
-if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) {
431
-	function dump_wp_query(){
430
+if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
431
+	function dump_wp_query() {
432 432
 		global $wp_query;
433 433
 		d($wp_query);
434 434
 	}
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
  * borrowed from Kint Debugger
439 439
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
440 440
  */
441
-if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) {
442
-	function dump_wp(){
441
+if (class_exists('Kint') && ! function_exists('dump_wp')) {
442
+	function dump_wp() {
443 443
 		global $wp;
444 444
 		d($wp);
445 445
 	}
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
  * borrowed from Kint Debugger
450 450
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
451 451
  */
452
-if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) {
453
-	function dump_post(){
452
+if (class_exists('Kint') && ! function_exists('dump_post')) {
453
+	function dump_post() {
454 454
 		global $post;
455 455
 		d($post);
456 456
 	}
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Class EEH_Debug_Tools
4 6
  *
@@ -122,8 +124,7 @@  discard block
 block discarded – undo
122 124
 				return;
123 125
 			}
124 126
 			echo '<h5>For Tag: '. $tag .'</h5>';
125
-		}
126
-		else {
127
+		} else {
127 128
 			$hook=$wp_filter;
128 129
 			ksort( $hook );
129 130
 		}
@@ -183,7 +184,7 @@  discard block
 block discarded – undo
183 184
 		if( isset( $this->_start_times[ $timer_name ] ) ){
184 185
 			$start_time = $this->_start_times[ $timer_name ];
185 186
 			unset( $this->_start_times[ $timer_name ] );
186
-		}else{
187
+		} else{
187 188
 			$start_time = array_pop( $this->_start_times );
188 189
 		}
189 190
 		$total_time = microtime( TRUE ) - $start_time;
Please login to merge, or discard this patch.
core/helpers/EEH_Event_Query.helper.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * Event Espresso
6
- *
7
- * Event Registration and Ticketing Management Plugin for WordPress
8
- *
9
- * @ package            Event Espresso
10
- * @ author                Event Espresso
11
- * @ copyright        (c) 2008-2014 Event Espresso  All Rights Reserved.
12
- * @ license            http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
13
- * @ link                    http://www.eventespresso.com
14
- * @ version            $VID:$
15
- *
16
- * ------------------------------------------------------------------------
17
- */
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Ticketing Management Plugin for WordPress
8
+	 *
9
+	 * @ package            Event Espresso
10
+	 * @ author                Event Espresso
11
+	 * @ copyright        (c) 2008-2014 Event Espresso  All Rights Reserved.
12
+	 * @ license            http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
13
+	 * @ link                    http://www.eventespresso.com
14
+	 * @ version            $VID:$
15
+	 *
16
+	 * ------------------------------------------------------------------------
17
+	 */
18 18
 
19 19
 
20 20
 
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function add_query_filters() {
87 87
 		//add query filters
88
-		add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 );
88
+		add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1);
89 89
 	}
90 90
 
91 91
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param \WP_Query $WP_Query
98 98
 	 * @return bool
99 99
 	 */
100
-	public static function apply_query_filters( WP_Query $WP_Query ) {
101
-		return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false;
100
+	public static function apply_query_filters(WP_Query $WP_Query) {
101
+		return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false;
102 102
 	}
103 103
 
104 104
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 * @access    public
109 109
 	 * @param \WP_Query $WP_Query
110 110
 	 */
111
-	public static function filter_query_parts( WP_Query $WP_Query ) {
111
+	public static function filter_query_parts(WP_Query $WP_Query) {
112 112
 		//ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in.
113
-		if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) {
113
+		if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) {
114 114
 			// build event list query
115
-			add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 );
116
-			add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 );
117
-			add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 );
118
-			add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 );
119
-			add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 );
115
+			add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2);
116
+			add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2);
117
+			add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2);
118
+			add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2);
119
+			add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2);
120 120
 		}
121 121
 	}
122 122
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 	 * @param string $orderby
132 132
 	 * @param string $sort
133 133
 	 */
134
-	public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) {
134
+	public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') {
135 135
 		self::$_query_params = array();
136
-		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month );
137
-		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category );
138
-		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired );
139
-		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby );
140
-		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort );
136
+		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month);
137
+		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category);
138
+		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired);
139
+		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby);
140
+		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort);
141 141
 	}
142 142
 
143 143
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param string $month
150 150
 	 * @return    string
151 151
 	 */
152
-	private static function _display_month( $month = '' ) {
153
-		return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month;
152
+	private static function _display_month($month = '') {
153
+		return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month;
154 154
 	}
155 155
 
156 156
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @param string $category
163 163
 	 * @return    string
164 164
 	 */
165
-	private static function _event_category_slug( $category = '' ) {
166
-		return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category;
165
+	private static function _event_category_slug($category = '') {
166
+		return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category;
167 167
 	}
168 168
 
169 169
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @param bool $show_expired
176 176
 	 * @return    boolean
177 177
 	 */
178
-	private static function _show_expired( $show_expired = FALSE ) {
178
+	private static function _show_expired($show_expired = FALSE) {
179 179
 		// override default expired option if set via filter
180
-		$_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired;
181
-		return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN );
180
+		$_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired;
181
+		return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN);
182 182
 	}
183 183
 
184 184
 
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 	 * @param    string $orderby
191 191
 	 * @return    array
192 192
 	 */
193
-	private static function _orderby( $orderby = 'start_date' ) {
194
-		$event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby;
195
-		$event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby );
196
-		$event_query_orderby = array_map( 'trim', $event_query_orderby );
193
+	private static function _orderby($orderby = 'start_date') {
194
+		$event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby;
195
+		$event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby);
196
+		$event_query_orderby = array_map('trim', $event_query_orderby);
197 197
 		return $event_query_orderby;
198 198
 	}
199 199
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @param string $sort
207 207
 	 * @return    array
208 208
 	 */
209
-	private static function _sort( $sort = 'ASC' ) {
210
-		$sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort;
211
-		return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC';
209
+	private static function _sort($sort = 'ASC') {
210
+		$sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort;
211
+		return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC';
212 212
 	}
213 213
 
214 214
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return array   array of clauses
223 223
 	 */
224
-	public static function posts_clauses( $clauses, WP_Query $wp_query ) {
225
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
224
+	public static function posts_clauses($clauses, WP_Query $wp_query) {
225
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
226 226
 			$clauses['distinct'] = "DISTINCT";
227 227
 		}
228 228
 		return $clauses;
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 	 * @param WP_Query $wp_query
239 239
 	 * @return    string
240 240
 	 */
241
-	public static function posts_fields( $SQL, WP_Query $wp_query ) {
242
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
241
+	public static function posts_fields($SQL, WP_Query $wp_query) {
242
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
243 243
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
244
-			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby );
244
+			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby);
245 245
 		}
246 246
 		return $SQL;
247 247
 	}
@@ -256,29 +256,29 @@  discard block
 block discarded – undo
256 256
 	 * @internal  param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
257 257
 	 * @return    string
258 258
 	 */
259
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
260
-		$SQL= '';
261
-		foreach( (array)$orderby_params as $orderby ) {
262
-			switch ( $orderby ) {
259
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
260
+		$SQL = '';
261
+		foreach ((array) $orderby_params as $orderby) {
262
+			switch ($orderby) {
263 263
 
264 264
 				case 'ticket_start' :
265
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ;
265
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date';
266 266
 					break;
267 267
 
268 268
 				case 'ticket_end' :
269
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ;
269
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date';
270 270
 					break;
271 271
 
272 272
 				case 'venue_title' :
273
-					$SQL .= ', Venue.post_title AS venue_title' ;
273
+					$SQL .= ', Venue.post_title AS venue_title';
274 274
 					break;
275 275
 
276 276
 				case 'city' :
277
-					$SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ;
277
+					$SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city';
278 278
 					break;
279 279
 
280 280
 				case 'state' :
281
-					$SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ;
281
+					$SQL .= ', '.EEM_State::instance()->table().'.STA_name';
282 282
 					break;
283 283
 
284 284
 			}
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
 	 * @param WP_Query $wp_query
297 297
 	 * @return    string
298 298
 	 */
299
-	public static function posts_join( $SQL = '', WP_Query $wp_query ) {
300
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
299
+	public static function posts_join($SQL = '', WP_Query $wp_query) {
300
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
301 301
 			// Category
302
-			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired );
303
-			$SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category );
304
-			$SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby );
302
+			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired);
303
+			$SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category);
304
+			$SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby);
305 305
 		}
306 306
 		return $SQL;
307 307
 	}
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 	 * @param    boolean $show_expired if TRUE, then displayed past events
317 317
 	 * @return string
318 318
 	 */
319
-	public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) {
320
-		if ( ! $show_expired ) {
321
-			$join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
322
-			if ( strpos( $SQL, $join ) === FALSE ) {
323
-				$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) ';
319
+	public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) {
320
+		if ( ! $show_expired) {
321
+			$join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
322
+			if (strpos($SQL, $join) === FALSE) {
323
+				$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) ';
324 324
 			}
325 325
 		}
326 326
 		return $SQL;
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @param 	string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
337 337
 	 * @return 	string
338 338
 	 */
339
-	public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) {
340
-		if ( ! empty( $join_terms ) ) {
339
+	public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') {
340
+		if ( ! empty($join_terms)) {
341 341
 			global $wpdb;
342 342
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
343 343
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -357,25 +357,25 @@  discard block
 block discarded – undo
357 357
 	 * @param 	array $orderby_params
358 358
 	 * @return 	string
359 359
 	 */
360
-	public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) {
361
-		foreach ( (array)$orderby_params as $orderby ) {
362
-			switch ( $orderby ) {
360
+	public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) {
361
+		foreach ((array) $orderby_params as $orderby) {
362
+			switch ($orderby) {
363 363
 				case 'ticket_start' :
364 364
 				case 'ticket_end' :
365
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() );
366
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )';
365
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name());
366
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )';
367 367
 					break;
368 368
 				case 'venue_title' :
369 369
 				case 'city' :
370
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
370
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
371 371
 					break;
372 372
 				case 'state' :
373
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
374
-					$SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL );
373
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
374
+					$SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL);
375 375
 					break;
376 376
 				case 'start_date' :
377 377
 				default :
378
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' );
378
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID');
379 379
 					break;
380 380
 
381 381
 			}
@@ -393,11 +393,11 @@  discard block
 block discarded – undo
393 393
 	 * @param string $join
394 394
 	 * @return string
395 395
 	 */
396
-	protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) {
397
-		if ( ! empty( $join )) {
398
-			$join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
399
-			if ( strpos( $SQL, $join ) === FALSE ) {
400
-				return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )';
396
+	protected static function _posts_join_for_datetime($SQL = '', $join = '') {
397
+		if ( ! empty($join)) {
398
+			$join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
399
+			if (strpos($SQL, $join) === FALSE) {
400
+				return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )';
401 401
 			}
402 402
 		}
403 403
 		return '';
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 	 * @param string $SQL
413 413
 	 * @return string
414 414
 	 */
415
-	protected static function _posts_join_for_event_venue( $SQL = '' ) {
415
+	protected static function _posts_join_for_event_venue($SQL = '') {
416 416
 		// Event Venue table name
417 417
 		$event_venue_table = EEM_Event_Venue::instance()->table();
418 418
 		// generate conditions for:  Event <=> Event Venue  JOIN clause
419
-		$event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name();
419
+		$event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name();
420 420
 		// don't add joins if they have already been added
421
-		if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) {
421
+		if (strpos($SQL, $event_to_event_venue_join) === FALSE) {
422 422
 			// Venue table name
423 423
 			$venue_table = EEM_Venue::instance()->table();
424 424
 			// Venue table pk
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 			$venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )";
432 432
 			// generate JOIN clause for: Venue <=> Venue Meta
433 433
 			$venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )";
434
-			unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table );
434
+			unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table);
435 435
 			return $venue_SQL;
436 436
 		}
437
-		unset( $event_venue_table, $event_to_event_venue_join );
437
+		unset($event_venue_table, $event_to_event_venue_join);
438 438
 		return '';
439 439
 	}
440 440
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 * @param string $SQL
448 448
 	 * @return string
449 449
 	 */
450
-	protected static function _posts_join_for_venue_state( $SQL = '' ) {
450
+	protected static function _posts_join_for_venue_state($SQL = '') {
451 451
 		// Venue Meta table name
452 452
 		$venue_meta_table = EEM_Venue::instance()->second_table();
453 453
 		// State table name
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 		// State table pk
456 456
 		$state_table_pk = EEM_State::instance()->primary_key_name();
457 457
 		// verify vars
458
-		if ( $venue_meta_table && $state_table && $state_table_pk ) {
458
+		if ($venue_meta_table && $state_table && $state_table_pk) {
459 459
 			// like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID
460 460
 			$join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk";
461 461
 			// don't add join if it has already been added
462
-			if ( strpos( $SQL, $join ) === FALSE ) {
463
-				unset( $state_table_pk, $venue_meta_table, $venue_table_pk );
462
+			if (strpos($SQL, $join) === FALSE) {
463
+				unset($state_table_pk, $venue_meta_table, $venue_table_pk);
464 464
 				return " LEFT JOIN $state_table ON ( $join )";
465 465
 			}
466 466
 		}
467
-		unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk );
467
+		unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk);
468 468
 		return '';
469 469
 	}
470 470
 
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
 	 * @param WP_Query $wp_query
479 479
 	 * @return    string
480 480
 	 */
481
-	public static function posts_where( $SQL = '', WP_Query $wp_query ) {
482
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
481
+	public static function posts_where($SQL = '', WP_Query $wp_query) {
482
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
483 483
 			// Show Expired ?
484
-			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired  );
484
+			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired);
485 485
 			// Category
486
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category  );
486
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category);
487 487
 			// Start Date
488
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month );
488
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month);
489 489
 		}
490 490
 		return $SQL;
491 491
 	}
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 	 * @param    boolean $show_expired if TRUE, then displayed past events
500 500
 	 * @return    string
501 501
 	 */
502
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
503
-		return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', TRUE ) . '" ' : '';
502
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
503
+		return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', TRUE).'" ' : '';
504 504
 	}
505 505
 
506 506
 
@@ -512,9 +512,9 @@  discard block
 block discarded – undo
512 512
 	 * @param    boolean $event_category_slug
513 513
 	 * @return    string
514 514
 	 */
515
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
515
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
516 516
 		global $wpdb;
517
-		return ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
517
+		return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : '';
518 518
 	}
519 519
 
520 520
 
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
 	 * @param    boolean $month
527 527
 	 * @return    string
528 528
 	 */
529
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
529
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
530 530
 		$SQL = '';
531
-		if ( ! empty( $month ) ) {
531
+		if ( ! empty($month)) {
532 532
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
533
-			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . gmdate( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"';
533
+			$SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.gmdate('Y-m-t 23:59:59', strtotime($month)).'"';
534 534
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
535
-			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . gmdate( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" ';
535
+			$SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.gmdate('Y-m-01 0:0:00', strtotime($month)).'" ';
536 536
 		}
537 537
 		return $SQL;
538 538
 	}
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
 	 * @param WP_Query $wp_query
548 548
 	 * @return    string
549 549
 	 */
550
-	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
551
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
552
-			$SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort );
550
+	public static function posts_orderby($SQL = '', WP_Query $wp_query) {
551
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
552
+			$SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort);
553 553
 		}
554 554
 		return $SQL;
555 555
 	}
@@ -580,63 +580,63 @@  discard block
 block discarded – undo
580 580
 	 * @param string     $sort
581 581
 	 * @return string
582 582
 	 */
583
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
583
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
584 584
 		global $wpdb;
585 585
 		$SQL = '';
586 586
 		$counter = 0;
587 587
 		//make sure 'orderby' is set in query params
588
-		if ( ! isset( self::$_query_params['orderby'] )) {
588
+		if ( ! isset(self::$_query_params['orderby'])) {
589 589
 			self::$_query_params['orderby'] = array();
590 590
 		}
591 591
 		// loop thru $orderby_params (type cast as array)
592
-		foreach ( (array)$orderby_params as $orderby ) {
592
+		foreach ((array) $orderby_params as $orderby) {
593 593
 			// check if we have already added this param
594
-			if ( isset( self::$_query_params['orderby'][ $orderby ] )) {
594
+			if (isset(self::$_query_params['orderby'][$orderby])) {
595 595
 				// if so then remove from the $orderby_params so that the count() method below is accurate
596
-				unset( $orderby_params[ $orderby ] );
596
+				unset($orderby_params[$orderby]);
597 597
 				// then bump ahead to the next param
598 598
 				continue;
599 599
 			}
600 600
 			// this will ad a comma depending on whether this is the first or last param
601
-			$glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', ';
601
+			$glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', ';
602 602
 			// ok what's we dealing with?
603
-			switch ( $orderby ) {
603
+			switch ($orderby) {
604 604
 				case 'id' :
605 605
 				case 'ID' :
606
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
606
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
607 607
 					break;
608 608
 				case 'end_date' :
609
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
609
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
610 610
 					break;
611 611
 				case 'event_name' :
612
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
612
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
613 613
 					break;
614 614
 				case 'category_slug' :
615
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
615
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
616 616
 					break;
617 617
 				case 'ticket_start' :
618
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
618
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
619 619
 					break;
620 620
 				case 'ticket_end' :
621
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
621
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
622 622
 					break;
623 623
 				case 'venue_title' :
624
-					$SQL .= $glue . 'venue_title ' . $sort;
624
+					$SQL .= $glue.'venue_title '.$sort;
625 625
 					break;
626 626
 				case 'city' :
627
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
627
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
628 628
 					break;
629 629
 				case 'state' :
630
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
630
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
631 631
 					break;
632 632
 				case 'start_date' :
633 633
 				default :
634
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
634
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort;
635 635
 					break;
636 636
 			}
637 637
 			// add to array of orderby params that have been added
638
-			self::$_query_params['orderby'][ $orderby ] = TRUE;
639
-			$counter ++;
638
+			self::$_query_params['orderby'][$orderby] = TRUE;
639
+			$counter++;
640 640
 		}
641 641
 		return $SQL;
642 642
 	}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
 	 *
230 230
 	 * @access    public
231 231
 	 * @param string $event_list_css
232
-	 * @return    array
232
+	 * @return    string
233 233
 	 */
234 234
 	public function event_list_css( $event_list_css = '' ) {
235 235
 		$event_list_css .=  ! empty( $event_list_css ) ? ' ' : '';
Please login to merge, or discard this patch.
core/helpers/EEH_File.helper.php 2 patches
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @ version		 	4.0
13 13
  *
14 14
  */
15
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
15
+require_once(EE_HELPERS.'EEH_Base.helper.php');
16 16
 /**
17 17
  *
18 18
  * Class EEH_File
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	private static function _get_wp_filesystem() {
42 42
 		global $wp_filesystem;
43 43
 		// no filesystem setup ???
44
-		if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
44
+		if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
45 45
 			// if some eager beaver's just trying to get in there too early...
46 46
 			// let them do it, because we are one of those eager beavers! :P
47 47
 			/**
@@ -54,29 +54,29 @@  discard block
 block discarded – undo
54 54
 			 * and there may be troubles if the WP files are owned by a different user
55 55
 			 * than the server user. But both of these issues should exist in 4.4 and earlier too
56 56
 			 */
57
-			if ( FALSE && ! did_action( 'wp_loaded' )) {
57
+			if (FALSE && ! did_action('wp_loaded')) {
58 58
 				$msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
59
-				if ( WP_DEBUG ) {
60
-					$msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
59
+				if (WP_DEBUG) {
60
+					$msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
61 61
 				}
62
-				throw new EE_Error( $msg );
62
+				throw new EE_Error($msg);
63 63
 			} else {
64 64
 				// should be loaded if we are past the wp_loaded hook...
65
-				if ( ! function_exists( 'WP_Filesystem' )) {
66
-					require_once( ABSPATH . 'wp-admin/includes/file.php' );
67
-					require_once( ABSPATH . 'wp-admin/includes/template.php' );
65
+				if ( ! function_exists('WP_Filesystem')) {
66
+					require_once(ABSPATH.'wp-admin/includes/file.php');
67
+					require_once(ABSPATH.'wp-admin/includes/template.php');
68 68
 				}
69 69
 				// basically check for direct or previously configured access
70
-				if ( ! WP_Filesystem() ) {
70
+				if ( ! WP_Filesystem()) {
71 71
 					// turn on output buffering so that we can capture the credentials form
72 72
 					ob_start();
73
-					$credentials = request_filesystem_credentials( '' );
73
+					$credentials = request_filesystem_credentials('');
74 74
 					// store credentials form for the time being
75 75
 					EEH_File::$_credentials_form = ob_get_clean();
76 76
 					// if credentials do NOT exist
77
-					if ( $credentials === FALSE ) {
78
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
79
-						throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
77
+					if ($credentials === FALSE) {
78
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
79
+						throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
80 80
 					}
81 81
 				}
82 82
 			}
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 * display_request_filesystem_credentials_form
90 90
 	 */
91 91
 	public static function display_request_filesystem_credentials_form() {
92
-		if ( ! empty( EEH_File::$_credentials_form )) {
93
-			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
92
+		if ( ! empty(EEH_File::$_credentials_form)) {
93
+			echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
94 94
 		}
95 95
 	}
96 96
 
@@ -108,29 +108,29 @@  discard block
 block discarded – undo
108 108
 	 * @throws EE_Error
109 109
 	 * @return bool
110 110
 	 */
111
-	public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) {
111
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') {
112 112
 		// load WP_Filesystem and set file permissions
113 113
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
114
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
115
-		if ( ! $wp_filesystem->is_readable( $full_file_path )) {
116
-			$file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name;
117
-			$file_name .= ! empty( $file_ext ) ? ' file' : ' folder';
114
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
115
+		if ( ! $wp_filesystem->is_readable($full_file_path)) {
116
+			$file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
117
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
118 118
 			$msg = sprintf(
119
-				__( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ),
119
+				__('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
120 120
 				$file_name,
121 121
 				'<br />'
122 122
 			);
123
-			if ( EEH_File::exists( $full_file_path )) {
124
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file );
123
+			if (EEH_File::exists($full_file_path)) {
124
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
125 125
 			} else {
126 126
 				// no file permissions means the file was not found
127 127
 				$msg .= sprintf(
128
-					__( 'Please ensure the following path is correct: "%s".', 'event_espresso' ),
128
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
129 129
 					$full_file_path
130 130
 				);
131 131
 			}
132
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
133
-				throw new EE_Error( $msg . '||' . $msg );
132
+			if (defined('WP_DEBUG') && WP_DEBUG) {
133
+				throw new EE_Error($msg.'||'.$msg);
134 134
 			}
135 135
 			return FALSE;
136 136
 		}
@@ -147,24 +147,24 @@  discard block
 block discarded – undo
147 147
 	 * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages
148 148
 	 * @return string
149 149
 	 */
150
-	private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){
150
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') {
151 151
 		// load WP_Filesystem and set file permissions
152 152
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
153 153
 		// check file permissions
154
-		$perms = $wp_filesystem->getchmod( $full_file_path );
155
-		if ( $perms ) {
154
+		$perms = $wp_filesystem->getchmod($full_file_path);
155
+		if ($perms) {
156 156
 			// file permissions exist, but way be set incorrectly
157
-			$type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : '';
158
-			$type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder';
157
+			$type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
158
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
159 159
 			return sprintf(
160
-				__( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ),
160
+				__('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
161 161
 				$type_of_file,
162 162
 				$perms
163 163
 			);
164 164
 		} else {
165 165
 			// file exists but file permissions could not be read ?!?!
166 166
 			return sprintf(
167
-				__( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ),
167
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
168 168
 				$full_file_path
169 169
 			);
170 170
 		}
@@ -179,33 +179,33 @@  discard block
 block discarded – undo
179 179
 	 * @throws EE_Error
180 180
 	 * @return bool
181 181
 	 */
182
-	public static function ensure_folder_exists_and_is_writable( $folder = '' ){
183
-		if ( empty( $folder )) {
182
+	public static function ensure_folder_exists_and_is_writable($folder = '') {
183
+		if (empty($folder)) {
184 184
 			return FALSE;
185 185
 		}
186 186
 		// remove ending DS
187
-		$folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' ));
187
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
188 188
 		// determine parent folder
189
-		$folder_segments = explode( DS, $folder );
190
-		array_pop( $folder_segments );
191
-		$parent_folder = implode( DS, $folder_segments ) . DS;
189
+		$folder_segments = explode(DS, $folder);
190
+		array_pop($folder_segments);
191
+		$parent_folder = implode(DS, $folder_segments).DS;
192 192
 		// add DS to folder
193
-		$folder = EEH_File::end_with_directory_separator( $folder );
193
+		$folder = EEH_File::end_with_directory_separator($folder);
194 194
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
195
-		if ( ! $wp_filesystem->is_dir( $folder )) {
196
-			if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) {
195
+		if ( ! $wp_filesystem->is_dir($folder)) {
196
+			if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
197 197
 				return FALSE;
198 198
 			} else {
199
-				if ( ! $wp_filesystem->mkdir( $folder )) {
200
-					if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
201
-						$msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder );
202
-						$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder );
203
-						throw new EE_Error( $msg );
199
+				if ( ! $wp_filesystem->mkdir($folder)) {
200
+					if (defined('WP_DEBUG') && WP_DEBUG) {
201
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
202
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
203
+						throw new EE_Error($msg);
204 204
 					}
205 205
 					return FALSE;
206 206
 				}
207 207
 			}
208
-		} elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
208
+		} elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
209 209
 			return FALSE;
210 210
 		}
211 211
 		return TRUE;
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
 	 * @throws EE_Error
221 221
 	 * @return bool
222 222
 	 */
223
-	public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){
223
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') {
224 224
 		// load WP_Filesystem and set file permissions
225 225
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
226
-		$full_path = EEH_File::standardise_directory_separators( $full_path );
227
-		if ( ! $wp_filesystem->is_writable( $full_path )) {
228
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
229
-				$msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder );
230
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path );
231
-				throw new EE_Error( $msg );
226
+		$full_path = EEH_File::standardise_directory_separators($full_path);
227
+		if ( ! $wp_filesystem->is_writable($full_path)) {
228
+			if (defined('WP_DEBUG') && WP_DEBUG) {
229
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
230
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
231
+				throw new EE_Error($msg);
232 232
 			}
233 233
 			return FALSE;
234 234
 		}
@@ -244,21 +244,21 @@  discard block
 block discarded – undo
244 244
 	 * @throws EE_Error
245 245
 	 * @return bool
246 246
 	 */
247
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) {
247
+	public static function ensure_file_exists_and_is_writable($full_file_path = '') {
248 248
 		// load WP_Filesystem and set file permissions
249 249
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
250
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
251
-		if ( ! EEH_File::exists( $full_file_path )) {
252
-			if ( ! $wp_filesystem->touch( $full_file_path )) {
253
-				if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
254
-					$msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path );
255
-					$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
256
-					throw new EE_Error( $msg );
250
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
251
+		if ( ! EEH_File::exists($full_file_path)) {
252
+			if ( ! $wp_filesystem->touch($full_file_path)) {
253
+				if (defined('WP_DEBUG') && WP_DEBUG) {
254
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
255
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
256
+					throw new EE_Error($msg);
257 257
 				}
258 258
 				return FALSE;
259 259
 			}
260 260
 		}
261
-		if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) {
261
+		if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
262 262
 			return FALSE;
263 263
 		}
264 264
 		return TRUE;
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 	 * @param string $full_file_path
272 272
 	 * @return string
273 273
 	 */
274
-	public static function get_file_contents( $full_file_path = '' ){
275
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
276
-		if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) {
274
+	public static function get_file_contents($full_file_path = '') {
275
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
276
+		if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
277 277
 			// load WP_Filesystem and set file permissions
278 278
 			$wp_filesystem = EEH_File::_get_wp_filesystem();
279
-			return $wp_filesystem->get_contents( $full_file_path );
279
+			return $wp_filesystem->get_contents($full_file_path);
280 280
 		}
281 281
 		return '';
282 282
 	}
@@ -291,26 +291,26 @@  discard block
 block discarded – undo
291 291
 	 * @throws EE_Error
292 292
 	 * @return bool
293 293
 	 */
294
-	public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){
295
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
296
-		$file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : '';
297
-		$folder = EEH_File::remove_filename_from_filepath( $full_file_path );
298
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
299
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
300
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path );
301
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
302
-				throw new EE_Error( $msg );
294
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') {
295
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
296
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
297
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
298
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
299
+			if (defined('WP_DEBUG') && WP_DEBUG) {
300
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
301
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
302
+				throw new EE_Error($msg);
303 303
 			}
304 304
 			return FALSE;
305 305
 		}
306 306
 		// load WP_Filesystem and set file permissions
307 307
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
308 308
 		// write the file
309
-		if ( ! $wp_filesystem->put_contents( $full_file_path, $file_contents )) {
310
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
311
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path );
312
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' );
313
-				throw new EE_Error( $msg );
309
+		if ( ! $wp_filesystem->put_contents($full_file_path, $file_contents)) {
310
+			if (defined('WP_DEBUG') && WP_DEBUG) {
311
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
312
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
313
+				throw new EE_Error($msg);
314 314
 			}
315 315
 			return FALSE;
316 316
 		}
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 	 * @param string $full_file_path
327 327
 	 * @return bool
328 328
 	 */
329
-	public static function exists( $full_file_path = '' ) {
329
+	public static function exists($full_file_path = '') {
330 330
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
331
-		return $wp_filesystem->exists( $full_file_path ) ? TRUE : FALSE;
331
+		return $wp_filesystem->exists($full_file_path) ? TRUE : FALSE;
332 332
 	}
333 333
 
334 334
 
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 	 * @param string $full_file_path
341 341
 	 * @return bool
342 342
 	 */
343
-	public static function is_readable( $full_file_path = '' ) {
343
+	public static function is_readable($full_file_path = '') {
344 344
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
345
-		return $wp_filesystem->is_readable( $full_file_path ) ? TRUE : FALSE;
345
+		return $wp_filesystem->is_readable($full_file_path) ? TRUE : FALSE;
346 346
 	}
347 347
 
348 348
 
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param string $full_file_path
355 355
 	 * @return string
356 356
 	 */
357
-	public static function remove_filename_from_filepath( $full_file_path = '' ) {
358
-		return pathinfo( $full_file_path, PATHINFO_DIRNAME );
357
+	public static function remove_filename_from_filepath($full_file_path = '') {
358
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
359 359
 	}
360 360
 
361 361
 
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param string $full_file_path
366 366
 	 * @return string
367 367
 	 */
368
-	public static function get_filename_from_filepath( $full_file_path = '' ) {
369
-		return pathinfo( $full_file_path, PATHINFO_BASENAME );
368
+	public static function get_filename_from_filepath($full_file_path = '') {
369
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
370 370
 	}
371 371
 
372 372
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param string $full_file_path
377 377
 	 * @return string
378 378
 	 */
379
-	public static function get_file_extension( $full_file_path = '' ) {
380
-		return pathinfo( $full_file_path, PATHINFO_EXTENSION );
379
+	public static function get_file_extension($full_file_path = '') {
380
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
381 381
 	}
382 382
 
383 383
 
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 	 * @param string $folder
388 388
 	 * @return bool
389 389
 	 */
390
-	public static function add_htaccess_deny_from_all( $folder = '' ) {
391
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
392
-		if ( ! EEH_File::exists( $folder . '.htaccess' ) ) {
393
-			if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) {
390
+	public static function add_htaccess_deny_from_all($folder = '') {
391
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
392
+		if ( ! EEH_File::exists($folder.'.htaccess')) {
393
+			if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
394 394
 				return FALSE;
395 395
 			}
396 396
 		}
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
 	 * @param string $file_path
406 406
 	 * @return string
407 407
 	 */
408
-	public static function get_classname_from_filepath_with_standard_filename( $file_path ){
408
+	public static function get_classname_from_filepath_with_standard_filename($file_path) {
409 409
 		//extract file from path
410
-		$filename = basename( $file_path );
410
+		$filename = basename($file_path);
411 411
 		//now remove the first period and everything after
412
-		$pos_of_first_period = strpos( $filename,'.' );
412
+		$pos_of_first_period = strpos($filename, '.');
413 413
 		return substr($filename, 0, $pos_of_first_period);
414 414
 	}
415 415
 
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 	 * @param string $file_path
422 422
 	 * @return string
423 423
 	 */
424
-	public static function standardise_directory_separators( $file_path ){
425
-		return str_replace( array( '\\', '/' ), DS, $file_path );
424
+	public static function standardise_directory_separators($file_path) {
425
+		return str_replace(array('\\', '/'), DS, $file_path);
426 426
 	}
427 427
 
428 428
 
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 * @param string $file_path
434 434
 	 * @return string
435 435
 	 */
436
-	public static function end_with_directory_separator( $file_path ){
437
-		return rtrim( $file_path, '/\\' ) . DS;
436
+	public static function end_with_directory_separator($file_path) {
437
+		return rtrim($file_path, '/\\').DS;
438 438
 	}
439 439
 
440 440
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	 * @param $file_path
445 445
 	 * @return string
446 446
 	 */
447
-	public static function standardise_and_end_with_directory_separator( $file_path ){
448
-		return self::end_with_directory_separator( self::standardise_directory_separators( $file_path ));
447
+	public static function standardise_and_end_with_directory_separator($file_path) {
448
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
449 449
 	}
450 450
 
451 451
 
@@ -462,21 +462,21 @@  discard block
 block discarded – undo
462 462
 	 *		if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
463 463
 	 *		 and values are their filepaths
464 464
 	 */
465
-	public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){
465
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) {
466 466
 		$class_to_folder_path = array();
467
-		foreach( $folder_paths as $folder_path ){
468
-			$folder_path = self::standardise_and_end_with_directory_separator( $folder_path );
467
+		foreach ($folder_paths as $folder_path) {
468
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
469 469
 			// load WP_Filesystem and set file permissions
470
-			$files_in_folder = glob( $folder_path . '*' );
470
+			$files_in_folder = glob($folder_path.'*');
471 471
 			$class_to_folder_path = array();
472
-			if ( $files_in_folder ) {
473
-				foreach( $files_in_folder as $file_path ){
472
+			if ($files_in_folder) {
473
+				foreach ($files_in_folder as $file_path) {
474 474
 					//only add files, not folders
475
-					if ( ! is_dir( $file_path )) {
476
-						if ( $index_numerically ) {
475
+					if ( ! is_dir($file_path)) {
476
+						if ($index_numerically) {
477 477
 							$class_to_folder_path[] = $file_path;
478 478
 						} else {
479
-							$classname = self::get_classname_from_filepath_with_standard_filename( $file_path );
479
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
480 480
 							$class_to_folder_path[$classname] = $file_path;
481 481
 						}
482 482
 					}
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
 	 * @return boolean success
497 497
 	 * @throws EE_Error
498 498
 	 */
499
-	public static function copy( $source_file, $destination_file, $overwrite = FALSE ){
500
-		$full_source_path = EEH_File::standardise_directory_separators( $source_file );
501
-		if( ! EEH_File::exists( $full_source_path ) ){
502
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
503
-				$msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path );
504
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path );
505
-				throw new EE_Error( $msg );
499
+	public static function copy($source_file, $destination_file, $overwrite = FALSE) {
500
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
501
+		if ( ! EEH_File::exists($full_source_path)) {
502
+			if (defined('WP_DEBUG') && WP_DEBUG) {
503
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
504
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
505
+				throw new EE_Error($msg);
506 506
 			}
507 507
 			return FALSE;
508 508
 		}
509 509
 
510
-		$full_dest_path = EEH_File::standardise_directory_separators( $destination_file );
511
-		$folder = EEH_File::remove_filename_from_filepath( $full_dest_path );
512
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
513
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
514
-				$msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path );
515
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path );
516
-				throw new EE_Error( $msg );
510
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
511
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
512
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
513
+			if (defined('WP_DEBUG') && WP_DEBUG) {
514
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
515
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
516
+				throw new EE_Error($msg);
517 517
 			}
518 518
 			return FALSE;
519 519
 		}
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
 		// load WP_Filesystem and set file permissions
522 522
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
523 523
 		// write the file
524
-		if ( ! $wp_filesystem->copy( $full_source_path, $full_dest_path, $overwrite )) {
525
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
526
-				$msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path );
527
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' );
528
-				throw new EE_Error( $msg );
524
+		if ( ! $wp_filesystem->copy($full_source_path, $full_dest_path, $overwrite)) {
525
+			if (defined('WP_DEBUG') && WP_DEBUG) {
526
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
527
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
528
+				throw new EE_Error($msg);
529 529
 			}
530 530
 			return FALSE;
531 531
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
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
  *
Please login to merge, or discard this patch.
core/helpers/EEH_HTML.helper.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
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;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	 * @param bool   $force_close
94 94
 	 * @return string
95 95
 	 */
96
-	protected static function _open_tag( $tag = 'div', $content = '', $id = '', $class = '', $style = '', $other_attributes = '', $force_close = FALSE ) {
97
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
98
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
99
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
100
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
101
-		$html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>';
102
-		$html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag  ) . $content : '';
103
-		$indent = ! empty( $content ) || $force_close ? TRUE : FALSE;
104
-		$html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : '';
96
+	protected static function _open_tag($tag = 'div', $content = '', $id = '', $class = '', $style = '', $other_attributes = '', $force_close = FALSE) {
97
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
98
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
99
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
100
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
101
+		$html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>';
102
+		$html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : '';
103
+		$indent = ! empty($content) || $force_close ? TRUE : FALSE;
104
+		$html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : '';
105 105
 		return $html;
106 106
 	}
107 107
 
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 	 * @param bool   $indent
118 118
 	 * @return string
119 119
 	 */
120
-	protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) {
121
-		if ( $id ) {
122
-			$comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag );
123
-		} else if ( $class ) {
124
-			$comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag );
120
+	protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) {
121
+		if ($id) {
122
+			$comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag);
123
+		} else if ($class) {
124
+			$comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag);
125 125
 		} else {
126 126
 			$comment = '';
127 127
 		}
128 128
 		$html = $indent ? EEH_HTML::nl( -1, $tag ) : '';
129
-		$html .= '</' . $tag . '>' . $comment;
129
+		$html .= '</'.$tag.'>'.$comment;
130 130
 		return $html;
131 131
 	}
132 132
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
146 146
 	 * @return string
147 147
 	 */
148
-	public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
149
-		return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes );
148
+	public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
149
+		return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes);
150 150
 	}
151 151
 
152 152
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @param string $class - html class attribute
160 160
 	 * @return string
161 161
 	 */
162
-	public static function divx( $id = '', $class = '' ) {
163
-		return EEH_HTML::_close_tag( 'div', $id, $class );
162
+	public static function divx($id = '', $class = '') {
163
+		return EEH_HTML::_close_tag('div', $id, $class);
164 164
 	}
165 165
 
166 166
 
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
177 177
 	 * @return string
178 178
 	 */
179
-	public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
180
-		return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE );
179
+	public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
180
+		return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE);
181 181
 	}
182
-	public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
183
-		return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE );
182
+	public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
183
+		return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE);
184 184
 	}
185
-	public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
186
-		return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE );
185
+	public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
186
+		return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE);
187 187
 	}
188
-	public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
189
-		return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE );
188
+	public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
189
+		return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE);
190 190
 	}
191
-	public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
192
-		return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE );
191
+	public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
192
+		return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE);
193 193
 	}
194
-	public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
195
-		return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE );
194
+	public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
195
+		return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE);
196 196
 	}
197 197
 
198 198
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
209 209
 	 * @return string
210 210
 	 */
211
-	public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
212
-		return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE );
211
+	public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
212
+		return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE);
213 213
 	}
214 214
 
215 215
 
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
225 225
 	 * @return string
226 226
 	 */
227
-	public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) {
228
-		return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes );
227
+	public static function ul($id = '', $class = '', $style = '', $other_attributes = '') {
228
+		return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes);
229 229
 	}
230 230
 
231 231
 
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * @param string $class - html class attribute
239 239
 	 * @return string
240 240
 	 */
241
-	public static function ulx( $id = '', $class = '' ) {
242
-		return EEH_HTML::_close_tag( 'ul', $id, $class );
241
+	public static function ulx($id = '', $class = '') {
242
+		return EEH_HTML::_close_tag('ul', $id, $class);
243 243
 	}
244 244
 
245 245
 
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
257 257
 	 * @return string
258 258
 	 */
259
-	public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
260
-		return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes );
259
+	public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
260
+		return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes);
261 261
 	}
262 262
 
263 263
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param string $class - html class attribute
271 271
 	 * @return string
272 272
 	 */
273
-	public static function lix( $id = '', $class = '' ) {
274
-		return EEH_HTML::_close_tag( 'li', $id, $class );
273
+	public static function lix($id = '', $class = '') {
274
+		return EEH_HTML::_close_tag('li', $id, $class);
275 275
 	}
276 276
 
277 277
 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
288 288
 	 * @return string
289 289
 	 */
290
-	public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
291
-		return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes );
290
+	public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
291
+		return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes);
292 292
 	}
293 293
 
294 294
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param string $class - html class attribute
301 301
 	 * @return string
302 302
 	 */
303
-	public static function tablex( $id = '', $class = '' ) {
304
-		return EEH_HTML::_close_tag( 'table', $id, $class );
303
+	public static function tablex($id = '', $class = '') {
304
+		return EEH_HTML::_close_tag('table', $id, $class);
305 305
 	}
306 306
 
307 307
 
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
318 318
 	 * @return string
319 319
 	 */
320
-	public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
321
-		return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes );
320
+	public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
321
+		return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes);
322 322
 	}
323 323
 
324 324
 
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 	 * @param string $class - html class attribute
331 331
 	 * @return string
332 332
 	 */
333
-	public static function theadx( $id = '', $class = '' ) {
334
-		return EEH_HTML::_close_tag( 'thead', $id, $class );
333
+	public static function theadx($id = '', $class = '') {
334
+		return EEH_HTML::_close_tag('thead', $id, $class);
335 335
 	}
336 336
 
337 337
 
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
348 348
 	 * @return string
349 349
 	 */
350
-	public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
351
-		return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes );
350
+	public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
351
+		return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes);
352 352
 	}
353 353
 
354 354
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @param string $class - html class attribute
361 361
 	 * @return string
362 362
 	 */
363
-	public static function tbodyx( $id = '', $class = '' ) {
364
-		return EEH_HTML::_close_tag( 'tbody', $id, $class );
363
+	public static function tbodyx($id = '', $class = '') {
364
+		return EEH_HTML::_close_tag('tbody', $id, $class);
365 365
 	}
366 366
 
367 367
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
378 378
 	 * @return string
379 379
 	 */
380
-	public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
381
-		return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes );
380
+	public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
381
+		return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes);
382 382
 	}
383 383
 
384 384
 
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 	 * @param string $class - html class attribute
391 391
 	 * @return string
392 392
 	 */
393
-	public static function trx( $id = '', $class = '' ) {
394
-		return EEH_HTML::_close_tag( 'tr', $id, $class );
393
+	public static function trx($id = '', $class = '') {
394
+		return EEH_HTML::_close_tag('tr', $id, $class);
395 395
 	}
396 396
 
397 397
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
408 408
 	 * @return string
409 409
 	 */
410
-	public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
411
-		return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes );
410
+	public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
411
+		return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes);
412 412
 	}
413 413
 
414 414
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param string $class - html class attribute
421 421
 	 * @return string
422 422
 	 */
423
-	public static function thx( $id = '', $class = '' ) {
424
-		return EEH_HTML::_close_tag( 'th', $id, $class );
423
+	public static function thx($id = '', $class = '') {
424
+		return EEH_HTML::_close_tag('th', $id, $class);
425 425
 	}
426 426
 
427 427
 
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
438 438
 	 * @return string
439 439
 	 */
440
-	public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
441
-		return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes );
440
+	public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
441
+		return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes);
442 442
 	}
443 443
 
444 444
 
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 	 * @param string $class - html class attribute
451 451
 	 * @return string
452 452
 	 */
453
-	public static function tdx( $id = '', $class = '' ) {
454
-		return EEH_HTML::_close_tag( 'td', $id, $class );
453
+	public static function tdx($id = '', $class = '') {
454
+		return EEH_HTML::_close_tag('td', $id, $class);
455 455
 	}
456 456
 
457 457
 
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 	 * @param int    $colspan
466 466
 	 * @return string
467 467
 	 */
468
-	public static function no_row( $content = '', $colspan = 2 ) {
468
+	public static function no_row($content = '', $colspan = 2) {
469 469
 		return EEH_HTML::tr(
470
-			EEH_HTML::td( $content, '', '',  'padding:0; border:none;', 'colspan="' . $colspan . '"' ),
471
-			'', '',  'padding:0; border:none;'
470
+			EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'),
471
+			'', '', 'padding:0; border:none;'
472 472
 		);
473 473
 	}
474 474
 
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
489 489
 	 * @return string
490 490
 	 */
491
-	public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
492
-		$link_text = ! empty( $link_text ) ? $link_text : $href;
493
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
494
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
495
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
496
-		$attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : '';
497
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
498
-		return '<a href="' . $href . '" ' . $attributes . '>'  . $link_text  . '</a>';
491
+	public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') {
492
+		$link_text = ! empty($link_text) ? $link_text : $href;
493
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
494
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
495
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
496
+		$attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : '';
497
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
498
+		return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>';
499 499
 	}
500 500
 
501 501
 
@@ -512,14 +512,14 @@  discard block
 block discarded – undo
512 512
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
513 513
 	 * @return string
514 514
 	 */
515
-	public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
516
-		$attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : '';
517
-		$attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : '';
518
-		$attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
519
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
520
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
521
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
522
-		return '<img' . $attributes  . '/>';
515
+	public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') {
516
+		$attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : '';
517
+		$attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : '';
518
+		$attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
519
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
520
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
521
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
522
+		return '<img'.$attributes.'/>';
523 523
 	}
524 524
 
525 525
 
@@ -537,12 +537,12 @@  discard block
 block discarded – undo
537 537
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
538 538
 	 * @return string
539 539
 	 */
540
-	protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
541
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
542
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
543
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
544
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
545
-		return '<' . $tag . ' ' . $attributes . '>'  . $content  . '</' . $tag . '>';
540
+	protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
541
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
542
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
543
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
544
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
545
+		return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>';
546 546
 	}
547 547
 
548 548
 
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
559 559
 	 * @return string
560 560
 	 */
561
-	public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
562
-		return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes );
561
+	public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
562
+		return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes);
563 563
 	}
564 564
 
565 565
 
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
576 576
 	 * @return string
577 577
 	 */
578
-	public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
579
-		return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes );
578
+	public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
579
+		return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes);
580 580
 	}
581 581
 
582 582
 
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
593 593
 	 * @return string
594 594
 	 */
595
-	public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
596
-		return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes );
595
+	public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
596
+		return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes);
597 597
 	}
598 598
 
599 599
 
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 	 * @param string $comment
606 606
 	 * @return string
607 607
 	 */
608
-	public static function comment( $comment = '' ) {
609
-		return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : '';
608
+	public static function comment($comment = '') {
609
+		return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : '';
610 610
 	}
611 611
 
612 612
 
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 	 * @param int $nmbr - the number of line breaks to return
618 618
 	 * @return string
619 619
 	 */
620
-	public static function br( $nmbr = 1 ) {
621
-		return str_repeat( '<br />', $nmbr );
620
+	public static function br($nmbr = 1) {
621
+		return str_repeat('<br />', $nmbr);
622 622
 	}
623 623
 
624 624
 
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @param int $nmbr - the number of non-breaking spaces to return
630 630
 	 * @return string
631 631
 	 */
632
-	public static function nbsp( $nmbr = 1 ) {
633
-		return str_repeat( '&nbsp;', $nmbr );
632
+	public static function nbsp($nmbr = 1) {
633
+		return str_repeat('&nbsp;', $nmbr);
634 634
 	}
635 635
 
636 636
 
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 	 * @param string $id
645 645
 	 * @return string
646 646
 	 */
647
-	public static function sanitize_id( $id = '' ) {
648
-		$key = str_replace( ' ', '-', trim( $id ) );
649
-		return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key );
647
+	public static function sanitize_id($id = '') {
648
+		$key = str_replace(' ', '-', trim($id));
649
+		return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key);
650 650
 	}
651 651
 
652 652
 
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
 	 * @param string $tag
659 659
 	 * @return string - newline character plus # of indents passed (can be + or -)
660 660
 	 */
661
-	public static function nl( $indent = 0, $tag = 'none' ) {
661
+	public static function nl($indent = 0, $tag = 'none') {
662 662
 		$html = "\n";
663
-		EEH_HTML::indent( $indent, $tag );
664
-		for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) {
663
+		EEH_HTML::indent($indent, $tag);
664
+		for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) {
665 665
 			$html .= "\t";
666 666
 		}
667 667
 		return $html;
@@ -676,17 +676,17 @@  discard block
 block discarded – undo
676 676
 	 * @param int    $indent can be negative to decrease the indentation level
677 677
 	 * @param string $tag
678 678
 	 */
679
-	public static function indent( $indent, $tag = 'none' ){
679
+	public static function indent($indent, $tag = 'none') {
680 680
 		static $default_indentation = FALSE;
681
-		if ( ! $default_indentation ) {
681
+		if ( ! $default_indentation) {
682 682
 			EEH_HTML::_set_default_indentation();
683 683
 			$default_indentation = TRUE;
684 684
 		}
685
-		if ( ! isset( EEH_HTML::$_indent[ $tag ] )) {
686
-			EEH_HTML::$_indent[ $tag ] = 0;
685
+		if ( ! isset(EEH_HTML::$_indent[$tag])) {
686
+			EEH_HTML::$_indent[$tag] = 0;
687 687
 		}
688
-		EEH_HTML::$_indent[ $tag ] += intval( $indent );
689
-		EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0;
688
+		EEH_HTML::$_indent[$tag] += intval($indent);
689
+		EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0;
690 690
 	}
691 691
 
692 692
 
Please login to merge, or discard this patch.
core/helpers/EEH_Inflector.helper.php 3 patches
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @version $Revision 0.1 $
36 36
  */
37 37
 class EEH_Inflector{
38
-    // ------ CLASS METHODS ------ //
39
-    // ---- Public methods ---- //
40
-    // {{{ pluralize()
38
+	// ------ CLASS METHODS ------ //
39
+	// ---- Public methods ---- //
40
+	// {{{ pluralize()
41 41
 
42 42
 	/**
43 43
 	 * Just calls self::pluralize and strtolower on $word and returns it
@@ -51,319 +51,319 @@  discard block
 block discarded – undo
51 51
 	static function singularize_and_upper( $word ) {
52 52
 		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
53 53
 	}
54
-    /**
55
-     * Pluralizes English nouns.
56
-     *
57
-     * @access public
58
-     * @static
59
-     * @param    string    $word    English noun to pluralize
60
-     * @return string Plural noun
61
-     */
62
-    static function pluralize($word){
63
-        $plural = array(
64
-            '/(quiz)$/i'               => '\1zes',
65
-            '/^(ox)$/i'                => '\1en',
66
-            '/([m|l])ouse$/i'          => '\1ice',
67
-            '/(matr|vert|ind)ix|ex$/i' => '\1ices',
68
-            '/(x|ch|ss|sh)$/i'         => '\1es',
69
-            '/([^aeiouy]|qu)ies$/i'    => '\1y',
70
-            '/([^aeiouy]|qu)y$/i'      => '\1ies',
71
-            '/(hive)$/i'               => '\1s',
72
-            '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
73
-            '/sis$/i'                  => 'ses',
74
-            '/([ti])um$/i'             => '\1a',
75
-            '/(buffal|tomat)o$/i'      => '\1oes',
76
-            '/(bu)s$/i'                => '\1ses',
77
-            '/(alias|status)/i'        => '\1es',
78
-            '/(octop|vir)us$/i'        => '\1i',
79
-            '/(ax|test)is$/i'          => '\1es',
80
-            '/s$/i'                    => 's',
81
-            '/$/'                      => 's');
82
-
83
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
84
-
85
-        $irregular = array(
86
-            'person' => 'people',
87
-            'man'    => 'men',
88
-            'child'  => 'children',
89
-            'sex'    => 'sexes',
90
-            'move'   => 'moves');
91
-
92
-        $lowercased_word = strtolower($word);
93
-
94
-        foreach($uncountable as $_uncountable){
95
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
54
+	/**
55
+	 * Pluralizes English nouns.
56
+	 *
57
+	 * @access public
58
+	 * @static
59
+	 * @param    string    $word    English noun to pluralize
60
+	 * @return string Plural noun
61
+	 */
62
+	static function pluralize($word){
63
+		$plural = array(
64
+			'/(quiz)$/i'               => '\1zes',
65
+			'/^(ox)$/i'                => '\1en',
66
+			'/([m|l])ouse$/i'          => '\1ice',
67
+			'/(matr|vert|ind)ix|ex$/i' => '\1ices',
68
+			'/(x|ch|ss|sh)$/i'         => '\1es',
69
+			'/([^aeiouy]|qu)ies$/i'    => '\1y',
70
+			'/([^aeiouy]|qu)y$/i'      => '\1ies',
71
+			'/(hive)$/i'               => '\1s',
72
+			'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
73
+			'/sis$/i'                  => 'ses',
74
+			'/([ti])um$/i'             => '\1a',
75
+			'/(buffal|tomat)o$/i'      => '\1oes',
76
+			'/(bu)s$/i'                => '\1ses',
77
+			'/(alias|status)/i'        => '\1es',
78
+			'/(octop|vir)us$/i'        => '\1i',
79
+			'/(ax|test)is$/i'          => '\1es',
80
+			'/s$/i'                    => 's',
81
+			'/$/'                      => 's');
82
+
83
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
84
+
85
+		$irregular = array(
86
+			'person' => 'people',
87
+			'man'    => 'men',
88
+			'child'  => 'children',
89
+			'sex'    => 'sexes',
90
+			'move'   => 'moves');
91
+
92
+		$lowercased_word = strtolower($word);
93
+
94
+		foreach($uncountable as $_uncountable){
95
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96 96
 					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
97
-                return $word;
98
-            }
99
-        }
100
-
101
-        foreach($irregular as $_plural => $_singular){
102
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
104
-            }
105
-        }
106
-
107
-        foreach($plural as $rule => $replacement){
108
-            if(preg_match($rule, $word)){
109
-                return preg_replace($rule, $replacement, $word);
110
-            }
111
-        }
112
-        return false;
113
-    }
114
-
115
-    // }}}
116
-    // {{{ singularize()
117
-
118
-    /**
119
-     * Singularizes English nouns.
120
-     *
121
-     * @access public
122
-     * @static
123
-     * @param    string    $word    English noun to singularize
124
-     * @return string Singular noun.
125
-     */
126
-    static function singularize($word){
127
-        $singular = array(
128
-            '/(quiz)zes$/i'                                                    => '\1',
129
-            '/(matr)ices$/i'                                                   => '\1ix',
130
-            '/(vert|ind)ices$/i'                                               => '\1ex',
131
-            '/^(ox)en/i'                                                       => '\1',
132
-            '/(alias|status)es$/i'                                             => '\1',
133
-            '/([octop|vir])i$/i'                                               => '\1us',
134
-            '/(cris|ax|test)es$/i'                                             => '\1is',
135
-            '/(shoe)s$/i'                                                      => '\1',
136
-            '/(o)es$/i'                                                        => '\1',
137
-            '/(bus)es$/i'                                                      => '\1',
138
-            '/([m|l])ice$/i'                                                   => '\1ouse',
139
-            '/(x|ch|ss|sh)es$/i'                                               => '\1',
140
-            '/(m)ovies$/i'                                                     => '\1ovie',
141
-            '/(s)eries$/i'                                                     => '\1eries',
142
-            '/([^aeiouy]|qu)ies$/i'                                            => '\1y',
143
-            '/([lr])ves$/i'                                                    => '\1f',
144
-            '/(tive)s$/i'                                                      => '\1',
145
-            '/(hive)s$/i'                                                      => '\1',
146
-            '/([^f])ves$/i'                                                    => '\1fe',
147
-            '/(^analy)ses$/i'                                                  => '\1sis',
148
-            '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
149
-            '/([ti])a$/i'                                                      => '\1um',
150
-            '/(n)ews$/i'                                                       => '\1ews',
151
-            '/s$/i'                                                            => '',
152
-        );
153
-
154
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
155
-
156
-        $irregular = array(
157
-            'person' => 'people',
158
-            'man'    => 'men',
159
-            'child'  => 'children',
160
-            'sex'    => 'sexes',
161
-            'move'   => 'moves');
162
-
163
-        $lowercased_word = strtolower($word);
164
-        foreach($uncountable as $_uncountable){
165
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
166
-                return $word;
167
-            }
168
-        }
169
-
170
-        foreach($irregular as $_plural => $_singular){
171
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
173
-            }
174
-        }
175
-
176
-        foreach($singular as $rule => $replacement){
177
-            if(preg_match($rule, $word)){
178
-                return preg_replace($rule, $replacement, $word);
179
-            }
180
-        }
181
-
182
-        return $word;
183
-    }
184
-
185
-    // }}}
186
-    // {{{ titleize()
187
-
188
-    /**
189
-     * Converts an underscored or CamelCase word into a English
190
-     * sentence.
191
-     *
192
-     * The titleize static function converts text like "WelcomePage",
193
-     * "welcome_page" or  "welcome page" to this "Welcome
194
-     * Page".
195
-     * If second parameter is set to 'first' it will only
196
-     * capitalize the first character of the title.
197
-     *
198
-     * @access public
199
-     * @static
200
-     * @param    string    $word    Word to format as tile
201
-     * @param    string    $uppercase    If set to 'first' it will only uppercase the
202
-     * first character. Otherwise it will uppercase all
203
-     * the words in the title.
204
-     * @return string Text formatted as title
205
-     */
206
-    static function titleize($word, $uppercase = ''){
207
-        $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208
-        return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209
-    }
210
-
211
-    // }}}
212
-    // {{{ camelize()
213
-
214
-    /**
215
-     * Returns given word as CamelCased
216
-     *
217
-     * Converts a word like "send_email" to "SendEmail". It
218
-     * will remove non alphanumeric character from the word, so
219
-     * "who's online" will be converted to "WhoSOnline"
220
-     *
221
-     * @access public
222
-     * @static
223
-     * @see variablize
224
-     * @param    string    $word    Word to convert to camel case
225
-     * @return string UpperCamelCasedWord
226
-     */
227
-    static function camelize($word){
228
-        return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229
-    }
230
-
231
-    // }}}
232
-    // {{{ underscore()
233
-
234
-    /**
235
-     * Converts a word "into_it_s_underscored_version"
236
-     *
237
-     * Convert any "CamelCased" or "ordinary Word" into an
238
-     * "underscored_word".
239
-     *
240
-     * This can be really useful for creating friendly URLs.
241
-     *
242
-     * @access public
243
-     * @static
244
-     * @param    string    $word    Word to underscore
245
-     * @return string Underscored word
246
-     */
247
-    static function underscore($word){
248
-        return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249
-    }
250
-
251
-    // }}}
252
-    // {{{ humanize()
253
-
254
-    /**
255
-     * Returns a human-readable string from $word
256
-     *
257
-     * Returns a human-readable string from $word, by replacing
258
-     * underscores with a space, and by upper-casing the initial
259
-     * character by default.
260
-     *
261
-     * If you need to uppercase all the words you just have to
262
-     * pass 'all' as a second parameter.
263
-     *
264
-     * @access public
265
-     * @static
266
-     * @param    string    $word    String to "humanize"
267
-     * @param    string    $uppercase    If set to 'all' it will uppercase all the words
268
-     * instead of just the first one.
269
-     * @return string Human-readable word
270
-     */
271
-    static function humanize($word, $uppercase = ''){
97
+				return $word;
98
+			}
99
+		}
100
+
101
+		foreach($irregular as $_plural => $_singular){
102
+			if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
+				return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
104
+			}
105
+		}
106
+
107
+		foreach($plural as $rule => $replacement){
108
+			if(preg_match($rule, $word)){
109
+				return preg_replace($rule, $replacement, $word);
110
+			}
111
+		}
112
+		return false;
113
+	}
114
+
115
+	// }}}
116
+	// {{{ singularize()
117
+
118
+	/**
119
+	 * Singularizes English nouns.
120
+	 *
121
+	 * @access public
122
+	 * @static
123
+	 * @param    string    $word    English noun to singularize
124
+	 * @return string Singular noun.
125
+	 */
126
+	static function singularize($word){
127
+		$singular = array(
128
+			'/(quiz)zes$/i'                                                    => '\1',
129
+			'/(matr)ices$/i'                                                   => '\1ix',
130
+			'/(vert|ind)ices$/i'                                               => '\1ex',
131
+			'/^(ox)en/i'                                                       => '\1',
132
+			'/(alias|status)es$/i'                                             => '\1',
133
+			'/([octop|vir])i$/i'                                               => '\1us',
134
+			'/(cris|ax|test)es$/i'                                             => '\1is',
135
+			'/(shoe)s$/i'                                                      => '\1',
136
+			'/(o)es$/i'                                                        => '\1',
137
+			'/(bus)es$/i'                                                      => '\1',
138
+			'/([m|l])ice$/i'                                                   => '\1ouse',
139
+			'/(x|ch|ss|sh)es$/i'                                               => '\1',
140
+			'/(m)ovies$/i'                                                     => '\1ovie',
141
+			'/(s)eries$/i'                                                     => '\1eries',
142
+			'/([^aeiouy]|qu)ies$/i'                                            => '\1y',
143
+			'/([lr])ves$/i'                                                    => '\1f',
144
+			'/(tive)s$/i'                                                      => '\1',
145
+			'/(hive)s$/i'                                                      => '\1',
146
+			'/([^f])ves$/i'                                                    => '\1fe',
147
+			'/(^analy)ses$/i'                                                  => '\1sis',
148
+			'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
149
+			'/([ti])a$/i'                                                      => '\1um',
150
+			'/(n)ews$/i'                                                       => '\1ews',
151
+			'/s$/i'                                                            => '',
152
+		);
153
+
154
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
155
+
156
+		$irregular = array(
157
+			'person' => 'people',
158
+			'man'    => 'men',
159
+			'child'  => 'children',
160
+			'sex'    => 'sexes',
161
+			'move'   => 'moves');
162
+
163
+		$lowercased_word = strtolower($word);
164
+		foreach($uncountable as $_uncountable){
165
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
166
+				return $word;
167
+			}
168
+		}
169
+
170
+		foreach($irregular as $_plural => $_singular){
171
+			if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
+				return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
173
+			}
174
+		}
175
+
176
+		foreach($singular as $rule => $replacement){
177
+			if(preg_match($rule, $word)){
178
+				return preg_replace($rule, $replacement, $word);
179
+			}
180
+		}
181
+
182
+		return $word;
183
+	}
184
+
185
+	// }}}
186
+	// {{{ titleize()
187
+
188
+	/**
189
+	 * Converts an underscored or CamelCase word into a English
190
+	 * sentence.
191
+	 *
192
+	 * The titleize static function converts text like "WelcomePage",
193
+	 * "welcome_page" or  "welcome page" to this "Welcome
194
+	 * Page".
195
+	 * If second parameter is set to 'first' it will only
196
+	 * capitalize the first character of the title.
197
+	 *
198
+	 * @access public
199
+	 * @static
200
+	 * @param    string    $word    Word to format as tile
201
+	 * @param    string    $uppercase    If set to 'first' it will only uppercase the
202
+	 * first character. Otherwise it will uppercase all
203
+	 * the words in the title.
204
+	 * @return string Text formatted as title
205
+	 */
206
+	static function titleize($word, $uppercase = ''){
207
+		$uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208
+		return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209
+	}
210
+
211
+	// }}}
212
+	// {{{ camelize()
213
+
214
+	/**
215
+	 * Returns given word as CamelCased
216
+	 *
217
+	 * Converts a word like "send_email" to "SendEmail". It
218
+	 * will remove non alphanumeric character from the word, so
219
+	 * "who's online" will be converted to "WhoSOnline"
220
+	 *
221
+	 * @access public
222
+	 * @static
223
+	 * @see variablize
224
+	 * @param    string    $word    Word to convert to camel case
225
+	 * @return string UpperCamelCasedWord
226
+	 */
227
+	static function camelize($word){
228
+		return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229
+	}
230
+
231
+	// }}}
232
+	// {{{ underscore()
233
+
234
+	/**
235
+	 * Converts a word "into_it_s_underscored_version"
236
+	 *
237
+	 * Convert any "CamelCased" or "ordinary Word" into an
238
+	 * "underscored_word".
239
+	 *
240
+	 * This can be really useful for creating friendly URLs.
241
+	 *
242
+	 * @access public
243
+	 * @static
244
+	 * @param    string    $word    Word to underscore
245
+	 * @return string Underscored word
246
+	 */
247
+	static function underscore($word){
248
+		return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249
+	}
250
+
251
+	// }}}
252
+	// {{{ humanize()
253
+
254
+	/**
255
+	 * Returns a human-readable string from $word
256
+	 *
257
+	 * Returns a human-readable string from $word, by replacing
258
+	 * underscores with a space, and by upper-casing the initial
259
+	 * character by default.
260
+	 *
261
+	 * If you need to uppercase all the words you just have to
262
+	 * pass 'all' as a second parameter.
263
+	 *
264
+	 * @access public
265
+	 * @static
266
+	 * @param    string    $word    String to "humanize"
267
+	 * @param    string    $uppercase    If set to 'all' it will uppercase all the words
268
+	 * instead of just the first one.
269
+	 * @return string Human-readable word
270
+	 */
271
+	static function humanize($word, $uppercase = ''){
272 272
 		//make special exceptions for acronyms
273 273
 		$word = str_replace('wp_', 'WP_', $word );
274
-        $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275
-        return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276
-    }
277
-
278
-    // }}}
279
-    // {{{ variablize()
280
-
281
-    /**
282
-     * Same as camelize but first char is underscored
283
-     *
284
-     * Converts a word like "send_email" to "sendEmail". It
285
-     * will remove non alphanumeric character from the word, so
286
-     * "who's online" will be converted to "whoSOnline"
287
-     *
288
-     * @access public
289
-     * @static
290
-     * @see camelize
291
-     * @param    string    $word    Word to lowerCamelCase
292
-     * @return string Returns a lowerCamelCasedWord
293
-     */
294
-    static function variablize($word){
295
-        $word = EEH_Inflector::camelize($word);
296
-        return strtolower($word[0]) . substr($word, 1);
297
-    }
298
-
299
-    // }}}
300
-    // {{{ tableize()
301
-
302
-    /**
303
-     * Converts a class name to its table name according to rails
304
-     * naming conventions.
305
-     *
306
-     * Converts "Person" to "people"
307
-     *
308
-     * @access public
309
-     * @static
310
-     * @see classify
311
-     * @param    string    $class_name    Class name for getting related table_name.
312
-     * @return string plural_table_name
313
-     */
314
-    static function tableize($class_name){
315
-        return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316
-    }
317
-
318
-    // }}}
319
-    // {{{ classify()
320
-
321
-    /**
322
-     * Converts a table name to its class name according to rails
323
-     * naming conventions.
324
-     *
325
-     * Converts "people" to "Person"
326
-     *
327
-     * @access public
328
-     * @static
329
-     * @see tableize
330
-     * @param    string    $table_name    Table name for getting related ClassName.
331
-     * @return string SingularClassName
332
-     */
333
-    static function classify($table_name){
334
-        return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335
-    }
336
-
337
-    // }}}
338
-    // {{{ ordinalize()
339
-
340
-    /**
341
-     * Converts number to its ordinal English form.
342
-     *
343
-     * This method converts 13 to 13th, 2 to 2nd ...
344
-     *
345
-     * @access public
346
-     * @static
347
-     * @param    integer    $number    Number to get its ordinal value
348
-     * @return string Ordinal representation of given string.
349
-     */
350
-    static function ordinalize($number){
351
-        if(in_array(($number % 100), range(11, 13))){
352
-            return $number . 'th';
353
-        }else{
354
-            switch(($number % 10)){
355
-                case 1:
356
-                    return $number . 'st';
357
-                    break;
358
-                case 2:
359
-                    return $number . 'nd';
360
-                    break;
361
-                case 3:
362
-                    return $number . 'rd';
363
-                default:
364
-                    return $number . 'th';
365
-                    break;
366
-            }
367
-        }
368
-    }
274
+		$uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275
+		return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276
+	}
277
+
278
+	// }}}
279
+	// {{{ variablize()
280
+
281
+	/**
282
+	 * Same as camelize but first char is underscored
283
+	 *
284
+	 * Converts a word like "send_email" to "sendEmail". It
285
+	 * will remove non alphanumeric character from the word, so
286
+	 * "who's online" will be converted to "whoSOnline"
287
+	 *
288
+	 * @access public
289
+	 * @static
290
+	 * @see camelize
291
+	 * @param    string    $word    Word to lowerCamelCase
292
+	 * @return string Returns a lowerCamelCasedWord
293
+	 */
294
+	static function variablize($word){
295
+		$word = EEH_Inflector::camelize($word);
296
+		return strtolower($word[0]) . substr($word, 1);
297
+	}
298
+
299
+	// }}}
300
+	// {{{ tableize()
301
+
302
+	/**
303
+	 * Converts a class name to its table name according to rails
304
+	 * naming conventions.
305
+	 *
306
+	 * Converts "Person" to "people"
307
+	 *
308
+	 * @access public
309
+	 * @static
310
+	 * @see classify
311
+	 * @param    string    $class_name    Class name for getting related table_name.
312
+	 * @return string plural_table_name
313
+	 */
314
+	static function tableize($class_name){
315
+		return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316
+	}
317
+
318
+	// }}}
319
+	// {{{ classify()
320
+
321
+	/**
322
+	 * Converts a table name to its class name according to rails
323
+	 * naming conventions.
324
+	 *
325
+	 * Converts "people" to "Person"
326
+	 *
327
+	 * @access public
328
+	 * @static
329
+	 * @see tableize
330
+	 * @param    string    $table_name    Table name for getting related ClassName.
331
+	 * @return string SingularClassName
332
+	 */
333
+	static function classify($table_name){
334
+		return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335
+	}
336
+
337
+	// }}}
338
+	// {{{ ordinalize()
339
+
340
+	/**
341
+	 * Converts number to its ordinal English form.
342
+	 *
343
+	 * This method converts 13 to 13th, 2 to 2nd ...
344
+	 *
345
+	 * @access public
346
+	 * @static
347
+	 * @param    integer    $number    Number to get its ordinal value
348
+	 * @return string Ordinal representation of given string.
349
+	 */
350
+	static function ordinalize($number){
351
+		if(in_array(($number % 100), range(11, 13))){
352
+			return $number . 'th';
353
+		}else{
354
+			switch(($number % 10)){
355
+				case 1:
356
+					return $number . 'st';
357
+					break;
358
+				case 2:
359
+					return $number . 'nd';
360
+					break;
361
+				case 3:
362
+					return $number . 'rd';
363
+				default:
364
+					return $number . 'th';
365
+					break;
366
+			}
367
+		}
368
+	}
369 369
 }
370 370
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 // +----------------------------------------------------------------------+
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @since 0.1
35 35
  * @version $Revision 0.1 $
36 36
  */
37
-class EEH_Inflector{
37
+class EEH_Inflector {
38 38
     // ------ CLASS METHODS ------ //
39 39
     // ---- Public methods ---- //
40 40
     // {{{ pluralize()
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 * @param string $word
45 45
 	 * @return string
46 46
 	 */
47
-	static function pluralize_and_lower( $word ){
48
-		return strtolower( self::pluralize( $word ) );
47
+	static function pluralize_and_lower($word) {
48
+		return strtolower(self::pluralize($word));
49 49
 	}
50 50
 
51
-	static function singularize_and_upper( $word ) {
52
-		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
51
+	static function singularize_and_upper($word) {
52
+		return str_replace(' ', '_', self::humanize(self::singularize($word), 'all'));
53 53
 	}
54 54
     /**
55 55
      * Pluralizes English nouns.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param    string    $word    English noun to pluralize
60 60
      * @return string Plural noun
61 61
      */
62
-    static function pluralize($word){
62
+    static function pluralize($word) {
63 63
         $plural = array(
64 64
             '/(quiz)$/i'               => '\1zes',
65 65
             '/^(ox)$/i'                => '\1en',
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 
92 92
         $lowercased_word = strtolower($word);
93 93
 
94
-        foreach($uncountable as $_uncountable){
95
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96
-					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
94
+        foreach ($uncountable as $_uncountable) {
95
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96
+					! ctype_alpha($lowercased_word[strlen($lowercased_word) - strlen($_uncountable)])) {
97 97
                 return $word;
98 98
             }
99 99
         }
100 100
 
101
-        foreach($irregular as $_plural => $_singular){
102
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
101
+        foreach ($irregular as $_plural => $_singular) {
102
+            if (preg_match('/('.$_plural.')$/i', $word, $arr)) {
103
+                return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word);
104 104
             }
105 105
         }
106 106
 
107
-        foreach($plural as $rule => $replacement){
108
-            if(preg_match($rule, $word)){
107
+        foreach ($plural as $rule => $replacement) {
108
+            if (preg_match($rule, $word)) {
109 109
                 return preg_replace($rule, $replacement, $word);
110 110
             }
111 111
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param    string    $word    English noun to singularize
124 124
      * @return string Singular noun.
125 125
      */
126
-    static function singularize($word){
126
+    static function singularize($word) {
127 127
         $singular = array(
128 128
             '/(quiz)zes$/i'                                                    => '\1',
129 129
             '/(matr)ices$/i'                                                   => '\1ix',
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
             'move'   => 'moves');
162 162
 
163 163
         $lowercased_word = strtolower($word);
164
-        foreach($uncountable as $_uncountable){
165
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
164
+        foreach ($uncountable as $_uncountable) {
165
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) {
166 166
                 return $word;
167 167
             }
168 168
         }
169 169
 
170
-        foreach($irregular as $_plural => $_singular){
171
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
170
+        foreach ($irregular as $_plural => $_singular) {
171
+            if (preg_match('/('.$_singular.')$/i', $word, $arr)) {
172
+                return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word);
173 173
             }
174 174
         }
175 175
 
176
-        foreach($singular as $rule => $replacement){
177
-            if(preg_match($rule, $word)){
176
+        foreach ($singular as $rule => $replacement) {
177
+            if (preg_match($rule, $word)) {
178 178
                 return preg_replace($rule, $replacement, $word);
179 179
             }
180 180
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * the words in the title.
204 204
      * @return string Text formatted as title
205 205
      */
206
-    static function titleize($word, $uppercase = ''){
206
+    static function titleize($word, $uppercase = '') {
207 207
         $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208 208
         return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209 209
     }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      * @param    string    $word    Word to convert to camel case
225 225
      * @return string UpperCamelCasedWord
226 226
      */
227
-    static function camelize($word){
227
+    static function camelize($word) {
228 228
         return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229 229
     }
230 230
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @param    string    $word    Word to underscore
245 245
      * @return string Underscored word
246 246
      */
247
-    static function underscore($word){
247
+    static function underscore($word) {
248 248
         return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249 249
     }
250 250
 
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
      * instead of just the first one.
269 269
      * @return string Human-readable word
270 270
      */
271
-    static function humanize($word, $uppercase = ''){
271
+    static function humanize($word, $uppercase = '') {
272 272
 		//make special exceptions for acronyms
273
-		$word = str_replace('wp_', 'WP_', $word );
273
+		$word = str_replace('wp_', 'WP_', $word);
274 274
         $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275 275
         return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276 276
     }
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
      * @param    string    $word    Word to lowerCamelCase
292 292
      * @return string Returns a lowerCamelCasedWord
293 293
      */
294
-    static function variablize($word){
294
+    static function variablize($word) {
295 295
         $word = EEH_Inflector::camelize($word);
296
-        return strtolower($word[0]) . substr($word, 1);
296
+        return strtolower($word[0]).substr($word, 1);
297 297
     }
298 298
 
299 299
     // }}}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      * @param    string    $class_name    Class name for getting related table_name.
312 312
      * @return string plural_table_name
313 313
      */
314
-    static function tableize($class_name){
314
+    static function tableize($class_name) {
315 315
         return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316 316
     }
317 317
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      * @param    string    $table_name    Table name for getting related ClassName.
331 331
      * @return string SingularClassName
332 332
      */
333
-    static function classify($table_name){
333
+    static function classify($table_name) {
334 334
         return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335 335
     }
336 336
 
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
      * @param    integer    $number    Number to get its ordinal value
348 348
      * @return string Ordinal representation of given string.
349 349
      */
350
-    static function ordinalize($number){
351
-        if(in_array(($number % 100), range(11, 13))){
352
-            return $number . 'th';
353
-        }else{
354
-            switch(($number % 10)){
350
+    static function ordinalize($number) {
351
+        if (in_array(($number % 100), range(11, 13))) {
352
+            return $number.'th';
353
+        } else {
354
+            switch (($number % 10)) {
355 355
                 case 1:
356
-                    return $number . 'st';
356
+                    return $number.'st';
357 357
                     break;
358 358
                 case 2:
359
-                    return $number . 'nd';
359
+                    return $number.'nd';
360 360
                     break;
361 361
                 case 3:
362
-                    return $number . 'rd';
362
+                    return $number.'rd';
363 363
                 default:
364
-                    return $number . 'th';
364
+                    return $number.'th';
365 365
                     break;
366 366
             }
367 367
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -350,7 +350,7 @@
 block discarded – undo
350 350
     static function ordinalize($number){
351 351
         if(in_array(($number % 100), range(11, 13))){
352 352
             return $number . 'th';
353
-        }else{
353
+        } else{
354 354
             switch(($number % 10)){
355 355
                 case 1:
356 356
                     return $number . 'st';
Please login to merge, or discard this patch.