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