Completed
Branch BETA-4.9-message-activity (793322)
by
unknown
18:25 queued 10s
created
core/admin/PostShortcodeTracking.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -864,7 +864,7 @@
 block discarded – undo
864 864
 	 * @param  int $ID
865 865
 	 * @param      $shortcode_class
866 866
 	 * @param      $shortcode_posts
867
-	 * @param      $page_for_posts
867
+	 * @param      string $page_for_posts
868 868
 	 * @return bool
869 869
 	 */
870 870
 	protected static function unset_posts_page_shortcode_for_post( $ID, $shortcode_class, $shortcode_posts, $page_for_posts ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -316,7 +316,7 @@
 block discarded – undo
316 316
 		);
317 317
 		// verify that post_shortcodes is set
318 318
 		\EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes )
319
-		                                                && is_array( \EE_Config::instance()->core->post_shortcodes )
319
+														&& is_array( \EE_Config::instance()->core->post_shortcodes )
320 320
 			? \EE_Config::instance()->core->post_shortcodes
321 321
 			: array();
322 322
 		// cycle thru post_shortcodes
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\admin;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -28,31 +28,31 @@  discard block
 block discarded – undo
28 28
 	public static function set_hooks_admin() {
29 29
 		add_action(
30 30
 			'save_post',
31
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ),
31
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'),
32 32
 			100,
33 33
 			2
34 34
 		);
35 35
 		add_action(
36 36
 			'delete_post',
37
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ),
37
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'),
38 38
 			100,
39 39
 			1
40 40
 		);
41 41
 		add_action(
42 42
 			'add_option_page_for_posts',
43
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ),
43
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'),
44 44
 			100,
45 45
 			2
46 46
 		);
47 47
 		add_action(
48 48
 			'update_option',
49
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ),
49
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'),
50 50
 			100,
51 51
 			3
52 52
 		);
53 53
 		add_action(
54 54
 			'delete_option',
55
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ),
55
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'),
56 56
 			100,
57 57
 			1
58 58
 		);
@@ -72,61 +72,61 @@  discard block
 block discarded – undo
72 72
 	 * @param \WP_Post $post
73 73
 	 * @return    void
74 74
 	 */
75
-	public static function parse_post_content_on_save( $post_ID, $post ) {
75
+	public static function parse_post_content_on_save($post_ID, $post) {
76 76
 		// if the post is trashed, then let's remove our post shortcode tracking
77
-		if ( $post instanceof \WP_Post && $post->post_status == 'trash' ) {
78
-			PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID );
77
+		if ($post instanceof \WP_Post && $post->post_status == 'trash') {
78
+			PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID);
79 79
 			return;
80 80
 		}
81 81
 		// default post types
82
-		$post_types = array( 'post' => 0, 'page' => 1 );
82
+		$post_types = array('post' => 0, 'page' => 1);
83 83
 		// add CPTs
84 84
 		$CPTs = \EE_Register_CPTs::get_CPTs();
85
-		$post_types = array_merge( $post_types, $CPTs );
85
+		$post_types = array_merge($post_types, $CPTs);
86 86
 		// for default or CPT posts...
87
-		if ( isset( $post_types[ $post->post_type ] ) ) {
87
+		if (isset($post_types[$post->post_type])) {
88 88
 			// post on frontpage ?
89 89
 			$page_for_posts = \EE_Config::get_page_for_posts();
90
-			if ( $post->post_name == $page_for_posts ) {
91
-				PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts );
90
+			if ($post->post_name == $page_for_posts) {
91
+				PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts);
92 92
 				return;
93 93
 			}
94 94
 			// array of shortcodes indexed by post name
95
-			\EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes )
95
+			\EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes)
96 96
 				? \EE_Registry::CFG()->core->post_shortcodes
97 97
 				: array();
98 98
 			// whether to proceed with update
99 99
 			$update_post_shortcodes = false;
100 100
 			// empty both arrays
101
-			\EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array();
101
+			\EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array();
102 102
 			// check that posts page is already being tracked
103
-			if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) {
103
+			if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) {
104 104
 				// if not, then ensure that it is properly added
105
-				\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array();
105
+				\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array();
106 106
 			}
107 107
 			// loop thru shortcodes
108
-			foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) {
108
+			foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) {
109 109
 				// convert to UPPERCASE to get actual shortcode
110
-				$EES_Shortcode = strtoupper( $EES_Shortcode );
110
+				$EES_Shortcode = strtoupper($EES_Shortcode);
111 111
 				// is the shortcode in the post_content ?
112
-				if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) {
112
+				if (strpos($post->post_content, $EES_Shortcode) !== false) {
113 113
 					// map shortcode to post names and post IDs
114
-					\EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID;
114
+					\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID;
115 115
 					// and add this shortcode to the tracking for the blog page
116
-					PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID );
116
+					PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID);
117 117
 					$update_post_shortcodes = true;
118 118
 				} else {
119 119
 					// shortcode is not present in post content, so check if we were tracking it previously
120 120
 					// stop tracking if shortcode is not used in this specific post
121
-					if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) {
122
-						unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] );
121
+					if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) {
122
+						unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]);
123 123
 						$update_post_shortcodes = true;
124 124
 					}
125 125
 					// make sure that something is set for the shortcode posts (even though we may remove this)
126 126
 					$shortcode_posts = isset(
127
-						\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ]
127
+						\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode]
128 128
 					)
129
-						? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ]
129
+						? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode]
130 130
 						: array();
131 131
 					// and stop tracking for this shortcode on the blog page if it is not used
132 132
 					$update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post(
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 						: $update_post_shortcodes;
141 141
 				}
142 142
 			}
143
-			if ( $update_post_shortcodes ) {
144
-				PostShortcodeTracking::update_post_shortcodes( $page_for_posts );
143
+			if ($update_post_shortcodes) {
144
+				PostShortcodeTracking::update_post_shortcodes($page_for_posts);
145 145
 			}
146 146
 		}
147 147
 	}
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
 	 * @param  string $page_for_posts
159 159
 	 * @return void
160 160
 	 */
161
-	protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) {
162
-		\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array();
161
+	protected static function set_post_shortcodes_for_posts_page($page_for_posts) {
162
+		\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array();
163 163
 		// loop thru shortcodes
164
-		foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) {
165
-			foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) {
166
-				PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID );
164
+		foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) {
165
+			foreach ($post_shortcodes as $EES_Shortcode => $post_ID) {
166
+				PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID);
167 167
 			}
168 168
 		}
169
-		PostShortcodeTracking::update_post_shortcodes( $page_for_posts );
169
+		PostShortcodeTracking::update_post_shortcodes($page_for_posts);
170 170
 	}
171 171
 
172 172
 
@@ -181,25 +181,25 @@  discard block
 block discarded – undo
181 181
 	 * @param         $EES_Shortcode
182 182
 	 * @param         $post_ID
183 183
 	 */
184
-	protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) {
184
+	protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) {
185 185
 		// critical page shortcodes that we do NOT want added to the Posts page (blog)
186 186
 		$critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array();
187 187
 		// if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE
188
-		if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) {
188
+		if (in_array($EES_Shortcode, $critical_shortcodes)) {
189 189
 			return;
190 190
 		}
191 191
 		// add shortcode to "Posts page" tracking
192
-		if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) {
192
+		if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) {
193 193
 			// make sure tracking is in form of an array
194
-			if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) {
195
-				\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array(
196
-					\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true
194
+			if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) {
195
+				\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array(
196
+					\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true
197 197
 				);
198 198
 			}
199
-			\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] =
200
-				\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] + array( $post_ID => true );
199
+			\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] =
200
+				\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] + array($post_ID => true);
201 201
 		} else {
202
-			\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true );
202
+			\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true);
203 203
 		}
204 204
 	}
205 205
 
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 	 * @param  int $ID
213 213
 	 * @return void
214 214
 	 */
215
-	protected static function unset_post_shortcodes_on_delete( $ID ) {
215
+	protected static function unset_post_shortcodes_on_delete($ID) {
216 216
 		$update_post_shortcodes = false;
217 217
 		// post on frontpage ?
218 218
 		$page_for_posts = \EE_Config::get_page_for_posts();
219 219
 		// looking for any references to this post
220
-		foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) {
220
+		foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) {
221 221
 			// is this the "Posts Page" (blog) ?
222
-			if ( $post_name == $page_for_posts ) {
222
+			if ($post_name == $page_for_posts) {
223 223
 				// loop thru shortcodes registered for the posts page
224
-				foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) {
224
+				foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) {
225 225
 					$update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post(
226 226
 						$ID,
227 227
 						$shortcode_class,
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
 				}
235 235
 			} else {
236 236
 				// loop thru shortcodes registered for each page
237
-				foreach ( $post_shortcodes as $shortcode_class => $post_ID ) {
237
+				foreach ($post_shortcodes as $shortcode_class => $post_ID) {
238 238
 					// if this is page is being deleted, then don't track any post shortcodes for it
239
-					if ( $post_ID == $ID ) {
240
-						unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] );
239
+					if ($post_ID == $ID) {
240
+						unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]);
241 241
 						$update_post_shortcodes = true;
242 242
 					}
243 243
 				}
244 244
 			}
245 245
 		}
246
-		if ( $update_post_shortcodes ) {
247
-			PostShortcodeTracking::update_post_shortcodes( $page_for_posts );
246
+		if ($update_post_shortcodes) {
247
+			PostShortcodeTracking::update_post_shortcodes($page_for_posts);
248 248
 		}
249 249
 	}
250 250
 
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
 		$update_post_shortcodes = false
270 270
 	) {
271 271
 		// make sure that an array of post IDs is being tracked for each  shortcode
272
-		if ( ! is_array( $shortcode_posts ) ) {
273
-			\EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array(
272
+		if ( ! is_array($shortcode_posts)) {
273
+			\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array(
274 274
 				$shortcode_posts => true
275 275
 			);
276 276
 			$update_post_shortcodes = true;
277 277
 		}
278 278
 		// now if the ID of the post being deleted is in the $shortcode_posts array
279
-		if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) {
280
-			unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] );
279
+		if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) {
280
+			unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]);
281 281
 			$update_post_shortcodes = true;
282 282
 		}
283 283
 		// if nothing is registered for that shortcode anymore, then delete the shortcode altogether
284
-		if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) {
285
-			unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] );
284
+		if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) {
285
+			unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]);
286 286
 			$update_post_shortcodes = true;
287 287
 		}
288 288
 		return $update_post_shortcodes;
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 * @param $page_for_posts
298 298
 	 * @return    void
299 299
 	 */
300
-	public static function update_post_shortcodes( $page_for_posts = '' ) {
300
+	public static function update_post_shortcodes($page_for_posts = '') {
301 301
 		// make sure page_for_posts is set
302
-		$page_for_posts = ! empty( $page_for_posts )
302
+		$page_for_posts = ! empty($page_for_posts)
303 303
 			? $page_for_posts
304 304
 			: \EE_Config::get_page_for_posts();
305 305
 		// allow others to mess stuff up :D
@@ -315,47 +315,47 @@  discard block
 block discarded – undo
315 315
 			$page_for_posts
316 316
 		);
317 317
 		// verify that post_shortcodes is set
318
-		\EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes )
319
-		                                                && is_array( \EE_Config::instance()->core->post_shortcodes )
318
+		\EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes)
319
+		                                                && is_array(\EE_Config::instance()->core->post_shortcodes)
320 320
 			? \EE_Config::instance()->core->post_shortcodes
321 321
 			: array();
322 322
 		// cycle thru post_shortcodes
323
-		foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) {
323
+		foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) {
324 324
 			// are there any shortcodes to track ?
325
-			if ( ! empty( $shortcodes ) ) {
325
+			if ( ! empty($shortcodes)) {
326 326
 				// loop thru list of tracked shortcodes
327
-				foreach ( $shortcodes as $shortcode => $post_id ) {
327
+				foreach ($shortcodes as $shortcode => $post_id) {
328 328
 					// if shortcode is for a critical page,
329 329
 					// BUT this is NOT the corresponding critical page for that shortcode
330
-					if ( $post_name == $page_for_posts ) {
330
+					if ($post_name == $page_for_posts) {
331 331
 						continue;
332 332
 					}
333 333
 					// skip the posts page, because we want all shortcodes registered for it
334
-					if ( $post_name == $page_for_posts ) {
334
+					if ($post_name == $page_for_posts) {
335 335
 						continue;
336 336
 					}
337 337
 					// make sure post still exists
338
-					$post = get_post( $post_id );
339
-					if ( $post ) {
338
+					$post = get_post($post_id);
339
+					if ($post) {
340 340
 						// check that the post name matches what we have saved
341
-						if ( $post->post_name == $post_name ) {
341
+						if ($post->post_name == $post_name) {
342 342
 							// if so, then break before hitting the unset below
343 343
 							continue;
344 344
 						}
345 345
 					}
346 346
 					// we don't like missing posts around here >:(
347
-					unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] );
347
+					unset(\EE_Config::instance()->core->post_shortcodes[$post_name]);
348 348
 				}
349 349
 			} else {
350 350
 				// you got no shortcodes to keep track of !
351
-				unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] );
351
+				unset(\EE_Config::instance()->core->post_shortcodes[$post_name]);
352 352
 			}
353 353
 		}
354 354
 		// critical page shortcodes that we do NOT want added to the Posts page (blog)
355 355
 		$critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array();
356
-		$critical_shortcodes = array_flip( $critical_shortcodes );
357
-		foreach ( $critical_shortcodes as $critical_shortcode ) {
358
-			unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] );
356
+		$critical_shortcodes = array_flip($critical_shortcodes);
357
+		foreach ($critical_shortcodes as $critical_shortcode) {
358
+			unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]);
359 359
 		}
360 360
 		//only show errors
361 361
 		\EE_Config::instance()->update_espresso_config();
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param  string $value
376 376
 	 * @return void
377 377
 	 */
378
-	public static function reset_page_for_posts_on_initial_set( $option, $value ) {
379
-		PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value );
378
+	public static function reset_page_for_posts_on_initial_set($option, $value) {
379
+		PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value);
380 380
 	}
381 381
 
382 382
 
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 	 * @param  string $value
394 394
 	 * @return void
395 395
 	 */
396
-	public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) {
397
-		if ( $option == 'page_for_posts' ) {
396
+	public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') {
397
+		if ($option == 'page_for_posts') {
398 398
 			global $wpdb;
399 399
 			$table = $wpdb->posts;
400 400
 			$SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
401
-			$new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts';
402
-			PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts );
401
+			$new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts';
402
+			PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts);
403 403
 		}
404 404
 	}
405 405
 
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $option
416 416
 	 * @return void
417 417
 	 */
418
-	public static function reset_page_for_posts_on_delete( $option ) {
419
-		if ( $option == 'page_for_posts' ) {
420
-			PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' );
418
+	public static function reset_page_for_posts_on_delete($option) {
419
+		if ($option == 'page_for_posts') {
420
+			PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts');
421 421
 		}
422 422
 	}
423 423
 
Please login to merge, or discard this patch.
core/db_classes/EE_Export.class.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3 3
 /**
4 4
  * EE_Export class
5 5
  * 
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	  * @access private
40 40
 	  * @param array $request_data
41 41
 	  */
42
- 	private function __construct( $request_data = array() ) {
42
+ 	private function __construct($request_data = array()) {
43 43
 		$this->_req_data = $request_data;
44
-		$this->today = date("Y-m-d",time());
45
-		require_once( EE_CLASSES . 'EE_CSV.class.php' );
46
-		$this->EE_CSV= EE_CSV::instance();
44
+		$this->today = date("Y-m-d", time());
45
+		require_once(EE_CLASSES.'EE_CSV.class.php');
46
+		$this->EE_CSV = EE_CSV::instance();
47 47
 	}
48 48
 
49 49
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	  * @param array $request_data
56 56
 	  * @return \EE_Export
57 57
 	  */
58
-	public static function instance( $request_data = array() ) {
58
+	public static function instance($request_data = array()) {
59 59
 		// check if class object is instantiated
60
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) {
61
-			self::$_instance = new self( $request_data );
60
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) {
61
+			self::$_instance = new self($request_data);
62 62
 		}
63 63
 		return self::$_instance;
64 64
 	}
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	public function export() {
73 73
 
74 74
 		// in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword
75
-		if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) {
75
+		if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) {
76 76
 			// check if action2 has export action
77
-			if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) {
77
+			if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) {
78 78
 				// whoop! there it is!
79 79
 				$this->_req_data['action'] = $this->_req_data['action2'];
80 80
 			}
81 81
 		}
82 82
 
83
-		$this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : '';
83
+		$this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : '';
84 84
 
85 85
 		switch ($this->_req_data['export']) {
86 86
 			case 'report':
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 					break;
95 95
 
96 96
 					case 'registrations_report_for_event':
97
-						$this->report_registrations_for_event( $this->_req_data['EVT_ID'] );
97
+						$this->report_registrations_for_event($this->_req_data['EVT_ID']);
98 98
 					break;
99 99
 
100 100
 					case 'attendees':
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					break;
107 107
 
108 108
 					default:
109
-						EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ;
109
+						EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
110 110
 						return FALSE;
111 111
 					break;
112 112
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * Downloads a CSV file with all the columns, but no data. This should be used for importing
125 125
 	 * @return null kills execution
126 126
 	 */
127
-	function export_sample(){
127
+	function export_sample() {
128 128
 		$event = EEM_Event::instance()->get_one();
129 129
 		$this->_req_data['EVT_ID'] = $event->ID();
130 130
 		$this->export_all_event_data();
@@ -150,23 +150,23 @@  discard block
 block discarded – undo
150 150
 		$state_country_query_params = array();
151 151
 		$question_group_query_params = array();
152 152
 		$question_query_params = array();
153
-		if ( isset( $this->_req_data['EVT_ID'] )) {
153
+		if (isset($this->_req_data['EVT_ID'])) {
154 154
 			// do we have an array of IDs ?
155 155
 
156
-			if ( is_array( $this->_req_data['EVT_ID'] )) {
157
-				$EVT_IDs =  array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] );
158
-				$value_to_equal = array('IN',$EVT_IDs);
156
+			if (is_array($this->_req_data['EVT_ID'])) {
157
+				$EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']);
158
+				$value_to_equal = array('IN', $EVT_IDs);
159 159
 				$filename = 'events';
160 160
 			} else {
161 161
 				// generate regular where = clause
162
-				$EVT_ID = absint( $this->_req_data['EVT_ID'] );
162
+				$EVT_ID = absint($this->_req_data['EVT_ID']);
163 163
 				$value_to_equal = $EVT_ID;
164 164
 				$event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID);
165 165
 
166
-				$filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) );
166
+				$filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso'));
167 167
 
168 168
 			}
169
-			$event_query_params[0]['EVT_ID'] =$value_to_equal;
169
+			$event_query_params[0]['EVT_ID'] = $value_to_equal;
170 170
 			$related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal;
171 171
 			$related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal;
172 172
 			$datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal;
@@ -210,42 +210,42 @@  discard block
 block discarded – undo
210 210
 
211 211
 			);
212 212
 
213
-		$model_data = $this->_get_export_data_for_models( $models_to_export );
213
+		$model_data = $this->_get_export_data_for_models($models_to_export);
214 214
 
215
-		$filename = $this->generate_filename ( $filename );
215
+		$filename = $this->generate_filename($filename);
216 216
 
217
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) {
218
-			EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
217
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) {
218
+			EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
219 219
 		}
220 220
 	}
221 221
 
222
-	function report_attendees(){
222
+	function report_attendees() {
223 223
 		$attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( 
224 224
 			array( 
225
-				'force_join' => array( 'State', 'Country' ), 
225
+				'force_join' => array('State', 'Country'), 
226 226
 				'caps' => EEM_Base::caps_read_admin 
227 227
 			) 
228 228
 		);
229 229
 		$csv_data = array();
230
-		foreach( $attendee_rows as $attendee_row ){
230
+		foreach ($attendee_rows as $attendee_row) {
231 231
 			$csv_row = array();
232
-			foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
233
-				if( $field_name == 'STA_ID' ){
234
-					$state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' );
235
-					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
236
-				}elseif( $field_name == 'CNT_ISO' ){
237
-					$country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' );
238
-					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
239
-				}else{
240
-					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
232
+			foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
233
+				if ($field_name == 'STA_ID') {
234
+					$state_name_field = EEM_State::instance()->field_settings_for('STA_name');
235
+					$csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()];
236
+				}elseif ($field_name == 'CNT_ISO') {
237
+					$country_name_field = EEM_Country::instance()->field_settings_for('CNT_name');
238
+					$csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()];
239
+				} else {
240
+					$csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()];
241 241
 				}
242 242
 			}
243 243
 			$csv_data[] = $csv_row;
244 244
 		}
245 245
 
246
-		$filename = $this->generate_filename ( 'contact-list-report' );
246
+		$filename = $this->generate_filename('contact-list-report');
247 247
 
248
-		$handle = $this->EE_CSV->begin_sending_csv( $filename);
248
+		$handle = $this->EE_CSV->begin_sending_csv($filename);
249 249
 		$this->EE_CSV->write_data_array_to_csv($handle, $csv_data);
250 250
 		$this->EE_CSV->end_sending_csv($handle);
251 251
 	}
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 		$countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL'))));
263 263
 //		$states_to_export_query_params
264 264
 		$models_to_export = array(
265
-			'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))),
266
-			'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))),
265
+			'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))),
266
+			'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))),
267 267
 			'Attendee'=>array(),
268 268
 		);
269 269
 
270 270
 
271 271
 
272
-		$model_data = $this->_get_export_data_for_models( $models_to_export );
273
-		$filename = $this->generate_filename ( 'all-attendees' );
272
+		$model_data = $this->_get_export_data_for_models($models_to_export);
273
+		$filename = $this->generate_filename('all-attendees');
274 274
 
275
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) {
276
-			EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
275
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) {
276
+			EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
277 277
 		}
278 278
 	}
279 279
 
@@ -285,19 +285,19 @@  discard block
 block discarded – undo
285 285
 	 * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
286 286
 	 * @return string
287 287
 	 */
288
-	protected function _prepare_value_from_db_for_display( $model, $field_name,  $raw_db_value, $pretty_schema = true ) {
289
-		$field_obj = $model->field_settings_for( $field_name );
290
-		$value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value );
291
-		if( $field_obj instanceof EE_Datetime_Field ) {
292
-			$field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema );
293
-			$field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema );
288
+	protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) {
289
+		$field_obj = $model->field_settings_for($field_name);
290
+		$value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
291
+		if ($field_obj instanceof EE_Datetime_Field) {
292
+			$field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema);
293
+			$field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema);
294 294
 		}
295
-		if( $pretty_schema === true){
296
-			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
297
-		}elseif( is_string( $pretty_schema ) ) {
298
-			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
299
-		}else{
300
-			return $field_obj->prepare_for_get( $value_on_model_obj );
295
+		if ($pretty_schema === true) {
296
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
297
+		}elseif (is_string($pretty_schema)) {
298
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
299
+		} else {
300
+			return $field_obj->prepare_for_get($value_on_model_obj);
301 301
 		}
302 302
 	}
303 303
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * and the questions associated with the registrations
307 307
 	 * @param int $event_id
308 308
 	 */
