Completed
Push — master ( 3737f0...b3eac7 )
by
unknown
43s
created
public/includes/lasso.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		
60 60
 		add_action( 'wp_ajax_get_aesop_component',     array( $this, 'get_aesop_component' ) );
61 61
 		add_action( 'wp_ajax_editus_do_shortcode',     array( $this, 'editus_do_shortcode' ) );
62
-        add_action( 'wp_ajax_editus_do_block',     array( $this, 'editus_do_block' ) );
62
+		add_action( 'wp_ajax_editus_do_block',     array( $this, 'editus_do_block' ) );
63 63
 		add_action( 'wp_ajax_editus_lock_post',     array( $this, 'editus_lock_post' ) );
64 64
 		add_action( 'wp_ajax_editus_unlock_post',     array( $this, 'editus_unlock_post' ) );
65 65
 		add_action( 'wp_ajax_editus_hide_tour',     array( $this, 'editus_hide_tour' ) );
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 		add_action( 'wp_ajax_editus_featured_img',     array( $this, 'set_featured_img' ) );
70 70
 		add_action( 'wp_ajax_editus_del_featured_img',     array( $this, 'del_featured_img' ) );
71 71
         
72
-        add_action( 'wp_ajax_editus_publish_post',     array( $this, 'on_publish_post' ) );
72
+		add_action( 'wp_ajax_editus_publish_post',     array( $this, 'on_publish_post' ) );
73 73
         
74
-        add_action( 'wp_ajax_editus_create_gallery',     array( $this, 'create_gallery' ) );
75
-        add_action( 'wp_ajax_editus_update_gallery',     array( $this, 'update_gallery' ) );
74
+		add_action( 'wp_ajax_editus_create_gallery',     array( $this, 'create_gallery' ) );
75
+		add_action( 'wp_ajax_editus_update_gallery',     array( $this, 'update_gallery' ) );
76 76
 
77 77
 		// enable saving custom fields through REST API
78 78
 		self::enable_metasave('post');
79 79
 		self::enable_metasave('page');
80 80
         
81
-        $default_post_types = apply_filters( 'lasso_allowed_post_types', array( 'post', 'page'));
81
+		$default_post_types = apply_filters( 'lasso_allowed_post_types', array( 'post', 'page'));
82 82
 		$allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor',  $default_post_types);
83
-        foreach ( $allowed_post_types  as $post_type ) {
84
-           self::enable_metasave($post_type);
83
+		foreach ( $allowed_post_types  as $post_type ) {
84
+		   self::enable_metasave($post_type);
85 85
 		}
86 86
 		//enqueue assets
87 87
 		new assets();
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
 		$out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' );
279 279
 	}
280 280
 	
281
-    // new ajax function to lock post for editing
281
+	// new ajax function to lock post for editing
282 282
 	public function editus_lock_post()
