Completed
Push — master ( 324b21...97e5ed )
by
unknown
01:55
created
public/includes/helpers.php 2 patches
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -12,21 +12,21 @@  discard block
 block discarded – undo
12 12
  * @return the option value
13 13
  * @since 1.0
14 14
  */
15
-function lasso_editor_get_option( $option, $section, $default = '' ) {
15
+function lasso_editor_get_option($option, $section, $default = '') {
16 16
 
17
-	if ( empty( $option ) )
17
+	if (empty($option))
18 18
 		return;
19 19
 
20
-	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
20
+	if (function_exists('is_multisite') && is_multisite()) {
21 21
 
22
-		$options = get_site_option( $section );
22
+		$options = get_site_option($section);
23 23
 
24 24
 	} else {
25 25
 
26
-		$options = get_option( $section );
26
+		$options = get_option($section);
27 27
 	}
28 28
 
29
-	if ( isset( $options[$option] ) ) {
29
+	if (isset($options[$option])) {
30 30
 		return $options[$option];
31 31
 	}
32 32
 
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function lasso_editor_galleries_exist() {
42 42
 
43
-	$q = new wp_query( array( 'post_type' => 'ai_galleries', 'post_status' => 'publish' ) );
43
+	$q = new wp_query(array('post_type' => 'ai_galleries', 'post_status' => 'publish'));
44 44
 
45
-	if ( $q->have_posts() )
45
+	if ($q->have_posts())
46 46
 		return true;
47 47
 	else
48 48
 		return false;
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 function lasso_get_supported_theme_class() {
58 58
 
59 59
 	$name  	= wp_get_theme()->get('Name');
60
-	$slug  	= lasso_clean_string( $name );
60
+	$slug  	= lasso_clean_string($name);
61 61
 
62
-	switch ( $slug ) {
62
+	switch ($slug) {
63 63
 		case 'aesop-story-theme': // aesop
64 64
 			$out = '.aesop-entry-content';
65 65
 			break;
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
 
109 109
 	}
110 110
 
111
-	return apply_filters('lasso_content_class', !empty( $out ) ? $out : false);
111
+	return apply_filters('lasso_content_class', !empty($out) ? $out : false);
112 112
 	//return !empty( $out ) ? $out : false;
113 113
 }
114 114
 
115 115
 function lasso_get_supported_theme_title_class() {
116 116
 
117 117
 	$name  	= wp_get_theme()->get('Name');
118
-	$slug  	= lasso_clean_string( $name );
118
+	$slug  	= lasso_clean_string($name);
119 119
 
120
-	switch ( $slug ) {
120
+	switch ($slug) {
121 121
 
122 122
 		case 'aesop-story-theme': // aesop
123 123
 			$out = '.aesop-entry-title';
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
 			break;
146 146
 	}
147 147
 
148
-	return apply_filters('lasso_title_class', !empty( $out ) ? $out : false);
148
+	return apply_filters('lasso_title_class', !empty($out) ? $out : false);
149 149
 }
150 150
 
151 151
 //since 0.9.9.6
152 152
 function lasso_get_supported_theme_featured_image_class() {
153 153
 
154 154
 	$name  	= wp_get_theme()->get('Name');
155
-	$slug  	= lasso_clean_string( $name );
155
+	$slug  	= lasso_clean_string($name);
156 156
 
157
-	return apply_filters('lasso_featured_image_class', !empty( $out ) ? $out : false);
157
+	return apply_filters('lasso_featured_image_class', !empty($out) ? $out : false);
158 158
 }
159 159
 
160 160
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 *	@since 0.8.7
166 166
 *	@return string of comma separated classes
167 167
 */
168
-function lasso_supported_no_save(){
168
+function lasso_supported_no_save() {
169 169
 
170 170
 	return apply_filters('lasso_dont_save', '.lasso--ignore, .sharedaddy, .us_wrapper, .twitter-tweet, .meta, .edit-link, .ssba, .jp-relatedposts, .fb-comments');
171 171
 }
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return array|mixed|object|string|void
181 181
  */
182
-function lasso_sanitize_data( $data ) {
183
-	return \lasso\sanatize::do_sanitize( $data );
182
+function lasso_sanitize_data($data) {
183
+	return \lasso\sanatize::do_sanitize($data);
184 184
 
185 185
 }
186 186
 
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
  *	@since 0.9.3
191 191
  *	@return string of comma delimited category slugs
192 192
 */
193
-function lasso_get_post_objects( $postid = '', $taxonomy = 'category') {
193
+function lasso_get_post_objects($postid = '', $taxonomy = 'category') {
194 194
 
195
-	if ( empty( $postid ) )
195
+	if (empty($postid))
196 196
 		$postid = get_the_ID();
197 197
 
198
-	$objects = 'category' == $taxonomy ? get_the_category( $postid ) : get_the_tags( $postid );
198
+	$objects = 'category' == $taxonomy ? get_the_category($postid) : get_the_tags($postid);
199 199
 
200
-	if ( empty( $objects) )
200
+	if (empty($objects))
201 201
 		return;
202 202
 
203 203
 	$out = '';
204
-	foreach( $objects as $object ) {
204
+	foreach ($objects as $object) {
205 205
 		//$out .= $object->slug.', ';
206 206
 		$out .= $object->name.', ';
207 207
 	}
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
  *	@since 0.9.3
217 217
  *	@return array all categoiries
218 218
 */
219
-function lasso_get_objects( $taxonomy = 'category' ) {
219
+function lasso_get_objects($taxonomy = 'category') {
220 220
 
221 221
 	$objects = 'category' == $taxonomy ? get_categories(array('hide_empty' => 0)) : get_tags(array('hide_empty' => 0));
222 222
 
223
-	if ( empty( $objects) )
223
+	if (empty($objects))
224 224
 		return;
225 225
 
226 226
 	$out = "";
227
-	foreach( $objects as $object ) {
227
+	foreach ($objects as $object) {
228 228
 		$out .= $object->name.',';
229 229
 	}
230 230
 
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
  * @since 0.9.4
240 240
  */
241 241
 function lasso_post_types_names() {
242
-	$post_types = get_post_types( array(
242
+	$post_types = get_post_types(array(
243 243
 		'public' => true,
244
-	), 'objects' );
245
-	$post_types = array_combine( array_keys( $post_types ), wp_list_pluck( $post_types, 'label' ) );
246
-    unset( $post_types[ 'attachment' ] );
244
+	), 'objects');
245
+	$post_types = array_combine(array_keys($post_types), wp_list_pluck($post_types, 'label'));
246
+    unset($post_types['attachment']);
247 247
 
248 248
 	/**
249 249
 	 * Set which post types are allowed
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @param array $allowed_post_types Array of names (not labels) of allowed post types. Must be registered.
254 254
 	 */
255
-	$allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( 'post', 'page') );
256
-	$allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types );
255
+	$allowed_post_types = lasso_editor_get_option('allowed_post_types', 'lasso_editor', array('post', 'page'));
256
+	$allowed_post_types = apply_filters('lasso_allowed_post_types', $allowed_post_types);
257 257
 	if (!current_user_can('edit_pages')) {
258
-		$allowed_post_types = array_diff($allowed_post_types,array('page'));
258
+		$allowed_post_types = array_diff($allowed_post_types, array('page'));
259 259
 	}
260
-	foreach( $post_types as $name => $label ) {
261
-		if ( ! in_array( $name, $allowed_post_types ) ) {
262
-			unset( $post_types[ $name ] );
260
+	foreach ($post_types as $name => $label) {
261
+		if (!in_array($name, $allowed_post_types)) {
262
+			unset($post_types[$name]);
263 263
 		}
264 264
 	}
265 265
 	return $post_types;
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 
268 268
 
269 269
 function lasso_post_types() {
270
-	$post_types = get_post_types( array(
270
+	$post_types = get_post_types(array(
271 271
 		'public' => true,
272
-	), 'names' );
273
-    unset( $post_types[ 'attachment' ] );
272
+	), 'names');
273
+    unset($post_types['attachment']);
274 274
 
275 275
 	/**
276 276
 	 * Set which post types are allowed
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @param array $allowed_post_types Array of names (not labels) of allowed post types. Must be registered.
281 281
 	 */
282
-	$allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( 'post') );
283
-	$allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types );
284
-	foreach( $post_types as $name => $label ) {
285
-		if ( ! in_array( $name, $allowed_post_types ) ) {
286
-			unset( $post_types[ $name ] );
282
+	$allowed_post_types = lasso_editor_get_option('allowed_post_types', 'lasso_editor', array('post'));
283
+	$allowed_post_types = apply_filters('lasso_allowed_post_types', $allowed_post_types);
284
+	foreach ($post_types as $name => $label) {
285
+		if (!in_array($name, $allowed_post_types)) {
286
+			unset($post_types[$name]);
287 287
 		}
288 288
 	}
289 289
 	return $post_types;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	global $wp_post_types;
294 294
 	$post_types = lasso_post_types();
295 295
 	$rest_base = array();
296
-	foreach ( $post_types as $post_type) {
296
+	foreach ($post_types as $post_type) {
297 297
 		$rest_base[$post_type] = $wp_post_types[$post_type]->rest_base;
298 298
 	}
299 299
     
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
 *	@uses lasso_modal_addons()
312 312
 *	@since 0.9.4
313 313
 */
314
-function lasso_modal_addons_content( $tab = '', $type ){
314
+function lasso_modal_addons_content($tab = '', $type) {
315 315
 
316
-	$name = lasso_clean_string( $tab['name'] );
316
+	$name = lasso_clean_string($tab['name']);
317 317
 
318
-	if ( 'tab' == $type ) {
318
+	if ('tab' == $type) {
319 319
 
320
-		$out = sprintf( '<li data-addon-name="%s">%s</li>', $name, $tab['name'] );
320
+		$out = sprintf('<li data-addon-name="%s">%s</li>', $name, $tab['name']);
321 321
 
322
-	} else if ( 'content' == $type ){
322
+	} else if ('content' == $type) {
323 323
 
324
-		$content = isset( $tab['content'] ) && is_callable( $tab['content'] ) ? call_user_func( $tab['content'] ) : false;
325
-		$options = isset( $tab['options'] ) && is_callable( $tab['options'] ) ? call_user_func( $tab['options'] ) : false;
324
+		$content = isset($tab['content']) && is_callable($tab['content']) ? call_user_func($tab['content']) : false;
325
+		$options = isset($tab['options']) && is_callable($tab['options']) ? call_user_func($tab['options']) : false;
326 326
 
327
-		$out = sprintf( '<div class="lasso--modal__content not-visible" data-addon-content="%s">
327
+		$out = sprintf('<div class="lasso--modal__content not-visible" data-addon-content="%s">
328 328
 			%s%s
329
-			</div>', $name, $content, lasso_option_form( $name, $options ) );
329
+			</div>', $name, $content, lasso_option_form($name, $options));
330 330
 
331 331
 	}
332 332
 
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 *
342 342
 * @return void|string
343 343
 */
344
-function lasso_clean_string( $string = '' ) {
344
+function lasso_clean_string($string = '') {
345 345
 
346
-	if ( empty( $string ) )
346
+	if (empty($string))
347 347
 		return;
348 348
 
349
-	return sanitize_text_field( strtolower( preg_replace('/[\s_]/', '-', $string ) ) );
349
+	return sanitize_text_field(strtolower(preg_replace('/[\s_]/', '-', $string)));
350 350
 }
351 351
 
352 352
 /**
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
  *
360 360
  * @return void|string
361 361
  */
362
-function lasso_unclean_string( $string = '' ) {
362
+function lasso_unclean_string($string = '') {
363 363
 
364
-	if ( empty( $string ) ) {
364
+	if (empty($string)) {
365 365
 		return;
366 366
 	}
367 367
 
368
-	return sanitize_text_field( strtolower( str_replace( '-', '_', $string ) ) );
368
+	return sanitize_text_field(strtolower(str_replace('-', '_', $string)));
369 369
 }
370 370
 
371 371
 
@@ -380,39 +380,39 @@  discard block
 block discarded – undo
380 380
  * @param unknown $postid int the id of the post object to check against
381 381
  * @since 0.9.9.7 added filter 'lasso_user_can_filter'
382 382
  */
383
-if ( !function_exists( 'lasso_user_can' ) ):
384
-	function lasso_user_can( $action = '', $postid = 0 ) {
383
+if (!function_exists('lasso_user_can')):
384
+	function lasso_user_can($action = '', $postid = 0) {
385 385
         $result = false;
386
-		if ( empty( $action ) )
386
+		if (empty($action))
387 387
 			$action = 'edit_posts';
388 388
 
389
-		if ( empty( $postid ) && $action != 'edit_posts' && $action != 'publish_posts')
389
+		if (empty($postid) && $action != 'edit_posts' && $action != 'publish_posts')
390 390
 			$postid = get_the_ID();
391 391
 
392
-		if ( is_user_logged_in() && current_user_can( $action, $postid ) ) {
392
+		if (is_user_logged_in() && current_user_can($action, $postid)) {
393 393
 			// check against post types:
394
-			$allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( 'post', 'page') );
394
+			$allowed_post_types = lasso_editor_get_option('allowed_post_types', 'lasso_editor', array('post', 'page'));
395 395
 			
396 396
 			if (!current_user_can('edit_pages')) {
397
-				$allowed_post_types = array_diff($allowed_post_types,array('page'));
397
+				$allowed_post_types = array_diff($allowed_post_types, array('page'));
398 398
 			}
399 399
 			
400 400
             if (!empty($allowed_post_types) && !empty($postid)) {
401
-				$type = get_post_type( $postid );
402
-                $allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types );
401
+				$type = get_post_type($postid);
402
+                $allowed_post_types = apply_filters('lasso_allowed_post_types', $allowed_post_types);
403 403
 				
404
-                if ( in_array( $type, $allowed_post_types ) ) {
405
-				   $result =  true;
404
+                if (in_array($type, $allowed_post_types)) {
405
+				   $result = true;
406 406
 			    }
407 407
             } else {
408 408
                 //we are not checking against a post, return true
409
-				$result =  true;
409
+				$result = true;
410 410
         	}
411 411
 		} else {
412 412
 			$result = false;
413 413
 		}
414 414
 		
415
-		return apply_filters( 'lasso_user_can_filter', $result,  $action, $postid);
415
+		return apply_filters('lasso_user_can_filter', $result, $action, $postid);
416 416
 	}
417 417
 endif;
418 418
 
@@ -421,25 +421,25 @@  discard block
 block discarded – undo
421 421
 *
422 422
 *	@since 0.9.5
423 423
 */
424
-if ( !function_exists('lasso_editor_empty_results') ):
424
+if (!function_exists('lasso_editor_empty_results')):
425 425
 
426
-	function lasso_editor_empty_results( $type = 'posts' ){
426
+	function lasso_editor_empty_results($type = 'posts') {
427 427
 
428
-		if ( 'posts' == $type ) {
428
+		if ('posts' == $type) {
429 429
 
430
-			$string = apply_filters('lasso_empty_state_message', __('No posts to show', 'lasso') );
430
+			$string = apply_filters('lasso_empty_state_message', __('No posts to show', 'lasso'));
431 431
 			$icon = 'lasso-icon-file-text2';
432 432
 			$button = false;
433 433
 
434
-		} elseif ( 'revision' == $type ) {
434
+		} elseif ('revision' == $type) {
435 435
 
436
-			$string = apply_filters('lasso_empty_state_message', __('No revisions found', 'lasso') );
436
+			$string = apply_filters('lasso_empty_state_message', __('No revisions found', 'lasso'));
437 437
 			$icon = 'lasso-icon-history';
438
-			$button = sprintf('<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">%s</a>', __('Close','lasso') );
438
+			$button = sprintf('<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">%s</a>', __('Close', 'lasso'));
439 439
 
440 440
 		}
441 441
 
442
-		return sprintf('<div id="lasso--empty-state" class="lasso--empty-state"><i class="lasso--empty-state-icon lasso-icon %s"></i><p>%s</p>%s</div>', $icon, $string, $button );
442
+		return sprintf('<div id="lasso--empty-state" class="lasso--empty-state"><i class="lasso--empty-state-icon lasso-icon %s"></i><p>%s</p>%s</div>', $icon, $string, $button);
443 443
 	}
444 444
 
445 445
 endif;
Please login to merge, or discard this patch.
Braces   +27 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function lasso_editor_get_option( $option, $section, $default = '' ) {
16 16
 
17
-	if ( empty( $option ) )
18
-		return;
17
+	if ( empty( $option ) ) {
18
+			return;
19
+	}
19 20
 
20 21
 	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
21 22
 
@@ -42,11 +43,12 @@  discard block
 block discarded – undo
42 43
 
43 44
 	$q = new wp_query( array( 'post_type' => 'ai_galleries', 'post_status' => 'publish' ) );
44 45
 
45
-	if ( $q->have_posts() )
46
-		return true;
47
-	else
48
-		return false;
49
-}
46
+	if ( $q->have_posts() ) {
47
+			return true;
48
+	} else {
49
+			return false;
50
+	}
51
+	}
50 52
 
51 53
 /**
52 54
  * Return a CSS class of an automatically supported theme
@@ -192,13 +194,15 @@  discard block
 block discarded – undo
192 194
 */
193 195
 function lasso_get_post_objects( $postid = '', $taxonomy = 'category') {
194 196
 
195
-	if ( empty( $postid ) )
196
-		$postid = get_the_ID();
197
+	if ( empty( $postid ) ) {
198
+			$postid = get_the_ID();
199
+	}
197 200
 
198 201
 	$objects = 'category' == $taxonomy ? get_the_category( $postid ) : get_the_tags( $postid );
199 202
 
200
-	if ( empty( $objects) )
201
-		return;
203
+	if ( empty( $objects) ) {
204
+			return;
205
+	}
202 206
 
203 207
 	$out = '';
204 208
 	foreach( $objects as $object ) {
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 
221 225
 	$objects = 'category' == $taxonomy ? get_categories(array('hide_empty' => 0)) : get_tags(array('hide_empty' => 0));
222 226
 
223
-	if ( empty( $objects) )
224
-		return;
227
+	if ( empty( $objects) ) {
228
+			return;
229
+	}
225 230
 
226 231
 	$out = "";
227 232
 	foreach( $objects as $object ) {
@@ -343,8 +348,9 @@  discard block
 block discarded – undo
343 348
 */
344 349
 function lasso_clean_string( $string = '' ) {
345 350
 
346
-	if ( empty( $string ) )
347
-		return;
351
+	if ( empty( $string ) ) {
352
+			return;
353
+	}
348 354
 
349 355
 	return sanitize_text_field( strtolower( preg_replace('/[\s_]/', '-', $string ) ) );
350 356
 }
@@ -383,11 +389,13 @@  discard block
 block discarded – undo
383 389
 if ( !function_exists( 'lasso_user_can' ) ):
384 390
 	function lasso_user_can( $action = '', $postid = 0 ) {
385 391
         $result = false;
386
-		if ( empty( $action ) )
387
-			$action = 'edit_posts';
392
+		if ( empty( $action ) ) {
393
+					$action = 'edit_posts';
394
+		}
388 395
 
389
-		if ( empty( $postid ) && $action != 'edit_posts' && $action != 'publish_posts')
390
-			$postid = get_the_ID();
396
+		if ( empty( $postid ) && $action != 'edit_posts' && $action != 'publish_posts') {
397
+					$postid = get_the_ID();
398
+		}
391 399
 
392 400
 		if ( is_user_logged_in() && current_user_can( $action, $postid ) ) {
393 401
 			// check against post types:
Please login to merge, or discard this patch.