309
-	function report_registrations_for_event( $event_id = NULL ){
309
+	function report_registrations_for_event($event_id = NULL) {
310 310
 		$reg_fields_to_include = array(
311 311
 				'TXN_ID',
312 312
 				'ATT_ID',
@@ -338,126 +338,126 @@  discard block
 block discarded – undo
338 338
 				array(
339 339
 					'OR' => array(
340 340
 						//don't include registrations from failed or abandoned transactions...
341
-						'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ),
341
+						'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)),
342 342
 						//unless the registration is approved, in which case include it regardless of transaction status
343 343
 						'STS_ID' => EEM_Registration::status_id_approved
344 344
 						),
345
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
345
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
346 346
 					),
347
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
348
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
347
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
348
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
349 349
 				'caps' => EEM_Base::caps_read_admin
350 350
 			),
351 351
 			$event_id
352 352
 		);
353
-		if( $event_id ){
354
-			$query_params[0]['EVT_ID'] =  $event_id;
355
-		}else{
356
-			$query_params[ 'force_join' ][] = 'Event';
353
+		if ($event_id) {
354
+			$query_params[0]['EVT_ID'] = $event_id;
355
+		} else {
356
+			$query_params['force_join'][] = 'Event';
357 357
 		}
358
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
358
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
359 359
 		//get all questions which relate to someone in this group
360 360
 		$registration_ids = array();
361
-		foreach( $registration_rows as $reg_row ) {
362
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
361
+		foreach ($registration_rows as $reg_row) {
362
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
363 363
 		}
364 364
 //		EEM_Question::instance()->show_next_x_db_queries();
365
-		$questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids))));
366
-		foreach($registration_rows as $reg_row){
367
-			if ( is_array( $reg_row ) ) {
365
+		$questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids))));
366
+		foreach ($registration_rows as $reg_row) {
367
+			if (is_array($reg_row)) {
368 368
 				$reg_csv_array = array();
369
-				if( ! $event_id ){
369
+				if ( ! $event_id) {
370 370
 					//get the event's name and Id
371
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
371
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
372 372
 				}
373
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
373
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
374 374
 				/*@var $reg_row EE_Registration */
375
-				foreach($reg_fields_to_include as $field_name){
375
+				foreach ($reg_fields_to_include as $field_name) {
376 376
 					$field = $reg_model->field_settings_for($field_name);
377
-					if($field_name == 'REG_final_price'){
378
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
379
-					}elseif( $field_name == 'REG_count' ){
380
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
381
-					}elseif( $field_name == 'REG_date' ) {
382
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
383
-					}else{
384
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
377
+					if ($field_name == 'REG_final_price') {
378
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
379
+					}elseif ($field_name == 'REG_count') {
380
+						$value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
381
+					}elseif ($field_name == 'REG_date') {
382
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
383
+					} else {
384
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
385 385
 					}
386 386
 					$reg_csv_array[$this->_get_column_name_for_field($field)] = $value;
387
-					if($field_name == 'REG_final_price'){
387
+					if ($field_name == 'REG_final_price') {
388 388
 						//add a column named Currency after the final price
389 389
 						$reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code;
390 390
 					}
391 391
 				}
392 392
 				//get pretty status
393
-				$stati = EEM_Status::instance()->localized_status( array(
394
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
395
-					$reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
393
+				$stati = EEM_Status::instance()->localized_status(array(
394
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
395
+					$reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ),
396 396
 						FALSE,
397
-						'sentence' );
398
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
397
+						'sentence');
398
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
399 399
 				//get pretty trnasaction status
400
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ];
401
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00';
402
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00';
400
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']];
401
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00';
402
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00';
403 403
 				$payment_methods = array();
404 404
 				$gateway_txn_ids_etc = array();
405 405
 				$payment_times = array();
406
-				if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){
406
+				if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) {
407 407
 					$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
408 408
 							array(
409 409
 								array(
410
-									'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ],
410
+									'TXN_ID' => $reg_row['Transaction.TXN_ID'],
411 411
 									'STS_ID' => EEM_Payment::status_id_approved
412 412
 								),
413
-								'force_join' => array( 'Payment_Method' ),
413
+								'force_join' => array('Payment_Method'),
414 414
 
415 415
 							),
416 416
 							ARRAY_A,
417 417
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
418 418
 
419
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
420
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
421
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
422
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
419
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
420
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
421
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
422
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
423 423
 					}
424 424
 
425 425
 				}
426
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
427
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
428
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
426
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
427
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
428
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
429 429
 
430 430
 				//get whether or not the user has checked in
431
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
431
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
432 432
 				//get ticket of registration and its price
433 433
 				$ticket_model = EE_Registry::instance()->load_model('Ticket');
434
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
435
-					$ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
434
+				if ($reg_row['Ticket.TKT_ID']) {
435
+					$ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
436 436
 					$datetimes_strings = array();
437
-					foreach( EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
438
-						$datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
437
+					foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
438
+						$datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
439 439
 					}
440 440
 
441 441
 				} else {
442
-					$ticket_name = __( 'Unknown', 'event_espresso' );
443
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
442
+					$ticket_name = __('Unknown', 'event_espresso');
443
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
444 444
 				}
445 445
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
446 446
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
447 447
 				//get datetime(s) of registration
448 448
 
449 449
 				//add attendee columns
450
-				foreach($att_fields_to_include as $att_field_name){
450
+				foreach ($att_fields_to_include as $att_field_name) {
451 451
 					$field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
452
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
453
-						if($att_field_name == 'STA_ID'){
454
-							$value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
455
-						}elseif($att_field_name == 'CNT_ISO'){
456
-							$value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
457
-						}else{
458
-							$value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
452
+					if ($reg_row['Attendee_CPT.ID']) {
453
+						if ($att_field_name == 'STA_ID') {
454
+							$value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
455
+						}elseif ($att_field_name == 'CNT_ISO') {
456
+							$value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
457
+						} else {
458
+							$value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
459 459
 						}
460
-					}else{
460
+					} else {
461 461
 						$value = '';
462 462
 					}
463 463
 
@@ -465,56 +465,56 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 
467 467
 				//make sure each registration has the same questions in the same order
468
-				foreach($questions_for_these_regs_rows as $question_row){
469
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
470
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
468
+				foreach ($questions_for_these_regs_rows as $question_row) {
469
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
470
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
471 471
 					}
472 472
 				}
473 473
 				//now fill out the questions THEY answered
474
-				foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){
474
+				foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) {
475 475
 					/* @var $answer EE_Answer */
476
-					if( $answer_row[ 'Question.QST_ID' ] ){
477
-						$question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] );
478
-					}else{
479
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
476
+					if ($answer_row['Question.QST_ID']) {
477
+						$question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']);
478
+					} else {
479
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
480 480
 					}
481
-                                        if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) {
482
-                                            $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] );
481
+                                        if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) {
482
+                                            $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']);
483 483
                                         } else {
484
-                                            $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] );
484
+                                            $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']);
485 485
                                         }
486 486
 				}
487
-				$registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row );
487
+				$registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row);
488 488
 			}
489 489
 		}
490 490
 
491 491
 		//if we couldn't export anything, we want to at least show the column headers
492
-		if(empty($registrations_csv_ready_array)){
492
+		if (empty($registrations_csv_ready_array)) {
493 493
 			$reg_csv_array = array();
494 494
 			$model_and_fields_to_include = array(
495 495
 				'Registration' => $reg_fields_to_include,
496 496
 				'Attendee' => $att_fields_to_include
497 497
 			);
498
-			foreach($model_and_fields_to_include as $model_name => $field_list){
498
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
499 499
 				$model = EE_Registry::instance()->load_model($model_name);
500
-				foreach($field_list as $field_name){
500
+				foreach ($field_list as $field_name) {
501 501
 					$field = $model->field_settings_for($field_name);
502
-					$reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name());
502
+					$reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name());
503 503
 				}
504 504
 			}
505 505
 			$registrations_csv_ready_array [] = $reg_csv_array;
506 506
 		}