283 283
 	{
284 284
 		$post_id= $_POST["postid"];
285 285
 		$locked = wp_check_post_lock($post_id);
286 286
 		
287 287
 		if (!$locked) {
288
-		    wp_set_post_lock($post_id);
288
+			wp_set_post_lock($post_id);
289 289
 			echo "true";
290 290
 		} else {
291 291
 			$user_info = get_userdata($locked);
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 	{
299 299
 		$post_id= $_POST["postid"];
300 300
 		$locked = wp_check_post_lock($post_id);
301
-        if (!$locked) {
302
-            delete_post_meta( $post_id, '_edit_lock');
303
-        }
301
+		if (!$locked) {
302
+			delete_post_meta( $post_id, '_edit_lock');
303
+		}
304 304
 		echo "true";
305 305
 		
306 306
 		exit;
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 		$status = isset( $data['status'] ) ? $data['status'] : false;
329 329
 		$postid = isset( $data['postid'] ) ? $data['postid'] : false;
330 330
 		$slug   = isset( $data['story_slug'] ) ? $data['story_slug'] : false;
331
-        $excerpt   = isset( $data['excerpt'] ) ? $data['excerpt'] : false;
331
+		$excerpt   = isset( $data['excerpt'] ) ? $data['excerpt'] : false;
332 332
 	
333 333
 
334 334
 		$args = array(
335 335
 			'ID'   			=> (int) $postid,
336 336
 			'post_name'  	=> $slug,
337 337
 			'post_status' 	=> $status,
338
-            'post_excerpt'  => wp_strip_all_tags($excerpt,true)
338
+			'post_excerpt'  => wp_strip_all_tags($excerpt,true)
339 339
 		);
340 340
 		
341 341
 		
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 		exit;
411 411
 	}
412 412
     
413
-    public function editus_do_block()
413
+	public function editus_do_block()
414 414
 	{
415 415
 		
416 416
 		$code= $_POST["code"];
417 417
 
418
-        $out = do_blocks( $code );
418
+		$out = do_blocks( $code );
419 419
 		
420 420
 		echo $out;
421 421
 		exit;
@@ -434,67 +434,67 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 		}
436 436
 		if ($code == "aesop_video") {
437
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
438
-		    echo aesop_video_shortcode($atts);
437
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
438
+			echo aesop_video_shortcode($atts);
439 439
 		}
440 440
 		else if ($code == "aesop_image") {
441
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
442
-		    echo aesop_image_shortcode($atts);
441
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
442
+			echo aesop_image_shortcode($atts);
443 443
 		}
444 444
 		else if ($code == "aesop_quote") {
445
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
446
-		    echo aesop_quote_shortcode($atts);
445
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
446
+			echo aesop_quote_shortcode($atts);
447 447
 		}
448 448
 		else if ($code == "aesop_parallax") {
449
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
450
-		    echo aesop_parallax_shortcode($atts);
449
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
450
+			echo aesop_parallax_shortcode($atts);
451 451
 		}
452 452
 		else if ($code == "aesop_character") {
453
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
454
-		    echo aesop_character_shortcode($atts);
453
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
454
+			echo aesop_character_shortcode($atts);
455 455
 		}
456 456
 		else if ($code == "aesop_collection") {
457
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
458
-		    echo aesop_collection_shortcode($atts);
457
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
458
+			echo aesop_collection_shortcode($atts);
459 459
 		}
460 460
 		else if ($code == "aesop_chapter") {
461
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
462
-		    echo aesop_chapter_shortcode($atts);
461
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
462
+			echo aesop_chapter_shortcode($atts);
463 463
 		}
464 464
 		else if ($code == "aesop_content") {
465
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
466
-		    echo aesop_content_shortcode($atts, $atts['content_data']);
465
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
466
+			echo aesop_content_shortcode($atts, $atts['content_data']);
467 467
 		}
468 468
 		else if ($code == "aesop_gallery") {
469
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
470
-		    echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]');
469
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
470
+			echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]');
471 471
 		}
472 472
 		else if ($code == "aesop_audio") {
473
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
474
-		    echo aesop_audio_shortcode($atts);
473
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
474
+			echo aesop_audio_shortcode($atts);
475 475
 		}
476 476
 		else if ($code == "aesop_document") {
477
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-document.php');
478
-		    echo aesop_document_shortcode($atts);
477
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-document.php');
478
+			echo aesop_document_shortcode($atts);
479 479
 		}
480 480
 		else if ($code == "aesop_timeline_stop") {		
481
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-timeline.php');
482
-		    echo aesop_timeline_stop_shortcode($atts);
481
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-timeline.php');
482
+			echo aesop_timeline_stop_shortcode($atts);
483 483
 		}
484
-        /*else if ($code == "aesop_content") {
484
+		/*else if ($code == "aesop_content") {
485 485
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-content.php');
486 486
 		    echo aesop_content_shortcode($atts);
487 487
 		}*/
