@@ -52,16 +52,16 @@ discard block |
||
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_hide_tour', array( $this, 'editus_hide_tour' ) ); |
|
64 | - add_action( 'wp_ajax_editus_set_post_setting', array( $this, 'editus_set_post_setting' ) ); |
|
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_hide_tour', array($this, 'editus_hide_tour')); |
|
64 | + add_action('wp_ajax_editus_set_post_setting', array($this, 'editus_set_post_setting')); |
|
65 | 65 | |
66 | 66 | // enable saving custom fields through REST API |
67 | 67 | self::enable_metasave('post'); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public static function get_instance() { |
93 | 93 | |
94 | 94 | // If the single instance hasn't been set, set it now. |
95 | - if ( null == self::$instance ) { |
|
95 | + if (null == self::$instance) { |
|
96 | 96 | self::$instance = new self; |
97 | 97 | } |
98 | 98 | |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | * WPMU is disabled or plugin is |
110 | 110 | * activated on an individual blog. |
111 | 111 | */ |
112 | - public static function activate( $network_wide ) { |
|
112 | + public static function activate($network_wide) { |
|
113 | 113 | |
114 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
114 | + if (function_exists('is_multisite') && is_multisite()) { |
|
115 | 115 | |
116 | - if ( $network_wide ) { |
|
116 | + if ($network_wide) { |
|
117 | 117 | |
118 | 118 | // Get all blog ids |
119 | 119 | $blog_ids = self::get_blog_ids(); |
120 | 120 | |
121 | - foreach ( $blog_ids as $blog_id ) { |
|
121 | + foreach ($blog_ids as $blog_id) { |
|
122 | 122 | |
123 | - switch_to_blog( $blog_id ); |
|
123 | + switch_to_blog($blog_id); |
|
124 | 124 | self::single_activate(); |
125 | 125 | } |
126 | 126 | |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | * WPMU is disabled or plugin is |
147 | 147 | * deactivated on an individual blog. |
148 | 148 | */ |
149 | - public static function deactivate( $network_wide ) { |
|
149 | + public static function deactivate($network_wide) { |
|
150 | 150 | |
151 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
151 | + if (function_exists('is_multisite') && is_multisite()) { |
|
152 | 152 | |
153 | - if ( $network_wide ) { |
|
153 | + if ($network_wide) { |
|
154 | 154 | |
155 | 155 | // Get all blog ids |
156 | 156 | $blog_ids = self::get_blog_ids(); |
157 | 157 | |
158 | - foreach ( $blog_ids as $blog_id ) { |
|
158 | + foreach ($blog_ids as $blog_id) { |
|
159 | 159 | |
160 | - switch_to_blog( $blog_id ); |
|
160 | + switch_to_blog($blog_id); |
|
161 | 161 | self::single_deactivate(); |
162 | 162 | |
163 | 163 | } |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param int $blog_id ID of the new blog. |
183 | 183 | */ |
184 | - public function activate_new_site( $blog_id ) { |
|
184 | + public function activate_new_site($blog_id) { |
|
185 | 185 | |
186 | - if ( 1 !== did_action( 'wpmu_new_blog' ) ) { |
|
186 | + if (1 !== did_action('wpmu_new_blog')) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | - switch_to_blog( $blog_id ); |
|
190 | + switch_to_blog($blog_id); |
|
191 | 191 | self::single_activate(); |
192 | 192 | restore_current_blog(); |
193 | 193 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | WHERE archived = '0' AND spam = '0' |
213 | 213 | AND deleted = '0'"; |
214 | 214 | |
215 | - return $wpdb->get_col( $sql ); |
|
215 | + return $wpdb->get_col($sql); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -223,18 +223,18 @@ discard block |
||
223 | 223 | */ |
224 | 224 | private static function single_activate() { |
225 | 225 | |
226 | - $curr_version = get_option( 'lasso_version' ); |
|
226 | + $curr_version = get_option('lasso_version'); |
|
227 | 227 | |
228 | 228 | // update upgraded from |
229 | - if ( $curr_version ) { |
|
230 | - update_option( 'lasso_updated_from', $curr_version ); |
|
229 | + if ($curr_version) { |
|
230 | + update_option('lasso_updated_from', $curr_version); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // update lasso version option |
234 | - update_option( 'lasso_version', LASSO_VERSION ); |
|
234 | + update_option('lasso_version', LASSO_VERSION); |
|
235 | 235 | |
236 | 236 | // set transietn for activation welcome |
237 | - set_transient( '_lasso_welcome_redirect', true, 30 ); |
|
237 | + set_transient('_lasso_welcome_redirect', true, 30); |
|
238 | 238 | |
239 | 239 | |
240 | 240 | } |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | public function load_plugin_textdomain() { |
257 | 257 | |
258 | 258 | $domain = $this->plugin_slug; |
259 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
259 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
260 | 260 | |
261 | - $out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' ); |
|
261 | + $out = load_textdomain($domain, trailingslashit(LASSO_DIR).'languages/'.$domain.'-'.$locale.'.mo'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // new ajax function to lock post for editing |
265 | 265 | public function editus_lock_post() |
266 | 266 | { |
267 | - $post_id= $_POST["postid"]; |
|
267 | + $post_id = $_POST["postid"]; |
|
268 | 268 | $locked = wp_check_post_lock($post_id); |
269 | 269 | |
270 | 270 | if (!$locked) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | echo "true"; |
273 | 273 | } else { |
274 | 274 | $user_info = get_userdata($locked); |
275 | - echo "Post opened by ".$user_info->first_name . " " . $user_info->last_name; |
|
275 | + echo "Post opened by ".$user_info->first_name." ".$user_info->last_name; |
|
276 | 276 | } |
277 | 277 | exit; |
278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | { |
283 | 283 | $user_id = get_current_user_ID(); |
284 | 284 | |
285 | - update_user_meta( $user_id, 'lasso_hide_tour', true ); |
|
285 | + update_user_meta($user_id, 'lasso_hide_tour', true); |
|
286 | 286 | exit; |
287 | 287 | } |
288 | 288 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | $data = array(); |
294 | 294 | parse_str($_POST['data'], $data); |
295 | 295 | |
296 | - if (!wp_verify_nonce( $data[ 'nonce' ], 'lasso-update-post-settings' )) { |
|
296 | + if (!wp_verify_nonce($data['nonce'], 'lasso-update-post-settings')) { |
|
297 | 297 | wp_send_json_error(); |
298 | 298 | exit; |
299 | 299 | } |
300 | 300 | |
301 | - $status = isset( $data['status'] ) ? $data['status'] : false; |
|
302 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
303 | - $slug = isset( $data['story_slug'] ) ? $data['story_slug'] : false; |
|
301 | + $status = isset($data['status']) ? $data['status'] : false; |
|
302 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
303 | + $slug = isset($data['story_slug']) ? $data['story_slug'] : false; |
|
304 | 304 | |
305 | 305 | |
306 | 306 | $args = array( |
@@ -311,33 +311,33 @@ discard block |
||
311 | 311 | |
312 | 312 | |
313 | 313 | |
314 | - wp_update_post( apply_filters( 'lasso_object_status_update_args', $args ) ); |
|
314 | + wp_update_post(apply_filters('lasso_object_status_update_args', $args)); |
|
315 | 315 | |
316 | 316 | // update categories |
317 | - $cats = isset( $data['story_cats'] ) ? $data['story_cats'] : false; |
|
317 | + $cats = isset($data['story_cats']) ? $data['story_cats'] : false; |
|
318 | 318 | |
319 | - self::set_post_terms( $postid, $cats, 'category' ); |
|
319 | + self::set_post_terms($postid, $cats, 'category'); |
|
320 | 320 | |
321 | 321 | // update tags |
322 | - $tags = isset( $data['story_tags'] ) ? $data['story_tags'] : false; |
|
323 | - self::set_post_terms( $postid, $tags, 'post_tag' ); |
|
322 | + $tags = isset($data['story_tags']) ? $data['story_tags'] : false; |
|
323 | + self::set_post_terms($postid, $tags, 'post_tag'); |
|
324 | 324 | |
325 | 325 | //update date |
326 | - $date = isset( $data['post_date'] ) ? $data['post_date'] : false; |
|
327 | - self::set_date( $postid, $date ); |
|
326 | + $date = isset($data['post_date']) ? $data['post_date'] : false; |
|
327 | + self::set_date($postid, $date); |
|
328 | 328 | |
329 | - do_action( 'lasso_post_updated', $postid, $slug, $status, get_current_user_ID() ); |
|
329 | + do_action('lasso_post_updated', $postid, $slug, $status, get_current_user_ID()); |
|
330 | 330 | wp_send_json_success(); |
331 | 331 | exit; |
332 | 332 | } |
333 | 333 | |
334 | 334 | public static function enable_metasave($type) |
335 | 335 | { |
336 | - register_rest_field( $type, 'metadata', array( |
|
337 | - 'get_callback' => function ( $data ) { |
|
338 | - return get_post_meta( $data['id']);//, '', '' ); |
|
336 | + register_rest_field($type, 'metadata', array( |
|
337 | + 'get_callback' => function($data) { |
|
338 | + return get_post_meta($data['id']); //, '', '' ); |
|
339 | 339 | }, |
340 | - 'update_callback' => function( $data, $post ) { |
|
340 | + 'update_callback' => function($data, $post) { |
|
341 | 341 | foreach ($data as $key => $value) { |
342 | 342 | update_post_meta($post->ID, $key, $value); |
343 | 343 | } |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | public function editus_do_shortcode() |
350 | 350 | { |
351 | 351 | |
352 | - $code= $_POST["code"]; |
|
352 | + $code = $_POST["code"]; |
|
353 | 353 | $code = str_replace('\"', '"', $code); |
354 | 354 | |
355 | - $code_wrapped = lasso_wrap_shortcodes( $code); |
|
356 | - $out = do_shortcode($code_wrapped); |
|
355 | + $code_wrapped = lasso_wrap_shortcodes($code); |
|
356 | + $out = do_shortcode($code_wrapped); |
|
357 | 357 | if ($out != '') { |
358 | 358 | echo $out; |
359 | 359 | exit; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | /** @var \WP_Embed $wp_embed */ |
365 | 365 | global $wp_embed; |
366 | 366 | $wp_embed->post_ID = $_POST["ID"]; |
367 | - $out =$wp_embed->run_shortcode( $code ); |
|
367 | + $out = $wp_embed->run_shortcode($code); |
|
368 | 368 | |
369 | 369 | echo $out; |
370 | 370 | exit; |
@@ -374,53 +374,53 @@ discard block |
||
374 | 374 | { |
375 | 375 | |
376 | 376 | |
377 | - $code= $_POST["code"]; |
|
377 | + $code = $_POST["code"]; |
|
378 | 378 | $atts = array( |
379 | 379 | ); |
380 | 380 | foreach ($_POST as $key => $value) { |
381 | - if ($key !="code" && $key !="action") { |
|
381 | + if ($key != "code" && $key != "action") { |
|
382 | 382 | //$shortcode = $shortcode.$key.'="'.$value.'" '; |
383 | 383 | $atts[$key] = $value; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | if ($code == "aesop_video") { |
387 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php'); |
|
387 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php'); |
|
388 | 388 | echo aesop_video_shortcode($atts); |
389 | 389 | } |
390 | 390 | else if ($code == "aesop_image") { |
391 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php'); |
|
391 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php'); |
|
392 | 392 | echo aesop_image_shortcode($atts); |
393 | 393 | } |
394 | 394 | else if ($code == "aesop_quote") { |
395 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php'); |
|
395 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php'); |
|
396 | 396 | echo aesop_quote_shortcode($atts); |
397 | 397 | } |
398 | 398 | else if ($code == "aesop_parallax") { |
399 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php'); |
|
399 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php'); |
|
400 | 400 | echo aesop_parallax_shortcode($atts); |
401 | 401 | } |
402 | 402 | else if ($code == "aesop_character") { |
403 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php'); |
|
403 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php'); |
|
404 | 404 | echo aesop_character_shortcode($atts); |
405 | 405 | } |
406 | 406 | else if ($code == "aesop_collection") { |
407 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php'); |
|
407 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php'); |
|
408 | 408 | echo aesop_collection_shortcode($atts); |
409 | 409 | } |
410 | 410 | else if ($code == "aesop_chapter") { |
411 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php'); |
|
411 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php'); |
|
412 | 412 | echo aesop_chapter_shortcode($atts); |
413 | 413 | } |
414 | 414 | else if ($code == "aesop_content") { |
415 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php'); |
|
415 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php'); |
|
416 | 416 | echo aesop_content_shortcode($atts, $atts['content_data']); |
417 | 417 | } |
418 | 418 | else if ($code == "aesop_gallery") { |
419 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php'); |
|
420 | - echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]'); |
|
419 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php'); |
|
420 | + echo do_shortcode('[aesop_gallery id="'.$atts["id"].'"]'); |
|
421 | 421 | } |
422 | 422 | else if ($code == "aesop_audio") { |
423 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php'); |
|
423 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php'); |
|
424 | 424 | echo aesop_audio_shortcode($atts); |
425 | 425 | } |
426 | 426 | else { |
@@ -436,17 +436,17 @@ discard block |
||
436 | 436 | |
437 | 437 | exit; |
438 | 438 | } |
439 | - public function set_post_terms( $postid, $value, $taxonomy ) { |
|
440 | - if( $value ) { |
|
441 | - $value = explode( ',', $value ); |
|
442 | - $allow_new_category = lasso_editor_get_option( 'allow_new_category', 'lasso_editor' ); |
|
439 | + public function set_post_terms($postid, $value, $taxonomy) { |
|
440 | + if ($value) { |
|
441 | + $value = explode(',', $value); |
|
442 | + $allow_new_category = lasso_editor_get_option('allow_new_category', 'lasso_editor'); |
|
443 | 443 | |
444 | - if ($taxonomy =='category') { |
|
444 | + if ($taxonomy == 'category') { |
|
445 | 445 | // convert from names to category ids |
446 | 446 | $cats = array(); |
447 | 447 | foreach ($value as $cat) { |
448 | 448 | $cat_id = get_cat_ID($cat); |
449 | - if ($cat_id !=0) { |
|
449 | + if ($cat_id != 0) { |
|
450 | 450 | $cats [] = $cat_id; |
451 | 451 | } else if ($allow_new_category) { |
452 | 452 | $cats [] = wp_create_category($cat); |
@@ -455,27 +455,27 @@ discard block |
||
455 | 455 | $value = $cats; |
456 | 456 | } |
457 | 457 | |
458 | - $result = wp_set_object_terms( $postid, $value, $taxonomy ); |
|
458 | + $result = wp_set_object_terms($postid, $value, $taxonomy); |
|
459 | 459 | } |
460 | - else { |
|
460 | + else { |
|
461 | 461 | //remove all terms from post |
462 | - $result = wp_set_object_terms( $postid, null, $taxonomy ); |
|
462 | + $result = wp_set_object_terms($postid, null, $taxonomy); |
|
463 | 463 | } |
464 | 464 | |
465 | - if ( ! is_wp_error( $result ) ) { |
|
465 | + if (!is_wp_error($result)) { |
|
466 | 466 | return true; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | return false; |
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | - public function set_date( $postid, $value) { |
|
473 | - if( $value ) { |
|
472 | + public function set_date($postid, $value) { |
|
473 | + if ($value) { |
|
474 | 474 | wp_update_post( |
475 | - array ( |
|
475 | + array( |
|
476 | 476 | 'ID' => $postid, // ID of the post to update |
477 | - 'post_date' => date( 'Y-m-d H:i:s', strtotime($value) ), |
|
478 | - 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime($value) ), |
|
477 | + 'post_date' => date('Y-m-d H:i:s', strtotime($value)), |
|
478 | + 'post_date_gmt' => gmdate('Y-m-d H:i:s', strtotime($value)), |
|
479 | 479 | ) |
480 | 480 | ); |
481 | 481 | } |