507
-		if( $event_id ){
508
-			$event_slug =  EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
509
-			if( ! $event_slug ) {
510
-				$event_slug = __( 'unknown', 'event_espresso' );
507
+		if ($event_id) {
508
+			$event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
509
+			if ( ! $event_slug) {
510
+				$event_slug = __('unknown', 'event_espresso');
511 511
 			}
512
-		}else{
513
-			$event_slug = __( 'all', 'event_espresso' );
512
+		} else {
513
+			$event_slug = __('all', 'event_espresso');
514 514
 		}
515
-		$filename = sprintf( "registrations-for-%s", $event_slug );
515
+		$filename = sprintf("registrations-for-%s", $event_slug);
516 516
 
517
-		$handle = $this->EE_CSV->begin_sending_csv( $filename);
517
+		$handle = $this->EE_CSV->begin_sending_csv($filename);
518 518
 		$this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array);
519 519
 		$this->EE_CSV->end_sending_csv($handle);
520 520
 	}
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @param EE_Model_Field_Base $field
525 525
 	 * @return string
526 526
 	 */
527
-	protected function _get_column_name_for_field(EE_Model_Field_Base $field){
527
+	protected function _get_column_name_for_field(EE_Model_Field_Base $field) {
528 528
 		return $field->get_nicename()."[".$field->get_name()."]";
529 529
 	}
530 530
 
@@ -537,17 +537,17 @@  discard block
 block discarded – undo
537 537
 	function export_categories() {
538 538
 		// are any Event IDs set?
539 539
 		$query_params = array();
540
-		if ( isset( $this->_req_data['EVT_CAT_ID'] )) {
540
+		if (isset($this->_req_data['EVT_CAT_ID'])) {
541 541
 			// do we have an array of IDs ?
542
-			if ( is_array( $this->_req_data['EVT_CAT_ID'] )) {
542
+			if (is_array($this->_req_data['EVT_CAT_ID'])) {
543 543
 				// generate an "IN (CSV)" where clause
544
-				$EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] );
544
+				$EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']);
545 545
 				$filename = 'event-categories';
546
-				$query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs);
546
+				$query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs);
547 547
 			} else {
548 548
 				// generate regular where = clause
549
-				$EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] );
550
-				$filename = 'event-category#' . $EVT_CAT_ID;
549
+				$EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']);
550
+				$filename = 'event-category#'.$EVT_CAT_ID;
551 551
 				$query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID;
552 552
 			}
553 553
 		} else {
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 				'Term_Taxonomy' => $query_params
560 560
 			);
561 561
 
562
-		$table_data = $this->_get_export_data_for_models( $tables_to_export );
563
-		$filename = $this->generate_filename ( $filename );
562
+		$table_data = $this->_get_export_data_for_models($tables_to_export);
563
+		$filename = $this->generate_filename($filename);
564 564
 
565
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) {
566
-			EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
565
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) {
566
+			EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
567 567
 		}
568 568
 	}
569 569
 
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 	 *		  @param string - export_name
575 575
 	 *			@return string on success, FALSE on fail
576 576
 	 */
577
-	private function generate_filename ( $export_name = '' ) {
578
-		if ( $export_name != '' ) {
579
-			$filename = get_bloginfo('name') . '-' . $export_name;
580
-			$filename = sanitize_key( $filename ) . '-' . $this->today;
577
+	private function generate_filename($export_name = '') {
578
+		if ($export_name != '') {
579
+			$filename = get_bloginfo('name').'-'.$export_name;
580
+			$filename = sanitize_key($filename).'-'.$this->today;
581 581
 			return $filename;
582
-		}	 else {
583
-			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
582
+		} else {
583
+			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
584 584
 		}
585 585
 		return false;
586 586
 	}
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
 	 *	@param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all
594 594
 	 *	@return array on success, FALSE on fail
595 595
 	 */
596
-	private function _get_export_data_for_models( $models_to_export = array() ) {
596
+	private function _get_export_data_for_models($models_to_export = array()) {
597 597
 		$table_data = FALSE;
598
-		if ( is_array( $models_to_export ) ) {
599
-			foreach ( $models_to_export as $model_name => $query_params ) {
598
+		if (is_array($models_to_export)) {
599
+			foreach ($models_to_export as $model_name => $query_params) {
600 600
 				//check for a numerically-indexed array. in that case, $model_name is the value!!
601
-				if(is_int($model_name)){
601
+				if (is_int($model_name)) {
602 602
 					$model_name = $query_params;
603 603
 					$query_params = array();
604 604
 				}
@@ -606,17 +606,17 @@  discard block
 block discarded – undo
606 606
 				$model_objects = $model->get_all($query_params);
607 607
 
608 608
 				$table_data[$model_name] = array();
609
-				foreach($model_objects as $model_object){
609
+				foreach ($model_objects as $model_object) {
610 610
 					$model_data_array = array();
611 611
 					$fields = $model->field_settings();
612
-					foreach($fields as $field){
612
+					foreach ($fields as $field) {
613 613
 						$column_name = $field->get_nicename()."[".$field->get_name()."]";
614
-						if($field instanceof EE_Datetime_Field){
614
+						if ($field instanceof EE_Datetime_Field) {
615 615
 //							$field->set_date_format('Y-m-d');
616 616
 //							$field->set_time_format('H:i:s');
617
-							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s');
617
+							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s');
618 618
 						}
619
-						else{
619
+						else {
620 620
 							$model_data_array[$column_name] = $model_object->get($field->get_name());
621 621
 						}
622 622
 					}
Please login to merge, or discard this patch.
core/db_models/fields/EE_Maybe_Serialized_Simple_HTML_Field.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  * But either way, the string or the array's values can ONLY contain simple HTML tags.
25 25
  * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field
26 26
  */
27
-class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field{
27
+class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field {
28 28
 	/**
29 29
 	 * removes all non-basic tags when setting
30 30
 	 * @param string $value_inputted_for_field_on_model_object
31 31
 	 * @return string
32 32
 	 */
33 33
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
34
-		return parent::prepare_for_set( $this->_remove_tags(  $value_inputted_for_field_on_model_object ) );
34
+		return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object));
35 35
 	}
36 36
 
37 37
 	/**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 * @param array|string $value
40 40
 	 * @return array|string
41 41
 	 */
42
-	protected function _remove_tags( $value ) {
43
-		if( is_array( $value ) ) {
44
-			foreach( $value as $key => $v ) {
45
-				$value[ $key ] = $this->_remove_tags( $v );
42
+	protected function _remove_tags($value) {
43
+		if (is_array($value)) {
44
+			foreach ($value as $key => $v) {
45
+				$value[$key] = $this->_remove_tags($v);
46 46
 			}
47
-		}elseif( is_string( $value ) ) {
48
-			$value = wp_kses("$value", $this->_get_allowed_tags() );
47
+		}elseif (is_string($value)) {
48
+			$value = wp_kses("$value", $this->_get_allowed_tags());
49 49
 		}
50 50
 		return $value;
51 51
 	}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return array|string
57 57
 	 */
58 58
 	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
59
-		return $this->_remove_tags( parent::prepare_for_set_from_db( $value_found_in_db_for_model_object ) );
59
+		return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object));
60 60
 	}
61 61
 
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @global array $allowedtags
66 66
 	 * @return array
67 67
 	 */
68
-	function _get_allowed_tags(){
69
-		return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this );
68
+	function _get_allowed_tags() {
69
+		return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this);
70 70
 	}
71 71
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Simple_HTML_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
2
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
3 3
 /**
4 4
  * Only allows a select, small number of html tags: a,abbr,acronym,b,blockquote,cite,code,del,em,i,q,strike,strong,ol,ul,li
5 5
  * If you want more use EE_Post_Content_Field, or if you want to allow ALL, use EE_Full_HTML_Field.
6 6
  * If you want NONE, use EE_Plain_Text_Field.
7 7
  */
8
-class EE_Simple_HTML_Field extends EE_Text_Field_Base{
8
+class EE_Simple_HTML_Field extends EE_Text_Field_Base {
9 9
 	/**
10 10
 	 * removes all tags when setting
11 11
 	 * @param string $value_inputted_for_field_on_model_object
12 12
 	 * @return string
13 13
 	 */
14 14
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
15
-		$value_with_select_tags =  wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags() );
15
+		$value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags());
16 16
 		return parent::prepare_for_set($value_with_select_tags);
17 17
 	}
18 18
 
Please login to merge, or discard this patch.
core/helpers/EEH_HTML.helper.php 1 patch
Spacing   +121 added lines, -121 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;
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 		$other_attributes = '',
103 103
 		$force_close = false
104 104
 	) {
105
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
106
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
107
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
108
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
109
-		$html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>';
110
-		$html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag  ) . $content : '';
111
-		$indent = ! empty( $content ) || $force_close ? TRUE : FALSE;
112
-		$html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : '';
105
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
106
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
107
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
108
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
109
+		$html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>';
110
+		$html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : '';
111
+		$indent = ! empty($content) || $force_close ? TRUE : FALSE;
112
+		$html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : '';
113 113
 		return $html;
114 114
 	}
115 115
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	 * @param bool   $indent
127 127
 	 * @return string
128 128
 	 */
129
-	protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) {
129
+	protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) {
130 130
 		$comment = '';
131
-		if ( $id ) {
132
-			$comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag );
133
-		} else if ( $class ) {
134
-			$comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag );
131
+		if ($id) {
132
+			$comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag);
133
+		} else if ($class) {
134
+			$comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag);
135 135
 		}
136 136
 		$html = $indent ? EEH_HTML::nl( -1, $tag ) : '';
137
-		$html .= '</' . $tag . '>' . $comment;
137
+		$html .= '</'.$tag.'>'.$comment;
138 138
 		return $html;
139 139
 	}
140 140
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
154 154
 	 * @return string
155 155
 	 */
156
-	public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
157
-		return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes );
156
+	public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
157
+		return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes);
158 158
 	}
159 159
 
160 160
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * @param string $class - html class attribute
168 168
 	 * @return string
169 169
 	 */
170
-	public static function divx( $id = '', $class = '' ) {
171
-		return EEH_HTML::_close_tag( 'div', $id, $class );
170
+	public static function divx($id = '', $class = '') {
171
+		return EEH_HTML::_close_tag('div', $id, $class);
172 172
 	}
173 173
 
174 174
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
185 185
 	 * @return string
186 186
 	 */
187
-	public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
188
-		return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE );
187
+	public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
188
+		return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE);
189 189
 	}