488
-        else if ($code == "aesop_wpimg") {
489
-            self::wpimg($atts);
488
+		else if ($code == "aesop_wpimg") {
489
+			self::wpimg($atts);
490 490
 		}
491 491
 		else if ($code == "aesop_wpimg-block") {
492
-            self::wpimg_block($atts);
492
+			self::wpimg_block($atts);
493 493
 		}
494 494
 		else {
495 495
 			$code = '['.$code.' ';
496 496
 			foreach ($atts as $key => $value) {
497
-			    $code = ''.$key.'="'.$value.'" ';
497
+				$code = ''.$key.'="'.$value.'" ';
498 498
 			}
499 499
 			$code = $code.']';
500 500
 			echo do_shortcode($code);
@@ -503,95 +503,95 @@  discard block
 block discarded – undo
503 503
 		exit; 
504 504
 	}
505 505
     
506
-    public static function wpimg($atts) {
506
+	public static function wpimg($atts) {
507 507
 
508
-        echo '<figure data-component-type="wpimg"';
508
+		echo '<figure data-component-type="wpimg"';
509 509
         
510
-        $extra = "";
510
+		$extra = "";
511 511
         
512
-        // try to use srcset and sizes on new WP installs
512
+		// try to use srcset and sizes on new WP installs
513 513
 		if ( function_exists('wp_get_attachment_image_srcset') && $attachment_id = attachment_url_to_postid( $atts['img'] ) ) {
514 514
 			$srcset = wp_get_attachment_image_srcset( $attachment_id, 'full' );
515 515
 			$sizes = wp_get_attachment_image_sizes( $attachment_id, 'full' );
516
-            $extra = "srcset='$srcset' sizes='$sizes' ";
517
-        }
518
-        if ($atts['align']=="left") {
519
-            $extra .= 'class="alignleft';
520
-        } else if ($atts['align']=="right") {
521
-            $extra .= 'class="alignright';
522
-        } else {
523
-            $extra .= 'class="aligncenter';
524
-        }
525
-        if ($atts['imgwidth'] || $atts['imgheight']) {
526
-            if ($atts['imgwidth']) {
527
-                $extra .= 'width:'. $atts['imgwidth'].';';
528
-            }
529
-            if ($atts['imgheight']) {
530
-                $extra .= 'height:'. $atts['imgheight'].';';
531
-            }
516
+			$extra = "srcset='$srcset' sizes='$sizes' ";
517
+		}
518
+		if ($atts['align']=="left") {
519
+			$extra .= 'class="alignleft';
520
+		} else if ($atts['align']=="right") {
521
+			$extra .= 'class="alignright';
522
+		} else {
523
+			$extra .= 'class="aligncenter';
524
+		}
525
+		if ($atts['imgwidth'] || $atts['imgheight']) {
526
+			if ($atts['imgwidth']) {
527
+				$extra .= 'width:'. $atts['imgwidth'].';';
528
+			}
529
+			if ($atts['imgheight']) {
530
+				$extra .= 'height:'. $atts['imgheight'].';';
531
+			}
532 532
             
533
-        }
534
-        $extra .= '"';
533
+		}
534
+		$extra .= '"';
535 535
         
536
-        foreach ($atts as $key => $value) {
536
+		foreach ($atts as $key => $value) {
537 537
 			 echo ' data-'.$key.'="'.$value.'"';
538 538
 		}
539
-        //echo ' class="wp-image- lasso--wpimg__wrap lasso-component">';
540
-        echo ' class="wp-caption lasso-component">';
541
-        $hrefset = false;
542
-        if ($atts['link'] != '' && (!isset($atts['linkoption']) || $atts['linkoption']=="url" ))
543
-        {
544
-            echo '<a href="' . $atts['link'] . '">';
545
-            $hrefset = true;
546
-        } else if (isset($atts['linkoption']) && $atts['linkoption'] == 'img' ) {
547
-            echo '<a href="' . $atts['img'] . '">';
548
-            $hrefset = true;
549
-        }
550
-        echo '<img src="' . $atts['img'] . '" alt="'. $atts['alt']  .  '" '. $extra. '>';
551
-        if ($hrefset)
552
-        {
553
-            echo '</a>';
554
-        }
555
-        if ($atts['caption'])
556
-        {
557
-            echo '<figcaption class="wp-caption-text">'.$atts['caption'].'</figcaption>';
558
-        }
559
-        echo '</figure>';
560
-        echo '<p><br></p>';
561
-        return;
562
-    }
539
+		//echo ' class="wp-image- lasso--wpimg__wrap lasso-component">';
540
+		echo ' class="wp-caption lasso-component">';
541
+		$hrefset = false;
542
+		if ($atts['link'] != '' && (!isset($atts['linkoption']) || $atts['linkoption']=="url" ))
543
+		{
544
+			echo '<a href="' . $atts['link'] . '">';
545
+			$hrefset = true;
546
+		} else if (isset($atts['linkoption']) && $atts['linkoption'] == 'img' ) {
547
+			echo '<a href="' . $atts['img'] . '">';
548
+			$hrefset = true;
549
+		}
550
+		echo '<img src="' . $atts['img'] . '" alt="'. $atts['alt']  .  '" '. $extra. '>';
551
+		if ($hrefset)
552
+		{
553
+			echo '</a>';
554
+		}
555
+		if ($atts['caption'])
556
+		{
557
+			echo '<figcaption class="wp-caption-text">'.$atts['caption'].'</figcaption>';
558
+		}
559
+		echo '</figure>';
560
+		echo '<p><br></p>';
561
+		return;
562
+	}
563 563
 	
564 564
 	public static function wpimg_block($atts) {
565 565
 		$imgextra = '';
566 566
 		if (!empty($atts['id'])) {
567 567
 			$imgextra = 'class="wp-image-'.$atts['id'].'"';
568 568
 		}
569
-        $figclass = 'aligncenter';
570
-        if ($atts['align']=="left") {
571
-            $figclass = 'alignleft';
572
-        } else if ($atts['align']=="right") {
573
-            $figclass = 'alignright';
574
-        } else {
575
-            $figclass = 'aligncenter';
576
-        }
569
+		$figclass = 'aligncenter';
570
+		if ($atts['align']=="left") {
571
+			$figclass = 'alignleft';
572
+		} else if ($atts['align']=="right") {
573
+			$figclass = 'alignright';
574
+		} else {
575
+			$figclass = 'aligncenter';
576
+		}
577 577
         
578
-        echo '<div class="wp-block-image" data-component-type="wpimg-block">'; 
579
-        echo '<figure class="wp-block-image '.$figclass.' size-large" contenteditable="false">';   
580
-        if (!empty($atts['link'])) {
581
-            echo '<a href="'.$atts['link'].'">';
582
-        }        
583
-        echo '<img src="' . $atts['img'] . '" alt="'. $atts['alt']  . '"' . $imgextra . ' >';
584
-        if ($atts['caption'])
585
-        {
586
-            echo '<figcaption>'.$atts['caption'].'</figcaption>';
587
-        }
588
-        if (!empty($atts['link'])) {
589
-            echo '</a>';
590
-        }
591
-        echo '</figure></div>';
592
-        echo '<p><br></p>';
593
-        return;
594
-    }
578
+		echo '<div class="wp-block-image" data-component-type="wpimg-block">'; 
579
+		echo '<figure class="wp-block-image '.$figclass.' size-large" contenteditable="false">';   
580
+		if (!empty($atts['link'])) {
581
+			echo '<a href="'.$atts['link'].'">';
582
+		}        
583
+		echo '<img src="' . $atts['img'] . '" alt="'. $atts['alt']  . '"' . $imgextra . ' >';
584
+		if ($atts['caption'])
585
+		{
586
+			echo '<figcaption>'.$atts['caption'].'</figcaption>';
587
+		}
588
+		if (!empty($atts['link'])) {
589
+			echo '</a>';
590
+		}
591
+		echo '</figure></div>';
592
+		echo '<p><br></p>';
593
+		return;
594
+	}
595 595
 	
