Completed
Push — master ( c34fb4...51d4c2 )
by
unknown
01:31
created
lasso.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 // If this file is called directly, abort.
21
-if ( ! defined( 'WPINC' ) ) {
21
+if (!defined('WPINC')) {
22 22
 	die;
23 23
 }
24 24
 
25 25
 // Set some constants
26
-define( 'LASSO_VERSION', '1.1.9' );
27
-define( 'LASSO_DIR', plugin_dir_path( __FILE__ ) );
28
-define( 'LASSO_URL', plugins_url( '', __FILE__ ) );
29
-define( 'LASSO_FILE', __FILE__ );
26
+define('LASSO_VERSION', '1.1.9');
27
+define('LASSO_DIR', plugin_dir_path(__FILE__));
28
+define('LASSO_URL', plugins_url('', __FILE__));
29
+define('LASSO_FILE', __FILE__);
30 30
 
31 31
 /**
32 32
  * Load plugin if PHP version is 5.4 or later.
33 33
  */
34
-if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
34
+if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
35 35
 
36
-	include_once( LASSO_DIR . '/bootstrap.php' );
36
+	include_once(LASSO_DIR.'/bootstrap.php');
37 37
 
38 38
 } else {
39 39
 
40 40
 	add_action('admin_head', 'lasso_fail_notice');
41
-	function lasso_fail_notice(){
41
+	function lasso_fail_notice() {
42 42
 
43 43
 		printf('<div class="error"><p>Editus requires PHP 5.4 or higher.</p></div>');
44 44
 
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 add_filter('register_post_type_args', 'lasso_show_in_rest', 10, 2);
49
-function lasso_show_in_rest($args, $post_type){
49
+function lasso_show_in_rest($args, $post_type) {
50 50
  
51
-    $allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( ) );
52
-	$allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types );
53
-	if (in_array( $post_type,$allowed_post_types)) {
51
+    $allowed_post_types = lasso_editor_get_option('allowed_post_types', 'lasso_editor', array( ));
52
+	$allowed_post_types = apply_filters('lasso_allowed_post_types', $allowed_post_types);
53
+	if (in_array($post_type, $allowed_post_types)) {
54 54
 		$args['show_in_rest'] = true;
55 55
 		if ($post_type != 'post' && $post_type != 'page') {
56 56
 			$args['rest_base'] = $post_type;
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 
64
-function lasso_editor_get_option( $option, $section, $default = '' ) {
64
+function lasso_editor_get_option($option, $section, $default = '') {
65 65
 
66
-	if ( empty( $option ) )
66
+	if (empty($option))
67 67
 		return;
68 68
 
69
-	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
69
+	if (function_exists('is_multisite') && is_multisite()) {
70 70
 
71
-		$options = get_site_option( $section );
71
+		$options = get_site_option($section);
72 72
 
73 73
 	} else {
74 74
 
75
-		$options = get_option( $section );
75
+		$options = get_option($section);
76 76
 	}
77 77
 
78
-	if ( isset( $options[$option] ) ) {
78
+	if (isset($options[$option])) {
79 79
 		return $options[$option];
80 80
 	}
81 81
 
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 ));
89 89
 
90 90
 // Gutenberg
91
-if( function_exists( 'is_gutenberg_page' ) ) {
92
-	function add_raw_to_post( $response, $post, $request ) {
91
+if (function_exists('is_gutenberg_page')) {
92
+	function add_raw_to_post($response, $post, $request) {
93 93
 		$response_data = $response->get_data();
94
-		if ( is_array( $response_data['content'] )) {
95
-			$response_data['content']['raw'] =  $post->post_content ;
96
-			$response->set_data( $response_data );
94
+		if (is_array($response_data['content'])) {
95
+			$response_data['content']['raw'] = $post->post_content;
96
+			$response->set_data($response_data);
97 97
 		}
98 98
 
99 99
 		return $response;
100 100
 	}
101
-	add_filter( "rest_prepare_post", 'add_raw_to_post', 10, 3 );
101
+	add_filter("rest_prepare_post", 'add_raw_to_post', 10, 3);
102 102
 }
103 103
 
Please login to merge, or discard this patch.
public/includes/lasso.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		add_action( 'wp_ajax_editus_featured_img',     array( $this, 'set_featured_img' ) );
69 69
 		add_action( 'wp_ajax_editus_del_featured_img',     array( $this, 'del_featured_img' ) );
70 70
         
71
-        add_action( 'wp_ajax_editus_publish_post',     array( $this, 'publish_post' ) );
71
+		add_action( 'wp_ajax_editus_publish_post',     array( $this, 'publish_post' ) );
72 72
 
73 73
 		// enable saving custom fields through REST API
74 74
 		self::enable_metasave('post');
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
 		$out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' );
269 269
 	}
270 270
 	
271
-    // new ajax function to lock post for editing
271
+	// new ajax function to lock post for editing
272 272
 	public function editus_lock_post()
273 273
 	{
274 274
 		$post_id= $_POST["postid"];
275 275
 		$locked = wp_check_post_lock($post_id);
276 276
 		
277 277
 		if (!$locked) {
278
-		    wp_set_post_lock($post_id);
278
+			wp_set_post_lock($post_id);
279 279
 			echo "true";
280 280
 		} else {
281 281
 			$user_info = get_userdata($locked);
@@ -400,59 +400,59 @@  discard block
 block discarded – undo
400 400
 		 );
401 401
 		foreach ($_POST as $key => $value) {
402 402
 			if ($key !="code" && $key !="action") {
403
-			    //$shortcode = $shortcode.$key.'="'.$value.'" ';
403
+				//$shortcode = $shortcode.$key.'="'.$value.'" ';
404 404
 				$atts[$key] = $value;
405 405
 			}
406 406
 		}
407 407
 		if ($code == "aesop_video") {
408
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
409
-		    echo aesop_video_shortcode($atts);
408
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
409
+			echo aesop_video_shortcode($atts);
410 410
 		}
411 411
 		else if ($code == "aesop_image") {
412
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
413
-		    echo aesop_image_shortcode($atts);
412
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
413
+			echo aesop_image_shortcode($atts);
414 414
 		}
415 415
 		else if ($code == "aesop_quote") {
416
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
417
-		    echo aesop_quote_shortcode($atts);
416
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
417
+			echo aesop_quote_shortcode($atts);
418 418
 		}
419 419
 		else if ($code == "aesop_parallax") {
420
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
421
-		    echo aesop_parallax_shortcode($atts);
420
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
421
+			echo aesop_parallax_shortcode($atts);
422 422
 		}
423 423
 		else if ($code == "aesop_character") {
424
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
425
-		    echo aesop_character_shortcode($atts);
424
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
425
+			echo aesop_character_shortcode($atts);
426 426
 		}
427 427
 		else if ($code == "aesop_collection") {
428
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
429
-		    echo aesop_collection_shortcode($atts);
428
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
429
+			echo aesop_collection_shortcode($atts);
430 430
 		}
431 431
 		else if ($code == "aesop_chapter") {
432
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
433
-		    echo aesop_chapter_shortcode($atts);
432
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
433
+			echo aesop_chapter_shortcode($atts);
434 434
 		}
435 435
 		else if ($code == "aesop_content") {
436
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
437
-		    echo aesop_content_shortcode($atts, $atts['content_data']);
436
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
437
+			echo aesop_content_shortcode($atts, $atts['content_data']);
438 438
 		}
439 439
 		else if ($code == "aesop_gallery") {
440
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
441
-		    echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]');
440
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
441
+			echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]');
442 442
 		}
443 443
 		else if ($code == "aesop_audio") {
444
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
445
-		    echo aesop_audio_shortcode($atts);
444
+			require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
445
+			echo aesop_audio_shortcode($atts);
446 446
 		}
447 447
 		else {
448 448
 			$code = '['.$code.' ';
449 449
 			foreach ($atts as $key => $value) {
450
-			    $code = ''.$key.'="'.$value.'" ';
450
+				$code = ''.$key.'="'.$value.'" ';
451 451
 			}
452 452
 			$code = $code.']';
453 453
 			echo do_shortcode($code);
454
-		    //require_once( ABSPATH . '/wp-content/plugins/aesop-events/public/includes/shortcode.php');
455
-		    //echo aesop_audio_shortcode($atts);
454
+			//require_once( ABSPATH . '/wp-content/plugins/aesop-events/public/includes/shortcode.php');
455
+			//echo aesop_audio_shortcode($atts);
456 456
 		}
457 457
 		
458 458
 		exit; 
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
 		exit;
493 493
 	}
494 494
     
495
-    /* This function doesn't actually publish post, but should be called when a post is published */
496
-    public function publish_post( ) {
495
+	/* This function doesn't actually publish post, but should be called when a post is published */
496
+	public function publish_post( ) {
497 497
 
498 498
 		$post_id = isset( $_POST['postid'] ) ? $_POST['postid'] : false;
499 499
         
500
-        do_action( 'transition_post_status', 'publish', 'draft', get_post( $post_id ) );
500
+		do_action( 'transition_post_status', 'publish', 'draft', get_post( $post_id ) );
501 501
 
502 502
 		exit;
503 503
 	}
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 			$allow_new_category = lasso_editor_get_option( 'allow_new_category', 'lasso_editor' );
556 556
 			
557 557
 			if ($taxonomy =='category') {
558
-                // convert from names to category ids
558
+				// convert from names to category ids
559 559
 				$cats = array();
560 560
 				foreach ($value as $cat) {
561 561
 					$cat_id = get_cat_ID($cat);
562 562
 					if ($cat_id !=0) {
563 563
 						$cats [] = $cat_id;
564 564
 					} else if ($allow_new_category) {
565
-					    $cats [] = wp_create_category($cat);
565
+						$cats [] = wp_create_category($cat);
566 566
 					}
567 567
 				}
568 568
 				$value = $cats;
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	public function set_date( $postid, $value) {
605 605
 		if( $value ) {
606 606
 			$value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time( 'timestamp', 1 ));
607
-            wp_update_post(
607
+			wp_update_post(
608 608
 				array (
609 609
 					'ID'            => $postid, // ID of the post to update
610 610
 					'post_date'     => date( 'Y-m-d H:i:s',  strtotime($value) ),
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 		require_once LASSO_DIR.'/public/includes/wrap-shortcodes.php';
53 53
 
54 54
 		// Activate plugin when new blog is added
55
-		add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
55
+		add_action('wpmu_new_blog', array($this, 'activate_new_site'));
56 56
 
57 57
 		// Load plugin text domain
58
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
58
+		add_action('init', array($this, 'load_plugin_textdomain'));
59 59
 		
60
-		add_action( 'wp_ajax_get_aesop_component',     array( $this, 'get_aesop_component' ) );
61
-		add_action( 'wp_ajax_editus_do_shortcode',     array( $this, 'editus_do_shortcode' ) );
62
-		add_action( 'wp_ajax_editus_lock_post',     array( $this, 'editus_lock_post' ) );
63
-		add_action( 'wp_ajax_editus_unlock_post',     array( $this, 'editus_unlock_post' ) );
64
-		add_action( 'wp_ajax_editus_hide_tour',     array( $this, 'editus_hide_tour' ) );
65
-		add_action( 'wp_ajax_editus_set_post_setting',     array( $this, 'editus_set_post_setting' ) );
66
-		add_action( 'wp_ajax_editus_get_ase_options',     array( $this, 'get_ase_options' ) );
67
-		add_action( 'wp_ajax_editus_delete_post',     array( $this, 'delete_post' ) );
68
-		add_action( 'wp_ajax_editus_featured_img',     array( $this, 'set_featured_img' ) );
69
-		add_action( 'wp_ajax_editus_del_featured_img',     array( $this, 'del_featured_img' ) );
60
+		add_action('wp_ajax_get_aesop_component', array($this, 'get_aesop_component'));
61
+		add_action('wp_ajax_editus_do_shortcode', array($this, 'editus_do_shortcode'));
62
+		add_action('wp_ajax_editus_lock_post', array($this, 'editus_lock_post'));
63
+		add_action('wp_ajax_editus_unlock_post', array($this, 'editus_unlock_post'));
64
+		add_action('wp_ajax_editus_hide_tour', array($this, 'editus_hide_tour'));
65
+		add_action('wp_ajax_editus_set_post_setting', array($this, 'editus_set_post_setting'));
66
+		add_action('wp_ajax_editus_get_ase_options', array($this, 'get_ase_options'));
67
+		add_action('wp_ajax_editus_delete_post', array($this, 'delete_post'));
68
+		add_action('wp_ajax_editus_featured_img', array($this, 'set_featured_img'));
69
+		add_action('wp_ajax_editus_del_featured_img', array($this, 'del_featured_img'));
70 70
         
71
-        add_action( 'wp_ajax_editus_publish_post',     array( $this, 'publish_post' ) );
71
+        add_action('wp_ajax_editus_publish_post', array($this, 'publish_post'));
72 72
 
73 73
 		// enable saving custom fields through REST API
74 74
 		self::enable_metasave('post');
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	public static function get_instance() {
100 100
 
101 101
 		// If the single instance hasn't been set, set it now.
102
-		if ( null == self::$instance ) {
102
+		if (null == self::$instance) {
103 103
 			self::$instance = new self;
104 104
 		}
105 105
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 	 *                                       WPMU is disabled or plugin is
117 117
 	 *                                       activated on an individual blog.
118 118
 	 */
119
-	public static function activate( $network_wide ) {
119
+	public static function activate($network_wide) {
120 120
 
121
-		if ( function_exists( 'is_multisite' ) && is_multisite() ) {
121
+		if (function_exists('is_multisite') && is_multisite()) {
122 122
 
123
-			if ( $network_wide  ) {
123
+			if ($network_wide) {
124 124
 
125 125
 				// Get all blog ids
126 126
 				$blog_ids = self::get_blog_ids();
127 127
 
128
-				foreach ( $blog_ids as $blog_id ) {
128
+				foreach ($blog_ids as $blog_id) {
129 129
 
130
-					switch_to_blog( $blog_id );
130
+					switch_to_blog($blog_id);
131 131
 					self::single_activate();
132 132
 				}
133 133
 
@@ -153,18 +153,18 @@  discard block
 block discarded – undo
153 153
 	 *                                       WPMU is disabled or plugin is
154 154
 	 *                                       deactivated on an individual blog.
155 155
 	 */
156
-	public static function deactivate( $network_wide ) {
156
+	public static function deactivate($network_wide) {
157 157
 
158
-		if ( function_exists( 'is_multisite' ) && is_multisite() ) {
158
+		if (function_exists('is_multisite') && is_multisite()) {
159 159
 
160
-			if ( $network_wide ) {
160
+			if ($network_wide) {
161 161
 
162 162
 				// Get all blog ids
163 163
 				$blog_ids = self::get_blog_ids();
164 164
 
165
-				foreach ( $blog_ids as $blog_id ) {
165
+				foreach ($blog_ids as $blog_id) {
166 166
 
167
-					switch_to_blog( $blog_id );
167
+					switch_to_blog($blog_id);
168 168
 					self::single_deactivate();
169 169
 
170 170
 				}
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param int     $blog_id ID of the new blog.
190 190
 	 */
191
-	public function activate_new_site( $blog_id ) {
191
+	public function activate_new_site($blog_id) {
192 192
 
193
-		if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
193
+		if (1 !== did_action('wpmu_new_blog')) {
194 194
 			return;
195 195
 		}
196 196
 
197
-		switch_to_blog( $blog_id );
197
+		switch_to_blog($blog_id);
198 198
 		self::single_activate();
199 199
 		restore_current_blog();
200 200
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			WHERE archived = '0' AND spam = '0'
220 220
 			AND deleted = '0'";
221 221
 
222
-		return $wpdb->get_col( $sql );
222
+		return $wpdb->get_col($sql);
223 223
 
224 224
 	}
225 225
 
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	private static function single_activate() {
232 232
 
233
-		$curr_version = get_option( 'lasso_version' );
233
+		$curr_version = get_option('lasso_version');
234 234
 
235 235
 		// update upgraded from
236
-		if ( $curr_version ) {
237
-			update_option( 'lasso_updated_from', $curr_version );
236
+		if ($curr_version) {
237
+			update_option('lasso_updated_from', $curr_version);
238 238
 		}
239 239
 
240 240
 		// update lasso version option
241
-		update_option( 'lasso_version', LASSO_VERSION );
241
+		update_option('lasso_version', LASSO_VERSION);
242 242
 
243 243
 		// set transietn for activation welcome
244
-		set_transient( '_lasso_welcome_redirect', true, 30 );
244
+		set_transient('_lasso_welcome_redirect', true, 30);
245 245
 
246 246
 
247 247
 	}
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
 	public function load_plugin_textdomain() {
264 264
 
265 265
 		$domain = $this->plugin_slug;
266
-		$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
266
+		$locale = apply_filters('plugin_locale', get_locale(), $domain);
267 267
 
268
-		$out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' );
268
+		$out = load_textdomain($domain, trailingslashit(LASSO_DIR).'languages/'.$domain.'-'.$locale.'.mo');
269 269
 	}
270 270
 	
271 271
     // new ajax function to lock post for editing
272 272
 	public function editus_lock_post()
273 273
 	{
274
-		$post_id= $_POST["postid"];
274
+		$post_id = $_POST["postid"];
275 275
 		$locked = wp_check_post_lock($post_id);
276 276
 		
277 277
 		if (!$locked) {
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 			echo "true";
280 280
 		} else {
281 281
 			$user_info = get_userdata($locked);
282
-			echo "Post opened by ".$user_info->first_name .  " " . $user_info->last_name;
282
+			echo "Post opened by ".$user_info->first_name." ".$user_info->last_name;
283 283
 		}
284 284
 		exit;
285 285
 	}
286 286
 	
287 287
 	public function editus_unlock_post()
288 288
 	{
289
-		$post_id= $_POST["postid"];
289
+		$post_id = $_POST["postid"];
290 290
 		$locked = wp_check_post_lock($post_id);
291
-		delete_post_meta( $post_id, '_edit_lock');
291
+		delete_post_meta($post_id, '_edit_lock');
292 292
 		echo "true";
293 293
 		
294 294
 		exit;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	{
300 300
 		$user_id = get_current_user_ID();
301 301
 				
302
-		update_user_meta( $user_id, 'lasso_hide_tour', true );
302
+		update_user_meta($user_id, 'lasso_hide_tour', true);
303 303
 		exit;
304 304
 	}
305 305
 	
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 		$data = array();
311 311
 		parse_str($_POST['data'], $data);
312 312
 		
313
-		if (!wp_verify_nonce( $data[ 'nonce' ], 'lasso-update-post-settings' )) {
313
+		if (!wp_verify_nonce($data['nonce'], 'lasso-update-post-settings')) {
314 314
 			wp_send_json_error();
315 315
 			exit;
316 316
 		}
317 317
 		
318
-		$status = isset( $data['status'] ) ? $data['status'] : false;
319
-		$postid = isset( $data['postid'] ) ? $data['postid'] : false;
320
-		$slug   = isset( $data['story_slug'] ) ? $data['story_slug'] : false;
318
+		$status = isset($data['status']) ? $data['status'] : false;
319
+		$postid = isset($data['postid']) ? $data['postid'] : false;
320
+		$slug   = isset($data['story_slug']) ? $data['story_slug'] : false;
321 321
 	
322 322
 
323 323
 		$args = array(
@@ -328,24 +328,24 @@  discard block
 block discarded – undo
328 328
 		
329 329
 		
330 330
 
331
-		wp_update_post( apply_filters( 'lasso_object_status_update_args', $args ) );
331
+		wp_update_post(apply_filters('lasso_object_status_update_args', $args));
332 332
 		
333 333
 		// update categories
334
-		$cats  = isset( $data['story_cats'] ) ? $data['story_cats'] : false;
334
+		$cats = isset($data['story_cats']) ? $data['story_cats'] : false;
335 335
 		
336
-		self::set_post_terms( $postid, $cats, 'category' );
336
+		self::set_post_terms($postid, $cats, 'category');
337 337
 		
338 338
 		// update tags
339
-		$tags = isset( $data['story_tags'] ) ? $data['story_tags'] : false;
340
-		self::set_post_terms( $postid, $tags, 'post_tag' );
339
+		$tags = isset($data['story_tags']) ? $data['story_tags'] : false;
340
+		self::set_post_terms($postid, $tags, 'post_tag');
341 341
 		
342 342
 		//update date
343
-		$date  = isset( $data['post_date'] ) ? $data['post_date'] : false;
344
-		self::set_date( $postid, $date );
343
+		$date = isset($data['post_date']) ? $data['post_date'] : false;
344
+		self::set_date($postid, $date);
345 345
 		
346
-		do_action( 'lasso_post_updated', $postid, $slug, $status, get_current_user_ID() );
347
-		$response= array(
348
-			'link'   => get_permalink($postid). (($status=='publish') ? '' : '&preview=true')
346
+		do_action('lasso_post_updated', $postid, $slug, $status, get_current_user_ID());
347
+		$response = array(
348
+			'link'   => get_permalink($postid).(($status == 'publish') ? '' : '&preview=true')
349 349
 		);
350 350
 		wp_send_json_success($response);
351 351
 		exit;
@@ -353,11 +353,11 @@  discard block
 block discarded – undo
353 353
 	
354 354
 	public static function enable_metasave($type)
355 355
 	{
356
-		register_rest_field( $type, 'metadata', array(
357
-			'get_callback' => function ( $data ) {
358
-				return get_post_meta( $data['id']);//, '', '' );
356
+		register_rest_field($type, 'metadata', array(
357
+			'get_callback' => function($data) {
358
+				return get_post_meta($data['id']); //, '', '' );
359 359
 			}, 
360
-			'update_callback' => function( $data, $post ) {
360
+			'update_callback' => function($data, $post) {
361 361
 				foreach ($data as $key => $value) {
362 362
 					update_post_meta($post->ID, $key, $value);
363 363
 				}
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 	public function editus_do_shortcode()
370 370
 	{
371 371
 		
372
-		$code= $_POST["code"];
372
+		$code = $_POST["code"];
373 373
 		$code = str_replace('\"', '"', $code);
374 374
 		
375
-		$code_wrapped = lasso_wrap_shortcodes( $code);
376
-		$out =  do_shortcode($code);
375
+		$code_wrapped = lasso_wrap_shortcodes($code);
376
+		$out = do_shortcode($code);
377 377
 		if ($out != '') {
378
-			$out =  do_shortcode($code_wrapped);
378
+			$out = do_shortcode($code_wrapped);
379 379
 			echo $out;
380 380
 			exit;
381 381
 		}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		/** @var \WP_Embed $wp_embed */
386 386
 		global $wp_embed;
387 387
 		$wp_embed->post_ID = $_POST["ID"];
388
-		$out =$wp_embed->run_shortcode( $code_wrapped );
388
+		$out = $wp_embed->run_shortcode($code_wrapped);
389 389
 		
390 390
 		echo $out;
391 391
 		exit;
@@ -395,53 +395,53 @@  discard block
 block discarded – undo
395 395
 	{
396 396
 		
397 397
 		
398
-		$code= $_POST["code"];
398
+		$code = $_POST["code"];
399 399
 		$atts = array(
400 400
 		 );
401 401
 		foreach ($_POST as $key => $value) {
402
-			if ($key !="code" && $key !="action") {
402
+			if ($key != "code" && $key != "action") {
403 403
 			    //$shortcode = $shortcode.$key.'="'.$value.'" ';
404 404
 				$atts[$key] = $value;
405 405
 			}
406 406
 		}
407 407
 		if ($code == "aesop_video") {
408
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
408
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
409 409
 		    echo aesop_video_shortcode($atts);
410 410
 		}
411 411
 		else if ($code == "aesop_image") {
412
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
412
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
413 413
 		    echo aesop_image_shortcode($atts);
414 414
 		}
415 415
 		else if ($code == "aesop_quote") {
416
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
416
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
417 417
 		    echo aesop_quote_shortcode($atts);
418 418
 		}
419 419
 		else if ($code == "aesop_parallax") {
420
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
420
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
421 421
 		    echo aesop_parallax_shortcode($atts);
422 422
 		}
423 423
 		else if ($code == "aesop_character") {
424
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
424
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
425 425
 		    echo aesop_character_shortcode($atts);
426 426
 		}
427 427
 		else if ($code == "aesop_collection") {
428
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
428
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
429 429
 		    echo aesop_collection_shortcode($atts);
430 430
 		}
431 431
 		else if ($code == "aesop_chapter") {
432
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
432
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
433 433
 		    echo aesop_chapter_shortcode($atts);
434 434
 		}
435 435
 		else if ($code == "aesop_content") {
436
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
436
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
437 437
 		    echo aesop_content_shortcode($atts, $atts['content_data']);
438 438
 		}
439 439
 		else if ($code == "aesop_gallery") {
440
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
441
-		    echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]');
440
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
441
+		    echo do_shortcode('[aesop_gallery id="'.$atts["id"].'"]');
442 442
 		}
443 443
 		else if ($code == "aesop_audio") {
444
-		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
444
+		    require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
445 445
 		    echo aesop_audio_shortcode($atts);
446 446
 		}
447 447
 		else {
@@ -462,20 +462,20 @@  discard block
 block discarded – undo
462 462
 	public function get_ase_options()
463 463
 	{
464 464
 		$blob = lasso_editor_options_blob();
465
-		$code= $_POST["component"];
465
+		$code = $_POST["component"];
466 466
 		echo $blob[$code];
467 467
 		exit; 
468 468
 	}
469 469
 	
470 470
 	public function delete_post( ) {
471 471
 
472
-		$postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false;
472
+		$postid = isset($_POST['postid']) ? $_POST['postid'] : false;
473 473
 
474 474
 		// bail out if the current user can't publish posts
475
-		if ( !lasso_user_can( 'delete_post', $postid ) )
475
+		if (!lasso_user_can('delete_post', $postid))
476 476
 			return;
477 477
 		
478
-		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_delete_post' )) {
478
+		if (!wp_verify_nonce($_POST['nonce'], 'lasso_delete_post')) {
479 479
 			wp_send_json_error();
480 480
 			exit;
481 481
 		}
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 			'post_status' 	=> 'trash'
486 486
 		);
487 487
 
488
-		wp_update_post( apply_filters( 'lasso_object_deleted_args', $args ) );
488
+		wp_update_post(apply_filters('lasso_object_deleted_args', $args));
489 489
 
490
-		do_action( 'lasso_object_deleted', $postid, get_current_user_ID() );
490
+		do_action('lasso_object_deleted', $postid, get_current_user_ID());
491 491
 
492 492
 		exit;
493 493
 	}
@@ -495,40 +495,40 @@  discard block
 block discarded – undo
495 495
     /* This function doesn't actually publish post, but should be called when a post is published */
496 496
     public function publish_post( ) {
497 497
 
498
-		$post_id = isset( $_POST['postid'] ) ? $_POST['postid'] : false;
498
+		$post_id = isset($_POST['postid']) ? $_POST['postid'] : false;
499 499
         
500
-        do_action( 'transition_post_status', 'publish', 'draft', get_post( $post_id ) );
500
+        do_action('transition_post_status', 'publish', 'draft', get_post($post_id));
501 501
 
502 502
 		exit;
503 503
 	}
504 504
 	
505 505
 	public function set_featured_img( ) {
506 506
 
507
-		$postid  	= isset( $_POST['postid'] ) ? $_POST['postid'] : false;
508
-		$image_id  	= isset( $_POST['image_id'] ) ? absint( $_POST['image_id'] ) : false;
509
-		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_gallery' )) {
507
+		$postid = isset($_POST['postid']) ? $_POST['postid'] : false;
508
+		$image_id = isset($_POST['image_id']) ? absint($_POST['image_id']) : false;
509
+		if (!wp_verify_nonce($_POST['nonce'], 'lasso_gallery')) {
510 510
 			wp_send_json_error();
511 511
 			exit;
512 512
 		}	
513 513
 
514
-		set_post_thumbnail( $postid, $image_id );
514
+		set_post_thumbnail($postid, $image_id);
515 515
 
516
-		do_action( 'lasso_featured_image_set', $postid, $image_id, get_current_user_ID() );
516
+		do_action('lasso_featured_image_set', $postid, $image_id, get_current_user_ID());
517 517
 
518 518
 		exit;
519 519
 	}
520 520
 	
521 521
 	public function del_featured_img( ) {
522 522
 
523
-		$postid  = isset( $_POST['postid'] ) ? $_POST['postid'] : false;
524
-		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_gallery' )) {
523
+		$postid = isset($_POST['postid']) ? $_POST['postid'] : false;
524
+		if (!wp_verify_nonce($_POST['nonce'], 'lasso_gallery')) {
525 525
 			wp_send_json_error();
526 526
 			exit;
527 527
 		}	
528 528
 
529
-		delete_post_thumbnail( $postid );
529
+		delete_post_thumbnail($postid);
530 530
 
531
-		do_action( 'lasso_featured_image_deleted', $postid, get_current_user_ID() );
531
+		do_action('lasso_featured_image_deleted', $postid, get_current_user_ID());
532 532
 
533 533
 		exit;
534 534
 	}
@@ -549,17 +549,17 @@  discard block
 block discarded – undo
549 549
 		return self::$revisions;
550 550
 	}*/
551 551
 	
552
-	public function set_post_terms( $postid, $value, $taxonomy ) {
553
-		if( $value ) {
554
-			$value = explode( ',', $value );
555
-			$allow_new_category = lasso_editor_get_option( 'allow_new_category', 'lasso_editor' );
552
+	public function set_post_terms($postid, $value, $taxonomy) {
553
+		if ($value) {
554
+			$value = explode(',', $value);
555
+			$allow_new_category = lasso_editor_get_option('allow_new_category', 'lasso_editor');
556 556
 			
557
-			if ($taxonomy =='category') {
557
+			if ($taxonomy == 'category') {
558 558
                 // convert from names to category ids
559 559
 				$cats = array();
560 560
 				foreach ($value as $cat) {
561 561
 					$cat_id = get_cat_ID($cat);
562
-					if ($cat_id !=0) {
562
+					if ($cat_id != 0) {
563 563
 						$cats [] = $cat_id;
564 564
 					} else if ($allow_new_category) {
565 565
 					    $cats [] = wp_create_category($cat);
@@ -568,47 +568,47 @@  discard block
 block discarded – undo
568 568
 				$value = $cats;
569 569
 			}
570 570
 	
571
-			$result = wp_set_object_terms( $postid, $value, $taxonomy );
571
+			$result = wp_set_object_terms($postid, $value, $taxonomy);
572 572
 		}
573
-		else  {
573
+		else {
574 574
 			//remove all terms from post
575
-			$result = wp_set_object_terms( $postid, null, $taxonomy );
575
+			$result = wp_set_object_terms($postid, null, $taxonomy);
576 576
 		}
577 577
 
578
-		if ( ! is_wp_error( $result ) ) {
578
+		if (!is_wp_error($result)) {
579 579
 			return true;
580
-		}else{
580
+		} else {
581 581
 			return false;
582 582
 		}
583 583
 	}
584 584
 	
585
-	function getEnglishMonthName($foreignMonthName){
585
+	function getEnglishMonthName($foreignMonthName) {
586 586
 
587 587
 		  setlocale(LC_ALL, 'en_US');
588 588
 
589
-		  $month_numbers = range(1,12);
589
+		  $month_numbers = range(1, 12);
590 590
 
591
-		  foreach($month_numbers as $month)
592
-			$english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011));
591
+		  foreach ($month_numbers as $month)
592
+			$english_months[] = strftime('%B', mktime(0, 0, 0, $month, 1, 2011));
593 593
 
594 594
 		  setlocale(LC_ALL, get_locale());
595 595
 
596
-		  foreach($month_numbers as $month)
597
-			$foreign_months[] = utf8_encode(strftime('%B',mktime(0,0,0,$month,1,2011)));
596
+		  foreach ($month_numbers as $month)
597
+			$foreign_months[] = utf8_encode(strftime('%B', mktime(0, 0, 0, $month, 1, 2011)));
598 598
 
599 599
 		  return str_replace($foreign_months, $english_months, $foreignMonthName);
600 600
 	}
601 601
 
602 602
 
603 603
 	
604
-	public function set_date( $postid, $value) {
605
-		if( $value ) {
606
-			$value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time( 'timestamp', 1 ));
604
+	public function set_date($postid, $value) {
605
+		if ($value) {
606
+			$value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time('timestamp', 1));
607 607
             wp_update_post(
608
-				array (
608
+				array(
609 609
 					'ID'            => $postid, // ID of the post to update
610
-					'post_date'     => date( 'Y-m-d H:i:s',  strtotime($value) ),
611
-					'post_date_gmt'     => gmdate( 'Y-m-d H:i:s',  strtotime($value) ),
610
+					'post_date'     => date('Y-m-d H:i:s', strtotime($value)),
611
+					'post_date_gmt'     => gmdate('Y-m-d H:i:s', strtotime($value)),
612 612
 				)
613 613
 			);
614 614
 		}
Please login to merge, or discard this patch.
Braces   +21 added lines, -29 removed lines patch added patch discarded remove patch
@@ -407,44 +407,34 @@  discard block
 block discarded – undo
407 407
 		if ($code == "aesop_video") {
408 408
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php');
409 409
 		    echo aesop_video_shortcode($atts);
410
-		}
411
-		else if ($code == "aesop_image") {
410
+		} else if ($code == "aesop_image") {
412 411
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php');
413 412
 		    echo aesop_image_shortcode($atts);
414
-		}
415
-		else if ($code == "aesop_quote") {
413
+		} else if ($code == "aesop_quote") {
416 414
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php');
417 415
 		    echo aesop_quote_shortcode($atts);
418
-		}
419
-		else if ($code == "aesop_parallax") {
416
+		} else if ($code == "aesop_parallax") {
420 417
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php');
421 418
 		    echo aesop_parallax_shortcode($atts);
422
-		}
423
-		else if ($code == "aesop_character") {
419
+		} else if ($code == "aesop_character") {
424 420
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php');
425 421
 		    echo aesop_character_shortcode($atts);
426
-		}
427
-		else if ($code == "aesop_collection") {
422
+		} else if ($code == "aesop_collection") {
428 423
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php');
429 424
 		    echo aesop_collection_shortcode($atts);
430
-		}
431
-		else if ($code == "aesop_chapter") {
425
+		} else if ($code == "aesop_chapter") {
432 426
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php');
433 427
 		    echo aesop_chapter_shortcode($atts);
434
-		}
435
-		else if ($code == "aesop_content") {
428
+		} else if ($code == "aesop_content") {
436 429
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php');
437 430
 		    echo aesop_content_shortcode($atts, $atts['content_data']);
438
-		}
439
-		else if ($code == "aesop_gallery") {
431
+		} else if ($code == "aesop_gallery") {
440 432
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php');
441 433
 		    echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]');
442
-		}
443
-		else if ($code == "aesop_audio") {
434
+		} else if ($code == "aesop_audio") {
444 435
 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php');
445 436
 		    echo aesop_audio_shortcode($atts);
446
-		}
447
-		else {
437
+		} else {
448 438
 			$code = '['.$code.' ';
449 439
 			foreach ($atts as $key => $value) {
450 440
 			    $code = ''.$key.'="'.$value.'" ';
@@ -472,8 +462,9 @@  discard block
 block discarded – undo
472 462
 		$postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false;
473 463
 
474 464
 		// bail out if the current user can't publish posts
475
-		if ( !lasso_user_can( 'delete_post', $postid ) )
476
-			return;
465
+		if ( !lasso_user_can( 'delete_post', $postid ) ) {
466
+					return;
467
+		}
477 468
 		
478 469
 		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_delete_post' )) {
479 470
 			wp_send_json_error();
@@ -569,15 +560,14 @@  discard block
 block discarded – undo
569 560
 			}
570 561
 	
571 562
 			$result = wp_set_object_terms( $postid, $value, $taxonomy );
572
-		}
573
-		else  {
563
+		} else  {
574 564
 			//remove all terms from post
575 565
 			$result = wp_set_object_terms( $postid, null, $taxonomy );
576 566
 		}
577 567
 
578 568
 		if ( ! is_wp_error( $result ) ) {
579 569
 			return true;
580
-		}else{
570
+		} else{
581 571
 			return false;
582 572
 		}
583 573
 	}
@@ -588,13 +578,15 @@  discard block
 block discarded – undo
588 578
 
589 579
 		  $month_numbers = range(1,12);
590 580
 
591
-		  foreach($month_numbers as $month)
592
-			$english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011));
581
+		  foreach($month_numbers as $month) {
582
+		  			$english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011));
583
+		  }
593 584
 
594 585
 		  setlocale(LC_ALL, get_locale());
595 586
 
596
-		  foreach($month_numbers as $month)
597
-			$foreign_months[] = utf8_encode(strftime('%B',mktime(0,0,0,$month,1,2011)));
587
+		  foreach($month_numbers as $month) {
588
+		  			$foreign_months[] = utf8_encode(strftime('%B',mktime(0,0,0,$month,1,2011)));
589
+		  }
598 590
 
599 591
 		  return str_replace($foreign_months, $english_months, $foreignMonthName);
600 592
 	}
Please login to merge, or discard this patch.