190 190
 
191 191
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
202 202
 	 * @return string
203 203
 	 */
204
-	public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
205
-		return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE );
204
+	public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
205
+		return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE);
206 206
 	}
207 207
 
208 208
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
219 219
 	 * @return string
220 220
 	 */
221
-	public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
222
-		return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE );
221
+	public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
222
+		return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE);
223 223
 	}
224 224
 
225 225
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
236 236
 	 * @return string
237 237
 	 */
238
-	public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
239
-		return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE );
238
+	public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
239
+		return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE);
240 240
 	}
241 241
 
242 242
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
253 253
 	 * @return string
254 254
 	 */
255
-	public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
256
-		return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE );
255
+	public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
256
+		return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE);
257 257
 	}
258 258
 
259 259
 
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
270 270
 	 * @return string
271 271
 	 */
272
-	public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
273
-		return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE );
272
+	public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
273
+		return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE);
274 274
 	}
275 275
 
276 276
 
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
287 287
 	 * @return string
288 288
 	 */
289
-	public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
290
-		return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE );
289
+	public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
290
+		return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE);
291 291
 	}
292 292
 
293 293
 
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
303 303
 	 * @return string
304 304
 	 */
305
-	public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) {
306
-		return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes );
305
+	public static function ul($id = '', $class = '', $style = '', $other_attributes = '') {
306
+		return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes);
307 307
 	}
308 308
 
309 309
 
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
 	 * @param string $class - html class attribute
317 317
 	 * @return string
318 318
 	 */
319
-	public static function ulx( $id = '', $class = '' ) {
320
-		return EEH_HTML::_close_tag( 'ul', $id, $class );
319
+	public static function ulx($id = '', $class = '') {
320
+		return EEH_HTML::_close_tag('ul', $id, $class);
321 321
 	}
322 322
 
323 323
 
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
335 335
 	 * @return string
336 336
 	 */
337
-	public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
338
-		return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes );
337
+	public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
338
+		return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes);
339 339
 	}
340 340
 
341 341
 
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 	 * @param string $class - html class attribute
349 349
 	 * @return string
350 350
 	 */
351
-	public static function lix( $id = '', $class = '' ) {
352
-		return EEH_HTML::_close_tag( 'li', $id, $class );
351
+	public static function lix($id = '', $class = '') {
352
+		return EEH_HTML::_close_tag('li', $id, $class);
353 353
 	}
354 354
 
355 355
 
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
366 366
 	 * @return string
367 367
 	 */
368
-	public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
369
-		return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes );
368
+	public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
369
+		return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes);
370 370
 	}
371 371
 
372 372
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param string $class - html class attribute
379 379
 	 * @return string
380 380
 	 */
381
-	public static function tablex( $id = '', $class = '' ) {
382
-		return EEH_HTML::_close_tag( 'table', $id, $class );
381
+	public static function tablex($id = '', $class = '') {
382
+		return EEH_HTML::_close_tag('table', $id, $class);
383 383
 	}
384 384
 
385 385
 
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
396 396
 	 * @return string
397 397
 	 */
398
-	public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
399
-		return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes );
398
+	public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
399
+		return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes);
400 400
 	}
401 401
 
402 402
 
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param string $class - html class attribute
409 409
 	 * @return string
410 410
 	 */
411
-	public static function theadx( $id = '', $class = '' ) {
412
-		return EEH_HTML::_close_tag( 'thead', $id, $class );
411
+	public static function theadx($id = '', $class = '') {
412
+		return EEH_HTML::_close_tag('thead', $id, $class);
413 413
 	}
414 414
 
415 415
 
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
426 426
 	 * @return string
427 427
 	 */
428
-	public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
429
-		return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes );
428
+	public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
429
+		return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes);
430 430
 	}
431 431
 
432 432
 
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param string $class - html class attribute
439 439
 	 * @return string
440 440
 	 */
441
-	public static function tbodyx( $id = '', $class = '' ) {
442
-		return EEH_HTML::_close_tag( 'tbody', $id, $class );
441
+	public static function tbodyx($id = '', $class = '') {
442
+		return EEH_HTML::_close_tag('tbody', $id, $class);
443 443
 	}
444 444
 
445 445
 
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
456 456
 	 * @return string
457 457
 	 */
458
-	public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
459
-		return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes );
458
+	public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
459
+		return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes);
460 460
 	}
461 461
 
462 462
 
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 	 * @param string $class - html class attribute
469 469
 	 * @return string
470 470
 	 */
471
-	public static function trx( $id = '', $class = '' ) {
472
-		return EEH_HTML::_close_tag( 'tr', $id, $class );
471
+	public static function trx($id = '', $class = '') {
472
+		return EEH_HTML::_close_tag('tr', $id, $class);
473 473
 	}
474 474
 
475 475
 
@@ -485,8 +485,8 @@  discard block
 block discarded – undo
485 485
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
486 486
 	 * @return string
487 487
 	 */
488
-	public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
489
-		return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes );
488
+	public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
489
+		return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes);
490 490
 	}
491 491
 
492 492
 
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 	 * @param string $class - html class attribute
499 499
 	 * @return string
500 500
 	 */
501
-	public static function thx( $id = '', $class = '' ) {
502
-		return EEH_HTML::_close_tag( 'th', $id, $class );
501
+	public static function thx($id = '', $class = '') {
502
+		return EEH_HTML::_close_tag('th', $id, $class);
503 503
 	}
504 504
 
505 505
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
516 516
 	 * @return string
517 517
 	 */
518
-	public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
519
-		return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes );
518
+	public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
519
+		return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes);
520 520
 	}
521 521
 
522 522
 
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	 * @param string $class - html class attribute
529 529
 	 * @return string
530 530
 	 */