596 596
 	
597 597
 	public function get_ase_options()
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
 		exit;
628 628
 	}
629 629
     
630
-    /* This function doesn't actually publish post, but should be called when a post is published */
631
-    public function on_publish_post( ) {
630
+	/* This function doesn't actually publish post, but should be called when a post is published */
631
+	public function on_publish_post( ) {
632 632
 
633 633
 		$post_id = isset( $_POST['postid'] ) ? $_POST['postid'] : false;
634 634
         
635
-        do_action( 'transition_post_status', 'publish', 'draft', get_post( $post_id ) );
635
+		do_action( 'transition_post_status', 'publish', 'draft', get_post( $post_id ) );
636 636
 
637 637
 		exit;
638 638
 	}
@@ -690,14 +690,14 @@  discard block
 block discarded – undo
690 690
 			$allow_new_category = lasso_editor_get_option( 'allow_new_category', 'lasso_editor' );
691 691
 			
692 692
 			if ($taxonomy =='category') {
693
-                // convert from names to category ids
693
+				// convert from names to category ids
694 694
 				$cats = array();
695 695
 				foreach ($value as $cat) {
696 696
 					$cat_id = get_cat_ID($cat);
697 697
 					if ($cat_id !=0) {
698 698
 						$cats [] = $cat_id;
699 699
 					} else if ($allow_new_category) {
700
-					    $cats [] = wp_create_category($cat);
700
+						$cats [] = wp_create_category($cat);
701 701
 					}
702 702
 				}
703 703
 				$value = $cats;
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 		}
718 718
 	}
719 719
     
720
-    public function create_gallery( ) {
720
+	public function create_gallery( ) {
721 721
 
722 722
 		$postid  	= isset( $_POST['postid'] ) ? $_POST['postid'] : false;
723 723
         
@@ -771,10 +771,10 @@  discard block
 block discarded – undo
771 771
 			'message' => 'gallery-created',
772 772
 			'id' => $postid)
773 773
 		);
774
-        exit;
774
+		exit;
775 775
 	}
776 776
     
777
-    public function update_gallery( ) {
777
+	public function update_gallery( ) {
778 778
         
779 779
 		$options      = isset( $_POST['fields'] ) ? $_POST['fields'] : false;
780 780
         
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
 
791 791
 		self::save_gallery_options( $postid, $gallery_ids, $options, $type );
792 792
 
793
-        echo json_encode( array('message' => 'gallery-updated') );
793
+		echo json_encode( array('message' => 'gallery-updated') );
794 794
 
795
-        exit;
795
+		exit;
796 796
 	}
797 797
     
798
-    public function save_gallery_options( $postid, $gallery_ids, $options, $type = false ) {
798
+	public function save_gallery_options( $postid, $gallery_ids, $options, $type = false ) {
799 799
 
800 800
 		// gallery width
801 801
 		$gallery_width = isset( $options['width'] ) ? $options['width'] : false;
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 	public function set_date( $postid, $value) {
880 880
 		if( $value ) {
881 881
 			$value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time( 'timestamp', 1 ));
882
-            wp_update_post(
882
+			wp_update_post(
883 883
 				array (
884 884
 					'ID'            => $postid, // ID of the post to update
885 885
 					'post_date'     => date( 'Y-m-d H:i:s',  strtotime($value) ),
Please login to merge, or discard this patch.