@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | // Unset post_to_diaspora meta field to prevent mistakenly republishing to diaspora*. |
260 | 260 | $meta = get_post_meta( $post_id, '_wp_to_diaspora', true ); |
261 | - $meta['post_to_diaspora'] = false; |
|
261 | + $meta[ 'post_to_diaspora' ] = false; |
|
262 | 262 | update_post_meta( $post_id, '_wp_to_diaspora', $meta ); |
263 | 263 | |
264 | 264 | return true; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | private function _get_full_content() { |
298 | 298 | // Only allow certain shortcodes. |
299 | 299 | global $shortcode_tags; |
300 | - $shortcode_tags_bkp = []; |
|
300 | + $shortcode_tags_bkp = [ ]; |
|
301 | 301 | |
302 | 302 | foreach ( $shortcode_tags as $shortcode_tag => $shortcode_function ) { |
303 | 303 | if ( ! in_array( $shortcode_tag, apply_filters( 'wp2d_shortcodes_filter', [ 'wp_caption', 'caption', 'gallery' ] ), true ) ) { |
@@ -385,12 +385,12 @@ discard block |
||
385 | 385 | $options = WP2D_Options::instance(); |
386 | 386 | $tags_to_post = $this->tags_to_post; |
387 | 387 | $tags_to_add = ''; |
388 | - $diaspora_tags = []; |
|
388 | + $diaspora_tags = [ ]; |
|
389 | 389 | |
390 | 390 | // Add any diaspora* tags? |
391 | 391 | if ( ! empty( $tags_to_post ) ) { |
392 | 392 | // The diaspora* tags to add to the post. |
393 | - $diaspora_tags_tmp = []; |
|
393 | + $diaspora_tags_tmp = [ ]; |
|
394 | 394 | |
395 | 395 | // Add global tags? |
396 | 396 | $global_tags = $options->get_option( 'global_tags' ); |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | |
417 | 417 | // Get all the tags and list them all nicely in a row. |
418 | 418 | foreach ( $diaspora_tags_tmp as $tag ) { |
419 | - $diaspora_tags[] = '#' . $tag; |
|
419 | + $diaspora_tags[ ] = '#' . $tag; |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | // Add all the found tags. |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | private function _save_to_history( $response ) { |
477 | 477 | // Make sure the post history is an array. |
478 | 478 | if ( empty( $this->post_history ) ) { |
479 | - $this->post_history = []; |
|
479 | + $this->post_history = [ ]; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | // Add a new entry to the history. |
483 | - $this->post_history[] = [ |
|
483 | + $this->post_history[ ] = [ |
|
484 | 484 | 'id' => $response->id, |
485 | 485 | 'guid' => $response->guid, |
486 | 486 | 'created_at' => $this->post->post_modified, |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | $content = do_shortcode( $content ); |
565 | 565 | |
566 | 566 | // If a caption attribute is defined, we'll add it after the image. |
567 | - if ( isset( $attr['caption'] ) && '' !== $attr['caption'] ) { |
|
568 | - $content .= "\n" . $this->get_img_caption( $attr['caption'] ); |
|
567 | + if ( isset( $attr[ 'caption' ] ) && '' !== $attr[ 'caption' ] ) { |
|
568 | + $content .= "\n" . $this->get_img_caption( $attr[ 'caption' ] ); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | return $content; |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | $captiontag = current_theme_supports( 'html5', 'gallery' ) ? 'figcaption' : 'dd'; |
586 | 586 | |
587 | 587 | // User value. |
588 | - if ( isset( $attr['captiontag'] ) ) { |
|
589 | - $captiontag = $attr['captiontag']; |
|
588 | + if ( isset( $attr[ 'captiontag' ] ) ) { |
|
589 | + $captiontag = $attr[ 'captiontag' ]; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // Let WordPress create the regular gallery. |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * @return string Prettified gallery image caption. |
611 | 611 | */ |
612 | 612 | public function custom_gallery_regex_callback( $m ) { |
613 | - return $this->get_img_caption( $m[2] ); |
|
613 | + return $this->get_img_caption( $m[ 2 ] ); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /* |
@@ -653,18 +653,18 @@ discard block |
||
653 | 653 | $options = WP2D_Options::instance(); |
654 | 654 | |
655 | 655 | // Make sure we have some value for post meta fields. |
656 | - $this->custom_tags = $this->custom_tags ?: []; |
|
656 | + $this->custom_tags = $this->custom_tags ? : [ ]; |
|
657 | 657 | |
658 | 658 | // If this post is already published, don't post again to diaspora* by default. |
659 | 659 | $this->post_to_diaspora = ( $this->post_to_diaspora && 'publish' !== get_post_status( $this->ID ) ); |
660 | - $this->aspects = $this->aspects ?: []; |
|
661 | - $this->services = $this->services ?: []; |
|
660 | + $this->aspects = $this->aspects ? : [ ]; |
|
661 | + $this->services = $this->services ? : [ ]; |
|
662 | 662 | |
663 | 663 | // Have we already posted on diaspora*? |
664 | 664 | if ( is_array( $this->post_history ) ) { |
665 | 665 | $latest_post = end( $this->post_history ); |
666 | 666 | ?> |
667 | - <p><a href="<?php echo esc_attr( $latest_post['post_url'] ); ?>" target="_blank"><?php esc_html_e( 'Already posted to diaspora*.', 'wp-to-diaspora' ); ?></a></p> |
|
667 | + <p><a href="<?php echo esc_attr( $latest_post[ 'post_url' ] ); ?>" target="_blank"><?php esc_html_e( 'Already posted to diaspora*.', 'wp-to-diaspora' ); ?></a></p> |
|
668 | 668 | <?php |
669 | 669 | } |
670 | 670 | ?> |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | /* OK, it's safe for us to save the data now. */ |
700 | 700 | |
701 | 701 | // Meta data to save. |
702 | - $meta_to_save = $_POST['wp_to_diaspora_settings']; |
|
702 | + $meta_to_save = $_POST[ 'wp_to_diaspora_settings' ]; |
|
703 | 703 | $options = WP2D_Options::instance(); |
704 | 704 | |
705 | 705 | // Checkboxes. |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | $options->validate_multi_selects( 'tags_to_post', $meta_to_save ); |
713 | 713 | |
714 | 714 | // Save custom tags as array. |
715 | - $options->validate_tags( $meta_to_save['custom_tags'] ); |
|
715 | + $options->validate_tags( $meta_to_save[ 'custom_tags' ] ); |
|
716 | 716 | |
717 | 717 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
718 | - $options->validate_aspects_services( $meta_to_save['aspects'], [ 'public' ] ); |
|
718 | + $options->validate_aspects_services( $meta_to_save[ 'aspects' ], [ 'public' ] ); |
|
719 | 719 | |
720 | 720 | // Clean up the list of services. |
721 | - $options->validate_aspects_services( $meta_to_save['services'] ); |
|
721 | + $options->validate_aspects_services( $meta_to_save[ 'services' ] ); |
|
722 | 722 | |
723 | 723 | // Update the meta data for this post. |
724 | 724 | update_post_meta( $post_id, '_wp_to_diaspora', $meta_to_save ); |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | */ |
734 | 734 | private function _is_safe_to_save() { |
735 | 735 | // Verify that our nonce is set and valid. |
736 | - if ( ! ( isset( $_POST['wp_to_diaspora_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wp_to_diaspora_meta_box_nonce'], 'wp_to_diaspora_meta_box' ) ) ) { |
|
736 | + if ( ! ( isset( $_POST[ 'wp_to_diaspora_meta_box_nonce' ] ) && wp_verify_nonce( $_POST[ 'wp_to_diaspora_meta_box_nonce' ], 'wp_to_diaspora_meta_box' ) ) ) { |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | } |
744 | 744 | |
745 | 745 | // Check the user's permissions. |
746 | - $permission = ( isset( $_POST['post_type'] ) && 'page' === $_POST['post_type'] ) ? 'edit_pages' : 'edit_posts'; |
|
746 | + $permission = ( isset( $_POST[ 'post_type' ] ) && 'page' === $_POST[ 'post_type' ] ) ? 'edit_pages' : 'edit_posts'; |
|
747 | 747 | if ( ! current_user_can( $permission, $this->ID ) ) { |
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
751 | 751 | // Make real sure that we have some meta data to save. |
752 | - if ( ! isset( $_POST['wp_to_diaspora_settings'] ) ) { |
|
752 | + if ( ! isset( $_POST[ 'wp_to_diaspora_settings' ] ) ) { |
|
753 | 753 | return false; |
754 | 754 | } |
755 | 755 | |
@@ -786,10 +786,10 @@ discard block |
||
786 | 786 | $latest_post = end( $diaspora_post_history ); |
787 | 787 | |
788 | 788 | // Only show if this post is showing a message and the post is a fresh share. |
789 | - if ( isset( $_GET['message'] ) && $post->post_modified === $latest_post['created_at'] ) { |
|
789 | + if ( isset( $_GET[ 'message' ] ) && $post->post_modified === $latest_post[ 'created_at' ] ) { |
|
790 | 790 | printf( '<div class="updated notice is-dismissible"><p>%1$s <a href="%2$s" target="_blank">%3$s</a></p></div>', |
791 | 791 | esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ), |
792 | - esc_url( $latest_post['post_url'] ), |
|
792 | + esc_url( $latest_post[ 'post_url' ] ), |
|
793 | 793 | esc_html__( 'View Post' ) |
794 | 794 | ); |
795 | 795 | } |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | */ |
804 | 804 | public function ignore_post_error() { |
805 | 805 | // If "Ignore" link has been clicked, delete the post error meta data. |
806 | - if ( isset( $_GET['wp2d_ignore_post_error'], $_GET['post'] ) ) { |
|
807 | - delete_post_meta( $_GET['post'], '_wp_to_diaspora_post_error' ); |
|
806 | + if ( isset( $_GET[ 'wp2d_ignore_post_error' ], $_GET[ 'post' ] ) ) { |
|
807 | + delete_post_meta( $_GET[ 'post' ], '_wp_to_diaspora_post_error' ); |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | } |