Completed
Push — master ( 219f22...ca2b8c )
by
unknown
02:26
created
public/includes/helpers.php 1 patch
Spacing   +72 added lines, -72 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
 	}
207 207
 
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
  *	@since 0.9.3
216 216
  *	@return array all categoiries
217 217
 */
218
-function lasso_get_objects( $taxonomy = 'category' ) {
218
+function lasso_get_objects($taxonomy = 'category') {
219 219
 
220 220
 	$objects = 'category' == $taxonomy ? get_categories(array('hide_empty' => 0)) : get_tags(array('hide_empty' => 0));
221 221
 
222
-	if ( empty( $objects) )
222
+	if (empty($objects))
223 223
 		return;
224 224
 
225 225
 	$out = array();
226
-	foreach( $objects as $object ) {
226
+	foreach ($objects as $object) {
227 227
 		$out[] = $object->slug;
228 228
 	}
229 229
 
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
  * @since 0.9.4
239 239
  */
240 240
 function lasso_post_types_names() {
241
-	$post_types = get_post_types( array(
241
+	$post_types = get_post_types(array(
242 242
 		'public' => true,
243
-	), 'objects' );
244
-	$post_types = array_combine( array_keys( $post_types ), wp_list_pluck( $post_types, 'label' ) );
245
-    unset( $post_types[ 'attachment' ] );
243
+	), 'objects');
244
+	$post_types = array_combine(array_keys($post_types), wp_list_pluck($post_types, 'label'));
245
+    unset($post_types['attachment']);
246 246
 
247 247
 	/**
248 248
 	 * Set which post types are allowed
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param array $allowed_post_types Array of names (not labels) of allowed post types. Must be registered.
253 253
 	 */
254
-	$allowed_post_types = apply_filters( 'lasso_allowed_post_types', array( 'post', 'page') );
255
-	foreach( $post_types as $name => $label ) {
256
-		if ( ! in_array( $name, $allowed_post_types ) ) {
257
-			unset( $post_types[ $name ] );
254
+	$allowed_post_types = apply_filters('lasso_allowed_post_types', array('post', 'page'));
255
+	foreach ($post_types as $name => $label) {
256
+		if (!in_array($name, $allowed_post_types)) {
257
+			unset($post_types[$name]);
258 258
 		}
259 259
 	}
260 260
 	return $post_types;
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 
263 263
 
264 264
 function lasso_post_types() {
265
-	$post_types = get_post_types( array(
265
+	$post_types = get_post_types(array(
266 266
 		'public' => true,
267
-	), 'names' );
267
+	), 'names');
268 268
 	//$post_types = array_combine( array_keys( $post_types ), wp_list_pluck( $post_types, 'label' ) );
269
-    unset( $post_types[ 'attachment' ] );
269
+    unset($post_types['attachment']);
270 270
 
271 271
 	/**
272 272
 	 * Set which post types are allowed
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param array $allowed_post_types Array of names (not labels) of allowed post types. Must be registered.
277 277
 	 */
278
-	$allowed_post_types = apply_filters( 'lasso_allowed_post_types', array( 'post', 'page') );
279
-	foreach( $post_types as $name => $label ) {
280
-		if ( ! in_array( $name, $allowed_post_types ) ) {
281
-			unset( $post_types[ $name ] );
278
+	$allowed_post_types = apply_filters('lasso_allowed_post_types', array('post', 'page'));
279
+	foreach ($post_types as $name => $label) {
280
+		if (!in_array($name, $allowed_post_types)) {
281
+			unset($post_types[$name]);
282 282
 		}
283 283
 	}
284 284
 	return $post_types;
@@ -297,22 +297,22 @@  discard block
 block discarded – undo
297 297
 *	@uses lasso_modal_addons()
298 298
 *	@since 0.9.4
299 299
 */
300
-function lasso_modal_addons_content( $tab = '', $type ){
300
+function lasso_modal_addons_content($tab = '', $type) {
301 301
 
302
-	$name = lasso_clean_string( $tab['name'] );
302
+	$name = lasso_clean_string($tab['name']);
303 303
 
304
-	if ( 'tab' == $type ) {
304
+	if ('tab' == $type) {
305 305
 
306
-		$out = sprintf( '<li data-addon-name="%s">%s</li>', $name, $tab['name'] );
306
+		$out = sprintf('<li data-addon-name="%s">%s</li>', $name, $tab['name']);
307 307
 
308
-	} else if ( 'content' == $type ){
308
+	} else if ('content' == $type) {
309 309
 
310
-		$content = isset( $tab['content'] ) && is_callable( $tab['content'] ) ? call_user_func( $tab['content'] ) : false;
311
-		$options = isset( $tab['options'] ) && is_callable( $tab['options'] ) ? call_user_func( $tab['options'] ) : false;
310
+		$content = isset($tab['content']) && is_callable($tab['content']) ? call_user_func($tab['content']) : false;
311
+		$options = isset($tab['options']) && is_callable($tab['options']) ? call_user_func($tab['options']) : false;
312 312
 
313
-		$out = sprintf( '<div class="lasso--modal__content not-visible" data-addon-content="%s">
313
+		$out = sprintf('<div class="lasso--modal__content not-visible" data-addon-content="%s">
314 314
 			%s%s
315
-			</div>', $name, $content, lasso_option_form( $name, $options ) );
315
+			</div>', $name, $content, lasso_option_form($name, $options));
316 316
 
317 317
 	}
318 318
 
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 *
328 328
 * @return void|string
329 329
 */
330
-function lasso_clean_string( $string = '' ) {
330
+function lasso_clean_string($string = '') {
331 331
 
332
-	if ( empty( $string ) )
332
+	if (empty($string))
333 333
 		return;
334 334
 
335
-	return sanitize_text_field( strtolower( preg_replace('/[\s_]/', '-', $string ) ) );
335
+	return sanitize_text_field(strtolower(preg_replace('/[\s_]/', '-', $string)));
336 336
 }
337 337
 
338 338
 /**
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
  *
346 346
  * @return void|string
347 347
  */
348
-function lasso_unclean_string( $string = '' ) {
348
+function lasso_unclean_string($string = '') {
349 349
 
350
-	if ( empty( $string ) ) {
350
+	if (empty($string)) {
351 351
 		return;
352 352
 	}
353 353
 
354
-	return sanitize_text_field( strtolower( str_replace( '-', '_', $string ) ) );
354
+	return sanitize_text_field(strtolower(str_replace('-', '_', $string)));
355 355
 }
356 356
 
357 357
 
@@ -366,22 +366,22 @@  discard block
 block discarded – undo
366 366
  * @param unknown $postid int the id of the post object to check against
367 367
  * @since 0.9.9.7 added filter 'lasso_user_can_filter'
368 368
  */
369
-if ( !function_exists( 'lasso_user_can' ) ):
370
-	function lasso_user_can( $action = '', $postid = 0 ) {
369
+if (!function_exists('lasso_user_can')):
370
+	function lasso_user_can($action = '', $postid = 0) {
371 371
         $result = false;
372
-		if ( empty( $action ) )
372
+		if (empty($action))
373 373
 			$action = 'edit_posts';
374 374
 
375
-		if ( empty( $postid ) )
375
+		if (empty($postid))
376 376
 			$postid = get_the_ID();
377 377
 
378
-		if ( is_user_logged_in() && current_user_can( $action, $postid ) ) {
379
-			$result =  true;
378
+		if (is_user_logged_in() && current_user_can($action, $postid)) {
379
+			$result = true;
380 380
 		} else {
381 381
 			$result = false;
382 382
 		}
383 383
 		
384
-		return apply_filters( 'lasso_user_can_filter', $result,  $action, $postid);
384
+		return apply_filters('lasso_user_can_filter', $result, $action, $postid);
385 385
 	}
386 386
 endif;
387 387
 
@@ -390,25 +390,25 @@  discard block
 block discarded – undo
390 390
 *
391 391
 *	@since 0.9.5
392 392
 */
393
-if ( !function_exists('lasso_editor_empty_results') ):
393
+if (!function_exists('lasso_editor_empty_results')):
394 394
 
395
-	function lasso_editor_empty_results( $type = 'posts' ){
395
+	function lasso_editor_empty_results($type = 'posts') {
396 396
 
397
-		if ( 'posts' == $type ) {
397
+		if ('posts' == $type) {
398 398
 
399
-			$string = apply_filters('lasso_empty_state_message', __('No posts to show', 'lasso') );
399
+			$string = apply_filters('lasso_empty_state_message', __('No posts to show', 'lasso'));
400 400
 			$icon = 'lasso-icon-file-text2';
401 401
 			$button = false;
402 402
 
403
-		} elseif ( 'revision' == $type ) {
403
+		} elseif ('revision' == $type) {
404 404
 
405
-			$string = apply_filters('lasso_empty_state_message', __('No revisions found', 'lasso') );
405
+			$string = apply_filters('lasso_empty_state_message', __('No revisions found', 'lasso'));
406 406
 			$icon = 'lasso-icon-history';
407
-			$button = sprintf('<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">%s</a>', __('Close','lasso') );
407
+			$button = sprintf('<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">%s</a>', __('Close', 'lasso'));
408 408
 
409 409
 		}
410 410
 
411
-		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 );
411
+		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);
412 412
 	}
413 413
 
414 414
 endif;
Please login to merge, or discard this patch.