531
-	public static function tdx( $id = '', $class = '' ) {
532
-		return EEH_HTML::_close_tag( 'td', $id, $class );
531
+	public static function tdx($id = '', $class = '') {
532
+		return EEH_HTML::_close_tag('td', $id, $class);
533 533
 	}
534 534
 
535 535
 
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 	 * @param int    $colspan
544 544
 	 * @return string
545 545
 	 */
546
-	public static function no_row( $content = '', $colspan = 2 ) {
546
+	public static function no_row($content = '', $colspan = 2) {
547 547
 		return EEH_HTML::tr(
548
-			EEH_HTML::td( $content, '', '',  'padding:0; border:none;', 'colspan="' . $colspan . '"' ),
549
-			'', '',  'padding:0; border:none;'
548
+			EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'),
549
+			'', '', 'padding:0; border:none;'
550 550
 		);
551 551
 	}
552 552
 
@@ -566,14 +566,14 @@  discard block
 block discarded – undo
566 566
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
567 567
 	 * @return string
568 568
 	 */
569
-	public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
570
-		$link_text = ! empty( $link_text ) ? $link_text : $href;
571
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
572
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
573
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
574
-		$attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : '';
575
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
576
-		return '<a href="' . $href . '" ' . $attributes . '>'  . $link_text  . '</a>';
569
+	public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') {
570
+		$link_text = ! empty($link_text) ? $link_text : $href;
571
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
572
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
573
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
574
+		$attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : '';
575
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
576
+		return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>';
577 577
 	}
578 578
 
579 579
 
@@ -590,14 +590,14 @@  discard block
 block discarded – undo
590 590
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
591 591
 	 * @return string
592 592
 	 */
593
-	public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
594
-		$attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : '';
595
-		$attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : '';
596
-		$attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
597
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
598
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
599
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
600
-		return '<img' . $attributes  . '/>';
593
+	public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') {
594
+		$attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : '';
595
+		$attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : '';
596
+		$attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
597
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
598
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
599
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
600
+		return '<img'.$attributes.'/>';
601 601
 	}
602 602
 
603 603
 
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
616 616
 	 * @return string
617 617
 	 */
618
-	protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
619
-		$attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : '';
620
-		$attributes .= ! empty( $class ) ? ' class="' . $class . '"' : '';
621
-		$attributes .= ! empty( $style ) ? ' style="' . $style . '"' : '';
622
-		$attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : '';
623
-		return '<' . $tag . ' ' . $attributes . '>'  . $content  . '</' . $tag . '>';
618
+	protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
619
+		$attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : '';
620
+		$attributes .= ! empty($class) ? ' class="'.$class.'"' : '';
621
+		$attributes .= ! empty($style) ? ' style="'.$style.'"' : '';
622
+		$attributes .= ! empty($other_attributes) ? ' '.$other_attributes : '';
623
+		return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>';
624 624
 	}
625 625
 
626 626
 
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
637 637
 	 * @return string
638 638
 	 */
639
-	public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
640
-		return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes );
639
+	public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
640
+		return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes);
641 641
 	}
642 642
 
643 643
 
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
654 654
 	 * @return string
655 655
 	 */
656
-	public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
657
-		return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes );
656
+	public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
657
+		return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes);
658 658
 	}
659 659
 
660 660
 
@@ -670,8 +670,8 @@  discard block
 block discarded – undo
670 670
 	 * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc
671 671
 	 * @return string
672 672
 	 */
673
-	public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) {
674
-		return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes );
673
+	public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') {
674
+		return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes);
675 675
 	}
676 676
 
677 677
 
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 	 * @param string $comment
684 684
 	 * @return string
685 685
 	 */
