@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @since 0.0.1 |
| 82 | 82 | * |
| 83 | - * @return Plugin slug variable. |
|
| 83 | + * @return string slug variable. |
|
| 84 | 84 | */ |
| 85 | 85 | public function get_plugin_slug() { |
| 86 | 86 | return $this->plugin_slug; |
@@ -338,6 +338,9 @@ discard block |
||
| 338 | 338 | exit; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | + /** |
|
| 342 | + * @param string $type |
|
| 343 | + */ |
|
| 341 | 344 | public static function enable_metasave($type) |
| 342 | 345 | { |
| 343 | 346 | register_rest_field( $type, 'metadata', array( |
@@ -526,6 +529,9 @@ discard block |
||
| 526 | 529 | return self::$revisions; |
| 527 | 530 | }*/ |
| 528 | 531 | |
| 532 | + /** |
|
| 533 | + * @param string $taxonomy |
|
| 534 | + */ |
|
| 529 | 535 | public function set_post_terms( $postid, $value, $taxonomy ) { |
| 530 | 536 | if( $value ) { |
| 531 | 537 | $value = explode( ',', $value ); |
@@ -52,20 +52,20 @@ 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' ) ); |
|
| 65 | - add_action( 'wp_ajax_editus_get_ase_options', array( $this, 'get_ase_options' ) ); |
|
| 66 | - add_action( 'wp_ajax_editus_delete_post', array( $this, 'delete_post' ) ); |
|
| 67 | - add_action( 'wp_ajax_editus_featured_img', array( $this, 'set_featured_img' ) ); |
|
| 68 | - 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_hide_tour', array($this, 'editus_hide_tour')); |
|
| 64 | + add_action('wp_ajax_editus_set_post_setting', array($this, 'editus_set_post_setting')); |
|
| 65 | + add_action('wp_ajax_editus_get_ase_options', array($this, 'get_ase_options')); |
|
| 66 | + add_action('wp_ajax_editus_delete_post', array($this, 'delete_post')); |
|
| 67 | + add_action('wp_ajax_editus_featured_img', array($this, 'set_featured_img')); |
|
| 68 | + add_action('wp_ajax_editus_del_featured_img', array($this, 'del_featured_img')); |
|
| 69 | 69 | |
| 70 | 70 | // enable saving custom fields through REST API |
| 71 | 71 | self::enable_metasave('post'); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public static function get_instance() { |
| 97 | 97 | |
| 98 | 98 | // If the single instance hasn't been set, set it now. |
| 99 | - if ( null == self::$instance ) { |
|
| 99 | + if (null == self::$instance) { |
|
| 100 | 100 | self::$instance = new self; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | * WPMU is disabled or plugin is |
| 114 | 114 | * activated on an individual blog. |
| 115 | 115 | */ |
| 116 | - public static function activate( $network_wide ) { |
|
| 116 | + public static function activate($network_wide) { |
|
| 117 | 117 | |
| 118 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 118 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 119 | 119 | |
| 120 | - if ( $network_wide ) { |
|
| 120 | + if ($network_wide) { |
|
| 121 | 121 | |
| 122 | 122 | // Get all blog ids |
| 123 | 123 | $blog_ids = self::get_blog_ids(); |
| 124 | 124 | |
| 125 | - foreach ( $blog_ids as $blog_id ) { |
|
| 125 | + foreach ($blog_ids as $blog_id) { |
|
| 126 | 126 | |
| 127 | - switch_to_blog( $blog_id ); |
|
| 127 | + switch_to_blog($blog_id); |
|
| 128 | 128 | self::single_activate(); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | * WPMU is disabled or plugin is |
| 151 | 151 | * deactivated on an individual blog. |
| 152 | 152 | */ |
| 153 | - public static function deactivate( $network_wide ) { |
|
| 153 | + public static function deactivate($network_wide) { |
|
| 154 | 154 | |
| 155 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 155 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 156 | 156 | |
| 157 | - if ( $network_wide ) { |
|
| 157 | + if ($network_wide) { |
|
| 158 | 158 | |
| 159 | 159 | // Get all blog ids |
| 160 | 160 | $blog_ids = self::get_blog_ids(); |
| 161 | 161 | |
| 162 | - foreach ( $blog_ids as $blog_id ) { |
|
| 162 | + foreach ($blog_ids as $blog_id) { |
|
| 163 | 163 | |
| 164 | - switch_to_blog( $blog_id ); |
|
| 164 | + switch_to_blog($blog_id); |
|
| 165 | 165 | self::single_deactivate(); |
| 166 | 166 | |
| 167 | 167 | } |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @param int $blog_id ID of the new blog. |
| 187 | 187 | */ |
| 188 | - public function activate_new_site( $blog_id ) { |
|
| 188 | + public function activate_new_site($blog_id) { |
|
| 189 | 189 | |
| 190 | - if ( 1 !== did_action( 'wpmu_new_blog' ) ) { |
|
| 190 | + if (1 !== did_action('wpmu_new_blog')) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - switch_to_blog( $blog_id ); |
|
| 194 | + switch_to_blog($blog_id); |
|
| 195 | 195 | self::single_activate(); |
| 196 | 196 | restore_current_blog(); |
| 197 | 197 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | WHERE archived = '0' AND spam = '0' |
| 217 | 217 | AND deleted = '0'"; |
| 218 | 218 | |
| 219 | - return $wpdb->get_col( $sql ); |
|
| 219 | + return $wpdb->get_col($sql); |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
@@ -227,18 +227,18 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | private static function single_activate() { |
| 229 | 229 | |
| 230 | - $curr_version = get_option( 'lasso_version' ); |
|
| 230 | + $curr_version = get_option('lasso_version'); |
|
| 231 | 231 | |
| 232 | 232 | // update upgraded from |
| 233 | - if ( $curr_version ) { |
|
| 234 | - update_option( 'lasso_updated_from', $curr_version ); |
|
| 233 | + if ($curr_version) { |
|
| 234 | + update_option('lasso_updated_from', $curr_version); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // update lasso version option |
| 238 | - update_option( 'lasso_version', LASSO_VERSION ); |
|
| 238 | + update_option('lasso_version', LASSO_VERSION); |
|
| 239 | 239 | |
| 240 | 240 | // set transietn for activation welcome |
| 241 | - set_transient( '_lasso_welcome_redirect', true, 30 ); |
|
| 241 | + set_transient('_lasso_welcome_redirect', true, 30); |
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | 244 | } |
@@ -260,15 +260,15 @@ discard block |
||
| 260 | 260 | public function load_plugin_textdomain() { |
| 261 | 261 | |
| 262 | 262 | $domain = $this->plugin_slug; |
| 263 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
| 263 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
| 264 | 264 | |
| 265 | - $out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' ); |
|
| 265 | + $out = load_textdomain($domain, trailingslashit(LASSO_DIR).'languages/'.$domain.'-'.$locale.'.mo'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // new ajax function to lock post for editing |
| 269 | 269 | public function editus_lock_post() |
| 270 | 270 | { |
| 271 | - $post_id= $_POST["postid"]; |
|
| 271 | + $post_id = $_POST["postid"]; |
|
| 272 | 272 | $locked = wp_check_post_lock($post_id); |
| 273 | 273 | |
| 274 | 274 | if (!$locked) { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | echo "true"; |
| 277 | 277 | } else { |
| 278 | 278 | $user_info = get_userdata($locked); |
| 279 | - echo "Post opened by ".$user_info->first_name . " " . $user_info->last_name; |
|
| 279 | + echo "Post opened by ".$user_info->first_name." ".$user_info->last_name; |
|
| 280 | 280 | } |
| 281 | 281 | exit; |
| 282 | 282 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | { |
| 287 | 287 | $user_id = get_current_user_ID(); |
| 288 | 288 | |
| 289 | - update_user_meta( $user_id, 'lasso_hide_tour', true ); |
|
| 289 | + update_user_meta($user_id, 'lasso_hide_tour', true); |
|
| 290 | 290 | exit; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | $data = array(); |
| 298 | 298 | parse_str($_POST['data'], $data); |
| 299 | 299 | |
| 300 | - if (!wp_verify_nonce( $data[ 'nonce' ], 'lasso-update-post-settings' )) { |
|
| 300 | + if (!wp_verify_nonce($data['nonce'], 'lasso-update-post-settings')) { |
|
| 301 | 301 | wp_send_json_error(); |
| 302 | 302 | exit; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $status = isset( $data['status'] ) ? $data['status'] : false; |
|
| 306 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
| 307 | - $slug = isset( $data['story_slug'] ) ? $data['story_slug'] : false; |
|
| 305 | + $status = isset($data['status']) ? $data['status'] : false; |
|
| 306 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
| 307 | + $slug = isset($data['story_slug']) ? $data['story_slug'] : false; |
|
| 308 | 308 | |
| 309 | 309 | |
| 310 | 310 | $args = array( |
@@ -315,24 +315,24 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | |
| 317 | 317 | |
| 318 | - wp_update_post( apply_filters( 'lasso_object_status_update_args', $args ) ); |
|
| 318 | + wp_update_post(apply_filters('lasso_object_status_update_args', $args)); |
|
| 319 | 319 | |
| 320 | 320 | // update categories |
| 321 | - $cats = isset( $data['story_cats'] ) ? $data['story_cats'] : false; |
|
| 321 | + $cats = isset($data['story_cats']) ? $data['story_cats'] : false; |
|
| 322 | 322 | |
| 323 | - self::set_post_terms( $postid, $cats, 'category' ); |
|
| 323 | + self::set_post_terms($postid, $cats, 'category'); |
|
| 324 | 324 | |
| 325 | 325 | // update tags |
| 326 | - $tags = isset( $data['story_tags'] ) ? $data['story_tags'] : false; |
|
| 327 | - self::set_post_terms( $postid, $tags, 'post_tag' ); |
|
| 326 | + $tags = isset($data['story_tags']) ? $data['story_tags'] : false; |
|
| 327 | + self::set_post_terms($postid, $tags, 'post_tag'); |
|
| 328 | 328 | |
| 329 | 329 | //update date |
| 330 | - $date = isset( $data['post_date'] ) ? $data['post_date'] : false; |
|
| 331 | - self::set_date( $postid, $date ); |
|
| 330 | + $date = isset($data['post_date']) ? $data['post_date'] : false; |
|
| 331 | + self::set_date($postid, $date); |
|
| 332 | 332 | |
| 333 | - do_action( 'lasso_post_updated', $postid, $slug, $status, get_current_user_ID() ); |
|
| 334 | - $response= array( |
|
| 335 | - 'link' => get_permalink($postid). (($status=='publish') ? '' : '&preview=true') |
|
| 333 | + do_action('lasso_post_updated', $postid, $slug, $status, get_current_user_ID()); |
|
| 334 | + $response = array( |
|
| 335 | + 'link' => get_permalink($postid).(($status == 'publish') ? '' : '&preview=true') |
|
| 336 | 336 | ); |
| 337 | 337 | wp_send_json_success($response); |
| 338 | 338 | exit; |
@@ -340,11 +340,11 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | public static function enable_metasave($type) |
| 342 | 342 | { |
| 343 | - register_rest_field( $type, 'metadata', array( |
|
| 344 | - 'get_callback' => function ( $data ) { |
|
| 345 | - return get_post_meta( $data['id']);//, '', '' ); |
|
| 343 | + register_rest_field($type, 'metadata', array( |
|
| 344 | + 'get_callback' => function($data) { |
|
| 345 | + return get_post_meta($data['id']); //, '', '' ); |
|
| 346 | 346 | }, |
| 347 | - 'update_callback' => function( $data, $post ) { |
|
| 347 | + 'update_callback' => function($data, $post) { |
|
| 348 | 348 | foreach ($data as $key => $value) { |
| 349 | 349 | update_post_meta($post->ID, $key, $value); |
| 350 | 350 | } |
@@ -356,13 +356,13 @@ discard block |
||
| 356 | 356 | public function editus_do_shortcode() |
| 357 | 357 | { |
| 358 | 358 | |
| 359 | - $code= $_POST["code"]; |
|
| 359 | + $code = $_POST["code"]; |
|
| 360 | 360 | $code = str_replace('\"', '"', $code); |
| 361 | 361 | |
| 362 | - $code_wrapped = lasso_wrap_shortcodes( $code); |
|
| 363 | - $out = do_shortcode($code); |
|
| 362 | + $code_wrapped = lasso_wrap_shortcodes($code); |
|
| 363 | + $out = do_shortcode($code); |
|
| 364 | 364 | if ($out != '') { |
| 365 | - $out = do_shortcode($code_wrapped); |
|
| 365 | + $out = do_shortcode($code_wrapped); |
|
| 366 | 366 | echo $out; |
| 367 | 367 | exit; |
| 368 | 368 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | /** @var \WP_Embed $wp_embed */ |
| 373 | 373 | global $wp_embed; |
| 374 | 374 | $wp_embed->post_ID = $_POST["ID"]; |
| 375 | - $out =$wp_embed->run_shortcode( $code_wrapped ); |
|
| 375 | + $out = $wp_embed->run_shortcode($code_wrapped); |
|
| 376 | 376 | |
| 377 | 377 | echo $out; |
| 378 | 378 | exit; |
@@ -382,53 +382,53 @@ discard block |
||
| 382 | 382 | { |
| 383 | 383 | |
| 384 | 384 | |
| 385 | - $code= $_POST["code"]; |
|
| 385 | + $code = $_POST["code"]; |
|
| 386 | 386 | $atts = array( |
| 387 | 387 | ); |
| 388 | 388 | foreach ($_POST as $key => $value) { |
| 389 | - if ($key !="code" && $key !="action") { |
|
| 389 | + if ($key != "code" && $key != "action") { |
|
| 390 | 390 | //$shortcode = $shortcode.$key.'="'.$value.'" '; |
| 391 | 391 | $atts[$key] = $value; |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | if ($code == "aesop_video") { |
| 395 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php'); |
|
| 395 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php'); |
|
| 396 | 396 | echo aesop_video_shortcode($atts); |
| 397 | 397 | } |
| 398 | 398 | else if ($code == "aesop_image") { |
| 399 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php'); |
|
| 399 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php'); |
|
| 400 | 400 | echo aesop_image_shortcode($atts); |
| 401 | 401 | } |
| 402 | 402 | else if ($code == "aesop_quote") { |
| 403 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php'); |
|
| 403 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php'); |
|
| 404 | 404 | echo aesop_quote_shortcode($atts); |
| 405 | 405 | } |
| 406 | 406 | else if ($code == "aesop_parallax") { |
| 407 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php'); |
|
| 407 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php'); |
|
| 408 | 408 | echo aesop_parallax_shortcode($atts); |
| 409 | 409 | } |
| 410 | 410 | else if ($code == "aesop_character") { |
| 411 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php'); |
|
| 411 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php'); |
|
| 412 | 412 | echo aesop_character_shortcode($atts); |
| 413 | 413 | } |
| 414 | 414 | else if ($code == "aesop_collection") { |
| 415 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php'); |
|
| 415 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php'); |
|
| 416 | 416 | echo aesop_collection_shortcode($atts); |
| 417 | 417 | } |
| 418 | 418 | else if ($code == "aesop_chapter") { |
| 419 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php'); |
|
| 419 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php'); |
|
| 420 | 420 | echo aesop_chapter_shortcode($atts); |
| 421 | 421 | } |
| 422 | 422 | else if ($code == "aesop_content") { |
| 423 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php'); |
|
| 423 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php'); |
|
| 424 | 424 | echo aesop_content_shortcode($atts, $atts['content_data']); |
| 425 | 425 | } |
| 426 | 426 | else if ($code == "aesop_gallery") { |
| 427 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php'); |
|
| 428 | - echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]'); |
|
| 427 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php'); |
|
| 428 | + echo do_shortcode('[aesop_gallery id="'.$atts["id"].'"]'); |
|
| 429 | 429 | } |
| 430 | 430 | else if ($code == "aesop_audio") { |
| 431 | - require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php'); |
|
| 431 | + require_once(ABSPATH.'/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php'); |
|
| 432 | 432 | echo aesop_audio_shortcode($atts); |
| 433 | 433 | } |
| 434 | 434 | else { |
@@ -449,20 +449,20 @@ discard block |
||
| 449 | 449 | public function get_ase_options() |
| 450 | 450 | { |
| 451 | 451 | $blob = lasso_editor_options_blob(); |
| 452 | - $code= $_POST["component"]; |
|
| 452 | + $code = $_POST["component"]; |
|
| 453 | 453 | echo $blob[$code]; |
| 454 | 454 | exit; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | public function delete_post( ) { |
| 458 | 458 | |
| 459 | - $postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false; |
|
| 459 | + $postid = isset($_POST['postid']) ? $_POST['postid'] : false; |
|
| 460 | 460 | |
| 461 | 461 | // bail out if teh current user can't publish posts |
| 462 | - if ( !lasso_user_can( 'delete_post', $postid ) ) |
|
| 462 | + if (!lasso_user_can('delete_post', $postid)) |
|
| 463 | 463 | return; |
| 464 | 464 | |
| 465 | - if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_delete_post' )) { |
|
| 465 | + if (!wp_verify_nonce($_POST['nonce'], 'lasso_delete_post')) { |
|
| 466 | 466 | wp_send_json_error(); |
| 467 | 467 | exit; |
| 468 | 468 | } |
@@ -472,40 +472,40 @@ discard block |
||
| 472 | 472 | 'post_status' => 'trash' |
| 473 | 473 | ); |
| 474 | 474 | |
| 475 | - wp_update_post( apply_filters( 'lasso_object_deleted_args', $args ) ); |
|
| 475 | + wp_update_post(apply_filters('lasso_object_deleted_args', $args)); |
|
| 476 | 476 | |
| 477 | - do_action( 'lasso_object_deleted', $postid, get_current_user_ID() ); |
|
| 477 | + do_action('lasso_object_deleted', $postid, get_current_user_ID()); |
|
| 478 | 478 | |
| 479 | 479 | exit; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | public function set_featured_img( ) { |
| 483 | 483 | |
| 484 | - $postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false; |
|
| 485 | - $image_id = isset( $_POST['image_id'] ) ? absint( $_POST['image_id'] ) : false; |
|
| 486 | - if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_gallery' )) { |
|
| 484 | + $postid = isset($_POST['postid']) ? $_POST['postid'] : false; |
|
| 485 | + $image_id = isset($_POST['image_id']) ? absint($_POST['image_id']) : false; |
|
| 486 | + if (!wp_verify_nonce($_POST['nonce'], 'lasso_gallery')) { |
|
| 487 | 487 | wp_send_json_error(); |
| 488 | 488 | exit; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - set_post_thumbnail( $postid, $image_id ); |
|
| 491 | + set_post_thumbnail($postid, $image_id); |
|
| 492 | 492 | |
| 493 | - do_action( 'lasso_featured_image_set', $postid, $image_id, get_current_user_ID() ); |
|
| 493 | + do_action('lasso_featured_image_set', $postid, $image_id, get_current_user_ID()); |
|
| 494 | 494 | |
| 495 | 495 | exit; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | public function del_featured_img( ) { |
| 499 | 499 | |
| 500 | - $postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false; |
|
| 501 | - if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_gallery' )) { |
|
| 500 | + $postid = isset($_POST['postid']) ? $_POST['postid'] : false; |
|
| 501 | + if (!wp_verify_nonce($_POST['nonce'], 'lasso_gallery')) { |
|
| 502 | 502 | wp_send_json_error(); |
| 503 | 503 | exit; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - delete_post_thumbnail( $postid ); |
|
| 506 | + delete_post_thumbnail($postid); |
|
| 507 | 507 | |
| 508 | - do_action( 'lasso_featured_image_deleted', $postid, get_current_user_ID() ); |
|
| 508 | + do_action('lasso_featured_image_deleted', $postid, get_current_user_ID()); |
|
| 509 | 509 | |
| 510 | 510 | exit; |
| 511 | 511 | } |
@@ -526,17 +526,17 @@ discard block |
||
| 526 | 526 | return self::$revisions; |
| 527 | 527 | }*/ |
| 528 | 528 | |
| 529 | - public function set_post_terms( $postid, $value, $taxonomy ) { |
|
| 530 | - if( $value ) { |
|
| 531 | - $value = explode( ',', $value ); |
|
| 532 | - $allow_new_category = lasso_editor_get_option( 'allow_new_category', 'lasso_editor' ); |
|
| 529 | + public function set_post_terms($postid, $value, $taxonomy) { |
|
| 530 | + if ($value) { |
|
| 531 | + $value = explode(',', $value); |
|
| 532 | + $allow_new_category = lasso_editor_get_option('allow_new_category', 'lasso_editor'); |
|
| 533 | 533 | |
| 534 | - if ($taxonomy =='category') { |
|
| 534 | + if ($taxonomy == 'category') { |
|
| 535 | 535 | // convert from names to category ids |
| 536 | 536 | $cats = array(); |
| 537 | 537 | foreach ($value as $cat) { |
| 538 | 538 | $cat_id = get_cat_ID($cat); |
| 539 | - if ($cat_id !=0) { |
|
| 539 | + if ($cat_id != 0) { |
|
| 540 | 540 | $cats [] = $cat_id; |
| 541 | 541 | } else if ($allow_new_category) { |
| 542 | 542 | $cats [] = wp_create_category($cat); |
@@ -545,47 +545,47 @@ discard block |
||
| 545 | 545 | $value = $cats; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $result = wp_set_object_terms( $postid, $value, $taxonomy ); |
|
| 548 | + $result = wp_set_object_terms($postid, $value, $taxonomy); |
|
| 549 | 549 | } |
| 550 | - else { |
|
| 550 | + else { |
|
| 551 | 551 | //remove all terms from post |
| 552 | - $result = wp_set_object_terms( $postid, null, $taxonomy ); |
|
| 552 | + $result = wp_set_object_terms($postid, null, $taxonomy); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - if ( ! is_wp_error( $result ) ) { |
|
| 555 | + if (!is_wp_error($result)) { |
|
| 556 | 556 | return true; |
| 557 | - }else{ |
|
| 557 | + } else { |
|
| 558 | 558 | return false; |
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - function getEnglishMonthName($foreignMonthName){ |
|
| 562 | + function getEnglishMonthName($foreignMonthName) { |
|
| 563 | 563 | |
| 564 | 564 | setlocale(LC_ALL, 'en_US'); |
| 565 | 565 | |
| 566 | - $month_numbers = range(1,12); |
|
| 566 | + $month_numbers = range(1, 12); |
|
| 567 | 567 | |
| 568 | - foreach($month_numbers as $month) |
|
| 569 | - $english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); |
|
| 568 | + foreach ($month_numbers as $month) |
|
| 569 | + $english_months[] = strftime('%B', mktime(0, 0, 0, $month, 1, 2011)); |
|
| 570 | 570 | |
| 571 | 571 | setlocale(LC_ALL, get_locale()); |
| 572 | 572 | |
| 573 | - foreach($month_numbers as $month) |
|
| 574 | - $foreign_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); |
|
| 573 | + foreach ($month_numbers as $month) |
|
| 574 | + $foreign_months[] = strftime('%B', mktime(0, 0, 0, $month, 1, 2011)); |
|
| 575 | 575 | |
| 576 | 576 | return str_replace($foreign_months, $english_months, $foreignMonthName); |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | |
| 580 | 580 | |
| 581 | - public function set_date( $postid, $value) { |
|
| 582 | - if( $value ) { |
|
| 583 | - $value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time( 'timestamp', 1 )); |
|
| 581 | + public function set_date($postid, $value) { |
|
| 582 | + if ($value) { |
|
| 583 | + $value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time('timestamp', 1)); |
|
| 584 | 584 | wp_update_post( |
| 585 | - array ( |
|
| 585 | + array( |
|
| 586 | 586 | 'ID' => $postid, // ID of the post to update |
| 587 | - 'post_date' => date( 'Y-m-d H:i:s', strtotime($value) ), |
|
| 588 | - 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime($value) ), |
|
| 587 | + 'post_date' => date('Y-m-d H:i:s', strtotime($value)), |
|
| 588 | + 'post_date_gmt' => gmdate('Y-m-d H:i:s', strtotime($value)), |
|
| 589 | 589 | ) |
| 590 | 590 | ); |
| 591 | 591 | } |
@@ -394,44 +394,34 @@ discard block |
||
| 394 | 394 | if ($code == "aesop_video") { |
| 395 | 395 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php'); |
| 396 | 396 | echo aesop_video_shortcode($atts); |
| 397 | - } |
|
| 398 | - else if ($code == "aesop_image") { |
|
| 397 | + } else if ($code == "aesop_image") { |
|
| 399 | 398 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php'); |
| 400 | 399 | echo aesop_image_shortcode($atts); |
| 401 | - } |
|
| 402 | - else if ($code == "aesop_quote") { |
|
| 400 | + } else if ($code == "aesop_quote") { |
|
| 403 | 401 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php'); |
| 404 | 402 | echo aesop_quote_shortcode($atts); |
| 405 | - } |
|
| 406 | - else if ($code == "aesop_parallax") { |
|
| 403 | + } else if ($code == "aesop_parallax") { |
|
| 407 | 404 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php'); |
| 408 | 405 | echo aesop_parallax_shortcode($atts); |
| 409 | - } |
|
| 410 | - else if ($code == "aesop_character") { |
|
| 406 | + } else if ($code == "aesop_character") { |
|
| 411 | 407 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php'); |
| 412 | 408 | echo aesop_character_shortcode($atts); |
| 413 | - } |
|
| 414 | - else if ($code == "aesop_collection") { |
|
| 409 | + } else if ($code == "aesop_collection") { |
|
| 415 | 410 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php'); |
| 416 | 411 | echo aesop_collection_shortcode($atts); |
| 417 | - } |
|
| 418 | - else if ($code == "aesop_chapter") { |
|
| 412 | + } else if ($code == "aesop_chapter") { |
|
| 419 | 413 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php'); |
| 420 | 414 | echo aesop_chapter_shortcode($atts); |
| 421 | - } |
|
| 422 | - else if ($code == "aesop_content") { |
|
| 415 | + } else if ($code == "aesop_content") { |
|
| 423 | 416 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php'); |
| 424 | 417 | echo aesop_content_shortcode($atts, $atts['content_data']); |
| 425 | - } |
|
| 426 | - else if ($code == "aesop_gallery") { |
|
| 418 | + } else if ($code == "aesop_gallery") { |
|
| 427 | 419 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php'); |
| 428 | 420 | echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]'); |
| 429 | - } |
|
| 430 | - else if ($code == "aesop_audio") { |
|
| 421 | + } else if ($code == "aesop_audio") { |
|
| 431 | 422 | require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php'); |
| 432 | 423 | echo aesop_audio_shortcode($atts); |
| 433 | - } |
|
| 434 | - else { |
|
| 424 | + } else { |
|
| 435 | 425 | $code = '['.$code.' '; |
| 436 | 426 | foreach ($atts as $key => $value) { |
| 437 | 427 | $code = ''.$key.'="'.$value.'" '; |
@@ -459,8 +449,9 @@ discard block |
||
| 459 | 449 | $postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false; |
| 460 | 450 | |
| 461 | 451 | // bail out if teh current user can't publish posts |
| 462 | - if ( !lasso_user_can( 'delete_post', $postid ) ) |
|
| 463 | - return; |
|
| 452 | + if ( !lasso_user_can( 'delete_post', $postid ) ) { |
|
| 453 | + return; |
|
| 454 | + } |
|
| 464 | 455 | |
| 465 | 456 | if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_delete_post' )) { |
| 466 | 457 | wp_send_json_error(); |
@@ -546,15 +537,14 @@ discard block |
||
| 546 | 537 | } |
| 547 | 538 | |
| 548 | 539 | $result = wp_set_object_terms( $postid, $value, $taxonomy ); |
| 549 | - } |
|
| 550 | - else { |
|
| 540 | + } else { |
|
| 551 | 541 | //remove all terms from post |
| 552 | 542 | $result = wp_set_object_terms( $postid, null, $taxonomy ); |
| 553 | 543 | } |
| 554 | 544 | |
| 555 | 545 | if ( ! is_wp_error( $result ) ) { |
| 556 | 546 | return true; |
| 557 | - }else{ |
|
| 547 | + } else{ |
|
| 558 | 548 | return false; |
| 559 | 549 | } |
| 560 | 550 | } |
@@ -565,13 +555,15 @@ discard block |
||
| 565 | 555 | |
| 566 | 556 | $month_numbers = range(1,12); |
| 567 | 557 | |
| 568 | - foreach($month_numbers as $month) |
|
| 569 | - $english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); |
|
| 558 | + foreach($month_numbers as $month) { |
|
| 559 | + $english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); |
|
| 560 | + } |
|
| 570 | 561 | |
| 571 | 562 | setlocale(LC_ALL, get_locale()); |
| 572 | 563 | |
| 573 | - foreach($month_numbers as $month) |
|
| 574 | - $foreign_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); |
|
| 564 | + foreach($month_numbers as $month) { |
|
| 565 | + $foreign_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); |
|
| 566 | + } |
|
| 575 | 567 | |
| 576 | 568 | return str_replace($foreign_months, $english_months, $foreignMonthName); |
| 577 | 569 | } |
@@ -18,27 +18,27 @@ discard block |
||
| 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.0.8.3' ); |
|
| 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.0.8.3'); |
|
| 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 |
||
| 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; |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | )); |
| 68 | 68 | |
| 69 | 69 | // Gutenberg |
| 70 | -if( function_exists( 'is_gutenberg_page' ) ) { |
|
| 71 | - function add_raw_to_post( $response, $post, $request ) { |
|
| 70 | +if (function_exists('is_gutenberg_page')) { |
|
| 71 | + function add_raw_to_post($response, $post, $request) { |
|
| 72 | 72 | $response_data = $response->get_data(); |
| 73 | - if ( is_array( $response_data['content'] )) { |
|
| 74 | - $response_data['content']['raw'] = $post->post_content ; |
|
| 75 | - $response->set_data( $response_data ); |
|
| 73 | + if (is_array($response_data['content'])) { |
|
| 74 | + $response_data['content']['raw'] = $post->post_content; |
|
| 75 | + $response->set_data($response_data); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $response; |
| 79 | 79 | } |
| 80 | - add_filter( "rest_prepare_post", 'add_raw_to_post', 10, 3 ); |
|
| 80 | + add_filter("rest_prepare_post", 'add_raw_to_post', 10, 3); |
|
| 81 | 81 | } |
| 82 | 82 | |