Completed
Push — master ( 728c8e...490197 )
by Armando
01:50 queued 51s
created
lib/class-wp2d-post.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 
230 230
 		// Unset post_to_diaspora meta field to prevent mistakenly republishing to diaspora*.
231 231
 		$meta                     = get_post_meta( $post_id, '_wp_to_diaspora', true );
232
-		$meta['post_to_diaspora'] = false;
232
+		$meta[ 'post_to_diaspora' ] = false;
233 233
 		update_post_meta( $post_id, '_wp_to_diaspora', $meta );
234 234
 
235 235
 		$status_message = $this->get_title_link();
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	private function get_full_content() {
320 320
 		// Only allow certain shortcodes.
321 321
 		global $shortcode_tags;
322
-		$shortcode_tags_bkp = [];
322
+		$shortcode_tags_bkp = [ ];
323 323
 
324 324
 		foreach ( $shortcode_tags as $shortcode_tag => $shortcode_function ) {
325 325
 			if ( ! in_array( $shortcode_tag, apply_filters( 'wp2d_shortcodes_filter', [ 'wp_caption', 'caption', 'gallery' ] ), true ) ) {
@@ -407,12 +407,12 @@  discard block
 block discarded – undo
407 407
 		$options       = WP2D_Options::instance();
408 408
 		$tags_to_post  = $this->tags_to_post;
409 409
 		$tags_to_add   = '';
410
-		$diaspora_tags = [];
410
+		$diaspora_tags = [ ];
411 411
 
412 412
 		// Add any diaspora* tags?
413 413
 		if ( ! empty( $tags_to_post ) ) {
414 414
 			// The diaspora* tags to add to the post.
415
-			$diaspora_tags_tmp = [];
415
+			$diaspora_tags_tmp = [ ];
416 416
 
417 417
 			// Add global tags?
418 418
 			$global_tags = $options->get_option( 'global_tags' );
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 
439 439
 			// Get all the tags and list them all nicely in a row.
440 440
 			foreach ( $diaspora_tags_tmp as $tag ) {
441
-				$diaspora_tags[] = '#' . $tag;
441
+				$diaspora_tags[ ] = '#' . $tag;
442 442
 			}
443 443
 
444 444
 			// Add all the found tags.
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	private function save_to_history( $response ) {
499 499
 		// Make sure the post history is an array.
500 500
 		if ( empty( $this->post_history ) ) {
501
-			$this->post_history = [];
501
+			$this->post_history = [ ];
502 502
 		}
503 503
 
504 504
 		// Add a new entry to the history.
505
-		$this->post_history[] = [
505
+		$this->post_history[ ] = [
506 506
 			'id'         => $response->id,
507 507
 			'guid'       => $response->guid,
508 508
 			'created_at' => $this->post->post_modified,
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 		$content = do_shortcode( $content );
589 589
 
590 590
 		// If a caption attribute is defined, we'll add it after the image.
591
-		if ( isset( $attr['caption'] ) && '' !== $attr['caption'] ) {
592
-			$content .= "\n" . $this->get_img_caption( $attr['caption'] );
591
+		if ( isset( $attr[ 'caption' ] ) && '' !== $attr[ 'caption' ] ) {
592
+			$content .= "\n" . $this->get_img_caption( $attr[ 'caption' ] );
593 593
 		}
594 594
 
595 595
 		return $content;
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	 */
607 607
 	public function custom_gallery_shortcode( $attr ) {
608 608
 		// Try user value and fall back to default value in WordPress.
609
-		$captiontag = $attr['captiontag'] ?? ( current_theme_supports( 'html5', 'gallery' ) ? 'figcaption' : 'dd' );
609
+		$captiontag = $attr[ 'captiontag' ] ?? ( current_theme_supports( 'html5', 'gallery' ) ? 'figcaption' : 'dd' );
610 610
 
611 611
 		// Let WordPress create the regular gallery.
612 612
 		$gallery = gallery_shortcode( $attr );
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 	 * @return string Prettified gallery image caption.
630 630
 	 */
631 631
 	public function custom_gallery_regex_callback( $m ) {
632
-		return $this->get_img_caption( $m[2] );
632
+		return $this->get_img_caption( $m[ 2 ] );
633 633
 	}
634 634
 
635 635
 	/*
@@ -672,18 +672,18 @@  discard block
 block discarded – undo
672 672
 		$options = WP2D_Options::instance();
673 673
 
674 674
 		// Make sure we have some value for post meta fields.
675
-		$this->custom_tags = $this->custom_tags ?: [];
675
+		$this->custom_tags = $this->custom_tags ? : [ ];
676 676
 
677 677
 		// If this post is already published, don't post again to diaspora* by default.
678 678
 		$this->post_to_diaspora = ( $this->post_to_diaspora && 'publish' !== get_post_status( $this->ID ) );
679
-		$this->aspects          = $this->aspects ?: [];
680
-		$this->services         = $this->services ?: [];
679
+		$this->aspects          = $this->aspects ? : [ ];
680
+		$this->services         = $this->services ? : [ ];
681 681
 
682 682
 		// Have we already posted on diaspora*?
683 683
 		$diaspora_post_url = '#';
684 684
 		if ( is_array( $this->post_history ) ) {
685 685
 			$latest_post       = end( $this->post_history );
686
-			$diaspora_post_url = $latest_post['post_url'];
686
+			$diaspora_post_url = $latest_post[ 'post_url' ];
687 687
 		}
688 688
 		?>
689 689
 		<p<?php echo '#' === $diaspora_post_url ? ' style="display: none;"' : ''; ?>><a id="diaspora-post-url" href="<?php echo esc_attr( $diaspora_post_url ); ?>" target="_blank"><?php esc_html_e( 'Already posted to diaspora*.', 'wp-to-diaspora' ); ?></a></p>
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 		/* OK, it's safe for us to save the data now. */
719 719
 
720 720
 		// Meta data to save.
721
-		$meta_to_save = $_POST['wp_to_diaspora_settings']; // phpcs:ignore
721
+		$meta_to_save = $_POST[ 'wp_to_diaspora_settings' ]; // phpcs:ignore
722 722
 		$options      = WP2D_Options::instance();
723 723
 
724 724
 		// Checkboxes.
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 		$options->validate_multi_selects( 'tags_to_post', $meta_to_save );
732 732
 
733 733
 		// Save custom tags as array.
734
-		$options->validate_tags( $meta_to_save['custom_tags'] );
734
+		$options->validate_tags( $meta_to_save[ 'custom_tags' ] );
735 735
 
736 736
 		// Clean up the list of aspects. If the list is empty, only use the 'Public' aspect.
737
-		$options->validate_aspects_services( $meta_to_save['aspects'], [ 'public' ] );
737
+		$options->validate_aspects_services( $meta_to_save[ 'aspects' ], [ 'public' ] );
738 738
 
739 739
 		// Clean up the list of services.
740
-		$options->validate_aspects_services( $meta_to_save['services'] );
740
+		$options->validate_aspects_services( $meta_to_save[ 'services' ] );
741 741
 
742 742
 		// Update the meta data for this post.
743 743
 		update_post_meta( $post_id, '_wp_to_diaspora', $meta_to_save );
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 */
753 753
 	private function is_safe_to_save() {
754 754
 		// Verify that our nonce is set and  valid.
755
-		if ( ! ( isset( $_POST['wp_to_diaspora_meta_box_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_to_diaspora_meta_box_nonce'] ), 'wp_to_diaspora_meta_box' ) ) ) {
755
+		if ( ! ( isset( $_POST[ 'wp_to_diaspora_meta_box_nonce' ] ) && wp_verify_nonce( sanitize_key( $_POST[ 'wp_to_diaspora_meta_box_nonce' ] ), 'wp_to_diaspora_meta_box' ) ) ) {
756 756
 			return false;
757 757
 		}
758 758
 
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 		}
763 763
 
764 764
 		// Check the user's permissions.
765
-		$permission = ( isset( $_POST['post_type'] ) && 'page' === $_POST['post_type'] ) ? 'edit_pages' : 'edit_posts';
765
+		$permission = ( isset( $_POST[ 'post_type' ] ) && 'page' === $_POST[ 'post_type' ] ) ? 'edit_pages' : 'edit_posts';
766 766
 		if ( ! current_user_can( $permission, $this->ID ) ) {
767 767
 			return false;
768 768
 		}
769 769
 
770 770
 		// Make real sure that we have some meta data to save.
771
-		if ( ! isset( $_POST['wp_to_diaspora_settings'] ) ) {
771
+		if ( ! isset( $_POST[ 'wp_to_diaspora_settings' ] ) ) {
772 772
 			return false;
773 773
 		}
774 774
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 				'<div class="error notice is-dismissible"><p>%1$s %2$s %3$s <a href="%4$s">%5$s</a></p></div>',
798 798
 				esc_html__( 'Failed to post to diaspora*.', 'wp-to-diaspora' ),
799 799
 				esc_html( $error->get_error_message() ),
800
-				$help_link,  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
800
+				$help_link, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
801 801
 				esc_url( add_query_arg( 'wp2d_ignore_post_error', '' ) ),
802 802
 				esc_html__( 'Ignore', 'wp-to-diaspora' )
803 803
 			);
@@ -806,11 +806,11 @@  discard block
 block discarded – undo
806 806
 			$latest_post = end( $diaspora_post_history );
807 807
 
808 808
 			// Only show if this post is showing a message and the post is a fresh share.
809
-			if ( isset( $_GET['message'] ) && $post->post_modified === $latest_post['created_at'] ) { // phpcs:ignore
809
+			if ( isset( $_GET[ 'message' ] ) && $post->post_modified === $latest_post[ 'created_at' ] ) { // phpcs:ignore
810 810
 				printf(
811 811
 					'<div class="updated notice is-dismissible"><p>%1$s <a href="%2$s" target="_blank">%3$s</a></p></div>',
812 812
 					esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ),
813
-					esc_url( $latest_post['post_url'] ),
813
+					esc_url( $latest_post[ 'post_url' ] ),
814 814
 					esc_html__( 'View Post', 'wp-to-diaspora' )
815 815
 				);
816 816
 			}
@@ -824,8 +824,8 @@  discard block
 block discarded – undo
824 824
 	 */
825 825
 	public function ignore_post_error() {
826 826
 		// If "Ignore" link has been clicked, delete the post error meta data.
827
-		if ( isset( $_GET['wp2d_ignore_post_error'], $_GET['post'] ) ) { // phpcs:ignore
828
-			delete_post_meta( absint( $_GET['post'] ), '_wp_to_diaspora_post_error' ); // phpcs:ignore
827
+		if ( isset( $_GET[ 'wp2d_ignore_post_error' ], $_GET[ 'post' ] ) ) { // phpcs:ignore
828
+			delete_post_meta( absint( $_GET[ 'post' ] ), '_wp_to_diaspora_post_error' ); // phpcs:ignore
829 829
 		}
830 830
 	}
831 831
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 			] );
842 842
 		}
843 843
 
844
-		$post_id = sanitize_key( $_REQUEST['post_id'] ?? '' );
844
+		$post_id = sanitize_key( $_REQUEST[ 'post_id' ] ?? '' );
845 845
 		if ( ! is_numeric( $post_id ) ) {
846 846
 			return;
847 847
 		}
@@ -858,12 +858,12 @@  discard block
 block discarded – undo
858 858
 			$latest_post = end( $diaspora_post_history );
859 859
 
860 860
 			// Only show if this post is a fresh share.
861
-			if ( get_post( $post_id )->post_modified === $latest_post['created_at'] ) { // phpcs:ignore
861
+			if ( get_post( $post_id )->post_modified === $latest_post[ 'created_at' ] ) { // phpcs:ignore
862 862
 				wp_send_json_success( [
863 863
 					'message' => esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ),
864 864
 					'action'  => [
865 865
 						'label' => esc_html__( 'View Post', 'wp-to-diaspora' ),
866
-						'url'   => esc_url( $latest_post['post_url'] ),
866
+						'url'   => esc_url( $latest_post[ 'post_url' ] ),
867 867
 					],
868 868
 				] );
869 869
 			}
Please login to merge, or discard this patch.