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