686
-	public static function comment( $comment = '' ) {
687
-		return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : '';
686
+	public static function comment($comment = '') {
687
+		return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : '';
688 688
 	}
689 689
 
690 690
 
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
 	 * @param int $nmbr - the number of line breaks to return
696 696
 	 * @return string
697 697
 	 */
698
-	public static function br( $nmbr = 1 ) {
699
-		return str_repeat( '<br />', $nmbr );
698
+	public static function br($nmbr = 1) {
699
+		return str_repeat('<br />', $nmbr);
700 700
 	}
701 701
 
702 702
 
@@ -707,8 +707,8 @@  discard block
 block discarded – undo
707 707
 	 * @param int $nmbr - the number of non-breaking spaces to return
708 708
 	 * @return string
709 709
 	 */
710
-	public static function nbsp( $nmbr = 1 ) {
711
-		return str_repeat( '&nbsp;', $nmbr );
710
+	public static function nbsp($nmbr = 1) {
711
+		return str_repeat('&nbsp;', $nmbr);
712 712
 	}
713 713
 
714 714
 
@@ -722,9 +722,9 @@  discard block
 block discarded – undo
722 722
 	 * @param string $id
723 723
 	 * @return string
724 724
 	 */
725
-	public static function sanitize_id( $id = '' ) {
726
-		$key = str_replace( ' ', '-', trim( $id ) );
727
-		return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key );
725
+	public static function sanitize_id($id = '') {
726
+		$key = str_replace(' ', '-', trim($id));
727
+		return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key);
728 728
 	}
729 729
 
730 730
 
@@ -736,10 +736,10 @@  discard block
 block discarded – undo
736 736
 	 * @param string $tag
737 737
 	 * @return string - newline character plus # of indents passed (can be + or -)
738 738
 	 */
739
-	public static function nl( $indent = 0, $tag = 'none' ) {
739
+	public static function nl($indent = 0, $tag = 'none') {
740 740
 		$html = "\n";
741
-		EEH_HTML::indent( $indent, $tag );
742
-		for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) {
741
+		EEH_HTML::indent($indent, $tag);
742
+		for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) {
743 743
 			$html .= "\t";
744 744
 		}
745 745
 		return $html;
@@ -754,17 +754,17 @@  discard block
 block discarded – undo
754 754
 	 * @param int    $indent can be negative to decrease the indentation level
755 755
 	 * @param string $tag
756 756
 	 */
757
-	public static function indent( $indent, $tag = 'none' ){
757
+	public static function indent($indent, $tag = 'none') {
758 758
 		static $default_indentation = FALSE;
759
-		if ( ! $default_indentation ) {
759
+		if ( ! $default_indentation) {
760 760
 			EEH_HTML::_set_default_indentation();
761 761
 			$default_indentation = TRUE;
762 762
 		}
763
-		if ( ! isset( EEH_HTML::$_indent[ $tag ] )) {
764
-			EEH_HTML::$_indent[ $tag ] = 0;
763
+		if ( ! isset(EEH_HTML::$_indent[$tag])) {
764
+			EEH_HTML::$_indent[$tag] = 0;
765 765
 		}
766
-		EEH_HTML::$_indent[ $tag ] += (int)$indent;
767
-		EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0;
766
+		EEH_HTML::$_indent[$tag] += (int) $indent;
767
+		EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0;
768 768
 	}
769 769
 
770 770
 
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
 	 * @global array $allowedtags
811 811
 	 * @return array
812 812
 	 */
813
-	public static function get_simple_tags(){
813
+	public static function get_simple_tags() {
814 814
 		global $allowedtags;
815 815
 		$tags_we_allow = $allowedtags;
816
-		$tags_we_allow['ol']=array();
817
-		$tags_we_allow['ul']=array();
818
-		$tags_we_allow['li']=array();
819
-		$tags_we_allow['br']=array();
820
-		$tags_we_allow['p']=array();
821
-		return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow );
816
+		$tags_we_allow['ol'] = array();
817
+		$tags_we_allow['ul'] = array();
818
+		$tags_we_allow['li'] = array();
819
+		$tags_we_allow['br'] = array();
820
+		$tags_we_allow['p'] = array();
821
+		return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow);
822 822
 	}
823 823
 
824 824
 
Please login to merge, or discard this patch.
core/libraries/rest_api/Calculated_Model_Fields.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * @since		 	   4.8.35.rc.001
16 16
  *
17 17
  */
18
-if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
19
-	exit( 'No direct script access allowed' );
18
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
19
+	exit('No direct script access allowed');
20 20
 }
21 21
 
22 22
 class Calculated_Model_Fields {
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * the WP_Request object,
39 39
 	 * the controller object
40 40
 	 */
41
-	public function mapping( $refresh = false ) {
42
-		if( ! $this->_mapping || $refresh ) {
41
+	public function mapping($refresh = false) {
42
+		if ( ! $this->_mapping || $refresh) {
43 43
 			$this->_mapping = $this->_generate_new_mapping();
44 44
 		}
45 45
 		return $this->_mapping;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	protected function _generate_new_mapping() {
54 54
 		$rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\';
55
-		$event_calculations_class = $rest_api_calculations_namespace . 'Event';
56
-		$datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime';
57
-		$registration_class = $rest_api_calculations_namespace . 'Registration';
55
+		$event_calculations_class = $rest_api_calculations_namespace.'Event';
56
+		$datetime_calculations_class = $rest_api_calculations_namespace.'Datetime';
57
+		$registration_class = $rest_api_calculations_namespace.'Registration';
58 58
 		return apply_filters(
59 59
 			'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping',
60 60
 			array(
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 * @param \EEM_Base $model
92 92
 	 * @return array allowable values for this field
93 93
 	 */
94
-	public function retrieve_calculated_fields_for_model( \EEM_Base $model ) {
94
+	public function retrieve_calculated_fields_for_model(\EEM_Base $model) {
95 95
 		$mapping = $this->mapping();
96
-		if( isset( $mapping[ $model->get_this_model_name() ] ) ) {
97
-			return array_keys( $mapping[ $model->get_this_model_name() ] );
96
+		if (isset($mapping[$model->get_this_model_name()])) {
97
+			return array_keys($mapping[$model->get_this_model_name()]);
98 98
 		} else {
99 99
 			return array();
100 100
 		}
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	 * @return mixed|null
114 114
 	 * @throws \EE_Error
115 115
 	 */
116
-	public function retrieve_calculated_field_value( \EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller ) {
116
+	public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller) {
117 117
 		$mapping = $this->mapping();
118
-		if( isset( $mapping[ $model->get_this_model_name() ] )
119
-			&& isset( $mapping[ $model->get_this_model_name() ][ $field_name ] ) ) {
120
-			$classname = $mapping[ $model->get_this_model_name() ][ $field_name ];
121
-			return call_user_func( array( $classname, $field_name ), $wpdb_row, $rest_request, $controller );
118
+		if (isset($mapping[$model->get_this_model_name()])
119
+			&& isset($mapping[$model->get_this_model_name()][$field_name])) {
120
+			$classname = $mapping[$model->get_this_model_name()][$field_name];
121
+			return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller);
122 122
 		}
123 123
 		throw new Rest_Exception( 
124 124
 			'calculated_field_does_not_exist',
125 125
 			sprintf( 
126
-				__( 'There is no calculated field %1$s on resource %2$s', 'event_espresso' ), 
126
+				__('There is no calculated field %1$s on resource %2$s', 'event_espresso'), 
127 127
 				$field_name, 
128 128
 				$model->get_this_model_name() 
129 129
 			) 
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Registration.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * @since		 	   $VID:$
16 16
  *
17 17
  */
18
-if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
19
-	exit( 'No direct script access allowed' );
18
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
19
+	exit('No direct script access allowed');
20 20
 }
21 21
 
22 22
 class Registration extends Calculations_Base {
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 * @return int
31 31
 	 * @throws \EE_Error
32 32
 	 */
33
-	public static function datetime_checkin_stati( $wpdb_row, $request, $controller ){
34
-		if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Registration.REG_ID' ] ) ) {
35
-			$reg = \EEM_Registration::instance()->get_one_by_ID( $wpdb_row[ 'Registration.REG_ID' ] );
33
+	public static function datetime_checkin_stati($wpdb_row, $request, $controller) {
34
+		if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) {
35
+			$reg = \EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']);
36 36
 		} else {
37 37
 			$reg = null;
38 38
 		}
39
-		if( ! $reg instanceof \EE_Registration 
39
+		if ( ! $reg instanceof \EE_Registration 
40 40
 		) {
41 41
 			throw new \EE_Error(
42 42
 				sprintf(
43
-					__( 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso' ),
44
-					$wpdb_row[ 'Registration.REG_ID' ],
45
-					print_r( $wpdb_row, true )
43
+					__('Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso'),
44
+					$wpdb_row['Registration.REG_ID'],
45
+					print_r($wpdb_row, true)
46 46
 				)
47 47
 			);
48 48
 		}
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 			)
55 55
 		);
56 56
 		$checkin_stati = array();
57
-		foreach( $datetime_ids as $datetime_id ) {
58
-			$status = $reg->check_in_status_for_datetime( $datetime_id );
59
-			switch( $status ) {
57
+		foreach ($datetime_ids as $datetime_id) {
58
+			$status = $reg->check_in_status_for_datetime($datetime_id);
59
+			switch ($status) {
60 60
 				case \EE_Registration::checkin_status_out:
61 61
 					$status_pretty = 'OUT';
62 62
 					break;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 					$status_pretty = 'NEVER';
69 69
 					break;
70 70
 			}
71
-			$checkin_stati[ $datetime_id ] = $status_pretty;
71
+			$checkin_stati[$datetime_id] = $status_pretty;
72 72
 		}
73 73
 		return $checkin_stati;
74 74
 	}
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Credit_Card_Month_Input.input.php 1 patch
Spacing   +4 added lines, -4 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
 /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * ------------------------------------------------------------------------
26 26
  */
27
-class EE_Credit_Card_Month_Input extends EE_Month_Input{
27
+class EE_Credit_Card_Month_Input extends EE_Month_Input {
28 28
 
29 29
 	/**
30 30
 	 * @param bool  $leading_zero
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 		$leading_zero = false, 
36 36
 		$input_settings = array(), 
37 37
 		$january_is_month_1 = true 
38
-	){
39
-		$this->set_sensitive_data_removal_strategy( new EE_All_Sensitive_Data_Removal() );
38
+	) {
39
+		$this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal());
40 40
 		parent::__construct(
41 41
 			$leading_zero,
42 42
 			$input_settings, 
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Month_Input.input.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@  discard block
 block discarded – undo
6 6
  * @subpackage
7 7
  * @author				Mike Nelson
8 8
  */
9
-class EE_Month_Input extends EE_Select_Input{
9
+class EE_Month_Input extends EE_Select_Input {
10 10
 
11 11
 	/**
12 12
 	 * @param bool  $leading_zero
13 13
 	 * @param array $input_settings
14 14
 	 * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0
15 15
 	 */
16
-	function __construct( $leading_zero = false, $input_settings = array(), $january_is_month_1 = true){
16
+	function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) {
17 17
 		$key_begin_range = $january_is_month_1 ? 1 : 0;
18
-		$key_range = range($key_begin_range, $key_begin_range + 11 );
19
-		if($leading_zero){
20
-			array_walk( $key_range, array( $this, '_zero_pad' ) );	
18
+		$key_range = range($key_begin_range, $key_begin_range + 11);
19
+		if ($leading_zero) {
20
+			array_walk($key_range, array($this, '_zero_pad'));	
21 21
 		}
22
-		$value_range = range( 1, 12 );
23
-		array_walk( $value_range, array( $this, '_zero_pad' ) );
22
+		$value_range = range(1, 12);
23
+		array_walk($value_range, array($this, '_zero_pad'));
24 24
 		parent::__construct(
25 25
 			array_combine( 
26 26
 				$key_range, 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param int $input
36 36
 	 * @param mixed $key
37 37
 	 */
38
-	protected function _zero_pad( &$input, $key ) {
39
-		$input = str_pad( $input, 2, '0', STR_PAD_LEFT );
38
+	protected function _zero_pad(&$input, $key) {
39
+		$input = str_pad($input, 2, '0', STR_PAD_LEFT);
40 40
 	}
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.